From 274ea76eea6e97be01a723122c0774e7e961bff2 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 2 Jan 2015 09:19:17 -0800 Subject: [PATCH] frames: Force on dark theme for all apps if the user requested it If the user requested a dark theme for all apps through GNOME Tweak Tool, go ahead and force it for all apps, not only GTK+3 apps. Thanks to MaTachi on reddit who suggested the idea: http://www.reddit.com/r/linux/comments/2r1zwj/linus_i_dont_know_who_thought_it_was_a_good_idea/cnc10ui --- src/ui/frames.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ui/frames.c b/src/ui/frames.c index 5493bdde0..7014e499a 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -484,6 +484,23 @@ meta_frames_new (int screen_number) return frames; } +static const char * +get_theme_variant_override (MetaFrames *frames) +{ + GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (frames)); + GtkSettings *settings = gtk_settings_get_for_screen (screen); + gboolean dark_theme_requested; + + g_object_get (settings, + "gtk-application-prefer-dark-theme", &dark_theme_requested, + NULL); + + if (dark_theme_requested) + return "dark"; + + return NULL; +} + /* In order to use a style with a window it has to be attached to that * window. Actually, the colormaps just have to match, but since GTK+ * already takes care of making sure that its cheap to attach a style @@ -495,11 +512,17 @@ meta_ui_frame_attach_style (MetaUIFrame *frame) { MetaFrames *frames = frame->frames; const char *variant; + const char *variant_override; if (frame->style_info != NULL) meta_style_info_unref (frame->style_info); - variant = frame->meta_window->gtk_theme_variant; + variant_override = get_theme_variant_override (frame->frames); + + if (variant_override) + variant = variant_override; + else + variant = frame->meta_window->gtk_theme_variant; if (variant == NULL || strcmp(variant, "normal") == 0) frame->style_info = meta_style_info_ref (frames->normal_style);