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
+31 -35
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, "event of the dialog",
g_param_spec_object ("event", "The event being edited",
"event of the dialog", GCAL_TYPE_EVENT,
"The event being edited", G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
GCAL_TYPE_EVENT,
G_PARAM_READWRITE));
/** /**
* 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, "Manager of the dialog",
g_param_spec_object ("manager", "The manager of the dialog",
"Manager of the dialog", GCAL_TYPE_MANAGER,
"The manager of the dialog", G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
GCAL_TYPE_MANAGER,
G_PARAM_READWRITE));
/** /**
* 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, "Manager of the dialog",
g_param_spec_enum ("time-format", "The manager of the dialog",
"Manager of the dialog", GCAL_TYPE_TIME_FORMAT,
"The manager of the dialog", GCAL_TIME_FORMAT_24H,
GCAL_TYPE_TIME_FORMAT, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
GCAL_TIME_FORMAT_24H,
G_PARAM_READWRITE | 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, "Whether the current event can be edited",
g_param_spec_boolean ("writable", "Whether the current event can be edited or not",
"Whether the current event can be edited", TRUE,
"Whether the current event can be edited or not", G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
TRUE,
G_PARAM_READWRITE)); 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*