[recipes] Make the recipe store a singleton



commit 2a89aeefc5138e80178578884453da9b972ef295
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Mar 11 15:42:50 2017 -0500

    Make the recipe store a singleton
    
    This avoids us having to juggle the application
    all over the place

 src/gr-recipe-store.c |   13 ++++++++++++-
 src/gr-recipe-store.h |    2 ++
 2 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index f2a7145..24a607b 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -1639,7 +1639,7 @@ gr_recipe_search_new (void)
 
         search = GR_RECIPE_SEARCH (g_object_new (GR_TYPE_RECIPE_SEARCH, NULL));
 
-        search->store = g_object_ref (gr_app_get_recipe_store (GR_APP (g_application_get_default ())));
+        search->store = g_object_ref (gr_recipe_store_get ());
 
         return search;
 }
@@ -1970,3 +1970,14 @@ static void
 gr_recipe_search_init (GrRecipeSearch *self)
 {
 }
+
+GrRecipeStore *
+gr_recipe_store_get (void)
+{
+        static GrRecipeStore *store;
+
+        if (store == NULL)
+                store = gr_recipe_store_new ();
+
+        return store;
+}
diff --git a/src/gr-recipe-store.h b/src/gr-recipe-store.h
index 572e0d4..003630c 100644
--- a/src/gr-recipe-store.h
+++ b/src/gr-recipe-store.h
@@ -30,6 +30,8 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GrRecipeStore, gr_recipe_store, GR, RECIPE_STORE, GObject)
 
+GrRecipeStore  *gr_recipe_store_get                 (void);
+
 GrRecipeStore  *gr_recipe_store_new                 (void);
 
 gboolean        gr_recipe_store_add_recipe          (GrRecipeStore  *self,


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