Store property GParamSpecs in an array for notify emission

This commit is contained in:
Gergely Polonkai 2014-08-13 00:51:26 +02:00
parent 68b46d2aee
commit 8bf5a49c4b
1 changed files with 89 additions and 78 deletions

View File

@ -79,10 +79,12 @@ enum {
PROP_GREGORIAN_SECOND, PROP_GREGORIAN_SECOND,
PROP_GREGORIAN_MICROSECOND, PROP_GREGORIAN_MICROSECOND,
PROP_GREGORIAN_TIMEZONE_OFFSET, PROP_GREGORIAN_TIMEZONE_OFFSET,
PROP_JULIAN_DAY_VALID PROP_JULIAN_DAY_VALID,
PROP_COUNT
}; };
static guint gswe_timestamp_signals[SIGNAL_LAST] = { 0 }; static guint gswe_timestamp_signals[SIGNAL_LAST] = { 0 };
static GParamSpec *gswe_timestamp_props[PROP_COUNT];
static void gswe_timestamp_dispose( static void gswe_timestamp_dispose(
GObject *gobject); GObject *gobject);
@ -150,15 +152,16 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* Otherwise, the values are recalculated only upon request (e.g. on * Otherwise, the values are recalculated only upon request (e.g. on
* calling gswe_timestamp_get_julian_day()). * calling gswe_timestamp_get_julian_day()).
*/ */
gswe_timestamp_props[PROP_INSTANT_RECALC] = g_param_spec_boolean(
"instant-recalc",
"Instant recalculation",
"Instantly recalculate values upon parameter change",
FALSE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_INSTANT_RECALC, PROP_INSTANT_RECALC,
g_param_spec_boolean( gswe_timestamp_props[PROP_INSTANT_RECALC]
"instant-recalc",
"Instant recalculation",
"Instantly recalculate values upon parameter change",
FALSE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE
)
); );
/** /**
@ -169,16 +172,16 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* Otherwise, the Gregorian date components will be recalculated upon * Otherwise, the Gregorian date components will be recalculated upon
* request. * request.
*/ */
gswe_timestamp_props[PROP_GREGORIAN_VALID] = g_param_spec_boolean(
"gregorian-valid",
"Gregorian date is valid",
"TRUE if the Gregorian date components are considered as valid.",
TRUE, G_PARAM_READABLE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_GREGORIAN_VALID, PROP_GREGORIAN_VALID,
g_param_spec_boolean( gswe_timestamp_props[PROP_GREGORIAN_VALID]
"gregorian-valid",
"Gregorian date is valid",
"TRUE if the Gregorian date components "
"are considered as valid.",
TRUE, G_PARAM_READABLE
)
); );
/** /**
@ -186,16 +189,17 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* *
* The Gregorian year of the timestamp * The Gregorian year of the timestamp
*/ */
gswe_timestamp_props[PROP_GREGORIAN_YEAR] = g_param_spec_int(
"gregorian-year",
"Gregorian year",
"The year according to the Gregorian calendar",
G_MININT, G_MAXINT, g_date_time_get_year(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_GREGORIAN_YEAR, PROP_GREGORIAN_YEAR,
g_param_spec_int( gswe_timestamp_props[PROP_GREGORIAN_YEAR]
"gregorian-year",
"Gregorian year",
"The year according to the Gregorian calendar",
G_MININT, G_MAXINT, g_date_time_get_year(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
)
); );
/** /**
@ -203,16 +207,17 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* *
* The Gregorian month of the timestamp * The Gregorian month of the timestamp
*/ */
gswe_timestamp_props[PROP_GREGORIAN_MONTH] = g_param_spec_int(
"gregorian-month",
"Gregorian month",
"The month according to the Gregorian calendar",
1, 12, g_date_time_get_month(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_GREGORIAN_MONTH, PROP_GREGORIAN_MONTH,
g_param_spec_int( gswe_timestamp_props[PROP_GREGORIAN_MONTH]
"gregorian-month",
"Gregorian month",
"The month according to the Gregorian calendar",
1, 12, g_date_time_get_month(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
)
); );
/** /**
@ -220,16 +225,17 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* *
* The Gregorian day of the timestamp * The Gregorian day of the timestamp
*/ */
gswe_timestamp_props[PROP_GREGORIAN_DAY] = g_param_spec_int(
"gregorian-day",
"Gregorian day",
"The day according to the Gregorian calendar",
1, 31, g_date_time_get_day_of_month(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_GREGORIAN_DAY, PROP_GREGORIAN_DAY,
g_param_spec_int( gswe_timestamp_props[PROP_GREGORIAN_DAY]
"gregorian-day",
"Gregorian day",
"The day according to the Gregorian calendar",
1, 31, g_date_time_get_day_of_month(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
)
); );
/** /**
@ -237,16 +243,17 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* *
* The Gregorian hour of the timestamp * The Gregorian hour of the timestamp
*/ */
gswe_timestamp_props[PROP_GREGORIAN_HOUR] = g_param_spec_int(
"gregorian-hour",
"Gregorian hour",
"The hour according to the Gregorian calendar",
0, 23, g_date_time_get_hour(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_GREGORIAN_HOUR, PROP_GREGORIAN_HOUR,
g_param_spec_int( gswe_timestamp_props[PROP_GREGORIAN_HOUR]
"gregorian-hour",
"Gregorian hour",
"The hour according to the Gregorian calendar",
0, 23, g_date_time_get_hour(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
)
); );
/** /**
@ -254,16 +261,17 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* *
* The Gregorian minute of the timestamp * The Gregorian minute of the timestamp
*/ */
gswe_timestamp_props[PROP_GREGORIAN_MINUTE] = g_param_spec_int(
"gregorian-minute",
"Gregorian minute",
"The minute according to the Gregorian calendar",
0, 59, g_date_time_get_minute(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_GREGORIAN_MINUTE, PROP_GREGORIAN_MINUTE,
g_param_spec_int( gswe_timestamp_props[PROP_GREGORIAN_MINUTE]
"gregorian-minute",
"Gregorian minute",
"The minute according to the Gregorian calendar",
0, 59, g_date_time_get_minute(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
)
); );
/** /**
@ -271,16 +279,17 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* *
* The Gregorian second of the timestamp * The Gregorian second of the timestamp
*/ */
gswe_timestamp_props[PROP_GREGORIAN_SECOND] = g_param_spec_int(
"gregorian-second",
"Gregorian second",
"The second according to the Gregorian calendar",
0, 61, g_date_time_get_second(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_GREGORIAN_SECOND, PROP_GREGORIAN_SECOND,
g_param_spec_int( gswe_timestamp_props[PROP_GREGORIAN_SECOND]
"gregorian-second",
"Gregorian second",
"The second according to the Gregorian calendar",
0, 61, g_date_time_get_second(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
)
); );
/** /**
@ -288,16 +297,17 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* *
* The Gregorian microsecond of the timestamp * The Gregorian microsecond of the timestamp
*/ */
gswe_timestamp_props[PROP_GREGORIAN_MICROSECOND] = g_param_spec_int(
"gregorian-microsecond",
"Gregorian microsecond",
"The microsecond according to the Gregorian calendar",
0, G_MAXINT, g_date_time_get_microsecond(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_GREGORIAN_MICROSECOND, PROP_GREGORIAN_MICROSECOND,
g_param_spec_int( gswe_timestamp_props[PROP_GREGORIAN_MICROSECOND]
"gregorian-microsecond",
"Gregorian microsecond",
"The microsecond according to the Gregorian calendar",
0, G_MAXINT, g_date_time_get_microsecond(local_time),
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
)
); );
/** /**
@ -305,17 +315,18 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* *
* The time zone offset in hours, relative to UTC * The time zone offset in hours, relative to UTC
*/ */
gswe_timestamp_props[PROP_GREGORIAN_TIMEZONE_OFFSET] = g_param_spec_double(
"gregorian-timezone-offset",
"Gregorian timezone offset",
"The offset relative to UTC in the Gregorian calendar",
-24.0, 24.0,
0.0,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_GREGORIAN_TIMEZONE_OFFSET, PROP_GREGORIAN_TIMEZONE_OFFSET,
g_param_spec_double( gswe_timestamp_props[PROP_GREGORIAN_TIMEZONE_OFFSET]
"gregorian-timezone-offset",
"Gregorian timezone offset",
"The offset relative to UTC in the Gregorian calendar",
-24.0, 24.0,
0.0,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE
)
); );
/** /**
@ -325,16 +336,16 @@ gswe_timestamp_class_init(GsweTimestampClass *klass)
* currently considered as valid, thus, no recalculation is needed. * currently considered as valid, thus, no recalculation is needed.
* Otherwise, the Julian day components will be recalculated upon request. * Otherwise, the Julian day components will be recalculated upon request.
*/ */
gswe_timestamp_props[PROP_JULIAN_DAY_VALID] = g_param_spec_boolean(
"julian-day-valid",
"Julian day is valid",
"TRUE if the Julian day components are considered as valid.",
TRUE, G_PARAM_READABLE
);
g_object_class_install_property( g_object_class_install_property(
gobject_class, gobject_class,
PROP_JULIAN_DAY_VALID, PROP_JULIAN_DAY_VALID,
g_param_spec_boolean( gswe_timestamp_props[PROP_JULIAN_DAY_VALID]
"julian-day-valid",
"Julian day is valid",
"TRUE if the Julian day components "
"are considered as valid.",
TRUE, G_PARAM_READABLE
)
); );
g_date_time_unref(local_time); g_date_time_unref(local_time);