[gnote] Fix editor scroll on show



commit b3f0f8a953d2d132f344d6bbd9b0f2d40c8d962d
Author: Aurimas Ä?ernius <aurisc4 gmail com>
Date:   Fri Jun 3 22:24:16 2011 +0300

    Fix editor scroll on show
    
    Editor is scrolled incorrectly, when all these apply:
    -note window is opened,
    -entire editor fits to window,
    -there's enough text to fill most of editor,
    -cursors position is near the last line.

 src/noteeditor.cpp |    3 ---
 src/notewindow.cpp |    7 +++++++
 src/notewindow.hpp |    1 +
 3 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/noteeditor.cpp b/src/noteeditor.cpp
index 23d019b..8de3639 100644
--- a/src/noteeditor.cpp
+++ b/src/noteeditor.cpp
@@ -46,9 +46,6 @@ namespace gnote {
                                                                 &on_font_setting_changed_gconf,
                                                                 this);
 
-    // Make sure the cursor position is visible
-    scroll_to (buffer->get_insert());
-
     // Set Font from GConf preference
     if (Preferences::obj().get<bool>(Preferences::ENABLE_CUSTOM_FONT)) {
       std::string font_string = Preferences::obj().get<std::string>(Preferences::CUSTOM_FONT_FACE);
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 58f159f..ade748e 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -622,6 +622,13 @@ namespace gnote {
     Glib::RefPtr<NoteBuffer>::cast_static(m_editor->get_buffer())->change_cursor_depth_directional(false);
   }
 
+  void NoteWindow::on_show()
+  {
+    utils::ForcedPresentWindow::on_show();
+    // Make sure the cursor position is visible
+    m_editor->scroll_to (m_editor->get_buffer()->get_insert());
+  }
+
   
   NoteFindBar::NoteFindBar(Note & note)
     : Gtk::HBox(false, 0)
diff --git a/src/notewindow.hpp b/src/notewindow.hpp
index fba0985..24def7c 100644
--- a/src/notewindow.hpp
+++ b/src/notewindow.hpp
@@ -136,6 +136,7 @@ public:
 protected:
   virtual bool on_delete_event(GdkEventAny *ev);
   virtual void on_hide();
+  virtual void on_show();
 private:
   bool on_key_pressed(GdkEventKey*);
   void close_window_handler();



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