[epiphany] Don't use deprecated gtk_menu_popup
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Don't use deprecated gtk_menu_popup
- Date: Fri, 14 Oct 2016 22:36:52 +0000 (UTC)
commit 8d4267a6910ac4d32b5c6ad188c70c1762f2cc72
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Fri Oct 14 17:34:15 2016 -0500
Don't use deprecated gtk_menu_popup
And also this function that's used to position the menus manually.
lib/ephy-gui.c | 68 ---------------------------------------------
lib/ephy-gui.h | 6 ----
src/ephy-header-bar.c | 9 +++--
src/ephy-history-window.c | 2 +-
src/ephy-window.c | 13 ++++----
src/passwords-dialog.c | 2 +-
6 files changed, 14 insertions(+), 86 deletions(-)
---
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c
index 43033c8..48a4b8a 100644
--- a/lib/ephy-gui.c
+++ b/lib/ephy-gui.c
@@ -95,74 +95,6 @@ ephy_gui_menu_position_tree_selection (GtkMenu *menu,
ephy_gui_sanitise_popup_position (menu, widget, x, y);
}
-/**
- * ephy_gui_menu_position_under_widget:
- * @menu:
- * @x:
- * @y:
- * @push_in:
- * @user_data: a #GtkWidget
- *
- * Positions @menu under (or over, depending on space available) the widget
- * @user_data.
- */
-void
-ephy_gui_menu_position_under_widget (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- /* Adapted from gtktoolbar.c */
- GtkWidget *widget = GTK_WIDGET (user_data);
- GtkWidget *container;
- GtkRequisition req;
- GtkRequisition menu_req;
- GtkAllocation allocation;
- GdkRectangle monitor;
- GdkWindow *window;
- int monitor_num;
- GdkScreen *screen;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER);
- g_return_if_fail (container != NULL);
-
- gtk_widget_get_preferred_size (widget, &req, NULL);
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
-
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- window = gtk_widget_get_window (widget);
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- gtk_widget_get_allocation (widget, &allocation);
- gdk_window_get_origin (window, x, y);
- if (!gtk_widget_get_has_window (widget)) {
- *x += allocation.x;
- *y += allocation.y;
- }
-
- if (gtk_widget_get_direction (container) == GTK_TEXT_DIR_LTR)
- *x += allocation.width - req.width;
- else
- *x += req.width - menu_req.width;
-
- if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height)
- *y += allocation.height;
- else if ((*y - menu_req.height) >= monitor.y)
- *y -= menu_req.height;
- else if (monitor.y + monitor.height - (*y + allocation.height) > *y)
- *y += allocation.height;
- else
- *y -= menu_req.height;
-
- *push_in = FALSE;
-}
-
GtkWindowGroup *
ephy_gui_ensure_window_group (GtkWindow *window)
{
diff --git a/lib/ephy-gui.h b/lib/ephy-gui.h
index 51d8671..d0ce8d8 100644
--- a/lib/ephy-gui.h
+++ b/lib/ephy-gui.h
@@ -37,12 +37,6 @@ void ephy_gui_menu_position_tree_selection (GtkMenu *menu,
gboolean *push_in,
gpointer user_data);
-void ephy_gui_menu_position_under_widget (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data);
-
GtkWindowGroup *ephy_gui_ensure_window_group (GtkWindow *window);
void ephy_gui_get_current_event (GdkEventType *type,
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 6963ca7..4b75fe2 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -419,10 +419,11 @@ popup_history_menu (GtkWidget *widget,
GtkWidget *menu;
menu = build_dropdown_menu (window, direction);
- gtk_menu_popup (GTK_MENU (menu),
- NULL, NULL,
- ephy_gui_menu_position_under_widget, widget,
- event->button, event->time);
+ gtk_menu_popup_at_widget (GTK_MENU (menu),
+ widget,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ (GdkEvent *)event);
}
typedef struct {
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 36caa23..b4d9a3a 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -449,7 +449,7 @@ on_treeview_button_press_event (GtkWidget *widget,
menu = gtk_menu_new_from_model (self->treeview_popup_menu_model);
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (self), NULL);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *)event);
return TRUE;
}
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 1e17569..be444d3 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2349,16 +2349,17 @@ show_notebook_popup_menu (GtkNotebook *notebook,
"move-right");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), page_num < n_pages - 1);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- NULL, NULL,
- event->button, event->time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *)event);
} else {
tab = GTK_WIDGET (window->active_embed);
tab_label = gtk_notebook_get_tab_label (notebook, tab);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
- ephy_gui_menu_position_under_widget, tab_label,
- 0, gtk_get_current_event_time ());
+ /* Not tested, because I don't know how to trigger this code. */
+ gtk_menu_popup_at_widget (GTK_MENU (menu),
+ tab_label,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ NULL);
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
}
diff --git a/src/passwords-dialog.c b/src/passwords-dialog.c
index 1121ffd..755f515 100644
--- a/src/passwords-dialog.c
+++ b/src/passwords-dialog.c
@@ -328,7 +328,7 @@ on_passwords_treeview_button_press_event (GtkWidget *widget,
menu = gtk_menu_new_from_model (dialog->treeview_popup_menu_model);
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (dialog), NULL);
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *)event);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]