[gedit] Port taglist plugin to libpeas
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Port taglist plugin to libpeas
- Date: Mon, 28 Jun 2010 18:38:39 +0000 (UTC)
commit c3471ad0a1e2a60a588f203421da1779a60649ff
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Jun 28 20:33:48 2010 +0200
Port taglist plugin to libpeas
plugins/Makefile.am | 10 +-
plugins/taglist/gedit-taglist-plugin-panel.c | 27 ++++--
plugins/taglist/gedit-taglist-plugin-panel.h | 29 +----
plugins/taglist/gedit-taglist-plugin-parser.h | 4 +-
plugins/taglist/gedit-taglist-plugin.c | 134 +++++++++++++-----------
plugins/taglist/gedit-taglist-plugin.h | 41 ++------
6 files changed, 117 insertions(+), 128 deletions(-)
---
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 06c934c..8a7e956 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -4,10 +4,10 @@ DIST_SUBDIRS = \
docinfo \
filebrowser \
modelines \
- sort
+ sort \
+ taglist
# spell \
-# taglist \
# time
# externaltools
# pythonconsole
@@ -19,9 +19,11 @@ SUBDIRS = \
docinfo \
filebrowser \
modelines \
- sort
+ sort \
+ taglist
-# taglist
+# filebrowser
+# modelines
# time
# pythonconsole
# quickopen
diff --git a/plugins/taglist/gedit-taglist-plugin-panel.c b/plugins/taglist/gedit-taglist-plugin-panel.c
index 1f6bab6..5942486 100644
--- a/plugins/taglist/gedit-taglist-plugin-panel.c
+++ b/plugins/taglist/gedit-taglist-plugin-panel.c
@@ -39,7 +39,6 @@
#include <gedit/gedit-utils.h>
#include <gedit/gedit-debug.h>
-#include <gedit/gedit-plugin.h>
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
@@ -68,7 +67,7 @@ struct _GeditTaglistPluginPanelPrivate
gchar *data_dir;
};
-GEDIT_PLUGIN_DEFINE_TYPE (GeditTaglistPluginPanel, gedit_taglist_plugin_panel, GTK_TYPE_VBOX)
+G_DEFINE_DYNAMIC_TYPE (GeditTaglistPluginPanel, gedit_taglist_plugin_panel, GTK_TYPE_VBOX)
enum
{
@@ -150,13 +149,18 @@ gedit_taglist_plugin_panel_class_init (GeditTaglistPluginPanelClass *klass)
g_object_class_install_property (object_class,
PROP_WINDOW,
g_param_spec_object ("window",
- "Window",
- "The GeditWindow this GeditTaglistPluginPanel is associated with",
- GEDIT_TYPE_WINDOW,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ "Window",
+ "The GeditWindow this GeditTaglistPluginPanel is associated with",
+ GEDIT_TYPE_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
- g_type_class_add_private (object_class, sizeof(GeditTaglistPluginPanelPrivate));
+ g_type_class_add_private (object_class, sizeof (GeditTaglistPluginPanelPrivate));
+}
+
+static void
+gedit_taglist_plugin_panel_class_finalize (GeditTaglistPluginPanelClass *klass)
+{
}
static void
@@ -774,4 +778,11 @@ gedit_taglist_plugin_panel_new (GeditWindow *window,
return GTK_WIDGET (panel);
}
+
+void
+_gedit_taglist_plugin_panel_register_type (GTypeModule *type_module)
+{
+ gedit_taglist_plugin_panel_register_type (type_module);
+}
+
/* ex:ts=8:noet: */
diff --git a/plugins/taglist/gedit-taglist-plugin-panel.h b/plugins/taglist/gedit-taglist-plugin-panel.h
index 247b3fb..859d6d2 100644
--- a/plugins/taglist/gedit-taglist-plugin-panel.h
+++ b/plugins/taglist/gedit-taglist-plugin-panel.h
@@ -23,9 +23,7 @@
/*
* Modified by the gedit Team, 2005. See the AUTHORS file for a
* list of people on the gedit Team.
- * See the ChangeLog files for a list of changes.
- *
- * $Id$
+ * See the ChangeLog files for a list of changes.
*/
#ifndef __GEDIT_TAGLIST_PLUGIN_PANEL_H__
@@ -37,9 +35,6 @@
G_BEGIN_DECLS
-/*
- * Type checking and casting macros
- */
#define GEDIT_TYPE_TAGLIST_PLUGIN_PANEL (gedit_taglist_plugin_panel_get_type())
#define GEDIT_TAGLIST_PLUGIN_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL, GeditTaglistPluginPanel))
#define GEDIT_TAGLIST_PLUGIN_PANEL_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL, GeditTaglistPluginPanel const))
@@ -48,13 +43,9 @@ G_BEGIN_DECLS
#define GEDIT_IS_TAGLIST_PLUGIN_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL))
#define GEDIT_TAGLIST_PLUGIN_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_TAGLIST_PLUGIN_PANEL, GeditTaglistPluginPanelClass))
-/* Private structure type */
-typedef struct _GeditTaglistPluginPanelPrivate GeditTaglistPluginPanelPrivate;
-
-/*
- * Main object structure
- */
-typedef struct _GeditTaglistPluginPanel GeditTaglistPluginPanel;
+typedef struct _GeditTaglistPluginPanel GeditTaglistPluginPanel;
+typedef struct _GeditTaglistPluginPanelPrivate GeditTaglistPluginPanelPrivate;
+typedef struct _GeditTaglistPluginPanelClass GeditTaglistPluginPanelClass;
struct _GeditTaglistPluginPanel
{
@@ -64,26 +55,18 @@ struct _GeditTaglistPluginPanel
GeditTaglistPluginPanelPrivate *priv;
};
-/*
- * Class definition
- */
-typedef struct _GeditTaglistPluginPanelClass GeditTaglistPluginPanelClass;
-
struct _GeditTaglistPluginPanelClass
{
GtkVBoxClass parent_class;
};
-/*
- * Public methods
- */
-GType gedit_taglist_plugin_panel_register_type (GTypeModule *module);
-
GType gedit_taglist_plugin_panel_get_type (void) G_GNUC_CONST;
GtkWidget *gedit_taglist_plugin_panel_new (GeditWindow *window,
const gchar *data_dir);
+void _gedit_taglist_plugin_panel_register_type (GTypeModule *type_module);
+
G_END_DECLS
#endif /* __GEDIT_TAGLIST_PLUGIN_PANEL_H__ */
diff --git a/plugins/taglist/gedit-taglist-plugin-parser.h b/plugins/taglist/gedit-taglist-plugin-parser.h
index 1a73025..581a28f 100644
--- a/plugins/taglist/gedit-taglist-plugin-parser.h
+++ b/plugins/taglist/gedit-taglist-plugin-parser.h
@@ -23,9 +23,7 @@
/*
* Modified by the gedit Team, 2002-2005. See the AUTHORS file for a
* list of people on the gedit Team.
- * See the ChangeLog files for a list of changes.
- *
- * $Id$
+ * See the ChangeLog files for a list of changes.
*/
#ifndef __GEDIT_TAGLIST_PLUGIN_PARSER_H__
diff --git a/plugins/taglist/gedit-taglist-plugin.c b/plugins/taglist/gedit-taglist-plugin.c
index 4a5e839..7e17f99 100644
--- a/plugins/taglist/gedit-taglist-plugin.c
+++ b/plugins/taglist/gedit-taglist-plugin.c
@@ -35,25 +35,31 @@
#include "gedit-taglist-plugin-panel.h"
#include "gedit-taglist-plugin-parser.h"
-#include <glib/gi18n-lib.h>
-#include <gmodule.h>
+#include <glib/gi18n.h>
-#include <gedit/gedit-plugin.h>
+#include <gedit/gedit-window.h>
+#include <gedit/gedit-window-activatable.h>
#include <gedit/gedit-debug.h>
-#define WINDOW_DATA_KEY "GeditTaglistPluginWindowData"
-
#define GEDIT_TAGLIST_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPluginPrivate))
+static void gedit_window_activatable_iface_init (GeditWindowActivatableInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (GeditTaglistPlugin,
+ gedit_taglist_plugin,
+ PEAS_TYPE_EXTENSION_BASE,
+ 0,
+ G_IMPLEMENT_INTERFACE_DYNAMIC (GEDIT_TYPE_WINDOW_ACTIVATABLE,
+ gedit_window_activatable_iface_init) \
+ \
+ _gedit_taglist_plugin_panel_register_type (type_module); \
+)
+
struct _GeditTaglistPluginPrivate
{
- gpointer dummy;
+ GtkWidget *taglist_panel;
};
-GEDIT_PLUGIN_REGISTER_TYPE_WITH_CODE (GeditTaglistPlugin, gedit_taglist_plugin,
- gedit_taglist_plugin_panel_register_type (module);
-)
-
static void
gedit_taglist_plugin_init (GeditTaglistPlugin *plugin)
{
@@ -65,82 +71,69 @@ gedit_taglist_plugin_init (GeditTaglistPlugin *plugin)
static void
gedit_taglist_plugin_finalize (GObject *object)
{
-/*
- GeditTaglistPlugin *plugin = GEDIT_TAGLIST_PLUGIN (object);
-*/
gedit_debug_message (DEBUG_PLUGINS, "GeditTaglistPlugin finalizing");
free_taglist ();
-
+
G_OBJECT_CLASS (gedit_taglist_plugin_parent_class)->finalize (object);
}
static void
-impl_activate (GeditPlugin *plugin,
- GeditWindow *window)
+gedit_taglist_plugin_activate (GeditWindowActivatable *activatable,
+ GeditWindow *window)
{
+ GeditTaglistPluginPrivate *priv;
GeditPanel *side_panel;
- GtkWidget *taglist_panel;
gchar *data_dir;
-
+
gedit_debug (DEBUG_PLUGINS);
-
- g_return_if_fail (g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY) == NULL);
-
+
+ priv = GEDIT_TAGLIST_PLUGIN (activatable)->priv;
+
side_panel = gedit_window_get_side_panel (window);
-
- data_dir = gedit_plugin_get_data_dir (plugin);
- taglist_panel = gedit_taglist_plugin_panel_new (window, data_dir);
+
+ data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (activatable));
+ priv->taglist_panel = gedit_taglist_plugin_panel_new (window, data_dir);
g_free (data_dir);
-
- gedit_panel_add_item_with_stock_icon (side_panel,
- taglist_panel,
+
+ gedit_panel_add_item_with_stock_icon (side_panel,
+ priv->taglist_panel,
"GeditTagListPanel",
- _("Tags"),
+ _("Tags"),
GTK_STOCK_ADD);
-
- g_object_set_data (G_OBJECT (window),
- WINDOW_DATA_KEY,
- taglist_panel);
}
static void
-impl_deactivate (GeditPlugin *plugin,
- GeditWindow *window)
+gedit_taglist_plugin_deactivate (GeditWindowActivatable *activatable,
+ GeditWindow *window)
{
+ GeditTaglistPluginPrivate *priv;
GeditPanel *side_panel;
- gpointer data;
-
+
gedit_debug (DEBUG_PLUGINS);
-
- data = g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
-
+
+ priv = GEDIT_TAGLIST_PLUGIN (activatable)->priv;
+
side_panel = gedit_window_get_side_panel (window);
- gedit_panel_remove_item (side_panel,
- GTK_WIDGET (data));
-
- g_object_set_data (G_OBJECT (window),
- WINDOW_DATA_KEY,
- NULL);
+ gedit_panel_remove_item (side_panel,
+ priv->taglist_panel);
}
static void
-impl_update_ui (GeditPlugin *plugin,
- GeditWindow *window)
+gedit_taglist_plugin_update_state (GeditWindowActivatable *activatable,
+ GeditWindow *window)
{
- gpointer data;
+ GeditTaglistPluginPrivate *priv;
GeditView *view;
-
+
gedit_debug (DEBUG_PLUGINS);
-
- data = g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
-
+
+ priv = GEDIT_TAGLIST_PLUGIN (activatable)->priv;
+
view = gedit_window_get_active_view (window);
-
- gtk_widget_set_sensitive (GTK_WIDGET (data),
+
+ gtk_widget_set_sensitive (priv->taglist_panel,
(view != NULL) &&
gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
}
@@ -149,14 +142,33 @@ static void
gedit_taglist_plugin_class_init (GeditTaglistPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GeditPluginClass *plugin_class = GEDIT_PLUGIN_CLASS (klass);
object_class->finalize = gedit_taglist_plugin_finalize;
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
- plugin_class->update_ui = impl_update_ui;
-
g_type_class_add_private (object_class, sizeof (GeditTaglistPluginPrivate));
}
+
+static void
+gedit_taglist_plugin_class_finalize (GeditTaglistPluginClass *klass)
+{
+}
+
+static void
+gedit_window_activatable_iface_init (GeditWindowActivatableInterface *iface)
+{
+ iface->activate = gedit_taglist_plugin_activate;
+ iface->deactivate = gedit_taglist_plugin_deactivate;
+ iface->update_state = gedit_taglist_plugin_update_state;
+}
+
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+ gedit_taglist_plugin_register_type (G_TYPE_MODULE (module));
+
+ peas_object_module_register_extension_type (module,
+ GEDIT_TYPE_WINDOW_ACTIVATABLE,
+ GEDIT_TYPE_TAGLIST_PLUGIN);
+}
+
/* ex:ts=8:noet: */
diff --git a/plugins/taglist/gedit-taglist-plugin.h b/plugins/taglist/gedit-taglist-plugin.h
index d2314ad..dc27e9f 100644
--- a/plugins/taglist/gedit-taglist-plugin.h
+++ b/plugins/taglist/gedit-taglist-plugin.h
@@ -16,15 +16,12 @@
* You should have received a copy of the GNU 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.
- *
*/
/*
* Modified by the gedit Team, 2002-2005. See the AUTHORS file for a
* list of people on the gedit Team.
- * See the ChangeLog files for a list of changes.
- *
- * $Id$
+ * See the ChangeLog files for a list of changes.
*/
#ifndef __GEDIT_TAGLIST_PLUGIN_H__
@@ -32,55 +29,41 @@
#include <glib.h>
#include <glib-object.h>
-#include <gedit/gedit-plugin.h>
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
G_BEGIN_DECLS
-/*
- * Type checking and casting macros
- */
#define GEDIT_TYPE_TAGLIST_PLUGIN (gedit_taglist_plugin_get_type ())
-#define GEDIT_TAGLIST_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPlugin))
-#define GEDIT_TAGLIST_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPluginClass))
+#define GEDIT_TAGLIST_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPlugin))
+#define GEDIT_TAGLIST_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPluginClass))
#define GEDIT_IS_TAGLIST_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GEDIT_TYPE_TAGLIST_PLUGIN))
#define GEDIT_IS_TAGLIST_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GEDIT_TYPE_TAGLIST_PLUGIN))
#define GEDIT_TAGLIST_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GEDIT_TYPE_TAGLIST_PLUGIN, GeditTaglistPluginClass))
-/* Private structure type */
-typedef struct _GeditTaglistPluginPrivate GeditTaglistPluginPrivate;
-
-/*
- * Main object structure
- */
typedef struct _GeditTaglistPlugin GeditTaglistPlugin;
+typedef struct _GeditTaglistPluginPrivate GeditTaglistPluginPrivate;
+typedef struct _GeditTaglistPluginClass GeditTaglistPluginClass;
struct _GeditTaglistPlugin
{
- GeditPlugin parent_instance;
+ PeasExtensionBase parent_instance;
/*< private >*/
GeditTaglistPluginPrivate *priv;
};
-/*
- * Class definition
- */
-typedef struct _GeditTaglistPluginClass GeditTaglistPluginClass;
-
struct _GeditTaglistPluginClass
{
- GeditPluginClass parent_class;
+ PeasExtensionBaseClass parent_class;
};
-/*
- * Public methods
- */
-GType gedit_taglist_plugin_get_type (void) G_GNUC_CONST;
+GType gedit_taglist_plugin_get_type (void) G_GNUC_CONST;
-/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_gedit_plugin (GTypeModule *module);
+G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
G_END_DECLS
#endif /* __GEDIT_TAGLIST_PLUGIN_H__ */
+
/* ex:ts=8:noet: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]