[gnome-calendar/calendar-editor] source-dialog: save the source when 'Add' button is clicked



commit 6ccb35222c0704ac53d1b4fd6bda5768524aa5cc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Apr 9 00:13:55 2015 -0300

    source-dialog: save the source when 'Add' button is clicked

 data/ui/source-dialog.ui |    2 +-
 src/gcal-source-dialog.c |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/source-dialog.ui b/data/ui/source-dialog.ui
index b983973..6e2c39c 100644
--- a/data/ui/source-dialog.ui
+++ b/data/ui/source-dialog.ui
@@ -818,7 +818,7 @@
             <property name="sensitive">False</property>
             <property name="can_focus">True</property>
             <property name="receives_default">True</property>
-            <signal name="clicked" handler="action_widget_activated" object="GcalSourceDialog" swapped="no"/>
+            <signal name="clicked" handler="add_button_clicked" object="GcalSourceDialog" swapped="no"/>
             <style>
               <class name="suggested-action"/>
             </style>
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index e0122d4..843a91b 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -81,6 +81,9 @@ struct _GcalSourceDialog
 
 #define ENTRY_PROGRESS_TIMEOUT            100
 
+static void       add_button_clicked                    (GtkWidget            *button,
+                                                         gpointer              user_data);
+
 static void       add_source                             (GcalManager         *manager,
                                                           ESource             *source,
                                                           gboolean             enabled,
@@ -180,6 +183,24 @@ GActionEntry actions[] = {
   {"web",   NULL,              NULL, NULL, NULL}
 };
 
+
+static void
+add_button_clicked (GtkWidget *button,
+                    gpointer   user_data)
+{
+  GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
+
+  if (priv->source != NULL)
+    {
+      // Commit the new source
+      gcal_manager_save_source (priv->manager, priv->source);
+
+      priv->source = NULL;
+
+      gcal_source_dialog_set_mode (GCAL_SOURCE_DIALOG (user_data), GCAL_SOURCE_DIALOG_MODE_NORMAL);
+    }
+}
+
 static void
 add_source (GcalManager *manager,
             ESource     *source,
@@ -1352,6 +1373,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, web_sources_listbox);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, web_sources_revealer);
 
+  gtk_widget_class_bind_template_callback (widget_class, add_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, action_widget_activated);
   gtk_widget_class_bind_template_callback (widget_class, back_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, calendar_file_selected);


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