[gnote] Make static take IGnote as argument



commit 83c4cb13e1a4ba3664130705acf4dfbf8904a69c
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Dec 15 14:08:49 2019 +0200

    Make static take IGnote as argument

 src/notebooks/notebookapplicationaddin.cpp |  2 +-
 src/notebooks/notebookmanager.cpp          | 29 +++++++++--------------------
 src/notebooks/notebookmanager.hpp          | 16 ++++++++++------
 src/notebooks/notebooknoteaddin.cpp        |  2 +-
 src/searchnoteswidget.cpp                  |  4 ++--
 5 files changed, 23 insertions(+), 30 deletions(-)
---
diff --git a/src/notebooks/notebookapplicationaddin.cpp b/src/notebooks/notebookapplicationaddin.cpp
index 513c89d3..9356139a 100644
--- a/src/notebooks/notebookapplicationaddin.cpp
+++ b/src/notebooks/notebookapplicationaddin.cpp
@@ -94,7 +94,7 @@ namespace gnote {
 
     void NotebookApplicationAddin::on_new_notebook_action(const Glib::VariantBase&)
     {
-      NotebookManager::prompt_create_new_notebook (NULL);
+      NotebookManager::prompt_create_new_notebook(ignote(), NULL);
     }
 
 
diff --git a/src/notebooks/notebookmanager.cpp b/src/notebooks/notebookmanager.cpp
index d88e2230..17bdd2d7 100644
--- a/src/notebooks/notebookmanager.cpp
+++ b/src/notebooks/notebookmanager.cpp
@@ -305,17 +305,16 @@ namespace gnote {
     }
 
 
-    Notebook::Ptr NotebookManager::prompt_create_new_notebook(Gtk::Window *parent)
+    Notebook::Ptr NotebookManager::prompt_create_new_notebook(IGnote & g, Gtk::Window *parent)
     {
-      return prompt_create_new_notebook(parent, Note::List());
+      return prompt_create_new_notebook(g, parent, Note::List());
     }
 
 
-    Notebook::Ptr NotebookManager::prompt_create_new_notebook(Gtk::Window *parent,
-                                                              const Note::List & notesToAdd)
+    Notebook::Ptr NotebookManager::prompt_create_new_notebook(IGnote & g, Gtk::Window *parent, const 
Note::List & notesToAdd)
     {
       // Prompt the user for the name of a new notebook
-      CreateNotebookDialog dialog(parent, (GtkDialogFlags)(GTK_DIALOG_MODAL | 
GTK_DIALOG_DESTROY_WITH_PARENT), IGnote::obj());
+      CreateNotebookDialog dialog(parent, (GtkDialogFlags)(GTK_DIALOG_MODAL | 
GTK_DIALOG_DESTROY_WITH_PARENT), g);
       
       
       int response = dialog.run ();
@@ -323,7 +322,7 @@ namespace gnote {
       if (response != Gtk::RESPONSE_OK)
         return Notebook::Ptr();
       
-      Notebook::Ptr notebook = IGnote::obj().notebook_manager().get_or_create_notebook (notebookName);
+      Notebook::Ptr notebook = g.notebook_manager().get_or_create_notebook (notebookName);
       if (!notebook) {
         DBG_OUT ("Could not create notebook: %s", notebookName.c_str());
       } 
@@ -335,7 +334,7 @@ namespace gnote {
           // Move all the specified notesToAdd into the new notebook
           for(Note::List::const_iterator iter = notesToAdd.begin();
               iter != notesToAdd.end(); ++iter) {
-            IGnote::obj().notebook_manager().move_note_to_notebook (*iter, notebook);
+            g.notebook_manager().move_note_to_notebook (*iter, notebook);
           }
         }
       }
@@ -343,17 +342,7 @@ namespace gnote {
       return notebook;
     }
     
-    /// <summary>
-    /// Prompt the user and delete the notebok (if they say so).
-    /// </summary>
-    /// <param name="parent">
-    /// A <see cref="Gtk.Window"/>
-    /// </param>
-    /// <param name="notebook">
-    /// A <see cref="Notebook"/>
-    /// </param>
-    void NotebookManager::prompt_delete_notebook(Gtk::Window * parent, 
-                                                 const Notebook::Ptr & notebook)
+    void NotebookManager::prompt_delete_notebook(IGnote & g, Gtk::Window * parent, const Notebook::Ptr & 
notebook)
     {
       // Confirmation Dialog
       utils::HIGMessageDialog dialog(parent,
@@ -373,11 +362,11 @@ namespace gnote {
       // Grab the template note before removing all the notebook tags
       Note::Ptr templateNote = notebook->get_template_note ();
       
-      IGnote::obj().notebook_manager().delete_notebook(notebook);
+      g.notebook_manager().delete_notebook(notebook);
 
       // Delete the template note
       if (templateNote) {
-        IGnote::obj().notebook_manager().note_manager().delete_note(templateNote);
+        g.notebook_manager().note_manager().delete_note(templateNote);
       }
     }
 
diff --git a/src/notebooks/notebookmanager.hpp b/src/notebooks/notebookmanager.hpp
index 5bec7528..10e6369d 100644
--- a/src/notebooks/notebookmanager.hpp
+++ b/src/notebooks/notebookmanager.hpp
@@ -35,7 +35,11 @@
 #include "tag.hpp"
 
 namespace gnote {
-  namespace notebooks {
+
+class IGnote;
+
+
+namespace notebooks {
 
 
 class NotebookManager
@@ -80,10 +84,9 @@ public:
   Notebook::Ptr get_notebook_from_note(const NoteBase::Ptr &);
   Notebook::Ptr get_notebook_from_tag(const Tag::Ptr &);
   static bool is_notebook_tag(const Tag::Ptr &);
-  static Notebook::Ptr prompt_create_new_notebook(Gtk::Window *);
-  static Notebook::Ptr prompt_create_new_notebook(Gtk::Window *,
-                                                  const Note::List & notesToAdd);
-  static void prompt_delete_notebook(Gtk::Window *, const Notebook::Ptr &);
+  static Notebook::Ptr prompt_create_new_notebook(IGnote &, Gtk::Window *);
+  static Notebook::Ptr prompt_create_new_notebook(IGnote &, Gtk::Window *, const Note::List & notesToAdd);
+  static void prompt_delete_notebook(IGnote &, Gtk::Window *, const Notebook::Ptr &);
   bool move_note_to_notebook (const Note::Ptr &, const Notebook::Ptr &);
 
   NotebookEventHandler & signal_note_added_to_notebook()
@@ -132,7 +135,8 @@ private:
   NoteManager                        & m_note_manager;
 };
 
-  }
+}
+
 }
 
 #endif
diff --git a/src/notebooks/notebooknoteaddin.cpp b/src/notebooks/notebooknoteaddin.cpp
index f0628e99..39df573b 100644
--- a/src/notebooks/notebooknoteaddin.cpp
+++ b/src/notebooks/notebooknoteaddin.cpp
@@ -124,7 +124,7 @@ namespace notebooks {
   {
     Note::List noteList;
     noteList.push_back(get_note());
-    NotebookManager::prompt_create_new_notebook(dynamic_cast<Gtk::Window*>(get_window()->host()), noteList);
+    NotebookManager::prompt_create_new_notebook(ignote(), dynamic_cast<Gtk::Window*>(get_window()->host()), 
noteList);
     get_window()->signal_popover_widgets_changed();
   }
 
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 399ead32..15b028f5 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -1368,7 +1368,7 @@ void SearchNotesWidget::on_open_notebook_template_note()
 
 void SearchNotesWidget::on_new_notebook()
 {
-  notebooks::NotebookManager::prompt_create_new_notebook(get_owning_window());
+  notebooks::NotebookManager::prompt_create_new_notebook(m_gnote, get_owning_window());
 }
 
 void SearchNotesWidget::on_delete_notebook()
@@ -1378,7 +1378,7 @@ void SearchNotesWidget::on_delete_notebook()
     return;
   }
 
-  notebooks::NotebookManager::prompt_delete_notebook(get_owning_window(), notebook);
+  notebooks::NotebookManager::prompt_delete_notebook(m_gnote, get_owning_window(), notebook);
 }
 
 void SearchNotesWidget::foreground()


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