[nautilus/wip/antoniof/post-gtk4-switch-fixes: 19/19] window: Drop size-allocate usage




commit c3112fa100755c1506208e53024ad5b5cbf4b27e
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Jan 7 08:40:54 2022 +0100

    window: Drop size-allocate usage
    
    The `size-allocate` signal is used to determine width of the sidebar, but
    it is no more availabe in GTK 4. Let's use `notifiy::position` on `GtkPaned`
    instead to get rid of the runtime warnings.

 src/nautilus-window.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 244adbf2a..93d3b56ff 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -829,12 +829,12 @@ save_sidebar_width_cb (gpointer user_data)
 
 /* side pane helpers */
 static void
-side_pane_size_allocate_callback (GtkWidget     *widget,
-                                  GtkAllocation *allocation,
-                                  gpointer       user_data)
+side_pane_notify_position_callback (GObject    *object,
+                                    GParamSpec *pspec,
+                                    gpointer    user_data)
 {
     NautilusWindow *window = user_data;
-
+    gint position;
 
     if (window->sidebar_width_handler_id != 0)
     {
@@ -842,10 +842,11 @@ side_pane_size_allocate_callback (GtkWidget     *widget,
         window->sidebar_width_handler_id = 0;
     }
 
-    if (allocation->width != window->side_pane_width &&
-        allocation->width > 1)
+    position = gtk_paned_get_position (GTK_PANED (window->content_paned));
+    if (position != window->side_pane_width &&
+        position > 1)
     {
-        window->side_pane_width = allocation->width;
+        window->side_pane_width = position;
 
         window->sidebar_width_handler_id =
             g_idle_add (save_sidebar_width_cb, window);
@@ -1312,9 +1313,9 @@ static void
 nautilus_window_set_up_sidebar (NautilusWindow *window)
 {
     setup_side_pane_width (window);
-    g_signal_connect (window->sidebar,
-                      "size-allocate",
-                      G_CALLBACK (side_pane_size_allocate_callback),
+    g_signal_connect (window->content_paned,
+                      "notify::position",
+                      G_CALLBACK (side_pane_notify_position_callback),
                       window);
 
     nautilus_gtk_places_sidebar_set_open_flags (NAUTILUS_GTK_PLACES_SIDEBAR (window->places_sidebar),


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