Skip to content

Commit

Permalink
Move .actor test to its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-costas committed Apr 24, 2024
1 parent fcbb3d9 commit 4588a72
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
5 changes: 1 addition & 4 deletions dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,7 @@ export const DockDash = GObject.registerClass({
});
this._box._delegate = this;
this._boxContainer.add_child(this._box);
if (this._scrollView.add_actor)
this._scrollView.add_actor(this._boxContainer);
else
this._scrollView.add_child(this._boxContainer);
Utils.addActor(this._scrollView, this._boxContainer);
this._dashContainer.add_child(this._scrollView);

this._showAppsIcon = new AppIcons.DockShowAppsIcon(this._position);
Expand Down
7 changes: 7 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,3 +686,10 @@ export function supportsExtendedBarriers() {
return global.display.supports_extended_barriers();
return !!(global.backend.capabilities & Meta.BackendCapabilities.BARRIERS);
}

export function addActor(element, actor) {
if (element.add_actor)
element.add_actor(actor);
else
element.add_child(actor);
}
15 changes: 3 additions & 12 deletions windowPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ export class WindowPreviewMenu extends PopupMenu.PopupMenu {
});
this._destroyId = this._source.connect('destroy', this.destroy.bind(this));

if (Main.uiGroup.add_actor)
Main.uiGroup.add_actor(this.actor);
else
Main.uiGroup.add_child(this.actor);
Utils.addActor(Main.uiGroup, this.actor);

this.connect('destroy', this._onDestroy.bind(this));
}
Expand Down Expand Up @@ -112,10 +109,7 @@ class WindowPreviewList extends PopupMenu.PopupMenuSection {
this.isHorizontal = position === St.Side.BOTTOM || position === St.Side.TOP;
this.box.set_vertical(!this.isHorizontal);
this.box.set_name('dashtodockWindowList');
if (this.actor.add_actor)
this.actor.add_actor(this.box);
else
this.actor.add_child(this.box);
Utils.addActor(this.actor, this.box);
this.actor._delegate = this;

this._shownInitially = false;
Expand Down Expand Up @@ -365,10 +359,7 @@ class WindowPreviewMenuItem extends PopupMenu.PopupBaseMenuItem {
? Clutter.ActorAlign.START : Clutter.ActorAlign.END,
y_align: Clutter.ActorAlign.START,
});
if (this.closeButton.add_actor)
this.closeButton.add_actor(new St.Icon({icon_name: 'window-close-symbolic'}));
else
this.closeButton.add_child(new St.Icon({icon_name: 'window-close-symbolic'}));
Utils.addActor(this.closeButton, new St.Icon({icon_name: 'window-close-symbolic'}));
this.closeButton.connect('clicked', () => this._closeWindow());

const overlayGroup = new Clutter.Actor({
Expand Down

0 comments on commit 4588a72

Please sign in to comment.