[gnote] Fix main window losing size



commit 4c8a8edb811c4cf287ba1d79a7fd6248d5a2279f
Author: Aurimas Äernius <aurisc4 gmail com>
Date:   Sun Oct 21 22:44:10 2012 +0300

    Fix main window losing size
    
    * Add running() to host, to indicate it's size can be queried
    * Only save main window size if host is running

 src/recentchanges.cpp     |    8 ++++++++
 src/recentchanges.hpp     |    6 ++++++
 src/searchnoteswidget.cpp |    6 +++++-
 src/utils.hpp             |    1 +
 4 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 34e756a..01065f1 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -43,6 +43,7 @@ namespace gnote {
     , m_note_manager(m)
     , m_search_notes_widget(m)
     , m_content_vbox(false, 0)
+    , m_mapped(false)
   {
     set_default_size(450,400);
     set_resizable(true);
@@ -337,5 +338,12 @@ namespace gnote {
     return children.size() ? dynamic_cast<utils::EmbedableWidget*>(children[0]) : NULL;
   }
 
+  bool NoteRecentChanges::on_map_event(GdkEventAny *evt)
+  {
+    bool res = NoteRecentChangesParent::on_map_event(evt);
+    m_mapped = true;
+    return res;
+  }
+
 }
 
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index d957038..2d74e4b 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -62,9 +62,14 @@ public:
   virtual void unembed_widget(utils::EmbedableWidget &);
   virtual void foreground_embeded(utils::EmbedableWidget &);
   virtual void background_embeded(utils::EmbedableWidget &);
+  virtual bool running()
+    {
+      return m_mapped;
+    }
 protected:
   NoteRecentChanges(NoteManager& m);
   virtual void on_show();
+  virtual bool on_map_event(GdkEventAny *evt);
 private:
   void on_open_note(const Note::Ptr &);
   void on_open_note_new_window(const Note::Ptr &);
@@ -84,6 +89,7 @@ private:
   std::list<utils::EmbedableWidget*> m_embeded_widgets;
   Gtk::Menu          *m_menu;
   Gtk::RadioMenuItem::Group m_tool_menu_group;
+  bool                m_mapped;
 };
 
 
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 4167faf..8a5e379 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -436,7 +436,11 @@ void SearchNotesWidget::save_position()
   int width;
   int height;
 
-  Gtk::Window *window = get_owning_window();
+  utils::EmbedableWidgetHost *current_host = host();
+  if(!current_host || !current_host->running()) {
+    return;
+  }
+  Gtk::Window *window = dynamic_cast<Gtk::Window*>(current_host);
   if(!window) {
     return;
   }
diff --git a/src/utils.hpp b/src/utils.hpp
index ede4244..0ef8567 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -251,6 +251,7 @@ namespace gnote {
       virtual void unembed_widget(EmbedableWidget &) = 0;
       virtual void foreground_embeded(EmbedableWidget &) = 0;
       virtual void background_embeded(EmbedableWidget &) = 0;
+      virtual bool running() = 0;
     };
 
     class EmbedableWidget



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