[gnome-calendar/calendar-editor] source-dialog: update source names



commit 99369054be4643fdbd5fceba9ebbeff1041df454
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Mar 31 00:51:41 2015 -0300

    source-dialog: update source names

 data/ui/source-dialog.ui |    2 ++
 src/gcal-source-dialog.c |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui
index 2dfbf61..939c9c0 100644
--- a/data/ui/source-dialog.ui
+++ b/data/ui/source-dialog.ui
@@ -255,6 +255,7 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="hexpand">True</property>
+                                <signal name="notify::text" handler="new_name_entry_text_changed" 
object="GcalSourceDialog" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="left_attach">1</property>
@@ -409,6 +410,7 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="hexpand">True</property>
+                                <signal name="notify::text" handler="new_name_entry_text_changed" 
object="GcalSourceDialog" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="left_attach">1</property>
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index e559ab4..d951aeb 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,
@@ -263,6 +267,36 @@ name_entry_text_changed (GObject    *object,
 }
 
 /**
+ * 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:
  *
  * Validates the current state of
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]