Skip to content

Commit 7958d12

Browse files
author
raveit65
committed
terminal-window: replace deprecated gtk_menu_popup
1 parent aeb8e28 commit 7958d12

File tree

1 file changed

+7
-65
lines changed

1 file changed

+7
-65
lines changed

‎src/terminal-window.c‎

Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -563,60 +563,6 @@ find_tab_num_at_pos (GtkNotebook *notebook,
563563
return -1;
564564
}
565565

566-
static void
567-
position_menu_under_widget (GtkMenu *menu,
568-
int *x,
569-
int *y,
570-
gboolean *push_in,
571-
gpointer user_data)
572-
{
573-
/* Adapted from gtktoolbar.c */
574-
GtkWidget *widget = GTK_WIDGET (user_data);
575-
GdkWindow *widget_window;
576-
GtkWidget *container;
577-
GtkRequisition req;
578-
GtkRequisition menu_req;
579-
GdkRectangle monitor;
580-
GdkMonitor *monitor_num;
581-
GdkDisplay *display;
582-
GtkAllocation widget_allocation;
583-
584-
widget_window = gtk_widget_get_window (widget);
585-
gtk_widget_get_allocation (widget, &widget_allocation);
586-
container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER);
587-
588-
gtk_widget_get_preferred_size (widget, &req, NULL);
589-
gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
590-
591-
display = gtk_widget_get_display (GTK_WIDGET (menu));
592-
monitor_num = gdk_display_get_monitor_at_window (display, widget_window);
593-
if (monitor_num == NULL)
594-
monitor_num = gdk_display_get_monitor (display, 0);
595-
gdk_monitor_get_geometry (monitor_num, &monitor);
596-
597-
gdk_window_get_origin (widget_window, x, y);
598-
if (!gtk_widget_get_has_window (widget))
599-
{
600-
*x += widget_allocation.x;
601-
*y += widget_allocation.y;
602-
}
603-
if (gtk_widget_get_direction (container) == GTK_TEXT_DIR_LTR)
604-
*x += widget_allocation.width - req.width;
605-
else
606-
*x += req.width - menu_req.width;
607-
608-
if ((*y + widget_allocation.height + menu_req.height) <= monitor.y + monitor.height)
609-
*y += widget_allocation.height;
610-
else if ((*y - menu_req.height) >= monitor.y)
611-
*y -= menu_req.height;
612-
else if (monitor.y + monitor.height - (*y + widget_allocation.height) > *y)
613-
*y += widget_allocation.height;
614-
else
615-
*y -= menu_req.height;
616-
617-
*push_in = FALSE;
618-
}
619-
620566
static void
621567
terminal_set_profile_toggled_callback (GtkToggleAction *action,
622568
TerminalWindow *window)
@@ -1545,11 +1491,7 @@ popup_clipboard_targets_received_cb (GtkClipboard *clipboard,
15451491
if (!gtk_menu_get_attach_widget (GTK_MENU (popup_menu)))
15461492
gtk_menu_attach_to_widget (GTK_MENU (popup_menu),GTK_WIDGET (screen),NULL);
15471493

1548-
gtk_menu_popup (GTK_MENU (popup_menu),
1549-
NULL, NULL,
1550-
NULL, NULL,
1551-
info->button,
1552-
info->timestamp);
1494+
gtk_menu_popup_at_pointer (GTK_MENU (popup_menu), NULL);
15531495
}
15541496

15551497
static void
@@ -2978,9 +2920,7 @@ notebook_button_press_cb (GtkWidget *widget,
29782920
gtk_menu_detach (GTK_MENU (menu));
29792921
tab = gtk_notebook_get_nth_page (notebook, tab_clicked);
29802922
gtk_menu_attach_to_widget (GTK_MENU (menu), tab, NULL);
2981-
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
2982-
NULL, NULL,
2983-
event->button, event->time);
2923+
gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
29842924

29852925
return TRUE;
29862926
}
@@ -3047,9 +2987,11 @@ notebook_popup_menu_cb (GtkWidget *widget,
30472987
if (gtk_menu_get_attach_widget (GTK_MENU (menu)))
30482988
gtk_menu_detach (GTK_MENU (menu));
30492989
gtk_menu_attach_to_widget (GTK_MENU (menu), tab_label, NULL);
3050-
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
3051-
position_menu_under_widget, tab_label,
3052-
0, gtk_get_current_event_time ());
2990+
gtk_menu_popup_at_widget (GTK_MENU (menu),
2991+
tab_label,
2992+
GDK_GRAVITY_SOUTH_WEST,
2993+
GDK_GRAVITY_NORTH_WEST,
2994+
NULL);
30532995
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
30542996

30552997
return TRUE;

0 commit comments

Comments
 (0)