[nautilus/wip/antoniof/gtk4-preparation-popovers: 81/83] notebook: Set action on close button




commit fcd4d53353fb83a27f6a43e30eacd940d5d41c83
Author: António Fernandes <antoniof gnome org>
Date:   Sun Dec 19 14:46:08 2021 +0000

    notebook: Set action on close button
    
    We listed to the button's "clicked" event and emit "tab-close-request",
    which NautilusWindow listens to and closes slot in response.
    
    Instead, we can make this a lot simpler by setting the equivalent action
    and removing the signals glue.

 src/nautilus-notebook.c | 35 +----------------------------------
 src/nautilus-window.c   | 12 ------------
 2 files changed, 1 insertion(+), 46 deletions(-)
---
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
index 6fed6e693..320a0786d 100644
--- a/src/nautilus-notebook.c
+++ b/src/nautilus-notebook.c
@@ -43,14 +43,6 @@ static int  nautilus_notebook_insert_page (GtkNotebook *notebook,
                                            GtkWidget   *menu_label,
                                            int          position);
 
-enum
-{
-    TAB_CLOSE_REQUEST,
-    LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
 struct _NautilusNotebook
 {
     GtkNotebook parent_instance;
@@ -73,17 +65,6 @@ nautilus_notebook_class_init (NautilusNotebookClass *klass)
     object_class->dispose = nautilus_notebook_dispose;
 
     notebook_class->insert_page = nautilus_notebook_insert_page;
-
-    signals[TAB_CLOSE_REQUEST] =
-        g_signal_new ("tab-close-request",
-                      G_OBJECT_CLASS_TYPE (object_class),
-                      G_SIGNAL_RUN_LAST,
-                      0,
-                      NULL, NULL,
-                      g_cclosure_marshal_VOID__OBJECT,
-                      G_TYPE_NONE,
-                      1,
-                      NAUTILUS_TYPE_WINDOW_SLOT);
 }
 
 static gint
@@ -272,19 +253,6 @@ nautilus_notebook_sync_tab_label (NautilusNotebook   *notebook,
     }
 }
 
-static void
-close_button_clicked_cb (GtkWidget          *widget,
-                         NautilusWindowSlot *slot)
-{
-    GtkWidget *notebook;
-
-    notebook = gtk_widget_get_ancestor (GTK_WIDGET (slot), NAUTILUS_TYPE_NOTEBOOK);
-    if (notebook != NULL)
-    {
-        g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, slot);
-    }
-}
-
 static GtkWidget *
 build_tab_label (NautilusNotebook   *notebook,
                  NautilusWindowSlot *slot)
@@ -326,8 +294,7 @@ build_tab_label (NautilusNotebook   *notebook,
     gtk_widget_set_name (close_button, "nautilus-tab-close-button");
 
     gtk_widget_set_tooltip_text (close_button, _("Close tab"));
-    g_signal_connect_object (close_button, "clicked",
-                             G_CALLBACK (close_button_clicked_cb), slot, 0);
+    gtk_actionable_set_action_name (GTK_ACTIONABLE (close_button), "win.close-current-view");
 
     gtk_box_pack_end (GTK_BOX (box), close_button, FALSE, FALSE, 0);
     gtk_widget_show (close_button);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 52cc02ad4..ab71eb5f7 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1770,15 +1770,6 @@ notebook_popup_menu_show (NautilusWindow *window,
     gtk_popover_popup (popover);
 }
 
-/* emitted when the user clicks the "close" button of tabs */
-static void
-notebook_tab_close_requested (NautilusNotebook   *notebook,
-                              NautilusWindowSlot *slot,
-                              NautilusWindow     *window)
-{
-    nautilus_window_slot_close (window, slot);
-}
-
 static void
 notebook_button_press_cb (GtkGestureMultiPress *gesture,
                           gint                  n_press,
@@ -1956,9 +1947,6 @@ notebook_create_window_cb (GtkNotebook *notebook,
 static void
 setup_notebook (NautilusWindow *window)
 {
-    g_signal_connect (window->notebook, "tab-close-request",
-                      G_CALLBACK (notebook_tab_close_requested),
-                      window);
     g_signal_connect (window->notebook, "popup-menu",
                       G_CALLBACK (notebook_popup_menu_cb),
                       window);


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