[gtranslator] Port gucharmap plugin to gtk3/libpeas
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Port gucharmap plugin to gtk3/libpeas
- Date: Sat, 4 Dec 2010 11:07:22 +0000 (UTC)
commit 2b4fd9e12d68a24bec499e4989ca000dd32f0c53
Author: Kenny Meyer <knny myer gmail com>
Date: Thu Dec 2 22:13:19 2010 -0300
Port gucharmap plugin to gtk3/libpeas
configure.ac | 12 +-
plugins/charmap/Makefile.am | 11 +-
plugins/charmap/gtr-charmap-panel.c | 76 +----
plugins/charmap/gtr-charmap-panel.h | 54 +---
plugins/charmap/gtr-charmap-plugin.c | 298 ++++++++++----------
plugins/charmap/gtr-charmap-plugin.h | 51 ++--
...in.desktop.in => gtr-charmap.plugin.desktop.in} | 2 +-
po/POTFILES.in | 2 +-
8 files changed, 216 insertions(+), 290 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d5d5bfb..1e9a10d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -209,15 +209,11 @@ AM_CONDITIONAL(USE_DICTIONARY, test x"$have_gdict" = "xyes")
# gucharmap
# ================================================================
have_gucharmap=no
-GUCHARMAP2_OPTIONAL=100
-PKG_CHECK_MODULES([GUCHARMAP],[gucharmap-2 >= $GUCHARMAP2_OPTIONAL],
- [have_gucharmap_2=yes],[have_gucharmap_2=no])
+GUCHARMAP_OPTIONAL=2.33.0
+PKG_CHECK_MODULES([GUCHARMAP],[gucharmap-2.90 >= $GUCHARMAP_OPTIONAL],
+ [have_gucharmap=yes],[have_gucharmap=no])
-if test "$have_gucharmap_2" = "yes"; then
- AC_DEFINE([HAVE_GUCHARMAP_2],[1],[Define if gucharmap API is version 2])
-fi
-
-AM_CONDITIONAL(USE_CHARMAP, test x"$have_gucharmap2" = "xyes")
+AM_CONDITIONAL(USE_CHARMAP, test x"$have_gucharmap" = "xyes")
dnl -------------------------------------------------------------------
dnl Enable debug builds.
diff --git a/plugins/charmap/Makefile.am b/plugins/charmap/Makefile.am
index 3833c40..187f26f 100644
--- a/plugins/charmap/Makefile.am
+++ b/plugins/charmap/Makefile.am
@@ -4,13 +4,10 @@ plugindir = $(libdir)/gtranslator/plugins
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/src \
- -I$(top_srcdir)/src/toolbareditor \
- -I$(top_srcdir)/src/plugin-system \
$(GTRANSLATOR_CFLAGS) \
$(GUCHARMAP_CFLAGS) \
$(WARN_CFLAGS) \
- $(DISABLE_DEPRECATED) \
- -DGTR_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+ $(DISABLE_DEPRECATED)
plugin_LTLIBRARIES = libcharmap.la
@@ -31,11 +28,11 @@ pixmaps__DATA = \
# Plugin Info
-plugin_in_files = gtr-charmap.gtranslator-plugin.desktop.in
+plugin_in_files = gtr-charmap.plugin.desktop.in
-%.gtranslator.plugin: %.gtranslator-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
-plugin_DATA = $(plugin_in_files:.gtranslator-plugin.desktop.in=.gtranslator.plugin)
+plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
EXTRA_DIST = $(pixmaps__DATA) $(plugin_in_files)
diff --git a/plugins/charmap/gtr-charmap-panel.c b/plugins/charmap/gtr-charmap-panel.c
index 1be20b7..c5d3432 100644
--- a/plugins/charmap/gtr-charmap-panel.c
+++ b/plugins/charmap/gtr-charmap-panel.c
@@ -22,14 +22,9 @@
#include <config.h>
#endif
-#include "gtr-plugin.h"
#include "gtr-charmap-panel.h"
-#ifdef HAVE_GUCHARMAP_2
#include <gucharmap/gucharmap.h>
-#else
-#include <gucharmap/gucharmap-script-chapters.h>
-#endif
#define GTR_CHARMAP_PANEL_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
(object), \
@@ -38,20 +33,15 @@
struct _GtrCharmapPanelPrivate
{
-#ifdef HAVE_GUCHARMAP_2
GucharmapChaptersView *chapters_view;
GucharmapChartable *chartable;
-#else
- GtkWidget *table;
- GtkWidget *chapters;
-#endif
};
-GTR_PLUGIN_DEFINE_TYPE (GtrCharmapPanel, gtr_charmap_panel, GTK_TYPE_VBOX)
-#ifdef HAVE_GUCHARMAP_2
- static void
- on_chapter_view_selection_changed (GtkTreeSelection * selection,
- GtrCharmapPanel * panel)
+G_DEFINE_DYNAMIC_TYPE (GtrCharmapPanel, gtr_charmap_panel, GTK_TYPE_VBOX)
+
+static void
+on_chapter_view_selection_changed (GtkTreeSelection *selection,
+ GtrCharmapPanel *panel)
{
GtrCharmapPanelPrivate *priv = panel->priv;
GucharmapCodepointList *codepoint_list;
@@ -60,41 +50,24 @@ GTR_PLUGIN_DEFINE_TYPE (GtrCharmapPanel, gtr_charmap_panel, GTK_TYPE_VBOX)
if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
return;
- codepoint_list =
- gucharmap_chapters_view_get_codepoint_list (priv->chapters_view);
+ codepoint_list = gucharmap_chapters_view_get_codepoint_list (priv->chapters_view);
gucharmap_chartable_set_codepoint_list (priv->chartable, codepoint_list);
g_object_unref (codepoint_list);
}
-#else
- static void
- on_chapter_changed (GucharmapChapters * chapters,
- GtrCharmapPanel * panel)
-{
- gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (panel->priv->table),
- gucharmap_chapters_get_codepoint_list
- (chapters));
-}
-#endif /* HAVE_GUCHARMAP_2 */
-
static void
-gtr_charmap_panel_init (GtrCharmapPanel * panel)
+gtr_charmap_panel_init (GtrCharmapPanel *panel)
{
GtrCharmapPanelPrivate *priv;
GtkPaned *paned;
-#ifdef HAVE_GUCHARMAP_2
GtkWidget *scrolled_window, *view, *chartable;
GtkTreeSelection *selection;
GucharmapChaptersModel *model;
-#else
- GucharmapCodepointList *codepoint_list;
-#endif
priv = panel->priv = GTR_CHARMAP_PANEL_GET_PRIVATE (panel);
paned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL));
-#ifdef HAVE_GUCHARMAP_2
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
@@ -134,26 +107,6 @@ gtr_charmap_panel_init (GtrCharmapPanel * panel)
gtk_widget_show (scrolled_window);
gucharmap_chapters_view_select_locale (priv->chapters_view);
-#else
- priv->chapters = gucharmap_script_chapters_new ();
- g_signal_connect (priv->chapters,
- "changed", G_CALLBACK (on_chapter_changed), panel);
-
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW
- (GUCHARMAP_CHAPTERS
- (priv->chapters)->tree_view), FALSE);
-
- codepoint_list = gucharmap_chapters_get_codepoint_list
- (GUCHARMAP_CHAPTERS (priv->chapters));
-
- priv->table = gucharmap_table_new ();
-
- gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (priv->table),
- codepoint_list);
-
- gtk_paned_pack1 (paned, priv->chapters, FALSE, TRUE);
- gtk_paned_pack2 (paned, priv->table, TRUE, TRUE);
-#endif /* HAVE_GUCHARMAP_2 */
gtk_paned_set_position (paned, 150);
@@ -176,22 +129,25 @@ gtr_charmap_panel_class_init (GtrCharmapPanelClass * klass)
object_class->finalize = gtr_charmap_panel_finalize;
}
+static void
+gtr_charmap_panel_class_finalize (GtrCharmapPanelClass *klass)
+{
+}
+
GtkWidget *
gtr_charmap_panel_new (void)
{
return GTK_WIDGET (g_object_new (GTR_TYPE_CHARMAP_PANEL, NULL));
}
-#ifdef HAVE_GUCHARMAP_2
GucharmapChartable *
gtr_charmap_panel_get_chartable (GtrCharmapPanel * panel)
{
return panel->priv->chartable;
}
-#else
-GucharmapTable *
-gtr_charmap_panel_get_table (GtrCharmapPanel * panel)
+
+void
+_gtr_charmap_panel_register_type (GTypeModule * type_module)
{
- return GUCHARMAP_TABLE (panel->priv->table);
+ gtr_charmap_panel_register_type (type_module);
}
-#endif
diff --git a/plugins/charmap/gtr-charmap-panel.h b/plugins/charmap/gtr-charmap-panel.h
index 5cb630c..304a206 100644
--- a/plugins/charmap/gtr-charmap-panel.h
+++ b/plugins/charmap/gtr-charmap-panel.h
@@ -27,29 +27,20 @@
#include <glib-object.h>
#include <gtk/gtk.h>
-#ifdef HAVE_GUCHARMAP_2
#include <gucharmap/gucharmap.h>
-#else
-#include <gucharmap/gucharmap-table.h>
-#endif
G_BEGIN_DECLS
-/*
- * Type checking and casting macros
- */
-#define GTR_TYPE_CHARMAP_PANEL (gtr_charmap_panel_get_type ())
-#define GTR_CHARMAP_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_CHARMAP_PANEL, GtrCharmapPanel))
-#define GTR_CHARMAP_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_CHARMAP_PANEL, GtrCharmapPanelClass))
-#define GTR_IS_CHARMAP_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CHARMAP_PANEL))
-#define GTR_IS_CHARMAP_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CHARMAP_PANEL))
-#define GTR_CHARMAP_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CHARMAP_PANEL, GtrCharmapPanelClass))
-/* Private structure type */
-typedef struct _GtrCharmapPanelPrivate GtrCharmapPanelPrivate;
-/*
- * Main object structure
- */
-typedef struct _GtrCharmapPanel GtrCharmapPanel;
+#define GTR_TYPE_CHARMAP_PANEL (gtr_charmap_panel_get_type ())
+#define GTR_CHARMAP_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_CHARMAP_PANEL, GtrCharmapPanel))
+#define GTR_CHARMAP_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_CHARMAP_PANEL, GtrCharmapPanelClass))
+#define GTR_IS_CHARMAP_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CHARMAP_PANEL))
+#define GTR_IS_CHARMAP_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CHARMAP_PANEL))
+#define GTR_CHARMAP_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CHARMAP_PANEL, GtrCharmapPanelClass))
+
+typedef struct _GtrCharmapPanel GtrCharmapPanel;
+typedef struct _GtrCharmapPanelClass GtrCharmapPanelClass;
+typedef struct _GtrCharmapPanelPrivate GtrCharmapPanelPrivate;
struct _GtrCharmapPanel
{
@@ -59,31 +50,18 @@ struct _GtrCharmapPanel
GtrCharmapPanelPrivate *priv;
};
-/*
- * Class definition
- */
-typedef struct _GtrCharmapPanelClass GtrCharmapPanelClass;
-
struct _GtrCharmapPanelClass
{
GtkVBoxClass parent_class;
};
-/*
- * Public methods
- */
-GType
-gtr_charmap_panel_get_type (void)
- G_GNUC_CONST;
- GType gtr_charmap_panel_register_type (GTypeModule * module);
- GtkWidget *gtr_charmap_panel_new (void);
+GType gtr_charmap_panel_get_type (void) G_GNUC_CONST;
+GtkWidget *gtr_charmap_panel_new (void);
+
+GucharmapChartable * gtr_charmap_panel_get_chartable (GtrCharmapPanel *panel);
-#ifdef HAVE_GUCHARMAP_2
-GucharmapChartable
- * gtr_charmap_panel_get_chartable (GtrCharmapPanel * panel);
-#else
-GucharmapTable * gtr_charmap_panel_get_table (GtrCharmapPanel * panel);
-#endif
+void _gtr_charmap_panel_register_type (GTypeModule *type_module);
G_END_DECLS
+
#endif /* __CHARMAP_PANEL_H__ */
diff --git a/plugins/charmap/gtr-charmap-plugin.c b/plugins/charmap/gtr-charmap-plugin.c
index a227c2e..976b89d 100644
--- a/plugins/charmap/gtr-charmap-plugin.c
+++ b/plugins/charmap/gtr-charmap-plugin.c
@@ -22,97 +22,137 @@
#include <config.h>
#endif
-#include <glib/gi18n-lib.h>
-
#include "gtr-charmap-plugin.h"
#include "gtr-charmap-panel.h"
-#include "gtr-debug.h"
+
+#include <glib/gi18n-lib.h>
#include "gtr-application.h"
#include "gtr-statusbar.h"
#include "gtr-window.h"
+#include "gtr-window-activatable.h"
-#ifdef HAVE_GUCHARMAP_2
+#include <libpeas-gtk/peas-gtk-configurable.h>
#include <gucharmap/gucharmap.h>
-#else
-#include <gucharmap/gucharmap-table.h>
-#include <gucharmap/gucharmap-unicode-info.h>
-#endif
-
-#define WINDOW_DATA_KEY "GtrCharmapPluginWindowData"
#define GTR_CHARMAP_PLUGIN_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
- GTR_TYPE_CHARMAP_PLUGIN, \
- GtrCharmapPluginPrivate))
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+ GTR_TYPE_CHARMAP_PLUGIN, \
+ GtrCharmapPluginPrivate))
-typedef struct
+struct _GtrCharmapPluginPrivate
{
- GtkWidget *panel;
- guint context_id;
-} WindowData;
-
-GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtrCharmapPlugin,
- gtr_charmap_plugin,
- gtr_charmap_panel_register_type (module);
- )
- static void gtr_charmap_plugin_init (GtrCharmapPlugin * plugin)
+ GtrWindow *window;
+ GtkWidget *charmap;
+
+ guint context_id;
+};
+
+enum
+{
+ PROP_0,
+ PROP_WINDOW
+};
+
+static void gtr_window_activatable_iface_init (GtrWindowActivatableInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtrCharmapPlugin,
+ gtr_charmap_plugin,
+ PEAS_TYPE_EXTENSION_BASE,
+ 0,
+ G_IMPLEMENT_INTERFACE_DYNAMIC (GTR_TYPE_WINDOW_ACTIVATABLE,
+ gtr_window_activatable_iface_init) \
+ \
+ _gtr_charmap_panel_register_type (type_module); \
+)
+
+static void
+gtr_charmap_plugin_init (GtrCharmapPlugin * plugin)
{
- //gtr_debug_message (DEBUG_PLUGINS, "GtrCharmapPlugin initializing");
+
+ plugin->priv = GTR_CHARMAP_PLUGIN_GET_PRIVATE (plugin);
}
static void
-gtr_charmap_plugin_finalize (GObject * object)
+gtr_charmap_plugin_dispose (GObject * object)
{
- //gtr_debug_message (DEBUG_PLUGINS, "GtrCharmapPlugin finalizing");
- G_OBJECT_CLASS (gtr_charmap_plugin_parent_class)->finalize (object);
+ GtrCharmapPlugin *plugin = GTR_CHARMAP_PLUGIN (object);
+
+ if (plugin->priv->window != NULL)
+ {
+ g_object_unref (plugin->priv->window);
+ plugin->priv->window = NULL;
+ }
+
+ G_OBJECT_CLASS (gtr_charmap_plugin_parent_class)->dispose (object);
}
static void
-free_window_data (WindowData * data)
+gtr_charmap_plugin_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- g_slice_free (WindowData, data);
+ GtrCharmapPlugin *plugin = GTR_CHARMAP_PLUGIN (object);
+
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ plugin->priv->window = GTR_WINDOW (g_value_dup_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-#ifdef HAVE_GUCHARMAP_2
- on_table_status_message (GucharmapChartable * chartable,
-#else
-on_table_status_message (GucharmapTable * chartable,
-#endif
- const gchar * message, GtrWindow * window)
+gtr_charmap_plugin_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtrCharmapPlugin *plugin = GTR_CHARMAP_PLUGIN (object);
+
+ switch (prop_id)
+ {
+ case PROP_WINDOW:
+ g_value_set_object (value, plugin->priv->window);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+on_table_status_message (GucharmapChartable *chartable,
+ const gchar *message,
+ GtrCharmapPlugin *plugin)
{
GtrStatusbar *statusbar;
- WindowData *data;
- statusbar = GTR_STATUSBAR (gtr_window_get_statusbar (window));
- data = (WindowData *) g_object_get_data (G_OBJECT (window),
- WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ statusbar = GTR_STATUSBAR (gtr_window_get_statusbar (plugin->priv->window));
- gtr_statusbar_pop (statusbar, data->context_id);
+ gtr_statusbar_pop (statusbar, plugin->priv->context_id);
if (message)
- gtr_statusbar_push (statusbar, data->context_id, message);
+ gtr_statusbar_push (statusbar, plugin->priv->context_id, message);
}
static void
-#ifdef HAVE_GUCHARMAP_2
-on_table_sync_active_char (GucharmapChartable * chartable,
- GParamSpec * psepc, GtrWindow * window)
-#else
-on_table_set_active_char (GucharmapTable * chartable,
- gunichar wc, GtrWindow * window)
-#endif
+on_table_sync_active_char (GucharmapChartable *chartable,
+ GParamSpec *psepc,
+ GtrCharmapPlugin *plugin)
{
GString *gs;
const gchar **temps;
gint i;
-#ifdef HAVE_GUCHARMAP_2
gunichar wc;
wc = gucharmap_chartable_get_active_character (chartable);
-#endif
gs = g_string_new (NULL);
g_string_append_printf (gs, "U+%4.4X %s", wc,
@@ -136,55 +176,35 @@ on_table_set_active_char (GucharmapTable * chartable,
g_free (temps);
}
- on_table_status_message (chartable, gs->str, window);
+ on_table_status_message (chartable, gs->str, plugin);
g_string_free (gs, TRUE);
}
static gboolean
-on_table_focus_out_event (GtkWidget * drawing_area,
- GdkEventFocus * event, GtrWindow * window)
+on_table_focus_out_event (GtkWidget *drawing_area,
+ GdkEventFocus *event,
+ GtrCharmapPlugin *plugin)
{
-#ifdef HAVE_GUCHARMAP_2
GucharmapChartable *chartable;
-#else
- GucharmapTable *chartable;
-#endif
- WindowData *data;
-
- data = (WindowData *) g_object_get_data (G_OBJECT (window),
- WINDOW_DATA_KEY);
- g_return_val_if_fail (data != NULL, FALSE);
-#ifdef HAVE_GUCHARMAP_2
- chartable = gtr_charmap_panel_get_chartable
- (GTR_CHARMAP_PANEL (data->panel));
-#else
- chartable = gtr_charmap_panel_get_table (GTR_CHARMAP_PANEL (data->panel));
-#endif
+ chartable = gtr_charmap_panel_get_chartable (GTR_CHARMAP_PANEL (plugin->priv->charmap));
- on_table_status_message (chartable, NULL, window);
+ on_table_status_message (chartable, NULL, plugin);
return FALSE;
}
-#ifdef HAVE_GUCHARMAP_2
-static void
-on_table_activate (GucharmapChartable * chartable, GtrWindow * window)
-#else
static void
-on_table_activate (GucharmapTable * chartable,
- gunichar wc, GtrWindow * window)
-#endif
+on_table_activate (GucharmapChartable *chartable,
+ GtrWindow *window)
{
GtkTextView *view;
GtkTextBuffer *document;
GtkTextIter start, end;
gchar buffer[6];
gchar length;
-#ifdef HAVE_GUCHARMAP_2
gunichar wc;
wc = gucharmap_chartable_get_active_character (chartable);
-#endif
g_return_if_fail (gucharmap_unichar_validate (wc));
@@ -211,50 +231,30 @@ on_table_activate (GucharmapTable * chartable,
}
static GtkWidget *
-create_charmap_panel (GtrWindow * window)
+create_charmap_panel (GtrCharmapPlugin *plugin)
{
GtkWidget *panel;
-#ifdef HAVE_GUCHARMAP_2
GucharmapChartable *chartable;
-#else
- GucharmapTable *table;
-#endif
panel = gtr_charmap_panel_new ();
-#ifdef HAVE_GUCHARMAP_2
chartable = gtr_charmap_panel_get_chartable (GTR_CHARMAP_PANEL (panel));
-#else
- table = gtr_charmap_panel_get_table (GTR_CHARMAP_PANEL (panel));
-#endif
-#ifdef HAVE_GUCHARMAP_2
g_signal_connect (chartable,
"notify::active-character",
- G_CALLBACK (on_table_sync_active_char), window);
+ G_CALLBACK (on_table_sync_active_char),
+ plugin);
g_signal_connect (chartable,
"focus-out-event",
- G_CALLBACK (on_table_focus_out_event), window);
+ G_CALLBACK (on_table_focus_out_event),
+ plugin);
g_signal_connect (chartable,
"status-message",
- G_CALLBACK (on_table_status_message), window);
+ G_CALLBACK (on_table_status_message),
+ plugin);
g_signal_connect (chartable,
- "activate", G_CALLBACK (on_table_activate), window);
-
-#else
- g_signal_connect (table,
- "set-active-char",
- G_CALLBACK (on_table_set_active_char), window);
- /* Note: GucharmapTable does not provide focus-out-event ... */
- g_signal_connect (table->drawing_area,
- "focus-out-event",
- G_CALLBACK (on_table_focus_out_event), window);
- g_signal_connect (table,
- "status-message",
- G_CALLBACK (on_table_status_message), window);
- g_signal_connect (table,
- "activate", G_CALLBACK (on_table_activate), window);
-#endif /* HAVE_GUCHARMAP_2 */
+ "activate", G_CALLBACK (on_table_activate),
+ plugin->priv->window);
gtk_widget_show_all (panel);
@@ -262,69 +262,77 @@ create_charmap_panel (GtrWindow * window)
}
static void
-impl_activate (GtrPlugin * plugin, GtrWindow * window)
+gtr_charmap_plugin_activate (GtrWindowActivatable *activatable)
{
+ GtrCharmapPluginPrivate *priv;
GtrStatusbar *statusbar;
- WindowData *data;
- data = g_new (WindowData, 1);
+ priv = GTR_CHARMAP_PLUGIN (activatable)->priv;
gtr_application_register_icon (GTR_APP, "gucharmap.ico",
"charmap-plugin-icon");
- data->panel = create_charmap_panel (window);
+ priv->charmap = create_charmap_panel (GTR_CHARMAP_PLUGIN (activatable));
- gtr_window_add_widget (window,
- data->panel,
+ gtr_window_add_widget (priv->window,
+ priv->charmap,
"GtrCharmapPlugin",
_("Character Map"),
- "charmap-plugin-icon", GTR_WINDOW_PLACEMENT_LEFT);
+ "charmap-plugin-icon",
+ GTR_WINDOW_PLACEMENT_LEFT);
- statusbar = GTR_STATUSBAR (gtr_window_get_statusbar (window));
- data->context_id = gtr_statusbar_get_context_id (statusbar,
+ statusbar = GTR_STATUSBAR (gtr_window_get_statusbar (priv->window));
+ priv->context_id = gtr_statusbar_get_context_id (statusbar,
"Character Description");
-
- g_object_set_data_full (G_OBJECT (window),
- WINDOW_DATA_KEY,
- data, (GDestroyNotify) free_window_data);
}
static void
-impl_deactivate (GtrPlugin * plugin, GtrWindow * window)
+gtr_charmap_plugin_deactivate (GtrWindowActivatable *activatable)
{
- WindowData *data;
-#ifdef HAVE_GUCHARMAP_2
+ GtrCharmapPluginPrivate *priv;
GucharmapChartable *chartable;
-#else
- GucharmapTable *chartable;
-#endif
- data = (WindowData *) g_object_get_data (G_OBJECT (window),
- WINDOW_DATA_KEY);
- g_return_if_fail (data != NULL);
+ priv = GTR_CHARMAP_PLUGIN (activatable)->priv;
-#ifdef HAVE_GUCHARMAP_2
- chartable = gtr_charmap_panel_get_chartable
- (GTR_CHARMAP_PANEL (data->panel));
-#else
- chartable = gtr_charmap_panel_get_table (GTR_CHARMAP_PANEL (data->panel));
-#endif
- on_table_status_message (chartable, NULL, window);
+ chartable = gtr_charmap_panel_get_chartable (GTR_CHARMAP_PANEL (priv->charmap));
+ on_table_status_message (chartable, NULL,
+ GTR_CHARMAP_PLUGIN (activatable));
+
+ gtr_window_remove_widget (priv->window, priv->charmap);
+}
+
+static void
+gtr_charmap_plugin_class_init (GtrCharmapPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- gtr_window_remove_widget (window, data->panel);
+ object_class->dispose = gtr_charmap_plugin_dispose;
+ object_class->set_property = gtr_charmap_plugin_set_property;
+ object_class->get_property = gtr_charmap_plugin_get_property;
- g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+ g_object_class_override_property (object_class, PROP_WINDOW, "window");
+ g_type_class_add_private (object_class, sizeof (GtrCharmapPluginPrivate));
}
static void
-gtr_charmap_plugin_class_init (GtrCharmapPluginClass * klass)
+gtr_charmap_plugin_class_finalize (GtrCharmapPluginClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtrPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+}
+
+static void
+gtr_window_activatable_iface_init (GtrWindowActivatableInterface *iface)
+{
+ iface->activate = gtr_charmap_plugin_activate;
+ iface->deactivate = gtr_charmap_plugin_deactivate;
+}
- object_class->finalize = gtr_charmap_plugin_finalize;
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+ gtr_charmap_plugin_register_type (G_TYPE_MODULE (module));
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
+ peas_object_module_register_extension_type (module,
+ GTR_TYPE_WINDOW_ACTIVATABLE,
+ GTR_TYPE_CHARMAP_PLUGIN);
}
diff --git a/plugins/charmap/gtr-charmap-plugin.h b/plugins/charmap/gtr-charmap-plugin.h
index 0fac4fa..0d9e138 100644
--- a/plugins/charmap/gtr-charmap-plugin.h
+++ b/plugins/charmap/gtr-charmap-plugin.h
@@ -25,50 +25,41 @@
#include <glib.h>
#include <glib-object.h>
-#include "gtr-plugin.h"
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
G_BEGIN_DECLS
-/*
- * Type checking and casting macros
- */
-#define GTR_TYPE_CHARMAP_PLUGIN (gtr_charmap_plugin_get_type ())
-#define GTR_CHARMAP_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_CHARMAP_PLUGIN, GtrCharmapPlugin))
-#define GTR_CHARMAP_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_CHARMAP_PLUGIN, GtrCharmapPluginClass))
-#define GTR_IS_CHARMAP_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CHARMAP_PLUGIN))
-#define GTR_IS_CHARMAP_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CHARMAP_PLUGIN))
-#define GTR_CHARMAP_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CHARMAP_PLUGIN, GtrCharmapPluginClass))
-/* Private structure type */
-typedef struct _GtrCharmapPluginPrivate GtrCharmapPluginPrivate;
-/*
- * Main object structure
- */
-typedef struct _GtrCharmapPlugin GtrCharmapPlugin;
+#define GTR_TYPE_CHARMAP_PLUGIN (gtr_charmap_plugin_get_type ())
+#define GTR_CHARMAP_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_CHARMAP_PLUGIN, GtrCharmapPlugin))
+#define GTR_CHARMAP_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_CHARMAP_PLUGIN, GtrCharmapPluginClass))
+#define GTR_IS_CHARMAP_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CHARMAP_PLUGIN))
+#define GTR_IS_CHARMAP_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CHARMAP_PLUGIN))
+#define GTR_CHARMAP_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CHARMAP_PLUGIN, GtrCharmapPluginClass))
+
+
+typedef struct _GtrCharmapPlugin GtrCharmapPlugin;
+typedef struct _GtrCharmapPluginPrivate GtrCharmapPluginPrivate;
+typedef struct _GtrCharmapPluginClass GtrCharmapPluginClass;
struct _GtrCharmapPlugin
{
- GtrPlugin parent_instance;
+ PeasExtensionBase parent_instance;
+
+ /*< private >*/
+ GtrCharmapPluginPrivate *priv;
};
-/*
- * Class definition
- */
-typedef struct _GtrCharmapPluginClass GtrCharmapPluginClass;
struct _GtrCharmapPluginClass
{
- GtrPluginClass parent_class;
+ PeasExtensionBaseClass parent_class;
};
-/*
- * Public methods
- */
-GType
-gtr_charmap_plugin_get_type (void)
- G_GNUC_CONST;
+GType gtr_charmap_plugin_get_type (void) G_GNUC_CONST;
-/* All the plugins must implement this function */
- G_MODULE_EXPORT GType register_gtr_plugin (GTypeModule * module);
+G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
G_END_DECLS
+
#endif /* __GTR_CHARMAP_PLUGIN_H__ */
diff --git a/plugins/charmap/gtr-charmap.gtranslator-plugin.desktop.in b/plugins/charmap/gtr-charmap.plugin.desktop.in
similarity index 92%
rename from plugins/charmap/gtr-charmap.gtranslator-plugin.desktop.in
rename to plugins/charmap/gtr-charmap.plugin.desktop.in
index e2477bf..79cbe93 100644
--- a/plugins/charmap/gtr-charmap.gtranslator-plugin.desktop.in
+++ b/plugins/charmap/gtr-charmap.plugin.desktop.in
@@ -1,4 +1,4 @@
-[Gtranslator Plugin]
+[Plugin]
Module=charmap
IAge=2
_Name=Character Map
diff --git a/po/POTFILES.in b/po/POTFILES.in
index df9f063..6c52920 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -8,7 +8,7 @@ plugins/alternate-language/gtr-alternate-language-panel.c
plugins/alternate-language/gtr-alternate-language-plugin.c
plugins/alternate-language/gtr-alternate-language.plugin.desktop.in
plugins/charmap/gtr-charmap-plugin.c
-plugins/charmap/gtr-charmap.gtranslator-plugin.desktop.in
+plugins/charmap/gtr-charmap.plugin.desktop.in
plugins/dictionary/gtr-dict-panel.c
plugins/dictionary/gtr-dict.gtranslator-plugin.desktop.in
plugins/dictionary/gtr-dictionary-plugin.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]