[gnote] Move NotebookManager to NoteManager



commit 66e94d74a6dad6e63a26e2a4ef843c659c92ad30
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Mon Oct 21 22:49:29 2019 +0300

    Move NotebookManager to NoteManager

 src/gnote.cpp       | 11 +++++------
 src/gnote.hpp       |  6 +-----
 src/notemanager.cpp |  2 ++
 src/notemanager.hpp |  6 ++++++
 4 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 3030b475..96934171 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -59,7 +59,6 @@ namespace gnote {
   Gnote::Gnote()
     : Gtk::Application("org.gnome.Gnote", Gio::APPLICATION_HANDLES_COMMAND_LINE)
     , m_manager(NULL)
-    , m_notebook_manager(NULL)
     , m_sync_manager(NULL)
     , m_is_background(false)
     , m_is_shell_search(false)
@@ -72,9 +71,6 @@ namespace gnote {
     if (m_prefsdlg) {
       delete m_prefsdlg;
     }
-    if(m_notebook_manager) {
-      delete m_notebook_manager;
-    }
     if(m_sync_manager) {
       delete m_sync_manager;
     }
@@ -150,8 +146,6 @@ namespace gnote {
     m_preferences.init();
     m_manager = new NoteManager(m_preferences);
     m_manager->init(note_path);
-    m_notebook_manager = new notebooks::NotebookManager(default_note_manager());
-    m_notebook_manager->init();
     m_action_manager.init();
     m_sync_manager = new sync::SyncManager(default_note_manager());
     m_sync_manager->init();
@@ -498,6 +492,11 @@ namespace gnote {
     MainWindow::present_in(get_window_for_note(), note);
   }
 
+  notebooks::NotebookManager & Gnote::notebook_manager()
+  {
+    return m_manager->notebook_manager();
+  }
+
 
   GnoteCommandLine::GnoteCommandLine()
     : m_context(g_option_context_new("Foobar"))
diff --git a/src/gnote.hpp b/src/gnote.hpp
index b930cd67..9bfbc115 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -130,10 +130,7 @@ public:
     {
       return m_icon_manager;
     }
-  virtual notebooks::NotebookManager & notebook_manager() override
-    {
-      return *m_notebook_manager;
-    }
+  virtual notebooks::NotebookManager & notebook_manager() override;
   virtual sync::SyncManager & sync_manager() override
     {
       return *m_sync_manager;
@@ -183,7 +180,6 @@ private:
 
   NoteManager *m_manager;
   IconManager m_icon_manager;
-  notebooks::NotebookManager *m_notebook_manager;
   Preferences m_preferences;
   ActionManager m_action_manager;
   sync::SyncManager *m_sync_manager;
diff --git a/src/notemanager.cpp b/src/notemanager.cpp
index bce21a39..c25606a2 100644
--- a/src/notemanager.cpp
+++ b/src/notemanager.cpp
@@ -39,6 +39,7 @@ namespace gnote {
 
   NoteManager::NoteManager(Preferences & preferences)
     : m_preferences(preferences)
+    , m_notebook_manager(*this)
     , m_addin_mgr(NULL)
     , m_note_archiver(*this)
   {
@@ -91,6 +92,7 @@ namespace gnote {
       load_notes ();
     }
 
+    m_notebook_manager.init();
     IGnote::obj().signal_quit.connect(sigc::mem_fun(*this, &NoteManager::on_exiting_event));
   }
 
diff --git a/src/notemanager.hpp b/src/notemanager.hpp
index 7210271b..51944126 100644
--- a/src/notemanager.hpp
+++ b/src/notemanager.hpp
@@ -27,6 +27,7 @@
 #include "note.hpp"
 #include "preferences.hpp"
 #include "tagmanager.hpp"
+#include "notebooks/notebookmanager.hpp"
 
 namespace gnote {
 
@@ -44,6 +45,10 @@ namespace gnote {
 
     void init(const Glib::ustring &);
 
+    notebooks::NotebookManager & notebook_manager()
+      {
+        return m_notebook_manager;
+      }
     virtual NoteArchiver & note_archiver() override
       {
         return m_note_archiver;
@@ -87,6 +92,7 @@ namespace gnote {
     void on_exiting_event();
 
     Preferences & m_preferences;
+    notebooks::NotebookManager m_notebook_manager;
     AddinManager   *m_addin_mgr;
     NoteArchiver m_note_archiver;
     TagManager m_tag_manager;


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