edit-dialog: add ::writable and ::manager properties
By using these properties, we gain the possibility to bind them to the widgets and save some needless code. This commit adds GcalEditDialog::writable and ::manager properties. Other needed properties will be eventually added in the subsequent commits.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="lock">
|
||||
<property name="visible" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default|invert-boolean" />
|
||||
<property name="icon_name">changes-prevent-symbolic</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
@@ -135,6 +136,7 @@
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="activates_default">True</property>
|
||||
<property name="editable" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
||||
<signal name="notify::text" handler="update_summary" object="GcalEditDialog" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -167,6 +169,7 @@
|
||||
<property name="can_focus">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="label" translatable="yes">All day</property>
|
||||
<property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
||||
<signal name="toggled" handler="gcal_edit_dialog_all_day_changed" object="GcalEditDialog" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -180,6 +183,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="secondary_icon_name">find-location-symbolic</property>
|
||||
<property name="editable" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
||||
<signal name="notify::text" handler="update_location" object="GcalEditDialog" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -202,6 +206,7 @@
|
||||
<property name="hexpand">True</property>
|
||||
<property name="left_margin">6</property>
|
||||
<property name="right_margin">6</property>
|
||||
<property name="editable" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
||||
<property name="wrap_mode">GTK_WRAP_WORD_CHAR</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -223,6 +228,7 @@
|
||||
<object class="GcalDateSelector" id="start_date_selector">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
||||
<signal name="modified" handler="update_date" object="GcalEditDialog" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -258,6 +264,7 @@
|
||||
<object class="GcalDateSelector" id="end_date_selector">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
||||
<signal name="modified" handler="update_date" object="GcalEditDialog" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -286,6 +293,7 @@
|
||||
<object class="GtkButton" id="delete_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="sensitive" bind-source="GcalEditDialog" bind-property="writable" bind-flags="default" />
|
||||
<signal name="clicked" handler="gcal_edit_dialog_action_button_clicked" object="GcalEditDialog" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkLabel" id="delete_label">
|
||||
|
||||
+101
-27
@@ -112,6 +112,14 @@ static void gcal_edit_dialog_all_day_changed (GtkWidget *wi
|
||||
|
||||
G_DEFINE_TYPE (GcalEditDialog, gcal_edit_dialog, GTK_TYPE_DIALOG)
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_MANAGER,
|
||||
PROP_WRITABLE,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
static void
|
||||
fill_sources_menu (GcalEditDialog *dialog)
|
||||
{
|
||||
@@ -468,6 +476,52 @@ update_time (GtkEntry *entry,
|
||||
e_cal_component_free_datetime (&dtend);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_edit_dialog_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GcalEditDialog *self = GCAL_EDIT_DIALOG (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_MANAGER:
|
||||
g_value_set_object (value, self->manager);
|
||||
break;
|
||||
|
||||
case PROP_WRITABLE:
|
||||
g_value_set_boolean (value, self->writable);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_edit_dialog_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GcalEditDialog *self = GCAL_EDIT_DIALOG (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_MANAGER:
|
||||
gcal_edit_dialog_set_manager (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_WRITABLE:
|
||||
gcal_edit_dialog_set_writable (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_edit_dialog_class_init (GcalEditDialogClass *klass)
|
||||
{
|
||||
@@ -475,12 +529,40 @@ gcal_edit_dialog_class_init (GcalEditDialogClass *klass)
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
object_class->get_property = gcal_edit_dialog_get_property;
|
||||
object_class->set_property = gcal_edit_dialog_set_property;
|
||||
object_class->constructed = gcal_edit_dialog_constructed;
|
||||
object_class->finalize = gcal_edit_dialog_finalize;
|
||||
|
||||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/edit-dialog.ui");
|
||||
|
||||
/**
|
||||
* 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));
|
||||
|
||||
/**
|
||||
* 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));
|
||||
|
||||
/* Buttons */
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, done_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, cancel_button);
|
||||
@@ -574,6 +656,7 @@ gcal_edit_dialog_finalize (GObject *object)
|
||||
g_clear_object (&dialog->action_group);
|
||||
g_clear_object (&dialog->action);
|
||||
g_clear_object (&dialog->component);
|
||||
g_clear_object (&dialog->manager);
|
||||
g_clear_object (&dialog->source);
|
||||
|
||||
G_OBJECT_CLASS (gcal_edit_dialog_parent_class)->finalize (object);
|
||||
@@ -583,35 +666,25 @@ static void
|
||||
gcal_edit_dialog_set_writable (GcalEditDialog *dialog,
|
||||
gboolean writable)
|
||||
{
|
||||
dialog->writable = writable;
|
||||
|
||||
gtk_widget_set_visible (dialog->lock, !writable);
|
||||
|
||||
gtk_editable_set_editable (GTK_EDITABLE (dialog->summary_entry), writable);
|
||||
gtk_editable_set_editable (GTK_EDITABLE (dialog->location_entry), writable);
|
||||
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (dialog->notes_text), writable);
|
||||
|
||||
gtk_widget_set_sensitive (dialog->all_day_check, writable);
|
||||
gtk_widget_set_sensitive (dialog->end_date_selector, writable);
|
||||
gtk_widget_set_sensitive (dialog->start_date_selector, writable);
|
||||
|
||||
if (!writable || (writable && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->all_day_check))))
|
||||
if (dialog->writable != writable)
|
||||
{
|
||||
gtk_widget_set_sensitive (dialog->start_time_selector, FALSE);
|
||||
gtk_widget_set_sensitive (dialog->end_time_selector, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (dialog->start_time_selector, TRUE);
|
||||
gtk_widget_set_sensitive (dialog->end_time_selector, TRUE);
|
||||
}
|
||||
dialog->writable = writable;
|
||||
|
||||
gtk_button_set_label (GTK_BUTTON (dialog->done_button),
|
||||
writable ? _("Save") : _("Done"));
|
||||
gtk_button_set_label (GTK_BUTTON (dialog->done_button), writable ? _("Save") : _("Done"));
|
||||
|
||||
/* add delete_button here */
|
||||
gtk_widget_set_sensitive (dialog->delete_button, writable);
|
||||
if (!writable || (writable && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->all_day_check))))
|
||||
{
|
||||
gtk_widget_set_sensitive (dialog->start_time_selector, FALSE);
|
||||
gtk_widget_set_sensitive (dialog->end_time_selector, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (dialog->start_time_selector, TRUE);
|
||||
gtk_widget_set_sensitive (dialog->end_time_selector, TRUE);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (dialog), "writable");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -879,7 +952,8 @@ gcal_edit_dialog_set_manager (GcalEditDialog *dialog,
|
||||
g_return_if_fail (GCAL_IS_EDIT_DIALOG (dialog));
|
||||
g_return_if_fail (GCAL_IS_MANAGER (manager));
|
||||
|
||||
dialog->manager = manager;
|
||||
if (g_set_object (&dialog->manager, manager))
|
||||
g_object_notify (G_OBJECT (dialog), "manager");
|
||||
}
|
||||
|
||||
ECalComponent*
|
||||
|
||||
Reference in New Issue
Block a user