Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override panel theme background color with dominant icon color #1564

Open
wants to merge 10 commits into
base: gnome-40
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -4331,6 +4331,16 @@
<property name="step_increment">5</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="trans_bg_icon_brightness_adjustment">
<property name="upper">100</property>
<property name="step_increment">5</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="trans_bg_icon_preview_brightness_adjustment">
<property name="upper">100</property>
<property name="step_increment">5</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="trans_opacity_min_adjustment">
<property name="upper">100</property>
<property name="step_increment">5</property>
Expand Down Expand Up @@ -5455,6 +5465,159 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="trans_bg_icon_row">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkBox" id="trans_bg_icon_main_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkGrid" id="trans_bg_icon_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkLabel" id="trans_bg_icon_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Override panel theme background color with dominant icon color </property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
<layout>
<property name="row">0</property>
<property name="column">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkBox" id="trans_bg_icon_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkSwitch" id="trans_bg_icon_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<layout>
<property name="row">0</property>
<property name="column">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkGrid" id="trans_bg_icon_options_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">12</property>
<property name="margin_top">12</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkLabel" id="trans_bg_icon_brightness_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Panel dominant color brightness (%)</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
<layout>
<property name="row">0</property>
<property name="column">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="trans_bg_icon_brightness_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">trans_bg_icon_brightness_adjustment</property>
<layout>
<property name="row">0</property>
<property name="column">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="trans_bg_icon_preview_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Apply to window preview</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
<layout>
<property name="row">1</property>
<property name="column">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkSwitch" id="trans_bg_icon_preview_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<layout>
<property name="row">1</property>
<property name="column">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="trans_bg_icon_preview_brightness_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Window preview brightness (%)</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
<layout>
<property name="row">2</property>
<property name="column">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="trans_bg_icon_preview_brightness_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">trans_bg_icon_preview_brightness_adjustment</property>
<layout>
<property name="row">2</property>
<property name="column">1</property>
</layout>
</object>
</child>
<layout>
<property name="row">1</property>
<property name="column">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="listbox_preview_show_title1">
<property name="visible">True</property>
Expand Down
23 changes: 19 additions & 4 deletions appIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ var taskbarAppIcon = Utils.defineClass({
Me.settings.connect('changed::focus-highlight', Lang.bind(this, this._settingsChangeRefresh)),
Me.settings.connect('changed::focus-highlight-dominant', Lang.bind(this, this._settingsChangeRefresh)),
Me.settings.connect('changed::focus-highlight-color', Lang.bind(this, this._settingsChangeRefresh)),
Me.settings.connect('changed::focus-dominant-color', Lang.bind(this, this._settingsChangeRefresh)),
Me.settings.connect('changed::focus-highlight-opacity', Lang.bind(this, this._settingsChangeRefresh)),
Me.settings.connect('changed::group-apps-label-font-size', Lang.bind(this, this._updateWindowTitleStyle)),
Me.settings.connect('changed::group-apps-label-font-weight', Lang.bind(this, this._updateWindowTitleStyle)),
Expand Down Expand Up @@ -606,7 +607,15 @@ var taskbarAppIcon = Utils.defineClass({
let highlightColor = this._getFocusHighlightColor();
inlineStyle += "background-color: " + cssHexTocssRgba(highlightColor, Me.settings.get_int('focus-highlight-opacity') * 0.01);
}


if (this._checkIfFocusedApp() && !this.isLauncher &&
(!this.window || isFocused) && !this._isThemeProvidingIndicator() && this._checkIfMonitorHasFocus()){
let dominantColor = this._getAppDominantColor();
if (dominantColor && this.parentPanelColor != dominantColor){
global.dashToPanel.emit('changed::focus-dominant-color', dominantColor);
}

}
if(this._dotsContainer.get_style() != inlineStyle && this._dotsContainer.mapped) {
if (!this._isGroupApps) {
//when the apps are ungrouped, set the style synchronously so the icons don't jump around on taskbar redraw
Expand Down Expand Up @@ -1083,11 +1092,17 @@ var taskbarAppIcon = Utils.defineClass({
return color;
},

_getAppDominantColor: function() {
let dce = new Utils.DominantColorExtractor(this.app);
let palette = dce._getColorPalette();
if (palette) return palette.original;
return undefined;
},

_getFocusHighlightColor: function() {
if (Me.settings.get_boolean('focus-highlight-dominant')) {
let dce = new Utils.DominantColorExtractor(this.app);
let palette = dce._getColorPalette();
if (palette) return palette.original;
let domColor = this._getAppDominantColor();
if (domColor !== undefined) return domColor;
}
return Me.settings.get_string('focus-highlight-color');
},
Expand Down
34 changes: 34 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,16 @@ const Preferences = new Lang.Class({
this._builder.get_object('trans_bg_color_colorbutton'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);

this._settings.bind('trans-use-dominant-icon-color',
this._builder.get_object('trans_bg_icon_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);

this._settings.bind('trans-apply-dominant-color-to-preview',
this._builder.get_object('trans_bg_icon_preview_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);

let rgba = new Gdk.RGBA();
rgba.parse(this._settings.get_string('trans-bg-color'));
Expand Down Expand Up @@ -997,6 +1007,30 @@ const Preferences = new Lang.Class({
this._settings.set_double('trans-panel-opacity', widget.get_value() * 0.01);
}));

this._builder.get_object('trans_bg_icon_brightness_spinbutton').set_value(this._settings.get_double('trans-panel-dominant-color-brightness') * 100);
this._builder.get_object('trans_bg_icon_brightness_spinbutton').connect('value-changed', Lang.bind(this, function (widget) {
if (widget.get_value() < 1){
// Somehow fixes bug that resets brightness to 0.5 when user sets to 0
this._settings.set_double('trans-panel-dominant-color-brightness', 0.001);
}
else
{
this._settings.set_double('trans-panel-dominant-color-brightness', widget.get_value() * 0.01);
}
}));

this._builder.get_object('trans_bg_icon_preview_brightness_spinbutton').set_value(this._settings.get_double('trans-preview-dominant-color-brightness') * 100);
this._builder.get_object('trans_bg_icon_preview_brightness_spinbutton').connect('value-changed', Lang.bind(this, function (widget) {
if (widget.get_value() < 1){
// Somehow fixes bug that resets brightness to 0.5 when user sets to 0
this._settings.set_double('trans-preview-dominant-color-brightness', 0.001);
}
else
{
this._settings.set_double('trans-preview-dominant-color-brightness', widget.get_value() * 0.01);
}
}));

this._settings.bind('trans-use-dynamic-opacity',
this._builder.get_object('trans_dyn_switch'),
'active',
Expand Down
20 changes: 20 additions & 0 deletions schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@
<summary>Override theme background color</summary>
<description>Replace current theme background color for the panel</description>
</key>
<key type="b" name="trans-use-dominant-icon-color">
<default>false</default>
<summary>Override panel theme background color with dominant icon color</summary>
<description>Replace current theme background color for the panel with the dominant color of the focused app icon. Falls back to overridden background color or theme color if no app is focused or if the Activities overlay is opened.</description>
</key>
<key type="b" name="trans-apply-dominant-color-to-preview">
<default>false</default>
<summary>Apply to window preview</summary>
<description>Apply dominant color to window preview</description>
</key>
<key type="s" name="trans-bg-color">
<default>"#000"</default>
<summary>Custom background color</summary>
Expand All @@ -259,6 +269,16 @@
<summary>Panel opacity</summary>
<description>Custom opacity for the panel</description>
</key>
<key type="d" name="trans-panel-dominant-color-brightness">
<default>0.5</default>
<summary>Panel dominant color brightness</summary>
<description>Modify brightness of dominant color of app icon used as panel background color</description>
</key>
<key type="d" name="trans-preview-dominant-color-brightness">
<default>0.15</default>
<summary>Window preview dominant color brightness</summary>
<description>Modify brightness of dominant color of app icon used as window preview background color</description>
</key>
<key name="trans-dynamic-behavior" enum="org.gnome.shell.extensions.dash-to-panel.proximityBehavior">
<default>'ALL_WINDOWS'</default>
<summary>Dynamic opacity behavior</summary>
Expand Down
Loading