[nautilus/wip/exalm/libhandy: 1/3] window: Remove "dnd-window-slot" hack




commit 4f701e4a2d15eef5d77595a4dbcc1e84675d4cfc
Author: António Fernandes <antoniof gnome org>
Date:   Wed Jul 13 12:09:45 2022 +0100

    window: Remove "dnd-window-slot" hack
    
    When a tab is moved into another window, we must remove the slot from
    the old window.
    
    Currently, we do this conditionally in `GtkNotebook::page-removed`.
    The condition we use is a hack: we check for a boolean set as data.
    
    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.
    
    So, instead, we can use a simpler condition: check whether the slot
    has been removed from the slots list already. This way we can drop
    the hack.
    
    (Note: tab detaching is currently disabled, but this is a preparation
    to reenable it after porting to AdwTabView.)

 src/nautilus-application.c |  5 ++++-
 src/nautilus-window.c      | 16 +++++-----------
 2 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 2898e052c..1e6b542ea 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -385,7 +385,10 @@ real_open_location_full (NautilusApplication *self,
     {
         active_slot = nautilus_window_get_active_slot (active_window);
         /* Just for debug.*/
-        old_location = nautilus_window_slot_get_location (active_slot);
+        if (active_slot)
+        {
+            old_location = nautilus_window_slot_get_location (active_slot);
+        }
     }
 
 
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 60734e9f9..215422893 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1375,15 +1375,14 @@ notebook_page_removed_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)
+    /* If the tab has been moved to another window, we need to remove the slot
+     * from the current window here. Otherwise, if the tab has been closed, then
+     * we have*/
+    if (g_list_find (window->slots, slot))
     {
-        return;
+        remove_slot_from_window (slot, window);
     }
-
-    remove_slot_from_window (slot, window);
 }
 
 static void
@@ -1409,7 +1408,6 @@ notebook_create_window_cb (GtkNotebook *notebook,
 {
     NautilusApplication *app;
     NautilusWindow *new_window;
-    NautilusWindowSlot *slot;
 
     if (!NAUTILUS_IS_WINDOW_SLOT (page))
     {
@@ -1421,10 +1419,6 @@ notebook_create_window_cb (GtkNotebook *notebook,
     gtk_window_set_display (GTK_WINDOW (new_window),
                             gtk_widget_get_display (GTK_WIDGET (notebook)));
 
-    slot = NAUTILUS_WINDOW_SLOT (page);
-    g_object_set_data (G_OBJECT (slot), "dnd-window-slot",
-                       GINT_TO_POINTER (TRUE));
-
     return GTK_NOTEBOOK (new_window->notebook);
 }
 


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