mirror of
https://gitlab.gnome.org/june/top-bar-organizer.git
synced 2026-01-12 01:03:51 +01:00
Refactor: Add PrefsBoxOrderListBoxes via UI file a. let them self-init
Add the `PrefsBoxOrderListBox`es to the `PrefsPage` via the `PrefsPage`es UI file. Also let the `PrefsBoxOrderListBox`es initialize themselves based on the given box order.
This commit is contained in:
parent
c54e24c151
commit
5362629f94
3 changed files with 51 additions and 31 deletions
|
|
@ -48,31 +48,5 @@ var PrefsPage = GObject.registerClass({
|
|||
scrollManager.stopScrollAll();
|
||||
});
|
||||
this.add_controller(controller);
|
||||
|
||||
// Add custom GTKListBoxes (PrefsBoxOrderListBoxes).
|
||||
this._left_box_order = new PrefsBoxOrderListBox.PrefsBoxOrderListBox({}, "left-box-order");
|
||||
this._left_box.append(this._left_box_order);
|
||||
this._center_box_order = new PrefsBoxOrderListBox.PrefsBoxOrderListBox({}, "center-box-order");
|
||||
this._center_box.append(this._center_box_order);
|
||||
this._right_box_order = new PrefsBoxOrderListBox.PrefsBoxOrderListBox({}, "right-box-order");
|
||||
this._right_box.append(this._right_box_order);
|
||||
|
||||
// Initialize the given `gtkListBox`.
|
||||
const initializeGtkListBox = (boxOrder, gtkListBox) => {
|
||||
// Add the items of the given configured box order as
|
||||
// GtkListBoxRows.
|
||||
for (const item of boxOrder) {
|
||||
const listBoxRow = new PrefsBoxOrderItemRow.PrefsBoxOrderItemRow({}, item);
|
||||
gtkListBox.append(listBoxRow);
|
||||
}
|
||||
|
||||
// Add a placeholder widget for the case, where `gtkListBox` doesn't
|
||||
// have any GtkListBoxRows.
|
||||
gtkListBox.set_placeholder(new PrefsBoxOrderListEmptyPlaceholder.PrefsBoxOrderListEmptyPlaceholder());
|
||||
};
|
||||
|
||||
initializeGtkListBox(settings.get_strv("left-box-order"), this._left_box_order);
|
||||
initializeGtkListBox(settings.get_strv("center-box-order"), this._center_box_order);
|
||||
initializeGtkListBox(settings.get_strv("right-box-order"), this._right_box_order);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue