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:
parent
d45e07b7a1
commit
b9e5097250
|
@ -1,7 +1,7 @@
|
||||||
usr/share/appdata
|
usr/share/appdata
|
||||||
|
usr/share/xed/plugins
|
||||||
usr/share/glib-2.0
|
usr/share/glib-2.0
|
||||||
usr/share/help
|
usr/share/help
|
||||||
usr/share/locale
|
usr/share/locale
|
||||||
usr/share/xed/icons
|
usr/share/xed/icons
|
||||||
usr/share/xed/plugins
|
|
||||||
usr/share/xed/ui/
|
usr/share/xed/ui/
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
usr/bin/xed
|
usr/bin/xed
|
||||||
usr/lib/*/xed/plugins/*.plugin
|
|
||||||
usr/lib/*/xed/girepository-1.0/
|
usr/lib/*/xed/girepository-1.0/
|
||||||
|
usr/lib/xed/xed-bugreport.sh
|
||||||
usr/lib/*/xed/plugins/*.plugin
|
usr/lib/*/xed/plugins/*.plugin
|
||||||
usr/lib/*/xed/plugins/*.so
|
usr/lib/*/xed/plugins/*.so
|
||||||
usr/lib/xed/xed-bugreport.sh
|
|
||||||
usr/share/applications/xed.desktop
|
usr/share/applications/xed.desktop
|
||||||
usr/share/man/
|
usr/share/man/
|
||||||
|
|
|
@ -1,26 +1,9 @@
|
||||||
DIST_SUBDIRS = \
|
DIST_SUBDIRS = \
|
||||||
changecase \
|
filebrowser \
|
||||||
docinfo \
|
modelines
|
||||||
filebrowser \
|
|
||||||
modelines \
|
|
||||||
sort \
|
|
||||||
spell \
|
|
||||||
taglist \
|
|
||||||
time \
|
|
||||||
trailsave
|
|
||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
changecase \
|
filebrowser \
|
||||||
docinfo \
|
modelines
|
||||||
filebrowser \
|
|
||||||
modelines \
|
|
||||||
sort \
|
|
||||||
taglist \
|
|
||||||
time \
|
|
||||||
trailsave
|
|
||||||
|
|
||||||
if ENABLE_ENCHANT
|
|
||||||
SUBDIRS += spell
|
|
||||||
endif
|
|
||||||
|
|
||||||
-include $(top_srcdir)/git.mk
|
-include $(top_srcdir)/git.mk
|
||||||
|
|
|
@ -77,7 +77,7 @@ struct _XedFileBookmarksStoreClass
|
||||||
};
|
};
|
||||||
|
|
||||||
GType xed_file_bookmarks_store_get_type (void) G_GNUC_CONST;
|
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);
|
XedFileBookmarksStore *xed_file_bookmarks_store_new (void);
|
||||||
gchar *xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model,
|
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
|
* Type checking and casting macros
|
||||||
*/
|
*/
|
||||||
#define XED_TYPE_FILE_BROWSER_PLUGIN (xed_file_browser_plugin_get_type ())
|
#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_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(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))
|
#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;
|
GType xed_file_browser_plugin_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
/* All the plugins must implement this function */
|
/* 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
|
G_END_DECLS
|
||||||
#endif /* __XED_FILE_BROWSER_PLUGIN_H__ */
|
#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 _XedFileBrowserStoreClass XedFileBrowserStoreClass;
|
||||||
typedef struct _XedFileBrowserStorePrivate XedFileBrowserStorePrivate;
|
typedef struct _XedFileBrowserStorePrivate XedFileBrowserStorePrivate;
|
||||||
|
|
||||||
typedef gboolean (*XedFileBrowserStoreFilterFunc) (XedFileBrowserStore
|
typedef gboolean (*XedFileBrowserStoreFilterFunc) (XedFileBrowserStore *model,
|
||||||
* model,
|
GtkTreeIter *iter,
|
||||||
GtkTreeIter * iter,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
struct _XedFileBrowserStore
|
struct _XedFileBrowserStore
|
||||||
{
|
{
|
||||||
|
@ -97,102 +96,91 @@ struct _XedFileBrowserStoreClass {
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
void (*begin_loading) (XedFileBrowserStore * model,
|
void (*begin_loading) (XedFileBrowserStore *model,
|
||||||
GtkTreeIter * iter);
|
GtkTreeIter *iter);
|
||||||
void (*end_loading) (XedFileBrowserStore * model,
|
void (*end_loading) (XedFileBrowserStore *model,
|
||||||
GtkTreeIter * iter);
|
GtkTreeIter *iter);
|
||||||
void (*error) (XedFileBrowserStore * model,
|
void (*error) (XedFileBrowserStore *model,
|
||||||
guint code,
|
guint code,
|
||||||
gchar * message);
|
gchar *message);
|
||||||
gboolean (*no_trash) (XedFileBrowserStore * model,
|
gboolean (*no_trash) (XedFileBrowserStore *model,
|
||||||
GList * files);
|
GList *files);
|
||||||
void (*rename) (XedFileBrowserStore * model,
|
void (*rename) (XedFileBrowserStore *model,
|
||||||
const gchar * olduri,
|
const gchar *olduri,
|
||||||
const gchar * newuri);
|
const gchar *newuri);
|
||||||
void (*begin_refresh) (XedFileBrowserStore * model);
|
void (*begin_refresh) (XedFileBrowserStore *model);
|
||||||
void (*end_refresh) (XedFileBrowserStore * model);
|
void (*end_refresh) (XedFileBrowserStore *model);
|
||||||
void (*unload) (XedFileBrowserStore * model,
|
void (*unload) (XedFileBrowserStore *model,
|
||||||
const gchar * uri);
|
const gchar *uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType xed_file_browser_store_get_type (void) G_GNUC_CONST;
|
GType xed_file_browser_store_get_type (void) G_GNUC_CONST;
|
||||||
void _xed_file_browser_store_register_type (GTypeModule * module);
|
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
|
XedFileBrowserStoreResult xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore *model,
|
||||||
xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore * model,
|
gchar const *root,
|
||||||
gchar const *root,
|
gchar const *virtual_root);
|
||||||
gchar const *virtual_root);
|
XedFileBrowserStoreResult xed_file_browser_store_set_root (XedFileBrowserStore *model,
|
||||||
XedFileBrowserStoreResult
|
gchar const *root);
|
||||||
xed_file_browser_store_set_root (XedFileBrowserStore * model,
|
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root (XedFileBrowserStore *model,
|
||||||
gchar const *root);
|
GtkTreeIter *iter);
|
||||||
XedFileBrowserStoreResult
|
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root_from_string (XedFileBrowserStore *model,
|
||||||
xed_file_browser_store_set_virtual_root (XedFileBrowserStore * model,
|
gchar const *root);
|
||||||
GtkTreeIter * iter);
|
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root_up (XedFileBrowserStore *model);
|
||||||
XedFileBrowserStoreResult
|
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root_top (XedFileBrowserStore *model);
|
||||||
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
|
gboolean xed_file_browser_store_get_iter_virtual_root (XedFileBrowserStore *model,
|
||||||
xed_file_browser_store_get_iter_virtual_root (XedFileBrowserStore * model,
|
GtkTreeIter *iter);
|
||||||
GtkTreeIter * iter);
|
gboolean xed_file_browser_store_get_iter_root (XedFileBrowserStore *model,
|
||||||
gboolean xed_file_browser_store_get_iter_root (XedFileBrowserStore * model,
|
GtkTreeIter *iter);
|
||||||
GtkTreeIter * iter);
|
gchar * xed_file_browser_store_get_root (XedFileBrowserStore *model);
|
||||||
gchar * xed_file_browser_store_get_root (XedFileBrowserStore * model);
|
gchar * xed_file_browser_store_get_virtual_root (XedFileBrowserStore *model);
|
||||||
gchar * xed_file_browser_store_get_virtual_root (XedFileBrowserStore * model);
|
|
||||||
|
|
||||||
gboolean xed_file_browser_store_iter_equal (XedFileBrowserStore * model,
|
gboolean xed_file_browser_store_iter_equal (XedFileBrowserStore *model,
|
||||||
GtkTreeIter * iter1,
|
GtkTreeIter *iter1,
|
||||||
GtkTreeIter * iter2);
|
GtkTreeIter *iter2);
|
||||||
|
|
||||||
void xed_file_browser_store_set_value (XedFileBrowserStore * tree_model,
|
void xed_file_browser_store_set_value (XedFileBrowserStore *tree_model,
|
||||||
GtkTreeIter * iter,
|
GtkTreeIter *iter,
|
||||||
gint column,
|
gint column,
|
||||||
GValue * value);
|
GValue *value);
|
||||||
|
|
||||||
void _xed_file_browser_store_iter_expanded (XedFileBrowserStore * model,
|
void _xed_file_browser_store_iter_expanded (XedFileBrowserStore *model,
|
||||||
GtkTreeIter * iter);
|
GtkTreeIter *iter);
|
||||||
void _xed_file_browser_store_iter_collapsed (XedFileBrowserStore * model,
|
void _xed_file_browser_store_iter_collapsed (XedFileBrowserStore *model,
|
||||||
GtkTreeIter * iter);
|
GtkTreeIter *iter);
|
||||||
|
|
||||||
XedFileBrowserStoreFilterMode
|
XedFileBrowserStoreFilterMode xed_file_browser_store_get_filter_mode (XedFileBrowserStore *model);
|
||||||
xed_file_browser_store_get_filter_mode (XedFileBrowserStore * model);
|
void xed_file_browser_store_set_filter_mode (XedFileBrowserStore *model,
|
||||||
void xed_file_browser_store_set_filter_mode (XedFileBrowserStore * model,
|
XedFileBrowserStoreFilterMode mode);
|
||||||
XedFileBrowserStoreFilterMode mode);
|
void xed_file_browser_store_set_filter_func (XedFileBrowserStore *model,
|
||||||
void xed_file_browser_store_set_filter_func (XedFileBrowserStore * model,
|
XedFileBrowserStoreFilterFunc func,
|
||||||
XedFileBrowserStoreFilterFunc func,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
void xed_file_browser_store_refilter (XedFileBrowserStore *model);
|
||||||
void xed_file_browser_store_refilter (XedFileBrowserStore * model);
|
XedFileBrowserStoreFilterMode xed_file_browser_store_filter_mode_get_default (void);
|
||||||
XedFileBrowserStoreFilterMode
|
|
||||||
xed_file_browser_store_filter_mode_get_default (void);
|
|
||||||
|
|
||||||
void xed_file_browser_store_refresh (XedFileBrowserStore * model);
|
void xed_file_browser_store_refresh (XedFileBrowserStore * model);
|
||||||
gboolean xed_file_browser_store_rename (XedFileBrowserStore * model,
|
gboolean xed_file_browser_store_rename (XedFileBrowserStore *model,
|
||||||
GtkTreeIter * iter,
|
GtkTreeIter *iter,
|
||||||
gchar const *new_name,
|
gchar const *new_name,
|
||||||
GError ** error);
|
GError **error);
|
||||||
XedFileBrowserStoreResult
|
XedFileBrowserStoreResult xed_file_browser_store_delete (XedFileBrowserStore *model,
|
||||||
xed_file_browser_store_delete (XedFileBrowserStore * model,
|
GtkTreeIter *iter,
|
||||||
GtkTreeIter * iter,
|
gboolean trash);
|
||||||
gboolean trash);
|
XedFileBrowserStoreResult xed_file_browser_store_delete_all (XedFileBrowserStore *model,
|
||||||
XedFileBrowserStoreResult
|
GList *rows,
|
||||||
xed_file_browser_store_delete_all (XedFileBrowserStore * model,
|
gboolean trash);
|
||||||
GList *rows,
|
|
||||||
gboolean trash);
|
|
||||||
|
|
||||||
gboolean xed_file_browser_store_new_file (XedFileBrowserStore * model,
|
gboolean xed_file_browser_store_new_file (XedFileBrowserStore *model,
|
||||||
GtkTreeIter * parent,
|
GtkTreeIter *parent,
|
||||||
GtkTreeIter * iter);
|
GtkTreeIter *iter);
|
||||||
gboolean xed_file_browser_store_new_directory (XedFileBrowserStore * model,
|
gboolean xed_file_browser_store_new_directory (XedFileBrowserStore *model,
|
||||||
GtkTreeIter * parent,
|
GtkTreeIter *parent,
|
||||||
GtkTreeIter * iter);
|
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
|
G_END_DECLS
|
||||||
#endif /* __XED_FILE_BROWSER_STORE_H__ */
|
#endif /* __XED_FILE_BROWSER_STORE_H__ */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,60 +25,61 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
#define XED_TYPE_FILE_BROWSER_VIEW (xed_file_browser_view_get_type ())
|
#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(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_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_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(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_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_FILE_BROWSER_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_FILE_BROWSER_VIEW, XedFileBrowserViewClass))
|
||||||
|
|
||||||
typedef struct _XedFileBrowserView XedFileBrowserView;
|
typedef struct _XedFileBrowserView XedFileBrowserView;
|
||||||
typedef struct _XedFileBrowserViewClass XedFileBrowserViewClass;
|
typedef struct _XedFileBrowserViewClass XedFileBrowserViewClass;
|
||||||
typedef struct _XedFileBrowserViewPrivate XedFileBrowserViewPrivate;
|
typedef struct _XedFileBrowserViewPrivate XedFileBrowserViewPrivate;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE,
|
{
|
||||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE
|
XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE,
|
||||||
|
XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE
|
||||||
} XedFileBrowserViewClickPolicy;
|
} XedFileBrowserViewClickPolicy;
|
||||||
|
|
||||||
struct _XedFileBrowserView
|
struct _XedFileBrowserView
|
||||||
{
|
{
|
||||||
GtkTreeView parent;
|
GtkTreeView parent;
|
||||||
|
|
||||||
XedFileBrowserViewPrivate *priv;
|
XedFileBrowserViewPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _XedFileBrowserViewClass
|
struct _XedFileBrowserViewClass
|
||||||
{
|
{
|
||||||
GtkTreeViewClass parent_class;
|
GtkTreeViewClass parent_class;
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
void (*error) (XedFileBrowserView * filetree,
|
void (*error) (XedFileBrowserView *filetree,
|
||||||
guint code,
|
guint code,
|
||||||
gchar const *message);
|
gchar const *message);
|
||||||
void (*file_activated) (XedFileBrowserView * filetree,
|
void (*file_activated) (XedFileBrowserView *filetree,
|
||||||
GtkTreeIter *iter);
|
GtkTreeIter *iter);
|
||||||
void (*directory_activated) (XedFileBrowserView * filetree,
|
void (*directory_activated) (XedFileBrowserView *filetree,
|
||||||
GtkTreeIter *iter);
|
GtkTreeIter *iter);
|
||||||
void (*bookmark_activated) (XedFileBrowserView * filetree,
|
void (*bookmark_activated) (XedFileBrowserView *filetree,
|
||||||
GtkTreeIter *iter);
|
GtkTreeIter *iter);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType xed_file_browser_view_get_type (void) G_GNUC_CONST;
|
GType xed_file_browser_view_get_type (void) G_GNUC_CONST;
|
||||||
void _xed_file_browser_view_register_type (GTypeModule * module);
|
void _xed_file_browser_view_register_type (GTypeModule *type_module);
|
||||||
|
|
||||||
GtkWidget *xed_file_browser_view_new (void);
|
GtkWidget *xed_file_browser_view_new (void);
|
||||||
void xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
|
void xed_file_browser_view_set_model (XedFileBrowserView *tree_view,
|
||||||
GtkTreeModel * model);
|
GtkTreeModel *model);
|
||||||
void xed_file_browser_view_start_rename (XedFileBrowserView * tree_view,
|
void xed_file_browser_view_start_rename (XedFileBrowserView *tree_view,
|
||||||
GtkTreeIter * iter);
|
GtkTreeIter *iter);
|
||||||
void xed_file_browser_view_set_click_policy (XedFileBrowserView * tree_view,
|
void xed_file_browser_view_set_click_policy (XedFileBrowserView *tree_view,
|
||||||
XedFileBrowserViewClickPolicy policy);
|
XedFileBrowserViewClickPolicy policy);
|
||||||
void xed_file_browser_view_set_restore_expand_state (XedFileBrowserView * tree_view,
|
void xed_file_browser_view_set_restore_expand_state (XedFileBrowserView *tree_view,
|
||||||
gboolean restore_expand_state);
|
gboolean restore_expand_state);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* __XED_FILE_BROWSER_VIEW_H__ */
|
#endif /* __XED_FILE_BROWSER_VIEW_H__ */
|
||||||
|
|
||||||
// ex:ts=8:noet:
|
// ex:ts=8:noet:
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
#include "xed-file-browser-enum-types.h"
|
#include "xed-file-browser-enum-types.h"
|
||||||
|
|
||||||
#define XED_FILE_BROWSER_WIDGET_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \
|
#define XED_FILE_BROWSER_WIDGET_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), \
|
||||||
XED_TYPE_FILE_BROWSER_WIDGET, \
|
XED_TYPE_FILE_BROWSER_WIDGET, \
|
||||||
XedFileBrowserWidgetPrivate))
|
XedFileBrowserWidgetPrivate))
|
||||||
|
|
||||||
#define XML_UI_FILE "xed-file-browser-widget-ui.xml"
|
#define XML_UI_FILE "xed-file-browser-widget-ui.xml"
|
||||||
#define LOCATION_DATA_KEY "xed-file-browser-widget-location"
|
#define LOCATION_DATA_KEY "xed-file-browser-widget-location"
|
||||||
|
@ -800,18 +800,15 @@ static GtkActionEntry toplevel_actions[] =
|
||||||
static const GtkActionEntry tree_actions_selection[] =
|
static const GtkActionEntry tree_actions_selection[] =
|
||||||
{
|
{
|
||||||
{"FileMoveToTrash", "user-trash", N_("_Move to Trash"), NULL,
|
{"FileMoveToTrash", "user-trash", N_("_Move to Trash"), NULL,
|
||||||
N_("Move selected file or folder to trash"),
|
N_("Move selected file or folder to trash"), G_CALLBACK (on_action_file_move_to_trash)},
|
||||||
G_CALLBACK (on_action_file_move_to_trash)},
|
|
||||||
{"FileDelete", "edit-delete-symbolic", N_("_Delete"), NULL,
|
{"FileDelete", "edit-delete-symbolic", N_("_Delete"), NULL,
|
||||||
N_("Delete selected file or folder"),
|
N_("Delete selected file or folder"), G_CALLBACK (on_action_file_delete)}
|
||||||
G_CALLBACK (on_action_file_delete)}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GtkActionEntry tree_actions_file_selection[] =
|
static const GtkActionEntry tree_actions_file_selection[] =
|
||||||
{
|
{
|
||||||
{"FileOpen", "document-open-symbolic", N_("Open"), NULL,
|
{"FileOpen", "document-open-symbolic", N_("_Open"), NULL,
|
||||||
N_("Open selected file"),
|
N_("Open selected file"), G_CALLBACK (on_action_file_open)}
|
||||||
G_CALLBACK (on_action_file_open)}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GtkActionEntry tree_actions[] =
|
static const GtkActionEntry tree_actions[] =
|
||||||
|
@ -823,8 +820,7 @@ static const GtkActionEntry tree_actions[] =
|
||||||
static const GtkActionEntry tree_actions_single_most_selection[] =
|
static const GtkActionEntry tree_actions_single_most_selection[] =
|
||||||
{
|
{
|
||||||
{"DirectoryNew", "folder-new-symbolic", N_("_New Folder"), NULL,
|
{"DirectoryNew", "folder-new-symbolic", N_("_New Folder"), NULL,
|
||||||
N_("Add new empty folder"),
|
N_("Add new empty folder"), G_CALLBACK (on_action_directory_new)},
|
||||||
G_CALLBACK (on_action_directory_new)},
|
|
||||||
{"FileNew", "document-new-symbolic", N_("New F_ile"), NULL,
|
{"FileNew", "document-new-symbolic", N_("New F_ile"), NULL,
|
||||||
N_("Add new empty file"), G_CALLBACK (on_action_file_new)}
|
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[] =
|
static const GtkActionEntry tree_actions_single_selection[] =
|
||||||
{
|
{
|
||||||
{"FileRename", NULL, N_("_Rename"), NULL,
|
{"FileRename", NULL, N_("_Rename"), NULL,
|
||||||
N_("Rename selected file or folder"),
|
N_("Rename selected file or folder"), G_CALLBACK (on_action_file_rename)}
|
||||||
G_CALLBACK (on_action_file_rename)}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GtkActionEntry tree_actions_sensitive[] =
|
static const GtkActionEntry tree_actions_sensitive[] =
|
||||||
{
|
{
|
||||||
{"DirectoryPrevious", "go-previous-symbolic", N_("_Previous Location"), NULL,
|
{"DirectoryPrevious", "go-previous-symbolic", N_("_Previous Location"), NULL,
|
||||||
N_("Go to the previous visited location"),
|
N_("Go to the previous visited location"), G_CALLBACK (on_action_directory_previous)},
|
||||||
G_CALLBACK (on_action_directory_previous)},
|
|
||||||
{"DirectoryNext", "go-next-symbolic", N_("_Next Location"), NULL,
|
{"DirectoryNext", "go-next-symbolic", N_("_Next Location"), NULL,
|
||||||
N_("Go to the next visited location"), G_CALLBACK (on_action_directory_next)},
|
N_("Go to the next visited location"), G_CALLBACK (on_action_directory_next)},
|
||||||
{"DirectoryRefresh", "view-refresh-symbolic", N_("Re_fresh View"), NULL,
|
{"DirectoryRefresh", "view-refresh-symbolic", N_("Re_fresh View"), NULL,
|
||||||
N_("Refresh the view"), G_CALLBACK (on_action_directory_refresh)},
|
N_("Refresh the view"), G_CALLBACK (on_action_directory_refresh)},
|
||||||
{"DirectoryOpen", "folder-open-symbolic", N_("_View Folder"), NULL,
|
{"DirectoryOpen", "folder-open-symbolic", N_("_View Folder"), NULL,
|
||||||
N_("View folder in file manager"),
|
N_("View folder in file manager"), G_CALLBACK (on_action_directory_open)}
|
||||||
G_CALLBACK (on_action_directory_open)}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GtkToggleActionEntry tree_actions_toggle[] =
|
static const GtkToggleActionEntry tree_actions_toggle[] =
|
||||||
{
|
{
|
||||||
{"FilterHidden", GTK_STOCK_DIALOG_AUTHENTICATION,
|
{"FilterHidden", GTK_STOCK_DIALOG_AUTHENTICATION, N_("Show _Hidden"), NULL,
|
||||||
N_("Show _Hidden"), NULL,
|
N_("Show hidden files and folders"), G_CALLBACK (on_action_filter_hidden), FALSE},
|
||||||
N_("Show hidden files and folders"),
|
|
||||||
G_CALLBACK (on_action_filter_hidden), FALSE},
|
|
||||||
{"FilterBinary", NULL, N_("Show _Binary"), NULL,
|
{"FilterBinary", NULL, N_("Show _Binary"), NULL,
|
||||||
N_("Show binary files"), G_CALLBACK (on_action_filter_binary),
|
N_("Show binary files"), G_CALLBACK (on_action_filter_binary), FALSE}
|
||||||
FALSE}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GtkActionEntry bookmark_actions[] =
|
static const GtkActionEntry bookmark_actions[] =
|
||||||
|
|
|
@ -71,7 +71,7 @@ struct _XedFileBrowserWidgetClass
|
||||||
};
|
};
|
||||||
|
|
||||||
GType xed_file_browser_widget_get_type (void) G_GNUC_CONST;
|
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);
|
GtkWidget *xed_file_browser_widget_new (const gchar *data_dir);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ typedef struct _ModelineOptions
|
||||||
GtkWrapMode wrap_mode;
|
GtkWrapMode wrap_mode;
|
||||||
gboolean display_right_margin;
|
gboolean display_right_margin;
|
||||||
guint right_margin_position;
|
guint right_margin_position;
|
||||||
|
|
||||||
ModelineSet set;
|
ModelineSet set;
|
||||||
} ModelineOptions;
|
} ModelineOptions;
|
||||||
|
|
||||||
|
@ -80,7 +80,10 @@ has_option (ModelineOptions *options,
|
||||||
void
|
void
|
||||||
modeline_parser_init (const gchar *data_dir)
|
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
|
void
|
||||||
|
@ -94,12 +97,13 @@ modeline_parser_shutdown ()
|
||||||
|
|
||||||
if (kate_languages != NULL)
|
if (kate_languages != NULL)
|
||||||
g_hash_table_destroy (kate_languages);
|
g_hash_table_destroy (kate_languages);
|
||||||
|
|
||||||
vim_languages = NULL;
|
vim_languages = NULL;
|
||||||
emacs_languages = NULL;
|
emacs_languages = NULL;
|
||||||
kate_languages = NULL;
|
kate_languages = NULL;
|
||||||
|
|
||||||
g_free (modelines_data_dir);
|
g_free (modelines_data_dir);
|
||||||
|
modelines_data_dir = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GHashTable *
|
static GHashTable *
|
||||||
|
@ -224,7 +228,7 @@ skip_whitespaces (gchar **s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse vi(m) modelines.
|
/* 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}
|
* - first form: [text]{white}{vi:|vim:|ex:}[white]{options}
|
||||||
* - second form: [text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]
|
* - second form: [text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]
|
||||||
* They can happen on the three first or last lines.
|
* They can happen on the three first or last lines.
|
||||||
|
@ -289,7 +293,7 @@ parse_vim_modeline (gchar *s,
|
||||||
{
|
{
|
||||||
g_free (options->language_id);
|
g_free (options->language_id);
|
||||||
options->language_id = get_language_id_vim (value->str);
|
options->language_id = get_language_id_vim (value->str);
|
||||||
|
|
||||||
options->set |= MODELINE_SET_LANGUAGE;
|
options->set |= MODELINE_SET_LANGUAGE;
|
||||||
}
|
}
|
||||||
else if (strcmp (key->str, "et") == 0 ||
|
else if (strcmp (key->str, "et") == 0 ||
|
||||||
|
@ -302,7 +306,7 @@ parse_vim_modeline (gchar *s,
|
||||||
strcmp (key->str, "tabstop") == 0)
|
strcmp (key->str, "tabstop") == 0)
|
||||||
{
|
{
|
||||||
intval = atoi (value->str);
|
intval = atoi (value->str);
|
||||||
|
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
options->tab_width = intval;
|
options->tab_width = intval;
|
||||||
|
@ -313,7 +317,7 @@ parse_vim_modeline (gchar *s,
|
||||||
strcmp (key->str, "shiftwidth") == 0)
|
strcmp (key->str, "shiftwidth") == 0)
|
||||||
{
|
{
|
||||||
intval = atoi (value->str);
|
intval = atoi (value->str);
|
||||||
|
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
options->indent_width = intval;
|
options->indent_width = intval;
|
||||||
|
@ -326,18 +330,18 @@ parse_vim_modeline (gchar *s,
|
||||||
|
|
||||||
options->set |= MODELINE_SET_WRAP_MODE;
|
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);
|
intval = atoi (value->str);
|
||||||
|
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
options->right_margin_position = intval;
|
options->right_margin_position = intval;
|
||||||
options->display_right_margin = TRUE;
|
options->display_right_margin = TRUE;
|
||||||
|
|
||||||
options->set |= MODELINE_SET_SHOW_RIGHT_MARGIN |
|
options->set |= MODELINE_SET_SHOW_RIGHT_MARGIN |
|
||||||
MODELINE_SET_RIGHT_MARGIN_POSITION;
|
MODELINE_SET_RIGHT_MARGIN_POSITION;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,13 +410,13 @@ parse_emacs_modeline (gchar *s,
|
||||||
{
|
{
|
||||||
g_free (options->language_id);
|
g_free (options->language_id);
|
||||||
options->language_id = get_language_id_emacs (value->str);
|
options->language_id = get_language_id_emacs (value->str);
|
||||||
|
|
||||||
options->set |= MODELINE_SET_LANGUAGE;
|
options->set |= MODELINE_SET_LANGUAGE;
|
||||||
}
|
}
|
||||||
else if (strcmp (key->str, "tab-width") == 0)
|
else if (strcmp (key->str, "tab-width") == 0)
|
||||||
{
|
{
|
||||||
intval = atoi (value->str);
|
intval = atoi (value->str);
|
||||||
|
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
options->tab_width = intval;
|
options->tab_width = intval;
|
||||||
|
@ -422,7 +426,7 @@ parse_emacs_modeline (gchar *s,
|
||||||
else if (strcmp (key->str, "indent-offset") == 0)
|
else if (strcmp (key->str, "indent-offset") == 0)
|
||||||
{
|
{
|
||||||
intval = atoi (value->str);
|
intval = atoi (value->str);
|
||||||
|
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
options->indent_width = intval;
|
options->indent_width = intval;
|
||||||
|
@ -433,14 +437,14 @@ parse_emacs_modeline (gchar *s,
|
||||||
{
|
{
|
||||||
intval = strcmp (value->str, "nil") == 0;
|
intval = strcmp (value->str, "nil") == 0;
|
||||||
options->insert_spaces = intval;
|
options->insert_spaces = intval;
|
||||||
|
|
||||||
options->set |= MODELINE_SET_INSERT_SPACES;
|
options->set |= MODELINE_SET_INSERT_SPACES;
|
||||||
}
|
}
|
||||||
else if (strcmp (key->str, "autowrap") == 0)
|
else if (strcmp (key->str, "autowrap") == 0)
|
||||||
{
|
{
|
||||||
intval = strcmp (value->str, "nil") != 0;
|
intval = strcmp (value->str, "nil") != 0;
|
||||||
options->wrap_mode = intval ? GTK_WRAP_WORD : GTK_WRAP_NONE;
|
options->wrap_mode = intval ? GTK_WRAP_WORD : GTK_WRAP_NONE;
|
||||||
|
|
||||||
options->set |= MODELINE_SET_WRAP_MODE;
|
options->set |= MODELINE_SET_WRAP_MODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,13 +508,13 @@ parse_kate_modeline (gchar *s,
|
||||||
{
|
{
|
||||||
g_free (options->language_id);
|
g_free (options->language_id);
|
||||||
options->language_id = get_language_id_kate (value->str);
|
options->language_id = get_language_id_kate (value->str);
|
||||||
|
|
||||||
options->set |= MODELINE_SET_LANGUAGE;
|
options->set |= MODELINE_SET_LANGUAGE;
|
||||||
}
|
}
|
||||||
else if (strcmp (key->str, "tab-width") == 0)
|
else if (strcmp (key->str, "tab-width") == 0)
|
||||||
{
|
{
|
||||||
intval = atoi (value->str);
|
intval = atoi (value->str);
|
||||||
|
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
options->tab_width = 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->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)
|
else if (strcmp (key->str, "word-wrap-column") == 0)
|
||||||
{
|
{
|
||||||
intval = atoi (value->str);
|
intval = atoi (value->str);
|
||||||
|
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
options->right_margin_position = intval;
|
options->right_margin_position = intval;
|
||||||
options->display_right_margin = TRUE;
|
options->display_right_margin = TRUE;
|
||||||
|
|
||||||
options->set |= MODELINE_SET_RIGHT_MARGIN_POSITION |
|
options->set |= MODELINE_SET_RIGHT_MARGIN_POSITION |
|
||||||
MODELINE_SET_SHOW_RIGHT_MARGIN;
|
MODELINE_SET_SHOW_RIGHT_MARGIN;
|
||||||
}
|
}
|
||||||
|
@ -611,7 +615,7 @@ check_previous (GtkSourceView *view,
|
||||||
ModelineSet set)
|
ModelineSet set)
|
||||||
{
|
{
|
||||||
GtkSourceBuffer *buffer = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
|
GtkSourceBuffer *buffer = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
|
||||||
|
|
||||||
/* Do not restore default when this is the first time */
|
/* Do not restore default when this is the first time */
|
||||||
if (!previous)
|
if (!previous)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -648,7 +652,7 @@ check_previous (GtkSourceView *view,
|
||||||
case MODELINE_SET_LANGUAGE:
|
case MODELINE_SET_LANGUAGE:
|
||||||
{
|
{
|
||||||
GtkSourceLanguage *language = gtk_source_buffer_get_language (buffer);
|
GtkSourceLanguage *language = gtk_source_buffer_get_language (buffer);
|
||||||
|
|
||||||
return (language == NULL && previous->language_id == NULL) ||
|
return (language == NULL && previous->language_id == NULL) ||
|
||||||
(language != NULL && g_strcmp0 (gtk_source_language_get_id (language),
|
(language != NULL && g_strcmp0 (gtk_source_language_get_id (language),
|
||||||
previous->language_id) == 0);
|
previous->language_id) == 0);
|
||||||
|
@ -674,7 +678,7 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
GtkTextIter iter, liter;
|
GtkTextIter iter, liter;
|
||||||
gint line_count;
|
gint line_count;
|
||||||
|
|
||||||
options.language_id = NULL;
|
options.language_id = NULL;
|
||||||
options.set = MODELINE_SET_NONE;
|
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);
|
MODELINE_OPTIONS_DATA_KEY);
|
||||||
|
|
||||||
/* Apply the options we got from modelines and restore defaults if
|
/* Apply the options we got from modelines and restore defaults if
|
||||||
|
@ -773,17 +777,17 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
(view,
|
(view,
|
||||||
xed_prefs_manager_get_insert_spaces ());
|
xed_prefs_manager_get_insert_spaces ());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_option (&options, MODELINE_SET_TAB_WIDTH))
|
if (has_option (&options, MODELINE_SET_TAB_WIDTH))
|
||||||
{
|
{
|
||||||
gtk_source_view_set_tab_width (view, options.tab_width);
|
gtk_source_view_set_tab_width (view, options.tab_width);
|
||||||
}
|
}
|
||||||
else if (check_previous (view, previous, MODELINE_SET_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 ());
|
xed_prefs_manager_get_tabs_size ());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_option (&options, MODELINE_SET_INDENT_WIDTH))
|
if (has_option (&options, MODELINE_SET_INDENT_WIDTH))
|
||||||
{
|
{
|
||||||
gtk_source_view_set_indent_width (view, options.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);
|
gtk_source_view_set_indent_width (view, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_option (&options, MODELINE_SET_WRAP_MODE))
|
if (has_option (&options, MODELINE_SET_WRAP_MODE))
|
||||||
{
|
{
|
||||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), options.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))
|
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 ());
|
xed_prefs_manager_get_wrap_mode ());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION))
|
if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION))
|
||||||
{
|
{
|
||||||
gtk_source_view_set_right_margin_position (view, options.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))
|
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 ());
|
xed_prefs_manager_get_right_margin_position ());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN))
|
if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN))
|
||||||
{
|
{
|
||||||
gtk_source_view_set_show_right_margin (view, options.display_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))
|
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 ());
|
xed_prefs_manager_get_display_right_margin ());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previous)
|
if (previous)
|
||||||
{
|
{
|
||||||
|
g_free (previous->language_id);
|
||||||
*previous = options;
|
*previous = options;
|
||||||
previous->language_id = g_strdup (options.language_id);
|
previous->language_id = g_strdup (options.language_id);
|
||||||
}
|
}
|
||||||
|
@ -833,13 +838,13 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
||||||
previous = g_slice_new (ModelineOptions);
|
previous = g_slice_new (ModelineOptions);
|
||||||
*previous = options;
|
*previous = options;
|
||||||
previous->language_id = g_strdup (options.language_id);
|
previous->language_id = g_strdup (options.language_id);
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (buffer),
|
g_object_set_data_full (G_OBJECT (buffer),
|
||||||
MODELINE_OPTIONS_DATA_KEY,
|
MODELINE_OPTIONS_DATA_KEY,
|
||||||
previous,
|
previous,
|
||||||
(GDestroyNotify)free_modeline_options);
|
(GDestroyNotify)free_modeline_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (options.language_id);
|
g_free (options.language_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
/*
|
/*
|
||||||
* modelie-parser.h
|
* modelie-parser.h
|
||||||
* Emacs, Kate and Vim-style modelines support for xed.
|
* Emacs, Kate and Vim-style modelines support for xed.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005-2007 - Steve Frécinaux <code@istique.net>
|
* Copyright (C) 2005-2007 - Steve Frécinaux <code@istique.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2, or (at your option)
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
* any later version.
|
* any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
@ -23,14 +23,14 @@
|
||||||
#define __MODELINE_PARSER_H__
|
#define __MODELINE_PARSER_H__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gtksourceview/gtksourceview.h>
|
#include <gtksourceview/gtksource.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
void modeline_parser_init (const gchar *data_dir);
|
void modeline_parser_init (const gchar *data_dir);
|
||||||
void modeline_parser_shutdown (void);
|
void modeline_parser_shutdown (void);
|
||||||
void modeline_parser_apply_modeline (GtkSourceView *view);
|
void modeline_parser_apply_modeline (GtkSourceView *view);
|
||||||
void modeline_parser_deactivate (GtkSourceView *view);
|
void modeline_parser_deactivate (GtkSourceView *view);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -20,90 +20,65 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
#include <libpeas/peas-activatable.h>
|
|
||||||
#include "xed-modeline-plugin.h"
|
#include "xed-modeline-plugin.h"
|
||||||
#include "modeline-parser.h"
|
#include "modeline-parser.h"
|
||||||
|
|
||||||
#include <xed/xed-window.h>
|
|
||||||
#include <xed/xed-debug.h>
|
#include <xed/xed-debug.h>
|
||||||
#include <xed/xed-utils.h>
|
#include <xed/xed-view-activatable.h>
|
||||||
|
#include <xed/xed-view.h>
|
||||||
#define DOCUMENT_DATA_KEY "XedModelinePluginDocumentData"
|
|
||||||
|
|
||||||
struct _XedModelinePluginPrivate
|
struct _XedModelinePluginPrivate
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
XedView *view;
|
||||||
|
|
||||||
gulong tab_added_handler_id;
|
gulong document_loaded_handler_id;
|
||||||
gulong tab_removed_handler_id;
|
gulong document_saved_handler_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
gulong document_loaded_handler_id;
|
|
||||||
gulong document_saved_handler_id;
|
|
||||||
} DocumentData;
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
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,
|
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedModelinePlugin,
|
||||||
xed_modeline_plugin,
|
xed_modeline_plugin,
|
||||||
PEAS_TYPE_EXTENSION_BASE,
|
PEAS_TYPE_EXTENSION_BASE,
|
||||||
0,
|
0,
|
||||||
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
|
G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_VIEW_ACTIVATABLE,
|
||||||
peas_activatable_iface_init))
|
xed_view_activatable_iface_init))
|
||||||
|
|
||||||
static void
|
|
||||||
document_data_free (DocumentData *ddata)
|
|
||||||
{
|
|
||||||
g_slice_free (DocumentData, ddata);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_modeline_plugin_constructed (GObject *object)
|
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
|
static void
|
||||||
xed_modeline_plugin_init (XedModelinePlugin *plugin)
|
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,
|
plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin,
|
||||||
XED_TYPE_MODELINE_PLUGIN,
|
XED_TYPE_MODELINE_PLUGIN,
|
||||||
XedModelinePluginPrivate);
|
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
|
static void
|
||||||
xed_modeline_plugin_dispose (GObject *object)
|
xed_modeline_plugin_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
|
@ -111,15 +86,21 @@ xed_modeline_plugin_dispose (GObject *object)
|
||||||
|
|
||||||
xed_debug_message (DEBUG_PLUGINS, "XedModelinePlugin disposing");
|
xed_debug_message (DEBUG_PLUGINS, "XedModelinePlugin disposing");
|
||||||
|
|
||||||
if (plugin->priv->window != NULL)
|
g_clear_object (&plugin->priv->view);
|
||||||
{
|
|
||||||
g_object_unref (plugin->priv->window);
|
|
||||||
plugin->priv->window = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (xed_modeline_plugin_parent_class)->dispose (object);
|
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
|
static void
|
||||||
xed_modeline_plugin_set_property (GObject *object,
|
xed_modeline_plugin_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
@ -130,8 +111,8 @@ xed_modeline_plugin_set_property (GObject *object,
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_OBJECT:
|
case PROP_VIEW:
|
||||||
plugin->priv->window = GTK_WIDGET (g_value_dup_object (value));
|
plugin->priv->view = XED_VIEW (g_value_dup_object (value));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -149,8 +130,8 @@ xed_modeline_plugin_get_property (GObject *object,
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_OBJECT:
|
case PROP_VIEW:
|
||||||
g_value_set_object (value, plugin->priv->window);
|
g_value_set_object (value, plugin->priv->view);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -159,131 +140,49 @@ xed_modeline_plugin_get_property (GObject *object,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_document_loaded_or_saved (XedDocument *document,
|
on_document_loaded_or_saved (XedDocument *document,
|
||||||
const GError *error,
|
const GError *error,
|
||||||
GtkSourceView *view)
|
GtkSourceView *view)
|
||||||
{
|
{
|
||||||
modeline_parser_apply_modeline (view);
|
modeline_parser_apply_modeline (view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
connect_handlers (XedView *view)
|
xed_modeline_plugin_activate (XedViewActivatable *activatable)
|
||||||
{
|
{
|
||||||
DocumentData *data;
|
XedModelinePlugin *plugin;
|
||||||
GtkTextBuffer *doc;
|
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 =
|
modeline_parser_apply_modeline (GTK_SOURCE_VIEW (plugin->priv->view));
|
||||||
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);
|
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (doc), DOCUMENT_DATA_KEY,
|
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (plugin->priv->view));
|
||||||
data, (GDestroyNotify) document_data_free);
|
|
||||||
|
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
|
static void
|
||||||
disconnect_handlers (XedView *view)
|
xed_modeline_plugin_deactivate (XedViewActivatable *activatable)
|
||||||
{
|
{
|
||||||
DocumentData *data;
|
XedModelinePlugin *plugin;
|
||||||
GtkTextBuffer *doc;
|
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)
|
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (plugin->priv->view));
|
||||||
{
|
|
||||||
g_signal_handler_disconnect (doc, data->document_loaded_handler_id);
|
|
||||||
g_signal_handler_disconnect (doc, data->document_saved_handler_id);
|
|
||||||
|
|
||||||
document_data_free (data);
|
g_signal_handler_disconnect (doc, plugin->priv->document_loaded_handler_id);
|
||||||
}
|
g_signal_handler_disconnect (doc, plugin->priv->document_saved_handler_id);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -292,35 +191,35 @@ xed_modeline_plugin_class_init (XedModelinePluginClass *klass)
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->constructed = xed_modeline_plugin_constructed;
|
object_class->constructed = xed_modeline_plugin_constructed;
|
||||||
object_class->finalize = xed_modeline_plugin_finalize;
|
|
||||||
object_class->dispose = xed_modeline_plugin_dispose;
|
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->set_property = xed_modeline_plugin_set_property;
|
||||||
object_class->get_property = xed_modeline_plugin_get_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));
|
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
|
static void
|
||||||
xed_modeline_plugin_class_finalize (XedModelinePluginClass *klass)
|
xed_modeline_plugin_class_finalize (XedModelinePluginClass *klass)
|
||||||
{
|
{
|
||||||
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE_EXTENDED */
|
/* 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
|
G_MODULE_EXPORT void
|
||||||
peas_register_types (PeasObjectModule *module)
|
peas_register_types (PeasObjectModule *module)
|
||||||
{
|
{
|
||||||
xed_modeline_plugin_register_type (G_TYPE_MODULE (module));
|
xed_modeline_plugin_register_type (G_TYPE_MODULE (module));
|
||||||
|
|
||||||
peas_object_module_register_extension_type (module,
|
peas_object_module_register_extension_type (module,
|
||||||
PEAS_TYPE_ACTIVATABLE,
|
XED_TYPE_VIEW_ACTIVATABLE,
|
||||||
XED_TYPE_MODELINE_PLUGIN);
|
XED_TYPE_MODELINE_PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,11 @@ G_BEGIN_DECLS
|
||||||
/* Private structure type */
|
/* Private structure type */
|
||||||
typedef struct _XedModelinePlugin XedModelinePlugin;
|
typedef struct _XedModelinePlugin XedModelinePlugin;
|
||||||
typedef struct _XedModelinePluginPrivate XedModelinePluginPrivate;
|
typedef struct _XedModelinePluginPrivate XedModelinePluginPrivate;
|
||||||
|
typedef struct _XedModelinePluginClass XedModelinePluginClass;
|
||||||
|
|
||||||
struct _XedModelinePlugin
|
struct _XedModelinePlugin
|
||||||
{
|
{
|
||||||
PeasExtensionBase parent_instance;
|
PeasExtensionBase parent;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
XedModelinePluginPrivate *priv;
|
XedModelinePluginPrivate *priv;
|
||||||
|
|
|
@ -70,6 +70,7 @@ NOINST_H_FILES = \
|
||||||
|
|
||||||
INST_H_FILES = \
|
INST_H_FILES = \
|
||||||
xed-app.h \
|
xed-app.h \
|
||||||
|
xed-app-activatable.h \
|
||||||
xed-commands.h \
|
xed-commands.h \
|
||||||
xed-debug.h \
|
xed-debug.h \
|
||||||
xed-document.h \
|
xed-document.h \
|
||||||
|
@ -91,7 +92,9 @@ INST_H_FILES = \
|
||||||
xed-tab.h \
|
xed-tab.h \
|
||||||
xed-utils.h \
|
xed-utils.h \
|
||||||
xed-view.h \
|
xed-view.h \
|
||||||
xed-window.h
|
xed-view-activatable.h \
|
||||||
|
xed-window.h \
|
||||||
|
xed-window-activatable.h
|
||||||
|
|
||||||
if !ENABLE_GVFS_METADATA
|
if !ENABLE_GVFS_METADATA
|
||||||
INST_H_FILES += xed-metadata-manager.h
|
INST_H_FILES += xed-metadata-manager.h
|
||||||
|
@ -105,6 +108,7 @@ header_DATA = \
|
||||||
|
|
||||||
libxed_c_files = \
|
libxed_c_files = \
|
||||||
xed-app.c \
|
xed-app.c \
|
||||||
|
xed-app-activatable.c \
|
||||||
xed-close-button.c \
|
xed-close-button.c \
|
||||||
xed-commands-documents.c \
|
xed-commands-documents.c \
|
||||||
xed-commands-edit.c \
|
xed-commands-edit.c \
|
||||||
|
@ -152,7 +156,9 @@ libxed_c_files = \
|
||||||
xed-tab-label.c \
|
xed-tab-label.c \
|
||||||
xed-utils.c \
|
xed-utils.c \
|
||||||
xed-view.c \
|
xed-view.c \
|
||||||
|
xed-view-activatable.c \
|
||||||
xed-window.c \
|
xed-window.c \
|
||||||
|
xed-window-activatable.c \
|
||||||
xedtextregion.c
|
xedtextregion.c
|
||||||
|
|
||||||
libxed_la_SOURCES = \
|
libxed_la_SOURCES = \
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* xed-app-activatable.h
|
||||||
|
* This file is part of xed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Steve Frécinaux
|
||||||
|
* Copyright (C) 2010 Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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
|
||||||
|
* GNU Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "xed-app-activatable.h"
|
||||||
|
#include "xed-app.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:xed-app-activatable
|
||||||
|
* @short_description: Interface for activatable extensions on apps
|
||||||
|
* @see_also: #PeasExtensionSet
|
||||||
|
*
|
||||||
|
* #XedAppActivatable is an interface which should be implemented by
|
||||||
|
* extensions that should be activated on a xed application.
|
||||||
|
**/
|
||||||
|
|
||||||
|
G_DEFINE_INTERFACE(XedAppActivatable, xed_app_activatable, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
void
|
||||||
|
xed_app_activatable_default_init (XedAppActivatableInterface *iface)
|
||||||
|
{
|
||||||
|
static gboolean initialized = FALSE;
|
||||||
|
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* XedAppActivatable:app:
|
||||||
|
*
|
||||||
|
* The app property contains the xed app for this
|
||||||
|
* #XedAppActivatable instance.
|
||||||
|
*/
|
||||||
|
g_object_interface_install_property (iface,
|
||||||
|
g_param_spec_object ("app",
|
||||||
|
"App",
|
||||||
|
"The xed app",
|
||||||
|
XED_TYPE_APP,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
initialized = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xed_app_activatable_activate:
|
||||||
|
* @activatable: A #XedAppActivatable.
|
||||||
|
*
|
||||||
|
* Activates the extension on the application.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xed_app_activatable_activate (XedAppActivatable *activatable)
|
||||||
|
{
|
||||||
|
XedAppActivatableInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (XED_IS_APP_ACTIVATABLE (activatable));
|
||||||
|
|
||||||
|
iface = XED_APP_ACTIVATABLE_GET_IFACE (activatable);
|
||||||
|
|
||||||
|
if (iface->activate != NULL)
|
||||||
|
{
|
||||||
|
iface->activate (activatable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xed_app_activatable_deactivate:
|
||||||
|
* @activatable: A #XedAppActivatable.
|
||||||
|
*
|
||||||
|
* Deactivates the extension from the application.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xed_app_activatable_deactivate (XedAppActivatable *activatable)
|
||||||
|
{
|
||||||
|
XedAppActivatableInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (XED_IS_APP_ACTIVATABLE (activatable));
|
||||||
|
|
||||||
|
iface = XED_APP_ACTIVATABLE_GET_IFACE (activatable);
|
||||||
|
|
||||||
|
if (iface->deactivate != NULL)
|
||||||
|
{
|
||||||
|
iface->deactivate (activatable);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* xed-app-activatable.h
|
||||||
|
* This file is part of xed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 - Steve Frécinaux
|
||||||
|
* Copyright (C) 2010 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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
|
||||||
|
* GNU Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XED_APP_ACTIVATABLE_H__
|
||||||
|
#define __XED_APP_ACTIVATABLE_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Type checking and casting macros
|
||||||
|
*/
|
||||||
|
#define XED_TYPE_APP_ACTIVATABLE (xed_app_activatable_get_type ())
|
||||||
|
#define XED_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_APP_ACTIVATABLE, XedAppActivatable))
|
||||||
|
#define XED_APP_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XED_TYPE_APP_ACTIVATABLE, XedAppActivatableInterface))
|
||||||
|
#define XED_IS_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_APP_ACTIVATABLE))
|
||||||
|
#define XED_APP_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XED_TYPE_APP_ACTIVATABLE, XedAppActivatableInterface))
|
||||||
|
|
||||||
|
typedef struct _XedAppActivatable XedAppActivatable; /* dummy typedef */
|
||||||
|
typedef struct _XedAppActivatableInterface XedAppActivatableInterface;
|
||||||
|
|
||||||
|
struct _XedAppActivatableInterface
|
||||||
|
{
|
||||||
|
GTypeInterface g_iface;
|
||||||
|
|
||||||
|
/* Virtual public methods */
|
||||||
|
void (*activate) (XedAppActivatable *activatable);
|
||||||
|
void (*deactivate) (XedAppActivatable *activatable);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public methods
|
||||||
|
*/
|
||||||
|
GType xed_app_activatable_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
void xed_app_activatable_activate (XedAppActivatable *activatable);
|
||||||
|
void xed_app_activatable_deactivate (XedAppActivatable *activatable);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __XED_APP_ACTIVATABLE_H__ */
|
|
@ -36,6 +36,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <libpeas/peas-extension-set.h>
|
||||||
|
|
||||||
#include "xed-app.h"
|
#include "xed-app.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
#include "xed-prefs-manager-app.h"
|
||||||
|
@ -45,6 +46,8 @@
|
||||||
#include "xed-utils.h"
|
#include "xed-utils.h"
|
||||||
#include "xed-enum-types.h"
|
#include "xed-enum-types.h"
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
|
#include "xed-app-activatable.h"
|
||||||
|
#include "xed-plugins-engine.h"
|
||||||
|
|
||||||
#define XED_PAGE_SETUP_FILE "xed-page-setup"
|
#define XED_PAGE_SETUP_FILE "xed-page-setup"
|
||||||
#define XED_PRINT_SETTINGS_FILE "xed-print-settings"
|
#define XED_PRINT_SETTINGS_FILE "xed-print-settings"
|
||||||
|
@ -61,8 +64,11 @@ struct _XedAppPrivate
|
||||||
{
|
{
|
||||||
GList *windows;
|
GList *windows;
|
||||||
XedWindow *active_window;
|
XedWindow *active_window;
|
||||||
|
|
||||||
GtkPageSetup *page_setup;
|
GtkPageSetup *page_setup;
|
||||||
GtkPrintSettings *print_settings;
|
GtkPrintSettings *print_settings;
|
||||||
|
|
||||||
|
PeasExtensionSet *extensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE(XedApp, xed_app, G_TYPE_OBJECT)
|
G_DEFINE_TYPE(XedApp, xed_app, G_TYPE_OBJECT)
|
||||||
|
@ -87,6 +93,16 @@ xed_app_finalize (GObject *object)
|
||||||
G_OBJECT_CLASS (xed_app_parent_class)->finalize (object);
|
G_OBJECT_CLASS (xed_app_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_app_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
XedApp *app = XED_APP (object);
|
||||||
|
|
||||||
|
g_clear_object (&app->priv->extensions);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xed_app_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_app_get_property (GObject *object,
|
xed_app_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
@ -107,9 +123,10 @@ xed_app_class_init (XedAppClass *klass)
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = xed_app_finalize;
|
object_class->finalize = xed_app_finalize;
|
||||||
|
object_class->dispose = xed_app_dispose;
|
||||||
object_class->get_property = xed_app_get_property;
|
object_class->get_property = xed_app_get_property;
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof(XedAppPrivate));
|
g_type_class_add_private (object_class, sizeof (XedAppPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -308,19 +325,40 @@ save_print_settings (XedApp *app)
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
extension_added (PeasExtensionSet *extensions,
|
||||||
|
PeasPluginInfo *info,
|
||||||
|
PeasExtension *exten,
|
||||||
|
XedApp *app)
|
||||||
|
{
|
||||||
|
peas_extension_call (exten, "activate");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
extension_removed (PeasExtensionSet *extensions,
|
||||||
|
PeasPluginInfo *info,
|
||||||
|
PeasExtension *exten,
|
||||||
|
XedApp *app)
|
||||||
|
{
|
||||||
|
peas_extension_call (exten, "deactivate");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_app_init (XedApp *app)
|
xed_app_init (XedApp *app)
|
||||||
{
|
{
|
||||||
app->priv = XED_APP_GET_PRIVATE (app);
|
app->priv = XED_APP_GET_PRIVATE (app);
|
||||||
|
|
||||||
load_accels ();
|
load_accels ();
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||||
app_weak_notify (gpointer data,
|
XED_TYPE_APP_ACTIVATABLE, "app", app, NULL);
|
||||||
GObject *where_the_app_was)
|
|
||||||
{
|
g_signal_connect (app->priv->extensions, "extension-added",
|
||||||
gtk_main_quit ();
|
G_CALLBACK (extension_added), app);
|
||||||
|
g_signal_connect (app->priv->extensions, "extension-removed",
|
||||||
|
G_CALLBACK (extension_removed), app);
|
||||||
|
|
||||||
|
peas_extension_set_call (app->priv->extensions, "activate");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -342,7 +380,6 @@ xed_app_get_default (void)
|
||||||
app = XED_APP (g_object_new (XED_TYPE_APP, NULL));
|
app = XED_APP (g_object_new (XED_TYPE_APP, NULL));
|
||||||
|
|
||||||
g_object_add_weak_pointer (G_OBJECT (app), (gpointer) &app);
|
g_object_add_weak_pointer (G_OBJECT (app), (gpointer) &app);
|
||||||
g_object_weak_ref (G_OBJECT (app), app_weak_notify, NULL);
|
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
@ -421,7 +458,7 @@ window_destroy (XedWindow *window,
|
||||||
save_page_setup (app);
|
save_page_setup (app);
|
||||||
save_print_settings (app);
|
save_print_settings (app);
|
||||||
|
|
||||||
g_object_unref (app);
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* xed-view-activatable.h
|
||||||
|
* This file is part of xed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Steve Frécinaux
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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
|
||||||
|
* GNU Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "xed-view-activatable.h"
|
||||||
|
#include "xed-view.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:xed-view-activatable
|
||||||
|
* @short_description: Interface for activatable extensions on views
|
||||||
|
* @see_also: #PeasExtensionSet
|
||||||
|
*
|
||||||
|
* #XedViewActivatable is an interface which should be implemented by
|
||||||
|
* extensions that should be activated on a xed view.
|
||||||
|
**/
|
||||||
|
G_DEFINE_INTERFACE(XedViewActivatable, xed_view_activatable, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
void
|
||||||
|
xed_view_activatable_default_init (XedViewActivatableInterface *iface)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* XedViewActivatable:view:
|
||||||
|
*
|
||||||
|
* The window property contains the xed window for this
|
||||||
|
* #XedViewActivatable instance.
|
||||||
|
*/
|
||||||
|
g_object_interface_install_property (iface,
|
||||||
|
g_param_spec_object ("view",
|
||||||
|
"view",
|
||||||
|
"A xed view",
|
||||||
|
XED_TYPE_VIEW,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xed_view_activatable_activate:
|
||||||
|
* @activatable: A #XedViewActivatable.
|
||||||
|
*
|
||||||
|
* Activates the extension on the window property.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xed_view_activatable_activate (XedViewActivatable *activatable)
|
||||||
|
{
|
||||||
|
XedViewActivatableInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (XED_IS_VIEW_ACTIVATABLE (activatable));
|
||||||
|
|
||||||
|
iface = XED_VIEW_ACTIVATABLE_GET_IFACE (activatable);
|
||||||
|
if (iface->activate != NULL)
|
||||||
|
{
|
||||||
|
iface->activate (activatable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xed_view_activatable_deactivate:
|
||||||
|
* @activatable: A #XedViewActivatable.
|
||||||
|
*
|
||||||
|
* Deactivates the extension on the window property.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xed_view_activatable_deactivate (XedViewActivatable *activatable)
|
||||||
|
{
|
||||||
|
XedViewActivatableInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (XED_IS_VIEW_ACTIVATABLE (activatable));
|
||||||
|
|
||||||
|
iface = XED_VIEW_ACTIVATABLE_GET_IFACE (activatable);
|
||||||
|
if (iface->deactivate != NULL)
|
||||||
|
{
|
||||||
|
iface->deactivate (activatable);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* xed-view-activatable.h
|
||||||
|
* This file is part of xed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 - Steve Frécinaux
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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
|
||||||
|
* GNU Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XED_VIEW_ACTIVATABLE_H__
|
||||||
|
#define __XED_VIEW_ACTIVATABLE_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Type checking and casting macros
|
||||||
|
*/
|
||||||
|
#define XED_TYPE_VIEW_ACTIVATABLE (xed_view_activatable_get_type ())
|
||||||
|
#define XED_VIEW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_VIEW_ACTIVATABLE, XedViewActivatable))
|
||||||
|
#define XED_VIEW_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XED_TYPE_VIEW_ACTIVATABLE, XedViewActivatableInterface))
|
||||||
|
#define XED_IS_VIEW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_VIEW_ACTIVATABLE))
|
||||||
|
#define XED_VIEW_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XED_TYPE_VIEW_ACTIVATABLE, XedViewActivatableInterface))
|
||||||
|
|
||||||
|
typedef struct _XedViewActivatable XedViewActivatable; /* dummy typedef */
|
||||||
|
typedef struct _XedViewActivatableInterface XedViewActivatableInterface;
|
||||||
|
|
||||||
|
struct _XedViewActivatableInterface
|
||||||
|
{
|
||||||
|
GTypeInterface g_iface;
|
||||||
|
|
||||||
|
/* Virtual public methods */
|
||||||
|
void (*activate) (XedViewActivatable *activatable);
|
||||||
|
void (*deactivate) (XedViewActivatable *activatable);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public methods
|
||||||
|
*/
|
||||||
|
GType xed_view_activatable_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
void xed_view_activatable_activate (XedViewActivatable *activatable);
|
||||||
|
void xed_view_activatable_deactivate (XedViewActivatable *activatable);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __XED_VIEW_ACTIVATABLE_H__ */
|
|
@ -6,9 +6,12 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
#include <libpeas/peas-extension-set.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
#include "xed-view.h"
|
#include "xed-view.h"
|
||||||
|
#include "xed-view-activatable.h"
|
||||||
|
#include "xed-plugins-engine.h"
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-prefs-manager.h"
|
#include "xed-prefs-manager.h"
|
||||||
#include "xed-prefs-manager-app.h"
|
#include "xed-prefs-manager-app.h"
|
||||||
|
@ -34,10 +37,13 @@ struct _XedViewPrivate
|
||||||
guint search_entry_changed_id;
|
guint search_entry_changed_id;
|
||||||
gboolean disable_popdown;
|
gboolean disable_popdown;
|
||||||
GtkTextBuffer *current_buffer;
|
GtkTextBuffer *current_buffer;
|
||||||
|
PeasExtensionSet *extensions;
|
||||||
|
guint view_realized : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void xed_view_dispose (GObject *object);
|
static void xed_view_dispose (GObject *object);
|
||||||
static void xed_view_finalize (GObject *object);
|
static void xed_view_finalize (GObject *object);
|
||||||
|
static void xed_view_realize (GtkWidget *widget);
|
||||||
static gint xed_view_focus_out (GtkWidget *widget, GdkEventFocus *event);
|
static gint xed_view_focus_out (GtkWidget *widget, GdkEventFocus *event);
|
||||||
static gboolean xed_view_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint timestamp);
|
static gboolean xed_view_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint timestamp);
|
||||||
static void xed_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
|
static void xed_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
|
||||||
|
@ -107,6 +113,7 @@ xed_view_class_init (XedViewClass *klass)
|
||||||
widget_class->drag_data_received = xed_view_drag_data_received;
|
widget_class->drag_data_received = xed_view_drag_data_received;
|
||||||
widget_class->drag_drop = xed_view_drag_drop;
|
widget_class->drag_drop = xed_view_drag_drop;
|
||||||
widget_class->button_press_event = xed_view_button_press_event;
|
widget_class->button_press_event = xed_view_button_press_event;
|
||||||
|
widget_class->realize = xed_view_realize;
|
||||||
klass->start_interactive_goto_line = start_interactive_goto_line;
|
klass->start_interactive_goto_line = start_interactive_goto_line;
|
||||||
|
|
||||||
text_view_class->delete_from_cursor = xed_view_delete_from_cursor;
|
text_view_class->delete_from_cursor = xed_view_delete_from_cursor;
|
||||||
|
@ -152,6 +159,24 @@ current_buffer_removed (XedView *view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
extension_added (PeasExtensionSet *extensions,
|
||||||
|
PeasPluginInfo *info,
|
||||||
|
PeasExtension *exten,
|
||||||
|
XedView *view)
|
||||||
|
{
|
||||||
|
peas_extension_call (exten, "activate");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
extension_removed (PeasExtensionSet *extensions,
|
||||||
|
PeasPluginInfo *info,
|
||||||
|
PeasExtension *exten,
|
||||||
|
XedView *view)
|
||||||
|
{
|
||||||
|
peas_extension_call (exten, "deactivate");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_notify_buffer_cb (XedView *view,
|
on_notify_buffer_cb (XedView *view,
|
||||||
GParamSpec *arg1,
|
GParamSpec *arg1,
|
||||||
|
@ -223,6 +248,14 @@ xed_view_init (XedView *view)
|
||||||
gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
|
gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||||
|
XED_TYPE_VIEW_ACTIVATABLE, "view", view, NULL);
|
||||||
|
|
||||||
|
g_signal_connect (view->priv->extensions, "extension-added",
|
||||||
|
G_CALLBACK (extension_added), view);
|
||||||
|
g_signal_connect (view->priv->extensions, "extension-removed",
|
||||||
|
G_CALLBACK (extension_removed), view);
|
||||||
|
|
||||||
/* Act on buffer change */
|
/* Act on buffer change */
|
||||||
g_signal_connect(view, "notify::buffer", G_CALLBACK (on_notify_buffer_cb), NULL);
|
g_signal_connect(view, "notify::buffer", G_CALLBACK (on_notify_buffer_cb), NULL);
|
||||||
}
|
}
|
||||||
|
@ -234,6 +267,12 @@ xed_view_dispose (GObject *object)
|
||||||
|
|
||||||
view = XED_VIEW(object);
|
view = XED_VIEW(object);
|
||||||
|
|
||||||
|
if (view->priv->extensions != NULL)
|
||||||
|
{
|
||||||
|
g_object_unref (view->priv->extensions);
|
||||||
|
view->priv->extensions = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (view->priv->search_window != NULL)
|
if (view->priv->search_window != NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_destroy (view->priv->search_window);
|
gtk_widget_destroy (view->priv->search_window);
|
||||||
|
@ -261,7 +300,8 @@ xed_view_finalize (GObject *object)
|
||||||
XedView *view;
|
XedView *view;
|
||||||
view = XED_VIEW(object);
|
view = XED_VIEW(object);
|
||||||
current_buffer_removed (view);
|
current_buffer_removed (view);
|
||||||
(* G_OBJECT_CLASS (xed_view_parent_class)->finalize) (object);
|
|
||||||
|
G_OBJECT_CLASS (xed_view_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
|
@ -1141,6 +1181,20 @@ xed_view_button_press_event (GtkWidget *widget,
|
||||||
return GTK_WIDGET_CLASS (xed_view_parent_class)->button_press_event (widget, event);
|
return GTK_WIDGET_CLASS (xed_view_parent_class)->button_press_event (widget, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_view_realize (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
XedView *view = XED_VIEW (widget);
|
||||||
|
|
||||||
|
if (!view->priv->view_realized)
|
||||||
|
{
|
||||||
|
peas_extension_set_call (view->priv->extensions, "activate");
|
||||||
|
view->priv->view_realized = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GTK_WIDGET_CLASS (xed_view_parent_class)->realize (widget);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
search_highlight_updated_cb (XedDocument *doc,
|
search_highlight_updated_cb (XedDocument *doc,
|
||||||
GtkTextIter *start,
|
GtkTextIter *start,
|
||||||
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* xed-window-activatable.h
|
||||||
|
* This file is part of xed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Steve Frécinaux
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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
|
||||||
|
* GNU Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "xed-window-activatable.h"
|
||||||
|
#include "xed-window.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:xed-window-activatable
|
||||||
|
* @short_description: Interface for activatable extensions on windows
|
||||||
|
* @see_also: #PeasExtensionSet
|
||||||
|
*
|
||||||
|
* #XedWindowActivatable is an interface which should be implemented by
|
||||||
|
* extensions that should be activated on a xed main window.
|
||||||
|
**/
|
||||||
|
G_DEFINE_INTERFACE(XedWindowActivatable, xed_window_activatable, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
void
|
||||||
|
xed_window_activatable_default_init (XedWindowActivatableInterface *iface)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* XedWindowActivatable:window:
|
||||||
|
*
|
||||||
|
* The window property contains the xed window for this
|
||||||
|
* #XedWindowActivatable instance.
|
||||||
|
*/
|
||||||
|
g_object_interface_install_property (iface,
|
||||||
|
g_param_spec_object ("window",
|
||||||
|
"Window",
|
||||||
|
"The xed window",
|
||||||
|
XED_TYPE_WINDOW,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xed_window_activatable_activate:
|
||||||
|
* @activatable: A #XedWindowActivatable.
|
||||||
|
*
|
||||||
|
* Activates the extension on the window property.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xed_window_activatable_activate (XedWindowActivatable *activatable)
|
||||||
|
{
|
||||||
|
XedWindowActivatableInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
|
||||||
|
|
||||||
|
iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
|
||||||
|
if (iface->activate != NULL)
|
||||||
|
{
|
||||||
|
iface->activate (activatable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xed_window_activatable_deactivate:
|
||||||
|
* @activatable: A #XedWindowActivatable.
|
||||||
|
*
|
||||||
|
* Deactivates the extension on the window property.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xed_window_activatable_deactivate (XedWindowActivatable *activatable)
|
||||||
|
{
|
||||||
|
XedWindowActivatableInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
|
||||||
|
|
||||||
|
iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
|
||||||
|
if (iface->deactivate != NULL)
|
||||||
|
{
|
||||||
|
iface->deactivate (activatable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xed_window_activatable_update_state:
|
||||||
|
* @activatable: A #XedWindowActivatable.
|
||||||
|
*
|
||||||
|
* Triggers an update of the extension insternal state to take into account
|
||||||
|
* state changes in the window state, due to some event or user action.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xed_window_activatable_update_state (XedWindowActivatable *activatable)
|
||||||
|
{
|
||||||
|
XedWindowActivatableInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
|
||||||
|
|
||||||
|
iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
|
||||||
|
if (iface->update_state != NULL)
|
||||||
|
{
|
||||||
|
iface->update_state (activatable);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* xed-window-activatable.h
|
||||||
|
* This file is part of xed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 - Steve Frécinaux
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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
|
||||||
|
* GNU Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XED_WINDOW_ACTIVATABLE_H__
|
||||||
|
#define __XED_WINDOW_ACTIVATABLE_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Type checking and casting macros
|
||||||
|
*/
|
||||||
|
#define XED_TYPE_WINDOW_ACTIVATABLE (xed_window_activatable_get_type ())
|
||||||
|
#define XED_WINDOW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_WINDOW_ACTIVATABLE, XedWindowActivatable))
|
||||||
|
#define XED_WINDOW_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XED_TYPE_WINDOW_ACTIVATABLE, XedWindowActivatableInterface))
|
||||||
|
#define XED_IS_WINDOW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_WINDOW_ACTIVATABLE))
|
||||||
|
#define XED_WINDOW_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XED_TYPE_WINDOW_ACTIVATABLE, XedWindowActivatableInterface))
|
||||||
|
|
||||||
|
typedef struct _XedWindowActivatable XedWindowActivatable; /* dummy typedef */
|
||||||
|
typedef struct _XedWindowActivatableInterface XedWindowActivatableInterface;
|
||||||
|
|
||||||
|
struct _XedWindowActivatableInterface
|
||||||
|
{
|
||||||
|
GTypeInterface g_iface;
|
||||||
|
|
||||||
|
/* Virtual public methods */
|
||||||
|
void (*activate) (XedWindowActivatable *activatable);
|
||||||
|
void (*deactivate) (XedWindowActivatable *activatable);
|
||||||
|
void (*update_state) (XedWindowActivatable *activatable);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public methods
|
||||||
|
*/
|
||||||
|
GType xed_window_activatable_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
void xed_window_activatable_activate (XedWindowActivatable *activatable);
|
||||||
|
void xed_window_activatable_deactivate (XedWindowActivatable *activatable);
|
||||||
|
void xed_window_activatable_update_state (XedWindowActivatable *activatable);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __XED_WINDOW_ACTIVATABLE_H__ */
|
|
@ -9,7 +9,6 @@
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gtksourceview/gtksource.h>
|
#include <gtksourceview/gtksource.h>
|
||||||
#include <libpeas/peas-activatable.h>
|
|
||||||
#include <libpeas/peas-extension-set.h>
|
#include <libpeas/peas-extension-set.h>
|
||||||
|
|
||||||
#include "xed-ui.h"
|
#include "xed-ui.h"
|
||||||
|
@ -27,6 +26,7 @@
|
||||||
#include "xed-panel.h"
|
#include "xed-panel.h"
|
||||||
#include "xed-documents-panel.h"
|
#include "xed-documents-panel.h"
|
||||||
#include "xed-plugins-engine.h"
|
#include "xed-plugins-engine.h"
|
||||||
|
#include "xed-window-activatable.h"
|
||||||
#include "xed-enum-types.h"
|
#include "xed-enum-types.h"
|
||||||
#include "xed-dirs.h"
|
#include "xed-dirs.h"
|
||||||
#include "xed-status-combo-box.h"
|
#include "xed-status-combo-box.h"
|
||||||
|
@ -142,7 +142,7 @@ xed_window_dispose (GObject *object)
|
||||||
|
|
||||||
xed_debug (DEBUG_WINDOW);
|
xed_debug (DEBUG_WINDOW);
|
||||||
|
|
||||||
window = XED_WINDOW(object);
|
window = XED_WINDOW (object);
|
||||||
|
|
||||||
/* Stop tracking removal of panes otherwise we always
|
/* Stop tracking removal of panes otherwise we always
|
||||||
* end up with thinking we had no pane active, since they
|
* end up with thinking we had no pane active, since they
|
||||||
|
@ -163,11 +163,13 @@ xed_window_dispose (GObject *object)
|
||||||
if (!window->priv->dispose_has_run)
|
if (!window->priv->dispose_has_run)
|
||||||
{
|
{
|
||||||
save_panes_state (window);
|
save_panes_state (window);
|
||||||
|
|
||||||
/* Note that unreffing the extension will automatically remove
|
/* Note that unreffing the extension will automatically remove
|
||||||
all extensions which in turn will deactivate the extension */
|
all extensions which in turn will deactivate the extension */
|
||||||
g_object_unref (window->priv->extensions);
|
g_object_unref (window->priv->extensions);
|
||||||
|
|
||||||
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
||||||
|
|
||||||
window->priv->dispose_has_run = TRUE;
|
window->priv->dispose_has_run = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,23 +193,10 @@ xed_window_dispose (GObject *object)
|
||||||
window->priv->recents_handler_id = 0;
|
window->priv->recents_handler_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->priv->manager != NULL)
|
g_clear_object (&window->priv->manager);
|
||||||
{
|
g_clear_object (&window->priv->message_bus);
|
||||||
g_object_unref (window->priv->manager);
|
g_clear_object (&window->priv->window_group);
|
||||||
window->priv->manager = NULL;
|
g_clear_object (&window->priv->default_location);
|
||||||
}
|
|
||||||
|
|
||||||
if (window->priv->message_bus != NULL)
|
|
||||||
{
|
|
||||||
g_object_unref (window->priv->message_bus);
|
|
||||||
window->priv->message_bus = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window->priv->window_group != NULL)
|
|
||||||
{
|
|
||||||
g_object_unref (window->priv->window_group);
|
|
||||||
window->priv->window_group = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now that there have broken some reference loops, force collection again. */
|
/* Now that there have broken some reference loops, force collection again. */
|
||||||
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
||||||
|
@ -218,13 +207,8 @@ xed_window_dispose (GObject *object)
|
||||||
static void
|
static void
|
||||||
xed_window_finalize (GObject *object)
|
xed_window_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
XedWindow *window;
|
|
||||||
xed_debug (DEBUG_WINDOW);
|
xed_debug (DEBUG_WINDOW);
|
||||||
window = XED_WINDOW(object);
|
|
||||||
if (window->priv->default_location != NULL)
|
|
||||||
{
|
|
||||||
g_object_unref (window->priv->default_location);
|
|
||||||
}
|
|
||||||
G_OBJECT_CLASS (xed_window_parent_class)->finalize (object);
|
G_OBJECT_CLASS (xed_window_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +630,7 @@ set_sensitivity_according_to_tab (XedWindow *window,
|
||||||
|
|
||||||
update_next_prev_doc_sensitivity (window, tab);
|
update_next_prev_doc_sensitivity (window, tab);
|
||||||
|
|
||||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2376,7 +2360,7 @@ sync_name (XedTab *tab,
|
||||||
g_free (escaped_name);
|
g_free (escaped_name);
|
||||||
g_free (tip);
|
g_free (tip);
|
||||||
|
|
||||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||||
}
|
}
|
||||||
|
|
||||||
static XedWindow *
|
static XedWindow *
|
||||||
|
@ -2789,7 +2773,7 @@ selection_changed (XedDocument *doc,
|
||||||
gtk_action_set_sensitive (action,
|
gtk_action_set_sensitive (action,
|
||||||
state_normal && editable && gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER(doc)));
|
state_normal && editable && gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER(doc)));
|
||||||
|
|
||||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2798,7 +2782,7 @@ sync_languages_menu (XedDocument *doc,
|
||||||
XedWindow *window)
|
XedWindow *window)
|
||||||
{
|
{
|
||||||
update_languages_menu (window);
|
update_languages_menu (window);
|
||||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2808,7 +2792,7 @@ readonly_changed (XedDocument *doc,
|
||||||
{
|
{
|
||||||
set_sensitivity_according_to_tab (window, window->priv->active_tab);
|
set_sensitivity_according_to_tab (window, window->priv->active_tab);
|
||||||
sync_name (window->priv->active_tab, NULL, window);
|
sync_name (window->priv->active_tab, NULL, window);
|
||||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2816,7 +2800,7 @@ editable_changed (XedView *view,
|
||||||
GParamSpec *arg1,
|
GParamSpec *arg1,
|
||||||
XedWindow *window)
|
XedWindow *window)
|
||||||
{
|
{
|
||||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2964,7 +2948,7 @@ notebook_tab_removed (XedNotebook *notebook,
|
||||||
|
|
||||||
if (window->priv->num_tabs == 0)
|
if (window->priv->num_tabs == 0)
|
||||||
{
|
{
|
||||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||||
}
|
}
|
||||||
|
|
||||||
update_window_state (window);
|
update_window_state (window);
|
||||||
|
@ -3374,21 +3358,21 @@ add_notebook (XedWindow *window,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_extension_added (PeasExtensionSet *extensions,
|
extension_added (PeasExtensionSet *extensions,
|
||||||
PeasPluginInfo *info,
|
PeasPluginInfo *info,
|
||||||
PeasExtension *exten,
|
PeasExtension *exten,
|
||||||
XedWindow *window)
|
XedWindow *window)
|
||||||
{
|
{
|
||||||
peas_extension_call (exten, "activate", window);
|
peas_extension_call (exten, "activate");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_extension_removed (PeasExtensionSet *extensions,
|
extension_removed (PeasExtensionSet *extensions,
|
||||||
PeasPluginInfo *info,
|
PeasPluginInfo *info,
|
||||||
PeasExtension *exten,
|
PeasExtension *exten,
|
||||||
XedWindow *window)
|
XedWindow *window)
|
||||||
{
|
{
|
||||||
peas_extension_call (exten, "deactivate", window);
|
peas_extension_call (exten, "deactivate");
|
||||||
|
|
||||||
/* Ensure update of the ui manager, because we suspect it does something with expected static strings in the
|
/* Ensure update of the ui manager, because we suspect it does something with expected static strings in the
|
||||||
* type module (when unloaded the strings don't exist anymore, and the ui manager update in a idle func) */
|
* type module (when unloaded the strings don't exist anymore, and the ui manager update in a idle func) */
|
||||||
|
@ -3501,13 +3485,13 @@ xed_window_init (XedWindow *window)
|
||||||
xed_debug_message (DEBUG_WINDOW, "Update plugins ui");
|
xed_debug_message (DEBUG_WINDOW, "Update plugins ui");
|
||||||
|
|
||||||
window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||||
PEAS_TYPE_ACTIVATABLE, "object", window, NULL);
|
XED_TYPE_WINDOW_ACTIVATABLE, "window", window, NULL);
|
||||||
|
|
||||||
|
g_signal_connect (window->priv->extensions, "extension-added", G_CALLBACK (extension_added), window);
|
||||||
|
g_signal_connect (window->priv->extensions, "extension-removed", G_CALLBACK (extension_removed), window);
|
||||||
|
|
||||||
peas_extension_set_call (window->priv->extensions, "activate");
|
peas_extension_set_call (window->priv->extensions, "activate");
|
||||||
|
|
||||||
g_signal_connect (window->priv->extensions, "extension-added", G_CALLBACK (on_extension_added), window);
|
|
||||||
g_signal_connect (window->priv->extensions, "extension-removed", G_CALLBACK (on_extension_removed), window);
|
|
||||||
|
|
||||||
/* set visibility of panes.
|
/* set visibility of panes.
|
||||||
* This needs to be done after plugins activatation */
|
* This needs to be done after plugins activatation */
|
||||||
init_panels_visibility (window);
|
init_panels_visibility (window);
|
||||||
|
|
Loading…
Reference in New Issue