event: Use parameter specs to declare properties

This commit is contained in:
Georges Basile Stavracas Neto
2018-01-30 01:10:08 -02:00
parent 2856131064
commit f3b4f68bf0
+114 -136
View File
@@ -135,6 +135,8 @@ enum {
N_PROPS N_PROPS
}; };
static GParamSpec* properties[N_PROPS] = { NULL, };
/* /*
* GcalEvent cache * GcalEvent cache
@@ -293,7 +295,7 @@ gcal_event_update_uid_internal (GcalEvent *self)
} }
e_cal_component_free_id (id); e_cal_component_free_id (id);
g_object_notify (G_OBJECT (self), "uid"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_UID]);
} }
static void static void
@@ -417,11 +419,11 @@ gcal_event_set_component_internal (GcalEvent *self,
/* Load and setup the alarms */ /* Load and setup the alarms */
load_alarms (self); load_alarms (self);
g_object_notify (G_OBJECT (self), "has-recurrence"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HAS_RECURRENCE]);
g_object_notify (G_OBJECT (self), "recurrence"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RECURRENCE]);
g_object_notify (G_OBJECT (self), "component"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COMPONENT]);
g_object_notify (G_OBJECT (self), "location"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LOCATION]);
g_object_notify (G_OBJECT (self), "summary"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SUMMARY]);
g_clear_pointer (&zone_start, g_time_zone_unref); g_clear_pointer (&zone_start, g_time_zone_unref);
g_clear_pointer (&zone_end, g_time_zone_unref); g_clear_pointer (&zone_end, g_time_zone_unref);
@@ -625,170 +627,146 @@ gcal_event_class_init (GcalEventClass *klass)
* *
* Whether the event is all day or not. * Whether the event is all day or not.
*/ */
g_object_class_install_property (object_class,
PROP_ALL_DAY, properties[PROP_ALL_DAY] = g_param_spec_boolean ("all-day",
g_param_spec_boolean ("all-day", "If event is all day",
"If event is all day", "Whether the event is all day or not",
"Whether the event is all day or not", FALSE,
FALSE, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
G_PARAM_READWRITE));
/** /**
* GcalEvent::color: * GcalEvent::color:
* *
* The color of the event. * The color of the event.
*/ */
g_object_class_install_property (object_class, properties[PROP_COLOR] = g_param_spec_boxed ("color",
PROP_COLOR, "Color of the event",
g_param_spec_boxed ("color", "The color of the event",
"Color of the event", GDK_TYPE_RGBA,
"The color of the event", G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
GDK_TYPE_RGBA,
G_PARAM_READWRITE));
/** /**
* GcalEvent::component: * GcalEvent::component:
* *
* The #ECalComponent of this event. * The #ECalComponent of this event.
*/ */
g_object_class_install_property (object_class, properties[PROP_COMPONENT] = g_param_spec_object ("component",
PROP_COMPONENT, "Component",
g_param_spec_object ("component", "The ECalComponent of the event",
"Component", E_TYPE_CAL_COMPONENT,
"The ECalComponent of the event", G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
E_TYPE_CAL_COMPONENT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/** /**
* GcalEvent::date-end: * GcalEvent::date-end:
* *
* The end date of the event. * The end date of the event.
*/ */
g_object_class_install_property (object_class, properties[PROP_DATE_END] = g_param_spec_boxed ("date-end",
PROP_DATE_END, "End date of the event",
g_param_spec_boxed ("date-end", "The end date of the event",
"End date of the event", G_TYPE_DATE_TIME,
"The end date of the event", G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
G_TYPE_DATE_TIME,
G_PARAM_READWRITE));
/** /**
* GcalEvent::date-start: * GcalEvent::date-start:
* *
* The start date of the event. * The start date of the event.
*/ */
g_object_class_install_property (object_class, properties[PROP_DATE_START] = g_param_spec_boxed ("date-start",
PROP_DATE_START, "Start date of the event",
g_param_spec_boxed ("date-start", "The start date of the event",
"Start date of the event", G_TYPE_DATE_TIME,
"The start date of the event", G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
G_TYPE_DATE_TIME,
G_PARAM_READWRITE));
/** /**
* GcalEvent::description: * GcalEvent::description:
* *
* The description of the event. * The description of the event.
*/ */
g_object_class_install_property (object_class, properties[PROP_DESCRIPTION] = g_param_spec_string ("description",
PROP_DESCRIPTION, "Description of the event",
g_param_spec_string ("description", "The description of the event",
"Description of the event", "",
"The description of the event", G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
"",
G_PARAM_READWRITE));
/**
* GcalEvent::location:
*
* The location of the event.
*/
g_object_class_install_property (object_class,
PROP_LOCATION,
g_param_spec_string ("location",
"Location of the event",
"The location of the event",
"",
G_PARAM_READWRITE));
/**
* GcalEvent::source:
*
* The #ESource this event belongs to.
*/
g_object_class_install_property (object_class,
PROP_SOURCE,
g_param_spec_object ("source",
"ESource",
"The ESource this event belongs to",
E_TYPE_SOURCE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
/**
* GcalEvent::summary:
*
* The summary of the event.
*/
g_object_class_install_property (object_class,
PROP_SUMMARY,
g_param_spec_string ("summary",
"Summary of the event",
"The summary of the event",
"",
G_PARAM_READWRITE));
/**
* GcalEvent::timezone:
*
* The timezone of the event.
*/
g_object_class_install_property (object_class,
PROP_TIMEZONE,
g_param_spec_boxed ("timezone",
"Timezone of the event",
"The timezone of the event",
G_TYPE_TIME_ZONE,
G_PARAM_READWRITE));
/**
* GcalEvent::uid:
*
* The unique identifier of the event.
*/
g_object_class_install_property (object_class,
PROP_UID,
g_param_spec_string ("uid",
"Identifier of the event",
"The unique identifier of the event",
"",
G_PARAM_READABLE));
/** /**
* GcalEvent::has-recurrence: * GcalEvent::has-recurrence:
* *
* The recurrence property of the event. * The recurrence property of the event.
*/ */
g_object_class_install_property (object_class, properties[PROP_HAS_RECURRENCE] = g_param_spec_boolean ("has-recurrence",
PROP_HAS_RECURRENCE, "If event has recurrence",
g_param_spec_boolean ("has-recurrence", "Whether the event has recurrence or not",
"If event has recurrence", FALSE,
"Whether the event has recurrence or not", G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
FALSE,
G_PARAM_READABLE)); /**
* GcalEvent::location:
*
* The location of the event.
*/
properties[PROP_LOCATION] = g_param_spec_string ("location",
"Location of the event",
"The location of the event",
"",
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/** /**
* GcalEvent::recurrence: * GcalEvent::recurrence:
* *
* The recurrence-rules property of the event. * The recurrence-rules property of the event.
*/ */
g_object_class_install_property (object_class, properties[PROP_RECURRENCE] = g_param_spec_boxed ("recurrence",
PROP_RECURRENCE, "Recurrence property of the event",
g_param_spec_boxed ("recurrence", "The recurrence property of the event",
"Recurrence property of the event", GCAL_TYPE_RECURRENCE,
"The recurrence property of the event", G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
GCAL_TYPE_RECURRENCE,
G_PARAM_READWRITE));
/**
* GcalEvent::source:
*
* The #ESource this event belongs to.
*/
properties[PROP_SOURCE] = g_param_spec_object ("source",
"ESource",
"The ESource this event belongs to",
E_TYPE_SOURCE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GcalEvent::summary:
*
* The summary of the event.
*/
properties[PROP_SUMMARY] = g_param_spec_string ("summary",
"Summary of the event",
"The summary of the event",
"",
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GcalEvent::timezone:
*
* The timezone of the event.
*/
properties[PROP_TIMEZONE] = g_param_spec_boxed ("timezone",
"Timezone of the event",
"The timezone of the event",
G_TYPE_TIME_ZONE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GcalEvent::uid:
*
* The unique identifier of the event.
*/
properties[PROP_UID] = g_param_spec_string ("uid",
"Identifier of the event",
"The unique identifier of the event",
"",
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
} }
static void static void
@@ -917,7 +895,7 @@ gcal_event_set_color (GcalEvent *self,
g_clear_pointer (&self->color, gdk_rgba_free); g_clear_pointer (&self->color, gdk_rgba_free);
self->color = gdk_rgba_copy (color); self->color = gdk_rgba_copy (color);
g_object_notify (G_OBJECT (self), "color"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR]);
} }
} }
@@ -954,7 +932,7 @@ gcal_event_set_all_day (GcalEvent *self,
{ {
self->all_day = all_day; self->all_day = all_day;
g_object_notify (G_OBJECT (self), "all-day"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ALL_DAY]);
} }
} }
@@ -1003,7 +981,7 @@ gcal_event_set_date_end (GcalEvent *self,
e_cal_component_set_dtend (self->component, component_dt); e_cal_component_set_dtend (self->component, component_dt);
e_cal_component_commit_sequence (self->component); e_cal_component_commit_sequence (self->component);
g_object_notify (G_OBJECT (self), "date-end"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DATE_END]);
e_cal_component_free_datetime (component_dt); e_cal_component_free_datetime (component_dt);
g_free (component_dt); g_free (component_dt);
@@ -1052,7 +1030,7 @@ gcal_event_set_date_start (GcalEvent *self,
e_cal_component_set_dtstart (self->component, component_dt); e_cal_component_set_dtstart (self->component, component_dt);
e_cal_component_commit_sequence (self->component); e_cal_component_commit_sequence (self->component);
g_object_notify (G_OBJECT (self), "date-start"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DATE_START]);
e_cal_component_free_datetime (component_dt); e_cal_component_free_datetime (component_dt);
g_free (component_dt); g_free (component_dt);
@@ -1105,7 +1083,7 @@ gcal_event_set_description (GcalEvent *self,
e_cal_component_set_description_list (self->component, &list); e_cal_component_set_description_list (self->component, &list);
e_cal_component_commit_sequence (self->component); e_cal_component_commit_sequence (self->component);
g_object_notify (G_OBJECT (self), "description"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DESCRIPTION]);
} }
} }
@@ -1321,7 +1299,7 @@ gcal_event_set_location (GcalEvent *self,
{ {
e_cal_component_set_location (self->component, location); e_cal_component_set_location (self->component, location);
g_object_notify (G_OBJECT (self), "location"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LOCATION]);
} }
} }
@@ -1388,7 +1366,7 @@ gcal_event_set_source (GcalEvent *self,
NULL); NULL);
} }
g_object_notify (G_OBJECT (self), "source"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SOURCE]);
gcal_event_update_uid_internal (self); gcal_event_update_uid_internal (self);
} }
@@ -1441,7 +1419,7 @@ gcal_event_set_summary (GcalEvent *self,
e_cal_component_set_summary (self->component, &text_component); e_cal_component_set_summary (self->component, &text_component);
e_cal_component_commit_sequence (self->component); e_cal_component_commit_sequence (self->component);
g_object_notify (G_OBJECT (self), "summary"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SUMMARY]);
} }
} }
@@ -1500,7 +1478,7 @@ gcal_event_set_timezone (GcalEvent *self,
g_clear_pointer (&new_dtstart, g_date_time_unref); g_clear_pointer (&new_dtstart, g_date_time_unref);
} }
g_object_notify (G_OBJECT (self), "timezone"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TIMEZONE]);
} }
} }