Commit 5dd2e1f9 authored by Cosimo Cecchi's avatar Cosimo Cecchi

slot: make the NautilusWindow a construct property

Instead of setting it in _new(). This makes code more robust.
parent d9ef715e
......@@ -50,7 +50,13 @@ enum {
LAST_SIGNAL
};
enum {
PROP_WINDOW = 1,
NUM_PROPERTIES
};
static guint signals[LAST_SIGNAL] = { 0 };
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
gboolean
nautilus_window_slot_handle_event (NautilusWindowSlot *slot,
......@@ -286,10 +292,49 @@ floating_bar_action_cb (NautilusFloatingBar *floating_bar,
}
static void
nautilus_window_slot_init (NautilusWindowSlot *slot)
nautilus_window_slot_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (object);
switch (property_id) {
case PROP_WINDOW:
slot->window = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
nautilus_window_slot_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (object);
switch (property_id) {
case PROP_WINDOW:
g_value_set_object (value, slot->window);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
nautilus_window_slot_constructed (GObject *object)
{
NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (object);
GtkWidget *extras_vbox;
G_OBJECT_CLASS (nautilus_window_slot_parent_class)->constructed (object);
gtk_orientable_set_orientation (GTK_ORIENTABLE (slot),
GTK_ORIENTATION_VERTICAL);
gtk_widget_show (GTK_WIDGET (slot));
......@@ -323,6 +368,12 @@ nautilus_window_slot_init (NautilusWindowSlot *slot)
slot->title = g_strdup (_("Loading..."));
}
static void
nautilus_window_slot_init (NautilusWindowSlot *slot)
{
/* do nothing */
}
static void
nautilus_window_slot_dispose (GObject *object)
{
......@@ -400,6 +451,9 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
klass->inactive = real_inactive;
oclass->dispose = nautilus_window_slot_dispose;
oclass->constructed = nautilus_window_slot_constructed;
oclass->set_property = nautilus_window_slot_set_property;
oclass->get_property = nautilus_window_slot_get_property;
signals[ACTIVE] =
g_signal_new ("active",
......@@ -428,6 +482,15 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_STRING);
properties[PROP_WINDOW] =
g_param_spec_object ("window",
"The NautilusWindow",
"The NautilusWindow this slot is part of",
NAUTILUS_TYPE_WINDOW,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
}
GFile *
......@@ -781,10 +844,7 @@ nautilus_window_slot_should_close_with_mount (NautilusWindowSlot *slot,
NautilusWindowSlot *
nautilus_window_slot_new (NautilusWindow *window)
{
NautilusWindowSlot *slot;
slot = g_object_new (NAUTILUS_TYPE_WINDOW_SLOT, NULL);
slot->window = window;
return slot;
return g_object_new (NAUTILUS_TYPE_WINDOW_SLOT,
"window", window,
NULL);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment