[gnome-photos/wip/rishi/online-miners: 3/12] source-manager: Enable getting a display name for a GOA provider type




commit 573a2225b35e7df05714e0a69f14fd1a10edef3f
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Mar 20 03:45:32 2021 +0100

    source-manager: Enable getting a display name for a GOA provider type
    
    Subsequent commits will use this to remove the DisplayName property
    offered by the org.gnome.OnlineMiners.Miner D-Bus interface. Not having
    a property in the D-Bus interface means that creating a GDBusProxy for
    it can be done synchronously without doing any slow I/O, which is
    always convenient.
    
    https://gitlab.gnome.org/GNOME/gnome-photos/-/issues/83

 src/photos-source-manager.c | 37 +++++++++++++++++++++++++++++++++++++
 src/photos-source-manager.h |  3 +++
 2 files changed, 40 insertions(+)
---
diff --git a/src/photos-source-manager.c b/src/photos-source-manager.c
index abb0a17e..9e68663e 100644
--- a/src/photos-source-manager.c
+++ b/src/photos-source-manager.c
@@ -495,6 +495,43 @@ photos_source_manager_get_for_provider_type (PhotosSourceManager *self, const gc
 }
 
 
+const gchar *
+photos_source_manager_get_provider_name_for_provider_type (PhotosSourceManager *self, const gchar 
*provider_type)
+{
+  g_autolist(GoaObject) accounts = NULL;
+  GList *l;
+  const gchar *ret_val = NULL;
+
+  g_return_val_if_fail (PHOTOS_IS_SOURCE_MANAGER (self), NULL);
+  g_return_val_if_fail (provider_type != NULL && provider_type[0] != '\0', NULL);
+
+  if (self->client == NULL)
+    goto out;
+
+  accounts = goa_client_get_accounts (self->client);
+  for (l = accounts; l != NULL; l = l->next)
+    {
+      GoaAccount *account;
+      GoaObject *object = GOA_OBJECT (l->data);
+      const gchar *account_provider_type;
+
+      account = goa_object_peek_account (object);
+      if (account == NULL)
+        continue;
+
+      account_provider_type = goa_account_get_provider_type (account);
+      if (g_strcmp0 (account_provider_type, provider_type) == 0)
+        {
+          ret_val = goa_account_get_provider_name (account);
+          goto out;
+        }
+    }
+
+ out:
+  return ret_val;
+}
+
+
 gboolean
 photos_source_manager_has_online_sources (PhotosSourceManager *self)
 {
diff --git a/src/photos-source-manager.h b/src/photos-source-manager.h
index a351eeb5..99ef2ece 100644
--- a/src/photos-source-manager.h
+++ b/src/photos-source-manager.h
@@ -35,6 +35,9 @@ PhotosBaseManager        *photos_source_manager_new                (void);
 GList                    *photos_source_manager_get_for_provider_type (PhotosSourceManager *self,
                                                                        const gchar *provider_type);
 
+const gchar              *photos_source_manager_get_provider_name_for_provider_type (PhotosSourceManager 
*self,
+                                                                                     const gchar 
*provider_type);
+
 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]