[gnote] Use open_notes_in_new_window utils
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Use open_notes_in_new_window utils
- Date: Sat, 19 Dec 2020 14:06:22 +0000 (UTC)
commit 10aae2a3ce153087f6759a34f51c37d0a4d68795
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Dec 19 15:18:00 2020 +0200
Use open_notes_in_new_window utils
src/mainwindow.cpp | 3 +--
src/recentchanges.cpp | 12 +-----------
src/recentchanges.hpp | 2 --
src/searchnoteswidget.cpp | 16 ++++++----------
src/searchnoteswidget.hpp | 2 +-
5 files changed, 9 insertions(+), 26 deletions(-)
---
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b25bbad1..1e55f44e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -87,8 +87,7 @@ MainWindow *MainWindow::present_default(IGnote & g, const Note::Ptr & note)
if(win) {
return win;
}
- Glib::RefPtr<Gio::Settings> settings = g.preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
- if(false == settings->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW)) {
+ if(false == g.preferences().open_notes_in_new_window()) {
if (note->has_window()) {
win = dynamic_cast<MainWindow*>(note->get_window()->host());
}
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index e849b7c4..6d9a55ae 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -62,13 +62,11 @@ namespace gnote {
, m_keybinder(get_accel_group())
{
Glib::RefPtr<Gio::Settings> settings = g.preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
- m_open_notes_in_new_window = settings->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
set_default_size(450,400);
set_resizable(true);
if(settings->get_boolean(Preferences::MAIN_WINDOW_MAXIMIZED)) {
maximize();
}
- settings->signal_changed().connect(sigc::mem_fun(*this, &NoteRecentChanges::on_settings_changed));
set_has_resize_grip(true);
set_icon_name(IconManager::GNOTE);
@@ -361,7 +359,7 @@ namespace gnote {
void NoteRecentChanges::on_open_note(const Note::Ptr & note)
{
- if(m_open_notes_in_new_window) {
+ if(m_preferences.open_notes_in_new_window()) {
on_open_note_new_window(note);
}
else {
@@ -829,14 +827,6 @@ namespace gnote {
}
}
- void NoteRecentChanges::on_settings_changed(const Glib::ustring & key)
- {
- if(key == Preferences::OPEN_NOTES_IN_NEW_WINDOW) {
- m_open_notes_in_new_window = m_preferences.get_schema_settings(
- Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
- }
- }
-
bool NoteRecentChanges::on_notes_widget_key_press(GdkEventKey *evt)
{
switch(evt->keyval) {
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index 51115be7..cb96f451 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -89,7 +89,6 @@ private:
void on_find_prev_button_clicked();
Gtk::PopoverMenu *make_window_menu(Gtk::Button *button, std::vector<PopoverWidget> && items);
void on_embedded_name_changed(const Glib::ustring & name);
- void on_settings_changed(const Glib::ustring & key);
bool on_notes_widget_key_press(GdkEventKey*);
void on_close_window(const Glib::VariantBase&);
void add_action(const MainWindowAction::Ptr & action);
@@ -118,7 +117,6 @@ private:
Gtk::PopoverMenu *m_window_menu_embedded;
Gtk::PopoverMenu *m_window_menu_default;
utils::GlobalKeybinder m_keybinder;
- bool m_open_notes_in_new_window;
std::map<Glib::ustring, MainWindowAction::Ptr> m_actions;
};
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 332a3737..47125058 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -107,7 +107,7 @@ SearchNotesWidget::SearchNotesWidget(IGnote & g, NoteManagerBase & m)
.connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_pin_status_changed));
Glib::RefPtr<Gio::Settings> settings = g.preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
- settings->signal_changed().connect(sigc::mem_fun(*this, &SearchNotesWidget::on_settings_changed));
+ g.preferences().signal_open_notes_in_new_window_changed.connect(sigc::mem_fun(*this,
&SearchNotesWidget::on_settings_changed));
parse_sorting_setting(settings->get_string(Preferences::SEARCH_SORTING));
g.preferences().signal_desktop_gnome_clock_format_changed.connect(sigc::mem_fun(*this,
&SearchNotesWidget::update_results));
}
@@ -1266,11 +1266,9 @@ Gtk::Menu *SearchNotesWidget::get_note_list_context_menu()
{
if(!m_note_list_context_menu) {
m_note_list_context_menu = new Gtk::Menu;
- bool open_notes_in_new_window = m_gnote.preferences().get_schema_settings(
- Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
Gtk::MenuItem *item;
- if(!open_notes_in_new_window) {
+ if(!m_gnote.preferences().open_notes_in_new_window()) {
item = manage(new Gtk::MenuItem);
item->set_related_action(m_open_note_action);
item->add_accelerator("activate", m_accel_group, GDK_KEY_O, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
@@ -1431,13 +1429,11 @@ std::vector<MainWindowAction::Ptr> SearchNotesWidget::get_widget_actions()
return actions;
}
-void SearchNotesWidget::on_settings_changed(const Glib::ustring & key)
+void SearchNotesWidget::on_settings_changed()
{
- if(key == Preferences::OPEN_NOTES_IN_NEW_WINDOW) {
- if(m_note_list_context_menu) {
- delete m_note_list_context_menu;
- m_note_list_context_menu = NULL;
- }
+ if(m_note_list_context_menu) {
+ delete m_note_list_context_menu;
+ m_note_list_context_menu = NULL;
}
}
diff --git a/src/searchnoteswidget.hpp b/src/searchnoteswidget.hpp
index d58e1ebd..6437de01 100644
--- a/src/searchnoteswidget.hpp
+++ b/src/searchnoteswidget.hpp
@@ -123,7 +123,7 @@ private:
void on_open_notebook_template_note();
void on_new_notebook();
void on_delete_notebook();
- void on_settings_changed(const Glib::ustring & key);
+ void on_settings_changed();
void on_sorting_changed();
void parse_sorting_setting(const Glib::ustring & sorting);
void on_rename_notebook();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]