Skip to content

Commit

Permalink
Bug 1272332 - Allow gtk the global dark theme behind a pref. r=karlt
Browse files Browse the repository at this point in the history
  • Loading branch information
nical committed Jun 21, 2016
1 parent 1a9bde7 commit 19ee915
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions modules/libpref/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4564,6 +4564,7 @@ pref("gfx.apitrace.enabled",false);
pref("gfx.content.use-native-pushlayer", true);
#ifdef MOZ_WIDGET_GTK
pref("gfx.xrender.enabled",false);
pref("widget.allow-gtk-dark-theme", false);
#endif
#endif

Expand Down
25 changes: 15 additions & 10 deletions widget/gtk/nsLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,16 +1098,21 @@ nsLookAndFeel::Init()
// with wrong color theme, see Bug 972382
GtkSettings *settings = gtk_settings_get_for_screen(gdk_screen_get_default());

// Disable dark theme because it interacts poorly with widget styling in
// web content (see bug 1216658).
// To avoid triggering reload of theme settings unnecessarily, only set the
// setting when necessary.
const gchar* dark_setting = "gtk-application-prefer-dark-theme";
gboolean dark;
g_object_get(settings, dark_setting, &dark, nullptr);

if (dark) {
g_object_set(settings, dark_setting, FALSE, nullptr);

bool allowDarkTheme = mozilla::Preferences::GetBool("widget.allow-gtk-dark-theme", false);

if (!allowDarkTheme) {
// Disable dark theme because it interacts poorly with widget styling in
// web content (see bug 1216658).
// To avoid triggering reload of theme settings unnecessarily, only set the
// setting when necessary.
const gchar* dark_setting = "gtk-application-prefer-dark-theme";
gboolean dark;
g_object_get(settings, dark_setting, &dark, nullptr);

if (dark) {
g_object_set(settings, dark_setting, FALSE, nullptr);
}
}

GtkWidgetPath *path = gtk_widget_path_new();
Expand Down

0 comments on commit 19ee915

Please sign in to comment.