[gnome-calendar] source-dialog: only add the source when it's not present
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] source-dialog: only add the source when it's not present
- Date: Mon, 25 May 2015 16:55:05 +0000 (UTC)
commit 30ca4c1d57a39507b9dc50b892236fe06411bdbc
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Apr 8 00:01:58 2015 -0300
source-dialog: only add the source when it's not present
src/gcal-source-dialog.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 6c0a2c3..7dca8fd 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -148,12 +148,29 @@ add_source (GcalManager *manager,
gpointer user_data)
{
GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
- GtkWidget *row;
+ GList *children, *l;
+ gboolean contains_source;
+
+ children = gtk_container_get_children (GTK_CONTAINER (priv->calendars_listbox));
+ contains_source = FALSE;
+
+ for (l = children; l != NULL; l = l->next)
+ {
+ if (g_object_get_data (l->data, "source") == source)
+ contains_source = TRUE;
+ }
- row = make_row_from_source (GCAL_SOURCE_DIALOG (user_data), source);
- g_object_set_data (G_OBJECT (row), "source", source);
+ if (!contains_source)
+ {
+ GtkWidget *row;
+
+ row = make_row_from_source (GCAL_SOURCE_DIALOG (user_data), source);
+ g_object_set_data (G_OBJECT (row), "source", source);
+
+ gtk_container_add (GTK_CONTAINER (priv->calendars_listbox), row);
+ }
- gtk_container_add (GTK_CONTAINER (priv->calendars_listbox), row);
+ g_list_free (children);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]