[gnote/tabbed: 17/19] Refactor action registering to separate method
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote/tabbed: 17/19] Refactor action registering to separate method
- Date: Tue, 2 Nov 2021 14:34:34 +0000 (UTC)
commit 99a50f4b631a046b245f4e68f8a252d5145e7d8e
Author: Aurimas Černius <aurisc4 gmail com>
Date: Tue Nov 2 14:03:15 2021 +0200
Refactor action registering to separate method
src/recentchanges.cpp | 51 ++++++++++++++++++++++++++++-----------------------
src/recentchanges.hpp | 1 +
2 files changed, 29 insertions(+), 23 deletions(-)
---
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 70dbc566..94f91a5f 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -115,29 +115,7 @@ namespace gnote {
set_title(_("Gnote"));
set_icon_name(IconManager::GNOTE);
-
- std::map<Glib::ustring, const Glib::VariantType*> actions = g.action_manager().get_main_window_actions();
- for(std::map<Glib::ustring, const Glib::VariantType*>::iterator iter = actions.begin();
- iter != actions.end(); ++iter) {
- MainWindowAction::Ptr action;
- if(iter->second == NULL) {
- add_action(action = MainWindowAction::create(iter->first));
- }
- else if(iter->second == &Glib::Variant<bool>::variant_type()) {
- add_action(action = MainWindowAction::create(iter->first, false));
- }
- else if(iter->second == &Glib::Variant<gint32>::variant_type()) {
- add_action(action = MainWindowAction::create(iter->first, 0));
- }
- else if(iter->second == &Glib::Variant<Glib::ustring>::variant_type()) {
- add_action(action = MainWindowAction::create(iter->first, Glib::ustring("")));
- }
- if(action) {
- action->is_modifying(g.action_manager().is_modifying_main_window_action(iter->first));
- }
- }
- find_action("close-window")->signal_activate()
- .connect(sigc::mem_fun(*this, &NoteRecentChanges::on_close_window));
+ register_actions();
m_search_notes_widget = new SearchNotesWidget(g, m);
m_search_notes_widget->signal_open_note
@@ -200,6 +178,33 @@ namespace gnote {
delete m_search_notes_widget;
}
+ void NoteRecentChanges::register_actions()
+ {
+ auto & am = m_gnote.action_manager();
+ std::map<Glib::ustring, const Glib::VariantType*> actions = am.get_main_window_actions();
+ for(std::map<Glib::ustring, const Glib::VariantType*>::iterator iter = actions.begin();
+ iter != actions.end(); ++iter) {
+ MainWindowAction::Ptr action;
+ if(iter->second == NULL) {
+ add_action(action = MainWindowAction::create(iter->first));
+ }
+ else if(iter->second == &Glib::Variant<bool>::variant_type()) {
+ add_action(action = MainWindowAction::create(iter->first, false));
+ }
+ else if(iter->second == &Glib::Variant<gint32>::variant_type()) {
+ add_action(action = MainWindowAction::create(iter->first, 0));
+ }
+ else if(iter->second == &Glib::Variant<Glib::ustring>::variant_type()) {
+ add_action(action = MainWindowAction::create(iter->first, Glib::ustring("")));
+ }
+ if(action) {
+ action->is_modifying(am.is_modifying_main_window_action(iter->first));
+ }
+ }
+ find_action("close-window")->signal_activate()
+ .connect(sigc::mem_fun(*this, &NoteRecentChanges::on_close_window));
+ }
+
void NoteRecentChanges::make_header_bar()
{
Gtk::Grid *left_box = manage(new Gtk::Grid);
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index f92c8d67..8f1daf10 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -101,6 +101,7 @@ private:
void add_action(const MainWindowAction::Ptr & action);
void on_popover_widgets_changed();
bool present_active(const Note::Ptr & note);
+ void register_actions();
IGnote &m_gnote;
NoteManagerBase &m_note_manager;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]