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

Use Cogl.Color when defined everywhere #2287

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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
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