From 4a60e0113120e0d1b743721e4993b6c64b5f12bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Wed, 24 Mar 2021 21:16:41 +0100 Subject: [PATCH] Auto set brighter sliders on Adwaita dark only --- css/styles.css | 6 ++--- data/com.github.rafostar.Clapper.gschema.xml | 4 ---- src/appBase.js | 24 ++++++++++++-------- src/playerBase.js | 18 +-------------- src/prefs.js | 4 +--- 5 files changed, 19 insertions(+), 37 deletions(-) diff --git a/css/styles.css b/css/styles.css index f6565d07..8d669014 100644 --- a/css/styles.css +++ b/css/styles.css @@ -61,6 +61,9 @@ radio { .roundedcorners { border-radius: 8px; } +.adwthemedark scale trough highlight { + filter: brightness(120%); +} .videowidget { min-width: 320px; @@ -301,9 +304,6 @@ radio { .gpufriendlyfs { box-shadow: none; } -.brightscale trough highlight { - filter: brightness(120%); -} /* Error BG */ .blackbackground { diff --git a/data/com.github.rafostar.Clapper.gschema.xml b/data/com.github.rafostar.Clapper.gschema.xml index 391a1b03..79ee6634 100644 --- a/data/com.github.rafostar.Clapper.gschema.xml +++ b/data/com.github.rafostar.Clapper.gschema.xml @@ -84,10 +84,6 @@ true Enable to force the app to use dark theme variant - - true - Enable to make all sliders/bars brighter - true Enable rendering window shadows (only if theme has them) diff --git a/src/appBase.js b/src/appBase.js index 09b7783b..44a5f342 100644 --- a/src/appBase.js +++ b/src/appBase.js @@ -33,12 +33,6 @@ class ClapperAppBase extends Gtk.Application if(!settings.get_boolean('render-shadows')) window.add_css_class('gpufriendly'); - if( - settings.get_boolean('dark-theme') - && settings.get_boolean('brighter-sliders') - ) - window.add_css_class('brightscale'); - for(let action in Menu.actions) { const simpleAction = new Gio.SimpleAction({ name: action @@ -94,6 +88,7 @@ class ClapperAppBase extends Gtk.Application { const theme = gtkSettings.gtk_theme_name; const window = this.active_window; + const hasAdwThemeDark = window.has_css_class('adwthemedark'); debug(`user selected theme: ${theme}`); @@ -102,6 +97,17 @@ class ClapperAppBase extends Gtk.Application if(!window.has_css_class('adwrounded')) window.add_css_class('adwrounded'); + if(theme.startsWith('Adwaita')) { + const isDarkTheme = settings.get_boolean('dark-theme'); + + if(isDarkTheme && !hasAdwThemeDark) + window.add_css_class('adwthemedark'); + else if(!isDarkTheme && hasAdwThemeDark) + window.remove_css_class('adwthemedark'); + } + else if(hasAdwThemeDark) + window.remove_css_class('adwthemedark'); + if(!theme.endsWith('-dark')) return; @@ -123,9 +129,7 @@ class ClapperAppBase extends Gtk.Application if(!hasAdwIcons) window.add_css_class('adwicons'); } - else { - if(hasAdwIcons) - window.remove_css_class('adwicons'); - } + else if(hasAdwIcons) + window.remove_css_class('adwicons'); } }); diff --git a/src/playerBase.js b/src/playerBase.js index 6dc643ac..25554392 100644 --- a/src/playerBase.js +++ b/src/playerBase.js @@ -176,27 +176,11 @@ class ClapperPlayerBase extends GstClapper.Clapper debug(`set subtitle-video offset: ${value}`); break; case 'dark-theme': - case 'brighter-sliders': root = this.widget.get_root(); if(!root || !root.isClapperApp) break; - const brightClass = 'brightscale'; - const isBrighter = root.has_css_class(brightClass); - - if(key === 'dark-theme' && isBrighter && !settings.get_boolean(key)) { - root.remove_css_class(brightClass); - debug('remove brighter sliders'); - break; - } - - const setBrighter = settings.get_boolean('brighter-sliders'); - if(setBrighter === isBrighter) - break; - - action = (setBrighter) ? 'add' : 'remove'; - root[action + '_css_class'](brightClass); - debug(`${action} brighter sliders`); + root.application._onThemeChanged(Gtk.Settings.get_default()); break; case 'play-flags': const initialFlags = this.pipeline.flags; diff --git a/src/prefs.js b/src/prefs.js index a28ce983..3bfe1989 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -329,9 +329,7 @@ class ClapperTweaksPage extends PrefsBase.Grid super._init(); this.addTitle('Appearance'); - const darkCheck = this.addCheckButton('Enable dark theme', 'dark-theme'); - const brighterCheck = this.addCheckButton('Make sliders brighter', 'brighter-sliders'); - darkCheck.bind_property('active', brighterCheck, 'visible', GObject.BindingFlags.SYNC_CREATE); + this.addCheckButton('Enable dark theme', 'dark-theme'); this.addTitle('Performance'); this.addCheckButton('Render window shadows', 'render-shadows');