[gnote] Disable WikiWords in AddinManager



commit b871234cd57cfd7f8cda449c01fbd0f1cc1892b8
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Oct 26 20:22:51 2013 +0300

    Disable WikiWords in AddinManager

 src/addinmanager.cpp |    5 ++++-
 src/watchers.cpp     |   33 ++++-----------------------------
 src/watchers.hpp     |    3 ---
 3 files changed, 8 insertions(+), 33 deletions(-)
---
diff --git a/src/addinmanager.cpp b/src/addinmanager.cpp
index 10c922b..9eb8530 100644
--- a/src/addinmanager.cpp
+++ b/src/addinmanager.cpp
@@ -249,7 +249,9 @@ namespace gnote {
     if(settings->get_boolean(Preferences::ENABLE_AUTO_LINKS)) {
       REGISTER_BUILTIN_NOTE_ADDIN(NoteLinkWatcher);
     }
-    REGISTER_BUILTIN_NOTE_ADDIN(NoteWikiWatcher);
+    if(settings->get_boolean(Preferences::ENABLE_WIKIWORDS)) {
+      REGISTER_BUILTIN_NOTE_ADDIN(NoteWikiWatcher);
+    }
     REGISTER_BUILTIN_NOTE_ADDIN(MouseHandWatcher);
     REGISTER_BUILTIN_NOTE_ADDIN(NoteTagsWatcher);
     REGISTER_BUILTIN_NOTE_ADDIN(notebooks::NotebookNoteAddin);
@@ -514,5 +516,6 @@ namespace gnote {
   {
     SETUP_NOTE_ADDIN(key, Preferences::ENABLE_URL_LINKS, NoteUrlWatcher);
     SETUP_NOTE_ADDIN(key, Preferences::ENABLE_AUTO_LINKS, NoteLinkWatcher);
+    SETUP_NOTE_ADDIN(key, Preferences::ENABLE_WIKIWORDS, NoteWikiWatcher);
   }
 }
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 406aaf9..99f4c23 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -1056,38 +1056,13 @@ namespace gnote {
 
   void NoteWikiWatcher::on_note_opened ()
   {
-    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(
-        Preferences::SCHEMA_GNOTE);
-    if (settings->get_boolean(Preferences::ENABLE_WIKIWORDS)) {
-      m_on_insert_text_cid = get_buffer()->signal_insert().connect(
-        sigc::mem_fun(*this, &NoteWikiWatcher::on_insert_text));
-      m_on_delete_range_cid = get_buffer()->signal_erase().connect(
-        sigc::mem_fun(*this, &NoteWikiWatcher::on_delete_range));
-    }
-    settings->signal_changed()
-      .connect(sigc::mem_fun(*this, &NoteWikiWatcher::on_enable_wikiwords_changed));
+    get_buffer()->signal_insert().connect(
+      sigc::mem_fun(*this, &NoteWikiWatcher::on_insert_text));
+    get_buffer()->signal_erase().connect(
+      sigc::mem_fun(*this, &NoteWikiWatcher::on_delete_range));
   }
 
 
-  void NoteWikiWatcher::on_enable_wikiwords_changed(const Glib::ustring & key)
-  {
-    if(key != Preferences::ENABLE_WIKIWORDS) {
-      return;
-    }
-    bool value = Preferences::obj().get_schema_settings(
-        Preferences::SCHEMA_GNOTE)->get_boolean(key);
-    if (value) {
-      m_on_insert_text_cid = get_buffer()->signal_insert().connect(
-        sigc::mem_fun(*this, &NoteWikiWatcher::on_insert_text));
-      m_on_delete_range_cid = get_buffer()->signal_erase().connect(
-        sigc::mem_fun(*this, &NoteWikiWatcher::on_delete_range));
-    } 
-    else {
-      m_on_insert_text_cid.disconnect();
-      m_on_delete_range_cid.disconnect();
-    }
-  }
-
   void NoteWikiWatcher::apply_wikiword_to_block (Gtk::TextIter start, Gtk::TextIter end)
   {
     NoteBuffer::get_block_extents (start,
diff --git a/src/watchers.hpp b/src/watchers.hpp
index 24676c2..e276680 100644
--- a/src/watchers.hpp
+++ b/src/watchers.hpp
@@ -227,7 +227,6 @@ namespace gnote {
       {
       }
   private:
-    void on_enable_wikiwords_changed(const Glib::ustring & key);
     void apply_wikiword_to_block (Gtk::TextIter start, Gtk::TextIter end);
     void on_delete_range(const Gtk::TextIter &,const Gtk::TextIter &);
     void on_insert_text(const Gtk::TextIter &, const Glib::ustring &, int);
@@ -236,8 +235,6 @@ namespace gnote {
     static const char * WIKIWORD_REGEX;
     Glib::RefPtr<Gtk::TextTag>   m_broken_link_tag;
     Glib::RefPtr<Glib::Regex>    m_regex;
-    sigc::connection    m_on_insert_text_cid;
-    sigc::connection    m_on_delete_range_cid;
   };
 
 


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