[Xfce4-commits] <xfce4-panel:devel> Properly handle the screen-changed signal and port to new plugin api.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:30:19 CEST 2009
Updating branch refs/heads/devel
to 604f3648a0c44ed3e162f38414f4ad0352f693fa (commit)
from 62ce18e655c5f9de46a41198e7920df585d75716 (commit)
commit 604f3648a0c44ed3e162f38414f4ad0352f693fa
Author: Nick Schermer <nick at xfce.org>
Date: Sun Mar 15 15:31:49 2009 +0100
Properly handle the screen-changed signal and port to new plugin api.
plugins/pager/pager.c | 29 +++++++++++++++--------------
plugins/pager/pager.h | 4 +++-
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index 625d30c..2a5c700 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -91,10 +91,8 @@ enum
-/* define and register the plugin */
-G_DEFINE_TYPE (PagerPlugin, pager_plugin, XFCE_TYPE_PANEL_PLUGIN)
-
-XFCE_PANEL_PLUGIN_REGISTER_OBJECT (XFCE_TYPE_PAGER_PLUGIN)
+/* define the plugin */
+XFCE_PANEL_DEFINE_PLUGIN_RESIDENT (PagerPlugin, pager_plugin)
@@ -111,7 +109,6 @@ pager_plugin_class_init (PagerPluginClass *klass)
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->scroll_event = pager_plugin_scroll_event;
- widget_class->screen_changed = pager_plugin_screen_changed;
plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
plugin_class->construct = pager_plugin_construct;
@@ -278,10 +275,6 @@ pager_plugin_screen_changed (GtkWidget *widget,
GdkScreen *screen;
WnckScreen *wnck_screen;
- /* do nothing until the xfconf properties are initialized */
- if (plugin->channel == NULL)
- return;
-
/* get the active screen */
screen = gtk_widget_get_screen (widget);
wnck_screen = wnck_screen_get (gdk_screen_get_number (screen));
@@ -329,7 +322,9 @@ pager_plugin_construct (XfcePanelPlugin *panel_plugin)
G_TYPE_UINT, plugin, "rows");
/* create the pager */
- pager_plugin_screen_changed (GTK_WIDGET (panel_plugin), NULL);
+ g_signal_connect (G_OBJECT (plugin), "screen-changed",
+ G_CALLBACK (pager_plugin_screen_changed), NULL);
+ pager_plugin_screen_changed (GTK_WIDGET (plugin), NULL);
}
@@ -341,8 +336,13 @@ pager_plugin_free_data (XfcePanelPlugin *panel_plugin)
panel_return_if_fail (XFCONF_IS_CHANNEL (plugin->channel));
+ /* disconnect screen changed signal */
+ g_signal_handlers_disconnect_by_func (G_OBJECT (plugin),
+ pager_plugin_screen_changed, NULL);
+
/* release the xfonf channel */
- g_object_unref (G_OBJECT (plugin->channel));
+ if (G_LIKELY (plugin->channel != NULL))
+ g_object_unref (G_OBJECT (plugin->channel));
/* shutdown xfconf */
xfconf_shutdown ();
@@ -443,13 +443,14 @@ pager_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
/* load the dialog from the glade file */
builder = gtk_builder_new ();
- if (gtk_builder_add_from_string (builder, pager_dialog_glade, pager_dialog_glade_length, NULL))
+ if (gtk_builder_add_from_string (builder, pager_dialog_glade,
+ pager_dialog_glade_length, NULL))
{
/* signals to monitor number of workspace changes */
g_signal_connect (G_OBJECT (plugin->wnck_screen), "workspace-created",
- G_CALLBACK (pager_plugin_configure_n_workspaces_changed), builder);
+ G_CALLBACK (pager_plugin_configure_n_workspaces_changed), builder);
g_signal_connect (G_OBJECT (plugin->wnck_screen), "workspace-destroyed",
- G_CALLBACK (pager_plugin_configure_n_workspaces_changed), builder);
+ G_CALLBACK (pager_plugin_configure_n_workspaces_changed), builder);
xfce_panel_plugin_block_menu (panel_plugin);
g_object_weak_ref (G_OBJECT (builder), pager_plugin_configure_destroyed, plugin);
diff --git a/plugins/pager/pager.h b/plugins/pager/pager.h
index 05da29e..f90932a 100644
--- a/plugins/pager/pager.h
+++ b/plugins/pager/pager.h
@@ -32,7 +32,9 @@ typedef struct _PagerPlugin PagerPlugin;
#define XFCE_IS_PAGER_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_PAGER_PLUGIN))
#define XFCE_PAGER_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_PAGER_PLUGIN, PagerPluginClass))
-GType pager_plugin_get_type (void) G_GNUC_CONST;
+GType pager_plugin_get_type (void) G_GNUC_CONST;
+
+void pager_plugin_register_type (GTypeModule *type_module);
G_END_DECLS
More information about the Xfce4-commits
mailing list