diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-11-09 19:01:27 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-11-09 19:01:27 -0500 |
commit | 2a6039e47fbd3fea159190a3afe8b7bebd120075 (patch) | |
tree | 295201d0d3d977e382c425b130b4bc6b4707b539 /gtk/gtkplacessidebar.c | |
parent | f911d17e562305bc6964a430b2be25cf5cad22b6 (diff) | |
download | gtk+-2a6039e47fbd3fea159190a3afe8b7bebd120075.tar.gz |
Filter out duplicate application shortcuts
The file chooser used to do this, the places sidebar
still needs to learn it.
https://bugzilla.gnome.org/show_bug.cgi?id=711636
Diffstat (limited to 'gtk/gtkplacessidebar.c')
-rw-r--r-- | gtk/gtkplacessidebar.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index ab1db3691f..7401aa3331 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -671,6 +671,38 @@ should_show_file (GtkPlacesSidebar *sidebar, return FALSE; } +static gboolean +file_is_shown (GtkPlacesSidebar *sidebar, + GFile *file) +{ + GtkTreeIter iter; + gchar *uri; + + if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (sidebar->store), &iter)) + return FALSE; + + do + { + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + PLACES_SIDEBAR_COLUMN_URI, &uri, + -1); + if (uri) + { + GFile *other; + gboolean found; + other = g_file_new_for_uri (uri); + g_free (uri); + found = g_file_equal (file, other); + g_object_unref (other); + if (found) + return TRUE; + } + } + while (gtk_tree_model_iter_next (sidebar->store, &iter)); + + return FALSE; +} + static void add_application_shortcuts (GtkPlacesSidebar *sidebar) { @@ -686,6 +718,9 @@ add_application_shortcuts (GtkPlacesSidebar *sidebar) if (!should_show_file (sidebar, file)) continue; + if (file_is_shown (sidebar, file)) + continue; + /* FIXME: we are getting file info synchronously. We may want to do it async at some point. */ info = g_file_query_info (file, "standard::display-name,standard::symbolic-icon", |