[Xfce4-commits] <xfce4-panel:devel> Fix wrong usage of xfce_panel_plugin_provider_get_unique_id.

Nick Schermer nick at xfce.org
Tue Aug 11 20:36:02 CEST 2009


Updating branch refs/heads/devel
         to dba3f3bf4fc0719214fc5c10b92845293c6208ff (commit)
       from b9af75e0c37753876455bfc88ddcb903786f9148 (commit)

commit dba3f3bf4fc0719214fc5c10b92845293c6208ff
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Aug 4 22:37:45 2009 +0200

    Fix wrong usage of xfce_panel_plugin_provider_get_unique_id.

 panel/panel-application.c    |   10 ++++------
 panel/panel-module-factory.c |    9 +++++++--
 panel/panel-module-factory.h |    3 ++-
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/panel/panel-application.c b/panel/panel-application.c
index f7bcbaa..a254a1d 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -570,6 +570,7 @@ panel_application_plugin_insert (PanelApplication  *application,
                                  gint               position)
 {
   GtkWidget *itembar, *provider;
+  gint       new_unique_id;
 
   panel_return_val_if_fail (PANEL_IS_APPLICATION (application), FALSE);
   panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
@@ -579,24 +580,21 @@ panel_application_plugin_insert (PanelApplication  *application,
   /* create a new panel plugin */
   provider = panel_module_factory_new_plugin (application->factory,
                                               name, screen, unique_id,
-                                              arguments);
+                                              arguments, &new_unique_id);
   if (G_UNLIKELY (provider == NULL))
     return FALSE;
 
   /* make sure there is no panel configuration with this unique id when a
    * new plugin is created */
   if (G_UNLIKELY (unique_id == -1))
-    {
-      unique_id = xfce_panel_plugin_provider_get_unique_id (XFCE_PANEL_PLUGIN_PROVIDER (provider));
-      panel_application_plugin_delete_config (application, name, unique_id);
-    }
+    panel_application_plugin_delete_config (application, name, new_unique_id);
 
   /* get the panel itembar */
   itembar = gtk_bin_get_child (GTK_BIN (window));
 
   /* add signal to monitor provider signals */
   g_signal_connect (G_OBJECT (provider), "provider-signal",
-                    G_CALLBACK (panel_application_plugin_provider_signal), application);
+      G_CALLBACK (panel_application_plugin_provider_signal), application);
 
   /* add the item to the panel */
   panel_itembar_insert (PANEL_ITEMBAR (itembar),
diff --git a/panel/panel-module-factory.c b/panel/panel-module-factory.c
index 4a1ce69..b91a2c3 100644
--- a/panel/panel-module-factory.c
+++ b/panel/panel-module-factory.c
@@ -396,7 +396,8 @@ panel_module_factory_new_plugin (PanelModuleFactory  *factory,
                                  const gchar         *name,
                                  GdkScreen           *screen,
                                  gint                 unique_id,
-                                 gchar              **arguments)
+                                 gchar              **arguments,
+                                 gint                *return_unique_id)
 {
   PanelModule *module;
   GtkWidget   *provider;
@@ -421,6 +422,10 @@ panel_module_factory_new_plugin (PanelModuleFactory  *factory,
          || panel_module_factory_get_plugin (factory, unique_id) != NULL)
     unique_id = ++unique_id_counter;
 
+  /* set the return value with an always valid unique id */
+  if (G_LIKELY (return_unique_id != NULL))
+    *return_unique_id = unique_id;
+
   /* create the new module */
   provider = panel_module_new_plugin (module, screen, unique_id, arguments);
 
@@ -429,7 +434,7 @@ panel_module_factory_new_plugin (PanelModuleFactory  *factory,
     {
       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-module-factory.h b/panel/panel-module-factory.h
index 61fae84..d67a03a 100644
--- a/panel/panel-module-factory.h
+++ b/panel/panel-module-factory.h
@@ -61,7 +61,8 @@ GtkWidget          *panel_module_factory_new_plugin          (PanelModuleFactory
                                                               const gchar         *name,
                                                               GdkScreen           *screen,
                                                               gint                 unique_id,
-                                                              gchar              **arguments) G_GNUC_MALLOC;
+                                                              gchar              **arguments,
+                                                              gint                *return_unique_id) G_GNUC_MALLOC;
 
 G_END_DECLS
 



More information about the Xfce4-commits mailing list