[gnome-photos/wip/rishi/collection: 24/44] embed, source-manager: Show notifications for mounts present at startup



commit 2cb047e513eb5439a61d3dbd54afb11a79f712f2
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jan 12 09:52:21 2018 +0100

    embed, source-manager: Show notifications for mounts present at startup
    
    Unlike GoaObject-backed sources, GMount-backed sources can be
    synchronously enumerated during start-up. However, this means that
    SourceManager::notification-show will be emitted too early for Embed to
    catch it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751212

 src/photos-embed.c          | 11 +++++++++++
 src/photos-source-manager.c | 17 +++++++++++++++++
 src/photos-source-manager.h |  2 ++
 3 files changed, 30 insertions(+)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index acf8f17c..fe5d784d 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -698,6 +698,8 @@ static void
 photos_embed_init (PhotosEmbed *self)
 {
   GApplication *app;
+  GList *l;
+  GList *sources_notified = NULL;
   GList *windows;
   PhotosSearchbar *searchbar;
   PhotosSearchContextState *state;
@@ -802,6 +804,13 @@ photos_embed_init (PhotosEmbed *self)
                            self,
                            G_CONNECT_SWAPPED);
 
+  sources_notified = photos_source_manager_get_notified (PHOTOS_SOURCE_MANAGER (self->src_mngr));
+  for (l = sources_notified; l != NULL; l = l->next)
+    {
+      PhotosSource *source = PHOTOS_SOURCE (l->data);
+      photos_embed_source_manager_notification_show (self, source);
+    }
+
   self->srch_mtch_mngr = g_object_ref (state->srch_mtch_mngr);
 
   self->srch_typ_mngr = g_object_ref (state->srch_typ_mngr);
@@ -820,6 +829,8 @@ photos_embed_init (PhotosEmbed *self)
                            G_CALLBACK (photos_embed_search_changed),
                            self,
                            G_CONNECT_SWAPPED);
+
+  g_list_free_full (sources_notified, g_object_unref);
 }
 
 
diff --git a/src/photos-source-manager.c b/src/photos-source-manager.c
index 14f4fc4d..2cfa23f8 100644
--- a/src/photos-source-manager.c
+++ b/src/photos-source-manager.c
@@ -339,6 +339,23 @@ photos_source_manager_get_for_provider_type (PhotosSourceManager *self, const gc
 }
 
 
+GList *
+photos_source_manager_get_notified (PhotosSourceManager *self)
+{
+  GHashTableIter iter;
+  GList *sources = NULL;
+  PhotosSource *source;
+
+  g_return_val_if_fail (PHOTOS_IS_SOURCE_MANAGER (self), NULL);
+
+  g_hash_table_iter_init (&iter, self->sources_notified);
+  while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &source))
+    sources = g_list_prepend (sources, g_object_ref (source));
+
+  return sources;
+}
+
+
 gboolean
 photos_source_manager_has_online_sources (PhotosSourceManager *self)
 {
diff --git a/src/photos-source-manager.h b/src/photos-source-manager.h
index 92d38dce..54777074 100644
--- a/src/photos-source-manager.h
+++ b/src/photos-source-manager.h
@@ -35,6 +35,8 @@ PhotosBaseManager        *photos_source_manager_new                (void);
 GList                    *photos_source_manager_get_for_provider_type (PhotosSourceManager *self,
                                                                        const gchar *provider_type);
 
+GList                    *photos_source_manager_get_notified          (PhotosSourceManager *self);
+
 gboolean                  photos_source_manager_has_online_sources    (PhotosSourceManager *self);
 
 gboolean                  photos_source_manager_has_provider_type     (PhotosSourceManager *self,


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