Refactor: Let PrefsBoxOrderItemRow handle item association

Let `PrefsBoxOrderItemRow` handle the association of itself with an item
itself.
Doing so makes the code cleaner, since the association isn't done
externally anymore.
This commit is contained in:
June 2021-07-05 07:58:01 +02:00
commit 309e2c07b9
No known key found for this signature in database
GPG key ID: 094C2AC34192FA11
2 changed files with 19 additions and 15 deletions

View file

@ -99,19 +99,7 @@ var PrefsWidget = GObject.registerClass({
// Add the items of the given configured box order as
// GtkListBoxRows.
for (const item of boxOrder) {
const listBoxRow = new PrefsBoxOrderItemRow.PrefsBoxOrderItemRow({}, this._scrollManager);
listBoxRow.item = item;
if (item.startsWith("appindicator-kstatusnotifieritem-")) {
// Set `item_name_display_label` of the `listBoxRow` to
// something nicer, if the associated item is an
// AppIndicator/KStatusNotifierItem item.
listBoxRow.item_name_display_label.set_label(item.replace("appindicator-kstatusnotifieritem-", ""));
} else {
// Otherwise just set the `item_name_display_label` of the
// `listBoxRow` to `item`.
listBoxRow.item_name_display_label.set_label(item);
}
const listBoxRow = new PrefsBoxOrderItemRow.PrefsBoxOrderItemRow({}, this._scrollManager, item);
gtkListBox.append(listBoxRow);
}