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

Add GNOME 45 support #163

Open
wants to merge 4 commits into
base: main
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
4 changes: 2 additions & 2 deletions [email protected]/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ export class Events {
log("[Dynamic Panel Transparency] Error could not register 'restacked' event.");
}

this._windowActorAddedSig = global.window_group.connect('actor-added', (...args) =>
this._windowActorAddedSig = global.window_group.connect('child-added', (...args) =>
this._windowActorAdded(...args)
);
this._windowActorRemovedSig = global.window_group.connect('actor-removed', (...args) =>
this._windowActorRemovedSig = global.window_group.connect('child-removed', (...args) =>
this._windowActorRemoved(...args)
);

Expand Down
60 changes: 26 additions & 34 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
/** @typedef {import('./main.js').DptExtension} DptExtension */

/** @type {Promise<null | { new(): DptExtension }>} */
let asyncInit;

function init() {
asyncInit = import('./main.js')
.then(({ DptExtension }) => {
return DptExtension;
})
.catch((error) => {
logError(error);
log('[Dynamic Panel Transparency] Failed to load.');

return null;
});
}

/** @type {DptExtension | null} */
let extension = null;

function enable() {
asyncInit
.then((DptExtension) => {
if (!DptExtension) return;

extension = new DptExtension();

extension.enable();
})
.catch((error) => {
import { DptExtension } from './main.js';
import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';

export default class ExtensionWrapper extends Extension {
/** @type {DptExtension | null} */
extension = null;

enable() {
try {
this.extension = new DptExtension();
this.extension.enable();
} catch (error) {
logError(error);
log('[Dynamic Panel Transparency] Failed to enable.');
});
}

function disable() {
extension?.disable();
}
}

disable() {
try {
if (this.extension) {
this.extension.disable();
this.extension = null;
}
} catch (error) {
logError(error);
log('[Dynamic Panel Transparency] Failed to disable.');
}
}
}
205 changes: 96 additions & 109 deletions [email protected]/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* exported init, enable, disable */

import St from 'gi://St';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';

import * as Util from './util.js';

Expand All @@ -13,7 +14,7 @@ import { Transitions } from './transitions.js';
import { main } from './shell.js';
import { setTimeout } from './timers.js';

const SETTINGS_DELAY = 3000;
const SETTINGS_DELAY = 500;

export class DptExtension {
constructor() {
Expand Down Expand Up @@ -145,19 +146,7 @@ export class DptExtension {
settings.on('transition-speed', () => {
main.panel.remove_style_class_name('dpt-panel-transition-duration');

let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();

for (let i = theming.stylesheets.length - 1; i >= 0; i--) {
let stylesheet = theming.stylesheets[i];
if (
stylesheet.indexOf('transitions') !== -1 &&
stylesheet.endsWith('panel-transition-duration.dpt.css')
) {
theme.unload_stylesheet(Util.get_file(stylesheet));
Util.remove_file(stylesheet);
theming.stylesheets.splice(i, 1);
}
}
this._unloadAndRemoveStylesheet('transitions/panel-transition-duration');

const id = (this.panel_transition_update_id = setTimeout(() => {
if (id !== this.panel_transition_update_id) {
Expand All @@ -178,19 +167,7 @@ export class DptExtension {
return;
}

let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();

for (let i = theming.stylesheets.length - 1; i >= 0; i--) {
let stylesheet = theming.stylesheets[i];
if (
stylesheet.indexOf('background') !== -1 &&
stylesheet.indexOf('panel-') !== -1
) {
theme.unload_stylesheet(Util.get_file(stylesheet));
Util.remove_file(stylesheet);
theming.stylesheets.splice(i, 1);
}
}
this._unloadAndRemoveStylesheet('background/panel-custom');

theming.initialize_background_styles();

Expand All @@ -217,19 +194,7 @@ export class DptExtension {
return;
}

let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();

for (let i = theming.stylesheets.length - 1; i >= 0; i--) {
let stylesheet = theming.stylesheets[i];
if (
stylesheet.indexOf('background') !== -1 &&
stylesheet.indexOf('panel-') !== -1
) {
theme.unload_stylesheet(Util.get_file(stylesheet));
Util.remove_file(stylesheet);
theming.stylesheets.splice(i, 1);
}
}
this._unloadAndRemoveStylesheet('background/panel-custom');

theming.initialize_background_styles();

Expand All @@ -248,39 +213,6 @@ export class DptExtension {
}, SETTINGS_DELAY));
});

settings.on('panel-color', () => {
theming.remove_background_color();

let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();

for (let i = theming.stylesheets.length - 1; i >= 0; i--) {
let stylesheet = theming.stylesheets[i];
if (
stylesheet.indexOf('background') !== -1 &&
stylesheet.indexOf('panel.dpt.css') !== -1
) {
theme.unload_stylesheet(Util.get_file(stylesheet));
Util.remove_file(stylesheet);
theming.stylesheets.splice(i, 1);
}
}

theming.register_background_color(settings.get_panel_color(), 'custom');

const id = (this.panel_color_update_id = setTimeout(() => {
if (id !== this.panel_color_update_id) {
return;
}

/* Get Rid of the Panel's CSS Background */
theming.remove_background_color();

intellifader.forceSyncCheck();

return;
}, SETTINGS_DELAY));
});

settings.on('text-shadow', () => {
if (settings.add_text_shadow()) {
theming.add_text_shadow();
Expand All @@ -300,16 +232,8 @@ export class DptExtension {
settings.on('text-shadow-position', () => {
theming.remove_text_shadow();

let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
this._unloadAndRemoveStylesheet('foreground/panel-text-shadow');

for (let i = theming.stylesheets.length - 1; i >= 0; i--) {
let stylesheet = theming.stylesheets[i];
if (stylesheet.indexOf('shadow') !== -1 && stylesheet.indexOf('text') !== -1) {
theme.unload_stylesheet(Util.get_file(stylesheet));
Util.remove_file(stylesheet);
theming.stylesheets.splice(i, 1);
}
}
let text_shadow = theming.register_text_shadow(
settings.get_text_shadow_color(),
settings.get_text_shadow_position()
Expand All @@ -336,16 +260,8 @@ export class DptExtension {
settings.on('icon-shadow-position', () => {
theming.remove_icon_shadow();

let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
this._unloadAndRemoveStylesheet('foreground/panel-icon-shadow');

for (let i = theming.stylesheets.length - 1; i >= 0; i--) {
let stylesheet = theming.stylesheets[i];
if (stylesheet.indexOf('shadow') !== -1 && stylesheet.indexOf('icon') !== -1) {
theme.unload_stylesheet(Util.get_file(stylesheet));
Util.remove_file(stylesheet);
theming.stylesheets.splice(i, 1);
}
}
let icon_shadow = theming.register_icon_shadow(
settings.get_icon_shadow_color(),
settings.get_icon_shadow_position()
Expand All @@ -372,16 +288,8 @@ export class DptExtension {
settings.on('icon-shadow-color', () => {
theming.remove_icon_shadow();

let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
this._unloadAndRemoveStylesheet('foreground/panel-icon-shadow');

for (let i = theming.stylesheets.length - 1; i >= 0; i--) {
let stylesheet = theming.stylesheets[i];
if (stylesheet.indexOf('shadow') !== -1 && stylesheet.indexOf('icon') !== -1) {
theme.unload_stylesheet(Util.get_file(stylesheet));
Util.remove_file(stylesheet);
theming.stylesheets.splice(i, 1);
}
}
let icon_shadow = theming.register_icon_shadow(
settings.get_icon_shadow_color(),
settings.get_icon_shadow_position()
Expand All @@ -408,16 +316,8 @@ export class DptExtension {
settings.on('text-shadow-color', () => {
theming.remove_text_shadow();

let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
this._unloadAndRemoveStylesheet('foreground/panel-text-shadow');

for (let i = theming.stylesheets.length - 1; i >= 0; i--) {
let stylesheet = theming.stylesheets[i];
if (stylesheet.indexOf('shadow') !== -1 && stylesheet.indexOf('text') !== -1) {
theme.unload_stylesheet(Util.get_file(stylesheet));
Util.remove_file(stylesheet);
theming.stylesheets.splice(i, 1);
}
}
let text_shadow = theming.register_text_shadow(
settings.get_text_shadow_color(),
settings.get_text_shadow_position()
Expand Down Expand Up @@ -453,6 +353,93 @@ export class DptExtension {
theming.remove_text_color();
theming.remove_text_color('maximized');
}
intellifader.forceSyncCheck();
});

settings.on('text-color', () => {
main.panel.remove_style_class_name('dpt-panel-text-color');

this._unloadAndRemoveStylesheet('foreground/panel-text-color');

const id = (this.text_color_update_id = setTimeout(() => {
if (id !== this.text_color_update_id) {
return;
}

theming.remove_background_color();
theming.register_text_color(settings.get_text_color());

intellifader.forceSyncCheck();

return;
}, SETTINGS_DELAY));
});

settings.on('maximized-text-color', () => {
main.panel.remove_style_class_name('dpt-panel-maximized-text-color');

this._unloadAndRemoveStylesheet('foreground/panel-maximized-text-color');

const id = (this.maximized_text_color_update_id = setTimeout(() => {
if (id !== this.maximized_text_color_update_id) {
return;
}

theming.remove_maximized_background_color();
theming.register_text_color(settings.get_maximized_text_color(), 'maximized');

intellifader.forceSyncCheck();

return;
}, SETTINGS_DELAY));
});

settings.on('panel-color', () => {
main.panel.remove_style_class_name('dpt-panel-color');

this._unloadAndRemoveStylesheet('background/panel-custom');

const id = (this.panel_color_update_id = setTimeout(() => {
if (id !== this.panel_color_update_id) {
return;
}

theming.remove_background_color();
theming.register_background_color(settings.get_panel_color(), 'custom');

intellifader.forceSyncCheck();

return;
}, SETTINGS_DELAY));
});

settings.on('enable-background-color', () => {
if (settings.enable_custom_background_color()) {
intellifader.forceSyncCheck();
} else {
theming.remove_background_color();
}
});

settings.on('enable-opacity', () => {
if (settings.enable_custom_opacity()) {
intellifader.forceSyncCheck();
} else {
theming.remove_opacity();
}
});
}

_unloadAndRemoveStylesheet(name) {
let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();

for (let i = this.theming.stylesheets.length - 1; i >= 0; i--) {
let stylesheet = this.theming.stylesheets[i];
if (stylesheet.includes(name)) {
theme.unload_stylesheet(Util.get_file(stylesheet));
Util.remove_file(stylesheet);
this.theming.stylesheets.splice(i, 1);
}
}
}
}
6 changes: 3 additions & 3 deletions [email protected]/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"description": "This extension fades your top panel to nothingness when there are no maximized windows present. Never again will the panel be abruptly darkened!",
"name": "Dynamic Panel Transparency",
"shell-version": [
"42",
"43"
"45",
"46"
],
"uuid": "[email protected]",
"settings-schema": "org.gnome.shell.extensions.dynamic-panel-transparency",
"version": 35,
"version": 45,
"gettext-domain": "dynamic-panel-transparency",
"url": "https://github.com/ewlsh/dynamic-panel-transparency/"
}
Loading