[gtk+/wip/attach-params: 15/20] gtkrecentchooserdefault: use gtk_menu_popup_with_params ()



commit 7c53ca71f88e205ada0554cb267be12e49f5be2e
Author: William Hua <william hua canonical com>
Date:   Wed Jan 20 02:20:20 2016 -0600

    gtkrecentchooserdefault: use gtk_menu_popup_with_params ()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756579

 gtk/gtkrecentchooserdefault.c |   65 ++++++++++++-----------------------------
 1 files changed, 19 insertions(+), 46 deletions(-)
---
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index 5d6172d..2f35146 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -1729,45 +1729,6 @@ recent_view_menu_build (GtkRecentChooserDefault *impl)
   recent_view_menu_ensure_state (impl);
 }
 
-/* taken from gtkfilechooserdefault.c */
-static void
-popup_position_func (GtkMenu   *menu,
-                     gint      *x,
-                     gint      *y,
-                     gboolean  *push_in,
-                     gpointer  user_data)
-{
-  GtkAllocation allocation;
-  GtkWidget *widget = GTK_WIDGET (user_data);
-  GdkScreen *screen = gtk_widget_get_screen (widget);
-  GtkRequisition req;
-  gint monitor_num;
-  GdkRectangle monitor;
-
-  if (G_UNLIKELY (!gtk_widget_get_realized (widget)))
-    return;
-
-  gdk_window_get_origin (gtk_widget_get_window (widget),
-                         x, y);
-
-  gtk_widget_get_preferred_size (GTK_WIDGET (menu),
-                                 &req, NULL);
-
-  gtk_widget_get_allocation (widget, &allocation);
-  *x += (allocation.width - req.width) / 2;
-  *y += (allocation.height - req.height) / 2;
-
-  monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
-  gtk_menu_set_monitor (menu, monitor_num);
-  gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
-
-  *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
-  *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
-
-  *push_in = FALSE;
-}
-
-
 static void
 recent_view_menu_popup (GtkRecentChooserDefault *impl,
                        GdkEventButton          *event)
@@ -1775,15 +1736,27 @@ recent_view_menu_popup (GtkRecentChooserDefault *impl,
   recent_view_menu_build (impl);
   
   if (event)
-    gtk_menu_popup (GTK_MENU (impl->priv->recent_popup_menu),
-                   NULL, NULL, NULL, NULL,
-                   event->button, event->time);
+    gtk_menu_popup_with_params (GTK_MENU (impl->priv->recent_popup_menu),
+                                NULL,
+                                NULL,
+                                NULL,
+                                event->button,
+                                event->time,
+                                TRUE,
+                                GDK_WINDOW_TYPE_HINT_POPUP_MENU,
+                                NULL);
   else
     {
-      gtk_menu_popup (GTK_MENU (impl->priv->recent_popup_menu),
-                     NULL, NULL,
-                     popup_position_func, impl->priv->recent_view,
-                     0, GDK_CURRENT_TIME);
+      gtk_menu_popup_with_params (GTK_MENU (impl->priv->recent_popup_menu),
+                                  NULL,
+                                  NULL,
+                                  impl->priv->recent_view,
+                                  0,
+                                  GDK_CURRENT_TIME,
+                                  TRUE,
+                                  GDK_WINDOW_TYPE_HINT_POPUP_MENU,
+                                  gtk_menu_create_params (GTK_MENU (impl->priv->recent_popup_menu)));
+
       gtk_menu_shell_select_first (GTK_MENU_SHELL (impl->priv->recent_popup_menu),
                                   FALSE);
     }


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