[gnome-calendar/calendar-editor] source-dialog: spawn online accounts creation on row activation



commit e5db7c8221da1b80d33ac3aaafd098e9db1becf5
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Apr 30 16:48:17 2015 -0300

    source-dialog: spawn online accounts creation on row activation

 src/gcal-source-dialog.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 99c5e19..b8be16f 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -21,6 +21,7 @@
 #include "gcal-utils.h"
 
 #include <glib/gi18n.h>
+#include <goa/goa.h>
 #include <libedataserverui/libedataserverui.h>
 
 typedef struct
@@ -70,6 +71,11 @@ typedef struct
   GtkWidget          *calendars_listbox;
   GtkWidget          *online_accounts_listbox;
 
+  /* stub goa rows */
+  GtkWidget          *exchange_stub_row;
+  GtkWidget          *google_stub_row;
+  GtkWidget          *owncloud_stub_row;
+
   /* flags */
   GcalSourceDialogMode mode;
   ESource            *source;
@@ -155,6 +161,10 @@ static void       name_entry_text_changed               (GObject             *ob
                                                          GParamSpec          *pspec,
                                                          gpointer             user_data);
 
+static void       online_accounts_listbox_row_activated (GtkListBox          *box,
+                                                         GtkListBoxRow       *row,
+                                                         gpointer             user_data);
+
 static void       online_accounts_settings_button_clicked (GtkWidget         *button,
                                                           gpointer            user_data);
 
@@ -640,6 +650,45 @@ name_entry_text_changed (GObject    *object,
     e_source_set_display_name (priv->source, gtk_entry_get_text (GTK_ENTRY (priv->name_entry)));
 }
 
+static void
+spawn_goa_with_args (gchar *action,
+                     gchar *arg)
+{
+  gchar *command[] = {"gnome-control-center", "online-accounts", action, arg, NULL};
+  g_spawn_async (NULL, command, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
+}
+
+/**
+ * online_accounts_listbox_row_activated:
+ *
+ * Selects the online account, or add one.
+ *
+ * Returns:
+ */
+static void
+online_accounts_listbox_row_activated (GtkListBox    *box,
+                                       GtkListBoxRow *row,
+                                       gpointer       user_data)
+{
+  GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
+
+  if ((GtkWidget*) row == priv->exchange_stub_row)
+    {
+      spawn_goa_with_args ("add", "exchange");
+    }
+  else if ((GtkWidget*) row == priv->google_stub_row)
+    {
+      spawn_goa_with_args ("add", "google");
+    }
+  else if ((GtkWidget*) row == priv->owncloud_stub_row)
+    {
+      spawn_goa_with_args ("add", "owncloud");
+    }
+  else
+    {
+    }
+}
+
 /**
  * response_signal:
  *
@@ -1806,12 +1855,15 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, credentials_user_entry);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, default_check);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, edit_grid);
+  gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, exchange_stub_row);
+  gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, google_stub_row);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, headerbar);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, location_dim_label);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, name_entry);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, notification);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, notification_label);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, online_accounts_listbox);
+  gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, owncloud_stub_row);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, remove_button);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, stack);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, web_sources_listbox);
@@ -1833,6 +1885,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, hide_notification);
   gtk_widget_class_bind_template_callback (widget_class, name_entry_text_changed);
   gtk_widget_class_bind_template_callback (widget_class, notification_child_revealed_changed);
+  gtk_widget_class_bind_template_callback (widget_class, online_accounts_listbox_row_activated);
   gtk_widget_class_bind_template_callback (widget_class, online_accounts_settings_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, remove_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, response_signal);


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