[gnome-photos] source-manager: Ensure validity of active source



commit e1065ca6546f27c912cf505543e16a0d9d2068dd
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Feb 2 20:37:28 2018 +0100

    source-manager: Ensure validity of active source
    
    While updating the list of sources, if the current active source is no
    longer available, then it should automatically switch to "all".

 src/photos-source-manager.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/photos-source-manager.c b/src/photos-source-manager.c
index 9d76b625..8596f76b 100644
--- a/src/photos-source-manager.c
+++ b/src/photos-source-manager.c
@@ -114,6 +114,8 @@ photos_source_manager_refresh_accounts (PhotosSourceManager *self)
   g_autoptr (GHashTable) new_sources = NULL;
   GList *accounts = NULL;
   GList *l;
+  PhotosSource *active_source;
+  const gchar *active_id;
   guint i;
   guint n_items;
 
@@ -146,6 +148,14 @@ photos_source_manager_refresh_accounts (PhotosSourceManager *self)
       g_hash_table_insert (new_sources, g_strdup (id), g_object_ref (source));
     }
 
+  active_source = PHOTOS_SOURCE (photos_base_manager_get_active_object (PHOTOS_BASE_MANAGER (self)));
+  active_id = photos_filterable_get_id (PHOTOS_FILTERABLE (active_source));
+  if (!photos_filterable_get_builtin (PHOTOS_FILTERABLE (active_source))
+      && !g_hash_table_contains (new_sources, active_id))
+    {
+      photos_base_manager_set_active_object_by_id (PHOTOS_BASE_MANAGER (self), PHOTOS_SOURCE_STOCK_ALL);
+    }
+
   photos_base_manager_process_new_objects (PHOTOS_BASE_MANAGER (self), new_sources);
 
   n_items = g_list_model_get_n_items (G_LIST_MODEL (self));


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