[gnome-control-center/gnome-3-8] sharing: prevent duplicate folders being selected for media sharing



commit 62c01003dd216368052760985d8915a2d02a49e4
Author: Thomas Wood <thomas wood intel com>
Date:   Wed Oct 2 16:42:18 2013 +0100

    sharing: prevent duplicate folders being selected for media sharing
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706661

 panels/sharing/cc-sharing-panel.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/panels/sharing/cc-sharing-panel.c b/panels/sharing/cc-sharing-panel.c
index 7650ee9..b3a88f6 100644
--- a/panels/sharing/cc-sharing-panel.c
+++ b/panels/sharing/cc-sharing-panel.c
@@ -403,6 +403,9 @@ cc_sharing_panel_add_folder (GtkWidget      *button,
   GtkWidget *dialog;
   GtkListStore *store;
   gchar *folder;
+  GtkTreeIter iter;
+  gboolean valid;
+  gboolean matching;
 
   dialog = gtk_file_chooser_dialog_new (_("Choose a Folder"),
                                         GTK_WINDOW (gtk_widget_get_toplevel (button)),
@@ -419,7 +422,21 @@ cc_sharing_panel_add_folder (GtkWidget      *button,
 
   folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
 
-  if (folder && !g_str_equal (folder, ""))
+  for (valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+       valid;
+       valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter))
+    {
+      gchar *string;
+
+      gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &string, -1);
+      matching = (g_strcmp0 (string, folder) != 0);
+      g_free (string);
+
+      if (matching)
+        break;
+    }
+
+  if (!matching && folder && !g_str_equal (folder, ""))
     gtk_list_store_insert_with_values (store, NULL, -1, 0, folder, -1);
 
   g_free (folder);


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