[gtk+/wip/attachment-rectangle] toolbar: use gtk_menu_popup_against for toolbar menus



commit 273f1c5e0496b2e1ac8fa21e2166bac3c4875a3f
Author: William Hua <william hua canonical com>
Date:   Thu Aug 27 08:53:40 2015 +0100

    toolbar: use gtk_menu_popup_against for toolbar menus

 gtk/gtktoolbar.c |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index 4c8674f..3fcf5fc 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -2638,15 +2638,44 @@ show_menu (GtkToolbar     *toolbar,
           GdkEventButton *event)
 {
   GtkToolbarPrivate *priv = toolbar->priv;
+  GdkAttachmentOptions options;
 
   rebuild_menu (toolbar);
 
   gtk_widget_show_all (GTK_WIDGET (priv->menu));
 
-  gtk_menu_popup (priv->menu, NULL, NULL,
-                 menu_position_func, toolbar,
-                 event? event->button : 0,
-                 event? event->time : gtk_get_current_event_time());
+  if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+    {
+      options = GDK_ATTACHMENT_ATTACH_BOTTOM_EDGE;
+
+      if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR)
+        options |= GDK_ATTACHMENT_ALIGN_LEFT_EDGES;
+      else
+        options |= GDK_ATTACHMENT_ALIGN_RIGHT_EDGES;
+    }
+  else
+    {
+      options = GDK_ATTACHMENT_ALIGN_TOP_EDGES;
+
+      if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR)
+        options |= GDK_ATTACHMENT_ATTACH_RIGHT_EDGE;
+      else
+        options |= GDK_ATTACHMENT_ATTACH_LEFT_EDGE;
+    }
+
+  options |= GDK_ATTACHMENT_ATTACH_OPPOSITE_EDGE;
+
+  gtk_menu_popup_against (priv->menu,
+                          event ? event->device : NULL,
+                          NULL,
+                          priv->arrow_button,
+                          NULL,
+                          options,
+                          NULL,
+                          NULL,
+                          NULL,
+                          event ? event->button : 0,
+                          event ? event->time : gtk_get_current_event_time ());
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]