[gnome-photos/wip/rishi/view-model: 3/6] Don't add a collection while we are browsing another one



commit 771c3ec034196b314e0c49298768e9455588f137
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Aug 23 19:54:05 2016 +0200

    Don't add a collection while we are browsing another one
    
    Since viewing a list of collections and browsing a specific collection
    share the same mode, we need to be careful that we don't insert a
    collection while we are browsing another.
    
    This can happen if a collection was created out of band (eg., by the
    miners), or if one was activated via the search provider. In the first
    case, we can ignore it because it is irrelevant to the current state
    of the application. In the second case, we should force it to come out
    of the current collection and then insert it.

 src/photos-application.c  |    2 +-
 src/photos-item-manager.c |   10 +++++++---
 src/photos-item-manager.h |    3 ++-
 3 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 624433a..47f32e1 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -700,7 +700,7 @@ photos_application_activate_query_executed (GObject *source_object, GAsyncResult
   if (cursor == NULL)
     goto out;
 
-  photos_item_manager_add_item (PHOTOS_ITEM_MANAGER (self->state->item_mngr), cursor);
+  photos_item_manager_add_item (PHOTOS_ITEM_MANAGER (self->state->item_mngr), cursor, TRUE);
 
   identifier = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_URN, NULL);
   item = photos_base_manager_get_object_by_id (self->state->item_mngr, identifier);
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 4c44da2..924d08f 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -155,7 +155,7 @@ photos_item_manager_item_created_executed (GObject *source_object, GAsyncResult
   if (cursor == NULL)
     goto out;
 
-  photos_item_manager_add_item (self, cursor);
+  photos_item_manager_add_item (self, cursor, FALSE);
 
  out:
   g_clear_object (&cursor);
@@ -704,11 +704,15 @@ photos_item_manager_activate_previous_collection (PhotosItemManager *self)
 
 
 void
-photos_item_manager_add_item (PhotosItemManager *self, TrackerSparqlCursor *cursor)
+photos_item_manager_add_item (PhotosItemManager *self, TrackerSparqlCursor *cursor, gboolean force)
 {
   if (photos_item_manager_cursor_is_collection (cursor))
     {
-      photos_item_manager_add_item_for_mode (self, PHOTOS_WINDOW_MODE_COLLECTIONS, cursor);
+      if (self->active_collection != NULL && force)
+        photos_item_manager_activate_previous_collection (self);
+
+      if (self->active_collection == NULL)
+        photos_item_manager_add_item_for_mode (self, PHOTOS_WINDOW_MODE_COLLECTIONS, cursor);
     }
   else
     {
diff --git a/src/photos-item-manager.h b/src/photos-item-manager.h
index c1b4c5e..367d9d3 100644
--- a/src/photos-item-manager.h
+++ b/src/photos-item-manager.h
@@ -86,7 +86,8 @@ PhotosBaseManager        *photos_item_manager_new                          (void
 void                      photos_item_manager_activate_previous_collection (PhotosItemManager *self);
 
 void                      photos_item_manager_add_item                     (PhotosItemManager *self,
-                                                                            TrackerSparqlCursor *cursor);
+                                                                            TrackerSparqlCursor *cursor,
+                                                                            gboolean force);
 
 void                      photos_item_manager_add_item_for_mode            (PhotosItemManager *self,
                                                                             PhotosWindowMode mode,


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