edit-dialog: Use parameter specs to define properties

This commit is contained in:
Georges Basile Stavracas Neto
2018-01-30 01:10:25 -02:00
parent f3b4f68bf0
commit f83826515e
+18 -22
View File
@@ -129,10 +129,12 @@ enum
PROP_MANAGER, PROP_MANAGER,
PROP_TIME_FORMAT, PROP_TIME_FORMAT,
PROP_WRITABLE, 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" }, { "select-calendar", on_calendar_selected, "s" },
}; };
@@ -276,7 +278,7 @@ gcal_edit_dialog_set_writable (GcalEditDialog *dialog,
dialog->writable = writable; dialog->writable = writable;
g_object_notify (G_OBJECT (dialog), "writable"); g_object_notify_by_pspec (G_OBJECT (dialog), properties[PROP_WRITABLE]);
} }
static void static void
@@ -782,53 +784,47 @@ gcal_edit_dialog_class_init (GcalEditDialogClass *klass)
* *
* The #GcalEvent being edited. * The #GcalEvent being edited.
*/ */
g_object_class_install_property (object_class, properties[PROP_EVENT] = g_param_spec_object ("event",
PROP_EVENT,
g_param_spec_object ("event",
"event of the dialog", "event of the dialog",
"The event being edited", "The event being edited",
GCAL_TYPE_EVENT, GCAL_TYPE_EVENT,
G_PARAM_READWRITE)); G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/** /**
* GcalEditDialog::manager: * GcalEditDialog::manager:
* *
* The #GcalManager of the dialog. * The #GcalManager of the dialog.
*/ */
g_object_class_install_property (object_class, properties[PROP_MANAGER] = g_param_spec_object ("manager",
PROP_MANAGER,
g_param_spec_object ("manager",
"Manager of the dialog", "Manager of the dialog",
"The manager of the dialog", "The manager of the dialog",
GCAL_TYPE_MANAGER, GCAL_TYPE_MANAGER,
G_PARAM_READWRITE)); G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/** /**
* GcalEditDialog::time-format: * GcalEditDialog::time-format:
* *
* The time format. * The time format.
*/ */
g_object_class_install_property (object_class, properties[PROP_TIME_FORMAT] = g_param_spec_enum ("time-format",
PROP_TIME_FORMAT,
g_param_spec_enum ("time-format",
"Manager of the dialog", "Manager of the dialog",
"The manager of the dialog", "The manager of the dialog",
GCAL_TYPE_TIME_FORMAT, GCAL_TYPE_TIME_FORMAT,
GCAL_TIME_FORMAT_24H, GCAL_TIME_FORMAT_24H,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/** /**
* GcalEditDialog::writable: * GcalEditDialog::writable:
* *
* Whether the current event can be edited or not. * Whether the current event can be edited or not.
*/ */
g_object_class_install_property (object_class, properties[PROP_WRITABLE] = g_param_spec_boolean ("writable",
PROP_WRITABLE,
g_param_spec_boolean ("writable",
"Whether the current event can be edited", "Whether the current event can be edited",
"Whether the current event can be edited or not", "Whether the current event can be edited or not",
TRUE, TRUE,
G_PARAM_READWRITE)); 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"); 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->start_time_selector), dialog->time_format);
gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (dialog->end_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); setup_alarms (dialog);
out: out:
g_object_notify (G_OBJECT (dialog), "event"); g_object_notify_by_pspec (G_OBJECT (dialog), properties[PROP_EVENT]);
dialog->setting_event = FALSE; dialog->setting_event = FALSE;
@@ -1455,7 +1451,7 @@ gcal_edit_dialog_set_manager (GcalEditDialog *dialog,
g_return_if_fail (GCAL_IS_MANAGER (manager)); g_return_if_fail (GCAL_IS_MANAGER (manager));
if (g_set_object (&dialog->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* static GDateTime*