From febf72fe26e33ba2cd42afc6a2475af9bf2a845d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Thu, 11 Feb 2021 15:05:25 +0000 Subject: [PATCH] src: switch to preferring gtk dark theme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables the app to use the dark theme when running in environments where a dark theme is available. This is not done in Windows because the dark theme looks quite odd when run on older versions of Windows where GTK can't replace the titlebars by default. Signed-off-by: Daniel P. Berrangé --- src/virt-viewer-app.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c index b53734a..5d3b395 100644 --- a/src/virt-viewer-app.c +++ b/src/virt-viewer-app.c @@ -2416,6 +2416,9 @@ virt_viewer_app_on_application_startup(GApplication *app) VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self); GError *error = NULL; gint i; +#ifndef G_OS_WIN32 + GtkSettings *gtk_settings; +#endif G_APPLICATION_CLASS(virt_viewer_app_parent_class)->startup(app); @@ -2424,6 +2427,13 @@ virt_viewer_app_on_application_startup(GApplication *app) G_N_ELEMENTS(actions), self); +#ifndef G_OS_WIN32 + gtk_settings = gtk_settings_get_default(); + g_object_set(G_OBJECT(gtk_settings), + "gtk-application-prefer-dark-theme", + TRUE, NULL); +#endif + priv->resource = virt_viewer_get_resource(); for (i = 0 ; i < G_N_ELEMENTS(action_accels); i++) {