[gnote] Do not use Preferences for note dir watcher own settings
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Do not use Preferences for note dir watcher own settings
- Date: Sun, 20 Dec 2020 10:58:50 +0000 (UTC)
commit 512de5625bd96abf962ca30225903c2bd7a491b4
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Dec 20 12:55:52 2020 +0200
Do not use Preferences for note dir watcher own settings
.../notedirectorywatcher.desktop.in.in | 2 +-
.../notedirectorywatcherapplicationaddin.cpp | 15 +++++---------
.../notedirectorywatcherpreferences.cpp | 23 +++++++++++++++-------
.../notedirectorywatcherpreferences.hpp | 7 ++++---
4 files changed, 26 insertions(+), 21 deletions(-)
---
diff --git a/src/addins/notedirectorywatcher/notedirectorywatcher.desktop.in.in
b/src/addins/notedirectorywatcher/notedirectorywatcher.desktop.in.in
index 6a621f63..8b84cf5f 100644
--- a/src/addins/notedirectorywatcher/notedirectorywatcher.desktop.in.in
+++ b/src/addins/notedirectorywatcher/notedirectorywatcher.desktop.in.in
@@ -4,7 +4,7 @@ _Name=Note Directory Watcher
_Description=Watch your Gnote note directory for changes to your notes.
_Authors=Aurimas Černius and Tomboy original authors
Category=Tools
-Version=0.4
+Version=0.5
DefaultEnabled=false
Module=libnotedirectorywatcher
LibgnoteRelease=@LIBGNOTE_RELEASE@
diff --git a/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.cpp
b/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.cpp
index 212cc24f..6191827a 100644
--- a/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.cpp
+++ b/src/addins/notedirectorywatcher/notedirectorywatcherapplicationaddin.cpp
@@ -28,7 +28,6 @@
#include "notedirectorywatcherapplicationaddin.hpp"
#include "notedirectorywatcherpreferencesfactory.hpp"
#include "notemanager.hpp"
-#include "preferences.hpp"
#include "sharp/files.hpp"
#include "sharp/string.hpp"
@@ -62,11 +61,10 @@ void NoteDirectoryWatcherApplicationAddin::initialize()
m_signal_changed_cid = m_file_system_watcher->signal_changed()
.connect(sigc::mem_fun(*this, &NoteDirectoryWatcherApplicationAddin::handle_file_system_change_event));
- Glib::RefPtr<Gio::Settings> settings =
ignote().preferences().get_schema_settings(SCHEMA_NOTE_DIRECTORY_WATCHER);
- m_check_interval = settings->get_int(CHECK_INTERVAL);
- sanitize_check_interval(settings);
- m_signal_settings_changed_cid = settings->signal_changed()
+ m_signal_settings_changed_cid = NoteDirectoryWatcherPreferences::settings()->signal_changed(CHECK_INTERVAL)
.connect(sigc::mem_fun(*this, &NoteDirectoryWatcherApplicationAddin::on_settings_changed));
+ m_check_interval = NoteDirectoryWatcherPreferences::settings()->get_int(CHECK_INTERVAL);
+ sanitize_check_interval(NoteDirectoryWatcherPreferences::settings());
m_initialized = true;
}
@@ -295,11 +293,8 @@ Glib::ustring NoteDirectoryWatcherApplicationAddin::make_uri(const Glib::ustring
void NoteDirectoryWatcherApplicationAddin::on_settings_changed(const Glib::ustring & key)
{
- if(key == CHECK_INTERVAL) {
- Glib::RefPtr<Gio::Settings> settings =
ignote().preferences().get_schema_settings(SCHEMA_NOTE_DIRECTORY_WATCHER);
- m_check_interval = settings->get_int(key);
- sanitize_check_interval(settings);
- }
+ m_check_interval = NoteDirectoryWatcherPreferences::settings()->get_int(key);
+ sanitize_check_interval(NoteDirectoryWatcherPreferences::settings());
}
void NoteDirectoryWatcherApplicationAddin::sanitize_check_interval(const Glib::RefPtr<Gio::Settings> &
settings)
diff --git a/src/addins/notedirectorywatcher/notedirectorywatcherpreferences.cpp
b/src/addins/notedirectorywatcher/notedirectorywatcherpreferences.cpp
index 4c4fb877..90126b28 100644
--- a/src/addins/notedirectorywatcher/notedirectorywatcherpreferences.cpp
+++ b/src/addins/notedirectorywatcher/notedirectorywatcherpreferences.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2014,2019 Aurimas Cernius
+ * Copyright (C) 2014,2019-2020 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
@@ -21,17 +21,27 @@
#include <glibmm/i18n.h>
#include "notedirectorywatcherpreferences.hpp"
-#include "preferences.hpp"
+
namespace notedirectorywatcher {
const char *SCHEMA_NOTE_DIRECTORY_WATCHER = "org.gnome.gnote.note-directory-watcher";
const char *CHECK_INTERVAL = "check-interval";
+Glib::RefPtr<Gio::Settings> NoteDirectoryWatcherPreferences::s_settings;
+
+
+Glib::RefPtr<Gio::Settings> & NoteDirectoryWatcherPreferences::settings()
+{
+ if(!s_settings) {
+ s_settings = Gio::Settings::create(SCHEMA_NOTE_DIRECTORY_WATCHER);
+ }
+
+ return s_settings;
+}
-NoteDirectoryWatcherPreferences::NoteDirectoryWatcherPreferences(gnote::IGnote &, gnote::Preferences &
preferences, gnote::NoteManager &)
+NoteDirectoryWatcherPreferences::NoteDirectoryWatcherPreferences(gnote::IGnote &, gnote::Preferences &,
gnote::NoteManager &)
: m_check_interval(1)
- , m_preferences(preferences)
{
Gtk::Label *label = manage(new Gtk::Label(_("_Directory check interval:"), true));
attach(*label, 0, 0, 1, 1);
@@ -39,14 +49,13 @@ NoteDirectoryWatcherPreferences::NoteDirectoryWatcherPreferences(gnote::IGnote &
m_check_interval.set_increments(1, 5);
m_check_interval.signal_value_changed()
.connect(sigc::mem_fun(*this, &NoteDirectoryWatcherPreferences::on_interval_changed));
-
m_check_interval.set_value(preferences.get_schema_settings(SCHEMA_NOTE_DIRECTORY_WATCHER)->get_int(CHECK_INTERVAL));
+ m_check_interval.set_value(settings()->get_int(CHECK_INTERVAL));
attach(m_check_interval, 1, 0, 1, 1);
}
void NoteDirectoryWatcherPreferences::on_interval_changed()
{
- m_preferences.get_schema_settings(SCHEMA_NOTE_DIRECTORY_WATCHER)->set_int(
- CHECK_INTERVAL, m_check_interval.get_value_as_int());
+ settings()->set_int(CHECK_INTERVAL, m_check_interval.get_value_as_int());
}
}
diff --git a/src/addins/notedirectorywatcher/notedirectorywatcherpreferences.hpp
b/src/addins/notedirectorywatcher/notedirectorywatcherpreferences.hpp
index f0d03350..f970a423 100644
--- a/src/addins/notedirectorywatcher/notedirectorywatcherpreferences.hpp
+++ b/src/addins/notedirectorywatcher/notedirectorywatcherpreferences.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2014,2019 Aurimas Cernius
+ * Copyright (C) 2014,2019-2020 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
@@ -29,7 +29,6 @@
namespace gnote {
class IGnote;
- class Preferences;
}
namespace notedirectorywatcher {
@@ -42,12 +41,14 @@ class NoteDirectoryWatcherPreferences
: public Gtk::Grid
{
public:
+ static Glib::RefPtr<Gio::Settings> & settings();
NoteDirectoryWatcherPreferences(gnote::IGnote &, gnote::Preferences &, gnote::NoteManager &);
private:
+ static Glib::RefPtr<Gio::Settings> s_settings;
+
void on_interval_changed();
Gtk::SpinButton m_check_interval;
- gnote::Preferences & m_preferences;
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]