[devhelp/wip/book-manager-singleton] AssistantView: remove dh_assistant_view_set_book_manager()



commit def8cc67063b08b337f8bce1f1cfa056d89ab147
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon May 1 15:44:53 2017 +0200

    AssistantView: remove dh_assistant_view_set_book_manager()
    
    It's a public function, but neither Anjuta nor gnome-builder use this
    function, so I think it's not a big problem to break this API directly.

 docs/reference/devhelp-sections.txt |    1 -
 src/dh-assistant-view.c             |   38 +++++++---------------------------
 src/dh-assistant-view.h             |    3 --
 src/dh-assistant.c                  |   13 ++---------
 4 files changed, 11 insertions(+), 44 deletions(-)
---
diff --git a/docs/reference/devhelp-sections.txt b/docs/reference/devhelp-sections.txt
index 11537d9..f1c9de9 100644
--- a/docs/reference/devhelp-sections.txt
+++ b/docs/reference/devhelp-sections.txt
@@ -50,7 +50,6 @@ dh_assistant_get_type
 <TITLE>DhAssistantView</TITLE>
 DhAssistantView
 dh_assistant_view_new
-dh_assistant_view_set_book_manager
 dh_assistant_view_set_link
 dh_assistant_view_search
 <SUBSECTION Standard>
diff --git a/src/dh-assistant-view.c b/src/dh-assistant-view.c
index 64dfe6e..cea3ada 100644
--- a/src/dh-assistant-view.c
+++ b/src/dh-assistant-view.c
@@ -25,12 +25,12 @@
 #include <glib/gi18n-lib.h>
 #include "dh-util.h"
 #include "dh-book.h"
+#include "dh-book-manager.h"
 
 typedef struct {
-        DhBookManager *book_manager;
-        DhLink        *link;
-        gchar         *current_search;
-        guint          snippet_loaded : 1;
+        DhLink *link;
+        gchar *current_search;
+        guint snippet_loaded : 1;
 } DhAssistantViewPrivate;
 
 enum {
@@ -52,10 +52,6 @@ view_finalize (GObject *object)
                 g_object_unref (priv->link);
         }
 
-        if (priv->book_manager) {
-                g_object_unref (priv->book_manager);
-        }
-
         g_free (priv->current_search);
 
         G_OBJECT_CLASS (dh_assistant_view_parent_class)->finalize (object);
@@ -163,27 +159,6 @@ dh_assistant_view_new (void)
         return g_object_new (DH_TYPE_ASSISTANT_VIEW, NULL);
 }
 
-/**
- * dh_assistant_view_set_book_manager:
- * @view: a #DhAssistantView.
- * @book_manager: the #DhBookManager.
- *
- * Set the #DhBookManager to search in.
- */
-void
-dh_assistant_view_set_book_manager (DhAssistantView *view,
-                                    DhBookManager   *book_manager)
-{
-        DhAssistantViewPrivate *priv;
-
-        g_return_if_fail (DH_IS_ASSISTANT_VIEW (view));
-        g_return_if_fail (DH_IS_BOOK_MANAGER (book_manager));
-
-        priv = dh_assistant_view_get_instance_private (view);
-
-        priv->book_manager = g_object_ref (book_manager);
-}
-
 static const gchar *
 find_in_buffer (const gchar *buffer,
                 const gchar *key,
@@ -444,6 +419,7 @@ dh_assistant_view_search (DhAssistantView *view,
                           const gchar     *str)
 {
         DhAssistantViewPrivate *priv;
+        DhBookManager       *book_manager;
         const gchar         *name;
         DhLink              *link;
         DhLink              *exact_link;
@@ -469,7 +445,9 @@ dh_assistant_view_search (DhAssistantView *view,
         prefix_link = NULL;
         exact_link = NULL;
 
-        for (books = dh_book_manager_get_books (priv->book_manager);
+        book_manager = dh_book_manager_get_singleton ();
+
+        for (books = dh_book_manager_get_books (book_manager);
              !exact_link && books;
              books = g_list_next (books)) {
                 GList *l;
diff --git a/src/dh-assistant-view.h b/src/dh-assistant-view.h
index 565c981..752f731 100644
--- a/src/dh-assistant-view.h
+++ b/src/dh-assistant-view.h
@@ -49,9 +49,6 @@ GType           dh_assistant_view_get_type              (void) G_GNUC_CONST;
 
 GtkWidget *     dh_assistant_view_new                   (void);
 
-void            dh_assistant_view_set_book_manager      (DhAssistantView *view,
-                                                         DhBookManager   *book_manager);
-
 gboolean        dh_assistant_view_set_link              (DhAssistantView *view,
                                                          DhLink          *link);
 
diff --git a/src/dh-assistant.c b/src/dh-assistant.c
index 51d9239..0accc04 100644
--- a/src/dh-assistant.c
+++ b/src/dh-assistant.c
@@ -114,16 +114,9 @@ dh_assistant_init (DhAssistant *assistant)
 GtkWidget *
 dh_assistant_new (DhApp *application)
 {
-        GtkWidget          *assistant;
-        DhAssistantPrivate *priv;
-
-        assistant = g_object_new (DH_TYPE_ASSISTANT, "application", application, NULL);
-
-        priv = dh_assistant_get_instance_private (DH_ASSISTANT (assistant));
-        dh_assistant_view_set_book_manager (DH_ASSISTANT_VIEW (priv->view),
-                                            dh_app_peek_book_manager (application));
-
-        return assistant;
+        return g_object_new (DH_TYPE_ASSISTANT,
+                             "application", application,
+                             NULL);
 }
 
 /**


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