src: switch to preferring gtk dark theme

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é <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2021-02-11 15:05:25 +00:00
parent 0f1c12dc38
commit febf72fe26

View File

@ -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++) {