[tepl] MetadataStore: add is_activated() private function



commit 0ee9be16b3e37c1158c6d819ea0fc943747c8175
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Apr 15 21:13:51 2020 +0200

    MetadataStore: add is_activated() private function

 tepl/tepl-metadata-store.c |  8 ++++++++
 tepl/tepl-metadata-store.h |  3 +++
 tepl/tepl-metadata.c       | 12 +++++++++++-
 3 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/tepl/tepl-metadata-store.c b/tepl/tepl-metadata-store.c
index d9b87f0..7411a2c 100644
--- a/tepl/tepl-metadata-store.c
+++ b/tepl/tepl-metadata-store.c
@@ -1072,3 +1072,11 @@ _tepl_metadata_store_set_metadata_for_location (TeplMetadataStore *store,
 
        store->priv->modified = TRUE;
 }
+
+gboolean
+_tepl_metadata_store_is_activated (TeplMetadataStore *store)
+{
+       g_return_val_if_fail (TEPL_IS_METADATA_STORE (store), FALSE);
+
+       return store->priv->xml_file != NULL;
+}
diff --git a/tepl/tepl-metadata-store.h b/tepl/tepl-metadata-store.h
index f5dc97c..44145bc 100644
--- a/tepl/tepl-metadata-store.h
+++ b/tepl/tepl-metadata-store.h
@@ -70,6 +70,9 @@ gboolean              tepl_metadata_store_save                        (TeplMetadataStore  
*store,
 G_GNUC_INTERNAL
 void                   _tepl_metadata_store_unref_singleton            (void);
 
+G_GNUC_INTERNAL
+gboolean               _tepl_metadata_store_is_activated               (TeplMetadataStore *store);
+
 G_GNUC_INTERNAL
 void                   _tepl_metadata_store_load_async                 (TeplMetadataStore   *store,
                                                                         gint                 io_priority,
diff --git a/tepl/tepl-metadata.c b/tepl/tepl-metadata.c
index df2b5fb..5cd5ee6 100644
--- a/tepl/tepl-metadata.c
+++ b/tepl/tepl-metadata.c
@@ -77,7 +77,12 @@ _tepl_metadata_query_info_async (GFile               *location,
 
        store = tepl_metadata_store_get_singleton ();
 
-       /* TODO: check if TeplMetadataStore is activated. */
+       if (!_tepl_metadata_store_is_activated (store))
+       {
+               g_task_return_pointer (task, NULL, NULL);
+               g_object_unref (task);
+               return;
+       }
 
        if (_tepl_metadata_store_is_loaded (store))
        {
@@ -89,6 +94,11 @@ _tepl_metadata_query_info_async (GFile               *location,
                g_object_unref (task);
                return;
        }
+
+       /* TODO check if it is load*ing*, if not, load(), if yes, connect to the
+        * notify::loaded signal.
+        * Or find an easier way to handle all of this.
+        */
 }
 
 GFileInfo *


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