[nautilus/wip/exalm/libhandy: 2/7] window: Add slot in a single path




commit 8f371921785ad676e17ed67735f18be837050734
Author: António Fernandes <antoniof gnome org>
Date:   Wed Jul 13 11:41:49 2022 +0100

    window: Add slot in a single path
    
    Currently, we add a slot to the window in 2 situations:
    
      1. When a new slot is created (`nautilus_window_initialize_slot()`);
      2. When a slot moves to another window (`notebook_page_added_cb()`).
    
    However, `GtkNotebook::page-added` triggers in both cases, so we use
    a hack with g_object_set_data() to know whether it happened by DND.
    
    This hack is wrong because it catches only the cases when a tab is
    detached into a new window, not when it's detached and attached to
    an already existing window.
    
    Fortunately, `nautilus_window_initialize_slot()` already calls
    `nautilus_notebook_add_tab()`, which is going to cause an emission of
    `GtkNotebook::page-added`. Therefore, we can simply add the slot
    unconditionally and exclusively in `notebook_page_added_cb()`.
    
    (Note, tab detaching is currently disabled, but this is a preparation
    to reenable it after porting to AdwTabView.)

 src/nautilus-window.c | 17 -----------------
 1 file changed, 17 deletions(-)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index fc690e90a..be8c22847 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -544,9 +544,6 @@ nautilus_window_initialize_slot (NautilusWindow     *window,
     g_signal_handlers_unblock_by_func (window->notebook,
                                        G_CALLBACK (notebook_switch_page_cb),
                                        window);
-
-    window->slots = g_list_append (window->slots, slot);
-    g_signal_emit (window, signals[SLOT_ADDED], 0, slot);
 }
 
 void
@@ -1407,24 +1404,10 @@ notebook_page_added_cb (GtkNotebook *notebook,
 {
     NautilusWindow *window = user_data;
     NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (page);
-    gboolean dnd_slot;
-
-    dnd_slot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (slot), "dnd-window-slot"));
-    if (!dnd_slot)
-    {
-        return;
-    }
-
-    g_object_set_data (G_OBJECT (page), "dnd-window-slot",
-                       GINT_TO_POINTER (FALSE));
 
     nautilus_window_slot_set_window (slot, window);
     window->slots = g_list_append (window->slots, slot);
     g_signal_emit (window, signals[SLOT_ADDED], 0, slot);
-
-    nautilus_window_set_active_slot (window, slot);
-
-    gtk_widget_show (GTK_WIDGET (window));
 }
 
 static GtkNotebook *


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