[Xfce4-commits] [panel-plugins/xfce4-clipman-plugin] 01/02: Position menu with XfceScreenPosition (bug 8849)
noreply at xfce.org
noreply at xfce.org
Fri May 30 11:22:21 CEST 2014
This is an automated email from the git hooks/post-receive script.
mmassonnet pushed a commit to branch master
in repository panel-plugins/xfce4-clipman-plugin.
commit eaa252ea4308490b9c6fa7a518eaed860dbfd989
Author: Mike Massonnet <m8t at gandi.net>
Date: Fri May 30 11:21:50 2014 +0200
Position menu with XfceScreenPosition (bug 8849)
---
panel-plugin/main-panel-plugin.c | 70 +++++++++++++++++++++-----------------
1 file changed, 39 insertions(+), 31 deletions(-)
diff --git a/panel-plugin/main-panel-plugin.c b/panel-plugin/main-panel-plugin.c
index 1279447..6e66414 100644
--- a/panel-plugin/main-panel-plugin.c
+++ b/panel-plugin/main-panel-plugin.c
@@ -158,45 +158,53 @@ my_plugin_position_menu (GtkMenu *menu,
gboolean *push_in,
MyPlugin *plugin)
{
+ gboolean above = TRUE;
gint button_width, button_height;
GtkRequisition requisition;
- GtkOrientation orientation;
+ XfceScreenPosition screen_position;
- orientation = xfce_panel_plugin_get_orientation (plugin->panel_plugin);
+ screen_position = xfce_panel_plugin_get_screen_position (plugin->panel_plugin);
gtk_widget_get_size_request (plugin->button, &button_width, &button_height);
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (plugin->panel_plugin)), x, y);
- switch (orientation)
+ switch (screen_position)
{
- case GTK_ORIENTATION_HORIZONTAL:
- if (*y + button_height + requisition.height > gdk_screen_height ())
- /* Show menu above */
- *y -= requisition.height;
- else
- /* Show menu below */
- *y += button_height;
-
- if (*x + requisition.width > gdk_screen_width ())
- /* Adjust horizontal position */
- *x = gdk_screen_width () - requisition.width;
- break;
-
- case GTK_ORIENTATION_VERTICAL:
- if (*x + button_width + requisition.width > gdk_screen_width ())
- /* Show menu on the right */
- *x -= requisition.width;
- else
- /* Show menu on the left */
- *x += button_width;
-
- if (*y + requisition.height > gdk_screen_height ())
- /* Adjust vertical position */
- *y = gdk_screen_height () - requisition.height;
- break;
-
- default:
- break;
+ case XFCE_SCREEN_POSITION_NW_H:
+ case XFCE_SCREEN_POSITION_N:
+ case XFCE_SCREEN_POSITION_NE_H:
+ above = FALSE;
+ case XFCE_SCREEN_POSITION_SW_H:
+ case XFCE_SCREEN_POSITION_S:
+ case XFCE_SCREEN_POSITION_SE_H:
+ g_message ("horiz: %d + %d + %d > %d", *y, button_height, requisition.height, gdk_screen_height ());
+ if (above)
+ /* Show menu above */
+ *y -= requisition.height;
+ else
+ /* Show menu below */
+ *y += button_height;
+
+ if (*x + requisition.width > gdk_screen_width ())
+ /* Adjust horizontal position */
+ *x = gdk_screen_width () - requisition.width;
+
+ break;
+
+ default:
+ g_message ("verti: %d + %d + %d > %d", *x, button_width, requisition.width, gdk_screen_width ());
+ if (*x + button_width + requisition.width > gdk_screen_width ())
+ /* Show menu on the right */
+ *x -= requisition.width;
+ else
+ /* Show menu on the left */
+ *x += button_width;
+
+ if (*y + requisition.height > gdk_screen_height ())
+ /* Adjust vertical position */
+ *y = gdk_screen_height () - requisition.height;
+
+ break;
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list