diff --git a/plugins/Makefile.am b/plugins/Makefile.am index f31e42b..522da2c 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -5,6 +5,7 @@ DIST_SUBDIRS = \ modelines \ sort \ spell \ + taglist \ time SUBDIRS = \ @@ -14,6 +15,7 @@ SUBDIRS = \ modelines \ sort \ spell \ + taglist \ time if ENABLE_ENCHANT diff --git a/plugins/taglist/xed-taglist-plugin.c b/plugins/taglist/xed-taglist-plugin.c index 8d379dc..ea23652 100644 --- a/plugins/taglist/xed-taglist-plugin.c +++ b/plugins/taglist/xed-taglist-plugin.c @@ -36,59 +36,54 @@ #include "xed-taglist-plugin-parser.h" #include -#include -#include #include +#include #include #define XED_TAGLIST_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_TAGLIST_PLUGIN, XedTaglistPluginPrivate)) struct _XedTaglistPluginPrivate { - GtkWidget *window; + XedWindow *window; GtkWidget *taglist_panel; }; -static void peas_activatable_iface_init (PeasActivatableInterface *iface); +static void xed_window_activatable_iface_init (XedWindowActivatableInterface *iface); G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedTaglistPlugin, xed_taglist_plugin, PEAS_TYPE_EXTENSION_BASE, 0, - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, - peas_activatable_iface_init) \ - \ - _xed_taglist_plugin_panel_register_type (type_module); \ + G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_WINDOW_ACTIVATABLE, + xed_window_activatable_iface_init) \ + \ + _xed_taglist_plugin_panel_register_type (type_module); \ ) enum { PROP_0, - PROP_OBJECT + PROP_WINDOW }; static void xed_taglist_plugin_init (XedTaglistPlugin *plugin) { - plugin->priv = XED_TAGLIST_PLUGIN_GET_PRIVATE (plugin); + plugin->priv = XED_TAGLIST_PLUGIN_GET_PRIVATE (plugin); - xed_debug_message (DEBUG_PLUGINS, "XedTaglistPlugin initializing"); + xed_debug_message (DEBUG_PLUGINS, "XedTaglistPlugin initializing"); } static void xed_taglist_plugin_dispose (GObject *object) { - XedTaglistPlugin *plugin = XED_TAGLIST_PLUGIN (object); + XedTaglistPlugin *plugin = XED_TAGLIST_PLUGIN (object); - xed_debug_message (DEBUG_PLUGINS, "XedTaglistPlugin disposing"); + xed_debug_message (DEBUG_PLUGINS, "XedTaglistPlugin disposing"); - if (plugin->priv->window != NULL) - { - g_object_unref (plugin->priv->window); - plugin->priv->window = NULL; - } + g_clear_object (&plugin->priv->window); G_OBJECT_CLASS (xed_taglist_plugin_parent_class)->dispose (object); } @@ -98,64 +93,58 @@ xed_taglist_plugin_finalize (GObject *object) { xed_debug_message (DEBUG_PLUGINS, "XedTaglistPlugin finalizing"); - free_taglist (); + free_taglist (); - G_OBJECT_CLASS (xed_taglist_plugin_parent_class)->finalize (object); + G_OBJECT_CLASS (xed_taglist_plugin_parent_class)->finalize (object); } static void -xed_taglist_plugin_activate (PeasActivatable *activatable) +xed_taglist_plugin_activate (XedWindowActivatable *activatable) { XedTaglistPluginPrivate *priv; - XedWindow *window; - XedPanel *side_panel; - gchar *data_dir; + XedPanel *side_panel; + gchar *data_dir; - xed_debug (DEBUG_PLUGINS); + xed_debug (DEBUG_PLUGINS); priv = XED_TAGLIST_PLUGIN (activatable)->priv; - window = XED_WINDOW (priv->window); - side_panel = xed_window_get_side_panel (window); + side_panel = xed_window_get_side_panel (priv->window); - data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (activatable)); - priv->taglist_panel = xed_taglist_plugin_panel_new (window, data_dir); - g_free (data_dir); + data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (activatable)); + priv->taglist_panel = xed_taglist_plugin_panel_new (priv->window, data_dir); + g_free (data_dir); - xed_panel_add_item (side_panel, priv->taglist_panel, _("Tags"), "list-add"); + xed_panel_add_item (side_panel, priv->taglist_panel, _("Tags"), "list-add"); } static void -xed_taglist_plugin_deactivate (PeasActivatable *activatable) +xed_taglist_plugin_deactivate (XedWindowActivatable *activatable) { XedTaglistPluginPrivate *priv; - XedWindow *window; - XedPanel *side_panel; + XedPanel *side_panel; - xed_debug (DEBUG_PLUGINS); + xed_debug (DEBUG_PLUGINS); - priv = XED_TAGLIST_PLUGIN (activatable)->priv; - window = XED_WINDOW (priv->window); - side_panel = xed_window_get_side_panel (window); + priv = XED_TAGLIST_PLUGIN (activatable)->priv; + side_panel = xed_window_get_side_panel (priv->window); - xed_panel_remove_item (side_panel, priv->taglist_panel); + xed_panel_remove_item (side_panel, priv->taglist_panel); } static void -xed_taglist_plugin_update_state (PeasActivatable *activatable) +xed_taglist_plugin_update_state (XedWindowActivatable *activatable) { - XedTaglistPluginPrivate *priv; - XedWindow *window; - XedView *view; + XedTaglistPluginPrivate *priv; + XedView *view; - xed_debug (DEBUG_PLUGINS); + xed_debug (DEBUG_PLUGINS); - priv = XED_TAGLIST_PLUGIN (activatable)->priv; - window = XED_WINDOW (priv->window); - view = xed_window_get_active_view (window); + priv = XED_TAGLIST_PLUGIN (activatable)->priv; + view = xed_window_get_active_view (priv->window); - gtk_widget_set_sensitive (priv->taglist_panel, - (view != NULL) && - gtk_text_view_get_editable (GTK_TEXT_VIEW (view))); + gtk_widget_set_sensitive (priv->taglist_panel, + (view != NULL) && + gtk_text_view_get_editable (GTK_TEXT_VIEW (view))); } static void @@ -168,8 +157,8 @@ xed_taglist_plugin_set_property (GObject *object, switch (prop_id) { - case PROP_OBJECT: - plugin->priv->window = GTK_WIDGET (g_value_dup_object (value)); + case PROP_WINDOW: + plugin->priv->window = XED_WINDOW (g_value_dup_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -187,7 +176,7 @@ xed_taglist_plugin_get_property (GObject *object, switch (prop_id) { - case PROP_OBJECT: + case PROP_WINDOW: g_value_set_object (value, plugin->priv->window); break; default: @@ -199,16 +188,16 @@ xed_taglist_plugin_get_property (GObject *object, static void xed_taglist_plugin_class_init (XedTaglistPluginClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = xed_taglist_plugin_finalize; + object_class->finalize = xed_taglist_plugin_finalize; object_class->dispose = xed_taglist_plugin_dispose; object_class->set_property = xed_taglist_plugin_set_property; object_class->get_property = xed_taglist_plugin_get_property; - g_object_class_override_property (object_class, PROP_OBJECT, "object"); + g_object_class_override_property (object_class, PROP_WINDOW, "window"); - g_type_class_add_private (object_class, sizeof (XedTaglistPluginPrivate)); + g_type_class_add_private (object_class, sizeof (XedTaglistPluginPrivate)); } static void @@ -218,7 +207,7 @@ xed_taglist_plugin_class_finalize (XedTaglistPluginClass *klass) } static void -peas_activatable_iface_init (PeasActivatableInterface *iface) +xed_window_activatable_iface_init (XedWindowActivatableInterface *iface) { iface->activate = xed_taglist_plugin_activate; iface->deactivate = xed_taglist_plugin_deactivate; @@ -231,6 +220,6 @@ peas_register_types (PeasObjectModule *module) xed_taglist_plugin_register_type (G_TYPE_MODULE (module)); peas_object_module_register_extension_type (module, - PEAS_TYPE_ACTIVATABLE, + XED_TYPE_WINDOW_ACTIVATABLE, XED_TYPE_TAGLIST_PLUGIN); } diff --git a/plugins/taglist/xed-taglist-plugin.h b/plugins/taglist/xed-taglist-plugin.h index aa40462..4a2d035 100644 --- a/plugins/taglist/xed-taglist-plugin.h +++ b/plugins/taglist/xed-taglist-plugin.h @@ -23,8 +23,6 @@ * Modified by the xed Team, 2002-2005. See the AUTHORS file for a * list of people on the xed Team. * See the ChangeLog files for a list of changes. - * - * $Id$ */ #ifndef __XED_TAGLIST_PLUGIN_H__ @@ -40,20 +38,16 @@ G_BEGIN_DECLS /* * Type checking and casting macros */ -#define XED_TYPE_TAGLIST_PLUGIN (xed_taglist_plugin_get_type ()) -#define XED_TAGLIST_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_TAGLIST_PLUGIN, XedTaglistPlugin)) -#define XED_TAGLIST_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_TAGLIST_PLUGIN, XedTaglistPluginClass)) +#define XED_TYPE_TAGLIST_PLUGIN (xed_taglist_plugin_get_type ()) +#define XED_TAGLIST_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_TAGLIST_PLUGIN, XedTaglistPlugin)) +#define XED_TAGLIST_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_TAGLIST_PLUGIN, XedTaglistPluginClass)) #define XED_IS_TAGLIST_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XED_TYPE_TAGLIST_PLUGIN)) #define XED_IS_TAGLIST_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_TAGLIST_PLUGIN)) #define XED_TAGLIST_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), XED_TYPE_TAGLIST_PLUGIN, XedTaglistPluginClass)) -/* Private structure type */ -typedef struct _XedTaglistPluginPrivate XedTaglistPluginPrivate; - -/* - * Main object structure - */ typedef struct _XedTaglistPlugin XedTaglistPlugin; +typedef struct _XedTaglistPluginPrivate XedTaglistPluginPrivate; +typedef struct _XedTaglistPluginClass XedTaglistPluginClass; struct _XedTaglistPlugin { @@ -63,22 +57,13 @@ struct _XedTaglistPlugin XedTaglistPluginPrivate *priv; }; -/* - * Class definition - */ -typedef struct _XedTaglistPluginClass XedTaglistPluginClass; - struct _XedTaglistPluginClass { PeasExtensionBaseClass parent_class; }; -/* - * Public methods - */ -GType xed_taglist_plugin_get_type (void) G_GNUC_CONST; +GType xed_taglist_plugin_get_type (void) G_GNUC_CONST; -/* All the plugins must implement this function */ G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module); G_END_DECLS