[Xfce4-commits] <xfce4-panel:devel> * Add is_active_panel to external plugins * Rename "Customize Panel" to "Panel Preferences..." * Misc small changes.

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


Updating branch refs/heads/devel
         to feeaa396d1b94b749905e2889e1bd3230a9cedf6 (commit)
       from 5b1cb8e6eccde167e6e7f1ed9865b29324a78ea5 (commit)

commit feeaa396d1b94b749905e2889e1bd3230a9cedf6
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Jun 21 00:39:23 2008 +0200

    * Add is_active_panel to external plugins
    * Rename "Customize Panel" to "Panel Preferences..."
    * Misc small changes.

 libxfce4panel/xfce-panel-plugin-provider.c |    6 +-
 libxfce4panel/xfce-panel-plugin-provider.h |    3 +-
 libxfce4panel/xfce-panel-plugin.c          |   76 +++++++++---------
 panel/panel-application.c                  |    4 +-
 panel/panel-glue.c                         |    4 +-
 panel/panel-plugin-external.c              |   23 +++++-
 panel/panel-plugin-external.h              |    2 +
 panel/panel-window.c                       |   55 ++++++++++---
 panel/panel-window.h                       |    2 +-
 wrapper/wrapper-plug.c                     |  120 +++++++++++++++++++---------
 10 files changed, 192 insertions(+), 103 deletions(-)

diff --git a/libxfce4panel/xfce-panel-plugin-provider.c b/libxfce4panel/xfce-panel-plugin-provider.c
index 44a8a6a..4e21546 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.c
+++ b/libxfce4panel/xfce-panel-plugin-provider.c
@@ -33,7 +33,7 @@ enum
   EXPAND_CHANGED,
   MOVE,
   ADD_NEW_ITEMS,
-  CUSTOMIZE_PANEL,
+  PANEL_PREFERENCES,
   LAST_SIGNAL
 };
 
@@ -107,8 +107,8 @@ xfce_panel_plugin_provider_base_init (gpointer klass)
                       g_cclosure_marshal_VOID__VOID,
                       G_TYPE_NONE, 0);
 
-      provider_signals[CUSTOMIZE_PANEL] =
-        g_signal_new (I_("customize-panel"),
+      provider_signals[PANEL_PREFERENCES] =
+        g_signal_new (I_("panel-preferences"),
                       G_TYPE_FROM_CLASS (klass),
                       G_SIGNAL_RUN_LAST,
                       0, NULL, NULL,
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index 286d396..e31e56e 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -40,13 +40,14 @@ enum _XfcePanelPluginMessage
   MESSAGE_EXPAND_CHANGED,
   MESSAGE_MOVE_ITEM,
   MESSAGE_ADD_NEW_ITEMS,
-  MESSAGE_CUSTOMIZE_PANEL,
+  MESSAGE_PANEL_PREFERENCES,
   MESSAGE_SET_SIZE,
   MESSAGE_SET_ORIENTATION,
   MESSAGE_SET_SCREEN_POSITION,
   MESSAGE_SET_PLUG_ID,
   MESSAGE_SET_SENSITIVE,
   MESSAGE_SET_BACKGROUND_ALPHA,
+  MESSAGE_SET_ACTIVE_PANEL,
   MESSAGE_SAVE,
   MESSAGE_REMOVE,
   MESSAGE_QUIT
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index ceb2de4..cf3896a 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -34,38 +34,38 @@
 typedef const gchar *(*ProviderToPlugin) (XfcePanelPluginProvider *provider);
 
 
-static void         xfce_panel_plugin_class_init           (XfcePanelPluginClass         *klass);
-static void         xfce_panel_plugin_init                 (XfcePanelPlugin              *plugin);
-static void         xfce_panel_plugin_provider_init        (XfcePanelPluginProviderIface *iface);
-static void         xfce_panel_plugin_get_property         (GObject                      *object,
-                                                            guint                         prop_id,
-                                                            GValue                       *value,
-                                                            GParamSpec                   *pspec);
-static void         xfce_panel_plugin_set_property         (GObject                      *object,
-                                                            guint                         prop_id,
-                                                            const GValue                 *value,
-                                                            GParamSpec                   *pspec);
-static void         xfce_panel_plugin_dispose              (GObject                      *object);
-static void         xfce_panel_plugin_finalize             (GObject                      *object);
-static gboolean     xfce_panel_plugin_button_press_event   (GtkWidget                    *widget,
-                                                            GdkEventButton               *event);
-static void         xfce_panel_plugin_menu_properties      (XfcePanelPlugin              *plugin);
-static void         xfce_panel_plugin_menu_about           (XfcePanelPlugin              *plugin);
-static void         xfce_panel_plugin_menu_move            (XfcePanelPlugin              *plugin);
-static void         xfce_panel_plugin_menu_remove          (XfcePanelPlugin              *plugin);
-static void         xfce_panel_plugin_menu_add_items       (XfcePanelPlugin              *plugin);
-static void         xfce_panel_plugin_menu_customize_panel (XfcePanelPlugin              *plugin);
-static GtkWidget   *xfce_panel_plugin_menu_new             (XfcePanelPlugin              *plugin);
-static gchar       *xfce_panel_plugin_relative_filename    (XfcePanelPlugin              *plugin);
-static void         xfce_panel_plugin_set_size             (XfcePanelPluginProvider      *provider,
-                                                            gint                          size);
-static void         xfce_panel_plugin_set_orientation      (XfcePanelPluginProvider      *provider,
-                                                            GtkOrientation                orientation);
-static void         xfce_panel_plugin_set_screen_position  (XfcePanelPluginProvider      *provider,
-                                                            XfceScreenPosition            screen_position);
-static void         xfce_panel_plugin_save                 (XfcePanelPluginProvider      *provider);
-static void         xfce_panel_plugin_take_window_notify   (gpointer                      data,
-                                                            GObject                      *where_the_object_was);
+static void         xfce_panel_plugin_class_init             (XfcePanelPluginClass         *klass);
+static void         xfce_panel_plugin_init                   (XfcePanelPlugin              *plugin);
+static void         xfce_panel_plugin_provider_init          (XfcePanelPluginProviderIface *iface);
+static void         xfce_panel_plugin_get_property           (GObject                      *object,
+                                                              guint                         prop_id,
+                                                              GValue                       *value,
+                                                              GParamSpec                   *pspec);
+static void         xfce_panel_plugin_set_property           (GObject                      *object,
+                                                              guint                         prop_id,
+                                                              const GValue                 *value,
+                                                              GParamSpec                   *pspec);
+static void         xfce_panel_plugin_dispose                (GObject                      *object);
+static void         xfce_panel_plugin_finalize               (GObject                      *object);
+static gboolean     xfce_panel_plugin_button_press_event     (GtkWidget                    *widget,
+                                                              GdkEventButton               *event);
+static void         xfce_panel_plugin_menu_properties        (XfcePanelPlugin              *plugin);
+static void         xfce_panel_plugin_menu_about             (XfcePanelPlugin              *plugin);
+static void         xfce_panel_plugin_menu_move              (XfcePanelPlugin              *plugin);
+static void         xfce_panel_plugin_menu_remove            (XfcePanelPlugin              *plugin);
+static void         xfce_panel_plugin_menu_add_items         (XfcePanelPlugin              *plugin);
+static void         xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin              *plugin);
+static GtkWidget   *xfce_panel_plugin_menu_new               (XfcePanelPlugin              *plugin);
+static gchar       *xfce_panel_plugin_relative_filename      (XfcePanelPlugin              *plugin);
+static void         xfce_panel_plugin_set_size               (XfcePanelPluginProvider      *provider,
+                                                              gint                          size);
+static void         xfce_panel_plugin_set_orientation        (XfcePanelPluginProvider      *provider,
+                                                              GtkOrientation                orientation);
+static void         xfce_panel_plugin_set_screen_position    (XfcePanelPluginProvider      *provider,
+                                                              XfceScreenPosition            screen_position);
+static void         xfce_panel_plugin_save                   (XfcePanelPluginProvider      *provider);
+static void         xfce_panel_plugin_take_window_notify     (gpointer                      data,
+                                                              GObject                      *where_the_object_was);
 
 
 
@@ -622,13 +622,13 @@ xfce_panel_plugin_menu_add_items (XfcePanelPlugin *plugin)
 
 
 static void
-xfce_panel_plugin_menu_customize_panel (XfcePanelPlugin *plugin)
+xfce_panel_plugin_menu_panel_preferences (XfcePanelPlugin *plugin)
 {
   panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
   panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (plugin));
 
-  /* emit customize-panel signal */
-  g_signal_emit_by_name (G_OBJECT (plugin), "customize-panel", 0);
+  /* emit panel-preferences signal */
+  g_signal_emit_by_name (G_OBJECT (plugin), "panel-preferences", 0);
 }
 
 
@@ -698,7 +698,7 @@ xfce_panel_plugin_menu_new (XfcePanelPlugin *plugin)
   gtk_widget_show (item);
 
   /* add new items */
-  item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items"));
+  item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items..."));
   g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_add_items), plugin);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
   gtk_widget_show (item);
@@ -708,8 +708,8 @@ xfce_panel_plugin_menu_new (XfcePanelPlugin *plugin)
   gtk_widget_show (image);
 
   /* customize panel */
-  item = gtk_image_menu_item_new_with_mnemonic (_("_Customize Panels"));
-  g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_customize_panel), plugin);
+  item = gtk_image_menu_item_new_with_mnemonic (_("Panel Pr_eferences..."));
+  g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (xfce_panel_plugin_menu_panel_preferences), plugin);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
   gtk_widget_show (item);
 
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 178f976..0d8c2e2 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -433,7 +433,7 @@ panel_application_insert_plugin (PanelApplication  *application,
       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), "customize-panel", G_CALLBACK (panel_preferences_dialog_show), 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);
 
@@ -1131,7 +1131,7 @@ panel_application_window_select (PanelApplication *application,
 
   /* update state for all windows */
   for (li = application->windows; li != NULL; li = li->next)
-    panel_window_set_selected (PANEL_WINDOW (li->data), !!(li->data == window));
+    panel_window_set_active_panel (PANEL_WINDOW (li->data), !!(li->data == window));
 }
 
 
diff --git a/panel/panel-glue.c b/panel/panel-glue.c
index 935c0b4..246871a 100644
--- a/panel/panel-glue.c
+++ b/panel/panel-glue.c
@@ -98,7 +98,7 @@ panel_glue_popup_menu (PanelWindow *window)
   gtk_widget_show (item);
 
   /* add new items */
-  item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items"));
+  item = gtk_image_menu_item_new_with_mnemonic (_("Add _New Items..."));
   g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (panel_item_dialog_show), NULL);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
   gtk_widget_show (item);
@@ -108,7 +108,7 @@ panel_glue_popup_menu (PanelWindow *window)
   gtk_widget_show (image);
 
   /* customize panel */
-  item = gtk_image_menu_item_new_with_mnemonic (_("_Customize Panels"));
+  item = gtk_image_menu_item_new_with_mnemonic (_("Panel Pr_eferences..."));
   g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (panel_preferences_dialog_show), window);
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
   gtk_widget_show (item);
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index ea54df1..44bfd28 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -274,19 +274,23 @@ panel_plugin_external_client_event (GtkWidget      *widget,
       switch (message)
         {
           case MESSAGE_EXPAND_CHANGED:
+            /* emit the expand changed signal */
             g_signal_emit_by_name (G_OBJECT (external), "expand-changed", !!(value == 1));
             break;
 
           case MESSAGE_MOVE_ITEM:
+            /* start a plugin dnd */
             g_signal_emit_by_name (G_OBJECT (external), "move-item", 0);
             break;
 
           case MESSAGE_ADD_NEW_ITEMS:
+            /* show the add new items dialog */
             g_signal_emit_by_name (G_OBJECT (external), "add-new-items", 0);
             break;
 
-          case MESSAGE_CUSTOMIZE_PANEL:
-            g_signal_emit_by_name (G_OBJECT (external), "customize-panel", 0);
+          case MESSAGE_PANEL_PREFERENCES:
+            /* show the panel preferences dialog */
+            g_signal_emit_by_name (G_OBJECT (external), "panel-preferences", 0, gtk_widget_get_toplevel (widget));
             break;
 
           case MESSAGE_REMOVE:
@@ -551,5 +555,18 @@ panel_plugin_external_set_background_alpha (PanelPluginExternal *external,
   panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (external));
 
   /* send the signal to the wrapper */
-  panel_plugin_external_send_message (PANEL_PLUGIN_EXTERNAL (external), MESSAGE_SET_BACKGROUND_ALPHA, percentage);
+  panel_plugin_external_send_message (external, MESSAGE_SET_BACKGROUND_ALPHA, percentage);
+}
+
+
+
+void
+panel_plugin_external_set_active_panel (PanelPluginExternal *external,
+                                        gboolean             active)
+{
+  panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (external));
+
+  /* send the signal to the wrapper */
+  panel_plugin_external_send_message (external, MESSAGE_SET_ACTIVE_PANEL, active ? 1 : 0);
 }
diff --git a/panel/panel-plugin-external.h b/panel/panel-plugin-external.h
index db93aef..0f17d3d 100644
--- a/panel/panel-plugin-external.h
+++ b/panel/panel-plugin-external.h
@@ -41,6 +41,8 @@ XfcePanelPluginProvider *panel_plugin_external_new (PanelModule *module, const g
 
 void panel_plugin_external_set_background_alpha (PanelPluginExternal *external, gint percentage);
 
+void panel_plugin_external_set_active_panel (PanelPluginExternal *external, gboolean active);
+
 G_END_DECLS
 
 #endif /* !__PANEL_PLUGIN_EXTERNAL_H__ */
diff --git a/panel/panel-window.c b/panel/panel-window.c
index b705278..06edc2e 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -142,8 +142,8 @@ struct _PanelWindow
   /* whether the panel is locked */
   guint                locked : 1;
 
-  /* when the panel is 'selected' */
-  guint                selected : 1;
+  /* when this is the active panel */
+  guint                is_active_panel : 1;
 
   /* panel orientation */
   guint                horizontal;
@@ -257,7 +257,7 @@ panel_window_init (PanelWindow *window)
   window->autohide_status = DISABLED;
   window->autohide_block = 0;
   window->autohide_window = NULL;
-  window->selected = FALSE;
+  window->is_active_panel = FALSE;
 
   /* set additional events we want to have */
   gtk_widget_add_events (GTK_WIDGET (window), GDK_BUTTON_PRESS_MASK);
@@ -347,17 +347,17 @@ panel_window_expose_event (GtkWidget      *widget,
       cr = gdk_cairo_create (widget->window);
 
       /* use another state when the panel is selected */
-      if (G_UNLIKELY (window->selected))
+      if (G_UNLIKELY (window->is_active_panel))
         state = GTK_STATE_SELECTED;
 
-      if (window->selected ||
+      if (window->is_active_panel ||
           (window->is_composited && window->background_alpha < 1.00))
         {
           /* get the background gdk color */
           color = &(widget->style->bg[state]);
 
           /* set the cairo source color */
-          _set_source_rgba (cr, color, window->selected ? 1.00 : window->background_alpha);
+          _set_source_rgba (cr, color, window->background_alpha);
 
           /* create retangle */
           cairo_rectangle (cr, event->area.x, event->area.y,
@@ -1013,7 +1013,13 @@ panel_window_paint_handle (PanelWindow  *window,
   gint           x, y, width, height;
   gint           i, xx, yy;
   GdkColor      *color;
-  gdouble        alpha = window->is_composited ? window->background_alpha : 1.00;
+  gdouble        alpha;
+
+  /* set the alpha (always show to handle for atleast 50%) */
+  if (window->is_composited)
+    alpha = 0.50 + window->background_alpha / 2.00;
+  else
+    alpha = 1.00;
 
   /* set initial numbers */
   x = alloc->x + 2;
@@ -1077,7 +1083,7 @@ panel_window_paint_border (PanelWindow  *window,
   gdouble        alpha = window->is_composited ? window->background_alpha : 1.00;
 
   /* 1px line */
-  cairo_set_line_width (cr, 1.0);
+  cairo_set_line_width (cr, 2.0);
 
   /* dark color */
   color = &(widget->style->dark[state]);
@@ -1108,7 +1114,7 @@ panel_window_paint_border (PanelWindow  *window,
   /* top line */
   cairo_rel_line_to (cr, alloc->width, 0);
 
-  /* stroke this part */
+  /* stroke the lines */
   cairo_stroke (cr);
 }
 
@@ -1551,19 +1557,40 @@ panel_window_is_composited (PanelWindow *window)
 
 
 
+static void
+panel_window_plugin_set_active_panel (GtkWidget *widget,
+                                      gpointer   user_data)
+{
+  panel_return_if_fail (PANEL_IS_WINDOW (user_data));
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget));
+
+  if (PANEL_IS_PLUGIN_EXTERNAL (widget))
+    panel_plugin_external_set_active_panel (PANEL_PLUGIN_EXTERNAL (widget), PANEL_WINDOW (user_data)->is_active_panel);
+}
+
+
+
 void
-panel_window_set_selected (PanelWindow *window,
-                           gboolean     selected)
+panel_window_set_active_panel (PanelWindow *window,
+                               gboolean     active)
 {
+  GtkWidget *itembar;
+
   panel_return_if_fail (PANEL_IS_WINDOW (window));
 
-  if (G_UNLIKELY (window->selected != selected))
+  if (G_UNLIKELY (window->is_active_panel != active))
     {
       /* set new value */
-      window->selected = selected;
+      window->is_active_panel = !!active;
 
       /* queue a redraw */
       gtk_widget_queue_draw (GTK_WIDGET (window));
+
+      /* get the itembar */
+      itembar = gtk_bin_get_child (GTK_BIN (window));
+
+      /* poke all the plugins */
+      gtk_container_foreach (GTK_CONTAINER (itembar), panel_window_plugin_set_active_panel, window);
     }
 }
 
@@ -2010,7 +2037,7 @@ panel_window_set_span_monitors (PanelWindow *window,
 
   if (window->span_monitors != span_monitors)
     {
-      window->span_monitors = span_monitors;
+      window->span_monitors = !!span_monitors;
 
       gtk_widget_queue_resize (GTK_WIDGET (window));
     }
diff --git a/panel/panel-window.h b/panel/panel-window.h
index f5d5736..3698650 100644
--- a/panel/panel-window.h
+++ b/panel/panel-window.h
@@ -75,7 +75,7 @@ GtkWidget           *panel_window_new                   (void);
 
 gboolean             panel_window_is_composited         (PanelWindow         *window);
 
-void                 panel_window_set_selected          (PanelWindow         *window,
+void                 panel_window_set_active_panel      (PanelWindow         *window,
                                                          gboolean             selected);
 
 PanelWindowSnapEdge  panel_window_get_snap_edge         (PanelWindow         *window);
diff --git a/wrapper/wrapper-plug.c b/wrapper/wrapper-plug.c
index b9ddef8..ad342b6 100644
--- a/wrapper/wrapper-plug.c
+++ b/wrapper/wrapper-plug.c
@@ -56,6 +56,9 @@ struct _WrapperPlug
 
   /* background alpha */
   gdouble                  background_alpha;
+
+  /* if this plugin is on an active panel */
+  guint                    is_active_panel : 1;
 };
 
 
@@ -68,54 +71,84 @@ static gboolean
 wrapper_plug_expose_event (GtkWidget      *widget,
                            GdkEventExpose *event)
 {
-  WrapperPlug *plug = WRAPPER_PLUG (widget);
-  cairo_t     *cr;
-  GdkColor    *color;
-
-  if (GTK_WIDGET_DRAWABLE (widget) && plug->background_alpha < 1.00)
+  WrapperPlug    *plug = WRAPPER_PLUG (widget);
+  cairo_t        *cr;
+  GdkColor       *color;
+  GtkStateType    state = GTK_STATE_NORMAL;
+  GtkOrientation  orientation;
+  GtkAllocation  *alloc = &(widget->allocation);
+  gdouble         alpha = plug->background_alpha;
+
+  if (GTK_WIDGET_DRAWABLE (widget))
     {
       /* create the cairo context */
       cr = gdk_cairo_create (widget->window);
 
-      /* get the background gdk color */
-      color = &(widget->style->bg[GTK_STATE_NORMAL]);
+      if (alpha < 1.00 || plug->is_active_panel)
+        {
+          /* change the state is this plugin is on an active panel */
+          if (G_UNLIKELY (plug->is_active_panel))
+            state = GTK_STATE_SELECTED;
+
+          /* get the background gdk color */
+          color = &(widget->style->bg[state]);
+
+          /* set the cairo source color */
+          _set_source_rgba (cr, color, alpha);
+
+          /* create retangle */
+          cairo_rectangle (cr, event->area.x, event->area.y,
+                           event->area.width, event->area.height);
+
+          /* draw on source */
+          cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+
+          /* paint rectangle */
+          cairo_fill (cr);
+        }
+
+      /* 1px line */
+      cairo_set_line_width (cr, 2.0);
+
+      /* get the plugin orientation */
+      orientation = xfce_panel_plugin_get_orientation (XFCE_PANEL_PLUGIN (plug->provider));
 
-      /* set the cairo source color */
-      _set_source_rgba (cr, color, plug->background_alpha);
+      /* dark color */
+      color = &(widget->style->light[state]);
+      _set_source_rgba (cr, color, alpha);
 
-      /* create retangle */
-      cairo_rectangle (cr, event->area.x, event->area.y,
-                       event->area.width, event->area.height);
+      /* move the cursor to the top left corner */
+      cairo_move_to (cr, alloc->x, alloc->y);
 
-      /* draw on source */
-      cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+      /* draw the light line */
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        cairo_rel_line_to (cr, alloc->width, 0);
+      else
+        cairo_rel_line_to (cr, 0, alloc->height);
 
-      /* paint rectangle */
-      cairo_fill (cr);
+      /* stroke the lines */
+      cairo_stroke (cr);
+
+      /* light color */
+      color = &(widget->style->dark[state]);
+      _set_source_rgba (cr, color, alpha);
+
+      /* set start position to bottom right */
+      cairo_move_to (cr, alloc->x + alloc->width, alloc->y + alloc->height);
+
+      /* draw the dark line */
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        cairo_rel_line_to (cr, -alloc->width, 0);
+      else
+        cairo_rel_line_to (cr, 0, -alloc->height);
+
+      /* stroke the lines */
+      cairo_stroke (cr);
 
       /* destroy cairo context */
       cairo_destroy (cr);
     }
 
-
-  //~ cairo_rectangle (cr, event->area.x,
-                   //~ event->area.y,
-                   //~ event->area.width,
-                   //~ event->area.height);
-  //~ cairo_clip (cr);
-//~
-  //~ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
-//~
-  //~ style = gtk_widget_get_style (widget);
-  //~ r = (double) style->bg[widget->state].red / (double) 65535;
-  //~ g = (double) style->bg[widget->state].green / (double) 65535;
-  //~ b = (double) style->bg[widget->state].blue / (double) 65535;
-  //~ cairo_set_source_rgba (cr, r, g, b, 0.50);
-  //~ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
-  //~ cairo_paint (cr);
-//~
-  //~ cairo_destroy (cr);
-
     return GTK_WIDGET_CLASS(wrapper_plug_parent_class)->expose_event(widget, event);
 }
 
@@ -143,6 +176,7 @@ wrapper_plug_init (WrapperPlug *plug)
   plug->socket_id = 0;
   plug->atom = panel_atom_intern ("XFCE_PANEL_PLUGIN");
   plug->background_alpha = 1.00;
+  plug->is_active_panel = FALSE;
 
   GdkScreen   *screen;
   GdkColormap *colormap;
@@ -222,6 +256,14 @@ wrapper_plug_client_event (GtkWidget      *widget,
             gtk_widget_queue_draw (widget);
             break;
 
+          case MESSAGE_SET_ACTIVE_PANEL:
+            /* set if this plugin is on an active panel */
+            plug->is_active_panel = !!(value == 1);
+
+            /* redraw the window */
+            gtk_widget_queue_draw (widget);
+            break;
+
           case MESSAGE_SAVE:
             /* save the plugin */
             xfce_panel_plugin_provider_save (plug->provider);
@@ -331,14 +373,14 @@ wrapper_plug_message_add_new_items (XfcePanelPluginProvider *provider,
 
 
 static void
-wrapper_plug_message_customize_panel (XfcePanelPluginProvider *provider,
-                                      WrapperPlug             *plug)
+wrapper_plug_message_panel_preferences (XfcePanelPluginProvider *provider,
+                                        WrapperPlug             *plug)
 {
   panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
   panel_return_if_fail (WRAPPER_IS_PLUG (plug));
 
   /* send signal */
-  wrapper_plug_send_message (plug, MESSAGE_CUSTOMIZE_PANEL, 0);
+  wrapper_plug_send_message (plug, MESSAGE_PANEL_PREFERENCES, 0);
 }
 
 
@@ -379,7 +421,7 @@ wrapper_plug_new (GdkNativeWindow          socket_id,
   g_signal_connect (G_OBJECT (provider), "expand-changed", G_CALLBACK (wrapper_plug_message_expand_changed), plug);
   g_signal_connect (G_OBJECT (provider), "move-item", G_CALLBACK (wrapper_plug_message_move_item), plug);
   g_signal_connect (G_OBJECT (provider), "add-new-items", G_CALLBACK (wrapper_plug_message_add_new_items), plug);
-  g_signal_connect (G_OBJECT (provider), "customize-panel", G_CALLBACK (wrapper_plug_message_customize_panel), plug);
+  g_signal_connect (G_OBJECT (provider), "panel-preferences", G_CALLBACK (wrapper_plug_message_panel_preferences), plug);
   g_signal_connect (G_OBJECT (provider), "destroy", G_CALLBACK (wrapper_plug_message_remove), plug);
 
   /* contruct the plug */



More information about the Xfce4-commits mailing list