Fix behavior of one_per_system plugin attribute.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Tue, 11 Feb 2014 03:14:49 +0000 (05:14 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Tue, 11 Feb 2014 03:14:49 +0000 (05:14 +0200)
The presence was wrongly checked against only current panel.

src/configurator.c
src/panel.c
src/private.h

index 2932650..afaa8e5 100644 (file)
@@ -654,14 +654,6 @@ static void on_add_plugin_response( GtkDialog* dlg,
     gtk_widget_destroy( GTK_WIDGET(dlg) );
 }
 
-static gboolean _class_is_present(LXPanelPluginInit *init, GList *p)
-{
-    for ( ; p; p = p->next)
-        if (PLUGIN_CLASS(p->data) == init)
-            return TRUE;
-    return FALSE;
-}
-
 static void on_add_plugin( GtkButton* btn, GtkTreeView* _view )
 {
     GtkWidget* dlg, *parent_win, *scroll;
@@ -723,7 +715,7 @@ static void on_add_plugin( GtkButton* btn, GtkTreeView* _view )
     while(g_hash_table_iter_next(&iter, &key, &val))
     {
         register LXPanelPluginInit *init = val;
-        if (!init->one_per_system || !_class_is_present(init, plugins))
+        if (!init->one_per_system || !_class_is_present(init))
         {
             GtkTreeIter it;
             gtk_list_store_append( list, &it );
index 5d5ff76..82e1fe0 100644 (file)
@@ -1727,3 +1727,24 @@ extern GtkWidget *panel_separator_new(Panel *panel)
 {
     return panel->my_separator_new();
 }
+
+gboolean _class_is_present(LXPanelPluginInit *init)
+{
+    GSList *sl;
+
+    for (sl = all_panels; sl; sl = sl->next )
+    {
+        Panel *panel = (Panel*)sl->data;
+        GList *plugins, *p;
+
+        plugins = gtk_container_get_children(GTK_CONTAINER(panel->box));
+        for (p = plugins; p; p = p->next)
+            if (PLUGIN_CLASS(p->data) == init)
+            {
+                g_list_free(plugins);
+                return TRUE;
+            }
+        g_list_free(plugins);
+    }
+    return FALSE;
+}
index 5bb491a..5717bc9 100644 (file)
@@ -193,6 +193,8 @@ GQuark lxpanel_plugin_qconf; /* access to congig_setting_t data */
 GQuark lxpanel_plugin_qpanel; /* access to Panel */
 #define PLUGIN_PANEL(_i) ((Panel*)g_object_get_qdata(G_OBJECT(_i),lxpanel_plugin_qpanel))
 
+gboolean _class_is_present(LXPanelPluginInit *init);
+
 /* -----------------------------------------------------------------------------
  *   Deprecated declarations. Kept for compatibility with old code plugins.
  *   Should be removed and appropriate code cleaned on some of next releases. */