diff --git a/src/prefs-box-order-list-box.ui b/src/prefs-box-order-list-box.ui new file mode 100644 index 0000000..7bd6ad6 --- /dev/null +++ b/src/prefs-box-order-list-box.ui @@ -0,0 +1,25 @@ + + + + + diff --git a/src/prefs-widget.ui b/src/prefs-widget.ui index eaa64e4..d662a65 100644 --- a/src/prefs-widget.ui +++ b/src/prefs-widget.ui @@ -37,7 +37,7 @@ - + vertical @@ -49,16 +49,10 @@ - - - none - True - - - + vertical @@ -70,16 +64,10 @@ - - - none - True - - - + vertical @@ -91,12 +79,6 @@ - - - none - True - - diff --git a/src/prefs.js b/src/prefs.js index 187a6f1..4740bde 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -25,6 +25,7 @@ const GObject = imports.gi.GObject; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); +const PrefsBoxOrderListBox = Me.imports.prefsModules.PrefsBoxOrderListBox; const PrefsBoxOrderListEmptyPlaceholder = Me.imports.prefsModules.PrefsBoxOrderListEmptyPlaceholder; const PrefsBoxOrderItemRow = Me.imports.prefsModules.PrefsBoxOrderItemRow; const ScrollManager = Me.imports.prefsModules.ScrollManager; @@ -33,9 +34,9 @@ var PrefsWidget = GObject.registerClass({ GTypeName: "PrefsWidget", Template: Me.dir.get_child("prefs-widget.ui").get_uri(), InternalChildren: [ - "left-box-order", - "center-box-order", - "right-box-order" + "left-box", + "center-box", + "right-box" ] }, class PrefsWidget extends Gtk.ScrolledWindow { _init(params = {}) { @@ -85,6 +86,14 @@ var PrefsWidget = GObject.registerClass({ }); 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 @@ -114,13 +123,6 @@ var PrefsWidget = GObject.registerClass({ initializeGtkListBox(this._settings.get_strv("left-box-order"), this._left_box_order); initializeGtkListBox(this._settings.get_strv("center-box-order"), this._center_box_order); initializeGtkListBox(this._settings.get_strv("right-box-order"), this._right_box_order); - - // Set the box order each GtkListBox is associated with. - // This is needed by the reordering of the GtkListBoxRows, so that the - // updated box orders can be saved. - this._left_box_order.boxOrder = "left-box-order"; - this._center_box_order.boxOrder = "center-box-order"; - this._right_box_order.boxOrder = "right-box-order"; } }); diff --git a/src/prefsModules/PrefsBoxOrderListBox.js b/src/prefsModules/PrefsBoxOrderListBox.js new file mode 100644 index 0000000..6e93561 --- /dev/null +++ b/src/prefsModules/PrefsBoxOrderListBox.js @@ -0,0 +1,42 @@ +/* + * This file is part of Top-Bar-Organizer (a Gnome Shell Extension for + * organizing your Gnome Shell top bar). + * Copyright (C) 2021 Julian Schacher + * + * Top-Bar-Organizer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +/* exported PrefsBoxOrderListBox */ +"use strict"; + +const Gtk = imports.gi.Gtk; +const GObject = imports.gi.GObject; + +const ExtensionUtils = imports.misc.extensionUtils; +const Me = ExtensionUtils.getCurrentExtension(); + +var PrefsBoxOrderListBox = GObject.registerClass({ + GTypeName: "PrefsBoxOrderListBox", + Template: Me.dir.get_child("prefs-box-order-list-box.ui").get_uri() +}, class PrefsBoxOrderListBox extends Gtk.ListBox { + /** + * @param {Object} params + * @param {String} boxOrder - The box order this PrefsBoxOrderListBox is + * associated with. + */ + _init(params = {}, boxOrder) { + super._init(params); + + this.boxOrder = boxOrder; + } +});