[devhelp/wip/book-manager-singleton: 1/3] BookManager: populate it in init()



commit f717bdaa64fcc5c3c2f3980cd4067a2cb0c7e746
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon May 1 13:44:41 2017 +0200

    BookManager: populate it in init()

 src/dh-app.c          |    2 --
 src/dh-book-manager.c |   29 ++++++++++++++++++++---------
 src/dh-book-manager.h |    4 +++-
 3 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/src/dh-app.c b/src/dh-app.c
index 3bd8135..123ffd3 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -507,9 +507,7 @@ dh_app_startup (GApplication *application)
         /* Setup accelerators */
         setup_accelerators (app);
 
-        /* Load the book manager */
         priv->book_manager = dh_book_manager_new ();
-        dh_book_manager_populate (priv->book_manager);
 }
 
 static void
diff --git a/src/dh-book-manager.c b/src/dh-book-manager.c
index 675b1c4..edd40a6 100644
--- a/src/dh-book-manager.c
+++ b/src/dh-book-manager.c
@@ -78,6 +78,7 @@ static void    book_manager_inc_language      (DhBookManager *book_manager,
                                                const gchar   *language_name);
 static void    book_manager_dec_language      (DhBookManager *book_manager,
                                                const gchar   *language_name);
+static void    populate                       (DhBookManager *book_manager);
 
 static void
 dh_book_manager_get_property (GObject    *object,
@@ -302,6 +303,8 @@ dh_book_manager_init (DhBookManager *book_manager)
                          book_manager,
                          "group-by-language",
                          G_SETTINGS_BIND_DEFAULT);
+
+        populate (book_manager);
 }
 
 static void
@@ -364,15 +367,8 @@ book_manager_add_books_in_data_dir (DhBookManager *book_manager,
         g_free (dir);
 }
 
-/**
- * dh_book_manager_populate:
- * @book_manager: a #DhBookManager.
- *
- * Populates the #DhBookManager with all books found on the system and user
- * directories.
- */
-void
-dh_book_manager_populate (DhBookManager *book_manager)
+static void
+populate (DhBookManager *book_manager)
 {
         const gchar * const * system_dirs;
 
@@ -387,6 +383,21 @@ dh_book_manager_populate (DhBookManager *book_manager)
         }
 }
 
+/**
+ * dh_book_manager_populate:
+ * @book_manager: a #DhBookManager.
+ *
+ * Populates the #DhBookManager with all books found on the system and user
+ * directories.
+ *
+ * Deprecated: 3.26: The #DhBookManager is now automatically populated when the
+ * object is created, there is no need to call this function anymore.
+ */
+void
+dh_book_manager_populate (DhBookManager *book_manager)
+{
+}
+
 static gchar *
 book_manager_get_book_path (const gchar *base_path,
                             const gchar *name)
diff --git a/src/dh-book-manager.h b/src/dh-book-manager.h
index 9fa7ef9..03a559f 100644
--- a/src/dh-book-manager.h
+++ b/src/dh-book-manager.h
@@ -43,12 +43,14 @@ struct _DhBookManagerClass {
 
 GType          dh_book_manager_get_type              (void) G_GNUC_CONST;
 DhBookManager *dh_book_manager_new                   (void);
-void           dh_book_manager_populate              (DhBookManager *book_manager);
 GList         *dh_book_manager_get_books             (DhBookManager *book_manager);
 gboolean       dh_book_manager_get_group_by_language (DhBookManager *book_manager);
 void           dh_book_manager_set_group_by_language (DhBookManager *book_manager,
                                                       gboolean       group_by_language);
 
+G_DEPRECATED
+void           dh_book_manager_populate              (DhBookManager *book_manager);
+
 G_END_DECLS
 
 #endif /* DH_BOOK_MANAGER_H */


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