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



commit 45e9c07099562502ef350e33c5c72433515024e7
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.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770342

 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 920d850..dacfd4c 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 4f0a4db..6634888 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -157,7 +157,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);
@@ -706,11 +706,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]