diff --git a/demos/gtk-demo/application.c b/demos/gtk-demo/application.c index 801b728a40..779ee3d955 100644 --- a/demos/gtk-demo/application.c +++ b/demos/gtk-demo/application.c @@ -1,4 +1,3 @@ - #include "config.h" #include diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index d3f65220d0..2b1c36f611 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -244,6 +244,23 @@ fontify_text (const char *format, GBytes *stderr_buf = NULL; GError *error = NULL; char *format_arg; + GtkSettings *settings; + char *theme; + gboolean prefer_dark; + const char *style_arg; + + settings = gtk_settings_get_default (); + g_object_get (settings, + "gtk-theme-name", &theme, + "gtk-application-prefer-dark-theme", &prefer_dark, + NULL); + + if (prefer_dark || strcmp (theme, "HighContrastInverse") == 0) + style_arg = "--style=edit-vim-dark"; + else + style_arg = "--style=edit-kwrite"; + + g_free (theme); format_arg = g_strconcat ("--syntax=", format, NULL); subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | @@ -253,6 +270,7 @@ fontify_text (const char *format, "highlight", format_arg, "--out-format=pango", + style_arg, NULL); g_free (format_arg); @@ -328,8 +346,13 @@ fontify (const char *format, { char *markup; gsize len; + char *p; markup = g_bytes_unref_to_data (bytes, &len); + /* highlight puts a span with font and size around its output, + * which we don't want. + */ + for (p = markup + strlen ("20 0 0 + 1 + word + 2 + 2