From 0fd21246a8cc827150dc59244bb419fe594a1e42 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Fri, 4 May 2018 16:45:16 +0200 Subject: ev-sidebar-links: replace deprecated gtk_menu_popup function --- shell/ev-sidebar-links.c | 10 ++---- shell/ev-utils.c | 84 ------------------------------------------------ shell/ev-utils.h | 6 ---- 3 files changed, 3 insertions(+), 97 deletions(-) (limited to 'shell') diff --git a/shell/ev-sidebar-links.c b/shell/ev-sidebar-links.c index b252fbb2..a4473504 100644 --- a/shell/ev-sidebar-links.c +++ b/shell/ev-sidebar-links.c @@ -347,10 +347,7 @@ popup_menu_cb (GtkWidget *treeview, EvSidebarLinks *sidebar) { GtkMenu *menu = build_popup_menu (sidebar); - gtk_menu_popup (menu, NULL, NULL, - ev_gui_menu_position_tree_selection, - sidebar->priv->tree_view, 0, - gtk_get_current_event_time ()); + gtk_menu_popup_at_pointer (menu, NULL); gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE); } @@ -369,9 +366,8 @@ button_press_cb (GtkWidget *treeview, NULL, NULL, NULL)) { gtk_tree_view_set_cursor (GTK_TREE_VIEW (treeview), path, NULL, FALSE); - gtk_menu_popup (build_popup_menu (sidebar), NULL, - NULL, NULL, NULL, event->button, - gtk_get_current_event_time ()); + gtk_menu_popup_at_pointer (build_popup_menu (sidebar), + (const GdkEvent*) event); gtk_tree_path_free (path); return TRUE; diff --git a/shell/ev-utils.c b/shell/ev-utils.c index 342f838e..ebfca1ec 100644 --- a/shell/ev-utils.c +++ b/shell/ev-utils.c @@ -26,90 +26,6 @@ #include #include -static int -_gtk_get_monitor_num (GdkMonitor *monitor) -{ - GdkDisplay *display; - int n_monitors, i; - - display = gdk_monitor_get_display (monitor); - n_monitors = gdk_display_get_n_monitors (display); - - for(i = 0; i < n_monitors; i++) - { - if (gdk_display_get_monitor (display, i) == monitor) return i; - } - - return -1; -} - -static void -ev_gui_sanitise_popup_position (GtkMenu *menu, - GtkWidget *widget, - gint *x, - gint *y) -{ - GdkDisplay *display = gtk_widget_get_display (widget); - GdkMonitor *monitor_num; - GdkRectangle monitor; - GtkRequisition req; - - g_return_if_fail (widget != NULL); - - gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL); - - monitor_num = gdk_display_get_monitor_at_point (display, *x, *y); - gtk_menu_set_monitor (menu, _gtk_get_monitor_num (monitor_num)); - gdk_monitor_get_geometry (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)); -} - -void -ev_gui_menu_position_tree_selection (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer user_data) -{ - GtkTreeSelection *selection; - GList *selected_rows; - GtkTreeModel *model; - GtkTreeView *tree_view = GTK_TREE_VIEW (user_data); - GtkWidget *widget = GTK_WIDGET (user_data); - GtkRequisition req; - GtkAllocation allocation; - GdkRectangle visible; - - gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL); - gdk_window_get_origin (gtk_widget_get_window (widget), x, y); - gtk_widget_get_allocation (widget, &allocation); - - *x += (allocation.width - req.width) / 2; - - /* Add on height for the treeview title */ - gtk_tree_view_get_visible_rect (tree_view, &visible); - *y += allocation.height - visible.height; - - selection = gtk_tree_view_get_selection (tree_view); - selected_rows = gtk_tree_selection_get_selected_rows (selection, &model); - if (selected_rows) - { - GdkRectangle cell_rect; - - gtk_tree_view_get_cell_area (tree_view, selected_rows->data, - NULL, &cell_rect); - - *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height); - - g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL); - g_list_free (selected_rows); - } - - ev_gui_sanitise_popup_position (menu, widget, x, y); -} - void file_chooser_dialog_add_writable_pixbuf_formats (GtkFileChooser *chooser) { diff --git a/shell/ev-utils.h b/shell/ev-utils.h index f37f5af6..03c9541a 100644 --- a/shell/ev-utils.h +++ b/shell/ev-utils.h @@ -26,12 +26,6 @@ G_BEGIN_DECLS -void ev_gui_menu_position_tree_selection (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer user_data); - void file_chooser_dialog_add_writable_pixbuf_formats (GtkFileChooser *chooser); GdkPixbufFormat* get_gdk_pixbuf_format_by_extension (gchar *uri); -- cgit v1.2.1