date-selector: Use parameter specs to declare properties
This commit is contained in:
+13
-11
@@ -37,14 +37,16 @@ struct _GcalDateSelector
|
|||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GcalDateSelector, gcal_date_selector, GTK_TYPE_ENTRY);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_DATE,
|
PROP_DATE,
|
||||||
LAST_PROP
|
N_PROPS
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (GcalDateSelector, gcal_date_selector, GTK_TYPE_ENTRY);
|
static GParamSpec* properties[N_PROPS] = { NULL, };
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_text (GcalDateSelector *self)
|
update_text (GcalDateSelector *self)
|
||||||
@@ -66,7 +68,7 @@ calendar_day_selected (GcalDateSelector *self)
|
|||||||
{
|
{
|
||||||
update_text (self);
|
update_text (self);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (self), "date");
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DATE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -204,13 +206,13 @@ gcal_date_selector_class_init (GcalDateSelectorClass *klass)
|
|||||||
*
|
*
|
||||||
* The current date of the selector.
|
* The current date of the selector.
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (object_class,
|
properties[PROP_DATE] = g_param_spec_boxed ("date",
|
||||||
PROP_DATE,
|
"Date of the selector",
|
||||||
g_param_spec_boxed ("date",
|
"The current date of the selector",
|
||||||
"Date of the selector",
|
G_TYPE_DATE_TIME,
|
||||||
"The current date of the selector",
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||||
G_TYPE_DATE_TIME,
|
|
||||||
G_PARAM_READWRITE));
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
|
||||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/date-selector.ui");
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/date-selector.ui");
|
||||||
|
|
||||||
@@ -262,7 +264,7 @@ gcal_date_selector_set_date (GcalDateSelector *selector,
|
|||||||
update_text (selector);
|
update_text (selector);
|
||||||
|
|
||||||
/* emit the MODIFIED signal */
|
/* emit the MODIFIED signal */
|
||||||
g_object_notify (G_OBJECT (selector), "date");
|
g_object_notify_by_pspec (G_OBJECT (selector), properties[PROP_DATE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user