[Xfce4-commits] <xfce4-panel:master> Don't ask for panel when inserting items (bug #8544).

Nick Schermer noreply at xfce.org
Sat Mar 10 15:40:01 CET 2012


Updating branch refs/heads/master
         to c44b85a4b3fcfe1363d4326b6ffb779766678764 (commit)
       from 882b4bb1a76d39fd82562bcb1fa4846c51cdb78b (commit)

commit c44b85a4b3fcfe1363d4326b6ffb779766678764
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Mar 10 15:38:46 2012 +0100

    Don't ask for panel when inserting items (bug #8544).

 panel/panel-application.c  |   36 ++++++++++++++++++++----------------
 panel/panel-application.h  |    1 +
 panel/panel-base-window.h  |    3 ---
 panel/panel-dbus-service.c |    9 +++++----
 panel/panel-item-dialog.c  |    8 +++++---
 5 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/panel/panel-application.c b/panel/panel-application.c
index db10e70..7506255 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -1364,15 +1364,16 @@ panel_application_destroy_dialogs (PanelApplication *application)
 
 void
 panel_application_add_new_item (PanelApplication  *application,
+                                PanelWindow       *window,
                                 const gchar       *plugin_name,
                                 gchar            **arguments)
 {
-  PanelWindow *window = NULL;
-  gint         panel_id;
+  gint panel_id;
 
   panel_return_if_fail (PANEL_IS_APPLICATION (application));
   panel_return_if_fail (plugin_name != NULL);
   panel_return_if_fail (application->windows != NULL);
+  panel_return_if_fail (window == NULL || PANEL_IS_WINDOW (window));
 
   /* leave if the config is locked */
   if (panel_application_get_locked (application))
@@ -1380,27 +1381,30 @@ panel_application_add_new_item (PanelApplication  *application,
 
   if (panel_module_factory_has_module (application->factory, plugin_name))
     {
-      /* find a suitable panel if there are 2 or more panel */
-      if (LIST_HAS_TWO_OR_MORE_ENTRIES (application->windows))
+      if (window == NULL)
         {
-          /* ask the user to select a panel */
-          panel_id = panel_dialogs_choose_panel (application);
-          if (panel_id == -1)
+          /* find a suitable panel if there are 2 or more panel */
+          if (LIST_HAS_TWO_OR_MORE_ENTRIES (application->windows))
             {
-              /* cancel was clicked */
-              return;
+              /* ask the user to select a panel */
+              panel_id = panel_dialogs_choose_panel (application);
+              if (panel_id == -1)
+                {
+                  /* cancel was clicked */
+                  return;
+                }
+              else
+                {
+                  /* get panel from the id */
+                  window = panel_application_get_window (application, panel_id);
+                }
             }
           else
             {
-              /* get panel from the id */
-              window = panel_application_get_window (application, panel_id);
+              /* get the first (and only) window */
+              window = g_slist_nth_data (application->windows, 0);
             }
         }
-      else
-        {
-          /* get the first (and only) window */
-          window = g_slist_nth_data (application->windows, 0);
-        }
 
       if (window != NULL && !panel_window_get_locked (window))
         {
diff --git a/panel/panel-application.h b/panel/panel-application.h
index 36f4504..ac28119 100644
--- a/panel/panel-application.h
+++ b/panel/panel-application.h
@@ -60,6 +60,7 @@ void              panel_application_take_dialog       (PanelApplication  *applic
 void              panel_application_destroy_dialogs   (PanelApplication  *application);
 
 void              panel_application_add_new_item      (PanelApplication  *application,
+                                                       PanelWindow       *window,
                                                        const gchar       *plugin_name,
                                                        gchar            **arguments);
 
diff --git a/panel/panel-base-window.h b/panel/panel-base-window.h
index 71c8d92..836e2b9 100644
--- a/panel/panel-base-window.h
+++ b/panel/panel-base-window.h
@@ -84,9 +84,6 @@ void         panel_base_window_set_borders (PanelBaseWindow *window,
                                             PanelBorders     borders);
 PanelBorders panel_base_window_get_borders (PanelBaseWindow *window);
 
-void         panel_base_window_set_active  (PanelBaseWindow *window,
-                                            gboolean         active);
-
 void         panel_util_set_source_rgba    (cairo_t         *cr,
                                             const GdkColor  *color,
                                             gdouble          alpha);
diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c
index 800b5dc..c0c6e9a 100644
--- a/panel/panel-dbus-service.c
+++ b/panel/panel-dbus-service.c
@@ -27,6 +27,7 @@
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
+#include <exo/exo.h>
 #include <common/panel-private.h>
 #include <common/panel-dbus.h>
 #include <libxfce4util/libxfce4util.h>
@@ -254,11 +255,11 @@ panel_dbus_service_add_new_item (PanelDBusService  *service,
 
   application = panel_application_get ();
 
+  if (arguments != NULL && exo_str_is_empty (*arguments))
+    arguments = NULL;
+
   /* add new plugin (with or without arguments) */
-  if (arguments && *arguments != NULL)
-    panel_application_add_new_item (application, plugin_name, arguments);
-  else
-    panel_application_add_new_item (application, plugin_name, NULL);
+  panel_application_add_new_item (application, NULL, plugin_name, arguments);
 
   g_object_unref (G_OBJECT (application));
 
diff --git a/panel/panel-item-dialog.c b/panel/panel-item-dialog.c
index e9a6fc7..98dd04a 100644
--- a/panel/panel-item-dialog.c
+++ b/panel/panel-item-dialog.c
@@ -108,6 +108,8 @@ struct _PanelItemDialog
 
   PanelModuleFactory *factory;
 
+  PanelWindow        *active;
+
   /* pointers to list */
   GtkListStore       *store;
   GtkTreeView        *treeview;
@@ -329,6 +331,7 @@ panel_item_dialog_response (GtkDialog *gtk_dialog,
       if (G_LIKELY (module != NULL))
         {
           panel_application_add_new_item (dialog->application,
+              dialog->active,
               panel_module_get_name (module), NULL);
           g_object_unref (G_OBJECT (module));
         }
@@ -795,6 +798,7 @@ panel_item_dialog_show (PanelWindow *window)
       /* set the active panel */
       application = panel_application_get ();
       panel_application_window_select (application, window);
+      dialog_singleton->active = window;
       g_object_unref (G_OBJECT (application));
 
       screen = gtk_window_get_screen (GTK_WINDOW (window));
@@ -803,10 +807,8 @@ panel_item_dialog_show (PanelWindow *window)
     {
       screen = gdk_screen_get_default ();
     }
-  gtk_window_set_screen (GTK_WINDOW (dialog_singleton), screen);
 
-  /* show the dialog */
-  gtk_widget_show (GTK_WIDGET (dialog_singleton));
+  gtk_window_set_screen (GTK_WINDOW (dialog_singleton), screen);
 
   /* focus the window */
   gtk_window_present (GTK_WINDOW (dialog_singleton));


More information about the Xfce4-commits mailing list