[gnote] Set custom font using Gtk::Settings
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Set custom font using Gtk::Settings
- Date: Tue, 11 May 2021 20:04:30 +0000 (UTC)
commit 4a5abcb81125ac0d5f7f5d70b8df4241ca532c37
Author: Aurimas Černius <aurisc4 gmail com>
Date: Tue May 11 22:56:59 2021 +0300
Set custom font using Gtk::Settings
src/noteeditor.cpp | 27 ++++++---------------------
src/noteeditor.hpp | 3 +--
2 files changed, 7 insertions(+), 23 deletions(-)
---
diff --git a/src/noteeditor.cpp b/src/noteeditor.cpp
index 05e327dd..b1159004 100644
--- a/src/noteeditor.cpp
+++ b/src/noteeditor.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2013,2016-2017,2019-2020 Aurimas Cernius
+ * Copyright (C) 2010-2013,2016-2017,2019-2021 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -21,6 +21,8 @@
#include <string.h>
+#include <gtkmm/settings.h>
+
#include "notebuffer.hpp"
#include "noteeditor.hpp"
#include "preferences.hpp"
@@ -49,15 +51,11 @@ namespace gnote {
// query all monitored settings to get change notifications
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
if(enable_custom_font) {
modify_font_from_string(font_string);
}
- else {
- override_font(gnome_font);
- }
// Set extra editor drag targets supported (in addition
// to the default TextView's various text formats)...
@@ -75,23 +73,10 @@ namespace gnote {
}
- Pango::FontDescription NoteEditor::get_gnome_document_font_description()
- {
- try {
- auto doc_font_string = m_preferences.desktop_gnome_font();
- return Pango::FontDescription(doc_font_string);
- }
- catch (...) {
- }
-
- return Pango::FontDescription();
- }
-
-
void NoteEditor::on_gnome_font_setting_changed()
{
if(!m_preferences.enable_custom_font()) {
- override_font(get_gnome_document_font_description());
+ Gtk::Settings::get_default()->reset_property("gtk-font-name");
}
}
@@ -105,7 +90,7 @@ namespace gnote {
}
else {
DBG_OUT("Switching back to the default font");
- override_font (get_gnome_document_font_description());
+ Gtk::Settings::get_default()->reset_property("gtk-font-name");
}
}
@@ -113,7 +98,7 @@ namespace gnote {
void NoteEditor::modify_font_from_string (const Glib::ustring & fontString)
{
DBG_OUT("Switching note font to '%s'...", fontString.c_str());
- override_font (Pango::FontDescription(fontString));
+ Gtk::Settings::get_default()->property_gtk_font_name() = fontString;
}
diff --git a/src/noteeditor.hpp b/src/noteeditor.hpp
index bef32dd0..03483e2c 100644
--- a/src/noteeditor.hpp
+++ b/src/noteeditor.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011,2013,2016-2017,2019-2020 Aurimas Cernius
+ * Copyright (C) 2011,2013,2016-2017,2019-2021 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -61,7 +61,6 @@ private:
static void paste_started(GtkTextView*, NoteEditor *_this);
static void paste_ended(GtkTextView*, NoteEditor *_this);
- Pango::FontDescription get_gnome_document_font_description();
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]