[gnote] Make NoteWindow provide gears menu



commit d2286f0ae16579bf41c6928838059a87dd587002
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Fri May 31 22:28:39 2013 +0300

    Make NoteWindow provide gears menu

 src/notewindow.cpp |   37 +++++++++++++++++++++++++++++++++++++
 src/notewindow.hpp |    9 +++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 0cdfefa..3f5c62a 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -269,6 +269,43 @@ namespace gnote {
     return m_embeddable_toolbar;
   }
 
+  std::vector<Glib::RefPtr<Gtk::Action> > NoteWindow::get_widget_actions()
+  {
+    std::vector<Glib::RefPtr<Gtk::Action> > res;
+    for(std::map<int, Glib::RefPtr<Gtk::Action> >::iterator iter = m_widget_actions.begin();
+        iter != m_widget_actions.end(); ++iter) {
+      res.push_back(iter->second);
+    }
+    return res;
+  }
+
+  sigc::signal<void> & NoteWindow::signal_actions_changed()
+  {
+    return m_signal_actions_changed;
+  }
+
+  void NoteWindow::add_widget_action(const Glib::RefPtr<Gtk::Action> & action, int order)
+  {
+    std::map<int, Glib::RefPtr<Gtk::Action> >::iterator iter = m_widget_actions.find(order);
+    while(iter != m_widget_actions.end()) {
+      iter = m_widget_actions.find(++order);
+    }
+    m_widget_actions[order] = action;
+    m_signal_actions_changed();
+  }
+
+  void NoteWindow::remove_widget_action(const std::string & name)
+  {
+    for(std::map<int, Glib::RefPtr<Gtk::Action> >::iterator iter = m_widget_actions.begin();
+        iter != m_widget_actions.end(); ++iter) {
+      if(iter->second->get_name() == name) {
+        m_widget_actions.erase(iter);
+        break;
+      }
+    }
+    m_signal_actions_changed();
+  }
+
 
     // Delete this Note.
     //
diff --git a/src/notewindow.hpp b/src/notewindow.hpp
index 9cb75a4..240b6a6 100644
--- a/src/notewindow.hpp
+++ b/src/notewindow.hpp
@@ -133,6 +133,7 @@ class NoteWindow
   , public EmbeddableWidget
   , public SearchableItem
   , public HasEmbeddableToolbar
+  , public HasActions
 {
 public:
   NoteWindow(Note &);
@@ -154,6 +155,11 @@ public:
   // use co-variant return
   virtual Gtk::Grid *embeddable_toolbar();
 
+  virtual std::vector<Glib::RefPtr<Gtk::Action> > get_widget_actions();
+  virtual sigc::signal<void> & signal_actions_changed();
+  void add_widget_action(const Glib::RefPtr<Gtk::Action> & action, int order);
+  void remove_widget_action(const std::string & name);
+
   void set_size(int width, int height)
     {
       m_width = width;
@@ -239,6 +245,9 @@ private:
   utils::GlobalKeybinder       *m_global_keys;
   utils::InterruptableTimeout  *m_mark_set_timeout;
 
+  std::map<int, Glib::RefPtr<Gtk::Action> > m_widget_actions;
+  sigc::signal<void> m_signal_actions_changed;
+
   Tag::Ptr m_template_tag;
   Tag::Ptr m_template_save_size_tag;
   Tag::Ptr m_template_save_selection_tag;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]