[gnome-calendar/calendar-management] source-manager: add already connected sources to the list



commit df060c773a29c28c5ff052bdfb4708dfbfd27c7e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Feb 3 01:46:18 2015 -0200

    source-manager: add already connected sources to the list

 src/gcal-source-manager-dialog.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-source-manager-dialog.c b/src/gcal-source-manager-dialog.c
index 3ec94b0..0bc5cd5 100644
--- a/src/gcal-source-manager-dialog.c
+++ b/src/gcal-source-manager-dialog.c
@@ -33,6 +33,8 @@ struct _GcalSourceManagerDialogPrivate
   GHashTable              *row_to_source;
   GHashTable              *source_to_row;
 
+  /* actions */
+  GSimpleActionGroup *action_group;
 
   /* properties */
   GcalManager             *manager; /* weak ref */
@@ -72,6 +74,8 @@ static void     source_removed_cb                          (GcalManager
                                                             gpointer             user_data);
 
 /* private */
+static void       fill_sources_list                        (GcalSourceManagerDialog *dialog);
+
 static GtkWidget* make_row_for_source                      (GcalSourceManagerDialog *dialog,
                                                             ESource                 *source);
 
@@ -255,6 +259,24 @@ source_removed_cb (GcalManager *manager,
   g_hash_table_remove (priv->source_to_row, source);
 }
 
+static void
+fill_sources_list (GcalSourceManagerDialog *dialog)
+{
+  GcalSourceManagerDialogPrivate *priv;
+  GList *sources, *aux;
+
+  priv = gcal_source_manager_dialog_get_instance_private (dialog);
+
+  sources = gcal_manager_get_sources_connected (priv->manager);
+
+  for (aux = sources; aux != NULL; aux = aux->next)
+    {
+      source_added_cb (priv->manager, aux->data, TRUE, dialog);
+    }
+
+  g_list_free (sources);
+}
+
 /**
  * make_row_for_source:
  *
@@ -362,6 +384,7 @@ gcal_source_manager_dialog_set_property (GObject      *object,
         priv->manager = g_value_get_pointer (value);
         g_signal_connect (priv->manager, "source-added", G_CALLBACK (source_added_cb), object);
         g_signal_connect (priv->manager, "source-removed", G_CALLBACK (source_removed_cb), object);
+        fill_sources_list (GCAL_SOURCE_MANAGER_DIALOG (object));
         break;
 
       default:
@@ -407,6 +430,7 @@ static void
 gcal_source_manager_dialog_constructed (GObject *object)
 {
   GcalSourceManagerDialogPrivate *priv;
+  GSimpleAction *file_action, *url_action;
 
   GtkBuilder *builder;
   GMenuModel *sourcesmenu;
@@ -427,6 +451,18 @@ gcal_source_manager_dialog_constructed (GObject *object)
 
   g_object_unref (builder);
 
+  /* action group */
+  priv->action_group = g_simple_action_group_new ();
+  gtk_widget_insert_action_group (GTK_WIDGET (object), "sources", G_ACTION_GROUP (priv->action_group));
+
+  /* sources.file action */
+  file_action = g_simple_action_new ("file", NULL);
+  g_action_map_add_action (G_ACTION_MAP (priv->action_group), G_ACTION (file_action));
+
+  /* sources.file action */
+  url_action = g_simple_action_new ("url", NULL);
+  g_action_map_add_action (G_ACTION_MAP (priv->action_group), G_ACTION (url_action));
+
   /* add separators to the listbox */
   gtk_list_box_set_header_func (GTK_LIST_BOX (priv->sources_listbox), display_header_func, NULL, NULL);
   gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->sources_listbox), sort_func_cb, object, NULL);


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