Auto set brighter sliders on Adwaita dark only

This commit is contained in:
Rafał Dzięgiel
2021-03-24 21:16:41 +01:00
parent b404eb2f56
commit 4a60e01131
5 changed files with 19 additions and 37 deletions

View File

@@ -61,6 +61,9 @@ radio {
.roundedcorners { .roundedcorners {
border-radius: 8px; border-radius: 8px;
} }
.adwthemedark scale trough highlight {
filter: brightness(120%);
}
.videowidget { .videowidget {
min-width: 320px; min-width: 320px;
@@ -301,9 +304,6 @@ radio {
.gpufriendlyfs { .gpufriendlyfs {
box-shadow: none; box-shadow: none;
} }
.brightscale trough highlight {
filter: brightness(120%);
}
/* Error BG */ /* Error BG */
.blackbackground { .blackbackground {

View File

@@ -84,10 +84,6 @@
<default>true</default> <default>true</default>
<summary>Enable to force the app to use dark theme variant</summary> <summary>Enable to force the app to use dark theme variant</summary>
</key> </key>
<key name="brighter-sliders" type="b">
<default>true</default>
<summary>Enable to make all sliders/bars brighter</summary>
</key>
<key name="render-shadows" type="b"> <key name="render-shadows" type="b">
<default>true</default> <default>true</default>
<summary>Enable rendering window shadows (only if theme has them)</summary> <summary>Enable rendering window shadows (only if theme has them)</summary>

View File

@@ -33,12 +33,6 @@ class ClapperAppBase extends Gtk.Application
if(!settings.get_boolean('render-shadows')) if(!settings.get_boolean('render-shadows'))
window.add_css_class('gpufriendly'); 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) { for(let action in Menu.actions) {
const simpleAction = new Gio.SimpleAction({ const simpleAction = new Gio.SimpleAction({
name: action name: action
@@ -94,6 +88,7 @@ class ClapperAppBase extends Gtk.Application
{ {
const theme = gtkSettings.gtk_theme_name; const theme = gtkSettings.gtk_theme_name;
const window = this.active_window; const window = this.active_window;
const hasAdwThemeDark = window.has_css_class('adwthemedark');
debug(`user selected theme: ${theme}`); debug(`user selected theme: ${theme}`);
@@ -102,6 +97,17 @@ class ClapperAppBase extends Gtk.Application
if(!window.has_css_class('adwrounded')) if(!window.has_css_class('adwrounded'))
window.add_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')) if(!theme.endsWith('-dark'))
return; return;
@@ -123,9 +129,7 @@ class ClapperAppBase extends Gtk.Application
if(!hasAdwIcons) if(!hasAdwIcons)
window.add_css_class('adwicons'); window.add_css_class('adwicons');
} }
else { else if(hasAdwIcons)
if(hasAdwIcons)
window.remove_css_class('adwicons'); window.remove_css_class('adwicons');
} }
}
}); });

View File

@@ -176,27 +176,11 @@ class ClapperPlayerBase extends GstClapper.Clapper
debug(`set subtitle-video offset: ${value}`); debug(`set subtitle-video offset: ${value}`);
break; break;
case 'dark-theme': case 'dark-theme':
case 'brighter-sliders':
root = this.widget.get_root(); root = this.widget.get_root();
if(!root || !root.isClapperApp) if(!root || !root.isClapperApp)
break; break;
const brightClass = 'brightscale'; root.application._onThemeChanged(Gtk.Settings.get_default());
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`);
break; break;
case 'play-flags': case 'play-flags':
const initialFlags = this.pipeline.flags; const initialFlags = this.pipeline.flags;

View File

@@ -329,9 +329,7 @@ class ClapperTweaksPage extends PrefsBase.Grid
super._init(); super._init();
this.addTitle('Appearance'); this.addTitle('Appearance');
const darkCheck = this.addCheckButton('Enable dark theme', 'dark-theme'); 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.addTitle('Performance'); this.addTitle('Performance');
this.addCheckButton('Render window shadows', 'render-shadows'); this.addCheckButton('Render window shadows', 'render-shadows');