[nautilus/wip/cdavis/toolbar-refactor: 1/2] window: Make active-slot a property
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/cdavis/toolbar-refactor: 1/2] window: Make active-slot a property
- Date: Sat, 30 Jul 2022 23:22:10 +0000 (UTC)
commit 3beb983e8094ba1c5d49a924d23ead0424021cac
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 | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index d37c44eb3..e0eec7971 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -139,6 +139,15 @@ 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" },
@@ -1701,6 +1710,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
@@ -2104,6 +2115,52 @@ 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)
{
@@ -2114,6 +2171,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;
@@ -2121,6 +2180,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]