[gnote] Use note_rename_behavior utilities
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Use note_rename_behavior utilities
- Date: Sat, 19 Dec 2020 14:06:21 +0000 (UTC)
commit 6be913f14f20fb24ea4706d527ec25252c696d55
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Dec 19 14:00:02 2020 +0200
Use note_rename_behavior utilities
src/note.cpp | 7 ++-----
src/preferencesdialog.cpp | 34 +++++++++++++---------------------
src/preferencesdialog.hpp | 2 +-
3 files changed, 16 insertions(+), 27 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index b06990a4..a718c6da 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -536,9 +536,7 @@ namespace gnote {
const Note::Ptr self = std::static_pointer_cast<Note>(shared_from_this());
if (!linking_notes.empty()) {
- Glib::RefPtr<Gio::Settings> settings =
m_gnote.preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
- const NoteRenameBehavior behavior
- = static_cast<NoteRenameBehavior>(settings->get_int(Preferences::NOTE_RENAME_BEHAVIOR));
+ const NoteRenameBehavior behavior =
static_cast<NoteRenameBehavior>(m_gnote.preferences().note_rename_behavior());
if (NOTE_RENAME_ALWAYS_SHOW_DIALOG == behavior) {
NoteRenameDialog *dlg = new NoteRenameDialog(linking_notes, old_title, self, m_gnote);
@@ -574,8 +572,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 =
m_gnote.preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
- settings->set_int(Preferences::NOTE_RENAME_BEHAVIOR, selected_behavior);
+ m_gnote.preferences().note_rename_behavior(selected_behavior);
}
const NoteRenameDialog::MapPtr notes = dlg->get_notes();
diff --git a/src/preferencesdialog.cpp b/src/preferencesdialog.cpp
index 5bf88485..7af8aa9b 100644
--- a/src/preferencesdialog.cpp
+++ b/src/preferencesdialog.cpp
@@ -167,9 +167,8 @@ namespace gnote {
add_action_widget (*button, Gtk::RESPONSE_CLOSE);
set_default_response(Gtk::RESPONSE_CLOSE);
- m_gnote.preferences().get_schema_settings(
- Preferences::SCHEMA_GNOTE)->signal_changed().connect(
- sigc::mem_fun(*this, &PreferencesDialog::on_preferences_setting_changed));
+ m_gnote.preferences().signal_note_rename_behavior_changed.connect(
+ sigc::mem_fun(*this, &PreferencesDialog::on_note_rename_behavior_changed));
m_gnote.preferences().signal_sync_autosync_timeout_changed
.connect(sigc::mem_fun(*this, &PreferencesDialog::on_autosync_timeout_setting_changed));
}
@@ -241,7 +240,6 @@ namespace gnote {
Gtk::Label *label;
Gtk::CheckButton *check;
sharp::PropertyEditorBool *peditor, *font_peditor,* bullet_peditor;
- Glib::RefPtr<Gio::Settings> settings =
m_gnote.preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
Gtk::Grid *options_list = manage(new Gtk::Grid);
options_list->set_row_spacing(12);
@@ -308,10 +306,10 @@ namespace gnote {
m_rename_behavior_combo->append(_("Ask me what to do"));
m_rename_behavior_combo->append(_("Never rename links"));
m_rename_behavior_combo->append(_("Always rename links"));
- int rename_behavior = settings->get_int(Preferences::NOTE_RENAME_BEHAVIOR);
+ int rename_behavior = m_gnote.preferences().note_rename_behavior();
if (0 > rename_behavior || 2 < rename_behavior) {
rename_behavior = 0;
- settings->set_int(Preferences::NOTE_RENAME_BEHAVIOR, rename_behavior);
+ m_gnote.preferences().note_rename_behavior(rename_behavior);
}
m_rename_behavior_combo->set_active(rename_behavior);
m_rename_behavior_combo->signal_changed().connect(
@@ -983,20 +981,15 @@ namespace gnote {
- void PreferencesDialog::on_preferences_setting_changed(const Glib::ustring & key)
+ void PreferencesDialog::on_note_rename_behavior_changed()
{
- if (key == Preferences::NOTE_RENAME_BEHAVIOR) {
- Glib::RefPtr<Gio::Settings> settings = m_gnote.preferences()
- .get_schema_settings(Preferences::SCHEMA_GNOTE);
- int rename_behavior = settings->get_int(key);
- if (0 > rename_behavior || 2 < rename_behavior) {
- rename_behavior = 0;
- settings->set_int(Preferences::NOTE_RENAME_BEHAVIOR, rename_behavior);
- }
- if (m_rename_behavior_combo->get_active_row_number()
- != rename_behavior) {
- m_rename_behavior_combo->set_active(rename_behavior);
- }
+ int rename_behavior = m_gnote.preferences().note_rename_behavior();
+ if(0 > rename_behavior || 2 < rename_behavior) {
+ rename_behavior = 0;
+ m_gnote.preferences().note_rename_behavior(rename_behavior);
+ }
+ if(m_rename_behavior_combo->get_active_row_number() != rename_behavior) {
+ m_rename_behavior_combo->set_active(rename_behavior);
}
}
@@ -1023,8 +1016,7 @@ namespace gnote {
void PreferencesDialog::on_rename_behavior_changed()
{
- m_gnote.preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->set_int(
- Preferences::NOTE_RENAME_BEHAVIOR, m_rename_behavior_combo->get_active_row_number());
+ m_gnote.preferences().note_rename_behavior(m_rename_behavior_combo->get_active_row_number());
}
diff --git a/src/preferencesdialog.hpp b/src/preferencesdialog.hpp
index ed323acb..d792b979 100644
--- a/src/preferencesdialog.hpp
+++ b/src/preferencesdialog.hpp
@@ -73,7 +73,7 @@ private:
void on_save_sync_addin_button();
void on_sync_settings_saved(bool saved, Glib::ustring errorMsg);
- void on_preferences_setting_changed(const Glib::ustring & key);
+ void on_note_rename_behavior_changed();
void on_autosync_timeout_setting_changed();
void on_rename_behavior_changed();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]