[nautilus/wip/antoniof/gtk4-preparation-popovers] general: Stop using GtkWidget::popup-menu



commit 08ef056d368d6b3e365775dd195100aa46d00c35
Author: António Fernandes <antoniof gnome org>
Date:   Sat Jan 1 19:50:09 2022 +0000

    general: Stop using GtkWidget::popup-menu
    
    The signal is gone in GTK 4.
    
    Replace the most relevant use with an action and a keyboard accelerator.

 src/nautilus-files-view.c | 38 +++++++++++++++-----------------------
 src/nautilus-window.c     | 12 ------------
 2 files changed, 15 insertions(+), 35 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 6d30afeb6..2c1ba4f62 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -1662,6 +1662,16 @@ 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,
@@ -7058,6 +7068,7 @@ 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
@@ -7648,6 +7659,9 @@ 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);
@@ -8314,25 +8328,6 @@ 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)
 {
@@ -9619,10 +9614,6 @@ 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);
 
@@ -9785,6 +9776,7 @@ 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 bf622d5e0..3d2dc48c0 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1824,15 +1824,6 @@ 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)
 {
@@ -1951,9 +1942,6 @@ 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]