Author: jasper
Date: 2007-09-30 18:14:31 +0000 (Sun, 30 Sep 2007)
New Revision: 26118
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:
* libxfce4panel/xfce-panel-plugin-iface.c,
libxfce4panel/xfce-panel-plugin-iface.h,
plugins/launcher/launcher.c,
plugins/windowlist/windowlist.c: API change for popup menu functions.
The API now consists of three functions:
xfce_panel_plugin_arrow_type(), xfce_panel_plugin_position_widget(),
and xfce_panel_plugin_menu_position_func(). This last function is
intended to be used as a callback function for gtk_menu_popup().
* plugins/windowlist/windowlist.c: Remove orientation change handler.
There is no need to check both for orientation changes and screen
position changes.
* plugins/windowlist/windowlist.c: Set size for plugin widget instead
of button. The size is not properly updated on orientation changes
otherwise.
Modified: xfce4-panel/trunk/ChangeLog
===================================================================
--- xfce4-panel/trunk/ChangeLog 2007-09-30 08:54:55 UTC (rev 26117)
+++ xfce4-panel/trunk/ChangeLog 2007-09-30 18:14:31 UTC (rev 26118)
@@ -1,4 +1,22 @@
+2007-09-30 20:14 jasper
+
+ * libxfce4panel/xfce-panel-plugin-iface.c,
+ libxfce4panel/xfce-panel-plugin-iface.h,
+ plugins/launcher/launcher.c,
+ plugins/windowlist/windowlist.c: API change for popup menu functions.
+ The API now consists of three functions:
+ xfce_panel_plugin_arrow_type(), xfce_panel_plugin_position_widget(),
+ and xfce_panel_plugin_menu_position_func(). This last function is
+ intended to be used as a callback function for gtk_menu_popup().
+ * plugins/windowlist/windowlist.c: Remove orientation change handler.
+ There is no need to check both for orientation changes and screen
+ position changes.
+ * plugins/windowlist/windowlist.c: Set size for plugin widget instead
+ of button. The size is not properly updated on orientation changes
+ otherwise.
+
2007-09-28 13:46 jasper
+
* libxfce4panel/xfce-panel-plugin-iface.c,
libxfce4panel/xfce-panel-plugin-iface.h,
plugins/launcher/launcher.c,
@@ -8,27 +26,27 @@
2007-07-09 22:45 nick
- * libxfce4panel/*, docs/API/*: Remove the html and xml directories,
- those are generated by gtk-doc, 100% symbol coverage and improve
- the layout of the chapters.
+ * libxfce4panel/*, docs/API/*: Remove the html and xml directories,
+ those are generated by gtk-doc, 100% symbol coverage and improve
+ the layout of the chapters.
2007-07-08 12:00 nick
- * plugins/clock/clock-digital.c: Allow markup and center the string.
- * plugins/clock/*: Move the localtime functions into 1 util and allow
- usage without locatime_r.
+ * plugins/clock/clock-digital.c: Allow markup and center the string.
+ * plugins/clock/*: Move the localtime functions into 1 util and allow
+ usage without locatime_r.
2007-07-07 10:32 nick
- * plugins/clock/clock-lcd.c: Typo, the 8 was test code.
+ * plugins/clock/clock-lcd.c: Typo, the 8 was test code.
2007-07-06 10:50 nick
- * plugins/clock/*: Import code.
- * NEWS: update.
- * Configure.in.in: Bump GTK dependency to 2.8.0 and add cairo as
- new dependency.
- * po/*: Merge new strings.
+ * plugins/clock/*: Import code.
+ * NEWS: update.
+ * Configure.in.in: Bump GTK dependency to 2.8.0 and add cairo as
+ new dependency.
+ * po/*: Merge new strings.
2007-05-27 10:50 nick
Modified: xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c
===================================================================
--- xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c 2007-09-30
08:54:55 UTC (rev 26117)
+++ xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.c 2007-09-30
18:14:31 UTC (rev 26118)
@@ -1259,269 +1259,215 @@
GINT_TO_POINTER (sensitive));
}
+
+
/* user menus & popups */
/**
- * xfce_panel_plugin_position_popup
+ * xfce_panel_plugin_arrow_type:
* @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.
+ *
+ * Determine the #GtkArrowType for a widget that opens a menu and uses
+ * xfce_panel_plugin_position_menu() to position the menu.
+ *
+ * Returns: The #GtkArrowType to use.
**/
GtkArrowType
-xfce_panel_plugin_position_popup (XfcePanelPlugin *plugin,
- GtkWidget *attach_widget,
- GtkRequisition *req,
- gint *x,
- gint *y)
+xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin)
{
- GtkArrowType direction = GTK_ARROW_NONE;
- GtkAllocation *attach;
- GdkScreen *screen;
- GdkRectangle geom;
- gint trash_x;
- gint trash_y;
- gint num;
+ XfceScreenPosition position;
+ GdkScreen *screen;
+ GdkRectangle geom;
+ gint mon, x, y;
- 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 (!GTK_WIDGET_REALIZED (plugin))
+ return GTK_ARROW_UP;
- 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))
+ position = xfce_panel_plugin_get_screen_position (plugin);
+ switch (position)
{
- case GTK_ORIENTATION_HORIZONTAL:
+ /* top */
+ case XFCE_SCREEN_POSITION_NW_H:
+ case XFCE_SCREEN_POSITION_N:
+ case XFCE_SCREEN_POSITION_NE_H:
+ return GTK_ARROW_DOWN;
- 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;
+ /* left */
+ case XFCE_SCREEN_POSITION_NW_V:
+ case XFCE_SCREEN_POSITION_W:
+ case XFCE_SCREEN_POSITION_SW_V:
+ return GTK_ARROW_RIGHT;
- case GTK_ORIENTATION_VERTICAL:
+ /* right */
+ case XFCE_SCREEN_POSITION_NE_V:
+ case XFCE_SCREEN_POSITION_E:
+ case XFCE_SCREEN_POSITION_SE_V:
+ return GTK_ARROW_LEFT;
- 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;
+ /* bottom */
+ case XFCE_SCREEN_POSITION_SW_H:
+ case XFCE_SCREEN_POSITION_S:
+ case XFCE_SCREEN_POSITION_SE_H:
+ return GTK_ARROW_UP;
+ /* floating */
default:
- break;
+ /* get the screen information */
+ screen = gtk_widget_get_screen (GTK_WIDGET (plugin));
+ mon = gdk_screen_get_monitor_at_window (screen, GTK_WIDGET
(plugin)->window);
+ gdk_screen_get_monitor_geometry (screen, mon, &geom);
+ gdk_window_get_root_origin (GTK_WIDGET (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);
}
+}
- /* 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
+ * xfce_panel_plugin_position_widget:
* @plugin : an #XfcePanelPlugin
- * @attach_widget : a #GtkWidget associated with the menu/popup
+ * @menu_widget : a #GtkWidget that will be used as popup menu
+ * @attach_widget : a #GtkWidget relative to which the menu should be
positioned
+ * @x : return location for the x coordinate
+ * @y : return location for the y coordinate
*
- * 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.
+ * The menu widget is positioned relative to the plugin. This function is
+ * intended for custom menu widgets.
*
- * @attach_widget needs to have its x and y coordinates already set.
+ * For a regular #GtkMenu you should use xfce_panel_plugin_position_menu()
+ * instead (as callback argument to gtk_menu_popup()).
*
- * 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.
+ * See also: xfce_panel_plugin_position_menu().
**/
-GtkArrowType
-xfce_panel_plugin_popup_direction (XfcePanelPlugin *plugin,
- GtkWidget *attach_widget)
+void
+xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin,
+ GtkWidget *menu_widget,
+ GtkWidget *attach_widget,
+ gint *x,
+ gint *y)
{
- GtkArrowType direction;
GtkRequisition req;
+ GdkScreen *screen;
+ GdkRectangle geom;
+ gint mon;
- /* these values are fairly arbitrary, but consistency is what matters most
*/
- req.width = 100;
- req.height = 200;
+ g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+ g_return_if_fail (GTK_IS_WIDGET (menu_widget));
+ g_return_if_fail (GTK_IS_WIDGET (attach_widget));
- direction = xfce_panel_plugin_position_popup (plugin,
- attach_widget,
- &req,
- NULL, NULL);
+ if (!GTK_WIDGET_REALIZED (menu_widget))
+ gtk_widget_realize (menu_widget);
- return direction;
-}
+ gtk_widget_size_request (menu_widget, &req);
+ gdk_window_get_origin (attach_widget->window, x, y);
-#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))
+ switch (xfce_panel_plugin_arrow_type (plugin))
+ {
+ case GTK_ARROW_UP:
+ *y -= req.height;
+ break;
-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;
+ case GTK_ARROW_DOWN:
+ *y += attach_widget->allocation.height;
+ break;
- g_return_if_fail (GTK_IS_MENU (menu));
- g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+ case GTK_ARROW_LEFT:
+ *x -= req.width;
+ break;
- attach_widget = gtk_menu_get_attach_widget (menu);
- g_return_if_fail (GTK_IS_WIDGET (attach_widget));
+ default: /* GTK_ARROW_RIGHT and GTK_ARROW_NONE */
+ *x += attach_widget->allocation.width;
+ break;
+ }
- if (!GTK_WIDGET_REALIZED (GTK_WIDGET (menu)))
- gtk_widget_realize (GTK_WIDGET (menu));
+ screen = gtk_widget_get_screen (attach_widget);
+ mon = gdk_screen_get_monitor_at_window (screen, attach_widget->window);
+ gdk_screen_get_monitor_geometry (screen, mon, &geom);
- /* NULL indicates use the attach widget's screen */
- gtk_menu_set_screen (menu, NULL);
+ /* 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;
- gtk_widget_size_request (GTK_WIDGET (menu), &req);
+ if (G_LIKELY (GTK_IS_MENU (menu_widget)))
+ gtk_menu_set_screen (GTK_MENU (menu_widget), screen);
+ else if (GTK_IS_WINDOW (menu_widget))
+ gtk_window_set_screen (GTK_WINDOW (menu_widget), screen);
+}
- 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
+ * xfce_panel_plugin_position_menu:
+ * @menu : a #GtkMenu
+ * @x : return location for the x coordinate
+ * @y : return location for the y coordinate
+ * @push_in : keep inside the screen (see #GtkMenuPositionFunc)
+ * @panel_plugin : a pointer to an #XfcePanelPlugin
*
- * This is a wrapper around gtk_menu_popup().
+ * Function to be used as #GtkMenuPositionFunc in a call to gtk_menu_popup().
+ * As data argument it needs an #XfcePanelPlugin.
*
- * It will call xfce_panel_plugin_register_menu() for you, so don't do that
- * again in the plugin code.
+ * The menu is normally positioned relative to @attach_widget. If you want the
+ * menu to be positioned relative to another widget, you can use
+ * gtk_menu_attach_to_widget() to explicitly set a 'parent' widget.
*
- * 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.
+ * As a convenience, xfce_panel_plugin_position_menu() calls
+ * xfce_panel_plugin_register_menu() for the menu.
*
- * If you do not set the attach widget, the menu will be positioned
- * on your mouse cursor (GTK default behavior).
+ * <example>
+ * void
+ * myplugin_popup_menu (XfcePanelPlugin *plugin,
+ * GtkMenu *menu,
+ * GdkEventButton *ev)
+ * {
+ * gtk_menu_popup (menu, NULL, NULL,
+ * xfce_panel_plugin_position_menu, plugin,
+ * ev->button, ev->time );
+ * }
+ * </example>
*
- * See also: xfce_panel_plugin_position_popup().
+ * For a custom widget that will be used as a popup menu, use
+ * xfce_panel_plugin_position_widget() instead.
*
- * Returns: The direction in which the menu opened relative to the attached
- * widget, or GTK_ARROW_NONE.
+ * See also: gtk_menu_popup().
**/
-GtkArrowType
-xfce_panel_plugin_menu_popup (XfcePanelPlugin *plugin,
- GtkMenu *menu,
- gint button,
- guint32 time)
+void
+xfce_panel_plugin_position_menu (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer panel_plugin)
{
- GtkWidget *attach_widget;
- gpointer _direction;
+ XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (panel_plugin);
+ GtkWidget *attach_widget;
- if (!XFCE_IS_PANEL_PLUGIN (plugin) ||
- !GTK_IS_MENU (menu) ||
- GTK_WIDGET_VISIBLE (menu))
- {
- /* we shouldn't be here */
- return GTK_ARROW_NONE;
- }
+ if ((attach_widget = gtk_menu_get_attach_widget (menu)) == NULL)
+ attach_widget = GTK_WIDGET (plugin);
- xfce_panel_plugin_register_menu (plugin, menu);
+ xfce_panel_plugin_position_widget (plugin,
+ GTK_WIDGET (menu),
+ attach_widget,
+ x, y);
- 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);
+ /* keep inside screen */
+ *push_in = TRUE;
- _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;
- }
+ xfce_panel_plugin_register_menu (plugin, menu);
}
+
+
#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-30
08:54:55 UTC (rev 26117)
+++ xfce4-panel/trunk/libxfce4panel/xfce-panel-plugin-iface.h 2007-09-30
18:14:31 UTC (rev 26118)
@@ -109,17 +109,17 @@
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,
+GtkArrowType xfce_panel_plugin_arrow_type (XfcePanelPlugin
*plugin);
+void xfce_panel_plugin_position_widget (XfcePanelPlugin
*plugin,
+ GtkWidget
*menu_widget,
+ GtkWidget
*attach_widget,
+ gint
*x,
gint
*y);
+void xfce_panel_plugin_position_menu (GtkMenu
*menu,
+ gint
*x,
+ gint
*y,
+ gboolean
*push_in,
+ gpointer
panel_plugin);
gchar *xfce_panel_plugin_lookup_rc_file (XfcePanelPlugin
*plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
Modified: xfce4-panel/trunk/plugins/launcher/launcher.c
===================================================================
--- xfce4-panel/trunk/plugins/launcher/launcher.c 2007-09-30 08:54:55 UTC
(rev 26117)
+++ xfce4-panel/trunk/plugins/launcher/launcher.c 2007-09-30 18:14:31 UTC
(rev 26118)
@@ -42,9 +42,6 @@
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);
@@ -265,21 +262,6 @@
-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
**/
@@ -623,7 +605,6 @@
launcher_menu_popup (gpointer user_data)
{
LauncherPlugin *launcher = user_data;
- GtkArrowType arrow_type;
GDK_THREADS_ENTER ();
@@ -635,12 +616,10 @@
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (launcher->arrow_button),
TRUE);
/* popup menu */
- 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);
+ gtk_menu_popup (GTK_MENU (launcher->menu), NULL, NULL,
+ xfce_panel_plugin_position_menu,
+ launcher->panel_plugin,
+ 1, gtk_get_current_event_time ());
GDK_THREADS_LEAVE ();
@@ -701,9 +680,6 @@
/* 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));
@@ -818,6 +794,7 @@
}
+
/**
* Panel Plugin Functions
**/
@@ -907,26 +884,15 @@
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);
@@ -1183,13 +1149,10 @@
GtkArrowType arrow_type;
/* get the arrow type */
- arrow_type = xfce_panel_plugin_popup_direction (XFCE_PANEL_PLUGIN
(launcher->panel_plugin),
- GTK_WIDGET
(launcher->box));
+ arrow_type = xfce_panel_plugin_arrow_type (launcher->panel_plugin);
/* set the arrow direction */
- if (arrow_type != GTK_ARROW_NONE)
- xfce_arrow_button_set_arrow_type
(XFCE_ARROW_BUTTON(launcher->arrow_button),
- arrow_type);
+ 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-30 08:54:55 UTC
(rev 26117)
+++ xfce4-panel/trunk/plugins/windowlist/windowlist.c 2007-09-30 18:14:31 UTC
(rev 26118)
@@ -51,9 +51,6 @@
typedef enum { WS_ADD = 1, WS_REMOVE } WorkspaceAction;
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);
@@ -447,7 +444,6 @@
gchar *ws_label, *rm_label;
gint size, i, wscount;
GList *windows, *li;
- GtkArrowType arrow_type;
PangoFontDescription *italic, *bold;
/* Menu item styles */
@@ -659,19 +655,11 @@
gtk_widget_show_all (menu);
- if (!at_pointer)
- {
- gtk_menu_attach_to_widget (GTK_MENU (menu),
- wl->button, NULL);
- }
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ xfce_panel_plugin_position_menu, wl->plugin,
+ ev ? ev->button : 0,
+ ev ? ev->time : gtk_get_current_event_time());
- 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;
}
@@ -961,22 +949,6 @@
/**
- * 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
@@ -1018,15 +990,12 @@
case ARROW_BUTTON:
DBG ("Create Arrow Button");
- wl->arrowtype = GTK_ARROW_NONE;
- wl->button = xfce_arrow_button_new (GTK_ARROW_NONE);
+ wl->arrowtype = xfce_panel_plugin_arrow_type (wl->plugin);
+ wl->button = xfce_arrow_button_new (wl->arrowtype);
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);
@@ -1056,50 +1025,6 @@
/**
- * Arrow type functions
- **/
-static void
-windowlist_update_arrow_type (Windowlist *wl)
-{
- GtkArrowType type = GTK_ARROW_NONE;
-
- if (!GTK_IS_WIDGET (wl->button))
- return;
-
- 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 void
-windowlist_set_arrow_type (Windowlist *wl,
- GtkArrowType new_arrow_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
@@ -1280,22 +1205,25 @@
switch (wl->layout)
{
case ICON_BUTTON:
- gtk_widget_set_size_request (GTK_WIDGET (wl->button),
- size, size);
+ gtk_widget_set_size_request (GTK_WIDGET (plugin),
+ size, size);
break;
case ARROW_BUTTON:
- switch (xfce_panel_plugin_get_orientation (wl->plugin))
+ switch (wl->arrowtype)
{
- case GTK_ORIENTATION_VERTICAL:
- gtk_widget_set_size_request (GTK_WIDGET (wl->button),
- size, ARROW_WIDTH);
+ case GTK_ARROW_LEFT:
+ case GTK_ARROW_RIGHT:
+ gtk_widget_set_size_request (GTK_WIDGET (plugin),
+ size, ARROW_WIDTH);
break;
- case GTK_ORIENTATION_HORIZONTAL:
- gtk_widget_set_size_request (GTK_WIDGET (wl->button),
- ARROW_WIDTH, size);
+ case GTK_ARROW_UP:
+ case GTK_ARROW_DOWN:
+ gtk_widget_set_size_request (GTK_WIDGET (plugin),
+ ARROW_WIDTH, size);
break;
+
default:
break;
}
@@ -1349,24 +1277,15 @@
{
DBG ("...");
- windowlist_update_arrow_type (wl);
-
+ wl->arrowtype = xfce_panel_plugin_arrow_type (plugin);
+
+ if (wl->layout == ARROW_BUTTON)
+ xfce_arrow_button_set_arrow_type (XFCE_ARROW_BUTTON (wl->button),
+ wl->arrowtype);
}
-static void
-windowlist_orientation_changed (XfcePanelPlugin *plugin,
- GtkOrientation orientation,
- Windowlist *wl)
-{
- DBG ("...");
-
- windowlist_update_arrow_type (wl);
-}
-
-
-
/**
* Construct plugin
**/
@@ -1387,9 +1306,6 @@
g_signal_connect (plugin, "screen-position-changed",
G_CALLBACK (windowlist_screen_position_changed), wl);
- g_signal_connect (plugin, "orientation-changed",
- G_CALLBACK (windowlist_orientation_changed), wl);
-
xfce_panel_plugin_menu_show_configure (plugin);
g_signal_connect (plugin, "configure-plugin",
G_CALLBACK (windowlist_properties), wl);
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits