From a830edf8cf1ba9ca5acf92f0cfaa23615a7e3952 Mon Sep 17 00:00:00 2001 From: Zander Brown Date: Wed, 8 Nov 2023 10:20:03 +0000 Subject: [PATCH] js: Cleanup use of StBin StBins (inc StButton) should have their content managed via :child rather than add_child() Part-of: --- js/ui/altTab.js | 2 +- js/ui/dash.js | 2 +- js/ui/dateMenu.js | 2 +- js/ui/magnifier.js | 12 +++++++----- js/ui/pageIndicators.js | 8 ++++---- js/ui/search.js | 12 +++++++----- js/ui/status/keyboard.js | 15 ++++++++------- 7 files changed, 29 insertions(+), 24 deletions(-) diff --git a/js/ui/altTab.js b/js/ui/altTab.js index 21dba9d3f..0e64d65ee 100644 --- a/js/ui/altTab.js +++ b/js/ui/altTab.js @@ -965,7 +965,7 @@ class ThumbnailSwitcher extends SwitcherPopup.SwitcherList { let clone = _createWindowClone(mutterWindow, thumbnailSize); this._thumbnailBins[i].set_height(binHeight); - this._thumbnailBins[i].add_child(clone); + this._thumbnailBins[i].child = clone; mutterWindow.connectObject('destroy', source => this._removeThumbnail(source, clone), this); diff --git a/js/ui/dash.js b/js/ui/dash.js index 8f4c2a95c..3cdc0b5af 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -210,7 +210,7 @@ class ShowAppsIcon extends DashItemContainer { }); this.icon.y_align = Clutter.ActorAlign.CENTER; - this.toggleButton.add_child(this.icon); + this.toggleButton.child = this.icon; this.toggleButton._delegate = this; this.setChild(this.toggleButton); diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index 53134deb6..0ffd73c76 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -64,7 +64,7 @@ class TodayButton extends St.Button { }); const hbox = new St.BoxLayout({vertical: true}); - this.add_child(hbox); + this.child = hbox; this._dayLabel = new St.Label({ style_class: 'day-label', diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js index ce03e3cd7..522b201fe 100644 --- a/js/ui/magnifier.js +++ b/js/ui/magnifier.js @@ -1469,17 +1469,19 @@ class ZoomRegion { // Private methods // _createActors() { + // Add a group to clip the contents of the magnified view. + const mainGroup = new Clutter.Actor({clip_to_allocation: true}); + // The root actor for the zoom region - this._magView = new St.Bin({style_class: 'magnifier-zoom-region'}); + this._magView = new St.Bin({ + style_class: 'magnifier-zoom-region', + child: mainGroup, + }); global.stage.add_child(this._magView); // hide the magnified region from CLUTTER_PICK_ALL Shell.util_set_hidden_from_pick(this._magView, true); - // Add a group to clip the contents of the magnified view. - let mainGroup = new Clutter.Actor({clip_to_allocation: true}); - this._magView.set_child(mainGroup); - // Add a background for when the magnified uiGroup is scrolled // out of view (don't want to see desktop showing through). this._background = new Background.SystemBackground(); diff --git a/js/ui/pageIndicators.js b/js/ui/pageIndicators.js index 38b812a6e..af3ee14ca 100644 --- a/js/ui/pageIndicators.js +++ b/js/ui/pageIndicators.js @@ -62,10 +62,10 @@ export const PageIndicators = GObject.registerClass({ St.ButtonMask.TWO | St.ButtonMask.THREE, reactive: this._reactive, - }); - indicator.child = new St.Widget({ - style_class: 'page-indicator-icon', - pivot_point: new Graphene.Point({x: 0.5, y: 0.5}), + child: new St.Widget({ + style_class: 'page-indicator-icon', + pivot_point: new Graphene.Point({x: 0.5, y: 0.5}), + }), }); indicator.connect('clicked', () => { this.emit('page-activated', pageIndex); diff --git a/js/ui/search.js b/js/ui/search.js index 76918290c..2cc357344 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -304,7 +304,7 @@ class ListSearchResults extends SearchResultsBase { }); this._container.add_child(this._content); - this._resultDisplayBin.set_child(this._container); + this._resultDisplayBin.child = this._container; } _setMoreCount(count) { @@ -468,10 +468,10 @@ class GridSearchResults extends SearchResultsBase { this._grid.layout_manager.spacing = node.get_length('spacing'); }); - this._resultDisplayBin.set_child(new St.Bin({ + this._resultDisplayBin.child = new St.Bin({ child: this._grid, x_align: Clutter.ActorAlign.CENTER, - })); + }); this._maxResults = provider.maxResults ?? -1; } @@ -588,9 +588,11 @@ export const SearchResultsView = GObject.registerClass({ x_align: Clutter.ActorAlign.CENTER, y_align: Clutter.ActorAlign.CENTER, }); - this._statusBin = new St.Bin({y_expand: true}); + this._statusBin = new St.Bin({ + y_expand: true, + child: this._statusText, + }); this.add_child(this._statusBin); - this._statusBin.add_child(this._statusText); this._highlightDefault = false; this._defaultResult = null; diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js index 7436326b9..cad5f2a86 100644 --- a/js/ui/status/keyboard.js +++ b/js/ui/status/keyboard.js @@ -125,14 +125,15 @@ class InputSourceSwitcher extends SwitcherPopup.SwitcherList { _addIcon(item) { let box = new St.BoxLayout({vertical: true}); - let bin = new St.Bin({style_class: 'input-source-switcher-symbol'}); - let symbol = new St.Label({ - text: item.shortName, - x_align: Clutter.ActorAlign.CENTER, - y_align: Clutter.ActorAlign.CENTER, + const symbol = new St.Bin({ + style_class: 'input-source-switcher-symbol', + child: new St.Label({ + text: item.shortName, + x_align: Clutter.ActorAlign.CENTER, + y_align: Clutter.ActorAlign.CENTER, + }), }); - bin.set_child(symbol); - box.add_child(bin); + box.add_child(symbol); let text = new St.Label({ text: item.displayName,