[Xfce4-commits] <xfce4-panel:devel> * Change some g_return_'s to panel_return for static functions. * Cleanup panel application. * Make panels sensitive again when a plugin drag is canceled. * Move plugin provider information of the panel to glue and use this function after a plugin move, insert and external plugin restart.

Nick Schermer nick at xfce.org
Tue Aug 11 20:22:35 CEST 2009


Updating branch refs/heads/devel
         to 125280be535aae51d76cfca7dc87a32e3a132a38 (commit)
       from f4a76381a98cd6cc13653634f65ab94fb81a9756 (commit)

commit 125280be535aae51d76cfca7dc87a32e3a132a38
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Jun 24 22:00:27 2008 +0200

    * Change some g_return_'s to panel_return for static functions.
    * Cleanup panel application.
    * Make panels sensitive again when a plugin drag is canceled.
    * Move plugin provider information of the panel to glue and
      use this function after a plugin move, insert and external
      plugin restart.

 libxfce4panel/xfce-panel-plugin.c |   10 +-
 panel/panel-application.c         |  604 ++++++++++++++++++++-----------------
 panel/panel-dbus-service.h        |    1 -
 panel/panel-glue.c                |   25 ++
 panel/panel-glue.h                |   22 +-
 panel/panel-plugin-external.c     |   26 ++-
 6 files changed, 386 insertions(+), 302 deletions(-)

diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 35acd30..c46d1d0 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -815,7 +815,7 @@ xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
 {
   XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
 
-  g_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
 
   /* check if update is required */
   if (G_LIKELY (xfce_panel_plugin_get_size (plugin) != size))
@@ -878,7 +878,7 @@ xfce_panel_plugin_set_orientation (XfcePanelPluginProvider *provider,
 {
   XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
 
-  g_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
 
   /* check if update is required */
   if (G_LIKELY (xfce_panel_plugin_get_orientation (plugin) != orientation))
@@ -912,14 +912,14 @@ xfce_panel_plugin_set_screen_position (XfcePanelPluginProvider *provider,
   panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
 
   /* check if update is required */
-  //~ if (G_LIKELY (xfce_panel_plugin_get_screen_position (plugin) != screen_position))
-    //~ {
+  if (G_LIKELY (xfce_panel_plugin_get_screen_position (plugin) != screen_position))
+    {
       /* store new screen position */
       plugin->priv->screen_position = screen_position;
 
       /* emit signal */
       g_signal_emit (G_OBJECT (plugin), plugin_signals[SCREEN_POSITION_CHANGED], 0, screen_position);
-    //~ }
+    }
 }
 
 
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 0d6f825..a85092e 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -47,16 +47,56 @@
 
 
 
-static void panel_application_class_init (PanelApplicationClass *klass);
-static void panel_application_init (PanelApplication *application);
-static void panel_application_finalize (GObject *object);
-static void panel_application_load (PanelApplication *application);
-static void panel_application_load_set_property (PanelWindow *window, const gchar *name, const gchar *value);
-static void panel_application_load_start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer  user_data, GError **error);
-static void panel_application_load_end_element (GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error);
-static gboolean panel_application_save_timeout (gpointer user_data);
-static gchar *panel_application_save_xml_contents (PanelApplication *application);
-static void panel_application_window_destroyed (GtkWidget *window, PanelApplication *application);
+static void      panel_application_class_init         (PanelApplicationClass  *klass);
+static void      panel_application_init               (PanelApplication       *application);
+static void      panel_application_finalize           (GObject                *object);
+static void      panel_application_load               (PanelApplication       *application);
+static void      panel_application_load_set_property  (PanelWindow            *window,
+                                                       const gchar            *name,
+                                                       const gchar            *value);
+static void      panel_application_load_start_element (GMarkupParseContext    *context,
+                                                       const gchar            *element_name,
+                                                       const gchar           **attribute_names,
+                                                       const gchar           **attribute_values,
+                                                       gpointer                user_data,
+                                                       GError                **error);
+static void      panel_application_load_end_element   (GMarkupParseContext    *context,
+                                                       const gchar            *element_name,
+                                                       gpointer                user_data,
+                                                       GError                **error);
+static void      panel_application_plugin_expand      (GtkWidget              *plugin,
+                                                       gboolean                expand,
+                                                       PanelWindow            *window);
+static void      panel_application_plugin_move        (GtkWidget              *item,
+                                                       PanelApplication       *application);
+static gboolean  panel_application_plugin_insert      (PanelApplication       *application,
+                                                       PanelWindow            *window,
+                                                       GdkScreen              *screen,
+                                                       const gchar            *name,
+                                                       const gchar            *id,
+                                                       gchar                 **arguments,
+                                                       gint                    position);
+static gboolean  panel_application_save_timeout       (gpointer                user_data);
+static gchar    *panel_application_save_xml_contents  (PanelApplication       *application);
+static void      panel_application_window_destroyed   (GtkWidget              *window,
+                                                       PanelApplication       *application);
+static void      panel_application_dialog_destroyed   (GtkWindow              *dialog,
+                                                       PanelApplication       *application);
+static void      panel_application_drag_data_received (GtkWidget              *itembar,
+                                                       GdkDragContext         *context,
+                                                       gint                    x,
+                                                       gint                    y,
+                                                       GtkSelectionData       *selection_data,
+                                                       guint                   info,
+                                                       guint                   time,
+                                                       PanelWindow            *window);
+static gboolean  panel_application_drag_drop          (GtkWidget              *itembar,
+                                                       GdkDragContext         *context,
+                                                       gint                    x,
+                                                       gint                    y,
+                                                       guint                   time,
+                                                       PanelWindow            *window);
+
 
 
 struct _PanelApplicationClass
@@ -108,6 +148,11 @@ static GMarkupParser markup_parser =
   NULL
 };
 
+static const GtkTargetEntry drag_targets[] =
+{
+    { "application/x-xfce-panel-plugin-widget", 0, 0 }
+};
+
 
 
 G_DEFINE_TYPE (PanelApplication, panel_application, G_TYPE_OBJECT);
@@ -177,6 +222,20 @@ panel_application_finalize (GObject *object)
 
 
 
+static const gchar *
+panel_application_get_unique_id (void)
+{
+  static gint  counter = 0;
+  static gchar id[30];
+
+  /* create a unique if of the current time and counter */
+  g_snprintf (id, sizeof (id), "%ld%d", time (NULL), counter++);
+
+  return id;
+}
+
+
+
 static void
 panel_application_load (PanelApplication *application)
 {
@@ -331,140 +390,6 @@ panel_application_load_set_property (PanelWindow *window,
 }
 
 
-/* TODO: finish and rename function */
-static void
-expand_handle (GtkWidget *plugin,
-               gboolean expand,
-               PanelWindow *window)
-{
-  GtkWidget *itembar;
-
-  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
-  panel_return_if_fail (PANEL_IS_WINDOW (window));
-
-  /* get the itembar */
-  itembar = gtk_bin_get_child (GTK_BIN (window));
-
-  /* set new expand mode */
-  panel_itembar_set_child_expand (PANEL_ITEMBAR (itembar), plugin, expand);
-}
-
-
-
-/* TODO: move away from here */
-static const GtkTargetEntry drag_targets[] =
-{
-    { "application/x-xfce-panel-plugin-widget", 0, 0 }
-};
-
-
-
-/* TODO: finish and rename function */
-static void
-move_handle (GtkWidget        *item,
-             PanelApplication *application)
-{
-  GdkEvent      *event;
-  GtkTargetList *target_list;
-
-  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (item));
-  panel_return_if_fail (PANEL_IS_APPLICATION (application));
-
-  /* get a copy of the current event */
-  event = gtk_get_current_event ();
-  if (G_LIKELY (event))
-    {
-      /* make the window insensitive */
-      panel_application_windows_sensitive (application, FALSE);
-
-      /* create a target list */
-      target_list = gtk_target_list_new (drag_targets, G_N_ELEMENTS (drag_targets));
-
-      /* begin a drag */
-      gtk_drag_begin (item, target_list, GDK_ACTION_MOVE, 1, event);
-
-      /* release the drag list */
-      gtk_target_list_unref (target_list);
-
-      /* free the event */
-      gdk_event_free (event);
-    }
-}
-
-
-
-static const gchar *
-panel_application_get_unique_id (void)
-{
-  static gint  counter = 0;
-  static gchar id[30];
-
-  /* create a unique if of the current time and counter */
-  g_snprintf (id, sizeof (id), "%ld%d", time (NULL), counter++);
-
-  return id;
-}
-
-
-
-static gboolean
-panel_application_insert_plugin (PanelApplication  *application,
-                                 PanelWindow       *window,
-                                 GdkScreen         *screen,
-                                 const gchar       *name,
-                                 const gchar       *id,
-                                 gchar            **arguments,
-                                 gint               position)
-{
-  GtkWidget               *itembar;
-  gboolean                 succeed = FALSE;
-  XfcePanelPluginProvider *provider;
-
-  panel_return_val_if_fail (PANEL_IS_APPLICATION (application), FALSE);
-  panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
-  panel_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
-  panel_return_val_if_fail (name != NULL, FALSE);
-
-  /* create a new unique id if needed */
-  if (id == NULL)
-    id = panel_application_get_unique_id ();
-
-  /* create a new panel plugin */
-  provider = panel_module_factory_create_plugin (application->factory, screen, name, id, arguments);
-
-  if (G_LIKELY (provider != NULL))
-    {
-      /* get the panel itembar */
-      itembar = gtk_bin_get_child (GTK_BIN (window));
-
-      g_signal_connect (G_OBJECT (provider), "expand-changed", G_CALLBACK (expand_handle), window);
-      g_signal_connect_swapped (G_OBJECT (provider), "panel-preferences", G_CALLBACK (panel_preferences_dialog_show), window);
-      g_signal_connect (G_OBJECT (provider), "add-new-items", G_CALLBACK (panel_item_dialog_show), NULL);
-      g_signal_connect (G_OBJECT (provider), "move-item", G_CALLBACK (move_handle), application);
-
-      /* add the item to the panel */
-      panel_itembar_insert (PANEL_ITEMBAR (itembar), GTK_WIDGET (provider), position);
-
-      /* set the background alpha if the plugin is external */
-      if (PANEL_IS_PLUGIN_EXTERNAL (provider))
-        panel_plugin_external_set_background_alpha (PANEL_PLUGIN_EXTERNAL (provider), panel_window_get_background_alpha (window));
-
-      /* send plugin information */
-      xfce_panel_plugin_provider_set_orientation (provider, panel_window_get_orientation (window));
-      xfce_panel_plugin_provider_set_screen_position (provider, panel_glue_get_screen_position (window));
-      xfce_panel_plugin_provider_set_size (provider, panel_window_get_size (window));
-
-      /* show the plugin */
-      gtk_widget_show (GTK_WIDGET (provider));
-
-      /* we've succeeded */
-      succeed = TRUE;
-    }
-
-  return succeed;
-}
-
-
 
 static void
 panel_application_load_start_element (GMarkupParseContext  *context,
@@ -542,7 +467,7 @@ panel_application_load_start_element (GMarkupParseContext  *context,
 
             /* append the new plugin */
             if (G_LIKELY (name != NULL))
-              panel_application_insert_plugin (parser->application, parser->window,
+              panel_application_plugin_insert (parser->application, parser->window,
                                                gtk_window_get_screen (GTK_WINDOW (parser->window)),
                                                name, id, NULL, -1);
           }
@@ -610,6 +535,131 @@ panel_application_load_end_element (GMarkupParseContext  *context,
 
 
 
+static void
+panel_application_plugin_expand (GtkWidget   *plugin,
+                                 gboolean     expand,
+                                 PanelWindow *window)
+{
+  GtkWidget *itembar;
+
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
+  panel_return_if_fail (PANEL_IS_WINDOW (window));
+
+  /* get the itembar */
+  itembar = gtk_bin_get_child (GTK_BIN (window));
+
+  /* set new expand mode */
+  panel_itembar_set_child_expand (PANEL_ITEMBAR (itembar), plugin, expand);
+}
+
+
+
+static void
+panel_application_plugin_move_end (GtkWidget        *item,
+                                   GdkDragContext   *context,
+                                   PanelApplication *application)
+{
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (item));
+  panel_return_if_fail (PANEL_IS_APPLICATION (application));
+
+  /* disconnect this signal */
+  g_signal_handlers_disconnect_by_func (G_OBJECT (item), G_CALLBACK (panel_application_plugin_move_end), application);
+
+  /* make the window insensitive */
+  panel_application_windows_sensitive (application, TRUE);
+}
+
+
+
+static void
+panel_application_plugin_move (GtkWidget        *item,
+                               PanelApplication *application)
+{
+  GdkEvent      *event;
+  GtkTargetList *target_list;
+
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (item));
+  panel_return_if_fail (PANEL_IS_APPLICATION (application));
+
+  /* get a copy of the current event */
+  event = gtk_get_current_event ();
+  if (G_LIKELY (event))
+    {
+      /* make the window insensitive */
+      panel_application_windows_sensitive (application, FALSE);
+
+      /* create a target list */
+      target_list = gtk_target_list_new (drag_targets, G_N_ELEMENTS (drag_targets));
+
+      /* begin a drag */
+      gtk_drag_begin (item, target_list, GDK_ACTION_MOVE, 1, event);
+
+      /* release the drag list */
+      gtk_target_list_unref (target_list);
+
+      /* free the event */
+      gdk_event_free (event);
+
+      /* signal to make the window sensitive again on a drag end */
+      g_signal_connect (G_OBJECT (item), "drag-end", G_CALLBACK (panel_application_plugin_move_end), application);
+    }
+}
+
+
+
+static gboolean
+panel_application_plugin_insert (PanelApplication  *application,
+                                 PanelWindow       *window,
+                                 GdkScreen         *screen,
+                                 const gchar       *name,
+                                 const gchar       *id,
+                                 gchar            **arguments,
+                                 gint               position)
+{
+  GtkWidget               *itembar;
+  gboolean                 succeed = FALSE;
+  XfcePanelPluginProvider *provider;
+
+  panel_return_val_if_fail (PANEL_IS_APPLICATION (application), FALSE);
+  panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
+  panel_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
+  panel_return_val_if_fail (name != NULL, FALSE);
+
+  /* create a new unique id if needed */
+  if (id == NULL)
+    id = panel_application_get_unique_id ();
+
+  /* create a new panel plugin */
+  provider = panel_module_factory_create_plugin (application->factory, screen, name, id, arguments);
+
+  if (G_LIKELY (provider != NULL))
+    {
+      /* get the panel itembar */
+      itembar = gtk_bin_get_child (GTK_BIN (window));
+
+      g_signal_connect (G_OBJECT (provider), "expand-changed", G_CALLBACK (panel_application_plugin_expand), window);
+      g_signal_connect (G_OBJECT (provider), "move-item", G_CALLBACK (panel_application_plugin_move), application);
+      g_signal_connect (G_OBJECT (provider), "add-new-items", G_CALLBACK (panel_item_dialog_show), NULL);
+      g_signal_connect_swapped (G_OBJECT (provider), "panel-preferences", G_CALLBACK (panel_preferences_dialog_show), window);
+
+      /* add the item to the panel */
+      panel_itembar_insert (PANEL_ITEMBAR (itembar), GTK_WIDGET (provider), position);
+
+      /* send all the needed info about the panel to the plugin */
+      panel_glue_set_provider_info (provider);
+
+      /* show the plugin */
+      gtk_widget_show (GTK_WIDGET (provider));
+
+      /* we've succeeded */
+      succeed = TRUE;
+    }
+
+  return succeed;
+}
+
+
+
 static gboolean
 panel_application_save_timeout (gpointer user_data)
 {
@@ -756,6 +806,135 @@ panel_application_dialog_destroyed (GtkWindow        *dialog,
 
 
 
+static void
+panel_application_drag_data_received (GtkWidget        *itembar,
+                                      GdkDragContext   *context,
+                                      gint              x,
+                                      gint              y,
+                                      GtkSelectionData *selection_data,
+                                      guint             info,
+                                      guint             time,
+                                      PanelWindow      *window)
+{
+  guint             position;
+  PanelApplication *application;
+  GtkWidget        *provider;
+  gboolean          succeed = FALSE;
+  GdkScreen        *screen;
+  const gchar      *name;
+  guint             old_position;
+
+  panel_return_if_fail (PANEL_IS_ITEMBAR (itembar));
+  panel_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+  panel_return_if_fail (PANEL_IS_WINDOW (window));
+
+  /* get the application */
+  application = panel_application_get ();
+
+  /* get the drop index on the itembar */
+  position = panel_itembar_get_drop_index (PANEL_ITEMBAR (itembar), x, y);
+
+  /* get the widget screen */
+  screen = gtk_widget_get_screen (itembar);
+
+  switch (info)
+    {
+      case PANEL_ITEMBAR_TARGET_PLUGIN_NAME:
+        if (G_LIKELY (selection_data->length > 0))
+          {
+            /* get the name from the selection data */
+            name = (const gchar *) selection_data->data;
+
+            /* create a new item with a unique id */
+            succeed = panel_application_plugin_insert (application, window, screen, name,
+                                                       NULL, NULL, position);
+          }
+        break;
+
+      case PANEL_ITEMBAR_TARGET_PLUGIN_WIDGET:
+        /* get the source widget */
+        provider = gtk_drag_get_source_widget (context);
+
+        /* debug check */
+        panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+        /* check if we move to another itembar */
+        if (gtk_widget_get_parent (provider) == itembar)
+          {
+            /* get the current position on the itembar */
+            old_position = panel_itembar_get_child_index (PANEL_ITEMBAR (itembar), provider);
+
+            /* decrease the counter if we drop after the current position */
+            if (position > old_position)
+              position--;
+
+            /* reorder the child if needed */
+            if (old_position != position)
+              panel_itembar_reorder_child (PANEL_ITEMBAR (itembar), provider, position);
+          }
+        else
+          {
+            /* reparent the widget, this will also call remove and add for the itembar */
+            gtk_widget_reparent (provider, itembar);
+
+            /* move the item to the correct position on the itembar */
+            panel_itembar_reorder_child (PANEL_ITEMBAR (itembar), provider, position);
+
+            /* send all the needed panel information to the plugin */
+            panel_glue_set_provider_info (XFCE_PANEL_PLUGIN_PROVIDER (provider));
+          }
+
+        /* everything went fine */
+        succeed = TRUE;
+        break;
+
+      default:
+        panel_assert_not_reached ();
+        break;
+    }
+
+  /* save the panel configuration if we succeeded */
+  if (G_LIKELY (succeed))
+    panel_application_save (application);
+
+  /* release the application */
+  g_object_unref (G_OBJECT (application));
+
+  /* tell the peer that we handled the drop */
+  gtk_drag_finish (context, succeed, FALSE, time);
+}
+
+
+
+static gboolean
+panel_application_drag_drop (GtkWidget      *itembar,
+                             GdkDragContext *context,
+                             gint            x,
+                             gint            y,
+                             guint           time,
+                             PanelWindow    *window)
+{
+  GdkAtom target;
+
+  panel_return_val_if_fail (PANEL_IS_ITEMBAR (itembar), FALSE);
+  panel_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
+  panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
+
+  target = gtk_drag_dest_find_target (itembar, context, NULL);
+
+  /* we cannot handle the drag data */
+  if (G_UNLIKELY (target == GDK_NONE))
+    return FALSE;
+
+  /* request the drag data */
+  gtk_drag_get_data (itembar, context, target, time);
+
+  /* we call gtk_drag_finish later */
+  return TRUE;
+}
+
+
+
 PanelApplication *
 panel_application_get (void)
 {
@@ -891,7 +1070,7 @@ panel_application_add_new_item (PanelApplication  *application,
       window = g_slist_nth_data (application->windows, nth);
 
       /* add the panel to the end of the choosen window */
-      panel_application_insert_plugin (application, window, gtk_widget_get_screen (GTK_WIDGET (window)),
+      panel_application_plugin_insert (application, window, gtk_widget_get_screen (GTK_WIDGET (window)),
                                        plugin_name, NULL, arguments, -1);
     }
   else
@@ -903,139 +1082,6 @@ panel_application_add_new_item (PanelApplication  *application,
 
 
 
-static void
-panel_application_drag_data_received (GtkWidget        *itembar,
-                                      GdkDragContext   *context,
-                                      gint              x,
-                                      gint              y,
-                                      GtkSelectionData *selection_data,
-                                      guint             info,
-                                      guint             time,
-                                      PanelWindow      *window)
-{
-  guint             position;
-  PanelApplication *application;
-  GtkWidget        *provider;
-  gboolean          succeed = FALSE;
-  GdkScreen        *screen;
-  const gchar      *name;
-  guint             old_position;
-
-  panel_return_if_fail (PANEL_IS_ITEMBAR (itembar));
-  panel_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
-  panel_return_if_fail (PANEL_IS_WINDOW (window));
-
-  /* get the application */
-  application = panel_application_get ();
-
-  /* get the drop index on the itembar */
-  position = panel_itembar_get_drop_index (PANEL_ITEMBAR (itembar), x, y);
-
-  /* get the widget screen */
-  screen = gtk_widget_get_screen (itembar);
-
-  switch (info)
-    {
-      case PANEL_ITEMBAR_TARGET_PLUGIN_NAME:
-        if (G_LIKELY (selection_data->length > 0))
-          {
-            /* get the name from the selection data */
-            name = (const gchar *) selection_data->data;
-
-            /* create a new item with a unique id */
-            succeed = panel_application_insert_plugin (application, window, screen, name,
-                                                       NULL, NULL, position);
-          }
-        break;
-
-      case PANEL_ITEMBAR_TARGET_PLUGIN_WIDGET:
-        /* make the itembar sensitive again */
-        panel_application_windows_sensitive (application, TRUE);
-
-        /* get the source widget */
-        provider = gtk_drag_get_source_widget (context);
-
-        /* debug check */
-        panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
-
-        /* check if we move to another itembar */
-        if (gtk_widget_get_parent (provider) == itembar)
-          {
-            /* get the current position on the itembar */
-            old_position = panel_itembar_get_child_index (PANEL_ITEMBAR (itembar), provider);
-
-            /* decrease the counter if we drop after the current position */
-            if (position > old_position)
-              position--;
-
-            /* reorder the child if needed */
-            if (old_position != position)
-              panel_itembar_reorder_child (PANEL_ITEMBAR (itembar), provider, position);
-          }
-        else
-          {
-            /* reparent the widget, this will also call remove and add for the itembar */
-            gtk_widget_reparent (provider, itembar);
-
-            /* move the item to the correct position on the itembar */
-            panel_itembar_reorder_child (PANEL_ITEMBAR (itembar), provider, position);
-
-            /* set new panel size */
-            /* TODO: update more panel-dependent settings after a move */
-            xfce_panel_plugin_provider_set_size (XFCE_PANEL_PLUGIN_PROVIDER (provider), panel_window_get_size (window));
-          }
-
-        /* everything went fine */
-        succeed = TRUE;
-        break;
-
-      default:
-        panel_assert_not_reached ();
-        break;
-    }
-
-  /* save the panel configuration if we succeeded */
-  if (G_LIKELY (succeed))
-    panel_application_save (application);
-
-  /* release the application */
-  g_object_unref (G_OBJECT (application));
-
-  /* tell the peer that we handled the drop */
-  gtk_drag_finish (context, succeed, FALSE, time);
-}
-
-
-
-static gboolean
-panel_application_drag_drop (GtkWidget      *itembar,
-                             GdkDragContext *context,
-                             gint            x,
-                             gint            y,
-                             guint           time,
-                             PanelWindow    *window)
-{
-  GdkAtom target;
-
-  panel_return_val_if_fail (PANEL_IS_ITEMBAR (itembar), FALSE);
-  panel_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), FALSE);
-  panel_return_val_if_fail (PANEL_IS_WINDOW (window), FALSE);
-
-  target = gtk_drag_dest_find_target (itembar, context, NULL);
-
-  /* we cannot handle the drag data */
-  if (G_UNLIKELY (target == GDK_NONE))
-    return FALSE;
-
-  /* request the drag data */
-  gtk_drag_get_data (itembar, context, target, time);
-
-  /* we call gtk_drag_finish later */
-  return TRUE;
-}
-
-
-
 PanelWindow *
 panel_application_new_window (PanelApplication *application,
                               GdkScreen        *screen)
diff --git a/panel/panel-dbus-service.h b/panel/panel-dbus-service.h
index 8e8f25c..bbfab76 100644
--- a/panel/panel-dbus-service.h
+++ b/panel/panel-dbus-service.h
@@ -40,4 +40,3 @@ GObject  *panel_dbus_service_new          (void);
 G_END_DECLS
 
 #endif /* !__PANEL_DBUS_SERVICE_H__ */
-
diff --git a/panel/panel-glue.c b/panel/panel-glue.c
index 246871a..9826fe7 100644
--- a/panel/panel-glue.c
+++ b/panel/panel-glue.c
@@ -34,6 +34,8 @@
 #include <panel/panel-preferences-dialog.h>
 #include <panel/panel-dialogs.h>
 #include <panel/panel-dbus-service.h>
+#include <panel/panel-plugin-external.h>
+#include <panel/panel-window.h>
 
 
 
@@ -313,3 +315,26 @@ panel_glue_set_screen_position (PanelWindow *window)
   /* send the new size to all plugins */
   gtk_container_foreach (GTK_CONTAINER (itembar), panel_glue_set_screen_position_foreach, GINT_TO_POINTER (screen_position));
 }
+
+
+
+void
+panel_glue_set_provider_info (XfcePanelPluginProvider *provider)
+{
+  PanelWindow *window;
+
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+  panel_return_if_fail (PANEL_IS_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (provider))));
+
+  /* get the plugins panel window */
+  window = PANEL_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (provider)));
+
+  /* set the background alpha if the plugin is external */
+  if (PANEL_IS_PLUGIN_EXTERNAL (provider))
+    panel_plugin_external_set_background_alpha (PANEL_PLUGIN_EXTERNAL (provider), panel_window_get_background_alpha (window));
+
+  /* send plugin information */
+  xfce_panel_plugin_provider_set_orientation (provider, panel_window_get_orientation (window));
+  xfce_panel_plugin_provider_set_screen_position (provider, panel_glue_get_screen_position (window));
+  xfce_panel_plugin_provider_set_size (provider, panel_window_get_size (window));
+}
diff --git a/panel/panel-glue.h b/panel/panel-glue.h
index 49b549d..1347f9d 100644
--- a/panel/panel-glue.h
+++ b/panel/panel-glue.h
@@ -21,21 +21,23 @@
 #include <gtk/gtk.h>
 #include <panel/panel-window.h>
 #include <libxfce4panel/libxfce4panel.h>
+#include <libxfce4panel/xfce-panel-plugin-provider.h>
 
 G_BEGIN_DECLS
 
-void               panel_glue_popup_menu          (PanelWindow    *window);
+void               panel_glue_popup_menu          (PanelWindow             *window);
 
-XfceScreenPosition panel_glue_get_screen_position (PanelWindow    *window);
+XfceScreenPosition panel_glue_get_screen_position (PanelWindow             *window);
 
-void               panel_glue_set_size            (PanelWindow    *window,
-                                                   gint            size);
-                          
-void               panel_glue_set_orientation     (PanelWindow    *window,
-                                                   GtkOrientation  orientation);
-                                 
-void               panel_glue_set_screen_position (PanelWindow    *window);
-                                     
+void               panel_glue_set_size            (PanelWindow             *window,
+                                                   gint                     size);
+
+void               panel_glue_set_orientation     (PanelWindow             *window,
+                                                   GtkOrientation           orientation);
+
+void               panel_glue_set_screen_position (PanelWindow             *window);
+
+void               panel_glue_set_provider_info   (XfcePanelPluginProvider *provider);
 
 G_END_DECLS
 
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index 5635def..7a50f7d 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -30,6 +30,8 @@
 #include <panel/panel-private.h>
 #include <panel/panel-module.h>
 #include <panel/panel-plugin-external.h>
+#include <panel/panel-window.h>
+#include <panel/panel-glue.h>
 
 
 
@@ -337,6 +339,7 @@ panel_plugin_external_plug_removed (GtkSocket *socket)
   GtkWidget           *dialog;
   gint                 response;
   gchar               *filename, *path;
+  PanelWindow         *window;
 
   /* create dialog */
   dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (socket))),
@@ -344,14 +347,15 @@ panel_plugin_external_plug_removed (GtkSocket *socket)
                                    GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
                                    _("Plugin '%s' unexpectedly left the building, do you want to restart it?"),
                                    panel_module_get_name (external->module));
-  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("If you press Execute the panel will try"
-                                            " to restart the plugin. Remove will remove it from the panel permanently."));
+  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("If you press Execute "
+                                            "the panel will try to restart the plugin otherwise it "
+                                            "will be permanently removed from the panel."));
   gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_EXECUTE, GTK_RESPONSE_OK,
                           GTK_STOCK_REMOVE, GTK_RESPONSE_CLOSE, NULL);
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
   gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
 
-  /* don't send or queue messages */
+  /* don't queue messages */
   external->plug_window_id = -1;
 
   /* reset the pid */
@@ -370,13 +374,21 @@ panel_plugin_external_plug_removed (GtkSocket *socket)
   /* handle the response */
   if (response == GTK_RESPONSE_OK)
     {
+      /* get the plugin panel */
+      window = PANEL_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (socket)));
+
+      /* debug check */
+      panel_return_val_if_fail (PANEL_IS_WINDOW (window), TRUE);
+
+      /* queue messages again */
+      external->plug_window_id = 0;
+
+      /* send panel information to the plugin */
+      panel_glue_set_provider_info (XFCE_PANEL_PLUGIN_PROVIDER (external));
+
       /* show the socket again (realize will spawn the plugin) */
       gtk_widget_show (GTK_WIDGET (socket));
 
-      /* TODO: The plugin needs an update from the panel status (size/orientation/...) here.
-       *       This should be handled from the application (signal to plugins for panel status
-       *       on realize/show?). */
-
       /* don't process other events */
       return TRUE;
     }



More information about the Xfce4-commits mailing list