[gnote] Remove use of static IGnote in MainWindow::present_default



commit 5f68bb0bba060aa63cdbf39d0862f2b1dc3840d3
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Tue Dec 3 22:28:42 2019 +0200

    Remove use of static IGnote in MainWindow::present_default

 src/dbus/remotecontrol.cpp | 2 +-
 src/mainwindow.cpp         | 8 ++++----
 src/mainwindow.hpp         | 2 +-
 src/noterenamedialog.cpp   | 3 ++-
 src/watchers.cpp           | 2 +-
 5 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/src/dbus/remotecontrol.cpp b/src/dbus/remotecontrol.cpp
index 19babb06..acd88a7a 100644
--- a/src/dbus/remotecontrol.cpp
+++ b/src/dbus/remotecontrol.cpp
@@ -391,7 +391,7 @@ void RemoteControl::on_note_saved(const NoteBase::Ptr & note)
 
 MainWindow & RemoteControl::present_note(const NoteBase::Ptr & note)
 {
-  return *MainWindow::present_default(std::static_pointer_cast<Note>(note));
+  return *MainWindow::present_default(m_gnote, std::static_pointer_cast<Note>(note));
 }
 
 
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b5b99368..92cbe078 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -78,7 +78,7 @@ MainWindow *MainWindow::present_in_new_window(IGnote & g, const Note::Ptr & note
   return NULL;
 }
 
-MainWindow *MainWindow::present_default(const Note::Ptr & note)
+MainWindow *MainWindow::present_default(IGnote & g, const Note::Ptr & note)
 {
   if(!note) {
     return NULL;
@@ -87,17 +87,17 @@ MainWindow *MainWindow::present_default(const Note::Ptr & note)
   if(win) {
     return win;
   }
-  Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
+  Glib::RefPtr<Gio::Settings> settings = g.preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
   if(false == settings->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW)) {
     if (note->has_window()) {
       win = dynamic_cast<MainWindow*>(note->get_window()->host());
     }
     else {
-      win = &IGnote::obj().get_window_for_note();
+      win = &g.get_window_for_note();
     }
   }
   if(!win) {
-    win = &IGnote::obj().new_main_window();
+    win = &g.new_main_window();
     win->close_on_escape(settings->get_boolean(Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE));
   }
   win->present_note(note);
diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp
index 69ed3e0e..dace3c92 100644
--- a/src/mainwindow.hpp
+++ b/src/mainwindow.hpp
@@ -39,7 +39,7 @@ public:
   static void present_in(MainWindow & win, const Note::Ptr & note);
   static MainWindow *present_active(const Note::Ptr & note);
   static MainWindow *present_in_new_window(IGnote & g, const Note::Ptr & note, bool close_on_esacpe);
-  static MainWindow *present_default(const Note::Ptr & note);
+  static MainWindow *present_default(IGnote & g, const Note::Ptr & note);
   static bool use_client_side_decorations(Preferences & prefs);
 
   explicit MainWindow(const Glib::ustring & title);
diff --git a/src/noterenamedialog.cpp b/src/noterenamedialog.cpp
index 697c0838..9e19b377 100644
--- a/src/noterenamedialog.cpp
+++ b/src/noterenamedialog.cpp
@@ -29,6 +29,7 @@
 #include <glibmm/i18n.h>
 #include <gtkmm/expander.h>
 
+#include "ignote.hpp"
 #include "mainwindow.hpp"
 #include "notewindow.hpp"
 #include "noterenamedialog.hpp"
@@ -361,7 +362,7 @@ void NoteRenameDialog::on_notes_view_row_activated(
   if (!note)
     return;
 
-  MainWindow *window = MainWindow::present_default(std::static_pointer_cast<Note>(note));
+  MainWindow *window = MainWindow::present_default(IGnote::obj(), std::static_pointer_cast<Note>(note));
   if(window) {
     window->set_search_text(Glib::ustring::compose("\"%1\"", old_title));
     window->show_search_bar();
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 72a9269f..8f68e3ba 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -1053,7 +1053,7 @@ namespace gnote {
     // also works around the bug.
     if (link) {
       DBG_OUT ("Opening note '%s' on click...", link_name.c_str());
-      MainWindow::present_default(std::static_pointer_cast<Note>(link));
+      MainWindow::present_default(ignote(), std::static_pointer_cast<Note>(link));
       return true;
     }
 


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