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 #endif +#include + /* 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..b723537 100644 --- a/mousepad/mousepad-view.c +++ b/mousepad/mousepad-view.c @@ -25,6 +25,8 @@ #include #include +#include + /* 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 11" #define mousepad_view_get_buffer(view) (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view))) @@ -2686,8 +2688,15 @@ mousepad_view_update_font (MousepadView *view) if (use_default) { + XfconfChannel *channel = xfconf_channel_get("xsettings"); + gchar * font = xfconf_channel_get_string(channel, "/Gtk/MonospaceFontName234", 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); + 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); }