[gnome-calendar] edit-dialog: Use parameter specs to define properties
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] edit-dialog: Use parameter specs to define properties
- Date: Tue, 30 Jan 2018 03:11:35 +0000 (UTC)
commit f83826515ed9ca5da63cddd35287dd02c1900335
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jan 30 01:10:25 2018 -0200
edit-dialog: Use parameter specs to define properties
src/gcal-edit-dialog.c | 66 ++++++++++++++++++++++++--------------------------
1 file changed, 31 insertions(+), 35 deletions(-)
---
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index c20dd1e1..182afde8 100644
--- a/src/gcal-edit-dialog.c
+++ b/src/gcal-edit-dialog.c
@@ -129,10 +129,12 @@ enum
PROP_MANAGER,
PROP_TIME_FORMAT,
PROP_WRITABLE,
- LAST_PROP
+ N_PROPS
};
-const GActionEntry action_entries[] =
+static GParamSpec* properties[N_PROPS] = { NULL, };
+
+static const GActionEntry action_entries[] =
{
{ "select-calendar", on_calendar_selected, "s" },
};
@@ -276,7 +278,7 @@ gcal_edit_dialog_set_writable (GcalEditDialog *dialog,
dialog->writable = writable;
- g_object_notify (G_OBJECT (dialog), "writable");
+ g_object_notify_by_pspec (G_OBJECT (dialog), properties[PROP_WRITABLE]);
}
static void
@@ -782,53 +784,47 @@ gcal_edit_dialog_class_init (GcalEditDialogClass *klass)
*
* The #GcalEvent being edited.
*/
- g_object_class_install_property (object_class,
- PROP_EVENT,
- g_param_spec_object ("event",
- "event of the dialog",
- "The event being edited",
- GCAL_TYPE_EVENT,
- G_PARAM_READWRITE));
+ properties[PROP_EVENT] = g_param_spec_object ("event",
+ "event of the dialog",
+ "The event being edited",
+ GCAL_TYPE_EVENT,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
/**
* GcalEditDialog::manager:
*
* The #GcalManager of the dialog.
*/
- g_object_class_install_property (object_class,
- PROP_MANAGER,
- g_param_spec_object ("manager",
- "Manager of the dialog",
- "The manager of the dialog",
- GCAL_TYPE_MANAGER,
- G_PARAM_READWRITE));
+ properties[PROP_MANAGER] = g_param_spec_object ("manager",
+ "Manager of the dialog",
+ "The manager of the dialog",
+ GCAL_TYPE_MANAGER,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
/**
* GcalEditDialog::time-format:
*
* The time format.
*/
- g_object_class_install_property (object_class,
- PROP_TIME_FORMAT,
- g_param_spec_enum ("time-format",
- "Manager of the dialog",
- "The manager of the dialog",
- GCAL_TYPE_TIME_FORMAT,
- GCAL_TIME_FORMAT_24H,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ properties[PROP_TIME_FORMAT] = g_param_spec_enum ("time-format",
+ "Manager of the dialog",
+ "The manager of the dialog",
+ GCAL_TYPE_TIME_FORMAT,
+ GCAL_TIME_FORMAT_24H,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
/**
* GcalEditDialog::writable:
*
* Whether the current event can be edited or not.
*/
- g_object_class_install_property (object_class,
- PROP_WRITABLE,
- g_param_spec_boolean ("writable",
- "Whether the current event can be edited",
- "Whether the current event can be edited or not",
- TRUE,
- G_PARAM_READWRITE));
+ properties[PROP_WRITABLE] = g_param_spec_boolean ("writable",
+ "Whether the current event can be edited",
+ "Whether the current event can be edited or not",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/edit-dialog.ui");
@@ -1241,7 +1237,7 @@ gcal_edit_dialog_set_time_format (GcalEditDialog *dialog,
gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (dialog->start_time_selector), dialog->time_format);
gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (dialog->end_time_selector), dialog->time_format);
- g_object_notify (G_OBJECT (dialog), "time-format");
+ g_object_notify_by_pspec (G_OBJECT (dialog), properties[PROP_TIME_FORMAT]);
}
/**
@@ -1433,7 +1429,7 @@ gcal_edit_dialog_set_event (GcalEditDialog *dialog,
setup_alarms (dialog);
out:
- g_object_notify (G_OBJECT (dialog), "event");
+ g_object_notify_by_pspec (G_OBJECT (dialog), properties[PROP_EVENT]);
dialog->setting_event = FALSE;
@@ -1455,7 +1451,7 @@ gcal_edit_dialog_set_manager (GcalEditDialog *dialog,
g_return_if_fail (GCAL_IS_MANAGER (manager));
if (g_set_object (&dialog->manager, manager))
- g_object_notify (G_OBJECT (dialog), "manager");
+ g_object_notify_by_pspec (G_OBJECT (dialog), properties[PROP_MANAGER]);
}
static GDateTime*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]