[nautilus/wip/antoniof/gnome-42: 18/72] Revert "general: Stop using GtkWidget::popup-menu"




commit dfaa7b56a3c6c0d24bd7c2bf2d69b76885f9dcfc
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Feb 11 14:47:04 2022 +0100

    Revert "general: Stop using GtkWidget::popup-menu"
    
    This reverts commit 80b6f77d2bc1b9463dc0195f44c786f35478d826.

 src/nautilus-files-view.c | 38 +++++++++++++++++++++++---------------
 src/nautilus-window.c     | 12 ++++++++++++
 2 files changed, 35 insertions(+), 15 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index ac2c0525b..ea6d50be1 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -1662,16 +1662,6 @@ action_preview_selection (GSimpleAction *action,
     nautilus_files_view_preview (view, data);
 }
 
-static void
-action_popup_menu (GSimpleAction *action,
-                   GVariant      *state,
-                   gpointer       user_data)
-{
-    NautilusFilesView *view = NAUTILUS_FILES_VIEW (user_data);
-
-    nautilus_files_view_pop_up_selection_context_menu (view, -1, -1);
-}
-
 static void
 pattern_select_response_cb (GtkWidget *dialog,
                             int        response,
@@ -7068,7 +7058,6 @@ const GActionEntry view_entries[] =
     { "select-pattern", action_select_pattern },
     { "invert-selection", action_invert_selection },
     { "preview-selection", action_preview_selection },
-    { "popup-menu", action_popup_menu },
 };
 
 static gboolean
@@ -7659,9 +7648,6 @@ real_update_actions_state (NautilusFilesView *view)
     action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
                                          "preview-selection");
     g_simple_action_set_enabled (G_SIMPLE_ACTION (action), selection_count != 0);
-    action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
-                                         "popup-menu");
-    g_simple_action_set_enabled (G_SIMPLE_ACTION (action), selection_count != 0);
 
     /* Drive menu */
     show_mount = (selection != NULL);
@@ -8328,6 +8314,25 @@ nautilus_files_view_pop_up_background_context_menu (NautilusFilesView *view,
     gtk_popover_popup (GTK_POPOVER (priv->background_menu));
 }
 
+static gboolean
+popup_menu_callback (NautilusFilesView *view)
+{
+    g_autolist (NautilusFile) selection = NULL;
+
+    selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
+
+    if (selection != NULL)
+    {
+        nautilus_files_view_pop_up_selection_context_menu (view, -1, -1);
+    }
+    else
+    {
+        nautilus_files_view_pop_up_background_context_menu (view, 0, 0);
+    }
+
+    return TRUE;
+}
+
 static void
 schedule_update_context_menus (NautilusFilesView *view)
 {
@@ -9612,6 +9617,10 @@ nautilus_files_view_init (NautilusFilesView *view)
                               "event",
                               G_CALLBACK (on_event),
                               view);
+    g_signal_connect_swapped (priv->scrolled_window,
+                              "popup-menu",
+                              G_CALLBACK (popup_menu_callback),
+                              view);
 
     gtk_overlay_set_child (GTK_OVERLAY (priv->overlay), priv->scrolled_window);
 
@@ -9774,7 +9783,6 @@ nautilus_files_view_init (NautilusFilesView *view)
     nautilus_application_set_accelerators (app, "view.zoom-standard", zoom_standard_accels);
     nautilus_application_set_accelerator (app, "view.invert-selection", "<shift><control>i");
     nautilus_application_set_accelerator (app, "view.preview-selection", "space");
-    nautilus_application_set_accelerator (app, "view.popup-menu", "Menu");
 
     priv->starred_cancellable = g_cancellable_new ();
     priv->tag_manager = nautilus_tag_manager_get ();
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index c40175275..d433e6b64 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1824,6 +1824,15 @@ notebook_button_press_cb (GtkGestureMultiPress *gesture,
     }
 }
 
+static gboolean
+notebook_popup_menu_cb (GtkWidget *widget,
+                        gpointer   user_data)
+{
+    NautilusWindow *window = user_data;
+    notebook_popup_menu_show (window, 0, 0);
+    return TRUE;
+}
+
 GtkWidget *
 nautilus_window_get_toolbar (NautilusWindow *window)
 {
@@ -1941,6 +1950,9 @@ notebook_create_window_cb (GtkNotebook *notebook,
 static void
 setup_notebook (NautilusWindow *window)
 {
+    g_signal_connect (window->notebook, "popup-menu",
+                      G_CALLBACK (notebook_popup_menu_cb),
+                      window);
     g_signal_connect (window->notebook, "switch-page",
                       G_CALLBACK (notebook_switch_page_cb),
                       window);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]