From 6aba71c9d0dc9d5d7fcb0d4147af566351f9dfe6 Mon Sep 17 00:00:00 2001 From: esoleyman Date: Wed, 5 Aug 2020 16:51:55 -0500 Subject: [PATCH 1/2] Follow shell theme Cheese can be used with either light or dark themes. Remove code commited in a70c15c2. --- src/cheese-application.vala | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/cheese-application.vala b/src/cheese-application.vala index d14571cf..170889c9 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", -- GitLab From 056601d208e8f70e99c9af3d2c5a39d02c738641 Mon Sep 17 00:00:00 2001 From: esoleyman Date: Wed, 5 Aug 2020 21:51:22 -0500 Subject: [PATCH 2/2] UI toggle to set dark theme Allow the user to prefer a dark theme for the application. This will override the desktop theme settings if set to a light variant and give the application a dark theme. Fixes #56. --- data/cheese-prefs.ui | 29 +++++++++++++++++++++++++++++ data/org.gnome.Cheese.gschema.xml | 6 ++++++ src/cheese-preferences.vala | 28 ++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/data/cheese-prefs.ui b/data/cheese-prefs.ui index 44bddf92..42ebad8e 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 7275b5e5..9368b4be 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-preferences.vala b/src/cheese-preferences.vala index f56af7e0..081453bb 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. -- GitLab