Skip to content

Commit

Permalink
theming, appIconIndicators: Support both Cogl.Color and Clutter.Color
Browse files Browse the repository at this point in the history
  • Loading branch information
3v1n0 committed Sep 23, 2024
1 parent f322cc5 commit 0b85c47
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
19 changes: 11 additions & 8 deletions appIconIndicators.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Clutter,
Cogl,
GdkPixbuf,
Gio,
GObject,
Expand Down Expand Up @@ -358,6 +359,8 @@ class RunningIndicatorDots extends RunningIndicatorBase {
const {settings} = Docking.DockManager;
if (!settings.applyCustomTheme) {
// Adjust for the backlit case
const Color = Cogl.Color ?? Clutter.Color;

if (settings.unityBacklitItems) {
// Use dominant color for dots too if the backlit is enables
const colorPalette = this._dominantColorExtractor._getColorPalette();
Expand All @@ -366,30 +369,30 @@ class RunningIndicatorDots extends RunningIndicatorBase {
this._borderWidth = 2;

if (colorPalette) {
[, this._borderColor] = Clutter.color_from_string(colorPalette.lighter);
[, this._bodyColor] = Clutter.color_from_string(colorPalette.darker);
[, this._borderColor] = Color.from_string(colorPalette.lighter);
[, this._bodyColor] = Color.from_string(colorPalette.darker);
} else {
// Fallback
[, this._borderColor] = Clutter.color_from_string('white');
[, this._bodyColor] = Clutter.color_from_string('gray');
[, this._borderColor] = Color.from_string('white');
[, this._bodyColor] = Color.from_string('gray');
}
}

// Apply dominant color if requested
if (settings.runningIndicatorDominantColor) {
const colorPalette = this._dominantColorExtractor._getColorPalette();
if (colorPalette)
[, this._bodyColor] = Clutter.color_from_string(colorPalette.original);
[, this._bodyColor] = Color.from_string(colorPalette.original);
else
// Fallback
[, this._bodyColor] = Clutter.color_from_string(settings.customThemeRunningDotsColor);
[, this._bodyColor] = Color.from_string(settings.customThemeRunningDotsColor);
}

// Finally, use customize style if requested
if (settings.customThemeCustomizeRunningDots) {
[, this._borderColor] = Clutter.color_from_string(settings.customThemeRunningDotsBorderColor);
[, this._borderColor] = Color.from_string(settings.customThemeRunningDotsBorderColor);
this._borderWidth = settings.customThemeRunningDotsBorderWidth;
[, this._bodyColor] = Clutter.color_from_string(settings.customThemeRunningDotsColor);
[, this._bodyColor] = Color.from_string(settings.customThemeRunningDotsColor);
}
}

Expand Down
6 changes: 3 additions & 3 deletions theming.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export class ThemeManager {

({backgroundColor} = settings);
// backgroundColor is a string like rgb(0,0,0)
const clutterColor = Clutter.Color ?? Cogl.Color;
const [ret, color] = clutterColor.from_string(backgroundColor);
const Color = Cogl.Color ?? Clutter.Color;
const [ret, color] = Color.from_string(backgroundColor);
if (!ret) {
logError(new Error(`${backgroundColor} is not a valid color string`));
return;
Expand All @@ -189,7 +189,7 @@ export class ThemeManager {
color.alpha = newAlpha * 255;
this._transparency.setColor(color);
} else {
// backgroundColor is a Clutter.Color object
// backgroundColor is a {Clutter,Cogl}.Color object
this._transparency.setColor(backgroundColor);
}
}
Expand Down

0 comments on commit 0b85c47

Please sign in to comment.