[gtk+/wip/attachment-parameters-4: 13/20] gtknotebook: use gtk_menu_popup_with_params ()
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/attachment-parameters-4: 13/20] gtknotebook: use gtk_menu_popup_with_params ()
- Date: Wed, 6 Jan 2016 00:41:07 +0000 (UTC)
commit 5155ed149dcbf20987e6268517fa8792562f5b39
Author: William Hua <william hua canonical com>
Date: Wed Sep 23 11:10:19 2015 -0400
gtknotebook: use gtk_menu_popup_with_params ()
gtk/gtknotebook.c | 77 +++++++++++++++++++++-------------------------------
1 files changed, 31 insertions(+), 46 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 0da495c..fe783d9 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -2930,8 +2930,15 @@ gtk_notebook_button_press (GtkWidget *widget,
if (priv->menu && gdk_event_triggers_context_menu ((GdkEvent *) event))
{
- gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL,
- NULL, NULL, 3, event->time);
+ gtk_menu_popup_with_params (GTK_MENU (priv->menu),
+ NULL,
+ NULL,
+ NULL,
+ 3,
+ event->time,
+ TRUE,
+ NULL);
+
return TRUE;
}
@@ -2974,58 +2981,36 @@ gtk_notebook_button_press (GtkWidget *widget,
return TRUE;
}
-static void
-popup_position_func (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer data)
-{
- GtkNotebook *notebook = data;
- GtkNotebookPrivate *priv = notebook->priv;
- GtkAllocation allocation;
- GtkWidget *w;
- GtkRequisition requisition;
-
- if (priv->focus_tab)
- {
- GtkNotebookPage *page;
-
- page = priv->focus_tab->data;
- w = page->tab_label;
- }
- else
- {
- w = GTK_WIDGET (notebook);
- }
-
- gdk_window_get_origin (gtk_widget_get_window (w), x, y);
-
- gtk_widget_get_allocation (w, &allocation);
- gtk_widget_get_preferred_size (GTK_WIDGET (menu),
- &requisition, NULL);
-
- if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
- *x += allocation.x + allocation.width - requisition.width;
- else
- *x += allocation.x;
-
- *y += allocation.y + allocation.height;
-
- *push_in = FALSE;
-}
-
static gboolean
gtk_notebook_popup_menu (GtkWidget *widget)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
+ GdkAttachParams *params;
if (priv->menu)
{
- gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL,
- popup_position_func, notebook,
- 0, gtk_get_current_event_time ());
+ params = gtk_menu_create_params (GTK_MENU (priv->menu));
+
+ gdk_attach_params_add_primary_rules (params,
+ GDK_ATTACH_AXIS_Y | GDK_ATTACH_RECT_MAX | GDK_ATTACH_WINDOW_MIN,
+ GDK_ATTACH_AXIS_Y | GDK_ATTACH_RECT_MIN | GDK_ATTACH_WINDOW_MAX,
+ NULL);
+
+ gdk_attach_params_add_secondary_rules (params,
+ GDK_ATTACH_AXIS_X | GDK_ATTACH_RECT_MIN | GDK_ATTACH_WINDOW_MIN,
+ GDK_ATTACH_AXIS_X | GDK_ATTACH_RECT_MAX | GDK_ATTACH_WINDOW_MAX,
+ NULL);
+
+ gtk_menu_popup_with_params (GTK_MENU (priv->menu),
+ NULL,
+ NULL,
+ priv->focus_tab ? GTK_NOTEBOOK_PAGE (priv->focus_tab)->tab_label :
GTK_WIDGET (notebook),
+ 0,
+ gtk_get_current_event_time (),
+ TRUE,
+ params);
+
gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]