[nautilus/gtk4-preparation-trunk: 11/64] pathbar: Refactor signals




commit a554936a42990104ecb1abfcf442c381b110472a
Author: António Fernandes <antoniof gnome org>
Date:   Sat Dec 18 21:06:57 2021 +0000

    pathbar: Refactor signals
    
    NautilusPathBar::path-clicked is never emited.
    NautilusPathBar::location-changed uses a parameter type that's gone in
    GTK 4: GtkPlacesOpenFlags.
    
    Generate a GType for our own NautilusOpenFlags enum type to be used as a
    signal parameter, remove the unused signal and repurpose its signal
    handler to handle the second signal (which no longer has a signature
    compatible with the GtkPlacesSidebar one).

 src/meson.build        |  1 +
 src/nautilus-pathbar.c | 22 +++++++---------------
 src/nautilus-window.c  | 12 +++++-------
 3 files changed, 13 insertions(+), 22 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 59471f036..682220389 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -14,6 +14,7 @@ libnautilus_sources = [
     c_template: 'nautilus-enum-types.c.template',
     h_template: 'nautilus-enum-types.h.template',
     sources: [
+      'nautilus-enums.h',
       'nautilus-search-popover.h',
       'nautilus-special-location-bar.h',
       'nautilus-query.h',
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 1480d7c77..53d191234 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -25,6 +25,8 @@
 #include "nautilus-pathbar.h"
 #include "nautilus-properties-window.h"
 
+#include "nautilus-enums.h"
+#include "nautilus-enum-types.h"
 #include "nautilus-file.h"
 #include "nautilus-file-utilities.h"
 #include "nautilus-global-preferences.h"
@@ -38,7 +40,6 @@
 enum
 {
     OPEN_LOCATION,
-    PATH_CLICKED,
     LAST_SIGNAL
 };
 
@@ -158,7 +159,7 @@ action_pathbar_open_item_new_tab (GSimpleAction *action,
 
     if (location)
     {
-        g_signal_emit (user_data, path_bar_signals[OPEN_LOCATION], 0, location, GTK_PLACES_OPEN_NEW_TAB);
+        g_signal_emit (user_data, path_bar_signals[OPEN_LOCATION], 0, location, NAUTILUS_OPEN_FLAG_NEW_TAB);
         g_object_unref (location);
     }
 }
@@ -182,7 +183,7 @@ action_pathbar_open_item_new_window (GSimpleAction *action,
 
     if (location)
     {
-        g_signal_emit (user_data, path_bar_signals[OPEN_LOCATION], 0, location, GTK_PLACES_OPEN_NEW_WINDOW);
+        g_signal_emit (user_data, path_bar_signals[OPEN_LOCATION], 0, location, 
NAUTILUS_OPEN_FLAG_NEW_WINDOW);
         g_object_unref (location);
     }
 }
@@ -451,16 +452,7 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class)
                       NULL, NULL, NULL,
                       G_TYPE_NONE, 2,
                       G_TYPE_FILE,
-                      GTK_TYPE_PLACES_OPEN_FLAGS);
-    path_bar_signals [PATH_CLICKED] =
-        g_signal_new ("path-clicked",
-                      G_OBJECT_CLASS_TYPE (path_bar_class),
-                      G_SIGNAL_RUN_FIRST,
-                      0,
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__OBJECT,
-                      G_TYPE_NONE, 1,
-                      G_TYPE_FILE);
+                      NAUTILUS_TYPE_OPEN_FLAGS);
 }
 
 void
@@ -589,7 +581,7 @@ button_clicked_cb (GtkButton *button,
     {
         g_signal_emit (button_data->path_bar, path_bar_signals[OPEN_LOCATION], 0,
                        button_data->path,
-                       GTK_PLACES_OPEN_NEW_WINDOW);
+                       NAUTILUS_OPEN_FLAG_NEW_WINDOW);
     }
     else
     {
@@ -713,7 +705,7 @@ on_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
             {
                 g_signal_emit (self, path_bar_signals[OPEN_LOCATION], 0,
                                button_data->path,
-                               GTK_PLACES_OPEN_NEW_TAB);
+                               NAUTILUS_OPEN_FLAG_NEW_TAB);
             }
         }
         break;
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 57595ba13..eb442ad16 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1724,11 +1724,11 @@ nautilus_window_show_operation_notification (NautilusWindow *window,
 }
 
 static void
-path_bar_location_changed_callback (GtkWidget      *widget,
-                                    GFile          *location,
-                                    NautilusWindow *window)
+on_path_bar_open_location (NautilusWindow    *window,
+                           GFile             *location,
+                           NautilusOpenFlags  open_flags)
 {
-    nautilus_window_open_location_full (window, location, 0, NULL, NULL);
+    nautilus_window_open_location_full (window, location, open_flags, NULL, NULL);
 }
 
 static void
@@ -1888,10 +1888,8 @@ setup_toolbar (NautilusWindow *window)
     /* connect to the pathbar signals */
     path_bar = nautilus_toolbar_get_path_bar (NAUTILUS_TOOLBAR (window->toolbar));
 
-    g_signal_connect_object (path_bar, "path-clicked",
-                             G_CALLBACK (path_bar_location_changed_callback), window, 0);
     g_signal_connect_swapped (path_bar, "open-location",
-                              G_CALLBACK (open_location_cb), window);
+                              G_CALLBACK (on_path_bar_open_location), window);
 
     /* connect to the location entry signals */
     location_entry = nautilus_toolbar_get_location_entry (NAUTILUS_TOOLBAR (window->toolbar));


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