[Xfce4-commits] r26115 - in xfce4-panel/trunk: . libxfce4panel plugins/launcher plugins/windowlist

Jasper Huijsmans jasper at xfce.org
Fri Sep 28 13:46:45 CEST 2007


Author: jasper
Date: 2007-09-28 11:46:45 +0000 (Fri, 28 Sep 2007)
New Revision: 26115

Modified:
   xfce4-panel/trunk/ChangeLog
   xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c
   xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.h
   xfce4-panel/trunk/plugins/launcher/launcher.c
   xfce4-panel/trunk/plugins/windowlist/windowlist.c
Log:
Add convenience functions for 
plugin popup menus and adjust launcher and windowlist to make
use of the new functionality. Patches by Diego Ongaro.

Modified: xfce4-panel/trunk/ChangeLog
===================================================================
--- xfce4-panel/trunk/ChangeLog	2007-09-28 11:11:47 UTC (rev 26114)
+++ xfce4-panel/trunk/ChangeLog	2007-09-28 11:46:45 UTC (rev 26115)
@@ -1,3 +1,11 @@
+2007-09-28 13:46 jasper
+	* libxfce4panel/xfce-panel-plugin-iface.c,
+	  libxfce4panel/xfce-panel-plugin-iface.h,
+	  plugins/launcher/launcher.c,
+	  plugins/windowlist/windowlist.c: Add convenience functions for 
+	  plugin popup menus and adjust launcher and windowlist to make
+	  use of the new functionality. Patches by Diego Ongaro.
+
 2007-07-09 22:45 nick
 
     * libxfce4panel/*, docs/API/*: Remove the html and xml directories,

Modified: xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c
===================================================================
--- xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c	2007-09-28 11:11:47 UTC (rev 26114)
+++ xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c	2007-09-28 11:46:45 UTC (rev 26115)
@@ -1259,7 +1259,269 @@
                                 GINT_TO_POINTER (sensitive));
 }
 
+/* user menus & popups */
 
+/**
+ * xfce_panel_plugin_position_popup
+ * @plugin        : an #XfcePanelPlugin
+ * @attach_widget : a #GtkWidget associated with the menu/popup
+ * @req           : a #GtkRequisition for the menu/popup
+ * @x             : a pointer for the x position, or NULL
+ * @y             : a pointer for the y position, or NULL
+ *
+ * This function positions a menu or small popup along the edge of
+ *  attach_widget, usually a button on the panel.
+ *
+ * @attach_widget needs to have its x and y coordinates already set.
+ *
+ * If you are not interested in the actual position but desire the returned
+ *  direction only, you may set @x and @y to be NULL.
+ *
+ * If you don't know how large your menu or popup will be, you should use
+ *  xfce_panel_plugin_popup_direction() instead.
+ *
+ * See also: xfce_panel_plugin_menu_popup()
+ *
+ * Returns: The direction in which a menu will be opened relative to the
+ *          attached widget or GTK_ARROW_NONE. 
+ *          If the return value is GTK_ARROW_NONE, the values in x and y 
+ *          should not be used.
+ **/
+GtkArrowType
+xfce_panel_plugin_position_popup (XfcePanelPlugin *plugin,
+                                  GtkWidget       *attach_widget,
+                                  GtkRequisition  *req,
+                                  gint            *x, 
+                                  gint            *y)
+{
+    GtkArrowType    direction = GTK_ARROW_NONE;
+    GtkAllocation  *attach;
+    GdkScreen      *screen;
+    GdkRectangle    geom;
+    gint            trash_x;
+    gint            trash_y;
+    gint            num;
 
+    g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), GTK_ARROW_NONE);
+    g_return_val_if_fail (GTK_IS_WIDGET (attach_widget), GTK_ARROW_NONE);
+
+    if (x == NULL)
+        x = &trash_x;
+    if (y == NULL)
+        y = &trash_y;
+
+    attach = &attach_widget->allocation;
+
+    gdk_window_get_origin (attach_widget->window, x, y);
+    g_return_val_if_fail (*x > 0 && *y > 0, GTK_ARROW_NONE);
+
+    screen = gtk_widget_get_screen (attach_widget);
+    num = gdk_screen_get_monitor_at_window (screen, attach_widget->window);
+    gdk_screen_get_monitor_geometry (screen, num, &geom);
+
+    switch (xfce_panel_plugin_get_orientation (plugin))
+    {
+        case GTK_ORIENTATION_HORIZONTAL:
+
+            if (*y + attach->height + req->height > geom.height)
+            {
+                /* Position above */
+                *y -= req->height;
+                direction = GTK_ARROW_UP;
+            }
+            else
+            {
+                /* Position below */
+                *y += attach->height;
+                direction = GTK_ARROW_DOWN;
+            }
+            break;
+
+        case GTK_ORIENTATION_VERTICAL:
+
+            if (*x + attach->width + req->width > geom.width)
+            {
+                /* Position on right */
+                *x -= req->width;
+                direction = GTK_ARROW_RIGHT;
+            }
+            else
+            {
+                /* Position on left */
+                *x += attach->width;
+                direction = GTK_ARROW_LEFT;
+            }
+            break;
+
+        default:
+            break;
+    }
+
+    /* keep inside the screen */
+    if (*x > geom.x + geom.width - req->width)
+        *x = geom.x + geom.width - req->width;
+    if (*x < geom.x)
+        *x = geom.x;
+
+    if (*y > geom.y + geom.height - req->height)
+        *y = geom.y + geom.height - req->height;
+    if (*y < geom.y)
+        *y = geom.y;
+
+    return direction;
+}
+
+/**
+ * xfce_panel_plugin_popup_direction
+ * @plugin        : an #XfcePanelPlugin
+ * @attach_widget : a #GtkWidget associated with the menu/popup
+ *
+ * This function tries to guess which direction a menu or small popup will be
+ *  opened. It can be used, for example, to initialize the direction of an 
+ *  arrow button before its associated menu has been built.
+ *
+ * @attach_widget needs to have its x and y coordinates already set.
+ *
+ * If you know how large your menu or popup will be, you should use
+ *  xfce_panel_plugin_position_popup() instead.
+ *
+ * See also: xfce_panel_plugin_position_popup()
+ *
+ * Returns: The direction in which a popup will probably be opened relative to
+ *          the attached widget, or GTK_ARROW_NONE.
+ **/
+GtkArrowType
+xfce_panel_plugin_popup_direction (XfcePanelPlugin *plugin,
+                                   GtkWidget       *attach_widget)
+{
+    GtkArrowType    direction;
+    GtkRequisition  req;
+
+    /* these values are fairly arbitrary, but consistency is what matters most */
+    req.width  = 100;
+    req.height = 200;
+
+    direction = xfce_panel_plugin_position_popup (plugin,
+                                                  attach_widget,
+                                                  &req,
+                                                  NULL, NULL);
+
+    return direction;
+}
+
+#define GTK_ARROW_TYPE_TO_POINTER(a) ((gpointer) (((gint) a)+1))
+#define POINTER_IS_GTK_ARROW_TYPE(a) (a != NULL && (gint) a < 10 && (gint) a > 0)
+#define POINTER_TO_GTK_ARROW_TYPE(a) ((GtkArrowType) (((gint) a)-1))
+
+static void
+_plugin_user_menu_position (GtkMenu         *menu,
+                            gint            *x, 
+                            gint            *y,
+                            gboolean        *push_in,
+                            XfcePanelPlugin *plugin)
+{
+    GtkRequisition  req;
+    GtkWidget      *attach_widget;
+    GtkArrowType    direction = GTK_ARROW_NONE;
+
+    g_return_if_fail (GTK_IS_MENU (menu));
+    g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+
+    attach_widget = gtk_menu_get_attach_widget (menu);
+    g_return_if_fail (GTK_IS_WIDGET (attach_widget));
+
+    if (!GTK_WIDGET_REALIZED (GTK_WIDGET (menu)))
+        gtk_widget_realize (GTK_WIDGET (menu));
+
+    /* NULL indicates use the attach widget's screen */
+    gtk_menu_set_screen (menu, NULL);
+
+    gtk_widget_size_request (GTK_WIDGET (menu), &req);
+
+    direction = xfce_panel_plugin_position_popup (plugin,
+                                                  attach_widget,
+                                                  &req,
+                                                  x, y);
+
+    g_object_set_data (G_OBJECT (menu),
+                       "open_direction",
+                       GTK_ARROW_TYPE_TO_POINTER (direction));
+
+    *push_in = FALSE;
+}
+
+/**
+ * xfce_panel_plugin_menu_popup
+ * @plugin : an #XfcePanelPlugin
+ * @menu   : a #GtkMenu to pop up
+ * @button : the mouse button clicked or 0
+ * @time   : time at which the activation event occurred
+ *
+ * This is a wrapper around gtk_menu_popup().
+ *
+ * It will call xfce_panel_plugin_register_menu() for you, so don't do that
+ *  again in the plugin code.
+ *
+ * If desired, set the widget associated with the menu using 
+ *  gtk_menu_attach_to_widget() before calling this function.
+ *  Setting the attach widget positions the menu along its edge.
+ *  That widget needs to have its x and y coordinates already.
+ *
+ * If you do not set the attach widget, the menu will be positioned
+ *  on your mouse cursor (GTK default behavior).
+ *
+ * See also: xfce_panel_plugin_position_popup().
+ *
+ * Returns: The direction in which the menu opened relative to the attached
+ *          widget, or GTK_ARROW_NONE.
+ **/
+GtkArrowType
+xfce_panel_plugin_menu_popup (XfcePanelPlugin *plugin, 
+                              GtkMenu         *menu,
+                              gint             button,
+                              guint32          time)
+{
+    GtkWidget *attach_widget;
+    gpointer _direction;
+
+    if (!XFCE_IS_PANEL_PLUGIN (plugin) ||
+        !GTK_IS_MENU (menu) ||
+        GTK_WIDGET_VISIBLE (menu))
+    {
+        /* we shouldn't be here */
+        return GTK_ARROW_NONE;
+    }
+
+    xfce_panel_plugin_register_menu (plugin, menu);
+
+    attach_widget = gtk_menu_get_attach_widget (menu);
+    if (GTK_IS_WIDGET (attach_widget))
+    {
+        gtk_menu_popup (menu,
+                        NULL, NULL,
+                        (GtkMenuPositionFunc) _plugin_user_menu_position,
+                        plugin,
+                        button, 
+                        time);
+
+        _direction = g_object_steal_data (G_OBJECT (menu), "open_direction");
+        if(POINTER_IS_GTK_ARROW_TYPE(_direction))
+            return POINTER_TO_GTK_ARROW_TYPE(_direction);
+        else
+            return GTK_ARROW_NONE;
+    }
+    else
+    {
+        gtk_menu_popup (menu,
+                        NULL, NULL,
+                        NULL,
+                        NULL,
+                        button, 
+                        time);
+        return GTK_ARROW_NONE;
+    }
+}
+
 #define __XFCE_PANEL_PLUGIN_IFACE_C__
 #include <libxfce4panel/libxfce4panel-aliasdef.c>
+

Modified: xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.h
===================================================================
--- xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.h	2007-09-28 11:11:47 UTC (rev 26114)
+++ xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.h	2007-09-28 11:46:45 UTC (rev 26115)
@@ -84,6 +84,8 @@
 typedef gboolean (*XfcePanelPluginCheck) (GdkScreen *screen);
 
 GType                xfce_panel_plugin_get_type             (void) G_GNUC_CONST;
+
+
 gchar               *xfce_panel_plugin_get_name             (XfcePanelPlugin  *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 gchar               *xfce_panel_plugin_get_id               (XfcePanelPlugin  *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 gchar               *xfce_panel_plugin_get_display_name     (XfcePanelPlugin  *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
@@ -93,6 +95,8 @@
                                                              gboolean          expand);
 gboolean             xfce_panel_plugin_get_expand           (XfcePanelPlugin  *plugin);
 GtkOrientation       xfce_panel_plugin_get_orientation      (XfcePanelPlugin  *plugin);
+
+
 void                 xfce_panel_plugin_add_action_widget    (XfcePanelPlugin  *plugin,
                                                              GtkWidget        *widget);
 void                 xfce_panel_plugin_menu_insert_item     (XfcePanelPlugin  *plugin,
@@ -101,11 +105,28 @@
 void                 xfce_panel_plugin_menu_show_configure  (XfcePanelPlugin  *plugin);
 void                 xfce_panel_plugin_block_menu           (XfcePanelPlugin  *plugin);
 void                 xfce_panel_plugin_unblock_menu         (XfcePanelPlugin  *plugin);
+
+
 void                 xfce_panel_plugin_register_menu        (XfcePanelPlugin  *plugin,
                                                              GtkMenu          *menu);
+GtkArrowType         xfce_panel_plugin_menu_popup           (XfcePanelPlugin  *plugin,
+                                                             GtkMenu          *menu,
+                                                             gint              button,
+                                                             guint32           time);
+GtkArrowType         xfce_panel_plugin_popup_direction      (XfcePanelPlugin  *plugin,
+                                                             GtkWidget        *attach_widget);
+GtkArrowType         xfce_panel_plugin_position_popup       (XfcePanelPlugin  *plugin,
+                                                             GtkWidget        *attach_widget,
+                                                             GtkRequisition   *popup_requisition,
+                                                             gint             *x, 
+                                                             gint             *y);
+
+
 gchar               *xfce_panel_plugin_lookup_rc_file       (XfcePanelPlugin  *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 gchar               *xfce_panel_plugin_save_location        (XfcePanelPlugin  *plugin,
                                                              gboolean          create) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
+
 void                 xfce_panel_plugin_focus_widget         (XfcePanelPlugin  *plugin,
                                                              GtkWidget        *widget);
 void                 xfce_panel_plugin_set_panel_hidden     (XfcePanelPlugin  *plugin,
@@ -114,3 +135,4 @@
 G_END_DECLS
 
 #endif /* !__XFCE_PANEL_PLUGIN_IFACE_H__ */
+

Modified: xfce4-panel/trunk/plugins/launcher/launcher.c
===================================================================
--- xfce4-panel/trunk/plugins/launcher/launcher.c	2007-09-28 11:11:47 UTC (rev 26114)
+++ xfce4-panel/trunk/plugins/launcher/launcher.c	2007-09-28 11:46:45 UTC (rev 26115)
@@ -42,6 +42,9 @@
                                                                      guint                  n_param_values,
                                                                      const GValue          *param_values,
                                                                      LauncherPlugin        *launcher);
+static void            launcher_utility_expose_event_init_arrow     (GtkWidget             *button,
+                                                                     GdkEventExpose        *event,
+                                                                     LauncherPlugin        *launcher);
 static gboolean        launcher_icon_button_expose_event            (GtkWidget             *widget,
                                                                      GdkEventExpose        *event,
                                                                      LauncherPlugin        *launcher);
@@ -79,11 +82,6 @@
 static gboolean        launcher_menu_item_released                  (GtkWidget             *mi,
                                                                      GdkEventButton        *event,
                                                                      LauncherPlugin        *launcher);
-static void            launcher_menu_position                       (GtkMenu               *menu,
-                                                                     gint                  *x,
-                                                                     gint                  *y,
-                                                                     gboolean              *push_in,
-                                                                     LauncherPlugin        *launcher);
 static void            launcher_menu_popup_destroyed                (gpointer               user_data);
 static gboolean        launcher_menu_popup                          (gpointer               user_data);
 static void            launcher_menu_deactivated                    (LauncherPlugin        *launcher);
@@ -93,7 +91,6 @@
 static void            launcher_plugin_pack_buttons                 (LauncherPlugin        *launcher);
 static gchar          *launcher_plugin_read_entry                   (XfceRc                *rc,
                                                                      const gchar           *name) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-static GtkArrowType    launcher_plugin_calculate_arrow_type         (XfcePanelPlugin       *panel_plugin);
 static void            launcher_plugin_screen_position_changed      (LauncherPlugin        *launcher);
 static void            launcher_plugin_orientation_changed          (LauncherPlugin        *launcher);
 static gboolean        launcher_plugin_set_size                     (LauncherPlugin        *launcher,
@@ -268,6 +265,21 @@
 
 
 
+static void
+launcher_utility_expose_event_init_arrow (GtkWidget      *button, 
+                                          GdkEventExpose *event, 
+                                          LauncherPlugin *launcher)
+{
+    launcher_plugin_screen_position_changed (launcher);
+
+    /* no need to run this again */
+    g_signal_handlers_disconnect_by_func (G_OBJECT (button), 
+                                          G_CALLBACK (launcher_utility_expose_event_init_arrow),
+                                          launcher);
+}
+
+
+
 /**
  * Icon Button Functions
  **/
@@ -279,7 +291,7 @@
     gint         x, y, w;
     GtkArrowType arrow_type;
 
-    /* only show the arrow when the arrow button is hidden */
+    /* only paint the arrow when the arrow button is hidden */
     if (launcher->arrow_position == LAUNCHER_ARROW_INSIDE_BUTTON)
     {
         /* calculate the width of the arrow */
@@ -598,44 +610,6 @@
 
 
 static void
-launcher_menu_position (GtkMenu        *menu,
-                        gint           *x,
-                        gint           *y,
-                        gboolean       *push_in,
-                        LauncherPlugin *launcher)
-{
-    GtkWidget      *widget = GTK_WIDGET (launcher->panel_plugin);
-    GtkRequisition  req;
-
-    if (!GTK_WIDGET_REALIZED (GTK_WIDGET (menu)))
-        gtk_widget_realize (GTK_WIDGET (menu));
-
-    gtk_widget_size_request (GTK_WIDGET (menu), &req);
-    gdk_window_get_origin (widget->window, x, y);
-
-    switch (xfce_arrow_button_get_arrow_type (XFCE_ARROW_BUTTON (launcher->arrow_button)))
-    {
-        case GTK_ARROW_UP:
-            *y -= req.height;
-            break;
-
-        case GTK_ARROW_DOWN:
-            *y += widget->allocation.height;
-            break;
-
-        case GTK_ARROW_LEFT:
-            *x -= req.width;
-            break;
-
-        default: /* GTK_ARROW_RIGHT and GTK_ARROW_NONE */
-            *x += widget->allocation.width;
-            break;
-    }
-}
-
-
-
-static void
 launcher_menu_popup_destroyed (gpointer user_data)
 {
     LauncherPlugin *launcher = user_data;
@@ -649,6 +623,7 @@
 launcher_menu_popup (gpointer user_data)
 {
     LauncherPlugin *launcher = user_data;
+    GtkArrowType    arrow_type;
 
     GDK_THREADS_ENTER ();
 
@@ -660,9 +635,12 @@
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (launcher->arrow_button), TRUE);
 
     /* popup menu */
-    gtk_menu_popup (GTK_MENU (launcher->menu), NULL, NULL,
-                    (GtkMenuPositionFunc) launcher_menu_position,
-                    launcher, 1, gtk_get_current_event_time ());
+    arrow_type = xfce_panel_plugin_menu_popup (XFCE_PANEL_PLUGIN (launcher->panel_plugin),
+                                               GTK_MENU (launcher->menu),
+                                               1, gtk_get_current_event_time ());
+    if (arrow_type != GTK_ARROW_NONE)
+        xfce_arrow_button_set_arrow_type (XFCE_ARROW_BUTTON(launcher->arrow_button), 
+                                          arrow_type);
 
     GDK_THREADS_LEAVE ();
 
@@ -723,6 +701,9 @@
 
     /* create new menu */
     launcher->menu = gtk_menu_new ();
+    gtk_menu_attach_to_widget (GTK_MENU (launcher->menu),
+                               launcher->box,
+                               NULL);
 
     /* get the plugin screen */
     screen = gtk_widget_get_screen (GTK_WIDGET (launcher->panel_plugin));
@@ -837,7 +818,6 @@
 }
 
 
-
 /**
  * Panel Plugin Functions
  **/
@@ -927,15 +907,26 @@
     if (G_UNLIKELY (g_list_length (launcher->entries) == 0))
         launcher->entries = g_list_prepend (launcher->entries, launcher_entry_new ());
 
-    /* set the arrow direction */
-    launcher_plugin_screen_position_changed (launcher);
-
     /* set the buttons in the correct position */
     launcher_plugin_pack_buttons (launcher);
 
     /* change the visiblity of the arrow button */
     launcher_menu_destroy (launcher);
 
+    /* set the arrow direction */
+    if (launcher->arrow_position == LAUNCHER_ARROW_INSIDE_BUTTON)
+    {
+            g_signal_connect (G_OBJECT (launcher->image), "expose-event",
+                              G_CALLBACK (launcher_utility_expose_event_init_arrow), 
+                              launcher);
+    }
+    else
+    {
+            g_signal_connect (G_OBJECT (launcher->arrow_button), "expose-event",
+                              G_CALLBACK (launcher_utility_expose_event_init_arrow), 
+                              launcher);
+    }
+
 #if !LAUNCHER_NEW_TOOLTIP_API
     /* set the button tooltip */
     launcher_icon_button_set_tooltip (launcher);
@@ -1186,74 +1177,19 @@
 
 
 
-static GtkArrowType
-launcher_plugin_calculate_arrow_type (XfcePanelPlugin *panel_plugin)
-{
-    XfceScreenPosition  position;
-    GdkScreen          *screen;
-    GdkRectangle        geom;
-    gint                mon, x, y;
-
-    g_return_val_if_fail (GTK_WIDGET_REALIZED (panel_plugin), GTK_ARROW_UP);
-
-    /* get the plugin position */
-    position = xfce_panel_plugin_get_screen_position (panel_plugin);
-
-    /* get the arrow direction */
-    switch (position)
-    {
-        /* top */
-        case XFCE_SCREEN_POSITION_NW_H:
-        case XFCE_SCREEN_POSITION_N:
-        case XFCE_SCREEN_POSITION_NE_H:
-            return GTK_ARROW_DOWN;
-
-        /* left */
-        case XFCE_SCREEN_POSITION_NW_V:
-        case XFCE_SCREEN_POSITION_W:
-        case XFCE_SCREEN_POSITION_SW_V:
-            return GTK_ARROW_RIGHT;
-
-        /* right */
-        case XFCE_SCREEN_POSITION_NE_V:
-        case XFCE_SCREEN_POSITION_E:
-        case XFCE_SCREEN_POSITION_SE_V:
-            return GTK_ARROW_LEFT;
-
-        /* bottom */
-        case XFCE_SCREEN_POSITION_SW_H:
-        case XFCE_SCREEN_POSITION_S:
-        case XFCE_SCREEN_POSITION_SE_H:
-            return GTK_ARROW_UP;
-
-        /* floating */
-        default:
-            /* get the screen information */
-            screen = gtk_widget_get_screen (GTK_WIDGET (panel_plugin));
-            mon = gdk_screen_get_monitor_at_window (screen, GTK_WIDGET (panel_plugin)->window);
-            gdk_screen_get_monitor_geometry (screen, mon, &geom);
-            gdk_window_get_root_origin (GTK_WIDGET (panel_plugin)->window, &x, &y);
-
-            /* get the position based on the screen position */
-            if (position == XFCE_SCREEN_POSITION_FLOATING_H)
-                return ((y < (geom.y + geom.height / 2)) ? GTK_ARROW_DOWN : GTK_ARROW_UP);
-            else
-                return ((x < (geom.x + geom.width / 2)) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT);
-    }
-}
-
-
-
 static void
 launcher_plugin_screen_position_changed (LauncherPlugin *launcher)
 {
     GtkArrowType arrow_type;
 
     /* get the arrow type */
-    arrow_type = launcher_plugin_calculate_arrow_type (launcher->panel_plugin);
+    arrow_type = xfce_panel_plugin_popup_direction (XFCE_PANEL_PLUGIN (launcher->panel_plugin),
+                                                    GTK_WIDGET (launcher->box));
 
     /* set the arrow direction */
-    xfce_arrow_button_set_arrow_type (XFCE_ARROW_BUTTON (launcher->arrow_button), arrow_type);
+    if (arrow_type != GTK_ARROW_NONE)
+        xfce_arrow_button_set_arrow_type (XFCE_ARROW_BUTTON(launcher->arrow_button), 
+                                          arrow_type);
 }
 
 

Modified: xfce4-panel/trunk/plugins/windowlist/windowlist.c
===================================================================
--- xfce4-panel/trunk/plugins/windowlist/windowlist.c	2007-09-28 11:11:47 UTC (rev 26114)
+++ xfce4-panel/trunk/plugins/windowlist/windowlist.c	2007-09-28 11:46:45 UTC (rev 26115)
@@ -50,24 +50,24 @@
 
 typedef enum { WS_ADD = 1, WS_REMOVE } WorkspaceAction;
 
-static gboolean
-windowlist_blink (gpointer data);
+static gboolean         windowlist_blink                (gpointer         data);
+static void             windowlist_update_arrow_type    (Windowlist      *wl);
+static void             windowlist_set_arrow_type       (Windowlist      *wl,
+                                                         GtkArrowType     arrow_type);
+static gboolean         windowlist_set_size             (XfcePanelPlugin *plugin,
+                                                         int              size,
+                                                         Windowlist      *wl);
+static void             windowlist_construct            (XfcePanelPlugin *plugin);
 
-static GtkArrowType
-windowlist_arrow_type (XfcePanelPlugin * plugin);
 
-static gboolean
-windowlist_set_size (XfcePanelPlugin *plugin,
-		     int size,
-		     Windowlist * wl);
 
 /**
  * REGISTER PLUGIN
  **/
-static void windowlist_construct (XfcePanelPlugin *plugin);
-
 XFCE_PANEL_PLUGIN_REGISTER_INTERNAL (windowlist_construct);
 
+
+
 /**
  * Common functions
  **/
@@ -77,8 +77,8 @@
     char *utf8 = NULL;
     if (!g_utf8_validate(string, -1, NULL))
     {
-	utf8 = g_locale_to_utf8(string, -1, NULL, NULL, NULL);
-	DBG("Title was not UTF-8 complaint");
+        utf8 = g_locale_to_utf8(string, -1, NULL, NULL, NULL);
+        DBG("Title was not UTF-8 complaint");
     }
     else
     {
@@ -91,72 +91,84 @@
     return utf8;
 }
 
+
+
 static gchar *
 menulist_workspace_name (NetkWorkspace *workspace,
-			 const gchar *num_title,
-			 const gchar *name_title)
+                         const gchar   *num_title,
+                         const gchar   *name_title)
 {
     const gchar *ws_name = NULL;
-    gchar *ws_title;
-    gint ws_num;
-    
+    gchar       *ws_title;
+    gint         ws_num;
+
     ws_num  = netk_workspace_get_number (workspace);    
     ws_name = netk_workspace_get_name (workspace);
-	    
-    if(!ws_name || atoi((const char *)ws_name) == ws_num + 1)
-	ws_title = g_strdup_printf(num_title, ws_num + 1);
+
+    if (!ws_name || strtol((const char *)ws_name, NULL, 0) == ws_num + 1)
+        ws_title = g_strdup_printf (num_title, ws_num + 1);
     else
-	ws_title = g_markup_printf_escaped(name_title, ws_name);
-    
+        ws_title = g_markup_printf_escaped (name_title, ws_name);
+
     return ws_title;
 }
 
+
+
 /**
  * Menu Actions
  **/
 static void
 menu_deactivated (GtkWidget *menu,
-		  GtkWidget *button)
+                  GtkWidget *button)
 {
     DBG ("Destroy menu");
-    
+
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), 
                                   FALSE);
     if (menu)
-	gtk_widget_destroy (menu);
+        gtk_widget_destroy (menu);
 }
 
+
+
 static gboolean
-menulist_goto_workspace (GtkWidget *mi,
-			 GdkEventButton *ev,
-			 NetkWorkspace *workspace)
+menulist_goto_workspace (GtkWidget      *mi,
+                         GdkEventButton *ev,
+                         NetkWorkspace  *workspace)
 {
     netk_workspace_activate (workspace);
-    
+
     return FALSE;
 }
 
+
+
 static void
-window_destroyed (gpointer data,
-		  GObject *object)
+window_destroyed (gpointer  data,
+                  GObject  *object)
 {
     GtkWidget *mi   = data;
     GtkWidget *menu = gtk_widget_get_parent(mi);
-    
+
     if(mi && menu)
         gtk_container_remove (GTK_CONTAINER(menu), mi);
-    
+
     gtk_menu_reposition (GTK_MENU(menu));
 }
 
+
+
 static void
 mi_destroyed (GtkObject *object,
-	      gpointer data)
+              gpointer   data)
 {
     g_object_weak_unref (G_OBJECT(data),
-            (GWeakNotify)window_destroyed, object);
+                         (GWeakNotify)window_destroyed, object);
 }
 
+
+
 static void
 action_menu_deactivated (GtkMenu *menu,
                          GtkMenu *parent)
@@ -167,14 +179,16 @@
     g_signal_emit_by_name (parent, "deactivate", 0);
 }
 
+
+
 static void
-popup_action_menu (GtkWidget * widget,
-		   NetkWindow *window)
+popup_action_menu (GtkWidget  *widget,
+                   NetkWindow *window)
 {
     static GtkWidget *menu = NULL;
 
     if (menu)
-	gtk_widget_destroy (menu);
+        gtk_widget_destroy (menu);
 
     menu = netk_create_window_action_menu (window);
 
@@ -182,13 +196,15 @@
                       G_CALLBACK (action_menu_deactivated), widget->parent);
 
     gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0,
-                    GDK_CURRENT_TIME);
+                    gtk_get_current_event_time());
 }
 
+
+
 static gboolean
-menulist_goto_window (GtkWidget *mi,
-		      GdkEventButton *ev,
-		      NetkWindow *window)
+menulist_goto_window (GtkWidget      *mi,
+                      GdkEventButton *ev,
+                      NetkWindow     *window)
 {
     if (ev->button == 1) /* Goto workspace and show window */
     {
@@ -197,75 +213,83 @@
         {
             netk_workspace_activate(netk_window_get_workspace(window));
         }
-	netk_window_activate (window);
+        netk_window_activate (window);
         g_signal_emit_by_name (mi->parent, "deactivate", 0);
     }
     else if (ev->button == 2) /* Show window on current workspace */
     {
         gtk_menu_popdown (GTK_MENU (mi->parent));
-	netk_window_activate (window);
+        netk_window_activate (window);
         g_signal_emit_by_name (mi->parent, "deactivate", 0);
     }
     else if (ev->button == 3) /* Show the popup menu */
     {
         popup_action_menu (mi, window);
 
-	/* the right-click menu will pop down the main menu */
-	return TRUE;
+        /* the right-click menu will pop down the main menu */
+        return TRUE;
     }
 
     return FALSE;
 }
 
+
+
 static gboolean
-menulist_add_screen (GtkWidget *mi,
-		     GdkEventButton *ev,
-		     Windowlist *wl)
+menulist_add_screen (GtkWidget      *mi,
+                     GdkEventButton *ev,
+                     Windowlist     *wl)
 {
     gint num = netk_screen_get_workspace_count (wl->screen) + 1;
-    
+
     netk_screen_change_workspace_count (netk_screen_get_default (), num);
-    
+
     return FALSE;
 }
 
+
+
 static gboolean
-menulist_remove_screen (GtkWidget *mi,
-		        GdkEventButton *ev,
-		        Windowlist *wl)
+menulist_remove_screen (GtkWidget      *mi,
+                        GdkEventButton *ev,
+                        Windowlist     *wl)
 {
     NetkWorkspace *workspace;
-    gint ws_num;
-    char *text;
-    
+    gint           ws_num;
+    char          *text;
+
     ws_num    = netk_screen_get_workspace_count (wl->screen) - 1;
     workspace = netk_screen_get_workspace (wl->screen, ws_num);
-    
+
     text = menulist_workspace_name (workspace,
-                _("Are you sure you want to remove workspace %d?"),
-                _("Are you sure you want to remove workspace '%s'?"));
-    
+            _("Are you sure you want to remove workspace %d?"),
+            _("Are you sure you want to remove workspace '%s'?"));
+
     if (xfce_confirm (text, GTK_STOCK_REMOVE, NULL))
     {
-	netk_screen_change_workspace_count (netk_screen_get_default (),
-					    ws_num);
+        netk_screen_change_workspace_count (netk_screen_get_default (),
+                                            ws_num);
     }
 
     g_free (text);
-    
+
     return FALSE;
 }
 
+
+
 static gboolean
-menulist_keypress (GtkWidget *menu, GdkEventKey *ev, Windowlist *wl)
+menulist_keypress (GtkWidget   *menu, 
+                   GdkEventKey *ev,
+                   Windowlist  *wl)
 {
-    GdkEventButton evb;
-    GList *l;
-    GtkWidget *mi = NULL;
-    NetkWindow *window;
-    NetkWorkspace *workspace;
-    gpointer ws_action;
-    guint state;
+    GdkEventButton  evb;
+    GList          *l;
+    GtkWidget      *mi = NULL;
+    NetkWindow     *window;
+    NetkWorkspace  *workspace;
+    gpointer        ws_action;
+    guint           state;
 
     for (l = GTK_MENU_SHELL (menu)->children; l != NULL; l = l->next)
     {
@@ -313,7 +337,7 @@
     }
     else if (evb.button == 1 && 
              (workspace = g_object_get_data (G_OBJECT (mi), "netk-workspace")) 
-                != NULL)
+             != NULL)
     {
         if (!NETK_IS_WORKSPACE (workspace))
             return FALSE;
@@ -322,7 +346,7 @@
     }
     else if (evb.button == 1 && 
              (ws_action = g_object_get_data (G_OBJECT (mi), "ws-action"))
-                != NULL)
+             != NULL)
     {
         if (GPOINTER_TO_INT (ws_action) == WS_REMOVE)
         {
@@ -337,100 +361,42 @@
     return FALSE;
 }
 
-/**
- * Menu position function
- **/
-static void
-windowlist_position_menu (GtkMenu *menu,
-			  int *x,
-			  int *y,
-			  gboolean * push_in,
-                          Windowlist *wl)
-{
-    GtkWidget *widget;
-    GtkRequisition req;
-    GdkScreen *screen;
-    GdkRectangle geom;
-    int num;
 
-    widget = GTK_WIDGET (wl->plugin);
-    
-    if (!GTK_WIDGET_REALIZED (GTK_WIDGET (menu)))
-        gtk_widget_realize (GTK_WIDGET (menu));
 
-    gtk_widget_size_request (GTK_WIDGET (menu), &req);
-    gdk_window_get_origin (widget->window, x, y);
- 
-    switch (wl->arrowtype)
-    {
-        case GTK_ARROW_UP:
-            *y += widget->allocation.y - req.height;
-            break;
-        case GTK_ARROW_DOWN:
-            *y += widget->allocation.y + widget->allocation.height;
-            break;
-        case GTK_ARROW_LEFT:
-            *x += widget->allocation.x - req.width;
-            *y += - req.height + widget->allocation.height;
-            break;
-        case GTK_ARROW_RIGHT:
-            *x += widget->allocation.x + widget->allocation.width;
-            *y += - req.height + widget->allocation.height;
-            break;
-        default:
-            break;
-    }
-
-    screen = gtk_widget_get_screen (widget);
-    num = gdk_screen_get_monitor_at_window (screen, widget->window);
-    gdk_screen_get_monitor_geometry (screen, num, &geom);
-    
-    gtk_menu_set_screen (menu, screen);
-
-    if (*x > geom.x + geom.width - req.width)
-        *x = geom.x + geom.width - req.width;
-    if (*x < geom.x)
-        *x = geom.x;
-
-    if (*y > geom.y + geom.height - req.height)
-        *y = geom.y + geom.height - req.height;
-    if (*y < geom.y)
-        *y = geom.y;
-}
-
 /**
  * Window List Menu functions
  **/
 static GtkWidget *
 menulist_menu_item (NetkWindow *window,
-		    Windowlist *wl,
-		    gint size)
+                    Windowlist *wl,
+                    gint        size)
 {
     GtkWidget *mi;
-    char *window_name = NULL;
-    GString *label;
-    GdkPixbuf *icon = NULL, *tmp = NULL;
-    
+    char      *window_name = NULL;
+    GString   *label;
+    GdkPixbuf *icon = NULL;
+    GdkPixbuf *tmp = NULL;
+
     window_name = menulist_utf8_string (netk_window_get_name (window));
     label = g_string_new (window_name);
-    
+
     if (netk_window_is_minimized (window))
     {
         g_string_prepend (label, "[");
         g_string_append (label, "]");
     }
-    
+
     /* hack: italic fonts are not completely shown, otherwise */
     g_string_append (label, " ");
-    
+
     if (wl->show_window_icons)
-	icon = netk_window_get_icon (window);
+        icon = netk_window_get_icon (window);
 
     if (icon)
     {
         GtkWidget *img;
         gint w, h;
-    
+
         w = gdk_pixbuf_get_width (icon);
         h = gdk_pixbuf_get_height (icon);
 
@@ -440,129 +406,135 @@
                                            GDK_INTERP_BILINEAR);
             icon = tmp;
         }
-    
+
         mi = gtk_image_menu_item_new_with_label (label->str);
-        
+
         img = gtk_image_new_from_pixbuf (icon);
         gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
-	
-	if (G_LIKELY (tmp))
-	    g_object_unref (G_OBJECT (tmp));
+
+        if (G_LIKELY (tmp))
+            g_object_unref (G_OBJECT (tmp));
     }
     else
     {
         mi = gtk_menu_item_new_with_label (label->str);
     }
-    
+
     gtk_label_set_ellipsize (GTK_LABEL (GTK_BIN (mi)->child), 
                              PANGO_ELLIPSIZE_END);
     gtk_label_set_max_width_chars (GTK_LABEL (GTK_BIN (mi)->child), 24);
-    
+
     gtk_tooltips_set_tip (wl->tooltips, mi, window_name, NULL);
 
     g_string_free (label, TRUE);
     g_free (window_name);
-    
+
     return mi;
 }
 
+
+
 static gboolean
-menulist_popup_menu (Windowlist * wl,
+menulist_popup_menu (Windowlist     *wl,
                      GdkEventButton *ev,
-                     gboolean at_pointer)
+                     gboolean        at_pointer)
 {
-    GtkWidget *menu, *mi, *icon;
-    NetkWindow *window;
-    NetkWorkspace *netk_workspace, *active_workspace, *window_workspace;
-    gchar *ws_label, *rm_label;
-    gint size, i, wscount;
-    GList *windows, *li;
+    GtkWidget            *menu, *mi, *icon;
+    NetkWindow           *window;
+    NetkWorkspace        *netk_workspace;
+    NetkWorkspace        *active_workspace;
+    NetkWorkspace        *window_workspace;
+    gchar                *ws_label, *rm_label;
+    gint                  size, i, wscount;
+    GList                *windows, *li;
+    GtkArrowType          arrow_type;
     PangoFontDescription *italic, *bold;
-    
+
     /* Menu item styles */
     italic = pango_font_description_from_string ("italic");
-    bold = pango_font_description_from_string ("bold");
-    
+    bold   = pango_font_description_from_string ("bold");
+
     menu = gtk_menu_new ();
-    xfce_panel_plugin_register_menu (XFCE_PANEL_PLUGIN (wl->plugin), 
-                                     GTK_MENU (menu));
-    
+
     gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &size, NULL);
-    
+
     windows = netk_screen_get_windows_stacked (wl->screen);
     active_workspace = netk_screen_get_active_workspace (wl->screen);
-    
+
     if (wl->show_all_workspaces)
-	wscount = netk_screen_get_workspace_count (wl->screen);
+        wscount = netk_screen_get_workspace_count (wl->screen);
     else
-	wscount = 1;
-    
+        wscount = 1;
+
     /* For Each Workspace */
     for (i = 0; i < wscount; i++)
     {
-	/* Load workspace */
-	if (wl->show_all_workspaces)
-	    netk_workspace = netk_screen_get_workspace (wl->screen, i);
+        /* Load workspace */
+        if (wl->show_all_workspaces)
+            netk_workspace = netk_screen_get_workspace (wl->screen, i);
         else
-	    netk_workspace = netk_screen_get_active_workspace (wl->screen);
-	
-	/* Create workspace menu item */
-	ws_label = 
+            netk_workspace = netk_screen_get_active_workspace (wl->screen);
+
+        /* Create workspace menu item */
+        ws_label = 
             menulist_workspace_name (netk_workspace, _("Workspace %d"), "%s");
 
         mi = gtk_menu_item_new_with_label (ws_label);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-	g_free (ws_label);
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+        g_free (ws_label);
 
         g_object_set_data (G_OBJECT (mi), "netk-workspace", netk_workspace);
 
         g_signal_connect (mi, "button-release-event",
-		G_CALLBACK (menulist_goto_workspace), netk_workspace);
-	
-	/* Apply layout */
-	if (netk_workspace == active_workspace)
-	    gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (mi)), bold);
+                          G_CALLBACK (menulist_goto_workspace), 
+                          netk_workspace);
+
+        /* Apply layout */
+        if (netk_workspace == active_workspace)
+            gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (mi)), bold);
         else
             gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (mi)), italic); 
 
         mi = gtk_separator_menu_item_new ();
         gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-	
-	/* Foreach Window */
-	for (li = windows; li; li = li->next)
+
+        /* Foreach Window */
+        for (li = windows; li; li = li->next)
         {
             /* If window is not on current workspace; continue */
-	    window = li->data;
+            window = li->data;
             window_workspace = netk_window_get_workspace (window);
-	    
+
             if (netk_workspace != window_workspace && 
-		!(netk_window_is_sticky (window) && 
-		netk_workspace == active_workspace))
-		    continue;
-	    
-	    if (netk_window_is_skip_pager (window) || 
-		netk_window_is_skip_tasklist (window))
-		    continue;
-	    
-	    /* Create menu item */
-	    mi = menulist_menu_item (window,
-				     wl,
-				     size);
-	    
-	    if (G_UNLIKELY (!mi))
+                !(netk_window_is_sticky (window) && 
+                netk_workspace == active_workspace))
+            {
                 continue;
-	    
-	    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-	    
+            }
+
+            if (netk_window_is_skip_pager (window) || 
+                netk_window_is_skip_tasklist (window))
+            {
+                continue;
+            }
+
+            /* Create menu item */
+            mi = menulist_menu_item (window, wl, size);
+
+            if (G_UNLIKELY (!mi))
+                continue;
+
+            gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
             if (netk_window_is_active (window))
             {
                 gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (mi)), 
-			italic);
+                        italic);
             }
 
-	    /* Apply some styles for windows on !current workspace and 
+            /* Apply some styles for windows on !current workspace and 
              * if they are urgent */
-	    if (netk_window_or_transient_demands_attention (window))
+            if (netk_window_or_transient_demands_attention (window))
             {
                 if (netk_workspace == active_workspace)
                 {
@@ -572,40 +544,40 @@
                 else
                 {
                     gtk_widget_modify_fg (gtk_bin_get_child (GTK_BIN (mi)),
-                             GTK_STATE_NORMAL,
-                             &(menu->style->fg[GTK_STATE_INSENSITIVE]));
+                                          GTK_STATE_NORMAL,
+                                          &(menu->style->fg[GTK_STATE_INSENSITIVE]));
                     gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (mi)),
                                             bold);
                 }
             }
-	    else if (netk_workspace != active_workspace && 
+            else if (netk_workspace != active_workspace && 
                      !netk_window_is_sticky (window))
             {
                 gtk_widget_modify_fg (gtk_bin_get_child (GTK_BIN (mi)),
                         GTK_STATE_NORMAL,
                         &(menu->style->fg[GTK_STATE_INSENSITIVE]));
             }
-	 
+
             g_object_set_data (G_OBJECT (mi), "netk-window", window);
 
-	    /* Connect some signals */
-	    g_signal_connect (mi, "button-release-event",
-                    G_CALLBACK (menulist_goto_window), window);
-	    
-	    g_object_weak_ref(G_OBJECT(window),
-                    (GWeakNotify)window_destroyed, mi);
-	    
-	    g_signal_connect(G_OBJECT(mi), "destroy",
-                    G_CALLBACK(mi_destroyed), window);
-	}
-	
-	if (i < wscount-1)
-	{
-	    mi = gtk_separator_menu_item_new ();
-	    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-	}
+            /* Connect some signals */
+            g_signal_connect (mi, "button-release-event",
+                              G_CALLBACK (menulist_goto_window), window);
+
+            g_object_weak_ref(G_OBJECT(window),
+                              (GWeakNotify)window_destroyed, mi);
+
+            g_signal_connect(G_OBJECT(mi), "destroy",
+                             G_CALLBACK(mi_destroyed), window);
+        }
+
+        if (i < wscount-1)
+        {
+            mi = gtk_separator_menu_item_new ();
+            gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+        }
     }
-    
+
     pango_font_description_free(italic);
     pango_font_description_free(bold);
 
@@ -614,40 +586,40 @@
     {
         int ws_action;
 
-	mi = gtk_separator_menu_item_new ();
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-	
-	/* Add workspace */
-	if (wl->show_window_icons)
-	{
-	    mi = gtk_image_menu_item_new_with_label (_("Add workspace"));
-	    icon = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
-	    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), icon);
-	}
-	else
-	{
-	    mi = gtk_menu_item_new_with_label (_("Add workspace"));
-	}
-	
+        mi = gtk_separator_menu_item_new ();
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+        /* Add workspace */
+        if (wl->show_window_icons)
+        {
+            mi = gtk_image_menu_item_new_with_label (_("Add workspace"));
+            icon = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
+            gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), icon);
+        }
+        else
+        {
+            mi = gtk_menu_item_new_with_label (_("Add workspace"));
+        }
+
         ws_action = WS_ADD;
         g_object_set_data (G_OBJECT (mi), "ws-action", GINT_TO_POINTER (ws_action));
 
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
 
-	g_signal_connect (mi, "button-release-event",
-		G_CALLBACK (menulist_add_screen), wl);
-	
-	/* Remove workspace */
-	wscount = netk_screen_get_workspace_count (wl->screen);
+        g_signal_connect (mi, "button-release-event",
+                          G_CALLBACK (menulist_add_screen), wl);
 
+        /* Remove workspace */
+        wscount = netk_screen_get_workspace_count (wl->screen);
+
         if (wscount > 1)
         {
             netk_workspace = netk_screen_get_workspace (wl->screen, wscount-1);
-            
+
             rm_label = menulist_workspace_name (netk_workspace,
                                                 _("Remove Workspace %d"),
                                                 _("Remove Workspace '%s'"));
-            
+
             if (wl->show_window_icons)
             {
                 mi = gtk_image_menu_item_new_with_label (rm_label);
@@ -668,143 +640,164 @@
             gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
 
             g_signal_connect (mi, "button-release-event",
-                    G_CALLBACK (menulist_remove_screen), wl);
+                              G_CALLBACK (menulist_remove_screen), wl);
         }
     }
-    
+
     /* key presses work on the menu, not the items */
     g_signal_connect (menu, "key-press-event",
-            G_CALLBACK (menulist_keypress), 
-            wl);
+                      G_CALLBACK (menulist_keypress), 
+                      wl);
 
     /* Activate toggle button */
     if (!at_pointer)
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wl->button), TRUE);
-    
+
     /* Connect signal, show widgets and popup */
     g_signal_connect (menu, "deactivate",
-		    G_CALLBACK (menu_deactivated), wl->button);
+                      G_CALLBACK (menu_deactivated), wl->button);
 
     gtk_widget_show_all (menu);
-    
-    gtk_menu_popup (GTK_MENU (menu), NULL, NULL, 
-                    at_pointer ? NULL
-                               : (GtkMenuPositionFunc)windowlist_position_menu,
-		    wl, 0, ev ? ev->time : GDK_CURRENT_TIME);
-    
+
+    if (!at_pointer)
+    {
+        gtk_menu_attach_to_widget (GTK_MENU (menu),
+                                   wl->button, NULL);
+    }
+
+    arrow_type = 
+        xfce_panel_plugin_menu_popup (XFCE_PANEL_PLUGIN (wl->plugin), 
+                                      GTK_MENU (menu),
+                                      ev ? ev->button : 0, 
+                                      ev ? ev->time : gtk_get_current_event_time());
+    windowlist_set_arrow_type(wl, arrow_type);
+
     return TRUE;
 }
 
+
+
 static gboolean
 menulist_toggle_menu (GtkToggleButton *button,
-                      GdkEventButton *ev, 
-                      Windowlist * wl)
+                      GdkEventButton  *ev, 
+                      Windowlist      *wl)
 {
     if (ev->button != 1)
-	return FALSE;
+        return FALSE;
     return menulist_popup_menu (wl, ev, FALSE);
 }
 
+
+
 /**
  * Check for urgent on workspaces
  **/
 static gboolean
 windowlist_search_urgent (gpointer data)
 {
-    Windowlist * wl = (Windowlist *) data;
-    NetkWindow *window;
-    NetkWorkspace *active_workspace, *window_workspace;
-    gboolean blink = FALSE;
-    GList *windows, *li;
-    
+    Windowlist    *wl = (Windowlist *) data;
+    NetkWindow    *window;
+    NetkWorkspace *active_workspace;
+    NetkWorkspace *window_workspace;
+    gboolean       blink = FALSE;
+    GList         *windows, *li;
+
     windows = netk_screen_get_windows_stacked (wl->screen);
     active_workspace = netk_screen_get_active_workspace (wl->screen);
 
     /* For Each Window (stop when we've found an urgent window) */
     for (li = windows; li && !blink; li = li->next)
     {
-	window = li->data;
-	window_workspace = netk_window_get_workspace (window);
-	
-	/* Don't check for urgent windows on current workspace
-	   if enabled in properties */
-	if (window_workspace == active_workspace && 
-	    wl->notify == OTHER_WORKSPACES)
-		continue;
-	    
-	/* Skip windows that are not in the tasklist */	
-	if (netk_window_is_sticky (window)	   ||
-	    netk_window_is_skip_pager (window)	   ||
-	    netk_window_is_skip_tasklist (window))
-		continue;
-	
-	/* Check if window is urgent */
-	if (netk_window_or_transient_demands_attention (window))
-	    blink = TRUE;
+        window = li->data;
+        window_workspace = netk_window_get_workspace (window);
+
+        /* Don't check for urgent windows on current workspace
+           if enabled in properties */
+        if (window_workspace == active_workspace && 
+            wl->notify == OTHER_WORKSPACES)
+        {
+            continue;
+        }
+
+        /* Skip windows that are not in the tasklist */	
+        if (netk_window_is_sticky (window)	   ||
+            netk_window_is_skip_pager (window)	   ||
+            netk_window_is_skip_tasklist (window))
+        {
+            continue;
+        }
+
+        /* Check if window is urgent */
+        if (netk_window_or_transient_demands_attention (window))
+            blink = TRUE;
     }
-    
+
     wl->blink = blink;
-    
+
     if (G_UNLIKELY (blink && !wl->blink_timeout_id))
     {
-	wl->blink_timeout_id = 
-                    g_timeout_add (FLASH_TIMEOUT, windowlist_blink, wl);
-	
-	DBG ("New blink source started: %d", wl->blink_timeout_id);
-	
-	/* Start the blink and don't wait 0,5 second */
-	windowlist_blink (wl);
+        wl->blink_timeout_id = 
+            g_timeout_add (FLASH_TIMEOUT, windowlist_blink, wl);
+
+        DBG ("New blink source started: %d", wl->blink_timeout_id);
+
+        /* Start the blink and don't wait 0,5 second */
+        windowlist_blink (wl);
     }
-	
-    
+
+
     if (G_UNLIKELY (!blink && wl->blink_timeout_id))
     {
-	DBG ("Blink source stopped: %d", wl->blink_timeout_id);
-	
-	g_source_remove (wl->blink_timeout_id);
-	wl->blink_timeout_id = 0;
-	windowlist_blink (wl);
+        DBG ("Blink source stopped: %d", wl->blink_timeout_id);
+
+        g_source_remove (wl->blink_timeout_id);
+        wl->blink_timeout_id = 0;
+        windowlist_blink (wl);
     }
-    
+
     return TRUE;
 }
 
+
+
 void
 windowlist_start_blink (Windowlist * wl)
 {
     /* Stop the Search function */
     if (wl->search_timeout_id)
     {
-	DBG ("Search source stopped: %d", wl->search_timeout_id);
-	g_source_remove (wl->search_timeout_id);
-	wl->search_timeout_id = 0;
+        DBG ("Search source stopped: %d", wl->search_timeout_id);
+        g_source_remove (wl->search_timeout_id);
+        wl->search_timeout_id = 0;
     }
-    
+
     /* Stop the blink if it's running */
     if (wl->blink_timeout_id)
     {
-	DBG ("Blink source stopped: %d", wl->blink_timeout_id);
-	g_source_remove (wl->blink_timeout_id);
-	wl->blink_timeout_id = 0;
+        DBG ("Blink source stopped: %d", wl->blink_timeout_id);
+        g_source_remove (wl->blink_timeout_id);
+        wl->blink_timeout_id = 0;
     }
-    
+
     /* force normal button normal */
     wl->blink = FALSE;
-    
+
     if (wl->notify != DISABLED)
     {
-	wl->search_timeout_id =
-		g_timeout_add (SEARCH_TIMEOUT, windowlist_search_urgent, wl);
-	
-	DBG ("New search source started: %d", wl->search_timeout_id);
-	
-	windowlist_search_urgent (wl);
+        wl->search_timeout_id =
+            g_timeout_add (SEARCH_TIMEOUT, windowlist_search_urgent, wl);
+
+        DBG ("New search source started: %d", wl->search_timeout_id);
+
+        windowlist_search_urgent (wl);
     }
-    
+
     /* Make sure button is normal */
     windowlist_blink (wl);
 }
 
+
+
 /**
  * Button functions
  **/
@@ -812,14 +805,14 @@
 windowlist_blink (gpointer data)
 {
     Windowlist * wl = (Windowlist *) data;
-    
+
     GtkStyle *style;
     GtkRcStyle *mod;
     GdkColor c;
-    
+
     g_return_val_if_fail (wl, FALSE);
     g_return_val_if_fail (wl->button, FALSE);
-    
+
     style = gtk_widget_get_style (wl->button);
     mod = gtk_widget_get_modifier_style (wl->button);
     c = style->bg[GTK_STATE_SELECTED];
@@ -827,11 +820,11 @@
     if(wl->blink && !wl->block_blink)
     {
         /* Paint the button */
-	
-	gtk_button_set_relief (GTK_BUTTON (wl->button),
-				GTK_RELIEF_NORMAL);
-	
-	if(mod->color_flags[GTK_STATE_NORMAL] & GTK_RC_BG)
+
+        gtk_button_set_relief (GTK_BUTTON (wl->button),
+                GTK_RELIEF_NORMAL);
+
+        if(mod->color_flags[GTK_STATE_NORMAL] & GTK_RC_BG)
         {
             mod->color_flags[GTK_STATE_NORMAL] &= ~(GTK_RC_BG);
             gtk_widget_modify_style(wl->button, mod);
@@ -845,50 +838,54 @@
     }
     else
     {
-	if (!wl->blink)
-	    gtk_button_set_relief (GTK_BUTTON (wl->button),
-				GTK_RELIEF_NONE);
-	
-	mod->color_flags[GTK_STATE_NORMAL] &= ~(GTK_RC_BG);
-	gtk_widget_modify_style(wl->button, mod);
+        if (!wl->blink)
+            gtk_button_set_relief (GTK_BUTTON (wl->button),
+                                   GTK_RELIEF_NONE);
+
+        mod->color_flags[GTK_STATE_NORMAL] &= ~(GTK_RC_BG);
+        gtk_widget_modify_style(wl->button, mod);
     }
-    
+
     return wl->blink;
 }
 
+
+
 /**
  * This will block the blink function on mouse over
  **/
 static void
 windowlist_state_changed (GtkWidget *button,
-			  GtkStateType state,
-			  Windowlist * wl)
+                          GtkStateType state,
+                          Windowlist * wl)
 {
     if (G_LIKELY(wl->notify == DISABLED || wl->blink == FALSE))
-	return;
-    
+        return;
+
     DBG ("Button State changed");
-    
+
     if (GTK_WIDGET_STATE (button) == 0)
-	wl->block_blink = FALSE;
-    
+        wl->block_blink = FALSE;
+
     else   
     {
-	wl->block_blink = TRUE;
-	windowlist_blink (wl);
+        wl->block_blink = TRUE;
+        windowlist_blink (wl);
     }
 }
 
+
+
 /**
  *
  **/
 static void
-windowlist_active_window_changed (GtkWidget * w,
-				  Windowlist * wl)
+windowlist_active_window_changed (GtkWidget  *w,
+                                  Windowlist *wl)
 {
     NetkWindow *win;
-    GdkPixbuf *pb;
-    
+    GdkPixbuf  *pb;
+
     if ((win = netk_screen_get_active_window (wl->screen)) != NULL)
     {
         pb = netk_window_get_icon (win);
@@ -902,11 +899,15 @@
     }
 }
 
+
+
 /**
  * Handle user messages
  **/
 static gboolean
-wl_message_received (GtkWidget *w, GdkEventClient *ev, gpointer user_data)
+wl_message_received (GtkWidget      *w, 
+                     GdkEventClient *ev, 
+                     gpointer        user_data)
 {
     Windowlist *wl = user_data;
 
@@ -922,14 +923,16 @@
     return FALSE;
 }
 
+
+
 static gboolean
 wl_set_selection (Windowlist *wl)
 {
     GdkScreen *gscreen;
-    gchar selection_name[32];
-    Atom selection_atom;
+    gchar      selection_name[32];
+    Atom       selection_atom;
     GtkWidget *win;
-    Window xwin;
+    Window     xwin;
 
     win = gtk_invisible_new ();
     gtk_widget_realize (win);
@@ -951,75 +954,93 @@
 
     g_signal_connect (G_OBJECT (win), "client-event",
                       G_CALLBACK (wl_message_received), wl);
-    
+
     return TRUE;
 }
 
+
+
 /**
+ * When the arrow is about to be drawn, set its orientation
+ **/
+static void
+windowlist_init_arrow (GtkWidget      *button, 
+                       GdkEventExpose *event,
+                       Windowlist     *wl)
+{
+    windowlist_update_arrow_type (wl);
+    g_signal_handlers_disconnect_by_func (G_OBJECT (button), 
+            G_CALLBACK (windowlist_init_arrow), 
+            wl);
+}
+
+
+
+/**
  * Build the panel button and connect signals and styles
  **/
 void
-windowlist_create_button (Windowlist * wl)
+windowlist_create_button (Windowlist *wl)
 {
     GdkPixbuf *pb;
-    
+
     if (wl->button)
-	gtk_widget_destroy (wl->button);
-    
+        gtk_widget_destroy (wl->button);
+
     if (wl->screen_callback_id)
     {
-	g_signal_handler_disconnect (wl->screen, wl->screen_callback_id);
-	wl->screen_callback_id = 0;
+        g_signal_handler_disconnect (wl->screen, wl->screen_callback_id);
+        wl->screen_callback_id = 0;
     }
-    
+
     switch (wl->layout)
     {
-	case ICON_BUTTON:
-	    DBG ("Create Icon Button");
-	    
-	    wl->button = gtk_toggle_button_new ();
-	    
-	    pb = gtk_widget_render_icon (GTK_WIDGET (wl->plugin),
-					 GTK_STOCK_MISSING_IMAGE,
-					 GTK_ICON_SIZE_MENU, NULL);
-	    wl->icon = xfce_scaled_image_new_from_pixbuf (pb);
-	    gtk_container_add (GTK_CONTAINER (wl->button), wl->icon);
-	    g_object_unref (G_OBJECT (pb));
-	
-	    wl->screen_callback_id =
-		g_signal_connect (wl->screen, "active-window-changed",
-                          G_CALLBACK (windowlist_active_window_changed), wl);
-	
-	    windowlist_active_window_changed (wl->button,
-					      wl);
-	    
-	    break;
-	
-	case ARROW_BUTTON:
-	    DBG ("Create Arrow Button");
-	    
-	    wl->button = xfce_arrow_button_new (GTK_ARROW_UP);
-	
-	    xfce_arrow_button_set_arrow_type (
-		XFCE_ARROW_BUTTON (wl->button), wl->arrowtype);
-	
-	    break;
+        case ICON_BUTTON:
+            DBG ("Create Icon Button");
+
+            wl->button = gtk_toggle_button_new ();
+
+            pb = gtk_widget_render_icon (GTK_WIDGET (wl->plugin),
+                                         GTK_STOCK_MISSING_IMAGE,
+                                         GTK_ICON_SIZE_MENU, NULL);
+            wl->icon = xfce_scaled_image_new_from_pixbuf (pb);
+            gtk_container_add (GTK_CONTAINER (wl->button), wl->icon);
+            g_object_unref (G_OBJECT (pb));
+
+            wl->screen_callback_id =
+                g_signal_connect (wl->screen, "active-window-changed",
+                                  G_CALLBACK (windowlist_active_window_changed), wl);
+
+            windowlist_active_window_changed (wl->button, wl);
+
+            break;
+
+        case ARROW_BUTTON:
+            DBG ("Create Arrow Button");
+
+            wl->arrowtype = GTK_ARROW_NONE;
+            wl->button = xfce_arrow_button_new (GTK_ARROW_NONE);
+
+            break;
     }
 
+    g_signal_connect (G_OBJECT (wl->button), "expose-event", 
+                      G_CALLBACK (windowlist_init_arrow), wl);
+
     /* Button layout */
     GTK_WIDGET_UNSET_FLAGS (wl->button, GTK_CAN_DEFAULT|GTK_CAN_FOCUS);
     gtk_button_set_relief (GTK_BUTTON (wl->button), GTK_RELIEF_NONE);
     gtk_button_set_focus_on_click (GTK_BUTTON (wl->button), FALSE);
-    
+
     /* Set the button sizes again */
     windowlist_set_size (wl->plugin,
-			 xfce_panel_plugin_get_size (wl->plugin),
-			 wl);
-    
+                         xfce_panel_plugin_get_size (wl->plugin),
+                         wl);
+
     /* Show, add and connect signals */
     g_signal_connect (wl->button, "button-press-event",
                       G_CALLBACK (menulist_toggle_menu), wl);
-    
+
     g_signal_connect (wl->button, "state-changed",
                       G_CALLBACK (windowlist_state_changed), wl);
 
@@ -1027,222 +1048,203 @@
 
     gtk_widget_show_all (wl->button);
     gtk_container_add (GTK_CONTAINER (wl->plugin), wl->button);
-    
+
     /* Add action widget */
     xfce_panel_plugin_add_action_widget (wl->plugin, wl->button);
 }
 
+
+
 /**
  * Arrow type functions
  **/
-static GtkArrowType
-calculate_floating_arrow_type (XfcePanelPlugin * plugin,
-			       XfceScreenPosition position)
+static void
+windowlist_update_arrow_type (Windowlist *wl)
 {
-    GtkWidget *widget = GTK_WIDGET (plugin);
-    GtkArrowType type = GTK_ARROW_UP;
-    int mon, x, y;
-    GdkScreen *screen;
-    GdkRectangle geom;
-    
-    if (!GTK_WIDGET_REALIZED (widget))
-    {
-        if (xfce_screen_position_is_horizontal (position))
-            return GTK_ARROW_UP;
-        else
-            return GTK_ARROW_LEFT;
-    }
+    GtkArrowType type = GTK_ARROW_NONE;
 
-    screen = gtk_widget_get_screen (widget);
-    mon = gdk_screen_get_monitor_at_window (screen, 
-                                            widget->window);
-    gdk_screen_get_monitor_geometry (screen, mon, &geom);
-    gdk_window_get_root_origin (widget->window, &x, &y);
-    
-    if (xfce_screen_position_is_horizontal (position))
-    {
-        if (y > geom.y + geom.height / 2)
-	    type = GTK_ARROW_UP;
-        else
-	    type = GTK_ARROW_DOWN;
-    }
-    else
-    {
-        if (x > geom.x + geom.width / 2)
-	    type = GTK_ARROW_LEFT;
-	else
-	    type = GTK_ARROW_RIGHT;
-    }
+    if (!GTK_IS_WIDGET (wl->button))
+        return;
 
-    return type;
+    type = 
+        xfce_panel_plugin_popup_direction (XFCE_PANEL_PLUGIN (wl->plugin),
+                                           GTK_WIDGET (wl->button));
+    if (type != GTK_ARROW_NONE)
+        windowlist_set_arrow_type (wl, type);
 }
 
-static GtkArrowType
-windowlist_arrow_type (XfcePanelPlugin * plugin)
+
+
+static void
+windowlist_set_arrow_type (Windowlist   *wl, 
+                           GtkArrowType  new_arrow_type)
 {
-    GtkArrowType type = GTK_ARROW_UP;
-    XfceScreenPosition position = xfce_panel_plugin_get_screen_position (plugin);
-    
-    if (xfce_screen_position_is_floating (position))
-	type = calculate_floating_arrow_type (plugin, position);
-    
-    else if (xfce_screen_position_is_top (position))
-	type = GTK_ARROW_DOWN;
-    
-    else if (xfce_screen_position_is_left (position))
-	type = GTK_ARROW_RIGHT;
-    
-    else if (xfce_screen_position_is_right (position))
-	type = GTK_ARROW_LEFT;
-    
-    else if (xfce_screen_position_is_bottom (position))
-	type = GTK_ARROW_UP;
-    
-    return type;
+    g_return_if_fail (wl->button != NULL);
+
+    if (new_arrow_type == GTK_ARROW_NONE || new_arrow_type == wl->arrowtype)
+        return;
+
+    wl->arrowtype = new_arrow_type;
+
+    if (wl->layout == ARROW_BUTTON)
+    {
+        xfce_arrow_button_set_arrow_type (XFCE_ARROW_BUTTON (wl->button),
+                                          wl->arrowtype);
+
+        windowlist_set_size (wl->plugin,
+                             xfce_panel_plugin_get_size (wl->plugin),
+                             wl);
+    }
 }
 
+
+
 /**
  * Read and write user settings
  **/
 static void
-windowlist_read (Windowlist * wl)
+windowlist_read (Windowlist *wl)
 {
     XfceRc *rc;
     gchar  *file;
-    
+
     if (!(file = xfce_panel_plugin_lookup_rc_file (wl->plugin)))
-	return;
-    
+        return;
+
     DBG("Read from file: %s", file);
 
     rc = xfce_rc_simple_open (file, TRUE);
     g_free (file);
-    
+
     if (!rc)
         return;
-    
+
     switch (xfce_rc_read_int_entry (rc, "button_layout", DEF_BUTTON_LAYOUT))
     {
-	case 0: 
-	    wl->layout = ICON_BUTTON;
-	    break;
-	
-	default: 
-	    wl->layout = ARROW_BUTTON;
-	    break;
+        case 0: 
+            wl->layout = ICON_BUTTON;
+            break;
+
+        default: 
+            wl->layout = ARROW_BUTTON;
+            break;
     }
-    
+
     switch (xfce_rc_read_int_entry (rc, "urgency_notify", DEF_NOTIFY))
     {
-	case 0: 
-	    wl->notify = DISABLED;
-	    break;
-	
-	case 1:
-	    wl->notify = OTHER_WORKSPACES;
-	    break;
-	
-	default: 
-	    wl->notify = ALL_WORKSPACES;
-	    break;
+        case 0: 
+            wl->notify = DISABLED;
+            break;
+
+        case 1:
+            wl->notify = OTHER_WORKSPACES;
+            break;
+
+        default: 
+            wl->notify = ALL_WORKSPACES;
+            break;
     }
-    
+
     wl->show_all_workspaces = 
-	xfce_rc_read_bool_entry (rc, "show_all_workspaces",	
+        xfce_rc_read_bool_entry (rc, "show_all_workspaces",	
                                  DEF_SHOW_ALL_WORKSPACES);
     wl->show_window_icons = 
-	xfce_rc_read_bool_entry (rc, "show_window_icons",	
+        xfce_rc_read_bool_entry (rc, "show_window_icons",	
                                  DEF_SHOW_WINDOW_ICONS);
     wl->show_workspace_actions = 
-	xfce_rc_read_bool_entry (rc, "show_workspace_actions",	
+        xfce_rc_read_bool_entry (rc, "show_workspace_actions",	
                                  DEF_SHOW_WORKSPACE_ACTIONS);
-    
+
     xfce_rc_close (rc);
 }
 
+
+
 static void
-windowlist_write (XfcePanelPlugin * plugin,
-		  Windowlist * wl)
+windowlist_write (XfcePanelPlugin *plugin,
+                  Windowlist      *wl)
 {
     XfceRc *rc;
     gchar  *file;
-    
+
     if (!(file = xfce_panel_plugin_save_location (wl->plugin, TRUE)))
-	return;
-    
+        return;
+
     DBG("Write to file: %s", file);
-    
+
     rc = xfce_rc_simple_open (file, FALSE);
     g_free (file);
-    
+
     if (!rc)
         return;
-    
+
     switch (wl->layout)
     {
-	case ICON_BUTTON:
-	    xfce_rc_write_int_entry (rc, "button_layout", 0);
-	    break;
-	
-	case ARROW_BUTTON:
-	    xfce_rc_write_int_entry (rc, "button_layout", 1);
-	    break;
+        case ICON_BUTTON:
+            xfce_rc_write_int_entry (rc, "button_layout", 0);
+            break;
+
+        case ARROW_BUTTON:
+            xfce_rc_write_int_entry (rc, "button_layout", 1);
+            break;
     }
-    
+
     switch (wl->notify)
     {
-	case DISABLED:
-	    xfce_rc_write_int_entry (rc, "urgency_notify", 0);
-	    break;
-	
-	case OTHER_WORKSPACES:
-	    xfce_rc_write_int_entry (rc, "urgency_notify", 1);
-	    break;
-	
-	case ALL_WORKSPACES:
-	    xfce_rc_write_int_entry (rc, "urgency_notify", 2);
-	    break;
+        case DISABLED:
+            xfce_rc_write_int_entry (rc, "urgency_notify", 0);
+            break;
+
+        case OTHER_WORKSPACES:
+            xfce_rc_write_int_entry (rc, "urgency_notify", 1);
+            break;
+
+        case ALL_WORKSPACES:
+            xfce_rc_write_int_entry (rc, "urgency_notify", 2);
+            break;
     }
-    
+
     xfce_rc_write_bool_entry (rc, "show_all_workspaces",	
                               wl->show_all_workspaces);
     xfce_rc_write_bool_entry (rc, "show_window_icons",		
                               wl->show_window_icons);
     xfce_rc_write_bool_entry (rc, "show_workspace_actions",	
                               wl->show_workspace_actions);
-    
+
     xfce_rc_close (rc);
 }
 
+
+
 /**
  * Initialize plugin
  **/
 static Windowlist *
-windowlist_new (XfcePanelPlugin * plugin)
+windowlist_new (XfcePanelPlugin *plugin)
 {
     GdkScreen *screen;
     int screen_idx;
-    
+
     Windowlist *wl = panel_slice_new0 (Windowlist);
-    
+
     /* Some default values if everything goes wrong */
     wl->layout			= DEF_BUTTON_LAYOUT;
     wl->show_all_workspaces	= DEF_SHOW_ALL_WORKSPACES;
     wl->show_window_icons	= DEF_SHOW_WINDOW_ICONS;
     wl->show_workspace_actions	= DEF_SHOW_WORKSPACE_ACTIONS;
     wl->notify			= DEF_NOTIFY;
-    
+
     /* Reset */
     wl->screen_callback_id = 0;
-    
+
     /* Reset Urgency Stuff */
     wl->search_timeout_id = 0;
     wl->blink_timeout_id = 0;
     wl->blink = FALSE;
     wl->block_blink = FALSE;
-    
+
     wl->plugin = plugin;
-    
+
     wl->tooltips = gtk_tooltips_new ();
     g_object_ref (G_OBJECT (wl->tooltips));
     gtk_object_sink (GTK_OBJECT (wl->tooltips));
@@ -1250,138 +1252,138 @@
     /* get the screen where the widget is, for dual screen */
     screen = gtk_widget_get_screen (GTK_WIDGET (plugin));
     screen_idx = gdk_screen_get_number (screen);
-    
+
     wl->screen = netk_screen_get (screen_idx);
-    
+
     /* Read user settings */
     windowlist_read (wl);
-    
-    /* Read arrow type, this is also used for the popup function */
-    wl->arrowtype = windowlist_arrow_type (wl->plugin);
-    
+
     /* Build the panel button */
+
     windowlist_create_button (wl);
-    
+
     return wl;
 }
 
+
+
 /**
  * Common plugin functions
  **/
 static gboolean
 windowlist_set_size (XfcePanelPlugin *plugin,
-		     int size,
-		     Windowlist * wl)
+                     int              size,
+                     Windowlist      *wl)
 {
     DBG ("Size: %d", size);
-    
+
     switch (wl->layout)
     {
-	case ICON_BUTTON:
-	    gtk_widget_set_size_request (GTK_WIDGET (wl->button),
-					 size, size);
-	    break;
-	
-	case ARROW_BUTTON:
-	    switch (wl->arrowtype)
-	    {
-		case GTK_ARROW_LEFT:
-		case GTK_ARROW_RIGHT:
-		    gtk_widget_set_size_request (GTK_WIDGET (wl->button),
-					 size, ARROW_WIDTH);
-		    break;
-		    
-		case GTK_ARROW_UP:
-		case GTK_ARROW_DOWN:
-		    gtk_widget_set_size_request (GTK_WIDGET (wl->button),
-					 ARROW_WIDTH, size);
-		    break;
+        case ICON_BUTTON:
+            gtk_widget_set_size_request (GTK_WIDGET (wl->button),
+                    size, size);
+            break;
+
+        case ARROW_BUTTON:
+            switch (xfce_panel_plugin_get_orientation (wl->plugin))
+            {
+                case GTK_ORIENTATION_VERTICAL:
+                    gtk_widget_set_size_request (GTK_WIDGET (wl->button),
+                            size, ARROW_WIDTH);
+                    break;
+
+                case GTK_ORIENTATION_HORIZONTAL:
+                    gtk_widget_set_size_request (GTK_WIDGET (wl->button),
+                            ARROW_WIDTH, size);
+                    break;
                 default:
                     break;
-	    }
-	    break;
+            }
+            break;
+
     }
-    
+
     return TRUE;
 }
 
+
+
 static void
-windowlist_free (XfcePanelPlugin * plugin,
-		 Windowlist * wl)
+windowlist_free (XfcePanelPlugin *plugin,
+                 Windowlist      *wl)
 {
     g_object_unref (G_OBJECT (wl->tooltips));
-    
+
     if (wl->screen_callback_id)
-	g_signal_handler_disconnect (wl->screen, wl->screen_callback_id);
-    
+        g_signal_handler_disconnect (wl->screen, wl->screen_callback_id);
+
     if (wl->search_timeout_id)
     {
-	DBG ("Stop urgent source: %d", wl->search_timeout_id);
-	g_source_remove (wl->search_timeout_id);
-	wl->search_timeout_id = 0;
+        DBG ("Stop urgent source: %d", wl->search_timeout_id);
+        g_source_remove (wl->search_timeout_id);
+        wl->search_timeout_id = 0;
     }
-    
+
     if (wl->blink_timeout_id)
     {
-	DBG ("Stop blink source: %d", wl->blink_timeout_id);
-	g_source_remove (wl->blink_timeout_id);
-	wl->blink_timeout_id = 0;
+        DBG ("Stop blink source: %d", wl->blink_timeout_id);
+        g_source_remove (wl->blink_timeout_id);
+        wl->blink_timeout_id = 0;
     }
-    
+
     if (wl->icon)
-	gtk_widget_destroy (wl->icon);
-    
+        gtk_widget_destroy (wl->icon);
+
     if (wl->button)
-	gtk_widget_destroy (wl->button);
-    
+        gtk_widget_destroy (wl->button);
+
     panel_slice_free (Windowlist, wl);
 }
 
+
+
 static void
-windowlist_screen_position_changed (XfcePanelPlugin *plugin, 
-                                  XfceScreenPosition position, 
-                                  Windowlist * wl)
+windowlist_screen_position_changed (XfcePanelPlugin    *plugin, 
+                                    XfceScreenPosition  position, 
+                                    Windowlist         *wl)
 {
     DBG ("...");
-    
-    wl->arrowtype = windowlist_arrow_type (plugin);
-    
-    if (wl->layout == ARROW_BUTTON)
-	xfce_arrow_button_set_arrow_type (
-		XFCE_ARROW_BUTTON (wl->button), wl->arrowtype);
+
+    windowlist_update_arrow_type (wl);
+
 }
 
+
+
 static void
 windowlist_orientation_changed (XfcePanelPlugin *plugin, 
-                                GtkOrientation orientation, 
-                                Windowlist * wl)
+                                GtkOrientation   orientation,
+                                Windowlist      *wl)
 {
     DBG ("...");
-    
-    wl->arrowtype = windowlist_arrow_type (plugin);
-    
-    if (wl->layout == ARROW_BUTTON)
-	xfce_arrow_button_set_arrow_type (
-		XFCE_ARROW_BUTTON (wl->button), wl->arrowtype);
+
+    windowlist_update_arrow_type (wl);
 }
 
+
+
 /**
  * Construct plugin
  **/
 static void
-windowlist_construct (XfcePanelPlugin * plugin)
+windowlist_construct (XfcePanelPlugin *plugin)
 {
     Windowlist *wl = windowlist_new (plugin);
-    
+
     g_signal_connect (plugin, "free-data",
                       G_CALLBACK (windowlist_free), wl);
 
     g_signal_connect (plugin, "save",
                       G_CALLBACK (windowlist_write), wl);
-    
+
     g_signal_connect (plugin, "size-changed", 
                       G_CALLBACK (windowlist_set_size), wl);
-    
+
     g_signal_connect (plugin, "screen-position-changed", 
                       G_CALLBACK (windowlist_screen_position_changed), wl);
 
@@ -1392,7 +1394,8 @@
     g_signal_connect (plugin, "configure-plugin",
                       G_CALLBACK (windowlist_properties), wl);
 
-    
+
     /* Start Urgency Search (if enabled ^_^) */
     windowlist_start_blink (wl);
 }
+



More information about the Xfce4-commits mailing list