From 252410a854e947788af370acf99ff3d5754ba26b Mon Sep 17 00:00:00 2001 From: Nick Schermer <nick@xfce.org> Date: Fri, 26 Feb 2010 14:08:08 +0100 Subject: [PATCH] Fixes in the DBus code and provider signals. - Improve the provider-signal enums. - Move the dbus-related code to a seperate file in the new common directory. - Various cleanups. --- common/Makefile.am | 6 + common/panel-dbus.h | 42 +++++++ configure.in.in | 1 + libxfce4panel/xfce-panel-plugin-provider.h | 22 ++-- libxfce4panel/xfce-panel-plugin.c | 23 ++-- panel/panel-application.c | 19 +-- panel/panel-dbus-client.c | 1 + panel/panel-dbus-service-infos.xml | 2 +- panel/panel-dbus-service.c | 17 +-- panel/panel-dbus-service.h | 7 +- panel/panel-marshal.list | 2 +- panel/panel-module-factory.c | 70 ++++++----- panel/panel-plugin-external.c | 82 ++++++------ plugins/launcher/launcher-dialog.c | 8 +- plugins/launcher/launcher.c | 4 +- plugins/tasklist/plugin.c | 46 +++---- plugins/tasklist/tasklist.c | 76 ++++++------ wrapper/main.c | 138 +++++++++------------ 18 files changed, 305 insertions(+), 261 deletions(-) create mode 100644 common/Makefile.am create mode 100644 common/panel-dbus.h diff --git a/common/Makefile.am b/common/Makefile.am new file mode 100644 index 000000000..7fee31228 --- /dev/null +++ b/common/Makefile.am @@ -0,0 +1,6 @@ +# $Id$ + +EXTRA_DIST = \ + panel-dbus.h + +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/common/panel-dbus.h b/common/panel-dbus.h new file mode 100644 index 000000000..a4e45c629 --- /dev/null +++ b/common/panel-dbus.h @@ -0,0 +1,42 @@ +/* $Id$ */ +/* + * Copyright (C) 2008 Nick Schermer <nick@xfce.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PANEL_DBUS_H__ +#define __PANEL_DBUS_H__ + +typedef enum _DBusPropertyChanged DBusPropertyChanged; + +/* panel dbus names */ +#define PANEL_DBUS_SERVICE_INTERFACE "org.xfce.Panel" +#define PANEL_DBUS_SERVICE_PATH "/org/xfce/Panel" +#define PANEL_DBUS_SERVICE_NAME PANEL_DBUS_SERVICE_INTERFACE + +enum _DBusPropertyChanged +{ + DBUS_PROPERTY_CHANGED_SIZE, + DBUS_PROPERTY_CHANGED_ORIENTATION, + DBUS_PROPERTY_CHANGED_SCREEN_POSITION, + DBUS_PROPERTY_CHANGED_BACKGROUND_ALPHA, + DBUS_PROPERTY_CHANGED_ACTIVE_PANEL, + DBUS_PROPERTY_CHANGED_SENSITIVE, + DBUS_PROPERTY_CHANGED_EMIT_SAVE, + DBUS_PROPERTY_CHANGED_QUIT_WRAPPER, +}; + +#endif /* !__PANEL_DBUS_H__ */ diff --git a/configure.in.in b/configure.in.in index d8fab45d8..bf09a5792 100644 --- a/configure.in.in +++ b/configure.in.in @@ -234,6 +234,7 @@ AC_SUBST([PLATFORM_LDFLAGS]) AC_OUTPUT([ Makefile +common/Makefile libxfce4panel/Makefile libxfce4panel/libxfce4panel-1.0.pc panel/Makefile diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h index 334955881..b344fc933 100644 --- a/libxfce4panel/xfce-panel-plugin-provider.h +++ b/libxfce4panel/xfce-panel-plugin-provider.h @@ -34,11 +34,6 @@ typedef enum _XfcePanelPluginProviderSignal XfcePanelPluginProviderSignal; #define XFCE_IS_PANEL_PLUGIN_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_PANEL_PLUGIN_PROVIDER)) #define XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XFCE_TYPE_PANEL_PLUGIN_PROVIDER, XfcePanelPluginProviderIface)) -/* panel dbus names */ -#define PANEL_DBUS_SERVICE_INTERFACE "org.xfce.Panel" -#define PANEL_DBUS_SERVICE_PATH "/org/xfce/Panel" -#define PANEL_DBUS_SERVICE_NAME PANEL_DBUS_SERVICE_INTERFACE - /* relative plugin filename (printf format) */ #define PANEL_PLUGIN_RELATIVE_PATH "xfce4" G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "%s-%d.rc" @@ -78,17 +73,18 @@ struct _XfcePanelPluginProviderIface enum _XfcePanelPluginProviderSignal { - MOVE_PLUGIN, - EXPAND_PLUGIN, - COLLAPSE_PLUGIN, - LOCK_PANEL, - UNLOCK_PANEL, - REMOVE_PLUGIN, - ADD_NEW_ITEMS, - PANEL_PREFERENCES, + PROVIDER_SIGNAL_MOVE_PLUGIN, + PROVIDER_SIGNAL_EXPAND_PLUGIN, + PROVIDER_SIGNAL_COLLAPSE_PLUGIN, + PROVIDER_SIGNAL_LOCK_PANEL, + PROVIDER_SIGNAL_UNLOCK_PANEL, + PROVIDER_SIGNAL_REMOVE_PLUGIN, + PROVIDER_SIGNAL_ADD_NEW_ITEMS, + PROVIDER_SIGNAL_PANEL_PREFERENCES }; + PANEL_SYMBOL_EXPORT GType xfce_panel_plugin_provider_get_type (void) G_GNUC_CONST; diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c index 5a15a1b6a..48f072c66 100644 --- a/libxfce4panel/xfce-panel-plugin.c +++ b/libxfce4panel/xfce-panel-plugin.c @@ -596,7 +596,8 @@ xfce_panel_plugin_menu_move (XfcePanelPlugin *plugin) panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin)); /* move the plugin */ - xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), MOVE_PLUGIN); + xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), + PROVIDER_SIGNAL_MOVE_PLUGIN); } @@ -631,7 +632,8 @@ xfce_panel_plugin_menu_remove (XfcePanelPlugin *plugin) gtk_widget_hide (dialog); /* ask the panel or wrapper to remove the plugin */ - xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), REMOVE_PLUGIN); + xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), + PROVIDER_SIGNAL_REMOVE_PLUGIN); } /* destroy */ @@ -647,7 +649,8 @@ xfce_panel_plugin_menu_add_items (XfcePanelPlugin *plugin) panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin)); /* open items dialog */ - xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), ADD_NEW_ITEMS); + xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), + PROVIDER_SIGNAL_ADD_NEW_ITEMS); } @@ -659,7 +662,8 @@ xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin *plugin) panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin)); /* open preferences dialog */ - xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), PANEL_PREFERENCES); + xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), + PROVIDER_SIGNAL_PANEL_PREFERENCES); } @@ -791,7 +795,8 @@ xfce_panel_plugin_unregister_menu (GtkMenu *menu, /* emit signal to unlock the panel */ if (G_LIKELY (plugin->priv->registered_menus == 0)) - xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), UNLOCK_PANEL); + xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), + PROVIDER_SIGNAL_UNLOCK_PANEL); } } @@ -955,7 +960,7 @@ xfce_panel_plugin_get_property_base (XfcePanelPlugin *plugin) /* create the propert if needed */ if (plugin->priv->property_base == NULL) - plugin->priv->property_base = g_strdup_printf (PANEL_PLUGIN_PROPERTY_BASE, + plugin->priv->property_base = g_strdup_printf (PANEL_PLUGIN_PROPERTY_BASE, plugin->priv->unique_id); return plugin->priv->property_base; @@ -1036,7 +1041,8 @@ xfce_panel_plugin_set_expand (XfcePanelPlugin *plugin, /* emit signal (in provider) */ xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), - expand ? EXPAND_PLUGIN : COLLAPSE_PLUGIN); + expand ? PROVIDER_SIGNAL_EXPAND_PLUGIN : + PROVIDER_SIGNAL_COLLAPSE_PLUGIN); } } @@ -1234,7 +1240,8 @@ xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin, /* tell panel it needs to lock */ if (G_LIKELY (plugin->priv->registered_menus == 1)) - xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), LOCK_PANEL); + xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin), + PROVIDER_SIGNAL_LOCK_PANEL); } diff --git a/panel/panel-application.c b/panel/panel-application.c index e3dcf0020..e2bf5a6ba 100644 --- a/panel/panel-application.c +++ b/panel/panel-application.c @@ -360,33 +360,34 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide /* get the panel of the plugin */ window = PANEL_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (provider))); + /* handle the signal emitted from the plugin provider */ switch (signal) { - case MOVE_PLUGIN: + case PROVIDER_SIGNAL_MOVE_PLUGIN: /* invoke the move function */ panel_application_plugin_move (GTK_WIDGET (provider), application); break; - case EXPAND_PLUGIN: - case COLLAPSE_PLUGIN: + case PROVIDER_SIGNAL_EXPAND_PLUGIN: + case PROVIDER_SIGNAL_COLLAPSE_PLUGIN: /* get the itembar */ itembar = gtk_bin_get_child (GTK_BIN (window)); /* set new expand mode */ - panel_itembar_set_child_expand (PANEL_ITEMBAR (itembar), GTK_WIDGET (provider), !!(signal == EXPAND_PLUGIN)); + panel_itembar_set_child_expand (PANEL_ITEMBAR (itembar), GTK_WIDGET (provider), !!(signal == PROVIDER_SIGNAL_EXPAND_PLUGIN)); break; - case LOCK_PANEL: + case PROVIDER_SIGNAL_LOCK_PANEL: /* block autohide */ panel_window_freeze_autohide (window); break; - case UNLOCK_PANEL: + case PROVIDER_SIGNAL_UNLOCK_PANEL: /* unblock autohide */ panel_window_thaw_autohide (window); break; - case REMOVE_PLUGIN: + case PROVIDER_SIGNAL_REMOVE_PLUGIN: /* create the xfconf property base */ property = g_strdup_printf (PANEL_PLUGIN_PROPERTY_BASE, xfce_panel_plugin_provider_get_unique_id (provider)); @@ -414,12 +415,12 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide g_free (path); break; - case ADD_NEW_ITEMS: + case PROVIDER_SIGNAL_ADD_NEW_ITEMS: /* open the items dialog */ panel_item_dialog_show (window); break; - case PANEL_PREFERENCES: + case PROVIDER_SIGNAL_PANEL_PREFERENCES: /* open the panel preferences */ panel_preferences_dialog_show (window); break; diff --git a/panel/panel-dbus-client.c b/panel/panel-dbus-client.c index 8cd537063..3ca822491 100644 --- a/panel/panel-dbus-client.c +++ b/panel/panel-dbus-client.c @@ -23,6 +23,7 @@ #include <dbus/dbus-glib.h> #include <libxfce4util/libxfce4util.h> +#include <common/panel-dbus.h> #include <libxfce4panel/libxfce4panel.h> #include <libxfce4panel/xfce-panel-plugin-provider.h> diff --git a/panel/panel-dbus-service-infos.xml b/panel/panel-dbus-service-infos.xml index 5735077ca..0b66bcee8 100644 --- a/panel/panel-dbus-service-infos.xml +++ b/panel/panel-dbus-service-infos.xml @@ -109,7 +109,7 @@ --> <signal name="PropertyChanged"> <arg name="plugin_id" type="i" /> - <arg name="property" type="s" /> + <arg name="property" type="u" /> <arg name="value" type="v"/> </signal> </interface> diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c index 02fb3a7b8..47abd3d77 100644 --- a/panel/panel-dbus-service.c +++ b/panel/panel-dbus-service.c @@ -28,6 +28,7 @@ #include <dbus/dbus.h> #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> +#include <common/panel-dbus.h> #include <libxfce4util/libxfce4util.h> #include <libxfce4panel/libxfce4panel.h> @@ -97,10 +98,10 @@ panel_dbus_service_class_init (PanelDBusServiceClass *klass) G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST, 0, NULL, NULL, - panel_marshal_VOID__INT_STRING_BOXED, + panel_marshal_VOID__INT_UINT_BOXED, G_TYPE_NONE, 3, G_TYPE_INT, - G_TYPE_STRING, + G_TYPE_UINT, G_TYPE_VALUE); /* install the d-bus info for our class */ @@ -327,6 +328,9 @@ panel_dbus_service_set_property (PanelDBusService *service, /* check if this is a plugin property change */ if (strcmp (property, "ProviderSignal") == 0) { + /* check if this is an enum */ + panel_return_val_if_fail (G_VALUE_HOLDS_INT (value), FALSE); + /* get the module factory */ factory = panel_module_factory_get (); @@ -335,7 +339,7 @@ panel_dbus_service_set_property (PanelDBusService *service, /* emit the signal for the local plugin provider */ if (G_LIKELY (provider)) - xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (provider), g_value_get_uint (value)); + xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (provider), g_value_get_int (value)); /* release the factory */ g_object_unref (G_OBJECT (factory)); @@ -367,14 +371,13 @@ panel_dbus_service_get (void) void -panel_dbus_service_set_plugin_property (gint plugin_id, - const gchar *property, - const GValue *value) +panel_dbus_service_set_plugin_property (gint plugin_id, + DBusPropertyChanged property, + const GValue *value) { PanelDBusService *service; panel_return_if_fail (plugin_id != -1); - panel_return_if_fail (IS_STRING (property)); panel_return_if_fail (value && G_TYPE_CHECK_VALUE (value)); /* get the dbus service */ diff --git a/panel/panel-dbus-service.h b/panel/panel-dbus-service.h index 7352ea262..c12a54270 100644 --- a/panel/panel-dbus-service.h +++ b/panel/panel-dbus-service.h @@ -21,6 +21,7 @@ #define __PANEL_DBUS_SERVICE_H__ #include <glib.h> +#include <common/panel-dbus.h> typedef struct _PanelDBusServiceClass PanelDBusServiceClass; typedef struct _PanelDBusService PanelDBusService; @@ -36,9 +37,9 @@ GType panel_dbus_service_get_type (void) G_GNUC_CONST; PanelDBusService *panel_dbus_service_get (void); -void panel_dbus_service_set_plugin_property (gint plugin_id, - const gchar *property, - const GValue *value); +void panel_dbus_service_set_plugin_property (gint plugin_id, + DBusPropertyChanged property, + const GValue *value); G_END_DECLS diff --git a/panel/panel-marshal.list b/panel/panel-marshal.list index 2d59568d6..320b25c59 100644 --- a/panel/panel-marshal.list +++ b/panel/panel-marshal.list @@ -1 +1 @@ -VOID:INT,STRING,BOXED +VOID:INT,UINT,BOXED diff --git a/panel/panel-module-factory.c b/panel/panel-module-factory.c index 90dc2da99..5acff1a44 100644 --- a/panel/panel-module-factory.c +++ b/panel/panel-module-factory.c @@ -46,6 +46,9 @@ static void panel_module_factory_load_modules (PanelModuleFactory * static gboolean panel_module_factory_modules_cleanup (gpointer key, gpointer value, gpointer user_data); +static void panel_module_factory_remove_plugin (gpointer user_data, + GObject *where_the_object_was); + enum @@ -66,8 +69,8 @@ struct _PanelModuleFactory /* hash table of loaded modules */ GHashTable *modules; - /* table table with created panel plugins */ - GHashTable *plugins; + /* a list with all the plugins */ + GSList *plugins; /* if the factory contains the launcher plugin */ guint has_launcher : 1; @@ -113,7 +116,6 @@ panel_module_factory_init (PanelModuleFactory *factory) /* create hash tables */ factory->modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); - factory->plugins = g_hash_table_new_full (g_int_hash, g_int_equal, NULL, NULL); /* load all the modules */ panel_module_factory_load_modules (factory); @@ -126,9 +128,11 @@ panel_module_factory_finalize (GObject *object) { PanelModuleFactory *factory = PANEL_MODULE_FACTORY (object); - /* destroy the hash tables */ + /* destroy the hash table */ g_hash_table_destroy (factory->modules); - g_hash_table_destroy (factory->plugins); + + /* free all the plugins */ + g_slist_free (factory->plugins); (*G_OBJECT_CLASS (panel_module_factory_parent_class)->finalize) (object); } @@ -210,7 +214,7 @@ panel_module_factory_load_modules (PanelModuleFactory *factory) g_hash_table_insert (factory->modules, internal_name, module); /* check if this is the launcher */ - if (factory->has_launcher == FALSE + if (factory->has_launcher == FALSE && exo_str_is_equal (LAUNCHER_PLUGIN_NAME, internal_name)) factory->has_launcher = TRUE; } @@ -264,6 +268,18 @@ panel_module_factory_modules_cleanup (gpointer key, +static void +panel_module_factory_remove_plugin (gpointer user_data, + GObject *where_the_object_was) +{ + PanelModuleFactory *factory = PANEL_MODULE_FACTORY (user_data); + + /* remove the plugin from the internal list */ + factory->plugins = g_slist_remove (factory->plugins, where_the_object_was); +} + + + PanelModuleFactory * panel_module_factory_get (void) { @@ -316,21 +332,6 @@ panel_module_factory_emit_unique_changed (PanelModule *module) -#if !GLIB_CHECK_VERSION (2,14,0) -static void -panel_module_factory_get_modules_foreach (gpointer key, - gpointer value, - gpointer user_data) -{ - GList **list = user_data; - - /* insert in the list */ - *list = g_list_prepend (*list, value); -} -#endif - - - GList * panel_module_factory_get_modules (PanelModuleFactory *factory) { @@ -339,16 +340,7 @@ panel_module_factory_get_modules (PanelModuleFactory *factory) /* make sure the hash table is clean */ g_hash_table_foreach_remove (factory->modules, panel_module_factory_modules_cleanup, factory); -#if GLIB_CHECK_VERSION (2,14,0) return g_hash_table_get_values (factory->modules); -#else - GList *list = NULL; - - /* insert all modules in the list */ - g_hash_table_foreach (factory->modules, panel_module_factory_get_modules_foreach, &list); - - return list; -#endif } @@ -369,10 +361,17 @@ XfcePanelPluginProvider * panel_module_factory_get_plugin (PanelModuleFactory *factory, gint unique_id) { + GSList *li; + panel_return_val_if_fail (PANEL_IS_MODULE_FACTORY (factory), NULL); panel_return_val_if_fail (unique_id != -1, NULL); - return g_hash_table_lookup (factory->plugins, &unique_id); + /* traverse the list to find the plugin with this unique id */ + for (li = factory->plugins; li != NULL; li = li->next) + if (xfce_panel_plugin_provider_get_unique_id (XFCE_PANEL_PLUGIN_PROVIDER (li->data)) == unique_id) + return XFCE_PANEL_PLUGIN_PROVIDER (li->data); + + return NULL; } @@ -404,15 +403,18 @@ panel_module_factory_create_plugin (PanelModuleFactory *factory, /* make sure this plugin has a unique id */ while (unique_id == -1 - || g_hash_table_lookup (factory->plugins, &unique_id) != NULL) + || panel_module_factory_get_plugin (factory, unique_id) != NULL) unique_id = ++unique_id_counter; /* create the new module */ provider = panel_module_create_plugin (module, screen, name, unique_id, arguments); - /* insert plugin in the hash table */ + /* insert plugin in the list */ if (G_LIKELY (provider)) - g_hash_table_insert (factory->plugins, &unique_id, provider); + { + factory->plugins = g_slist_prepend (factory->plugins, provider); + g_object_weak_ref (G_OBJECT (provider), panel_module_factory_remove_plugin, factory); + } return provider; } diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c index 9a406b8c6..b70f3e66a 100644 --- a/panel/panel-plugin-external.c +++ b/panel/panel-plugin-external.c @@ -24,6 +24,7 @@ #include <exo/exo.h> #include <gdk/gdk.h> #include <gdk/gdkx.h> +#include <common/panel-dbus.h> #include <libxfce4util/libxfce4util.h> #include <libxfce4panel/libxfce4panel.h> #include <libxfce4panel/xfce-panel-plugin-provider.h> @@ -46,29 +47,29 @@ -static void panel_plugin_external_class_init (PanelPluginExternalClass *klass); -static void panel_plugin_external_init (PanelPluginExternal *external); -static void panel_plugin_external_provider_init (XfcePanelPluginProviderIface *iface); -static void panel_plugin_external_finalize (GObject *object); -static void panel_plugin_external_realize (GtkWidget *widget); -static void panel_plugin_external_unrealize (GtkWidget *widget); -static gboolean panel_plugin_external_plug_removed (GtkSocket *socket); -static void panel_plugin_external_plug_added (GtkSocket *socket); -static void panel_plugin_external_provider_signal (XfcePanelPluginProvider *provider, - XfcePanelPluginProviderSignal signal); -static const gchar *panel_plugin_external_get_name (XfcePanelPluginProvider *provider); -static gint panel_plugin_external_get_unique_id (XfcePanelPluginProvider *provider); -static void panel_plugin_external_set_size (XfcePanelPluginProvider *provider, - gint size); -static void panel_plugin_external_set_orientation (XfcePanelPluginProvider *provider, - GtkOrientation orientation); -static void panel_plugin_external_set_screen_position (XfcePanelPluginProvider *provider, - XfceScreenPosition screen_position); -static void panel_plugin_external_save (XfcePanelPluginProvider *provider); -static void panel_plugin_external_set_sensitive (PanelPluginExternal *external); -static void panel_plugin_external_set_property (PanelPluginExternal *external, - const gchar *property, - const GValue *value); +static void panel_plugin_external_class_init (PanelPluginExternalClass *klass); +static void panel_plugin_external_init (PanelPluginExternal *external); +static void panel_plugin_external_provider_init (XfcePanelPluginProviderIface *iface); +static void panel_plugin_external_finalize (GObject *object); +static void panel_plugin_external_realize (GtkWidget *widget); +static void panel_plugin_external_unrealize (GtkWidget *widget); +static gboolean panel_plugin_external_plug_removed (GtkSocket *socket); +static void panel_plugin_external_plug_added (GtkSocket *socket); +static void panel_plugin_external_provider_signal (XfcePanelPluginProvider *provider, + XfcePanelPluginProviderSignal signal); +static const gchar *panel_plugin_external_get_name (XfcePanelPluginProvider *provider); +static gint panel_plugin_external_get_unique_id (XfcePanelPluginProvider *provider); +static void panel_plugin_external_set_size (XfcePanelPluginProvider *provider, + gint size); +static void panel_plugin_external_set_orientation (XfcePanelPluginProvider *provider, + GtkOrientation orientation); +static void panel_plugin_external_set_screen_position (XfcePanelPluginProvider *provider, + XfceScreenPosition screen_position); +static void panel_plugin_external_save (XfcePanelPluginProvider *provider); +static void panel_plugin_external_set_sensitive (PanelPluginExternal *external); +static void panel_plugin_external_set_property (PanelPluginExternal *external, + DBusPropertyChanged property, + const GValue *value); @@ -102,8 +103,8 @@ struct _PanelPluginExternal typedef struct { - const gchar *property; - GValue value; + DBusPropertyChanged property; + GValue value; } QueuedData; @@ -274,7 +275,8 @@ panel_plugin_external_unrealize (GtkWidget *widget) g_value_set_boolean (&value, FALSE); /* send (don't queue here) */ - panel_dbus_service_set_plugin_property (external->unique_id, "Quit", &value); + panel_dbus_service_set_plugin_property (external->unique_id, DBUS_PROPERTY_CHANGED_QUIT_WRAPPER, + &value); /* unset */ g_value_unset (&value); @@ -359,7 +361,8 @@ panel_plugin_external_plug_removed (GtkSocket *socket) else { /* emit a remove signal, so we can cleanup the plugin configuration (in panel-application) */ - xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (external), REMOVE_PLUGIN); + xfce_panel_plugin_provider_send_signal (XFCE_PANEL_PLUGIN_PROVIDER (external), + PROVIDER_SIGNAL_REMOVE_PLUGIN); /* destroy the socket */ gtk_widget_destroy (GTK_WIDGET (socket)); @@ -384,7 +387,7 @@ panel_plugin_external_plug_added (GtkSocket *socket) { /* reverse the order fo the queue, since we prepended all the time */ external->dbus_queue = g_slist_reverse (external->dbus_queue); - + /* flush the queue */ for (li = external->dbus_queue; li != NULL; li = li->next) { @@ -412,7 +415,7 @@ panel_plugin_external_provider_signal (XfcePanelPluginProvider *provider, panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider)); /* only handle the remove signal, everything else is handles in panel-application */ - if (signal == REMOVE_PLUGIN) + if (signal == PROVIDER_SIGNAL_REMOVE_PLUGIN) { /* we're forced removing the plugin, don't ask for a restart */ external->plug_embedded = FALSE; @@ -449,14 +452,13 @@ panel_plugin_external_get_unique_id (XfcePanelPluginProvider *provider) static void panel_plugin_external_set_property (PanelPluginExternal *external, - const gchar *property, + DBusPropertyChanged property, const GValue *value) { QueuedData *data; panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external)); panel_return_if_fail (value && G_TYPE_CHECK_VALUE (value)); - panel_return_if_fail (IS_STRING (property)); if (G_LIKELY (external->plug_embedded)) { @@ -493,7 +495,8 @@ panel_plugin_external_set_size (XfcePanelPluginProvider *provider, g_value_set_int (&value, size); /* send the value */ - panel_plugin_external_set_property (PANEL_PLUGIN_EXTERNAL (provider), "Size", &value); + panel_plugin_external_set_property (PANEL_PLUGIN_EXTERNAL (provider), + DBUS_PROPERTY_CHANGED_SIZE, &value); /* unset */ g_value_unset (&value); @@ -515,7 +518,8 @@ panel_plugin_external_set_orientation (XfcePanelPluginProvider *provider, g_value_set_uint (&value, orientation); /* send the value */ - panel_plugin_external_set_property (PANEL_PLUGIN_EXTERNAL (provider), "Orientation", &value); + panel_plugin_external_set_property (PANEL_PLUGIN_EXTERNAL (provider), + DBUS_PROPERTY_CHANGED_ORIENTATION, &value); /* unset */ g_value_unset (&value); @@ -537,7 +541,8 @@ panel_plugin_external_set_screen_position (XfcePanelPluginProvider *provider, g_value_set_uint (&value, screen_position); /* send the value */ - panel_plugin_external_set_property (PANEL_PLUGIN_EXTERNAL (provider), "ScreenPosition", &value); + panel_plugin_external_set_property (PANEL_PLUGIN_EXTERNAL (provider), + DBUS_PROPERTY_CHANGED_SCREEN_POSITION, &value); /* unset */ g_value_unset (&value); @@ -558,7 +563,8 @@ panel_plugin_external_save (XfcePanelPluginProvider *provider) g_value_set_boolean (&value, FALSE); /* send signal to wrapper */ - panel_plugin_external_set_property (PANEL_PLUGIN_EXTERNAL (provider), "Save", &value); + panel_plugin_external_set_property (PANEL_PLUGIN_EXTERNAL (provider), + DBUS_PROPERTY_CHANGED_EMIT_SAVE, &value); /* unset */ g_value_unset (&value); @@ -578,7 +584,7 @@ panel_plugin_external_set_sensitive (PanelPluginExternal *external) g_value_set_boolean (&value, GTK_WIDGET_IS_SENSITIVE (external)); /* send message */ - panel_plugin_external_set_property (external, "Sensitive", &value); + panel_plugin_external_set_property (external, DBUS_PROPERTY_CHANGED_SENSITIVE, &value); /* unset */ g_value_unset (&value); @@ -624,7 +630,7 @@ panel_plugin_external_set_background_alpha (PanelPluginExternal *external, g_value_set_int (&value, percentage); /* send message */ - panel_plugin_external_set_property (external, "BackgroundAlpha", &value); + panel_plugin_external_set_property (external, DBUS_PROPERTY_CHANGED_BACKGROUND_ALPHA, &value); /* unset */ g_value_unset (&value); @@ -645,7 +651,7 @@ panel_plugin_external_set_active_panel (PanelPluginExternal *external, g_value_set_boolean (&value, active); /* send message */ - panel_plugin_external_set_property (external, "ActivePanel", &value); + panel_plugin_external_set_property (external, DBUS_PROPERTY_CHANGED_ACTIVE_PANEL, &value); /* unset */ g_value_unset (&value); diff --git a/plugins/launcher/launcher-dialog.c b/plugins/launcher/launcher-dialog.c index 07681ddf2..2fa456933 100644 --- a/plugins/launcher/launcher-dialog.c +++ b/plugins/launcher/launcher-dialog.c @@ -31,8 +31,7 @@ static void launcher_dialog_add_button_clicked (GtkWidget *button, GtkWidget *menu) { - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 1, - gtk_get_current_event_time()); + } @@ -42,7 +41,7 @@ launcher_dialog_show (LauncherPlugin *plugin) { GtkBuilder *builder; GObject *dialog; - GObject *object, *menu; + GObject *object; panel_return_if_fail (XFCE_IS_LAUNCHER_PLUGIN (plugin)); @@ -56,8 +55,7 @@ launcher_dialog_show (LauncherPlugin *plugin) g_signal_connect_swapped (G_OBJECT (object), "clicked", G_CALLBACK (gtk_widget_destroy), dialog); object = gtk_builder_get_object (builder, "entry-add"); - menu = gtk_builder_get_object (builder, "add-menu"); - g_signal_connect (G_OBJECT (object), "clicked", G_CALLBACK (launcher_dialog_add_button_clicked), GTK_MENU (menu)); + g_signal_connect (G_OBJECT (object), "clicked", G_CALLBACK (launcher_dialog_add_button_clicked), NULL); /* connect binding to the advanced properties */ object = gtk_builder_get_object (builder, "disable-tooltips"); diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c index d028fd227..092763ae0 100644 --- a/plugins/launcher/launcher.c +++ b/plugins/launcher/launcher.c @@ -112,7 +112,7 @@ static void launcher_plugin_init (LauncherPlugin *plugin) { GdkScreen *screen; - + /* initialize xfconf */ xfconf_init (NULL); @@ -314,7 +314,7 @@ launcher_plugin_free_data (XfcePanelPlugin *panel_plugin) /* release the xfconf channel */ g_object_unref (G_OBJECT (plugin->channel)); - + /* shutdown xfconf */ xfconf_shutdown (); diff --git a/plugins/tasklist/plugin.c b/plugins/tasklist/plugin.c index 555b83427..1e683cfa4 100644 --- a/plugins/tasklist/plugin.c +++ b/plugins/tasklist/plugin.c @@ -14,7 +14,7 @@ * along with this library; 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 @@ -49,7 +49,7 @@ struct _TasklistPlugin /* the xfconf channel */ XfconfChannel *channel; - + /* the tasklist widget */ GtkWidget *tasklist; }; @@ -93,7 +93,7 @@ tasklist_plugin_init (TasklistPlugin *plugin) { /* initialize xfconf */ xfconf_init (NULL); - + plugin->tasklist = g_object_new (XFCE_TYPE_TASKLIST, NULL); gtk_container_add (GTK_CONTAINER (plugin), plugin->tasklist); } @@ -104,26 +104,26 @@ static void tasklist_plugin_construct (XfcePanelPlugin *panel_plugin) { TasklistPlugin *plugin = XFCE_TASKLIST_PLUGIN (panel_plugin); - + /* expand the plugin */ xfce_panel_plugin_set_expand (XFCE_PANEL_PLUGIN (plugin), TRUE); xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin)); - + /* open the xfconf channel */ plugin->channel = xfce_panel_plugin_xfconf_channel_new (panel_plugin); - + /* create bindings */ - xfconf_g_property_bind (plugin->channel, "/style", G_TYPE_UINT, + xfconf_g_property_bind (plugin->channel, "/style", G_TYPE_UINT, plugin->tasklist, "style"); - xfconf_g_property_bind (plugin->channel, "/include-all-workspaces", G_TYPE_BOOLEAN, + xfconf_g_property_bind (plugin->channel, "/include-all-workspaces", G_TYPE_BOOLEAN, plugin->tasklist, "include-all-workspaces"); - xfconf_g_property_bind (plugin->channel, "/flat-buttons", G_TYPE_BOOLEAN, + xfconf_g_property_bind (plugin->channel, "/flat-buttons", G_TYPE_BOOLEAN, plugin->tasklist, "flat-buttons"); - xfconf_g_property_bind (plugin->channel, "/switch-workspace-on-unminimize", G_TYPE_BOOLEAN, + xfconf_g_property_bind (plugin->channel, "/switch-workspace-on-unminimize", G_TYPE_BOOLEAN, plugin->tasklist, "switch-workspace-on-unminimize"); - xfconf_g_property_bind (plugin->channel, "/show-only-minimized", G_TYPE_BOOLEAN, + xfconf_g_property_bind (plugin->channel, "/show-only-minimized", G_TYPE_BOOLEAN, plugin->tasklist, "show-only-minimized"); - + /* show the tasklist */ gtk_widget_show (plugin->tasklist); } @@ -134,11 +134,11 @@ static void tasklist_plugin_free_data (XfcePanelPlugin *panel_plugin) { TasklistPlugin *plugin = XFCE_TASKLIST_PLUGIN (panel_plugin); - + /* release the xfconf channel */ if (G_LIKELY (plugin->channel)) g_object_unref (G_OBJECT (plugin->channel)); - + /* shutdown xfconf */ xfconf_shutdown (); } @@ -150,7 +150,7 @@ tasklist_plugin_orientation_changed (XfcePanelPlugin *panel_plugin, GtkOrientation orientation) { TasklistPlugin *plugin = XFCE_TASKLIST_PLUGIN (panel_plugin); - + /* set the new tasklist orientation */ xfce_tasklist_set_orientation (XFCE_TASKLIST (plugin->tasklist), orientation); } @@ -170,31 +170,31 @@ tasklist_plugin_configure_plugin (XfcePanelPlugin *panel_plugin) { dialog = gtk_builder_get_object (builder, "dialog"); g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder); - + object = gtk_builder_get_object (builder, "close-button"); g_signal_connect_swapped (G_OBJECT (object), "clicked", G_CALLBACK (gtk_widget_destroy), dialog); - + object = gtk_builder_get_object (builder, "style"); exo_mutual_binding_new (G_OBJECT (plugin->tasklist), "style", object, "active"); - + object = gtk_builder_get_object (builder, "include-all-workspaces"); exo_mutual_binding_new (G_OBJECT (plugin->tasklist), "include-all-workspaces", object, "active"); - + object = gtk_builder_get_object (builder, "flat-buttons"); exo_mutual_binding_new (G_OBJECT (plugin->tasklist), "flat-buttons", object, "active"); - + object = gtk_builder_get_object (builder, "switch-workspace-on-unminimize"); exo_mutual_binding_new_with_negation (G_OBJECT (plugin->tasklist), "switch-workspace-on-unminimize", object, "active"); - + object = gtk_builder_get_object (builder, "show-only-minimized"); exo_mutual_binding_new (G_OBJECT (plugin->tasklist), "show-only-minimized", object, "active"); - + /* TODO remove when implemented by glade */ GtkCellRenderer *cell1 = gtk_cell_renderer_text_new (); object = gtk_builder_get_object (builder, "style"); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), cell1, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), cell1, "text", 0, NULL); - + gtk_widget_show (GTK_WIDGET (dialog)); } else diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c index 998bdce2a..998b0cb6b 100644 --- a/plugins/tasklist/tasklist.c +++ b/plugins/tasklist/tasklist.c @@ -61,7 +61,7 @@ struct _XfceTasklist /* number of visible buttons, we cache this to avoid a loop */ guint n_visible_children; - + /* classgroups of all the windows in the taskbar */ GSList *class_groups; @@ -100,7 +100,7 @@ struct _XfceTasklistChild /* this window of this button */ WnckWindow *window; - + /* class group of this window */ WnckClassGroup *class_group; @@ -173,7 +173,7 @@ xfce_tasklist_class_init (XfceTasklistClass *klass) gtkcontainer_class->remove = xfce_tasklist_remove; gtkcontainer_class->forall = xfce_tasklist_forall; gtkcontainer_class->child_type = xfce_tasklist_child_type; - + g_object_class_install_property (gobject_class, PROP_STYLE, g_param_spec_uint ("style", NULL, NULL, @@ -181,25 +181,25 @@ xfce_tasklist_class_init (XfceTasklistClass *klass) XFCE_TASKLIST_STYLE_ICONBOX, XFCE_TASKLIST_STYLE_NORMAL, EXO_PARAM_READWRITE)); - + g_object_class_install_property (gobject_class, PROP_INCLUDE_ALL_WORKSPACES, g_param_spec_boolean ("include-all-workspaces", NULL, NULL, FALSE, EXO_PARAM_READWRITE)); - + g_object_class_install_property (gobject_class, PROP_FLAT_BUTTONS, g_param_spec_boolean ("flat-buttons", NULL, NULL, FALSE, EXO_PARAM_READWRITE)); - + g_object_class_install_property (gobject_class, PROP_SWITCH_WORKSPACE_ON_UNMINIMIZE, g_param_spec_boolean ("switch-workspace-on-unminimize", NULL, NULL, TRUE, EXO_PARAM_READWRITE)); - + g_object_class_install_property (gobject_class, PROP_SHOW_ONLY_MINIMIZED, g_param_spec_boolean ("show-only-minimized", NULL, NULL, @@ -234,36 +234,36 @@ xfce_tasklist_init (XfceTasklist *tasklist) -static void -xfce_tasklist_get_property (GObject *object, - guint prop_id, - GValue *value, +static void +xfce_tasklist_get_property (GObject *object, + guint prop_id, + GValue *value, GParamSpec *pspec) { XfceTasklist *tasklist = XFCE_TASKLIST (object); - + switch (prop_id) { case PROP_STYLE: g_value_set_uint (value, tasklist->style); break; - + case PROP_INCLUDE_ALL_WORKSPACES: g_value_set_boolean (value, tasklist->all_workspaces); break; - + case PROP_FLAT_BUTTONS: g_value_set_boolean (value, !!(tasklist->button_relief == GTK_RELIEF_NONE)); break; - + case PROP_SWITCH_WORKSPACE_ON_UNMINIMIZE: g_value_set_boolean (value, tasklist->switch_workspace); break; - + case PROP_SHOW_ONLY_MINIMIZED: g_value_set_boolean (value, tasklist->only_minimized); break; - + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -272,43 +272,43 @@ xfce_tasklist_get_property (GObject *object, -static void -xfce_tasklist_set_property (GObject *object, - guint prop_id, - const GValue *value, +static void +xfce_tasklist_set_property (GObject *object, + guint prop_id, + const GValue *value, GParamSpec *pspec) { XfceTasklist *tasklist = XFCE_TASKLIST (object); - + switch (prop_id) { case PROP_STYLE: /* set the tasklist style */ xfce_tasklist_set_style (tasklist, g_value_get_uint (value)); break; - + case PROP_INCLUDE_ALL_WORKSPACES: /* set include all workspaces */ xfce_tasklist_set_include_all_workspaces (tasklist, g_value_get_boolean (value)); break; - + case PROP_FLAT_BUTTONS: /* set the tasklist relief */ xfce_tasklist_set_button_relief (tasklist, - g_value_get_boolean (value) ? + g_value_get_boolean (value) ? GTK_RELIEF_NONE : GTK_RELIEF_NORMAL); break; - + case PROP_SWITCH_WORKSPACE_ON_UNMINIMIZE: /* set the new value */ tasklist->switch_workspace = g_value_get_boolean (value); break; - + case PROP_SHOW_ONLY_MINIMIZED: /* whether the tasklist shows only minimized applications */ xfce_tasklist_set_show_only_minimized (tasklist, g_value_get_boolean (value)); break; - + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -321,7 +321,7 @@ static void xfce_tasklist_finalize (GObject *object) { XfceTasklist *tasklist = XFCE_TASKLIST (object); - + g_return_if_fail (tasklist->children == NULL); g_return_if_fail (tasklist->class_groups == NULL); @@ -681,7 +681,7 @@ xfce_tasklist_disconnect_screen (XfceTasklist *tasklist) { GSList *li, *lnext; XfceTasklistChild *child; - + g_return_if_fail (XFCE_IS_TASKLIST (tasklist)); g_return_if_fail (WNCK_IS_SCREEN (tasklist->screen)); @@ -691,13 +691,13 @@ xfce_tasklist_disconnect_screen (XfceTasklist *tasklist) g_signal_handlers_disconnect_by_func (G_OBJECT (tasklist->screen), G_CALLBACK (xfce_tasklist_window_added), tasklist); g_signal_handlers_disconnect_by_func (G_OBJECT (tasklist->screen), G_CALLBACK (xfce_tasklist_window_removed), tasklist); g_signal_handlers_disconnect_by_func (G_OBJECT (tasklist->screen), G_CALLBACK (xfce_tasklist_viewports_changed), tasklist); - + /* remove all the windows */ for (li = tasklist->children; li != NULL; li = lnext) { lnext = li->next; child = li->data; - + /* do a fake window remove */ xfce_tasklist_window_removed (tasklist->screen, child->window, tasklist); } @@ -807,10 +807,10 @@ xfce_tasklist_window_added (WnckScreen *screen, child->tasklist = tasklist; child->window = window; child->unique_id = unique_id_counter++; - + /* get the class group of the new window */ class_group = wnck_window_get_class_group (window); - + if (G_LIKELY (class_group)) { /* try to find the class group in the list */ @@ -821,7 +821,7 @@ xfce_tasklist_window_added (WnckScreen *screen, /* prepend the class group if it's new */ if (li == NULL) tasklist->class_groups = g_slist_prepend (tasklist->class_groups, class_group); - + /* set the class group */ child->class_group = g_object_ref (G_OBJECT (class_group)); } @@ -857,7 +857,7 @@ xfce_tasklist_window_removed (WnckScreen *screen, g_return_if_fail (WNCK_IS_WINDOW (window)); g_return_if_fail (XFCE_IS_TASKLIST (tasklist)); g_return_if_fail (tasklist->screen == screen); - + /* remove the child from the taskbar */ for (li = tasklist->children; li != NULL; li = li->next) { @@ -871,11 +871,11 @@ xfce_tasklist_window_removed (WnckScreen *screen, * window in the group */ if (g_list_length (wnck_class_group_get_windows (child->class_group)) == 1) tasklist->class_groups = g_slist_remove (tasklist->class_groups, child->class_group); - + /* release the class group */ g_object_unref (G_OBJECT (child->class_group)); } - + /* destroy the button */ gtk_widget_destroy (child->button); diff --git a/wrapper/main.c b/wrapper/main.c index 35d7a7786..2c1d6c364 100644 --- a/wrapper/main.c +++ b/wrapper/main.c @@ -39,6 +39,7 @@ #include <dbus/dbus-glib-lowlevel.h> #include <gtk/gtk.h> +#include <common/panel-dbus.h> #include <libxfce4util/libxfce4util.h> #include <libxfce4panel/libxfce4panel.h> #include <libxfce4panel/xfce-panel-plugin-provider.h> @@ -74,7 +75,7 @@ static GOptionEntry option_entries[] = static void dbus_gproxy_provider_property_changed (DBusGProxy *dbus_gproxy, gint plugin_id, - const gchar *property, + DBusPropertyChanged changed_property, const GValue *value, XfcePanelPluginProvider *provider) { @@ -88,32 +89,49 @@ dbus_gproxy_provider_property_changed (DBusGProxy *dbus_gproxy, if (plugin_id != opt_unique_id) return; - /* handle the property */ - if (G_UNLIKELY (!IS_STRING (property))) - g_message ("External plugin '%s-%d' received null property.", opt_name, opt_unique_id); - else if (strcmp (property, "Size") == 0) - xfce_panel_plugin_provider_set_size (provider, g_value_get_int (value)); - else if (strcmp (property, "Orientation") == 0) - xfce_panel_plugin_provider_set_orientation (provider, g_value_get_uint (value)); - else if (strcmp (property, "ScreenPosition") == 0) - xfce_panel_plugin_provider_set_screen_position (provider, g_value_get_uint (value)); - else if (strcmp (property, "Save") == 0) - xfce_panel_plugin_provider_save (provider); - else if (strcmp (property, "Quit") == 0) - gtk_main_quit (); - else if (strcmp (property, "Sensitive") == 0) - gtk_widget_set_sensitive (GTK_WIDGET (provider), g_value_get_boolean (value)); - else + /* handle the changed property send by the panel to the wrapper */ + switch (changed_property) { - /* get the plug */ - plug = g_object_get_qdata (G_OBJECT (provider), plug_quark); - - if (strcmp (property, "BackgroundAlpha") == 0) - wrapper_plug_set_background_alpha (plug, g_value_get_int (value) / 100.00); - else if (strcmp (property, "ActivePanel") == 0) - wrapper_plug_set_selected (plug, g_value_get_boolean (value)); - else - g_message ("External plugin '%s-%d' received unknown property '%s'.", opt_name, opt_unique_id, property); + case DBUS_PROPERTY_CHANGED_SIZE: + xfce_panel_plugin_provider_set_size (provider, g_value_get_int (value)); + break; + + case DBUS_PROPERTY_CHANGED_ORIENTATION: + xfce_panel_plugin_provider_set_orientation (provider, g_value_get_uint (value)); + break; + + case DBUS_PROPERTY_CHANGED_SCREEN_POSITION: + xfce_panel_plugin_provider_set_screen_position (provider, g_value_get_uint (value)); + break; + + case DBUS_PROPERTY_CHANGED_EMIT_SAVE: + xfce_panel_plugin_provider_save (provider); + break; + + case DBUS_PROPERTY_CHANGED_QUIT_WRAPPER: + gtk_main_quit (); + break; + + case DBUS_PROPERTY_CHANGED_SENSITIVE: + gtk_widget_set_sensitive (GTK_WIDGET (provider), g_value_get_boolean (value)); + break; + + case DBUS_PROPERTY_CHANGED_BACKGROUND_ALPHA: + case DBUS_PROPERTY_CHANGED_ACTIVE_PANEL: + /* get the plug */ + plug = g_object_get_qdata (G_OBJECT (provider), plug_quark); + + /* set a plug value */ + if (changed_property == DBUS_PROPERTY_CHANGED_BACKGROUND_ALPHA) + wrapper_plug_set_background_alpha (plug, g_value_get_int (value) / 100.00); + else + wrapper_plug_set_selected (plug, g_value_get_boolean (value)); + break; + + default: + g_message ("External plugin '%s-%d' received unknown property '%d'.", + opt_name, opt_unique_id, changed_property); + break; } } @@ -124,64 +142,26 @@ dbus_gproxy_provider_signal (XfcePanelPluginProvider *provider, XfcePanelPluginProviderSignal signal, DBusGProxy *dbus_gproxy) { - GValue value = { 0, }; - GError *error = NULL; - guint active_panel = 0; - gboolean result = FALSE; + GValue value = { 0, }; + GError *error = NULL; panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider)); panel_return_if_fail (opt_unique_id == xfce_panel_plugin_provider_get_unique_id (provider)); - /* handle the signal */ - switch (signal) - { - case MOVE_PLUGIN: - case REMOVE_PLUGIN: - case EXPAND_PLUGIN: - case COLLAPSE_PLUGIN: - case LOCK_PANEL: - case UNLOCK_PANEL: - /* initialize the value */ - g_value_init (&value, G_TYPE_UINT); - g_value_set_uint (&value, signal); - - /* invoke the method */ - result = wrapper_dbus_client_set_property (dbus_gproxy, opt_unique_id, - "ProviderSignal", &value, &error); - - /* unset */ - g_value_unset (&value); - break; - - case ADD_NEW_ITEMS: - case PANEL_PREFERENCES: - /* try to get the panel number of this plugin */ - if (wrapper_dbus_client_get_property (dbus_gproxy, opt_unique_id, - "PanelNumber", &value, NULL)) - { - /* set the panel number */ - active_panel = g_value_get_uint (&value); - g_value_unset (&value); - } - - /* invoke the methode */ - if (signal == ADD_NEW_ITEMS) - result = wrapper_dbus_client_display_items_dialog (dbus_gproxy, active_panel, &error); - else - result = wrapper_dbus_client_display_preferences_dialog (dbus_gproxy, active_panel, &error); - break; + /* initialize the value */ + g_value_init (&value, G_TYPE_INT); + g_value_set_int (&value, signal); - default: - g_critical ("Plugin '%s-%d' received an unknown provider signal '%d'.", opt_name, opt_unique_id, signal); - return; - } - - /* handle errors */ - if (result == FALSE) + /* send the provider signal to the panel */ + if (!wrapper_dbus_client_set_property (dbus_gproxy, opt_unique_id, + "ProviderSignal", &value, &error)) { g_critical ("DBus error: %s", error->message); g_error_free (error); } + + /* unset */ + g_value_unset (&value); } @@ -323,9 +303,9 @@ main (gint argc, gchar **argv) } /* setup signal for property changes */ - dbus_g_object_register_marshaller (wrapper_marshal_VOID__INT_STRING_BOXED, G_TYPE_NONE, - G_TYPE_INT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); - dbus_g_proxy_add_signal (dbus_gproxy, "PropertyChanged", G_TYPE_INT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); + dbus_g_object_register_marshaller (wrapper_marshal_VOID__INT_UINT_BOXED, G_TYPE_NONE, + G_TYPE_INT, G_TYPE_UINT, G_TYPE_VALUE, G_TYPE_INVALID); + dbus_g_proxy_add_signal (dbus_gproxy, "PropertyChanged", G_TYPE_INT, G_TYPE_UINT, G_TYPE_VALUE, G_TYPE_INVALID); /* load the module and link the function */ module = g_module_open (opt_filename, G_MODULE_BIND_LOCAL); @@ -355,7 +335,7 @@ main (gint argc, gchar **argv) } /* contruct the panel plugin */ - provider = (*construct_func) (opt_name, opt_unique_id, opt_display_name, + provider = (*construct_func) (opt_name, opt_unique_id, opt_display_name, opt_arguments, gdk_screen_get_default ()); if (G_LIKELY (provider)) { -- GitLab