[gnote] Move NotebookManager ctor code to init method
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Move NotebookManager ctor code to init method
- Date: Mon, 21 Oct 2019 19:49:40 +0000 (UTC)
commit 787c059c4417eeca7427f5973c6f403439722a75
Author: Aurimas Černius <aurisc4 gmail com>
Date: Mon Oct 21 22:33:47 2019 +0300
Move NotebookManager ctor code to init method
src/gnote.cpp | 1 +
src/notebooks/notebookmanager.cpp | 65 ++++++++++++++++++++-------------------
src/notebooks/notebookmanager.hpp | 1 +
3 files changed, 36 insertions(+), 31 deletions(-)
---
diff --git a/src/gnote.cpp b/src/gnote.cpp
index da72dd34..d9f169b1 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -151,6 +151,7 @@ namespace gnote {
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();
diff --git a/src/notebooks/notebookmanager.cpp b/src/notebooks/notebookmanager.cpp
index 06e8cc7c..0b0d1f2f 100644
--- a/src/notebooks/notebookmanager.cpp
+++ b/src/notebooks/notebookmanager.cpp
@@ -41,42 +41,45 @@ namespace gnote {
: m_adding_notebook(false)
, m_active_notes(new ActiveNotesNotebook(manager))
, m_note_manager(manager)
- {
- m_notebooks = Gtk::ListStore::create(m_column_types);
+ {
+ }
- m_sortedNotebooks = Gtk::TreeModelSort::create (m_notebooks);
- m_sortedNotebooks->set_sort_func (
- 0, sigc::ptr_fun(&NotebookManager::compare_notebooks_sort_func));
- m_sortedNotebooks->set_sort_column (0, Gtk::SORT_ASCENDING);
+ void NotebookManager::init()
+ {
+ m_notebooks = Gtk::ListStore::create(m_column_types);
- m_notebooks_to_display = Gtk::TreeModelFilter::create(m_sortedNotebooks);
- m_notebooks_to_display->set_visible_func(
- sigc::mem_fun(*this, &NotebookManager::filter_notebooks_to_display));
-
- m_filteredNotebooks = Gtk::TreeModelFilter::create (m_sortedNotebooks);
- m_filteredNotebooks->set_visible_func(
- sigc::ptr_fun(&NotebookManager::filter_notebooks));
-
- Notebook::Ptr allNotesNotebook(new AllNotesNotebook(manager));
- Gtk::TreeIter iter = m_notebooks->append ();
- iter->set_value(0, Notebook::Ptr(allNotesNotebook));
-
- Notebook::Ptr unfiledNotesNotebook(new UnfiledNotesNotebook(manager));
- iter = m_notebooks->append ();
- iter->set_value(0, Notebook::Ptr(unfiledNotesNotebook));
+ m_sortedNotebooks = Gtk::TreeModelSort::create (m_notebooks);
+ m_sortedNotebooks->set_sort_func (
+ 0, sigc::ptr_fun(&NotebookManager::compare_notebooks_sort_func));
+ m_sortedNotebooks->set_sort_column (0, Gtk::SORT_ASCENDING);
- Notebook::Ptr pinned_notes_notebook(new PinnedNotesNotebook(manager));
- iter = m_notebooks->append();
- iter->set_value(0, pinned_notes_notebook);
+ m_notebooks_to_display = Gtk::TreeModelFilter::create(m_sortedNotebooks);
+ m_notebooks_to_display->set_visible_func(
+ sigc::mem_fun(*this, &NotebookManager::filter_notebooks_to_display));
- iter = m_notebooks->append();
- iter->set_value(0, m_active_notes);
- std::static_pointer_cast<ActiveNotesNotebook>(m_active_notes)->signal_size_changed
- .connect(sigc::mem_fun(*this, &NotebookManager::on_active_notes_size_changed));
+ m_filteredNotebooks = Gtk::TreeModelFilter::create (m_sortedNotebooks);
+ m_filteredNotebooks->set_visible_func(
+ sigc::ptr_fun(&NotebookManager::filter_notebooks));
-
- load_notebooks ();
- }
+ Notebook::Ptr allNotesNotebook(new AllNotesNotebook(m_note_manager));
+ Gtk::TreeIter iter = m_notebooks->append ();
+ iter->set_value(0, Notebook::Ptr(allNotesNotebook));
+
+ Notebook::Ptr unfiledNotesNotebook(new UnfiledNotesNotebook(m_note_manager));
+ iter = m_notebooks->append ();
+ iter->set_value(0, Notebook::Ptr(unfiledNotesNotebook));
+
+ Notebook::Ptr pinned_notes_notebook(new PinnedNotesNotebook(m_note_manager));
+ iter = m_notebooks->append();
+ iter->set_value(0, pinned_notes_notebook);
+
+ iter = m_notebooks->append();
+ iter->set_value(0, m_active_notes);
+ std::static_pointer_cast<ActiveNotesNotebook>(m_active_notes)->signal_size_changed
+ .connect(sigc::mem_fun(*this, &NotebookManager::on_active_notes_size_changed));
+
+ load_notebooks ();
+ }
Notebook::Ptr NotebookManager::get_notebook(const Glib::ustring & notebookName) const
diff --git a/src/notebooks/notebookmanager.hpp b/src/notebooks/notebookmanager.hpp
index 8dd84a2b..5bec7528 100644
--- a/src/notebooks/notebookmanager.hpp
+++ b/src/notebooks/notebookmanager.hpp
@@ -44,6 +44,7 @@ public:
typedef sigc::signal<void, const Note &, const Notebook::Ptr &> NotebookEventHandler;
NotebookManager(NoteManager &);
+ void init();
NoteManager & note_manager() const
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]