[gtk+/wip/attach-params: 15/20] gtkrecentchooserdefault: use gtk_menu_popup_with_params ()
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/attach-params: 15/20] gtkrecentchooserdefault: use gtk_menu_popup_with_params ()
- Date: Wed, 6 Jan 2016 17:26:58 +0000 (UTC)
commit 8cdfc42230ecc7e1bda26de87b59dfbc1811b5ba
Author: William Hua <william hua canonical com>
Date: Wed Jan 6 12:00:00 2016 -0500
gtkrecentchooserdefault: use gtk_menu_popup_with_params ()
gtk/gtkrecentchooserdefault.c | 77 ++++++++++++++++------------------------
1 files changed, 31 insertions(+), 46 deletions(-)
---
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index 5d6172d..8392d2a 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -1729,61 +1729,46 @@ 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)
{
+ GdkAttachParams *params;
+
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);
+ params = gtk_menu_create_params (GTK_MENU (impl->priv->recent_popup_menu));
+
+ gdk_attach_params_add_primary_rules (params,
+ GDK_ATTACH_AXIS_Y | GDK_ATTACH_RECT_MID | GDK_ATTACH_WINDOW_MID,
+ NULL);
+
+ gdk_attach_params_add_secondary_rules (params,
+ GDK_ATTACH_AXIS_X | GDK_ATTACH_RECT_MID | GDK_ATTACH_WINDOW_MID,
+ NULL);
+
+ 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,
+ params);
+
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]