Commit 8d4267a6 authored by Michael Catanzaro's avatar Michael Catanzaro

Don't use deprecated gtk_menu_popup

And also this function that's used to position the menus manually.
parent ef5d1272
......@@ -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)
{
......
......@@ -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,
......
......@@ -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 {
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment