[nautilus/wip/cdavis/toolbar-refactor: 2/4] window: Make active-slot a property




commit b3366d0f6629404cbb5b0d6c9b766fb119b1c6f3
Author: Christopher Davis <christopherdavis gnome org>
Date:   Fri Jul 22 22:50:22 2022 -0400

    window: Make active-slot a property
    
    This will make managing the toolbars and child widgets
    easier.

 src/nautilus-window.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 9c8b8b78e..a4d92f22e 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -144,6 +144,14 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 G_DEFINE_TYPE (NautilusWindow, nautilus_window, ADW_TYPE_APPLICATION_WINDOW);
 
+enum {
+    PROP_0,
+    PROP_ACTIVE_SLOT,
+    N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
+
 static const GtkPadActionEntry pad_actions[] =
 {
     { GTK_PAD_ACTION_BUTTON, 0, -1, N_("Parent folder"), "up" },
@@ -1804,6 +1812,8 @@ nautilus_window_set_active_slot (NautilusWindow     *window,
 
         on_location_changed (window);
     }
+
+    g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_ACTIVE_SLOT]);
 }
 
 static void
@@ -2212,6 +2222,42 @@ nautilus_window_init (NautilusWindow *window)
                       G_CALLBACK (nautilus_window_key_bubble), NULL);
 }
 
+static void
+nautilus_window_get_property (GObject    *object,
+                              guint       prop_id,
+                              GValue     *value,
+                              GParamSpec *pspec)
+{
+    NautilusWindow *self = NAUTILUS_WINDOW (object);
+
+    switch (prop_id)
+    {
+        case PROP_ACTIVE_SLOT:
+            g_value_set_object (value, G_OBJECT (nautilus_window_get_active_slot (self)));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+nautilus_window_set_property (GObject      *object,
+                              guint         prop_id,
+                              const GValue *value,
+                              GParamSpec   *pspec)
+{
+    NautilusWindow *self = NAUTILUS_WINDOW (object);
+
+    switch (prop_id)
+    {
+        case PROP_ACTIVE_SLOT:
+            nautilus_window_set_active_slot (self, NAUTILUS_WINDOW_SLOT (g_value_get_object (value)));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
 static void
 nautilus_window_class_init (NautilusWindowClass *class)
 {
@@ -2222,6 +2268,8 @@ nautilus_window_class_init (NautilusWindowClass *class)
     oclass->dispose = nautilus_window_dispose;
     oclass->finalize = nautilus_window_finalize;
     oclass->constructed = nautilus_window_constructed;
+    oclass->get_property = nautilus_window_get_property;
+    oclass->set_property = nautilus_window_set_property;
 
     wclass->show = nautilus_window_show;
     wclass->realize = nautilus_window_realize;
@@ -2229,6 +2277,14 @@ nautilus_window_class_init (NautilusWindowClass *class)
 
     winclass->close_request = nautilus_window_close_request;
 
+    properties[PROP_ACTIVE_SLOT] =
+        g_param_spec_object ("active-slot",
+                             NULL, NULL,
+                             NAUTILUS_TYPE_WINDOW_SLOT,
+                             G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+
+    g_object_class_install_properties (oclass, N_PROPS, properties);
+
     gtk_widget_class_set_template_from_resource (wclass,
                                                  "/org/gnome/nautilus/ui/nautilus-window.ui");
     gtk_widget_class_bind_template_child (wclass, NautilusWindow, toolbar);


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