[gnote] Make Preferences non-singleton



commit a4bf559fa6b44cf43117604518f24a1a6dc1111c
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Oct 12 15:13:07 2019 +0300

    Make Preferences non-singleton

 src/addinmanager.cpp                         |  8 +++----
 src/addinmanager.hpp                         |  5 ++--
 src/gnote.cpp                                |  7 +++---
 src/gnote.hpp                                |  6 +++++
 src/ignote.hpp                               |  2 ++
 src/mainwindow.cpp                           |  4 ++--
 src/note.cpp                                 |  9 ++++----
 src/notebooks/notebooknewnotemenuitem.cpp    |  2 +-
 src/notebuffer.cpp                           |  3 ++-
 src/noteeditor.cpp                           | 15 ++++++------
 src/notemanager.cpp                          | 15 ++++++------
 src/notemanager.hpp                          |  4 +++-
 src/notewindow.cpp                           |  2 +-
 src/preferences.cpp                          |  2 +-
 src/preferences.hpp                          |  6 ++---
 src/preferencesdialog.cpp                    | 34 ++++++++++++++--------------
 src/recentchanges.cpp                        | 10 ++++----
 src/searchnoteswidget.cpp                    | 14 ++++++------
 src/synchronization/fusesyncserviceaddin.cpp |  3 ++-
 src/synchronization/isyncmanager.cpp         |  5 ++--
 src/synchronization/syncdialog.cpp           |  4 ++--
 src/synchronization/syncmanager.cpp          |  6 ++---
 src/utils.cpp                                |  3 ++-
 src/watchers.cpp                             |  5 ++--
 24 files changed, 94 insertions(+), 80 deletions(-)
---
diff --git a/src/addinmanager.cpp b/src/addinmanager.cpp
index da669524..cccf92d3 100644
--- a/src/addinmanager.cpp
+++ b/src/addinmanager.cpp
@@ -36,7 +36,6 @@
 #include "debug.hpp"
 #include "iactionmanager.hpp"
 #include "ignote.hpp"
-#include "preferences.hpp"
 #include "preferencetabaddin.hpp"
 #include "watchers.hpp"
 #include "notebooks/notebookapplicationaddin.hpp"
@@ -60,7 +59,7 @@ namespace gnote {
 #define SETUP_NOTE_ADDIN(key, KEY, klass) \
   do { \
     if(key == KEY) { \
-      Glib::RefPtr<Gio::Settings> settings = Preferences::obj() \
+      Glib::RefPtr<Gio::Settings> settings = m_preferences \
         .get_schema_settings(Preferences::SCHEMA_GNOTE); \
       if(settings->get_boolean(key)) { \
         sharp::IfaceFactoryBase *iface = new sharp::IfaceFactory<klass>; \
@@ -90,8 +89,9 @@ namespace {
 }
 
 
-  AddinManager::AddinManager(NoteManager & note_manager, const Glib::ustring & conf_dir)
+  AddinManager::AddinManager(NoteManager & note_manager, Preferences & preferences, const Glib::ustring & 
conf_dir)
     : m_note_manager(note_manager)
+    , m_preferences(preferences)
     , m_gnote_conf_dir(conf_dir)
   {
     m_addins_prefs_dir = Glib::build_filename(conf_dir, "addins");
@@ -258,7 +258,7 @@ namespace {
     if (!sharp::directory_exists (m_addins_prefs_dir))
       g_mkdir_with_parents(m_addins_prefs_dir.c_str(), S_IRWXU);
 
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
+    Glib::RefPtr<Gio::Settings> settings = m_preferences
       .get_schema_settings(Preferences::SCHEMA_GNOTE);
     settings->signal_changed()
       .connect(sigc::mem_fun(*this, &AddinManager::on_setting_changed));
diff --git a/src/addinmanager.hpp b/src/addinmanager.hpp
index de4c4f8c..2f3b5bc1 100644
--- a/src/addinmanager.hpp
+++ b/src/addinmanager.hpp
@@ -32,6 +32,7 @@
 #include "note.hpp"
 #include "noteaddin.hpp"
 #include "importaddin.hpp"
+#include "preferences.hpp"
 
 
 namespace gnote {
@@ -50,8 +51,7 @@ typedef std::map<Glib::ustring, AddinInfo> AddinInfoMap;
 class AddinManager
 {
 public:
-
-  AddinManager(NoteManager & note_manager, const Glib::ustring & conf_dir);
+  AddinManager(NoteManager & note_manager, Preferences & preferences, const Glib::ustring & conf_dir);
   ~AddinManager();
 
   void add_note_addin_info(const Glib::ustring & id, const sharp::DynamicModule * dmod);
@@ -96,6 +96,7 @@ private:
   void register_addin_actions() const;
     
   NoteManager & m_note_manager;
+  Preferences & m_preferences;
   const Glib::ustring m_gnote_conf_dir;
   Glib::ustring m_addins_prefs_dir;
   Glib::ustring m_addins_prefs_file;
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 3b6f71e8..19c5c52d 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -141,8 +141,8 @@ namespace gnote {
     Glib::ustring note_path = get_note_path(m_cmd_line.note_path());
 
     //create singleton objects
-    new Preferences;
-    m_manager = new NoteManager(note_path);
+    m_preferences.init();;
+    m_manager = new NoteManager(m_preferences, note_path);
     new notebooks::NotebookManager(default_note_manager());
     new ActionManager;
     sync::SyncManager::init(default_note_manager());
@@ -398,8 +398,7 @@ namespace gnote {
     // if notes are opened in new window by default, then open new window for search
     // otherwise switch the only window to search
     // if there is more than one window open, open new for search, since we can't decide which one to switch
-    bool new_window = Preferences::obj()
-      .get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
+    bool new_window = 
m_preferences.get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
     if(main_windows > 1 || new_window) {
       MainWindow & main_window = new_main_window();
       main_window.present_search();
diff --git a/src/gnote.hpp b/src/gnote.hpp
index cae59ee1..6ee869b2 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -32,6 +32,7 @@
 #include "actionmanager.hpp"
 #include "iconmanager.hpp"
 #include "ignote.hpp"
+#include "preferences.hpp"
 #include "remotecontrolproxy.hpp"
 #include "synchronization/syncdialog.hpp"
 
@@ -124,6 +125,10 @@ public:
     {
       return m_icon_manager;
     }
+  virtual Preferences & preferences()
+    {
+      return m_preferences;
+    }
 
   void on_preferences_response(int res);
   void on_show_preferences_action(const Glib::VariantBase&);
@@ -165,6 +170,7 @@ private:
 
   NoteManager *m_manager;
   IconManager m_icon_manager;
+  Preferences m_preferences;
   Glib::RefPtr<Gtk::IconTheme> m_icon_theme;
   bool m_is_background;
   bool m_is_shell_search;
diff --git a/src/ignote.hpp b/src/ignote.hpp
index 71f82e80..54e67243 100644
--- a/src/ignote.hpp
+++ b/src/ignote.hpp
@@ -26,6 +26,7 @@
 namespace gnote {
 
 class IconManager;
+class Preferences;
 
 
 class IGnote
@@ -40,6 +41,7 @@ public:
   virtual ~IGnote();
 
   virtual IconManager & icon_manager() = 0;
+  virtual Preferences & preferences() = 0;
 
   virtual MainWindow & get_main_window() = 0;
   virtual MainWindow & get_window_for_note() = 0;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 314090ff..4c9ea31f 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -87,7 +87,7 @@ MainWindow *MainWindow::present_default(const Note::Ptr & note)
   if(win) {
     return win;
   }
-  Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+  Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().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());
@@ -108,7 +108,7 @@ MainWindow *MainWindow::present_default(const Note::Ptr & note)
 bool MainWindow::use_client_side_decorations()
 {
   if(s_use_client_side_decorations < 0) {
-    Glib::ustring setting = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_string(
+    Glib::ustring setting = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_string(
       Preferences::USE_CLIENT_SIDE_DECORATIONS);
     if(setting == "enabled") {
       s_use_client_side_decorations = 1;
diff --git a/src/note.cpp b/src/note.cpp
index 321d9499..ddc76dee 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -28,6 +28,7 @@
 #include <gtkmm/button.h>
 #include <gtkmm/stock.h>
 
+#include "ignote.hpp"
 #include "mainwindow.hpp"
 #include "note.hpp"
 #include "notemanager.hpp"
@@ -551,7 +552,7 @@ namespace gnote {
     const Note::Ptr self = std::static_pointer_cast<Note>(shared_from_this());
 
     if (!linking_notes.empty()) {
-      Glib::RefPtr<Gio::Settings> settings = 
Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+      Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
       const NoteRenameBehavior behavior
         = static_cast<NoteRenameBehavior>(settings->get_int(Preferences::NOTE_RENAME_BEHAVIOR));
 
@@ -585,7 +586,7 @@ namespace gnote {
       NoteRenameDialog *dlg = static_cast<NoteRenameDialog*>(dialog);
       const NoteRenameBehavior selected_behavior = dlg->get_selected_behavior();
       if(Gtk::RESPONSE_CANCEL != response && NOTE_RENAME_ALWAYS_SHOW_DIALOG != selected_behavior) {
-        Glib::RefPtr<Gio::Settings> settings = 
Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+        Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
         settings->set_int(Preferences::NOTE_RENAME_BEHAVIOR, selected_behavior);
       }
 
@@ -780,7 +781,7 @@ namespace gnote {
 
   bool Note::is_pinned() const
   {
-    Glib::ustring pinned_uris = Preferences::obj()
+    Glib::ustring pinned_uris = IGnote::obj().preferences()
       .get_schema_settings(Preferences::SCHEMA_GNOTE)->get_string(Preferences::MENU_PINNED_NOTES);
     return pinned_uris.find(uri()) != Glib::ustring::npos;
   }
@@ -789,7 +790,7 @@ namespace gnote {
   void Note::set_pinned(bool pinned) const
   {
     Glib::ustring new_pinned;
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+    Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
     Glib::ustring old_pinned = settings->get_string(Preferences::MENU_PINNED_NOTES);
     bool is_currently_pinned = old_pinned.find(uri()) != Glib::ustring::npos;
 
diff --git a/src/notebooks/notebooknewnotemenuitem.cpp b/src/notebooks/notebooknewnotemenuitem.cpp
index b4b01d6c..6544c500 100644
--- a/src/notebooks/notebooknewnotemenuitem.cpp
+++ b/src/notebooks/notebooknewnotemenuitem.cpp
@@ -56,7 +56,7 @@ namespace gnote {
       // Look for the template note and create a new note
       Note::Ptr note = m_notebook->create_notebook_note ();
       MainWindow::present_in_new_window(note,
-        Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
+        IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
           Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE));
     }
 
diff --git a/src/notebuffer.cpp b/src/notebuffer.cpp
index 31c3758e..f3d03f62 100644
--- a/src/notebuffer.cpp
+++ b/src/notebuffer.cpp
@@ -28,6 +28,7 @@
 
 #include "config.h"
 #include "debug.hpp"
+#include "ignote.hpp"
 #include "notebuffer.hpp"
 #include "notetag.hpp"
 #include "note.hpp"
@@ -55,7 +56,7 @@ namespace gnote {
 
   bool NoteBuffer::get_enable_auto_bulleted_lists() const
   {
-    return Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
+    return IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
         Preferences::ENABLE_AUTO_BULLETED_LISTS);
   }
   
diff --git a/src/noteeditor.cpp b/src/noteeditor.cpp
index 65342a00..19d21aba 100644
--- a/src/noteeditor.cpp
+++ b/src/noteeditor.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2013,2016-2017 Aurimas Cernius
+ * Copyright (C) 2010-2013,2016-2017,2019 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -21,6 +21,7 @@
 
 #include <string.h>
 
+#include "ignote.hpp"
 #include "notebuffer.hpp"
 #include "noteeditor.hpp"
 #include "preferences.hpp"
@@ -39,9 +40,9 @@ namespace gnote {
     set_right_margin(default_margin());
     property_can_default().set_value(true);
 
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+    Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
     //Set up the schema to watch the default document font
-    Glib::RefPtr<Gio::Settings> desktop_settings = Preferences::obj()
+    Glib::RefPtr<Gio::Settings> desktop_settings = IGnote::obj().preferences()
       .get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE);
     if(desktop_settings) {
       desktop_settings->signal_changed().connect(
@@ -78,7 +79,7 @@ namespace gnote {
   Pango::FontDescription NoteEditor::get_gnome_document_font_description()
   {
     try {
-      Glib::RefPtr<Gio::Settings> desktop_settings = Preferences::obj()
+      Glib::RefPtr<Gio::Settings> desktop_settings = IGnote::obj().preferences()
         .get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE);
       if(desktop_settings) {
         Glib::ustring doc_font_string =
@@ -100,9 +101,9 @@ namespace gnote {
       update_custom_font_setting ();
     }
     else if(key == Preferences::DESKTOP_GNOME_FONT) {
-      if (!Preferences::obj().get_schema_settings(
+      if (!IGnote::obj().preferences().get_schema_settings(
           Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::ENABLE_CUSTOM_FONT)) {
-        Glib::RefPtr<Gio::Settings> desktop_settings = Preferences::obj()
+        Glib::RefPtr<Gio::Settings> desktop_settings = IGnote::obj().preferences()
           .get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE);
         if(desktop_settings) {
           Glib::ustring value = desktop_settings->get_string(key);
@@ -115,7 +116,7 @@ namespace gnote {
 
   void NoteEditor::update_custom_font_setting()
   {
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
+    Glib::RefPtr<Gio::Settings> settings = IGnote::obj().preferences()
       .get_schema_settings(Preferences::SCHEMA_GNOTE);
 
     if (settings->get_boolean(Preferences::ENABLE_CUSTOM_FONT)) {
diff --git a/src/notemanager.cpp b/src/notemanager.cpp
index 5ba93595..45e3d1ad 100644
--- a/src/notemanager.cpp
+++ b/src/notemanager.cpp
@@ -32,14 +32,14 @@
 #include "addinmanager.hpp"
 #include "ignote.hpp"
 #include "itagmanager.hpp"
-#include "preferences.hpp"
 #include "sharp/directory.hpp"
 #include "sharp/dynamicmodule.hpp"
 
 namespace gnote {
 
-  NoteManager::NoteManager(const Glib::ustring & directory)
+  NoteManager::NoteManager(Preferences & preferences, const Glib::ustring & directory)
     : NoteManagerBase(directory)
+    , m_preferences(preferences)
     , m_note_archiver(*this)
   {
     Glib::ustring backup = directory + "/Backup";
@@ -55,8 +55,7 @@ namespace gnote {
 
     NoteManagerBase::_common_init(directory, backup_directory);
 
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
-      .get_schema_settings(Preferences::SCHEMA_GNOTE);
+    Glib::RefPtr<Gio::Settings> settings = m_preferences.get_schema_settings(Preferences::SCHEMA_GNOTE);
     // Watch the START_NOTE_URI setting and update it so that the
     // StartNoteUri property doesn't generate a call to
     // Preferences.Get () each time it's accessed.
@@ -107,14 +106,14 @@ namespace gnote {
   void NoteManager::on_setting_changed(const Glib::ustring & key)
   {
     if(key == Preferences::START_NOTE_URI) {
-      m_start_note_uri = Preferences::obj()
+      m_start_note_uri = m_preferences
         .get_schema_settings(Preferences::SCHEMA_GNOTE)->get_string(Preferences::START_NOTE_URI);
     }
   }
 
   AddinManager *NoteManager::create_addin_manager()
   {
-    return new AddinManager(*this, IGnote::conf_dir());
+    return new AddinManager(*this, m_preferences, IGnote::conf_dir());
   }
 
   void NoteManager::create_start_notes ()
@@ -166,7 +165,7 @@ namespace gnote {
       NoteBase::Ptr start_note = create (_("Start Here"),
                                 start_note_content);
       start_note->queue_save (CONTENT_CHANGED);
-      Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_string(
+      m_preferences.get_schema_settings(Preferences::SCHEMA_GNOTE)->set_string(
           Preferences::START_NOTE_URI, start_note->uri());
 
       NoteBase::Ptr links_note = create (_("Using Links in Gnote"),
@@ -203,7 +202,7 @@ namespace gnote {
       // Attempt to find an existing Start Here note
       NoteBase::Ptr start_note = find (_("Start Here"));
       if (start_note) {
-        Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_string(
+        m_preferences.get_schema_settings(Preferences::SCHEMA_GNOTE)->set_string(
             Preferences::START_NOTE_URI, start_note->uri());
       }
     }
diff --git a/src/notemanager.hpp b/src/notemanager.hpp
index 7c5ae6f5..e09cea54 100644
--- a/src/notemanager.hpp
+++ b/src/notemanager.hpp
@@ -25,6 +25,7 @@
 
 #include "notemanagerbase.hpp"
 #include "note.hpp"
+#include "preferences.hpp"
 #include "tagmanager.hpp"
 
 namespace gnote {
@@ -38,7 +39,7 @@ namespace gnote {
     typedef std::shared_ptr<NoteManager> Ptr;
     typedef sigc::slot<void, const Note::Ptr &> NoteChangedSlot;
     
-    NoteManager(const Glib::ustring &);
+    NoteManager(Preferences & preferences, const Glib::ustring &);
     ~NoteManager();
 
     virtual NoteArchiver & note_archiver() override
@@ -84,6 +85,7 @@ namespace gnote {
     void load_notes();
     void on_exiting_event();
 
+    Preferences & m_preferences;
     AddinManager   *m_addin_mgr;
     NoteArchiver m_note_archiver;
     TagManager m_tag_manager;
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 3c1d26c9..1658e983 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -225,7 +225,7 @@ namespace gnote {
 
   void NoteWindow::hint_size(int & width, int & height)
   {
-    if (Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
+    if (IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
           Preferences::AUTOSIZE_NOTE_WINDOW)) {
       width = m_width;
       height = m_height;
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 7de910f7..b7091299 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -85,7 +85,7 @@ namespace gnote {
   const char * Preferences::DESKTOP_GNOME_KEY_THEME = "gtk-key-theme";
 
 
-  Preferences::Preferences()
+  void Preferences::init()
   {
     m_schemas[SCHEMA_GNOTE] = Gio::Settings::create(SCHEMA_GNOTE);
     m_schemas[SCHEMA_KEYBINDINGS] = Gio::Settings::create(SCHEMA_KEYBINDINGS);
diff --git a/src/preferences.hpp b/src/preferences.hpp
index c0b4a81c..8979dfc7 100644
--- a/src/preferences.hpp
+++ b/src/preferences.hpp
@@ -28,12 +28,9 @@
 #include <sigc++/signal.h>
 #include <giomm/settings.h>
 
-#include "base/singleton.hpp"
-
 namespace gnote {
 
   class Preferences 
-    : public base::Singleton<Preferences>
   {
   public:
     static const char *SCHEMA_GNOTE;
@@ -93,7 +90,8 @@ namespace gnote {
     static const char *DESKTOP_GNOME_FONT;
     static const char *DESKTOP_GNOME_KEY_THEME;
 
-    Preferences();
+    Preferences() {}
+    void init();
 
     Glib::RefPtr<Gio::Settings> get_schema_settings(const Glib::ustring & schema);
   private:
diff --git a/src/preferencesdialog.cpp b/src/preferencesdialog.cpp
index da249a27..167d3400 100644
--- a/src/preferencesdialog.cpp
+++ b/src/preferencesdialog.cpp
@@ -163,7 +163,7 @@ namespace gnote {
       add_action_widget (*button, Gtk::RESPONSE_CLOSE);
       set_default_response(Gtk::RESPONSE_CLOSE);
 
-    Preferences::obj().get_schema_settings(
+    IGnote::obj().preferences().get_schema_settings(
       Preferences::SCHEMA_GNOTE)->signal_changed().connect(
         sigc::mem_fun(*this, &PreferencesDialog::on_preferences_setting_changed));
   }
@@ -225,7 +225,7 @@ namespace gnote {
       Gtk::Label *label;
       Gtk::CheckButton *check;
       sharp::PropertyEditorBool *peditor, *font_peditor,* bullet_peditor;
-      Glib::RefPtr<Gio::Settings> settings = 
Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+      Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
 
       Gtk::Grid *options_list = manage(new Gtk::Grid);
       options_list->set_row_spacing(12);
@@ -354,7 +354,7 @@ namespace gnote {
     button->add (*font_box);
     button->show ();
 
-    Glib::ustring font_desc = Preferences::obj().get_schema_settings(
+    Glib::ustring font_desc = IGnote::obj().preferences().get_schema_settings(
         Preferences::SCHEMA_GNOTE)->get_string(Preferences::CUSTOM_FONT_FACE);
     update_font_button (font_desc);
 
@@ -371,7 +371,7 @@ namespace gnote {
     Gtk::CheckButton *check;
     sharp::PropertyEditorBool *peditor;
     int vbox_row = 0;
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
+    Glib::RefPtr<Gio::Settings> settings = IGnote::obj().preferences()
       .get_schema_settings(Preferences::SCHEMA_GNOTE);
 
     // internal links
@@ -448,7 +448,7 @@ namespace gnote {
 
     // Read from Preferences which service is configured and select it
     // by default.  Otherwise, just select the first one in the list.
-    Glib::ustring addin_id = Preferences::obj()
+    Glib::ustring addin_id = IGnote::obj().preferences()
       .get_schema_settings(Preferences::SCHEMA_SYNC)->get_string(Preferences::SYNC_SELECTED_SERVICE_ADDIN);
 
     Gtk::TreeIter active_iter;
@@ -496,11 +496,11 @@ namespace gnote {
     vbox->attach(*m_sync_addin_prefs_container, 0, vbox_row++, 1, 1);
 
     // Autosync preference
-    int timeout = Preferences::obj().get_schema_settings(
+    int timeout = IGnote::obj().preferences().get_schema_settings(
         Preferences::SCHEMA_SYNC)->get_int(Preferences::SYNC_AUTOSYNC_TIMEOUT);
     if(timeout > 0 && timeout < 5) {
       timeout = 5;
-      Preferences::obj().get_schema_settings(
+      IGnote::obj().preferences().get_schema_settings(
           Preferences::SCHEMA_SYNC)->set_int(Preferences::SYNC_AUTOSYNC_TIMEOUT, 5);
     }
     Gtk::Grid *autosyncBox = manage(new Gtk::Grid);
@@ -928,7 +928,7 @@ namespace gnote {
     Gtk::FontSelectionDialog *font_dialog =
       new Gtk::FontSelectionDialog (_("Choose Note Font"));
 
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+    Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
     Glib::ustring font_name = settings->get_string(Preferences::CUSTOM_FONT_FACE);
     font_dialog->set_font_name(font_name);
 
@@ -975,7 +975,7 @@ namespace gnote {
   void  PreferencesDialog::on_preferences_setting_changed(const Glib::ustring & key)
   {
     if (key == Preferences::NOTE_RENAME_BEHAVIOR) {
-      Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
+      Glib::RefPtr<Gio::Settings> settings = IGnote::obj().preferences()
         .get_schema_settings(Preferences::SCHEMA_GNOTE);
       int rename_behavior = settings->get_int(key);
       if (0 > rename_behavior || 2 < rename_behavior) {
@@ -988,7 +988,7 @@ namespace gnote {
       }
     }
     else if(key == Preferences::SYNC_AUTOSYNC_TIMEOUT) {
-      int timeout = Preferences::obj().get_schema_settings(
+      int timeout = IGnote::obj().preferences().get_schema_settings(
           Preferences::SCHEMA_SYNC)->get_int(Preferences::SYNC_AUTOSYNC_TIMEOUT);
       if(timeout <= 0 && m_autosync_check->get_active()) {
         m_autosync_check->set_active(false);
@@ -1009,7 +1009,7 @@ namespace gnote {
 
   void  PreferencesDialog::on_rename_behavior_changed()
   {
-    Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_int(
+    IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_int(
         Preferences::NOTE_RENAME_BEHAVIOR, m_rename_behavior_combo->get_active_row_number());
   }
 
@@ -1018,7 +1018,7 @@ namespace gnote {
   {
     // Get saved behavior
     sync::SyncTitleConflictResolution savedBehavior = sync::CANCEL;
-    int dlgBehaviorPref = Preferences::obj().get_schema_settings(
+    int dlgBehaviorPref = IGnote::obj().preferences().get_schema_settings(
       Preferences::SCHEMA_SYNC)->get_int(Preferences::SYNC_CONFIGURED_CONFLICT_BEHAVIOR);
     // TODO: Check range of this int
     savedBehavior = static_cast<sync::SyncTitleConflictResolution>(dlgBehaviorPref);
@@ -1085,7 +1085,7 @@ namespace gnote {
       newBehavior = sync::OVERWRITE_EXISTING;
     }
 
-    Preferences::obj().get_schema_settings(Preferences::SCHEMA_SYNC)->set_int(
+    IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_SYNC)->set_int(
       Preferences::SYNC_CONFIGURED_CONFLICT_BEHAVIOR, static_cast<int>(newBehavior));
   }
 
@@ -1167,7 +1167,7 @@ namespace gnote {
       DBG_OUT("Error calling %s.reset_configuration: %s", m_selected_sync_addin->id().c_str(), e.what());
     }
 
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_SYNC);
+    Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_SYNC);
     settings->set_string(Preferences::SYNC_SELECTED_SERVICE_ADDIN, "");
 
     // Reset conflict handling behavior
@@ -1216,7 +1216,7 @@ namespace gnote {
 
     utils::HIGMessageDialog *dialog;
     if(saved) {
-      Preferences::obj().get_schema_settings(Preferences::SCHEMA_SYNC)->set_string(
+      IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_SYNC)->set_string(
         Preferences::SYNC_SELECTED_SERVICE_ADDIN, m_selected_sync_addin->id());
 
       m_sync_addin_combo->set_sensitive(false);
@@ -1244,7 +1244,7 @@ namespace gnote {
       // TODO: Change the SyncServiceAddin API so the call to
       // SaveConfiguration has a way of passing back an exception
       // or other text so it can be displayed to the user.
-      Preferences::obj().get_schema_settings(Preferences::SCHEMA_SYNC)->set_string(
+      IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_SYNC)->set_string(
        Preferences::SYNC_SELECTED_SERVICE_ADDIN, "");
 
       m_sync_addin_combo->set_sensitive(true);
@@ -1418,7 +1418,7 @@ namespace gnote {
 
   void PreferencesDialog::update_timeout_pref()
   {
-    Preferences::obj().get_schema_settings(Preferences::SCHEMA_SYNC)->set_int(
+    IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_SYNC)->set_int(
         Preferences::SYNC_AUTOSYNC_TIMEOUT,
         m_autosync_check->get_active() ? static_cast<int>(m_autosync_spinner->get_value()) : -1);
   }
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 627780e3..a1a7cfb3 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -59,7 +59,7 @@ namespace gnote {
     , m_window_menu_default(NULL)
     , m_keybinder(get_accel_group())
   {
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+    Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
     m_open_notes_in_new_window = settings->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
     m_close_note_on_escape = settings->get_boolean(Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE);
     set_default_size(450,400);
@@ -381,7 +381,7 @@ namespace gnote {
     Glib::RefPtr<Gdk::Window> win = get_window();
     // background window (for tray to work) might not have GDK window
     if(win) {
-      Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_boolean(
+      IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_boolean(
           Preferences::MAIN_WINDOW_MAXIMIZED,
           win->get_state() & Gdk::WINDOW_STATE_MAXIMIZED);
     }
@@ -525,7 +525,7 @@ namespace gnote {
       wid.show();
       widget.foreground();
 
-      bool maximized = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
+      bool maximized = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
         Preferences::MAIN_WINDOW_MAXIMIZED);
       if(get_realized()) {
         //if window is showing, use actual state
@@ -825,11 +825,11 @@ namespace gnote {
   void NoteRecentChanges::on_settings_changed(const Glib::ustring & key)
   {
     if(key == Preferences::OPEN_NOTES_IN_NEW_WINDOW) {
-      m_open_notes_in_new_window = Preferences::obj().get_schema_settings(
+      m_open_notes_in_new_window = IGnote::obj().preferences().get_schema_settings(
         Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
     }
     else if(key == Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE) {
-      m_close_note_on_escape = Preferences::obj().get_schema_settings(
+      m_close_note_on_escape = IGnote::obj().preferences().get_schema_settings(
         Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE);
     }
   }
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index c1d3150a..0c58ba4a 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -104,10 +104,10 @@ SearchNotesWidget::SearchNotesWidget(NoteManager & m)
   notebooks::NotebookManager::obj().signal_note_pin_status_changed
     .connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_pin_status_changed));
 
-  Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+  Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
   settings->signal_changed().connect(sigc::mem_fun(*this, &SearchNotesWidget::on_settings_changed));
   parse_sorting_setting(settings->get_string(Preferences::SEARCH_SORTING));
-  settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE);
+  settings = IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE);
   settings->signal_changed().connect(sigc::mem_fun(*this, &SearchNotesWidget::on_settings_changed));
 }
 
@@ -272,7 +272,7 @@ void SearchNotesWidget::save_position()
     return;
   }
 
-  Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
+  Glib::RefPtr<Gio::Settings> settings = IGnote::obj().preferences()
     .get_schema_settings(Preferences::SCHEMA_GNOTE);
   settings->set_int(Preferences::SEARCH_WINDOW_SPLITTER_POS, get_position());
 
@@ -1283,7 +1283,7 @@ Gtk::Menu *SearchNotesWidget::get_note_list_context_menu()
 {
   if(!m_note_list_context_menu) {
     m_note_list_context_menu = new Gtk::Menu;
-    bool open_notes_in_new_window = Preferences::obj().get_schema_settings(
+    bool open_notes_in_new_window = IGnote::obj().preferences().get_schema_settings(
       Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
 
     Gtk::MenuItem *item;
@@ -1415,7 +1415,7 @@ void SearchNotesWidget::background()
 
 void SearchNotesWidget::hint_size(int & width, int & height)
 {
-  Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
+  Glib::RefPtr<Gio::Settings> settings = IGnote::obj().preferences()
     .get_schema_settings(Preferences::SCHEMA_GNOTE);
   width = settings->get_int(Preferences::SEARCH_WINDOW_WIDTH);
   height = settings->get_int(Preferences::SEARCH_WINDOW_HEIGHT);
@@ -1423,7 +1423,7 @@ void SearchNotesWidget::hint_size(int & width, int & height)
 
 void SearchNotesWidget::size_internals()
 {
-  Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
+  Glib::RefPtr<Gio::Settings> settings = IGnote::obj().preferences()
     .get_schema_settings(Preferences::SCHEMA_GNOTE);
   int pos = settings->get_int(Preferences::SEARCH_WINDOW_SPLITTER_POS);
   if(pos) {
@@ -1487,7 +1487,7 @@ void SearchNotesWidget::on_sorting_changed()
     else {
       value += "desc";
     }
-    Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_string(
+    IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_string(
       Preferences::SEARCH_SORTING, value);
   }
 }
diff --git a/src/synchronization/fusesyncserviceaddin.cpp b/src/synchronization/fusesyncserviceaddin.cpp
index 812882cf..3769aad6 100644
--- a/src/synchronization/fusesyncserviceaddin.cpp
+++ b/src/synchronization/fusesyncserviceaddin.cpp
@@ -24,6 +24,7 @@
 #include "debug.hpp"
 #include "filesystemsyncserver.hpp"
 #include "fusesyncserviceaddin.hpp"
+#include "ignote.hpp"
 #include "preferences.hpp"
 #include "sharp/directory.hpp"
 #include "sharp/files.hpp"
@@ -255,7 +256,7 @@ bool FuseSyncServiceAddin::mount_fuse(bool useStoredValues)
 
 int FuseSyncServiceAddin::get_timeout_ms()
 {
-  Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+  Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
   try {
     return settings->get_int(Preferences::SYNC_FUSE_MOUNT_TIMEOUT);
   }
diff --git a/src/synchronization/isyncmanager.cpp b/src/synchronization/isyncmanager.cpp
index c3a41345..ed72d2ad 100644
--- a/src/synchronization/isyncmanager.cpp
+++ b/src/synchronization/isyncmanager.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2013,2017 Aurimas Cernius
+ * Copyright (C) 2012-2013,2017,2019 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
  */
 
 
+#include "ignote.hpp"
 #include "isyncmanager.hpp"
 #include "preferences.hpp"
 #include "sharp/uuid.hpp"
@@ -28,7 +29,7 @@ namespace sync {
 
 
 SyncLockInfo::SyncLockInfo()
-  : 
client_id(Preferences::obj().get_schema_settings(Preferences::SCHEMA_SYNC)->get_string(Preferences::SYNC_CLIENT_ID))
+  : 
client_id(IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_SYNC)->get_string(Preferences::SYNC_CLIENT_ID))
   , transaction_id(sharp::uuid().string())
   , renew_count(0)
   , duration(0, 2, 0) // default of 2 minutes
diff --git a/src/synchronization/syncdialog.cpp b/src/synchronization/syncdialog.cpp
index 58c1ddac..978769ed 100644
--- a/src/synchronization/syncdialog.cpp
+++ b/src/synchronization/syncdialog.cpp
@@ -596,7 +596,7 @@ void SyncDialog::note_conflict_detected(const Note::Ptr & localConflictNote,
                                         NoteUpdate remoteNote,
                                         const std::vector<Glib::ustring> & noteUpdateTitles)
 {
-  int dlgBehaviorPref = Preferences::obj()
+  int dlgBehaviorPref = IGnote::obj().preferences()
     .get_schema_settings(Preferences::SCHEMA_SYNC)->get_int(Preferences::SYNC_CONFIGURED_CONFLICT_BEHAVIOR);
   std::exception *mainThreadException = NULL;
 
@@ -683,7 +683,7 @@ void SyncDialog::note_conflict_detected_(
       }
     }
 
-    Preferences::obj().get_schema_settings(Preferences::SCHEMA_SYNC)->set_int(
+    IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_SYNC)->set_int(
       Preferences::SYNC_CONFIGURED_CONFLICT_BEHAVIOR, static_cast<int>(savedBehavior)); // TODO: Clean up
 
     conflictDlg.hide();
diff --git a/src/synchronization/syncmanager.cpp b/src/synchronization/syncmanager.cpp
index 87e2ed48..6593f9a2 100644
--- a/src/synchronization/syncmanager.cpp
+++ b/src/synchronization/syncmanager.cpp
@@ -90,7 +90,7 @@ namespace sync {
   {
     try {
       NoteManager & manager(dynamic_cast<NoteManager&>(note_mgr()));
-      Preferences::obj().get_schema_settings(Preferences::SCHEMA_SYNC)->signal_changed()
+      IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_SYNC)->signal_changed()
         .connect(sigc::mem_fun(*this, &SyncManager::preferences_setting_changed));
       manager.signal_note_saved.connect(sigc::mem_fun(*this, &SyncManager::handle_note_saved_or_deleted));
       manager.signal_note_deleted.connect(sigc::mem_fun(*this, &SyncManager::handle_note_saved_or_deleted));
@@ -418,7 +418,7 @@ namespace sync {
 
   void SyncManager::update_sync_action()
   {
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_SYNC);
+    Glib::RefPtr<Gio::Settings> settings = 
IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_SYNC);
     Glib::ustring sync_addin_id = settings->get_string(Preferences::SYNC_SELECTED_SERVICE_ADDIN);
     IActionManager::obj().get_app_action("sync-notes")->set_enabled(sync_addin_id != "");
 
@@ -539,7 +539,7 @@ namespace sync {
   {
     SyncServiceAddin *addin = NULL;
 
-    Glib::ustring sync_service_id = Preferences::obj()
+    Glib::ustring sync_service_id = IGnote::obj().preferences()
       .get_schema_settings(Preferences::SCHEMA_SYNC)->get_string(Preferences::SYNC_SELECTED_SERVICE_ADDIN);
     if(sync_service_id != "") {
       addin = get_sync_service_addin(sync_service_id);
diff --git a/src/utils.cpp b/src/utils.cpp
index deac9ebc..190c9602 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -42,6 +42,7 @@
 #include "sharp/string.hpp"
 #include "sharp/uri.hpp"
 #include "sharp/datetime.hpp"
+#include "ignote.hpp"
 #include "preferences.hpp"
 #include "note.hpp"
 #include "utils.hpp"
@@ -186,7 +187,7 @@ namespace gnote {
     {
       bool use_12h = false;
       if(show_time) {
-        use_12h = Preferences::obj().get_schema_settings(
+        use_12h = IGnote::obj().preferences().get_schema_settings(
           Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE)->get_string(
             Preferences::DESKTOP_GNOME_CLOCK_FORMAT) == "12h";
       }
diff --git a/src/watchers.cpp b/src/watchers.cpp
index d368c5e2..72a9269f 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -31,6 +31,7 @@
 #include "sharp/string.hpp"
 #include "debug.hpp"
 #include "iactionmanager.hpp"
+#include "ignote.hpp"
 #include "mainwindow.hpp"
 #include "noteeditor.hpp"
 #include "notemanager.hpp"
@@ -290,7 +291,7 @@ namespace gnote {
 
   void NoteSpellChecker::on_note_opened ()
   {
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
+    Glib::RefPtr<Gio::Settings> settings = IGnote::obj().preferences()
       .get_schema_settings(Preferences::SCHEMA_GNOTE);
     settings->signal_changed()
       .connect(sigc::mem_fun(*this, &NoteSpellChecker::on_enable_spellcheck_changed));
@@ -383,7 +384,7 @@ namespace gnote {
     if (key != Preferences::ENABLE_SPELLCHECKING) {
       return;
     }
-    bool value = Preferences::obj()
+    bool value = IGnote::obj().preferences()
       .get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(key);
     
     if (value) {



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