diff --git a/data/cheese-prefs.ui b/data/cheese-prefs.ui index 44bddf921f1ad4e3e7b45c868f76bededbe62f6c..42ebad8e8a1b2fe9938e64fed49b5ba8317f2970 100644 --- a/data/cheese-prefs.ui +++ b/data/cheese-prefs.ui @@ -490,6 +490,35 @@ False + + + Enable _dark theme + True + True + False + start + start + 9 + 12 + True + True + + + + 3 + + + + + True + False + Appearance + + + 3 + False + + False diff --git a/data/org.gnome.Cheese.gschema.xml b/data/org.gnome.Cheese.gschema.xml index 7275b5e5cfd8d4f7517351fae770db3ce5305e69..9368b4be9e1430df635e15117d58b3cf673d246a 100644 --- a/data/org.gnome.Cheese.gschema.xml +++ b/data/org.gnome.Cheese.gschema.xml @@ -1,6 +1,12 @@ + + Enable a dark theme + Set to true to always prefer a dark theme + false + + Use a countdown Set to true to show a countdown before taking a photo diff --git a/src/cheese-application.vala b/src/cheese-application.vala index d14571cf7c6830c7dd3cd3e19470fe048f449327..170889c98526130d0c59e2320187b9d9e87e31d7 100644 --- a/src/cheese-application.vala +++ b/src/cheese-application.vala @@ -100,14 +100,6 @@ public class Cheese.Application : Gtk.Application { if (this.get_windows () == null) { - // Prefer a dark GTK+ theme, bug 660628. - var gtk_settings = Gtk.Settings.get_default (); - - if (gtk_settings != null) - { - gtk_settings.gtk_application_prefer_dark_theme = true; - } - main_window = new Cheese.MainWindow (this); Environment.set_variable ("PULSE_PROP_media.role", "production", diff --git a/src/cheese-preferences.vala b/src/cheese-preferences.vala index f56af7e059cf4ba01b04d2e8fd94b6f0815336f8..081453bbfcbcf4a3783b140c5b62878ab20dbec3 100644 --- a/src/cheese-preferences.vala +++ b/src/cheese-preferences.vala @@ -55,6 +55,8 @@ public class Cheese.PreferencesDialog : Gtk.Dialog private Gtk.CheckButton countdown_check; [GtkChild] private Gtk.CheckButton flash_check; + [GtkChild] + private Gtk.CheckButton enable_dark_theme; private MediaMode current_mode; @@ -178,6 +180,8 @@ public PreferencesDialog (Cheese.Camera camera) SettingsBindFlags.DEFAULT); settings.bind ("flash", flash_check, "active", SettingsBindFlags.DEFAULT); + settings.bind ("enable-dark-theme", enable_dark_theme, "active", + SettingsBindFlags.DEFAULT); } /** @@ -351,6 +355,30 @@ public PreferencesDialog (Cheese.Camera camera) settings.set_double ("saturation", adjustment.value); } + /** + * Prefer the dark theme when checked and prefer the desktop theme when + * unchecked + * + * @param checkbutton The enable dark theme check button + */ + [GtkCallback] + private void on_enable_dark_theme_toggled (Gtk.ToggleButton checkbutton) + { + var active = checkbutton.get_active(); + var gtk_settings = Gtk.Settings.get_default (); + + if (active == true) + { + gtk_settings.set("gtk-application-prefer-dark-theme", true); + } + else + { + gtk_settings.set("gtk-application-prefer-dark-theme", false); + } + + settings.set_boolean ("enable-dark-theme", active); + } + /** * Update the video device combo box when a camera device was added or * removed.