gui/event-widget: Use modern practices for properties

Use a property array, install them all at once, and notify using
g_object_notify_by_pspec().

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/761>
This commit is contained in:
Georges Basile Stavracas Neto
2026-05-05 21:36:36 -03:00
parent 030d01b380
commit bfc4a7dc62
+13 -17
View File
@@ -80,8 +80,9 @@ enum
PROP_0, PROP_0,
PROP_EVENT, PROP_EVENT,
PROP_TIMESTAMP_POLICY, PROP_TIMESTAMP_POLICY,
N_PROPS,
PROP_ORIENTATION, PROP_ORIENTATION,
NUM_PROPS
}; };
enum enum
@@ -98,6 +99,7 @@ typedef enum
} CursorType; } CursorType;
static guint signals[NUM_SIGNALS] = { 0, }; static guint signals[NUM_SIGNALS] = { 0, };
static GParamSpec *properties[N_PROPS] = { NULL, };
static gboolean read_only_to_propagation_phase_cb (GBinding *binding, static gboolean read_only_to_propagation_phase_cb (GBinding *binding,
const GValue *from_value, const GValue *from_value,
@@ -771,13 +773,9 @@ gcal_event_widget_class_init (GcalEventWidgetClass *klass)
* *
* The event this widget represents. * The event this widget represents.
*/ */
g_object_class_install_property (object_class, properties[PROP_EVENT] = g_param_spec_object ("event", NULL, NULL,
PROP_EVENT, GCAL_TYPE_EVENT,
g_param_spec_object ("event", G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
"Event",
"The event this widget represents",
GCAL_TYPE_EVENT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/** /**
* GcalEventWidget::timestamp-policy: * GcalEventWidget::timestamp-policy:
@@ -787,14 +785,12 @@ gcal_event_widget_class_init (GcalEventWidgetClass *klass)
* Whether to show the start time, end time, or no time for the * Whether to show the start time, end time, or no time for the
* event. Depending on the event's kind, it will be an hour or a day. * event. Depending on the event's kind, it will be an hour or a day.
*/ */
g_object_class_install_property (object_class, properties[PROP_TIMESTAMP_POLICY] = g_param_spec_enum ("timestamp-policy", NULL, NULL,
PROP_TIMESTAMP_POLICY, GCAL_TYPE_TIMESTAMP_POLICY,
g_param_spec_enum ("timestamp-policy", GCAL_TIMESTAMP_POLICY_NONE,
"Timestamp Policy", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
"The policy for this widget's timestamp",
GCAL_TYPE_TIMESTAMP_POLICY, g_object_class_install_properties (object_class, N_PROPS, properties);
GCAL_TIMESTAMP_POLICY_NONE,
G_PARAM_READWRITE));
/** /**
* GcalEventWidget::orientation: * GcalEventWidget::orientation:
@@ -985,7 +981,7 @@ gcal_event_widget_set_timestamp_policy (GcalEventWidget *self,
gcal_event_widget_update_timestamp (self); gcal_event_widget_update_timestamp (self);
g_object_notify (G_OBJECT (self), "timestamp-policy"); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TIMESTAMP_POLICY]);
} }
} }