[gnome-calendar] source-dialog: be sensitive to GcalManager::'source-removed' signal



commit 876d50fdabbb87663ea314554d5750ddff4c3ee3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Apr 8 19:36:07 2015 -0300

    source-dialog: be sensitive to GcalManager::'source-removed' signal

 src/gcal-source-dialog.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 54bc554..c7ec4c2 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -132,6 +132,10 @@ static void       new_name_entry_text_changed           (GObject             *ob
                                                          GParamSpec          *pspec,
                                                          gpointer             user_data);
 
+static void       remove_source                         (GcalManager         *manager,
+                                                         ESource             *source,
+                                                         gpointer             user_data);
+
 static void       response_signal                       (GtkDialog           *dialog,
                                                          gint                 response_id,
                                                          gpointer             user_data);
@@ -1156,6 +1160,43 @@ discover_sources_cb (GObject      *source,
   g_slist_free_full (user_adresses, g_free);
 }
 
+/**
+ * remove_source:
+ *
+ * Removes the given source from the source
+ * list.
+ *
+ * Returns:
+ */
+static void
+remove_source (GcalManager *manager,
+               ESource     *source,
+               gpointer     user_data)
+{
+  GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
+  GtkWidget *row;
+  GList *children, *aux;
+
+  children = gtk_container_get_children (GTK_CONTAINER (priv->calendars_listbox));
+  row = NULL;
+
+  for (aux = children; aux != NULL; aux = aux->next)
+    {
+      ESource *child_source = g_object_get_data (G_OBJECT (aux->data), "source");
+
+      if (child_source != NULL && child_source == source)
+        {
+          row = aux->data;
+          break;
+        }
+    }
+
+  if (row != NULL)
+    gtk_widget_destroy (row);
+
+  g_list_free (children);
+}
+
 GcalSourceDialog *
 gcal_source_dialog_new (void)
 {
@@ -1284,6 +1325,7 @@ gcal_source_dialog_set_manager (GcalSourceDialog *dialog,
     }
 
   g_signal_connect (priv->manager, "source-added", G_CALLBACK (add_source), dialog);
+  g_signal_connect (priv->manager, "source-removed", G_CALLBACK (remove_source), dialog);
   /* TODO: connect ::source-removed signals */
 }
 


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