[totem] main: Don't allow adding duplicate items to recent



commit ddccdc94f5a1c9ba5a0b973901d09d35c792aa81
Author: Bastien Nocera <hadess hadess net>
Date:   Fri May 9 11:40:57 2014 +0200

    main: Don't allow adding duplicate items to recent
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729775

 src/totem-grilo.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/totem-grilo.c b/src/totem-grilo.c
index da8edfc..2133d77 100644
--- a/src/totem-grilo.c
+++ b/src/totem-grilo.c
@@ -2533,6 +2533,7 @@ totem_grilo_add_item_to_recent (TotemGrilo *self,
 {
        GrlMedia *media;
        GFile *file;
+       FindMediaData data;
 
        g_return_val_if_fail (TOTEM_IS_GRILO (self), FALSE);
 
@@ -2574,6 +2575,19 @@ totem_grilo_add_item_to_recent (TotemGrilo *self,
        if (!media)
                return FALSE;
 
+       data.found = FALSE;
+       data.key = GRL_METADATA_KEY_URL;
+       data.media = media;
+       data.iter = NULL;
+       gtk_tree_model_foreach (self->priv->recent_model, (GtkTreeModelForeachFunc) find_media_cb, &data);
+
+       if (data.found) {
+               g_debug ("URI '%s' is already present in the bookmarks, not adding duplicate", uri);
+               gtk_tree_iter_free (data.iter);
+               g_object_unref (media);
+               return FALSE;
+       }
+
        /* This should be quick, just adding the item to the DB */
        grl_source_store_sync (self->priv->bookmarks_src,
                               NULL,


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