diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui index 0545232f..6d790423 100644 --- a/data/ui/source-dialog.ui +++ b/data/ui/source-dialog.ui @@ -10,6 +10,7 @@ 450 550 500 + False diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c index 4341effd..e68f02fa 100644 --- a/src/gcal-source-dialog.c +++ b/src/gcal-source-dialog.c @@ -70,6 +70,10 @@ static void name_entry_text_changed (GObject *ob GParamSpec *pspec, gpointer user_data); +static void response_signal (GtkDialog *dialog, + gint response_id, + gpointer user_data); + G_DEFINE_TYPE_WITH_PRIVATE (GcalSourceDialog, gcal_source_dialog, GTK_TYPE_DIALOG) enum { @@ -100,6 +104,9 @@ action_widget_activated (GtkWidget *widget, priv->old_default_source = NULL; + /* save the source */ + gcal_manager_save_source (priv->manager, priv->source); + gtk_dialog_response (GTK_DIALOG (user_data), response); } @@ -189,6 +196,28 @@ name_entry_text_changed (GObject *object, e_source_set_display_name (priv->source, gtk_entry_get_text (GTK_ENTRY (priv->name_entry))); } +/** + * response_signal: + * + * Save the source when the dialog + * is close. + * + * Returns: + */ +static void +response_signal (GtkDialog *dialog, + gint response_id, + gpointer user_data) +{ + GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (dialog)->priv; + + /* save the source */ + if (priv->mode == GCAL_SOURCE_DIALOG_MODE_EDIT || response_id == GTK_RESPONSE_APPLY) + { + gcal_manager_save_source (priv->manager, priv->source); + } +} + GcalSourceDialog * gcal_source_dialog_new (void) { @@ -283,6 +312,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass) gtk_widget_class_bind_template_callback (widget_class, default_check_toggled); gtk_widget_class_bind_template_callback (widget_class, description_label_link_activated); gtk_widget_class_bind_template_callback (widget_class, name_entry_text_changed); + gtk_widget_class_bind_template_callback (widget_class, response_signal); } static void