From 397e5014130a447d7364851d4a43acb06100887a Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 31 Mar 2015 00:51:41 -0300 Subject: [PATCH] source-dialog: update source names --- data/ui/source-dialog.ui | 2 ++ src/gcal-source-dialog.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui index 2dfbf610..939c9c02 100644 --- a/data/ui/source-dialog.ui +++ b/data/ui/source-dialog.ui @@ -255,6 +255,7 @@ True True True + 1 @@ -409,6 +410,7 @@ True True True + 1 diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c index e559ab46..d951aeb3 100644 --- a/src/gcal-source-dialog.c +++ b/src/gcal-source-dialog.c @@ -97,6 +97,10 @@ static void name_entry_text_changed (GObject *ob GParamSpec *pspec, gpointer user_data); +static void new_name_entry_text_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data); + static void notebook_page_switched (GtkWidget *notebook, GtkWidget *page, guint page_num, @@ -262,6 +266,36 @@ name_entry_text_changed (GObject *object, e_source_set_display_name (priv->source, gtk_entry_get_text (GTK_ENTRY (priv->name_entry))); } +/** + * new_name_entry_text_changed: + * + * Callend when the name entry of a + * new to-be-added source is edited. + * It changes the source's display + * name, but wait's for the calendar's + * 'response' signal to commit these + * changes. + * + * Returns: + */ +static void +new_name_entry_text_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv; + ESource *source = NULL; + + if (GTK_WIDGET (object) == priv->web_new_calendar_name_entry) + source = priv->remote_source; + + if (GTK_WIDGET (object) == priv->new_calendar_name_entry) + source = priv->local_source; + + if (source != NULL) + e_source_set_display_name (source, gtk_entry_get_text (GTK_ENTRY (object))); +} + /** * notebook_page_switched: * @@ -949,6 +983,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, new_name_entry_text_changed); gtk_widget_class_bind_template_callback (widget_class, notebook_page_switched); gtk_widget_class_bind_template_callback (widget_class, response_signal); gtk_widget_class_bind_template_callback (widget_class, url_entry_text_changed);