[gnote/gnome-3-10] Make setting enable-close-note-on-escape work



commit e39b496200245f61b24d5860afbceef675b310af
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Dec 22 00:19:23 2013 +0200

    Make setting enable-close-note-on-escape work
    
    Fixes Bug 720748.

 src/addins/backlinks/backlinkmenuitem.cpp |    4 +++-
 src/mainwindow.cpp                        |    6 +++---
 src/notebooks/notebooknewnotemenuitem.cpp |    4 +++-
 src/recentchanges.cpp                     |   14 +++++++++-----
 src/recentchanges.hpp                     |    1 +
 src/tray.cpp                              |    7 +++++--
 6 files changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/src/addins/backlinks/backlinkmenuitem.cpp b/src/addins/backlinks/backlinkmenuitem.cpp
index 6cc16aa..7a43bca 100644
--- a/src/addins/backlinks/backlinkmenuitem.cpp
+++ b/src/addins/backlinks/backlinkmenuitem.cpp
@@ -97,7 +97,9 @@ void BacklinkMenuItem::on_activate()
     return;
   }
 
-  gnote::MainWindow::present_in_new_window(m_note, true);
+  gnote::MainWindow::present_in_new_window(m_note,
+    gnote::Preferences::obj().get_schema_settings(gnote::Preferences::SCHEMA_GNOTE)->
+      get_boolean(gnote::Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE));
 }
 
 
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 4d7a188..0b8d805 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -83,13 +83,13 @@ MainWindow *MainWindow::present_default(const Note::Ptr & note)
   if(win) {
     return win;
   }
-  if(false == Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
-                Preferences::OPEN_NOTES_IN_NEW_WINDOW)) {
+  Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+  if(false == settings->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW)) {
     win = dynamic_cast<MainWindow*>(note->get_window()->host());
   }
   if(!win) {
     win = &IGnote::obj().new_main_window();
-    win->close_on_escape(true);
+    win->close_on_escape(settings->get_boolean(Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE));
   }
   win->present_note(note);
   win->present();
diff --git a/src/notebooks/notebooknewnotemenuitem.cpp b/src/notebooks/notebooknewnotemenuitem.cpp
index 2ef488a..3cebf34 100644
--- a/src/notebooks/notebooknewnotemenuitem.cpp
+++ b/src/notebooks/notebooknewnotemenuitem.cpp
@@ -54,7 +54,9 @@ namespace gnote {
       
       // Look for the template note and create a new note
       Note::Ptr note = m_notebook->create_notebook_note ();
-      MainWindow::present_in_new_window(note, true);
+      MainWindow::present_in_new_window(note,
+        Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
+          Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE));
     }
 
 
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index e6a079e..b8a6277 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -51,13 +51,13 @@ namespace gnote {
     , m_window_menu_embedded(NULL)
     , m_window_menu_default(NULL)
     , m_keybinder(get_accel_group())
-    , m_open_notes_in_new_window(Preferences::obj().get_schema_settings(
-        Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW))
   {
+    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
+    m_open_notes_in_new_window = settings->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
+    m_close_note_on_escape = settings->get_boolean(Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE);
     set_default_size(450,400);
     set_resizable(true);
     set_hide_titlebar_when_maximized(true);
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
     if(settings->get_boolean(Preferences::MAIN_WINDOW_MAXIMIZED)) {
       maximize();
     }
@@ -333,7 +333,7 @@ namespace gnote {
 
   void NoteRecentChanges::on_open_note_new_window(const Note::Ptr & note)
   {
-    present_in_new_window(note, true);
+    present_in_new_window(note, m_close_note_on_escape);
   }
 
   void NoteRecentChanges::on_delete_note()
@@ -383,7 +383,7 @@ namespace gnote {
       else if(close_on_escape()) {
         close_window();
       }
-      else {
+      else if(m_close_note_on_escape) {
         EmbeddableWidget *current_item = currently_embedded();
         if(current_item) {
           background_embedded(*current_item);
@@ -740,6 +740,10 @@ namespace gnote {
       m_open_notes_in_new_window = Preferences::obj().get_schema_settings(
         Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
     }
+    else if(key == Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE) {
+      m_close_note_on_escape = Preferences::obj().get_schema_settings(
+        Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE);
+    }
   }
 
   bool NoteRecentChanges::on_notes_widget_key_press(GdkEventKey *evt)
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index c29bf76..403ea05 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -112,6 +112,7 @@ private:
   Gtk::Menu          *m_window_menu_default;
   utils::GlobalKeybinder m_keybinder;
   bool                m_open_notes_in_new_window;
+  bool                m_close_note_on_escape;
 };
 
 
diff --git a/src/tray.cpp b/src/tray.cpp
index c32e07d..ed373fa 100644
--- a/src/tray.cpp
+++ b/src/tray.cpp
@@ -95,7 +95,9 @@ namespace gnote {
   {
     if(!m_inhibit_activate) {
       if(m_note) {
-        MainWindow::present_in_new_window(m_note, true);
+        MainWindow::present_in_new_window(m_note,
+          Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
+            Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE));
       }
     }
   }
@@ -363,7 +365,8 @@ namespace gnote {
     MainWindow &win = IGnote::obj().new_main_window();
     win.new_note();
     win.present();
-    win.close_on_escape(true);
+    win.close_on_escape(Preferences::obj().get_schema_settings(
+      Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE));
   }
 
   void Tray::on_search_notes_activate()


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