[gnote] Add support for main window actions
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add support for main window actions
- Date: Sun, 24 Feb 2013 17:00:06 +0000 (UTC)
commit a776af3f48c45af3b3f7318ee4ccb6e98c02c58c
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Feb 24 18:52:15 2013 +0200
Add support for main window actions
Ability to add actions for main window search and note modes.
Intended to provide plugins ability to extend main window functionality.
src/actionmanager.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++
src/actionmanager.hpp | 12 ++++++++
src/iactionmanager.hpp | 9 ++++++
3 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index fd8fd08..d68b8e6 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -312,4 +312,71 @@ namespace gnote {
return section;
}
+ void ActionManager::add_main_window_search_action(const Glib::RefPtr<Gtk::Action> & action, int order)
+ {
+ add_main_window_action(m_main_window_search_actions, action, order);
+ signal_main_window_search_actions_changed();
+ }
+
+ void ActionManager::remove_main_window_search_action(const std::string & name)
+ {
+ remove_main_window_action(m_main_window_search_actions, name);
+ signal_main_window_search_actions_changed();
+ }
+
+ std::vector<Glib::RefPtr<Gtk::Action> > ActionManager::get_main_window_search_actions()
+ {
+ return get_main_window_actions(m_main_window_search_actions);
+ }
+
+ void ActionManager::add_main_window_note_action(const Glib::RefPtr<Gtk::Action> & action, int order)
+ {
+ add_main_window_action(m_main_window_note_actions, action, order);
+ signal_main_window_note_actions_changed();
+ }
+
+ void ActionManager::remove_main_window_note_action(const std::string & name)
+ {
+ remove_main_window_action(m_main_window_note_actions, name);
+ signal_main_window_note_actions_changed();
+ }
+
+ std::vector<Glib::RefPtr<Gtk::Action> > ActionManager::get_main_window_note_actions()
+ {
+ return get_main_window_actions(m_main_window_note_actions);
+ }
+
+ void ActionManager::add_main_window_action(std::map<int, Glib::RefPtr<Gtk::Action> > & actions,
+ const Glib::RefPtr<Gtk::Action> & action, int order)
+ {
+ std::map<int, Glib::RefPtr<Gtk::Action> >::iterator iter = actions.find(order);
+ while(iter != actions.end()) {
+ iter = actions.find(++order);
+ }
+ actions[order] = action;
+ }
+
+ void ActionManager::remove_main_window_action(std::map<int, Glib::RefPtr<Gtk::Action> > & actions,
+ const std::string & name)
+ {
+ for(std::map<int, Glib::RefPtr<Gtk::Action> >::iterator iter = actions.begin();
+ iter != actions.end(); ++iter) {
+ if(iter->second->get_name() == name) {
+ actions.erase(iter);
+ break;
+ }
+ }
+ }
+
+ std::vector<Glib::RefPtr<Gtk::Action> > ActionManager::get_main_window_actions(
+ std::map<int, Glib::RefPtr<Gtk::Action> > & actions)
+ {
+ std::vector<Glib::RefPtr<Gtk::Action> > res;
+ for(std::map<int, Glib::RefPtr<Gtk::Action> >::iterator iter = actions.begin();
+ iter != actions.end(); ++iter) {
+ res.push_back(iter->second);
+ }
+ return res;
+ }
+
}
diff --git a/src/actionmanager.hpp b/src/actionmanager.hpp
index de35e14..8bf3048 100644
--- a/src/actionmanager.hpp
+++ b/src/actionmanager.hpp
@@ -67,10 +67,20 @@ public:
virtual void add_app_menu_item(int section, int order, const std::string & label,
const std::string & action_def);
Glib::RefPtr<Gio::Menu> get_app_menu() const;
+ virtual void add_main_window_search_action(const Glib::RefPtr<Gtk::Action> & action, int order);
+ virtual void remove_main_window_search_action(const std::string & name);
+ virtual std::vector<Glib::RefPtr<Gtk::Action> > get_main_window_search_actions();
+ virtual void add_main_window_note_action(const Glib::RefPtr<Gtk::Action> & action, int order);
+ virtual void remove_main_window_note_action(const std::string & name);
+ virtual std::vector<Glib::RefPtr<Gtk::Action> > get_main_window_note_actions();
private:
void make_app_actions();
void make_app_menu_items();
Glib::RefPtr<Gio::Menu> make_app_menu_section(int section) const;
+ void add_main_window_action(std::map<int, Glib::RefPtr<Gtk::Action> > & actions,
+ const Glib::RefPtr<Gtk::Action> & action, int order);
+ void remove_main_window_action(std::map<int, Glib::RefPtr<Gtk::Action> > & actions, const std::string &
name);
+ std::vector<Glib::RefPtr<Gtk::Action> > get_main_window_actions(std::map<int, Glib::RefPtr<Gtk::Action> >
& actions);
Glib::RefPtr<Gtk::UIManager> m_ui;
Glib::RefPtr<Gtk::ActionGroup> m_main_window_actions;
@@ -99,6 +109,8 @@ private:
};
typedef std::multimap<int, AppMenuItem> AppMenuItemMultiMap;
AppMenuItemMultiMap m_app_menu_items;
+ std::map<int, Glib::RefPtr<Gtk::Action> > m_main_window_search_actions;
+ std::map<int, Glib::RefPtr<Gtk::Action> > m_main_window_note_actions;
};
diff --git a/src/iactionmanager.hpp b/src/iactionmanager.hpp
index 772b3bd..73c1d5f 100644
--- a/src/iactionmanager.hpp
+++ b/src/iactionmanager.hpp
@@ -46,8 +46,17 @@ public:
virtual Glib::RefPtr<Gio::SimpleAction> add_app_action(const std::string & name) = 0;
virtual void add_app_menu_item(int section, int order, const std::string & label,
const std::string & action_def) = 0;
+ virtual void add_main_window_search_action(const Glib::RefPtr<Gtk::Action> & action, int order) = 0;
+ virtual void remove_main_window_search_action(const std::string & name) = 0;
+ virtual std::vector<Glib::RefPtr<Gtk::Action> > get_main_window_search_actions() = 0;
+ virtual void add_main_window_note_action(const Glib::RefPtr<Gtk::Action> & action, int order) = 0;
+ virtual void remove_main_window_note_action(const std::string & name) = 0;
+ virtual std::vector<Glib::RefPtr<Gtk::Action> > get_main_window_note_actions() = 0;
virtual const Glib::RefPtr<Gtk::UIManager> & get_ui() = 0;
virtual Gtk::Widget * get_widget(const std::string &n) const = 0;
+
+ sigc::signal<void> signal_main_window_search_actions_changed;
+ sigc::signal<void> signal_main_window_note_actions_changed;
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]