[gnote] Add new_note method to main window



commit 23463ebce01c32c1a7868bda90782fcafa2c1151
Author: Aurimas Äernius <aurisc4 gmail com>
Date:   Sat Oct 13 21:39:08 2012 +0300

    Add new_note method to main window

 src/recentchanges.cpp |   14 ++++++++++++++
 src/recentchanges.hpp |    2 ++
 2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 988cc6a..0683576 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -40,6 +40,7 @@ namespace gnote {
 
   NoteRecentChanges::NoteRecentChanges(NoteManager& m)
     : NoteRecentChangesParent(_("Notes"))
+    , m_note_manager(m)
     , m_search_notes_widget(m)
     , m_content_vbox(false, 0)
   {
@@ -94,6 +95,19 @@ namespace gnote {
   }
 
 
+  void NoteRecentChanges::new_note()
+  {
+    std::vector<Gtk::Widget*> current = m_embed_box.get_children();
+    SearchNotesWidget *search_wgt = dynamic_cast<SearchNotesWidget*>(current.size() > 0 ? current[0] : NULL);
+    if(search_wgt) {
+      search_wgt->new_note();
+    }
+    else {
+      present_note(m_note_manager.create());
+    }
+  }
+
+
   NoteRecentChanges::Ptr NoteRecentChanges::get_owning(Gtk::Widget & widget)
   {
     Ptr owner;
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index 2d5e52b..f238311 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -57,6 +57,7 @@ public:
   virtual ~NoteRecentChanges();
   void set_search_text(const std::string & value);
   void present_note(const Note::Ptr & note);
+  void new_note();
 
   virtual void embed_widget(utils::EmbedableWidget &);
   virtual void unembed_widget(utils::EmbedableWidget &);
@@ -75,6 +76,7 @@ private:
   bool is_foreground(utils::EmbedableWidget &);
   void on_embeded_widget_menu_item_toggled(utils::EmbedableWidget *);
 
+  NoteManager        &m_note_manager;
   SearchNotesWidget   m_search_notes_widget;
   Gtk::VBox           m_content_vbox;
   Gtk::VBox           m_embed_box;



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