Skip to content

Commit 6ae2a58

Browse files
committed
refactored gnome 46 support
1 parent c72bc4e commit 6ae2a58

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/helpers/shell/PanelButton.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ import {
3030
Gio._promisify(GdkPixbuf.Pixbuf, "new_from_stream_async", "new_from_stream_finish");
3131
Gio._promisify(Gio.File.prototype, "query_info_async", "query_info_finish");
3232

33+
function find_child_by_name(parent: Clutter.Actor | Clutter.Container, name: string) {
34+
if (Clutter.Container === undefined) {
35+
const children = (parent as Clutter.Actor).get_children();
36+
for (const child of children) {
37+
if (child.get_name() === name) {
38+
return child;
39+
}
40+
}
41+
} else {
42+
return parent.find_child_by_name(name);
43+
}
44+
}
45+
3346
class PanelButton extends PanelMenu.Button {
3447
private playerProxy: PlayerProxy;
3548
private extension: MediaControls;
@@ -568,7 +581,7 @@ class PanelButton extends PanelMenu.Button {
568581
tapAction.connect("tap", onClick);
569582
icon.add_action(tapAction);
570583

571-
const oldIcon = this.menuControls.get_child_at_index(options.menuProps.index);
584+
const oldIcon = find_child_by_name(this.menuControls, options.name);
572585

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

717730
icon.add_action(tapAction);
718731

719-
const oldIcon = this.buttonControls.get_child_at_index(options.panelProps.index);
732+
const oldIcon = find_child_by_name(this.buttonControls, options.name);
720733

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

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

732744
if (icon != null) {
733745
this.buttonControls.remove_child(icon);

src/helpers/shell/ScrollingLabel.ts

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class ScrollingLabel extends St.ScrollView {
6464

6565
this.onShowChangedId = this.label.connect("show", this.onShowChanged.bind(this));
6666
this.box.add_child(this.label);
67+
6768
if (Clutter.Container === undefined) {
6869
this.add_child(this.box);
6970
} else {

0 commit comments

Comments
 (0)