[gnote] Do not use singleton IGnote in AddinManager
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Do not use singleton IGnote in AddinManager
- Date: Sun, 17 Nov 2019 16:44:37 +0000 (UTC)
commit 171388c64489e88edfca2eebb18c3c75de19a344
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Nov 17 18:43:32 2019 +0200
Do not use singleton IGnote in AddinManager
src/addinmanager.cpp | 15 ++++++++-------
src/addinmanager.hpp | 3 ++-
src/notemanager.cpp | 2 +-
3 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/addinmanager.cpp b/src/addinmanager.cpp
index 698faac9..d02cb587 100644
--- a/src/addinmanager.cpp
+++ b/src/addinmanager.cpp
@@ -89,8 +89,9 @@ namespace {
}
- AddinManager::AddinManager(NoteManager & note_manager, Preferences & preferences, const Glib::ustring &
conf_dir)
- : m_note_manager(note_manager)
+ AddinManager::AddinManager(IGnote & g, NoteManager & note_manager, Preferences & preferences, const
Glib::ustring & conf_dir)
+ : m_gnote(g)
+ , m_note_manager(note_manager)
, m_preferences(preferences)
, m_gnote_conf_dir(conf_dir)
{
@@ -158,7 +159,7 @@ namespace {
const Note::Ptr & note = iter->first;
NoteAddin *const addin = dynamic_cast<NoteAddin *>((*f)());
if(addin) {
- addin->initialize(IGnote::obj(), note);
+ addin->initialize(m_gnote, note);
id_addin_map.insert(std::make_pair(id, addin));
}
}
@@ -361,7 +362,7 @@ namespace {
sharp::IInterface* iface = (*addin_info.second)();
NoteAddin * addin = dynamic_cast<NoteAddin *>(iface);
if(addin) {
- addin->initialize(IGnote::obj(), note);
+ addin->initialize(m_gnote, note);
loaded.insert(std::make_pair(addin_info.first, addin));
}
else {
@@ -438,7 +439,7 @@ namespace {
const sharp::DynamicModule * dmod
= m_module_manager.get_module(iter->first);
if (!dmod || dmod->is_enabled()) {
- addin->initialize(IGnote::obj(), m_note_manager);
+ addin->initialize(m_gnote, m_note_manager);
}
}
}
@@ -563,7 +564,7 @@ namespace {
{
IdAddinPrefsMap::const_iterator iter = m_addin_prefs.find(id);
if(iter != m_addin_prefs.end()) {
- return iter->second->create_preference_widget(IGnote::obj(), IGnote::obj().preferences(),
m_note_manager);
+ return iter->second->create_preference_widget(m_gnote, m_gnote.preferences(), m_note_manager);
}
return NULL;
}
@@ -577,7 +578,7 @@ namespace {
void AddinManager::register_addin_actions() const
{
- auto & manager(IGnote::obj().action_manager());
+ auto & manager(m_gnote.action_manager());
for(auto & info : m_addin_infos) {
auto & non_modifying = info.second.non_modifying_actions();
for(auto & action : info.second.actions()) {
diff --git a/src/addinmanager.hpp b/src/addinmanager.hpp
index 2f3b5bc1..3a9d7a6d 100644
--- a/src/addinmanager.hpp
+++ b/src/addinmanager.hpp
@@ -51,7 +51,7 @@ typedef std::map<Glib::ustring, AddinInfo> AddinInfoMap;
class AddinManager
{
public:
- AddinManager(NoteManager & note_manager, Preferences & preferences, const Glib::ustring & conf_dir);
+ AddinManager(IGnote & g, NoteManager & note_manager, Preferences & preferences, const Glib::ustring &
conf_dir);
~AddinManager();
void add_note_addin_info(const Glib::ustring & id, const sharp::DynamicModule * dmod);
@@ -95,6 +95,7 @@ private:
void on_setting_changed(const Glib::ustring & key);
void register_addin_actions() const;
+ IGnote & m_gnote;
NoteManager & m_note_manager;
Preferences & m_preferences;
const Glib::ustring m_gnote_conf_dir;
diff --git a/src/notemanager.cpp b/src/notemanager.cpp
index c25606a2..40309b00 100644
--- a/src/notemanager.cpp
+++ b/src/notemanager.cpp
@@ -111,7 +111,7 @@ namespace gnote {
AddinManager *NoteManager::create_addin_manager()
{
- return new AddinManager(*this, m_preferences, IGnote::conf_dir());
+ return new AddinManager(IGnote::obj(), *this, m_preferences, IGnote::conf_dir());
}
void NoteManager::create_start_notes ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]