[nautilus/wip/antoniof/gnome-42: 31/72] Revert "window: Stop using GtkMenuShell"
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gnome-42: 31/72] Revert "window: Stop using GtkMenuShell"
- Date: Fri, 11 Feb 2022 19:28:00 +0000 (UTC)
commit a863d8374ce706b62ad99f7de5aaf947d1fc443b
Author: António Fernandes <antoniof gnome org>
Date: Fri Feb 11 19:21:21 2022 +0000
Revert "window: Stop using GtkMenuShell"
This reverts commit be80e7dc7c4e576544aceeeaa8e58c65bcfcad7f.
src/nautilus-window.c | 112 ++++++++++++++++++++++++++++++------
src/resources/ui/nautilus-window.ui | 28 ---------
2 files changed, 96 insertions(+), 44 deletions(-)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 6327fd31a..7c09fb51d 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -148,9 +148,6 @@ struct _NautilusWindow
guint sidebar_width_handler_id;
gulong bookmarks_id;
- GtkWidget *tab_menu;
- GMenuModel *tab_menu_model;
-
GQueue *tab_data_queue;
GtkPadController *pad_controller;
@@ -1765,15 +1762,99 @@ on_path_bar_open_location (NautilusWindow *window,
nautilus_window_open_location_full (window, location, open_flags, NULL, NULL);
}
+static void
+notebook_popup_menu_new_tab_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ NautilusWindow *window = user_data;
+
+ nautilus_window_new_tab (window);
+}
+
+static void
+notebook_popup_menu_move_left_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ NautilusWindow *window = user_data;
+
+ nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), -1);
+}
+
+static void
+notebook_popup_menu_move_right_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ NautilusWindow *window = user_data;
+
+
+ nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), 1);
+}
+
+static void
+notebook_popup_menu_close_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ NautilusWindow *window = user_data;
+ NautilusWindowSlot *slot;
+
+ slot = window->active_slot;
+ nautilus_window_slot_close (window, slot);
+}
+
static void
notebook_popup_menu_show (NautilusWindow *window,
- gdouble x,
- gdouble y)
+ const GdkEvent *event)
{
- GtkPopover *popover = GTK_POPOVER (window->tab_menu);
+ GtkWidget *popup;
+ GtkWidget *item;
+ gboolean can_move_left, can_move_right;
+ NautilusNotebook *notebook;
+
+ notebook = NAUTILUS_NOTEBOOK (window->notebook);
- gtk_popover_set_pointing_to (popover, &(GdkRectangle){x, y, 0, 0});
- gtk_popover_popup (popover);
+ can_move_left = nautilus_notebook_can_reorder_current_child_relative (notebook, -1);
+ can_move_right = nautilus_notebook_can_reorder_current_child_relative (notebook, 1);
+
+ popup = gtk_menu_new ();
+
+ item = gtk_menu_item_new_with_mnemonic (_("_New Tab"));
+ g_signal_connect (item, "activate",
+ G_CALLBACK (notebook_popup_menu_new_tab_cb),
+ window);
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup),
+ item);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup),
+ gtk_separator_menu_item_new ());
+
+ item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Left"));
+ g_signal_connect (item, "activate",
+ G_CALLBACK (notebook_popup_menu_move_left_cb),
+ window);
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup),
+ item);
+ gtk_widget_set_sensitive (item, can_move_left);
+
+ item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Right"));
+ g_signal_connect (item, "activate",
+ G_CALLBACK (notebook_popup_menu_move_right_cb),
+ window);
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup),
+ item);
+ gtk_widget_set_sensitive (item, can_move_right);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup),
+ gtk_separator_menu_item_new ());
+
+ item = gtk_menu_item_new_with_mnemonic (_("_Close Tab"));
+ g_signal_connect (item, "activate",
+ G_CALLBACK (notebook_popup_menu_close_cb), window);
+ gtk_menu_shell_append (GTK_MENU_SHELL (popup),
+ item);
+
+ gtk_widget_show_all (popup);
+
+ gtk_menu_popup_at_pointer (GTK_MENU (popup), event);
}
/* emitted when the user clicks the "close" button of tabs */
@@ -1793,6 +1874,8 @@ notebook_button_press_cb (GtkGestureMultiPress *gesture,
gpointer user_data)
{
NautilusWindow *window;
+ GdkEventSequence *sequence;
+ const GdkEvent *event;
window = NAUTILUS_WINDOW (user_data);
@@ -1801,7 +1884,10 @@ notebook_button_press_cb (GtkGestureMultiPress *gesture,
return;
}
- notebook_popup_menu_show (window, x, y);
+ sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
+ event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
+
+ notebook_popup_menu_show (window, event);
}
static gboolean
@@ -1809,7 +1895,7 @@ notebook_popup_menu_cb (GtkWidget *widget,
gpointer user_data)
{
NautilusWindow *window = user_data;
- notebook_popup_menu_show (window, 0, 0);
+ notebook_popup_menu_show (window, NULL);
return TRUE;
}
@@ -2622,10 +2708,6 @@ nautilus_window_init (NautilusWindow *window)
window,
G_CONNECT_SWAPPED);
- gtk_popover_bind_model (GTK_POPOVER (window->tab_menu),
- window->tab_menu_model,
- NULL);
-
g_signal_connect (window, "notify::is-maximized",
G_CALLBACK (on_is_maximized_changed), NULL);
@@ -2705,8 +2787,6 @@ nautilus_window_class_init (NautilusWindowClass *class)
gtk_widget_class_bind_template_child (wclass, NautilusWindow, sidebar);
gtk_widget_class_bind_template_child (wclass, NautilusWindow, main_view);
gtk_widget_class_bind_template_child (wclass, NautilusWindow, notebook);
- gtk_widget_class_bind_template_child (wclass, NautilusWindow, tab_menu);
- gtk_widget_class_bind_template_child (wclass, NautilusWindow, tab_menu_model);
gtk_widget_class_bind_template_child (wclass, NautilusWindow, in_app_notification_undo);
gtk_widget_class_bind_template_child (wclass, NautilusWindow, in_app_notification_undo_label);
gtk_widget_class_bind_template_child (wclass, NautilusWindow, in_app_notification_undo_undo_button);
diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui
index cd5799f36..472ee7fce 100644
--- a/src/resources/ui/nautilus-window.ui
+++ b/src/resources/ui/nautilus-window.ui
@@ -1,33 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <object class="GtkPopover" id="tab_menu">
- <property name="position">bottom</property>
- <property name="relative-to">notebook</property>
- </object>
- <menu id="tab_menu_model">
- <section>
- <item>
- <attribute name="label" translatable="yes">_New Tab</attribute>
- <attribute name="action">win.new-tab</attribute>
- </item>
- </section>
- <section>
- <item>
- <attribute name="label" translatable="yes">Move Tab _Left</attribute>
- <attribute name="action">win.tab-move-left</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Move Tab _Right</attribute>
- <attribute name="action">win.tab-move-right</attribute>
- </item>
- </section>
- <section>
- <item>
- <attribute name="label" translatable="yes">_Close Tab</attribute>
- <attribute name="action">win.close-current-view</attribute>
- </item>
- </section>
- </menu>
<template class="NautilusWindow" parent="HdyApplicationWindow">
<property name="show-menubar">False</property>
<property name="title" translatable="yes">_Files</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]