[gnote] Make addins have references to managers and Gnote
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Make addins have references to managers and Gnote
- Date: Sat, 26 Oct 2019 12:20:07 +0000 (UTC)
commit 19b4ef3fd9f2d8ad080072b5c3da9f5ae4075018
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Oct 26 15:19:39 2019 +0300
Make addins have references to managers and Gnote
src/abstractaddin.cpp | 5 +++--
src/abstractaddin.hpp | 15 ++++++++++++++-
src/addinmanager.cpp | 8 +++-----
src/applicationaddin.hpp | 17 ++++++++++++-----
src/noteaddin.cpp | 3 ++-
src/noteaddin.hpp | 2 +-
src/synchronization/syncserviceaddin.hpp | 12 ++++++++++++
7 files changed, 47 insertions(+), 15 deletions(-)
---
diff --git a/src/abstractaddin.cpp b/src/abstractaddin.cpp
index 92a38442..764b5bde 100644
--- a/src/abstractaddin.cpp
+++ b/src/abstractaddin.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010 Aurimas Cernius
+ * Copyright (C) 2010,2019 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -26,7 +26,8 @@
namespace gnote {
AbstractAddin::AbstractAddin()
- : m_disposing(false)
+ : m_gnote(NULL)
+ , m_disposing(false)
{
}
diff --git a/src/abstractaddin.hpp b/src/abstractaddin.hpp
index fbd0794b..7616431f 100644
--- a/src/abstractaddin.hpp
+++ b/src/abstractaddin.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010,2012-2013 Aurimas Cernius
+ * Copyright (C) 2010,2012-2013,2019 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -30,6 +30,9 @@
namespace gnote {
+class IGnote;
+
+
class AbstractAddin
: public sharp::IInterface
, public sigc::trackable
@@ -38,13 +41,23 @@ public:
AbstractAddin();
virtual ~AbstractAddin();
+ void initialize(IGnote & ignote)
+ {
+ m_gnote = &ignote;
+ }
void dispose();
bool is_disposing() const
{ return m_disposing; }
+
+ IGnote & ignote()
+ {
+ return *m_gnote;
+ }
protected:
virtual void dispose(bool disposing);
private:
+ IGnote *m_gnote;
bool m_disposing;
};
diff --git a/src/addinmanager.cpp b/src/addinmanager.cpp
index 95453e33..f8a7b6ce 100644
--- a/src/addinmanager.cpp
+++ b/src/addinmanager.cpp
@@ -158,7 +158,7 @@ namespace {
const Note::Ptr & note = iter->first;
NoteAddin *const addin = dynamic_cast<NoteAddin *>((*f)());
if(addin) {
- addin->initialize(note);
+ addin->initialize(IGnote::obj(), note);
id_addin_map.insert(std::make_pair(id, addin));
}
}
@@ -324,7 +324,6 @@ namespace {
f = dmod->query_interface(ApplicationAddin::IFACE_NAME);
if(f) {
ApplicationAddin * addin = dynamic_cast<ApplicationAddin*>((*f)());
- addin->note_manager(m_note_manager);
m_app_addins.insert(std::make_pair(mod_id, addin));
}
f = dmod->query_interface(sync::SyncServiceAddin::IFACE_NAME);
@@ -362,7 +361,7 @@ namespace {
sharp::IInterface* iface = (*addin_info.second)();
NoteAddin * addin = dynamic_cast<NoteAddin *>(iface);
if(addin) {
- addin->initialize(note);
+ addin->initialize(IGnote::obj(), note);
loaded.insert(std::make_pair(addin_info.first, addin));
}
else {
@@ -436,11 +435,10 @@ namespace {
for(AppAddinMap::const_iterator iter = m_app_addins.begin();
iter != m_app_addins.end(); ++iter) {
ApplicationAddin * addin = iter->second;
- addin->note_manager(m_note_manager);
const sharp::DynamicModule * dmod
= m_module_manager.get_module(iter->first);
if (!dmod || dmod->is_enabled()) {
- addin->initialize();
+ addin->initialize(IGnote::obj(), m_note_manager);
}
}
}
diff --git a/src/applicationaddin.hpp b/src/applicationaddin.hpp
index 6750ef89..4189bc9d 100644
--- a/src/applicationaddin.hpp
+++ b/src/applicationaddin.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2013 Aurimas Cernius
+ * Copyright (C) 2013,2019 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -36,6 +36,17 @@ class ApplicationAddin
public:
static const char * IFACE_NAME;
+ ApplicationAddin()
+ : m_note_manager(NULL)
+ {}
+
+ void initialize(IGnote & ignote, NoteManager & note_manager)
+ {
+ AbstractAddin::initialize(ignote);
+ m_note_manager = ¬e_manager;
+ initialize();
+ }
+
/// <summary>
/// Called when Gnote has started up and is nearly 100% initialized.
/// </summary>
@@ -55,10 +66,6 @@ public:
{
return *m_note_manager;
}
- void note_manager(NoteManager & manager)
- {
- m_note_manager = &manager;
- }
private:
NoteManager *m_note_manager;
};
diff --git a/src/noteaddin.cpp b/src/noteaddin.cpp
index 39fd4377..612bc8d8 100644
--- a/src/noteaddin.cpp
+++ b/src/noteaddin.cpp
@@ -31,8 +31,9 @@ namespace gnote {
const char * NoteAddin::IFACE_NAME = "gnote::NoteAddin";
- void NoteAddin::initialize(const Note::Ptr & note)
+ void NoteAddin::initialize(IGnote & ignote, const Note::Ptr & note)
{
+ AbstractAddin::initialize(ignote);
m_note = note;
m_note_opened_cid = m_note->signal_opened().connect(
sigc::mem_fun(*this, &NoteAddin::on_note_opened_event));
diff --git a/src/noteaddin.hpp b/src/noteaddin.hpp
index 727a3886..44376f39 100644
--- a/src/noteaddin.hpp
+++ b/src/noteaddin.hpp
@@ -51,7 +51,7 @@ public:
static const char * IFACE_NAME;
/// factory method
// static NoteAddin *create() { return NULL; }
- void initialize(const Note::Ptr & note);
+ void initialize(IGnote & ignote, const Note::Ptr & note);
virtual void dispose(bool) override;
diff --git a/src/synchronization/syncserviceaddin.hpp b/src/synchronization/syncserviceaddin.hpp
index 3bbf7fe1..06da00ee 100644
--- a/src/synchronization/syncserviceaddin.hpp
+++ b/src/synchronization/syncserviceaddin.hpp
@@ -39,6 +39,16 @@ namespace sync {
typedef sigc::slot<void> EventHandler;
static const char * IFACE_NAME;
+ SyncServiceAddin()
+ : m_sync_manager(NULL)
+ {}
+
+ void initialize(IGnote & ignote, ISyncManager & sync_manager)
+ {
+ AbstractAddin::initialize(ignote);
+ m_sync_manager = &sync_manager;
+ }
+
virtual SyncServer::Ptr create_sync_server() = 0;
virtual void post_sync_cleanup() = 0;
virtual Gtk::Widget *create_preferences_control(EventHandler requiredPrefChanged) = 0;
@@ -55,6 +65,8 @@ namespace sync {
virtual void initialize () = 0;
virtual void shutdown () = 0;
virtual bool initialized () = 0;
+ private:
+ ISyncManager *m_sync_manager;
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]