Skip to content

Commit

Permalink
refactored gnome 46 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sakithb committed Apr 16, 2024
1 parent c72bc4e commit 6ae2a58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/helpers/shell/PanelButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ import {
Gio._promisify(GdkPixbuf.Pixbuf, "new_from_stream_async", "new_from_stream_finish");
Gio._promisify(Gio.File.prototype, "query_info_async", "query_info_finish");

function find_child_by_name(parent: Clutter.Actor | Clutter.Container, name: string) {
if (Clutter.Container === undefined) {
const children = (parent as Clutter.Actor).get_children();
for (const child of children) {
if (child.get_name() === name) {
return child;
}
}
} else {
return parent.find_child_by_name(name);
}
}

class PanelButton extends PanelMenu.Button {
private playerProxy: PlayerProxy;
private extension: MediaControls;
Expand Down Expand Up @@ -568,7 +581,7 @@ class PanelButton extends PanelMenu.Button {
tapAction.connect("tap", onClick);
icon.add_action(tapAction);

const oldIcon = this.menuControls.get_child_at_index(options.menuProps.index);
const oldIcon = find_child_by_name(this.menuControls, options.name);

if (oldIcon?.get_parent() === this.menuControls) {
this.menuControls.replace_child(oldIcon, icon);
Expand Down Expand Up @@ -716,7 +729,7 @@ class PanelButton extends PanelMenu.Button {

icon.add_action(tapAction);

const oldIcon = this.buttonControls.get_child_at_index(options.panelProps.index);
const oldIcon = find_child_by_name(this.buttonControls, options.name);

if (oldIcon != null) {
this.buttonControls.replace_child(oldIcon, icon);
Expand All @@ -726,8 +739,7 @@ class PanelButton extends PanelMenu.Button {
}

private removeButtonControlIcon(options: ControlIconOptions) {
// @ts-expect-error typing error
const icon = this.buttonControls.get_child_at_index(options.menuProps.index);
const icon = find_child_by_name(this.buttonControls, options.name);

if (icon != null) {
this.buttonControls.remove_child(icon);
Expand Down
1 change: 1 addition & 0 deletions src/helpers/shell/ScrollingLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ScrollingLabel extends St.ScrollView {

this.onShowChangedId = this.label.connect("show", this.onShowChanged.bind(this));
this.box.add_child(this.label);

if (Clutter.Container === undefined) {
this.add_child(this.box);
} else {
Expand Down

0 comments on commit 6ae2a58

Please sign in to comment.