Add new (App/Window/View)Activatable interfaces for plugins
Currently only the modelines and filebrowser plugins are updated to these new interfaces
This commit is contained in:
@@ -1,26 +1,9 @@
|
||||
DIST_SUBDIRS = \
|
||||
changecase \
|
||||
docinfo \
|
||||
filebrowser \
|
||||
modelines \
|
||||
sort \
|
||||
spell \
|
||||
taglist \
|
||||
time \
|
||||
trailsave
|
||||
DIST_SUBDIRS = \
|
||||
filebrowser \
|
||||
modelines
|
||||
|
||||
SUBDIRS = \
|
||||
changecase \
|
||||
docinfo \
|
||||
filebrowser \
|
||||
modelines \
|
||||
sort \
|
||||
taglist \
|
||||
time \
|
||||
trailsave
|
||||
|
||||
if ENABLE_ENCHANT
|
||||
SUBDIRS += spell
|
||||
endif
|
||||
SUBDIRS = \
|
||||
filebrowser \
|
||||
modelines
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
@@ -77,7 +77,7 @@ struct _XedFileBookmarksStoreClass
|
||||
};
|
||||
|
||||
GType xed_file_bookmarks_store_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_bookmarks_store_register_type (GTypeModule * module);
|
||||
void _xed_file_bookmarks_store_register_type (GTypeModule *type_module);
|
||||
|
||||
XedFileBookmarksStore *xed_file_bookmarks_store_new (void);
|
||||
gchar *xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model,
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,7 @@ G_BEGIN_DECLS
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XED_TYPE_FILE_BROWSER_PLUGIN (xed_file_browser_plugin_get_type ())
|
||||
#define XED_FILE_BROWSER_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_FILE_BROWSER_PLUGIN, XedFileBrowserPlugin))
|
||||
#define XED_FILE_BROWSER_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_FILE_BROWSER_PLUGIN, XedFileBrowserPlugin))
|
||||
#define XED_FILE_BROWSER_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_FILE_BROWSER_PLUGIN, XedFileBrowserPluginClass))
|
||||
#define XED_IS_FILE_BROWSER_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XED_TYPE_FILE_BROWSER_PLUGIN))
|
||||
#define XED_IS_FILE_BROWSER_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_FILE_BROWSER_PLUGIN))
|
||||
@@ -65,7 +65,7 @@ struct _XedFileBrowserPluginClass
|
||||
GType xed_file_browser_plugin_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* All the plugins must implement this function */
|
||||
G_MODULE_EXPORT void peas_register_types (PeasObjectModule * module);
|
||||
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __XED_FILE_BROWSER_PLUGIN_H__ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -81,10 +81,9 @@ typedef struct _XedFileBrowserStore XedFileBrowserStore;
|
||||
typedef struct _XedFileBrowserStoreClass XedFileBrowserStoreClass;
|
||||
typedef struct _XedFileBrowserStorePrivate XedFileBrowserStorePrivate;
|
||||
|
||||
typedef gboolean (*XedFileBrowserStoreFilterFunc) (XedFileBrowserStore
|
||||
* model,
|
||||
GtkTreeIter * iter,
|
||||
gpointer user_data);
|
||||
typedef gboolean (*XedFileBrowserStoreFilterFunc) (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
struct _XedFileBrowserStore
|
||||
{
|
||||
@@ -97,102 +96,91 @@ struct _XedFileBrowserStoreClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (*begin_loading) (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter);
|
||||
void (*end_loading) (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter);
|
||||
void (*error) (XedFileBrowserStore * model,
|
||||
guint code,
|
||||
gchar * message);
|
||||
gboolean (*no_trash) (XedFileBrowserStore * model,
|
||||
GList * files);
|
||||
void (*rename) (XedFileBrowserStore * model,
|
||||
const gchar * olduri,
|
||||
const gchar * newuri);
|
||||
void (*begin_refresh) (XedFileBrowserStore * model);
|
||||
void (*end_refresh) (XedFileBrowserStore * model);
|
||||
void (*unload) (XedFileBrowserStore * model,
|
||||
const gchar * uri);
|
||||
void (*begin_loading) (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
void (*end_loading) (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
void (*error) (XedFileBrowserStore *model,
|
||||
guint code,
|
||||
gchar *message);
|
||||
gboolean (*no_trash) (XedFileBrowserStore *model,
|
||||
GList *files);
|
||||
void (*rename) (XedFileBrowserStore *model,
|
||||
const gchar *olduri,
|
||||
const gchar *newuri);
|
||||
void (*begin_refresh) (XedFileBrowserStore *model);
|
||||
void (*end_refresh) (XedFileBrowserStore *model);
|
||||
void (*unload) (XedFileBrowserStore *model,
|
||||
const gchar *uri);
|
||||
};
|
||||
|
||||
GType xed_file_browser_store_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_browser_store_register_type (GTypeModule * module);
|
||||
GType xed_file_browser_store_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_browser_store_register_type (GTypeModule *type_module);
|
||||
|
||||
XedFileBrowserStore *xed_file_browser_store_new (gchar const *root);
|
||||
XedFileBrowserStore *xed_file_browser_store_new (gchar const *root);
|
||||
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore * model,
|
||||
gchar const *root,
|
||||
gchar const *virtual_root);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_root (XedFileBrowserStore * model,
|
||||
gchar const *root);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_virtual_root (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_virtual_root_from_string (XedFileBrowserStore * model,
|
||||
gchar const *root);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_virtual_root_up (XedFileBrowserStore * model);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_virtual_root_top (XedFileBrowserStore * model);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore *model,
|
||||
gchar const *root,
|
||||
gchar const *virtual_root);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_root (XedFileBrowserStore *model,
|
||||
gchar const *root);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root_from_string (XedFileBrowserStore *model,
|
||||
gchar const *root);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root_up (XedFileBrowserStore *model);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root_top (XedFileBrowserStore *model);
|
||||
|
||||
gboolean
|
||||
xed_file_browser_store_get_iter_virtual_root (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter);
|
||||
gboolean xed_file_browser_store_get_iter_root (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter);
|
||||
gchar * xed_file_browser_store_get_root (XedFileBrowserStore * model);
|
||||
gchar * xed_file_browser_store_get_virtual_root (XedFileBrowserStore * model);
|
||||
gboolean xed_file_browser_store_get_iter_virtual_root (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
gboolean xed_file_browser_store_get_iter_root (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
gchar * xed_file_browser_store_get_root (XedFileBrowserStore *model);
|
||||
gchar * xed_file_browser_store_get_virtual_root (XedFileBrowserStore *model);
|
||||
|
||||
gboolean xed_file_browser_store_iter_equal (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter1,
|
||||
GtkTreeIter * iter2);
|
||||
gboolean xed_file_browser_store_iter_equal (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter1,
|
||||
GtkTreeIter *iter2);
|
||||
|
||||
void xed_file_browser_store_set_value (XedFileBrowserStore * tree_model,
|
||||
GtkTreeIter * iter,
|
||||
gint column,
|
||||
GValue * value);
|
||||
void xed_file_browser_store_set_value (XedFileBrowserStore *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
gint column,
|
||||
GValue *value);
|
||||
|
||||
void _xed_file_browser_store_iter_expanded (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter);
|
||||
void _xed_file_browser_store_iter_collapsed (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter);
|
||||
void _xed_file_browser_store_iter_expanded (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
void _xed_file_browser_store_iter_collapsed (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
|
||||
XedFileBrowserStoreFilterMode
|
||||
xed_file_browser_store_get_filter_mode (XedFileBrowserStore * model);
|
||||
void xed_file_browser_store_set_filter_mode (XedFileBrowserStore * model,
|
||||
XedFileBrowserStoreFilterMode mode);
|
||||
void xed_file_browser_store_set_filter_func (XedFileBrowserStore * model,
|
||||
XedFileBrowserStoreFilterFunc func,
|
||||
gpointer user_data);
|
||||
void xed_file_browser_store_refilter (XedFileBrowserStore * model);
|
||||
XedFileBrowserStoreFilterMode
|
||||
xed_file_browser_store_filter_mode_get_default (void);
|
||||
XedFileBrowserStoreFilterMode xed_file_browser_store_get_filter_mode (XedFileBrowserStore *model);
|
||||
void xed_file_browser_store_set_filter_mode (XedFileBrowserStore *model,
|
||||
XedFileBrowserStoreFilterMode mode);
|
||||
void xed_file_browser_store_set_filter_func (XedFileBrowserStore *model,
|
||||
XedFileBrowserStoreFilterFunc func,
|
||||
gpointer user_data);
|
||||
void xed_file_browser_store_refilter (XedFileBrowserStore *model);
|
||||
XedFileBrowserStoreFilterMode xed_file_browser_store_filter_mode_get_default (void);
|
||||
|
||||
void xed_file_browser_store_refresh (XedFileBrowserStore * model);
|
||||
gboolean xed_file_browser_store_rename (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter,
|
||||
gchar const *new_name,
|
||||
GError ** error);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_delete (XedFileBrowserStore * model,
|
||||
GtkTreeIter * iter,
|
||||
gboolean trash);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_delete_all (XedFileBrowserStore * model,
|
||||
GList *rows,
|
||||
gboolean trash);
|
||||
void xed_file_browser_store_refresh (XedFileBrowserStore * model);
|
||||
gboolean xed_file_browser_store_rename (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter,
|
||||
gchar const *new_name,
|
||||
GError **error);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_delete (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter,
|
||||
gboolean trash);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_delete_all (XedFileBrowserStore *model,
|
||||
GList *rows,
|
||||
gboolean trash);
|
||||
|
||||
gboolean xed_file_browser_store_new_file (XedFileBrowserStore * model,
|
||||
GtkTreeIter * parent,
|
||||
GtkTreeIter * iter);
|
||||
gboolean xed_file_browser_store_new_directory (XedFileBrowserStore * model,
|
||||
GtkTreeIter * parent,
|
||||
GtkTreeIter * iter);
|
||||
gboolean xed_file_browser_store_new_file (XedFileBrowserStore *model,
|
||||
GtkTreeIter *parent,
|
||||
GtkTreeIter *iter);
|
||||
gboolean xed_file_browser_store_new_directory (XedFileBrowserStore *model,
|
||||
GtkTreeIter *parent,
|
||||
GtkTreeIter *iter);
|
||||
|
||||
void xed_file_browser_store_cancel_mount_operation (XedFileBrowserStore *store);
|
||||
void xed_file_browser_store_cancel_mount_operation (XedFileBrowserStore *store);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __XED_FILE_BROWSER_STORE_H__ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,60 +25,61 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#define XED_TYPE_FILE_BROWSER_VIEW (xed_file_browser_view_get_type ())
|
||||
#define XED_FILE_BROWSER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserView))
|
||||
#define XED_FILE_BROWSER_VIEW_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserView const))
|
||||
#define XED_FILE_BROWSER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserViewClass))
|
||||
#define XED_IS_FILE_BROWSER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_FILE_BROWSER_VIEW))
|
||||
#define XED_IS_FILE_BROWSER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_FILE_BROWSER_VIEW))
|
||||
#define XED_FILE_BROWSER_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserViewClass))
|
||||
#define XED_TYPE_FILE_BROWSER_VIEW (xed_file_browser_view_get_type ())
|
||||
#define XED_FILE_BROWSER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserView))
|
||||
#define XED_FILE_BROWSER_VIEW_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserView const))
|
||||
#define XED_FILE_BROWSER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserViewClass))
|
||||
#define XED_IS_FILE_BROWSER_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_FILE_BROWSER_VIEW))
|
||||
#define XED_IS_FILE_BROWSER_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_FILE_BROWSER_VIEW))
|
||||
#define XED_FILE_BROWSER_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserViewClass))
|
||||
|
||||
typedef struct _XedFileBrowserView XedFileBrowserView;
|
||||
typedef struct _XedFileBrowserViewClass XedFileBrowserViewClass;
|
||||
typedef struct _XedFileBrowserViewPrivate XedFileBrowserViewPrivate;
|
||||
|
||||
typedef enum {
|
||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE,
|
||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE
|
||||
typedef enum
|
||||
{
|
||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE,
|
||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE
|
||||
} XedFileBrowserViewClickPolicy;
|
||||
|
||||
struct _XedFileBrowserView
|
||||
{
|
||||
GtkTreeView parent;
|
||||
GtkTreeView parent;
|
||||
|
||||
XedFileBrowserViewPrivate *priv;
|
||||
XedFileBrowserViewPrivate *priv;
|
||||
};
|
||||
|
||||
struct _XedFileBrowserViewClass
|
||||
{
|
||||
GtkTreeViewClass parent_class;
|
||||
GtkTreeViewClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (*error) (XedFileBrowserView * filetree,
|
||||
guint code,
|
||||
gchar const *message);
|
||||
void (*file_activated) (XedFileBrowserView * filetree,
|
||||
GtkTreeIter *iter);
|
||||
void (*directory_activated) (XedFileBrowserView * filetree,
|
||||
GtkTreeIter *iter);
|
||||
void (*bookmark_activated) (XedFileBrowserView * filetree,
|
||||
GtkTreeIter *iter);
|
||||
/* Signals */
|
||||
void (*error) (XedFileBrowserView *filetree,
|
||||
guint code,
|
||||
gchar const *message);
|
||||
void (*file_activated) (XedFileBrowserView *filetree,
|
||||
GtkTreeIter *iter);
|
||||
void (*directory_activated) (XedFileBrowserView *filetree,
|
||||
GtkTreeIter *iter);
|
||||
void (*bookmark_activated) (XedFileBrowserView *filetree,
|
||||
GtkTreeIter *iter);
|
||||
};
|
||||
|
||||
GType xed_file_browser_view_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_browser_view_register_type (GTypeModule * module);
|
||||
GType xed_file_browser_view_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_browser_view_register_type (GTypeModule *type_module);
|
||||
|
||||
GtkWidget *xed_file_browser_view_new (void);
|
||||
void xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
|
||||
GtkTreeModel * model);
|
||||
void xed_file_browser_view_start_rename (XedFileBrowserView * tree_view,
|
||||
GtkTreeIter * iter);
|
||||
void xed_file_browser_view_set_click_policy (XedFileBrowserView * tree_view,
|
||||
XedFileBrowserViewClickPolicy policy);
|
||||
void xed_file_browser_view_set_restore_expand_state (XedFileBrowserView * tree_view,
|
||||
gboolean restore_expand_state);
|
||||
GtkWidget *xed_file_browser_view_new (void);
|
||||
void xed_file_browser_view_set_model (XedFileBrowserView *tree_view,
|
||||
GtkTreeModel *model);
|
||||
void xed_file_browser_view_start_rename (XedFileBrowserView *tree_view,
|
||||
GtkTreeIter *iter);
|
||||
void xed_file_browser_view_set_click_policy (XedFileBrowserView *tree_view,
|
||||
XedFileBrowserViewClickPolicy policy);
|
||||
void xed_file_browser_view_set_restore_expand_state (XedFileBrowserView *tree_view,
|
||||
gboolean restore_expand_state);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __XED_FILE_BROWSER_VIEW_H__ */
|
||||
#endif /* __XED_FILE_BROWSER_VIEW_H__ */
|
||||
|
||||
// ex:ts=8:noet:
|
||||
|
@@ -43,8 +43,8 @@
|
||||
#include "xed-file-browser-enum-types.h"
|
||||
|
||||
#define XED_FILE_BROWSER_WIDGET_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \
|
||||
XED_TYPE_FILE_BROWSER_WIDGET, \
|
||||
XedFileBrowserWidgetPrivate))
|
||||
XED_TYPE_FILE_BROWSER_WIDGET, \
|
||||
XedFileBrowserWidgetPrivate))
|
||||
|
||||
#define XML_UI_FILE "xed-file-browser-widget-ui.xml"
|
||||
#define LOCATION_DATA_KEY "xed-file-browser-widget-location"
|
||||
@@ -800,18 +800,15 @@ static GtkActionEntry toplevel_actions[] =
|
||||
static const GtkActionEntry tree_actions_selection[] =
|
||||
{
|
||||
{"FileMoveToTrash", "user-trash", N_("_Move to Trash"), NULL,
|
||||
N_("Move selected file or folder to trash"),
|
||||
G_CALLBACK (on_action_file_move_to_trash)},
|
||||
N_("Move selected file or folder to trash"), G_CALLBACK (on_action_file_move_to_trash)},
|
||||
{"FileDelete", "edit-delete-symbolic", N_("_Delete"), NULL,
|
||||
N_("Delete selected file or folder"),
|
||||
G_CALLBACK (on_action_file_delete)}
|
||||
N_("Delete selected file or folder"), G_CALLBACK (on_action_file_delete)}
|
||||
};
|
||||
|
||||
static const GtkActionEntry tree_actions_file_selection[] =
|
||||
{
|
||||
{"FileOpen", "document-open-symbolic", N_("Open"), NULL,
|
||||
N_("Open selected file"),
|
||||
G_CALLBACK (on_action_file_open)}
|
||||
{"FileOpen", "document-open-symbolic", N_("_Open"), NULL,
|
||||
N_("Open selected file"), G_CALLBACK (on_action_file_open)}
|
||||
};
|
||||
|
||||
static const GtkActionEntry tree_actions[] =
|
||||
@@ -823,8 +820,7 @@ static const GtkActionEntry tree_actions[] =
|
||||
static const GtkActionEntry tree_actions_single_most_selection[] =
|
||||
{
|
||||
{"DirectoryNew", "folder-new-symbolic", N_("_New Folder"), NULL,
|
||||
N_("Add new empty folder"),
|
||||
G_CALLBACK (on_action_directory_new)},
|
||||
N_("Add new empty folder"), G_CALLBACK (on_action_directory_new)},
|
||||
{"FileNew", "document-new-symbolic", N_("New F_ile"), NULL,
|
||||
N_("Add new empty file"), G_CALLBACK (on_action_file_new)}
|
||||
};
|
||||
@@ -832,33 +828,27 @@ static const GtkActionEntry tree_actions_single_most_selection[] =
|
||||
static const GtkActionEntry tree_actions_single_selection[] =
|
||||
{
|
||||
{"FileRename", NULL, N_("_Rename"), NULL,
|
||||
N_("Rename selected file or folder"),
|
||||
G_CALLBACK (on_action_file_rename)}
|
||||
N_("Rename selected file or folder"), G_CALLBACK (on_action_file_rename)}
|
||||
};
|
||||
|
||||
static const GtkActionEntry tree_actions_sensitive[] =
|
||||
{
|
||||
{"DirectoryPrevious", "go-previous-symbolic", N_("_Previous Location"), NULL,
|
||||
N_("Go to the previous visited location"),
|
||||
G_CALLBACK (on_action_directory_previous)},
|
||||
N_("Go to the previous visited location"), G_CALLBACK (on_action_directory_previous)},
|
||||
{"DirectoryNext", "go-next-symbolic", N_("_Next Location"), NULL,
|
||||
N_("Go to the next visited location"), G_CALLBACK (on_action_directory_next)},
|
||||
{"DirectoryRefresh", "view-refresh-symbolic", N_("Re_fresh View"), NULL,
|
||||
N_("Refresh the view"), G_CALLBACK (on_action_directory_refresh)},
|
||||
{"DirectoryOpen", "folder-open-symbolic", N_("_View Folder"), NULL,
|
||||
N_("View folder in file manager"),
|
||||
G_CALLBACK (on_action_directory_open)}
|
||||
N_("View folder in file manager"), G_CALLBACK (on_action_directory_open)}
|
||||
};
|
||||
|
||||
static const GtkToggleActionEntry tree_actions_toggle[] =
|
||||
{
|
||||
{"FilterHidden", GTK_STOCK_DIALOG_AUTHENTICATION,
|
||||
N_("Show _Hidden"), NULL,
|
||||
N_("Show hidden files and folders"),
|
||||
G_CALLBACK (on_action_filter_hidden), FALSE},
|
||||
{"FilterHidden", GTK_STOCK_DIALOG_AUTHENTICATION, N_("Show _Hidden"), NULL,
|
||||
N_("Show hidden files and folders"), G_CALLBACK (on_action_filter_hidden), FALSE},
|
||||
{"FilterBinary", NULL, N_("Show _Binary"), NULL,
|
||||
N_("Show binary files"), G_CALLBACK (on_action_filter_binary),
|
||||
FALSE}
|
||||
N_("Show binary files"), G_CALLBACK (on_action_filter_binary), FALSE}
|
||||
};
|
||||
|
||||
static const GtkActionEntry bookmark_actions[] =
|
||||
|
@@ -71,7 +71,7 @@ struct _XedFileBrowserWidgetClass
|
||||
};
|
||||
|
||||
GType xed_file_browser_widget_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_browser_widget_register_type (GTypeModule * module);
|
||||
void _xed_file_browser_widget_register_type (GTypeModule *type_module);
|
||||
|
||||
GtkWidget *xed_file_browser_widget_new (const gchar *data_dir);
|
||||
|
||||
|
@@ -64,7 +64,7 @@ typedef struct _ModelineOptions
|
||||
GtkWrapMode wrap_mode;
|
||||
gboolean display_right_margin;
|
||||
guint right_margin_position;
|
||||
|
||||
|
||||
ModelineSet set;
|
||||
} ModelineOptions;
|
||||
|
||||
@@ -80,7 +80,10 @@ has_option (ModelineOptions *options,
|
||||
void
|
||||
modeline_parser_init (const gchar *data_dir)
|
||||
{
|
||||
modelines_data_dir = g_strdup (data_dir);
|
||||
if (modelines_data_dir == NULL)
|
||||
{
|
||||
modelines_data_dir = g_strdup (data_dir);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -94,12 +97,13 @@ modeline_parser_shutdown ()
|
||||
|
||||
if (kate_languages != NULL)
|
||||
g_hash_table_destroy (kate_languages);
|
||||
|
||||
|
||||
vim_languages = NULL;
|
||||
emacs_languages = NULL;
|
||||
kate_languages = NULL;
|
||||
|
||||
g_free (modelines_data_dir);
|
||||
modelines_data_dir = NULL;
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
@@ -224,7 +228,7 @@ skip_whitespaces (gchar **s)
|
||||
}
|
||||
|
||||
/* Parse vi(m) modelines.
|
||||
* Vi(m) modelines looks like this:
|
||||
* Vi(m) modelines looks like this:
|
||||
* - first form: [text]{white}{vi:|vim:|ex:}[white]{options}
|
||||
* - second form: [text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]
|
||||
* They can happen on the three first or last lines.
|
||||
@@ -289,7 +293,7 @@ parse_vim_modeline (gchar *s,
|
||||
{
|
||||
g_free (options->language_id);
|
||||
options->language_id = get_language_id_vim (value->str);
|
||||
|
||||
|
||||
options->set |= MODELINE_SET_LANGUAGE;
|
||||
}
|
||||
else if (strcmp (key->str, "et") == 0 ||
|
||||
@@ -302,7 +306,7 @@ parse_vim_modeline (gchar *s,
|
||||
strcmp (key->str, "tabstop") == 0)
|
||||
{
|
||||
intval = atoi (value->str);
|
||||
|
||||
|
||||
if (intval)
|
||||
{
|
||||
options->tab_width = intval;
|
||||
@@ -313,7 +317,7 @@ parse_vim_modeline (gchar *s,
|
||||
strcmp (key->str, "shiftwidth") == 0)
|
||||
{
|
||||
intval = atoi (value->str);
|
||||
|
||||
|
||||
if (intval)
|
||||
{
|
||||
options->indent_width = intval;
|
||||
@@ -326,18 +330,18 @@ parse_vim_modeline (gchar *s,
|
||||
|
||||
options->set |= MODELINE_SET_WRAP_MODE;
|
||||
}
|
||||
else if (strcmp (key->str, "textwidth") == 0)
|
||||
else if (strcmp (key->str, "textwidth") == 0 || strcmp (key->str, "tw") == 0)
|
||||
{
|
||||
intval = atoi (value->str);
|
||||
|
||||
|
||||
if (intval)
|
||||
{
|
||||
options->right_margin_position = intval;
|
||||
options->display_right_margin = TRUE;
|
||||
|
||||
|
||||
options->set |= MODELINE_SET_SHOW_RIGHT_MARGIN |
|
||||
MODELINE_SET_RIGHT_MARGIN_POSITION;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,13 +410,13 @@ parse_emacs_modeline (gchar *s,
|
||||
{
|
||||
g_free (options->language_id);
|
||||
options->language_id = get_language_id_emacs (value->str);
|
||||
|
||||
|
||||
options->set |= MODELINE_SET_LANGUAGE;
|
||||
}
|
||||
else if (strcmp (key->str, "tab-width") == 0)
|
||||
{
|
||||
intval = atoi (value->str);
|
||||
|
||||
|
||||
if (intval)
|
||||
{
|
||||
options->tab_width = intval;
|
||||
@@ -422,7 +426,7 @@ parse_emacs_modeline (gchar *s,
|
||||
else if (strcmp (key->str, "indent-offset") == 0)
|
||||
{
|
||||
intval = atoi (value->str);
|
||||
|
||||
|
||||
if (intval)
|
||||
{
|
||||
options->indent_width = intval;
|
||||
@@ -433,14 +437,14 @@ parse_emacs_modeline (gchar *s,
|
||||
{
|
||||
intval = strcmp (value->str, "nil") == 0;
|
||||
options->insert_spaces = intval;
|
||||
|
||||
|
||||
options->set |= MODELINE_SET_INSERT_SPACES;
|
||||
}
|
||||
else if (strcmp (key->str, "autowrap") == 0)
|
||||
{
|
||||
intval = strcmp (value->str, "nil") != 0;
|
||||
options->wrap_mode = intval ? GTK_WRAP_WORD : GTK_WRAP_NONE;
|
||||
|
||||
|
||||
options->set |= MODELINE_SET_WRAP_MODE;
|
||||
}
|
||||
}
|
||||
@@ -504,13 +508,13 @@ parse_kate_modeline (gchar *s,
|
||||
{
|
||||
g_free (options->language_id);
|
||||
options->language_id = get_language_id_kate (value->str);
|
||||
|
||||
|
||||
options->set |= MODELINE_SET_LANGUAGE;
|
||||
}
|
||||
else if (strcmp (key->str, "tab-width") == 0)
|
||||
{
|
||||
intval = atoi (value->str);
|
||||
|
||||
|
||||
if (intval)
|
||||
{
|
||||
options->tab_width = intval;
|
||||
@@ -539,17 +543,17 @@ parse_kate_modeline (gchar *s,
|
||||
|
||||
options->wrap_mode = intval ? GTK_WRAP_WORD : GTK_WRAP_NONE;
|
||||
|
||||
options->set |= MODELINE_SET_WRAP_MODE;
|
||||
options->set |= MODELINE_SET_WRAP_MODE;
|
||||
}
|
||||
else if (strcmp (key->str, "word-wrap-column") == 0)
|
||||
{
|
||||
intval = atoi (value->str);
|
||||
|
||||
|
||||
if (intval)
|
||||
{
|
||||
options->right_margin_position = intval;
|
||||
options->display_right_margin = TRUE;
|
||||
|
||||
|
||||
options->set |= MODELINE_SET_RIGHT_MARGIN_POSITION |
|
||||
MODELINE_SET_SHOW_RIGHT_MARGIN;
|
||||
}
|
||||
@@ -611,7 +615,7 @@ check_previous (GtkSourceView *view,
|
||||
ModelineSet set)
|
||||
{
|
||||
GtkSourceBuffer *buffer = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
|
||||
|
||||
|
||||
/* Do not restore default when this is the first time */
|
||||
if (!previous)
|
||||
return FALSE;
|
||||
@@ -648,7 +652,7 @@ check_previous (GtkSourceView *view,
|
||||
case MODELINE_SET_LANGUAGE:
|
||||
{
|
||||
GtkSourceLanguage *language = gtk_source_buffer_get_language (buffer);
|
||||
|
||||
|
||||
return (language == NULL && previous->language_id == NULL) ||
|
||||
(language != NULL && g_strcmp0 (gtk_source_language_get_id (language),
|
||||
previous->language_id) == 0);
|
||||
@@ -674,7 +678,7 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter iter, liter;
|
||||
gint line_count;
|
||||
|
||||
|
||||
options.language_id = NULL;
|
||||
options.set = MODELINE_SET_NONE;
|
||||
|
||||
@@ -757,7 +761,7 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||
}
|
||||
}
|
||||
|
||||
ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer),
|
||||
ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer),
|
||||
MODELINE_OPTIONS_DATA_KEY);
|
||||
|
||||
/* Apply the options we got from modelines and restore defaults if
|
||||
@@ -773,17 +777,17 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||
(view,
|
||||
xed_prefs_manager_get_insert_spaces ());
|
||||
}
|
||||
|
||||
|
||||
if (has_option (&options, MODELINE_SET_TAB_WIDTH))
|
||||
{
|
||||
gtk_source_view_set_tab_width (view, options.tab_width);
|
||||
}
|
||||
else if (check_previous (view, previous, MODELINE_SET_TAB_WIDTH))
|
||||
{
|
||||
gtk_source_view_set_tab_width (view,
|
||||
gtk_source_view_set_tab_width (view,
|
||||
xed_prefs_manager_get_tabs_size ());
|
||||
}
|
||||
|
||||
|
||||
if (has_option (&options, MODELINE_SET_INDENT_WIDTH))
|
||||
{
|
||||
gtk_source_view_set_indent_width (view, options.indent_width);
|
||||
@@ -792,39 +796,40 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||
{
|
||||
gtk_source_view_set_indent_width (view, -1);
|
||||
}
|
||||
|
||||
|
||||
if (has_option (&options, MODELINE_SET_WRAP_MODE))
|
||||
{
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), options.wrap_mode);
|
||||
}
|
||||
else if (check_previous (view, previous, MODELINE_SET_WRAP_MODE))
|
||||
{
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
|
||||
xed_prefs_manager_get_wrap_mode ());
|
||||
}
|
||||
|
||||
|
||||
if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION))
|
||||
{
|
||||
gtk_source_view_set_right_margin_position (view, options.right_margin_position);
|
||||
}
|
||||
else if (check_previous (view, previous, MODELINE_SET_RIGHT_MARGIN_POSITION))
|
||||
{
|
||||
gtk_source_view_set_right_margin_position (view,
|
||||
gtk_source_view_set_right_margin_position (view,
|
||||
xed_prefs_manager_get_right_margin_position ());
|
||||
}
|
||||
|
||||
|
||||
if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN))
|
||||
{
|
||||
gtk_source_view_set_show_right_margin (view, options.display_right_margin);
|
||||
}
|
||||
else if (check_previous (view, previous, MODELINE_SET_SHOW_RIGHT_MARGIN))
|
||||
{
|
||||
gtk_source_view_set_show_right_margin (view,
|
||||
gtk_source_view_set_show_right_margin (view,
|
||||
xed_prefs_manager_get_display_right_margin ());
|
||||
}
|
||||
|
||||
|
||||
if (previous)
|
||||
{
|
||||
g_free (previous->language_id);
|
||||
*previous = options;
|
||||
previous->language_id = g_strdup (options.language_id);
|
||||
}
|
||||
@@ -833,13 +838,13 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||
previous = g_slice_new (ModelineOptions);
|
||||
*previous = options;
|
||||
previous->language_id = g_strdup (options.language_id);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (buffer),
|
||||
MODELINE_OPTIONS_DATA_KEY,
|
||||
|
||||
g_object_set_data_full (G_OBJECT (buffer),
|
||||
MODELINE_OPTIONS_DATA_KEY,
|
||||
previous,
|
||||
(GDestroyNotify)free_modeline_options);
|
||||
}
|
||||
|
||||
|
||||
g_free (options.language_id);
|
||||
}
|
||||
|
||||
|
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* modelie-parser.h
|
||||
* Emacs, Kate and Vim-style modelines support for xed.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2005-2007 - Steve Frécinaux <code@istique.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@@ -23,14 +23,14 @@
|
||||
#define __MODELINE_PARSER_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtksourceview/gtksourceview.h>
|
||||
#include <gtksourceview/gtksource.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void modeline_parser_init (const gchar *data_dir);
|
||||
void modeline_parser_shutdown (void);
|
||||
void modeline_parser_apply_modeline (GtkSourceView *view);
|
||||
void modeline_parser_deactivate (GtkSourceView *view);
|
||||
void modeline_parser_init (const gchar *data_dir);
|
||||
void modeline_parser_shutdown (void);
|
||||
void modeline_parser_apply_modeline (GtkSourceView *view);
|
||||
void modeline_parser_deactivate (GtkSourceView *view);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -20,90 +20,65 @@
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gmodule.h>
|
||||
#include <libpeas/peas-activatable.h>
|
||||
#include "xed-modeline-plugin.h"
|
||||
#include "modeline-parser.h"
|
||||
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-debug.h>
|
||||
#include <xed/xed-utils.h>
|
||||
|
||||
#define DOCUMENT_DATA_KEY "XedModelinePluginDocumentData"
|
||||
#include <xed/xed-view-activatable.h>
|
||||
#include <xed/xed-view.h>
|
||||
|
||||
struct _XedModelinePluginPrivate
|
||||
{
|
||||
GtkWidget *window;
|
||||
XedView *view;
|
||||
|
||||
gulong tab_added_handler_id;
|
||||
gulong tab_removed_handler_id;
|
||||
gulong document_loaded_handler_id;
|
||||
gulong document_saved_handler_id;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gulong document_loaded_handler_id;
|
||||
gulong document_saved_handler_id;
|
||||
} DocumentData;
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_OBJECT
|
||||
PROP_VIEW
|
||||
};
|
||||
|
||||
static void peas_activatable_iface_init (PeasActivatableInterface *iface);
|
||||
static void xed_view_activatable_iface_init (XedViewActivatableInterface *iface);
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedModelinePlugin,
|
||||
xed_modeline_plugin,
|
||||
PEAS_TYPE_EXTENSION_BASE,
|
||||
0,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
|
||||
peas_activatable_iface_init))
|
||||
|
||||
static void
|
||||
document_data_free (DocumentData *ddata)
|
||||
{
|
||||
g_slice_free (DocumentData, ddata);
|
||||
}
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_VIEW_ACTIVATABLE,
|
||||
xed_view_activatable_iface_init))
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_constructed (GObject *object)
|
||||
{
|
||||
gchar *data_dir;
|
||||
gchar *data_dir;
|
||||
|
||||
data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (object));
|
||||
data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (object));
|
||||
|
||||
modeline_parser_init (data_dir);
|
||||
modeline_parser_init (data_dir);
|
||||
|
||||
g_free (data_dir);
|
||||
g_free (data_dir);
|
||||
|
||||
G_OBJECT_CLASS (xed_modeline_plugin_parent_class)->constructed (object);
|
||||
G_OBJECT_CLASS (xed_modeline_plugin_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_init (XedModelinePlugin *plugin)
|
||||
{
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedModelinePlugin initializing");
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedModelinePlugin initializing");
|
||||
|
||||
plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin,
|
||||
XED_TYPE_MODELINE_PLUGIN,
|
||||
XedModelinePluginPrivate);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_finalize (GObject *object)
|
||||
{
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedModelinePlugin finalizing");
|
||||
|
||||
modeline_parser_shutdown ();
|
||||
|
||||
G_OBJECT_CLASS (xed_modeline_plugin_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_dispose (GObject *object)
|
||||
{
|
||||
@@ -111,15 +86,21 @@ xed_modeline_plugin_dispose (GObject *object)
|
||||
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedModelinePlugin disposing");
|
||||
|
||||
if (plugin->priv->window != NULL)
|
||||
{
|
||||
g_object_unref (plugin->priv->window);
|
||||
plugin->priv->window = NULL;
|
||||
}
|
||||
g_clear_object (&plugin->priv->view);
|
||||
|
||||
G_OBJECT_CLASS (xed_modeline_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_finalize (GObject *object)
|
||||
{
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedModelinePlugin finalizing");
|
||||
|
||||
modeline_parser_shutdown ();
|
||||
|
||||
G_OBJECT_CLASS (xed_modeline_plugin_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -130,8 +111,8 @@ xed_modeline_plugin_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OBJECT:
|
||||
plugin->priv->window = GTK_WIDGET (g_value_dup_object (value));
|
||||
case PROP_VIEW:
|
||||
plugin->priv->view = XED_VIEW (g_value_dup_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@@ -149,8 +130,8 @@ xed_modeline_plugin_get_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OBJECT:
|
||||
g_value_set_object (value, plugin->priv->window);
|
||||
case PROP_VIEW:
|
||||
g_value_set_object (value, plugin->priv->view);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@@ -159,131 +140,49 @@ xed_modeline_plugin_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
on_document_loaded_or_saved (XedDocument *document,
|
||||
const GError *error,
|
||||
GtkSourceView *view)
|
||||
on_document_loaded_or_saved (XedDocument *document,
|
||||
const GError *error,
|
||||
GtkSourceView *view)
|
||||
{
|
||||
modeline_parser_apply_modeline (view);
|
||||
modeline_parser_apply_modeline (view);
|
||||
}
|
||||
|
||||
static void
|
||||
connect_handlers (XedView *view)
|
||||
xed_modeline_plugin_activate (XedViewActivatable *activatable)
|
||||
{
|
||||
DocumentData *data;
|
||||
GtkTextBuffer *doc;
|
||||
XedModelinePlugin *plugin;
|
||||
GtkTextBuffer *doc;
|
||||
|
||||
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
data = g_slice_new (DocumentData);
|
||||
plugin = XED_MODELINE_PLUGIN (activatable);
|
||||
|
||||
data->document_loaded_handler_id =
|
||||
g_signal_connect (doc, "loaded",
|
||||
G_CALLBACK (on_document_loaded_or_saved),
|
||||
view);
|
||||
data->document_saved_handler_id =
|
||||
g_signal_connect (doc, "saved",
|
||||
G_CALLBACK (on_document_loaded_or_saved),
|
||||
view);
|
||||
modeline_parser_apply_modeline (GTK_SOURCE_VIEW (plugin->priv->view));
|
||||
|
||||
g_object_set_data_full (G_OBJECT (doc), DOCUMENT_DATA_KEY,
|
||||
data, (GDestroyNotify) document_data_free);
|
||||
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (plugin->priv->view));
|
||||
|
||||
plugin->priv->document_loaded_handler_id =
|
||||
g_signal_connect (doc, "loaded",
|
||||
G_CALLBACK (on_document_loaded_or_saved), plugin->priv->view);
|
||||
plugin->priv->document_saved_handler_id =
|
||||
g_signal_connect (doc, "saved",
|
||||
G_CALLBACK (on_document_loaded_or_saved), plugin->priv->view);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_handlers (XedView *view)
|
||||
xed_modeline_plugin_deactivate (XedViewActivatable *activatable)
|
||||
{
|
||||
DocumentData *data;
|
||||
GtkTextBuffer *doc;
|
||||
XedModelinePlugin *plugin;
|
||||
GtkTextBuffer *doc;
|
||||
|
||||
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
data = g_object_steal_data (G_OBJECT (doc), DOCUMENT_DATA_KEY);
|
||||
plugin = XED_MODELINE_PLUGIN (activatable);
|
||||
|
||||
if (data)
|
||||
{
|
||||
g_signal_handler_disconnect (doc, data->document_loaded_handler_id);
|
||||
g_signal_handler_disconnect (doc, data->document_saved_handler_id);
|
||||
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (plugin->priv->view));
|
||||
|
||||
document_data_free (data);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Modeline handlers not found");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_window_tab_added (XedWindow *window,
|
||||
XedTab *tab,
|
||||
gpointer user_data)
|
||||
{
|
||||
connect_handlers (xed_tab_get_view (tab));
|
||||
}
|
||||
|
||||
static void
|
||||
on_window_tab_removed (XedWindow *window,
|
||||
XedTab *tab,
|
||||
gpointer user_data)
|
||||
{
|
||||
disconnect_handlers (xed_tab_get_view (tab));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_activate (PeasActivatable *activatable)
|
||||
{
|
||||
XedModelinePluginPrivate *data;
|
||||
XedWindow *window;
|
||||
GList *views;
|
||||
GList *l;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
data = XED_MODELINE_PLUGIN (activatable)->priv;
|
||||
window = XED_WINDOW (data->window);
|
||||
|
||||
views = xed_window_get_views (window);
|
||||
for (l = views; l != NULL; l = l->next)
|
||||
{
|
||||
connect_handlers (XED_VIEW (l->data));
|
||||
modeline_parser_apply_modeline (GTK_SOURCE_VIEW (l->data));
|
||||
}
|
||||
g_list_free (views);
|
||||
|
||||
data->tab_added_handler_id =
|
||||
g_signal_connect (window, "tab-added",
|
||||
G_CALLBACK (on_window_tab_added), NULL);
|
||||
|
||||
data->tab_removed_handler_id =
|
||||
g_signal_connect (window, "tab-removed",
|
||||
G_CALLBACK (on_window_tab_removed), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_deactivate (PeasActivatable *activatable)
|
||||
{
|
||||
XedModelinePluginPrivate *data;
|
||||
XedWindow *window;
|
||||
GList *views;
|
||||
GList *l;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
data = XED_MODELINE_PLUGIN (activatable)->priv;
|
||||
window = XED_WINDOW (data->window);
|
||||
|
||||
g_signal_handler_disconnect (window, data->tab_added_handler_id);
|
||||
g_signal_handler_disconnect (window, data->tab_removed_handler_id);
|
||||
|
||||
views = xed_window_get_views (window);
|
||||
|
||||
for (l = views; l != NULL; l = l->next)
|
||||
{
|
||||
disconnect_handlers (XED_VIEW (l->data));
|
||||
|
||||
modeline_parser_deactivate (GTK_SOURCE_VIEW (l->data));
|
||||
}
|
||||
|
||||
g_list_free (views);
|
||||
g_signal_handler_disconnect (doc, plugin->priv->document_loaded_handler_id);
|
||||
g_signal_handler_disconnect (doc, plugin->priv->document_saved_handler_id);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -292,35 +191,35 @@ xed_modeline_plugin_class_init (XedModelinePluginClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructed = xed_modeline_plugin_constructed;
|
||||
object_class->finalize = xed_modeline_plugin_finalize;
|
||||
object_class->dispose = xed_modeline_plugin_dispose;
|
||||
object_class->finalize = xed_modeline_plugin_finalize;
|
||||
object_class->set_property = xed_modeline_plugin_set_property;
|
||||
object_class->get_property = xed_modeline_plugin_get_property;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_OBJECT, "object");
|
||||
g_object_class_override_property (object_class, PROP_VIEW, "view");
|
||||
|
||||
g_type_class_add_private (klass, sizeof (XedModelinePluginPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_view_activatable_iface_init (XedViewActivatableInterface *iface)
|
||||
{
|
||||
iface->activate = xed_modeline_plugin_activate;
|
||||
iface->deactivate = xed_modeline_plugin_deactivate;
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_class_finalize (XedModelinePluginClass *klass)
|
||||
{
|
||||
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE_EXTENDED */
|
||||
}
|
||||
|
||||
static void
|
||||
peas_activatable_iface_init (PeasActivatableInterface *iface)
|
||||
{
|
||||
iface->activate = xed_modeline_plugin_activate;
|
||||
iface->deactivate = xed_modeline_plugin_deactivate;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
peas_register_types (PeasObjectModule *module)
|
||||
{
|
||||
xed_modeline_plugin_register_type (G_TYPE_MODULE (module));
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
PEAS_TYPE_ACTIVATABLE,
|
||||
XED_TYPE_VIEW_ACTIVATABLE,
|
||||
XED_TYPE_MODELINE_PLUGIN);
|
||||
}
|
||||
|
@@ -39,10 +39,11 @@ G_BEGIN_DECLS
|
||||
/* Private structure type */
|
||||
typedef struct _XedModelinePlugin XedModelinePlugin;
|
||||
typedef struct _XedModelinePluginPrivate XedModelinePluginPrivate;
|
||||
typedef struct _XedModelinePluginClass XedModelinePluginClass;
|
||||
|
||||
struct _XedModelinePlugin
|
||||
{
|
||||
PeasExtensionBase parent_instance;
|
||||
PeasExtensionBase parent;
|
||||
|
||||
/*< private >*/
|
||||
XedModelinePluginPrivate *priv;
|
||||
|
Reference in New Issue
Block a user