[gnome-characters/bilelmoussaoui/gtk4: 5/71] don't subclass GtkListBox
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-characters/bilelmoussaoui/gtk4: 5/71] don't subclass GtkListBox
- Date: Thu, 25 Nov 2021 11:03:09 +0000 (UTC)
commit bf4d221672c2e02759eaa94697203de51625b648
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Fri Nov 19 11:33:46 2021 +0100
don't subclass GtkListBox
src/categoryList.js | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/src/categoryList.js b/src/categoryList.js
index 5a6f27a..6afbf3b 100644
--- a/src/categoryList.js
+++ b/src/categoryList.js
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-const {Gc, GLib, GObject, Gtk, GnomeDesktop} = imports.gi;
+const {Adw, Gc, GLib, GObject, Gtk, GnomeDesktop} = imports.gi;
const Gettext = imports.gettext;
const Params = imports.params;
@@ -161,10 +161,11 @@ const CategoryListRowWidget = GObject.registerClass({
});
const CategoryListWidget = GObject.registerClass({
-}, class CategoryListWidget extends Gtk.ListBox {
+}, class CategoryListWidget extends Adw.Bin {
_init(params) {
const filtered = Params.filter(params, { categoryList: null });
params = Params.fill(params, {});
+ this.list = Gtk.ListBox.new();
super._init(params);
@@ -176,18 +177,19 @@ const CategoryListWidget = GObject.registerClass({
let category = this._categoryList[index];
let rowWidget = new CategoryListRowWidget({}, category);
rowWidget.get_style_context().add_class('category');
- this.add(rowWidget);
+ this.list.append(rowWidget);
}
- }
- vfunc_row_selected(row) {
- if (row != null && row.selectable) {
- let toplevel = row.get_toplevel();
- let action = toplevel.lookup_action('category');
- action.activate(new GLib.Variant('s', row.category.name));
- this._lastSelectedRow = row;
- }
+ this.list.connect('row-selected', (row) => {
+ if (row != null && row.selectable) {
+ let toplevel = row.get_root();
+ let action = toplevel.lookup_action('category');
+ action.activate(new GLib.Variant('s', row.category.name));
+ this._lastSelectedRow = row;
+ }
+ });
}
+
populateCategoryList() {
}
@@ -206,14 +208,14 @@ const CategoryListWidget = GObject.registerClass({
restorePreviousSelection() {
if (this._lastSelectedRow) {
- this.select_row(this._lastSelectedRow)
+ this.list.select_row(this._lastSelectedRow)
}
}
unselect() {
- let selected = this.get_selected_row()
+ let selected = this.list.get_selected_row()
if (selected)
- this.unselect_row(selected)
+ this.list.unselect_row(selected)
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]