[gnote] Port watchers to new Preferences



commit 59e06d2978f1b8dc676c3cda23a2746bddf70efa
Author: Aurimas Äernius <aurisc4 gmail com>
Date:   Tue Jun 21 23:27:42 2011 +0300

    Port watchers to new Preferences
    
    Use new Preferences API with Gio::Settings.

 src/watchers.cpp |   34 ++++++++++++++++++----------------
 src/watchers.hpp |    5 ++---
 2 files changed, 20 insertions(+), 19 deletions(-)
---
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 5b7e165..6253a68 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -296,9 +296,11 @@ namespace gnote {
 
   void NoteSpellChecker::on_note_opened ()
   {
-    Preferences::obj().signal_setting_changed()
+    Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
+      .get_schema_settings(Preferences::SCHEMA_GNOTE);
+    settings->signal_changed()
       .connect(sigc::mem_fun(*this, &NoteSpellChecker::on_enable_spellcheck_changed));
-    if(Preferences::obj().get<bool>(Preferences::ENABLE_SPELLCHECKING)) {
+    if(settings->get_boolean(Preferences::ENABLE_SPELLCHECKING)) {
       attach ();
     }
   }
@@ -336,16 +338,15 @@ namespace gnote {
   }
   
 
-  void NoteSpellChecker::on_enable_spellcheck_changed(Preferences *, GConfEntry * entry)
+  void NoteSpellChecker::on_enable_spellcheck_changed(const Glib::ustring & key)
   {
-    const char * key = gconf_entry_get_key(entry);
-    
-    if (strcmp(key, Preferences::ENABLE_SPELLCHECKING) != 0) {
+    if (key != Preferences::ENABLE_SPELLCHECKING) {
       return;
     }
-    GConfValue *value = gconf_entry_get_value(entry);
+    bool value = Preferences::obj()
+      .get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(key);
     
-    if (gconf_value_get_bool(value)) {
+    if (value) {
       attach ();
     } 
     else {
@@ -953,26 +954,27 @@ namespace gnote {
 
   void NoteWikiWatcher::on_note_opened ()
   {
-    if ((bool) Preferences::obj().get<bool> (Preferences::ENABLE_WIKIWORDS)) {
+    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));
     }
-    Preferences::obj().signal_setting_changed()
+    settings->signal_changed()
       .connect(sigc::mem_fun(*this, &NoteWikiWatcher::on_enable_wikiwords_changed));
   }
 
 
-  void NoteWikiWatcher::on_enable_wikiwords_changed(Preferences *, GConfEntry * entry)
+  void NoteWikiWatcher::on_enable_wikiwords_changed(const Glib::ustring & key)
   {
-    const char * key = gconf_entry_get_key(entry);
-    
-    if (strcmp(key, Preferences::ENABLE_WIKIWORDS) != 0) {
+    if(key != Preferences::ENABLE_WIKIWORDS) {
       return;
     }
-    GConfValue * value = gconf_entry_get_value(entry);
-    if (gconf_value_get_bool(value)) {
+    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(
diff --git a/src/watchers.hpp b/src/watchers.hpp
index 7c019d1..b97b7b7 100644
--- a/src/watchers.hpp
+++ b/src/watchers.hpp
@@ -35,7 +35,6 @@ extern "C" {
 #include <gtkspell/gtkspell.h>
 }
 #endif
-#include <gconf/gconf-client.h>
 
 #include <gdkmm/cursor.h>
 #include <gtkmm/textiter.h>
@@ -105,7 +104,7 @@ namespace gnote {
   private:
     void attach();
     void detach();
-    void on_enable_spellcheck_changed(Preferences *, GConfEntry *);
+    void on_enable_spellcheck_changed(const Glib::ustring & key);
     void tag_applied(const Glib::RefPtr<const Gtk::TextTag> &,
                      const Gtk::TextIter &, const Gtk::TextIter &);
 
@@ -218,7 +217,7 @@ namespace gnote {
       {
       }
   private:
-    void on_enable_wikiwords_changed(Preferences *, GConfEntry *);
+    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);



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