[Xfce4-commits] [apps/mousepad] 01/01: Read system font from xfconf property (Bug #12485)
noreply at xfce.org
noreply at xfce.org
Wed Aug 22 05:05:05 CEST 2018
This is an automated email from the git hooks/post-receive script.
a n d r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/mousepad.
commit 30d3b6029995ce9ee1bb05d003ca2358471add6d
Author: Anna Arad <xfce at shards.me>
Date: Wed Aug 22 00:01:08 2018 -0300
Read system font from xfconf property (Bug #12485)
---
configure.ac.in | 1 +
mousepad/Makefile.am | 4 +++-
mousepad/main.c | 14 ++++++++++++++
mousepad/mousepad-view.c | 16 ++++++++++++++--
4 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/configure.ac.in b/configure.ac.in
index 90b96f7..4591960 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -84,6 +84,7 @@ dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.30.0])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.30.0])
+XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.12.0])
dnl **********************
dnl *** GTK+ 3 support ***
diff --git a/mousepad/Makefile.am b/mousepad/Makefile.am
index 888582d..24e06aa 100644
--- a/mousepad/Makefile.am
+++ b/mousepad/Makefile.am
@@ -72,6 +72,7 @@ mousepad_CFLAGS = \
$(GTHREAD_CFLAGS) \
$(GTKSOURCEVIEW_CFLAGS) \
$(PLATFORM_CFLAGS) \
+ $(XFCONF_CFLAGS) \
-DMOUSEPAD_GSETTINGS_SCHEMA_DIR=\""$(datadir)/glib-2.0/schemas"\"
mousepad_LDFLAGS = \
@@ -82,7 +83,8 @@ mousepad_LDADD = \
$(GLIB_LIBS) \
$(GTK_LIBS) \
$(GTHREAD_LIBS) \
- $(GTKSOURCEVIEW_LIBS)
+ $(GTKSOURCEVIEW_LIBS) \
+ $(XFCONF_LIBS)
if HAVE_DBUS
mousepad_built_sources += \
diff --git a/mousepad/main.c b/mousepad/main.c
index da25e7a..47d31e9 100644
--- a/mousepad/main.c
+++ b/mousepad/main.c
@@ -24,6 +24,8 @@
#include <libintl.h>
#endif
+#include <xfconf/xfconf.h>
+
/* globals */
static gchar **filenames = NULL;
@@ -160,6 +162,15 @@ main (gint argc, gchar **argv)
/* use the Mousepad icon as default for new windows */
gtk_window_set_default_icon_name ("accessories-text-editor");
+ /* Initialize xfconf */
+ if (G_UNLIKELY (xfconf_init(&error) == FALSE))
+ {
+ g_error ("Failed to initialize xfconf");
+ g_error_free (error);
+
+ return EXIT_FAILURE;
+ }
+
/* create a new mousepad application */
application = mousepad_application_get ();
@@ -181,6 +192,9 @@ main (gint argc, gchar **argv)
/* enter the main loop */
gtk_main ();
+ /* Shutdown xfconf */
+ xfconf_shutdown();
+
#ifdef HAVE_DBUS
/* release dbus service reference */
g_object_unref (G_OBJECT (dbus_service));
diff --git a/mousepad/mousepad-view.c b/mousepad/mousepad-view.c
index bd0e37c..0ee0893 100644
--- a/mousepad/mousepad-view.c
+++ b/mousepad/mousepad-view.c
@@ -25,6 +25,8 @@
#include <gtksourceview/gtksourcestylescheme.h>
#include <gtksourceview/gtksourcestyleschememanager.h>
+#include <xfconf/xfconf.h>
+
/* GTK+ 3 removed textview->im_context which is used for multi-selection and
* nobody has re-written multi-selection feature to not use this field
* so if building with GTK3 or with GSEAL_ENABLE disable the multi-select
@@ -35,7 +37,7 @@
-#define MOUSEPAD_VIEW_DEFAULT_FONT "Monospace"
+#define MOUSEPAD_VIEW_DEFAULT_FONT "Monospace 10"
#define mousepad_view_get_buffer(view) (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)))
@@ -2686,8 +2688,18 @@ mousepad_view_update_font (MousepadView *view)
if (use_default)
{
+ XfconfChannel *channel = xfconf_channel_get ("xsettings");
+ gchar *font = xfconf_channel_get_string (channel, "/Gtk/MonospaceFontName", NULL);
PangoFontDescription *font_desc;
- font_desc = pango_font_description_from_string (MOUSEPAD_VIEW_DEFAULT_FONT);
+
+ if (G_LIKELY (font != NULL))
+ {
+ font_desc = pango_font_description_from_string (font);
+ g_free (font);
+ }
+ else
+ font_desc = pango_font_description_from_string (MOUSEPAD_VIEW_DEFAULT_FONT);
+
mousepad_view_override_font (view, font_desc);
pango_font_description_free (font_desc);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list