[nautilus/wip/exalm/libhandy: 75/77] window-slot: Make allow_stop and title actual properties




commit a931fdd53a16a013f9f6c4a33c6087e13ddb3c75
Author: António Fernandes <antoniof gnome org>
Date:   Thu Jul 21 15:35:54 2022 +0200

    window-slot: Make allow_stop and title actual properties
    
    Based on larger patch by Alexander Mikhaylenko

 src/nautilus-window-slot.c | 48 +++++++++++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 3b0a83baf..a0bb238a7 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -62,6 +62,8 @@ enum
     PROP_SELECTION,
     PROP_LOCATION,
     PROP_TOOLTIP,
+    PROP_ALLOW_STOP,
+    PROP_TITLE,
     NUM_PROPERTIES
 };
 
@@ -865,6 +867,18 @@ nautilus_window_slot_get_property (GObject    *object,
         }
         break;
 
+        case PROP_ALLOW_STOP:
+        {
+            g_value_set_boolean (value, nautilus_window_slot_get_allow_stop (self));
+        }
+        break;
+
+        case PROP_TITLE:
+        {
+            g_value_set_string (value, nautilus_window_slot_get_title (self));
+        }
+        break;
+
         default:
         {
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -928,6 +942,7 @@ nautilus_window_slot_constructed (GObject *object)
                             G_BINDING_DEFAULT);
 
     self->title = g_strdup (_("Loading…"));
+    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
 }
 
 static void
@@ -3063,6 +3078,16 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
                              NULL,
                              G_PARAM_READWRITE);
 
+    properties[PROP_ALLOW_STOP] =
+        g_param_spec_boolean ("allow-stop", "", "",
+                              FALSE,
+                              G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+    properties[PROP_TITLE] =
+        g_param_spec_string ("title", "", "",
+                             NULL,
+                             G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
     g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
 }
 
@@ -3133,34 +3158,19 @@ void
 nautilus_window_slot_update_title (NautilusWindowSlot *self)
 {
     NautilusWindow *window;
-    char *title;
-    gboolean do_sync = FALSE;
+    g_autofree char *title = NULL;
     title = nautilus_compute_title_for_location (self->location);
     window = nautilus_window_slot_get_window (self);
 
     if (g_strcmp0 (title, self->title) != 0)
     {
-        do_sync = TRUE;
-
         g_free (self->title);
-        self->title = title;
-        title = NULL;
-    }
+        self->title = g_steal_pointer (&title);
 
-    if (strlen (self->title) > 0)
-    {
-        do_sync = TRUE;
-    }
+        g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
 
-    if (do_sync)
-    {
         nautilus_window_sync_title (window, self);
     }
-
-    if (title != NULL)
-    {
-        g_free (title);
-    }
 }
 
 gboolean
@@ -3180,6 +3190,8 @@ nautilus_window_slot_set_allow_stop (NautilusWindowSlot *self,
 
     window = nautilus_window_slot_get_window (self);
     nautilus_window_sync_allow_stop (window, self);
+
+    g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ALLOW_STOP]);
 }
 
 void


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