[PATCH 4/7] Store add-in enabled status in ini file.
- From: Łukasz Krotowski <lukasz krotowski gmail com>
- To: gnote-list gnome org
- Subject: [PATCH 4/7] Store add-in enabled status in ini file.
- Date: Sat, 22 May 2010 03:34:23 +0200
Signed-off-by: Łukasz Krotowski <lukasz krotowski gmail com>
---
src/addinmanager.cpp | 32 ++++++++++++++++++++++++++++++++
src/addinmanager.hpp | 1 +
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/src/addinmanager.cpp b/src/addinmanager.cpp
index aba867d..9a50ac2 100644
--- a/src/addinmanager.cpp
+++ b/src/addinmanager.cpp
@@ -74,6 +74,7 @@ namespace gnote {
: m_gnote_conf_dir(conf_dir)
{
m_addins_prefs_dir = Glib::build_filename(conf_dir, "addins");
+ m_addins_prefs_file = Glib::build_filename(m_addins_prefs_dir, "global.ini");
const bool is_first_run
= !sharp::directory_exists(m_addins_prefs_dir);
@@ -95,6 +96,24 @@ namespace gnote {
AddinManager::~AddinManager()
{
+ Glib::KeyFile global_addins_prefs;
+ try {
+ global_addins_prefs.load_from_file(m_addins_prefs_file);
+ }
+ catch (Glib::Error & not_loaded_ignored) {}
+
+ const sharp::ModuleList & list = m_module_manager.get_modules();
+ for(sharp::ModuleList::const_iterator iter = list.begin();
+ iter != list.end(); ++iter) {
+ const sharp::DynamicModule* dmod = *iter;
+ global_addins_prefs.set_boolean("Enabled", dmod->id(), dmod->enabled());
+ }
+
+ Glib::RefPtr<Gio::File> prefs_file = Gio::File::create_for_path(m_addins_prefs_file);
+ Glib::RefPtr<Gio::FileOutputStream> prefs_file_stream = prefs_file->append_to();
+ prefs_file_stream->truncate(0);
+ prefs_file_stream->write(global_addins_prefs.to_data());
+
sharp::map_delete_all_second(m_app_addins);
for(NoteAddinMap::const_iterator iter = m_note_addins.begin();
iter != m_note_addins.end(); ++iter) {
@@ -214,6 +233,15 @@ namespace gnote {
m_module_manager.load_modules();
+ bool global_addins_prefs_loaded = true;
+ Glib::KeyFile global_addins_prefs;
+ try {
+ global_addins_prefs.load_from_file(m_addins_prefs_file);
+ }
+ catch (Glib::Error & not_loaded) {
+ global_addins_prefs_loaded = false;
+ }
+
const sharp::ModuleList & list = m_module_manager.get_modules();
for(sharp::ModuleList::const_iterator iter = list.begin();
iter != list.end(); ++iter) {
@@ -223,6 +251,10 @@ namespace gnote {
continue;
}
+ if(global_addins_prefs_loaded &&
+ global_addins_prefs.has_key("Enabled", dmod->id()))
+ dmod->enabled(global_addins_prefs.get_boolean("Enabled", dmod->id()));
+
sharp::IfaceFactoryBase * f = dmod->query_interface(NoteAddin::IFACE_NAME);
if(f) {
m_note_addin_infos.insert(std::make_pair(dmod->id(), f));
diff --git a/src/addinmanager.hpp b/src/addinmanager.hpp
index c3eb161..d9f6361 100644
--- a/src/addinmanager.hpp
+++ b/src/addinmanager.hpp
@@ -78,6 +78,7 @@ private:
const std::string m_gnote_conf_dir;
std::string m_addins_prefs_dir;
+ std::string m_addins_prefs_file;
sharp::ModuleManager m_module_manager;
std::list<sharp::IfaceFactoryBase*> m_builtin_ifaces;
/// Key = TypeExtensionNode.Id
--
1.7.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]