[gtk/demo-polish: 4/5] gtk-demo: Adapt hightlighting style for dark themes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/demo-polish: 4/5] gtk-demo: Adapt hightlighting style for dark themes
- Date: Sun, 9 Aug 2020 04:05:37 +0000 (UTC)
commit 1d49f933e91152b2a505e1b1460cf6017ce5a8e6
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 8 23:50:45 2020 -0400
gtk-demo: Adapt hightlighting style for dark themes
Switch to a highlight style that is readable with
dark background, if prefer-dark is set or we are
in HighContrastInverse.
demos/gtk-demo/main.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
---
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index 2c8686044d..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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]