summaryrefslogtreecommitdiff
path: root/src/nautilus-window.c
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2022-01-10 12:30:13 +0000
committerAntónio Fernandes <antoniojpfernandes@gmail.com>2022-02-12 16:49:04 +0000
commit14c20909ef88476abcfe2b6e9892407736c34423 (patch)
tree4a30a6e85a7ec30f3a63e6a6a9024a6e49b97763 /src/nautilus-window.c
parent7ec35dd46b76db31515fa23c78f5211c14bbeec0 (diff)
downloadnautilus-14c20909ef88476abcfe2b6e9892407736c34423.tar.gz
window: Attach tab context menu to the tab
Due to GtkPopover now being a child of the window, instead of setting an attach widget we need to pass it the allocation of the tab, with the origin coordinates translated to the window coordinate space. Also use double instead of int when appropriate and replace GdkEvent usage with event controller method to get modifier status. Closes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2101
Diffstat (limited to 'src/nautilus-window.c')
-rw-r--r--src/nautilus-window.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 7cc676ac5..9214a56ab 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1756,12 +1756,18 @@ on_path_bar_open_location (NautilusWindow *window,
static void
notebook_popup_menu_show (NautilusWindow *window,
- gdouble x,
- gdouble y)
+ GtkWidget *tab)
{
GtkPopover *popover = GTK_POPOVER (window->tab_menu);
-
- gtk_popover_set_pointing_to (popover, &(GdkRectangle){x, y, 0, 0});
+ GtkAllocation allocation;
+ gdouble x, y;
+
+ gtk_widget_get_allocation (tab, &allocation);
+ gtk_widget_translate_coordinates (tab, GTK_WIDGET (window),
+ allocation.x, allocation.y, &x, &y);
+ allocation.x = x;
+ allocation.y = y;
+ gtk_popover_set_pointing_to (popover, (GdkRectangle *) &allocation);
gtk_popover_popup (popover);
}
@@ -1775,9 +1781,8 @@ notebook_button_press_cb (GtkGestureClick *gesture,
NautilusWindow *window;
GtkNotebook *notebook;
gint tab_clicked;
+ GtkWidget *tab_widget;
guint button;
- GdkEventSequence *sequence;
- GdkEvent *event;
GdkModifierType state;
if (n_press != 1)
@@ -1788,22 +1793,21 @@ notebook_button_press_cb (GtkGestureClick *gesture,
window = NAUTILUS_WINDOW (user_data);
notebook = GTK_NOTEBOOK (window->notebook);
- if (!nautilus_notebook_get_tab_clicked (notebook, x, y, &tab_clicked))
+ tab_widget = nautilus_notebook_get_tab_clicked (notebook, x, y, &tab_clicked);
+ if (tab_widget == NULL)
{
return;
}
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
- sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
- event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
- state = gdk_event_get_modifier_state (event);
+ state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
if (button == GDK_BUTTON_SECONDARY &&
(state & gtk_accelerator_get_default_mod_mask ()) == 0)
{
/* switch to the page before opening the menu */
gtk_notebook_set_current_page (notebook, tab_clicked);
- notebook_popup_menu_show (window, x, y);
+ notebook_popup_menu_show (window, tab_widget);
}
else if (button == GDK_BUTTON_MIDDLE)
{