[gnote] Use custom font utilities in note editor



commit 5b8b1720c2e6486c2171f66d7a17cf1a1681428a
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Fri Dec 18 23:28:33 2020 +0200

    Use custom font utilities in note editor

 src/noteeditor.cpp | 22 +++++++---------------
 src/noteeditor.hpp |  1 -
 2 files changed, 7 insertions(+), 16 deletions(-)
---
diff --git a/src/noteeditor.cpp b/src/noteeditor.cpp
index 40668799..85ecd066 100644
--- a/src/noteeditor.cpp
+++ b/src/noteeditor.cpp
@@ -40,15 +40,15 @@ namespace gnote {
     set_right_margin(default_margin());
     property_can_default().set_value(true);
 
-    Glib::RefPtr<Gio::Settings> settings = m_preferences.get_schema_settings(Preferences::SCHEMA_GNOTE);
-    settings->signal_changed().connect(sigc::mem_fun(*this, &NoteEditor::on_font_setting_changed));
+    m_preferences.signal_enable_custom_font_changed.connect(sigc::mem_fun(*this, 
&NoteEditor::update_custom_font_setting));
+    m_preferences.signal_custom_font_face_changed.connect(sigc::mem_fun(*this, 
&NoteEditor::update_custom_font_setting));
     //Set up the schema to watch the default document font
     m_preferences.signal_desktop_gnome_font_changed
       .connect(sigc::mem_fun(*this, &NoteEditor::on_gnome_font_setting_changed));
 
     // query all monitored settings to get change notifications
-    bool enable_custom_font = settings->get_boolean(Preferences::ENABLE_CUSTOM_FONT);
-    auto font_string = settings->get_string(Preferences::CUSTOM_FONT_FACE);
+    bool enable_custom_font = m_preferences.enable_custom_font();
+    auto font_string = m_preferences.custom_font_face();
     auto gnome_font = get_gnome_document_font_description();
 
     // Set Font from preference
@@ -88,17 +88,9 @@ namespace gnote {
   }
 
 
-  void NoteEditor::on_font_setting_changed (const Glib::ustring & key)
-  {
-    if(key == Preferences::ENABLE_CUSTOM_FONT || key == Preferences::CUSTOM_FONT_FACE) {
-      update_custom_font_setting ();
-    }
-  }
-
-
   void NoteEditor::on_gnome_font_setting_changed()
   {
-    
if(!m_preferences.get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::ENABLE_CUSTOM_FONT))
 {
+    if(!m_preferences.enable_custom_font()) {
       override_font(get_gnome_document_font_description());
     }
   }
@@ -108,8 +100,8 @@ namespace gnote {
   {
     Glib::RefPtr<Gio::Settings> settings = m_preferences.get_schema_settings(Preferences::SCHEMA_GNOTE);
 
-    if (settings->get_boolean(Preferences::ENABLE_CUSTOM_FONT)) {
-      Glib::ustring fontString = settings->get_string(Preferences::CUSTOM_FONT_FACE);
+    if (m_preferences.enable_custom_font()) {
+      auto fontString = m_preferences.custom_font_face();
       DBG_OUT( "Switching note font to '%s'...", fontString.c_str());
       modify_font_from_string (fontString);
     } 
diff --git a/src/noteeditor.hpp b/src/noteeditor.hpp
index 2b97ffb7..bef32dd0 100644
--- a/src/noteeditor.hpp
+++ b/src/noteeditor.hpp
@@ -62,7 +62,6 @@ private:
   static void paste_ended(GtkTextView*, NoteEditor *_this);
 
   Pango::FontDescription get_gnome_document_font_description();
-  void on_font_setting_changed (const Glib::ustring & key);
   void on_gnome_font_setting_changed();
   void update_custom_font_setting();
   void modify_font_from_string (const Glib::ustring & fontString);


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