Skip to content

Commit 78dbbfb

Browse files
authored
library: Remove usage of Adw.PreferencesRow (#955)
1 parent dd9a3e8 commit 78dbbfb

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/Library/EntryRow.blp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
using Gtk 4.0;
22
using Adw 1;
33

4-
template $EntryRow: Adw.PreferencesRow {
4+
template $EntryRow: Adw.ActionRow {
5+
activatable: true;
6+
57
accessibility {
68
labelled-by: title_label;
79
described-by: description_label;
810
}
911

10-
title: bind title_label.label;
11-
12+
[prefix]
1213
Box contents {
1314
orientation: horizontal;
1415

1516
Box labels_box {
1617
margin-top: 6;
17-
margin-start: 12;
1818
margin-bottom: 6;
1919
spacing: 3;
2020
orientation: vertical;
@@ -43,13 +43,13 @@ template $EntryRow: Adw.PreferencesRow {
4343
margin-top: 3;
4444
}
4545
}
46+
}
4647

47-
Image {
48-
icon-name: "go-next-symbolic";
49-
margin-end: 12;
50-
margin-start: 6;
51-
hexpand: true;
52-
halign: end;
53-
}
48+
[suffix]
49+
Image {
50+
icon-name: "go-next-symbolic";
51+
margin-start: 6;
52+
hexpand: true;
53+
halign: end;
5454
}
5555
}

src/Library/EntryRow.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import GObject from "gi://GObject";
66
import { getLanguage } from "../util.js";
77
import Template from "./EntryRow.blp" with { type: "uri" };
88

9-
class EntryRow extends Adw.PreferencesRow {
9+
class EntryRow extends Adw.ActionRow {
1010
constructor({ demo, ...params } = {}) {
1111
super(params);
1212

@@ -22,7 +22,7 @@ class EntryRow extends Adw.PreferencesRow {
2222
});
2323

2424
activate_action.connect("activate", () => {
25-
this.emit("activated", null);
25+
this.emit("triggered", null);
2626
});
2727
action_group.add_action(activate_action);
2828

@@ -47,7 +47,7 @@ class EntryRow extends Adw.PreferencesRow {
4747
});
4848

4949
button.connect("clicked", () => {
50-
this.emit("activated", language);
50+
this.emit("triggered", language);
5151
});
5252

5353
return button;
@@ -68,7 +68,7 @@ export default GObject.registerClass(
6868
),
6969
},
7070
Signals: {
71-
activated: {
71+
triggered: {
7272
param_types: [GObject.TYPE_JSOBJECT],
7373
},
7474
},

src/Library/Library.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ export default function Library({ application }) {
2727
window.add_css_class("devel");
2828
}
2929

30-
let last_selected;
30+
let last_triggered;
3131

3232
window.connect("close-request", quitOnLastWindowClose);
3333

3434
const demos = getDemos();
3535
const widgets_map = new Map();
3636
const category_map = new Map();
3737
demos.forEach((demo) => {
38-
const widget = new EntryRow({ demo: demo });
39-
if (demo.name === "Welcome") last_selected = widget;
38+
const entry_row = new EntryRow({ demo: demo });
39+
if (demo.name === "Welcome") last_triggered = entry_row;
4040

41-
widget.connect("activated", (_self, language) => {
42-
last_selected = widget;
41+
entry_row.connect("triggered", (_self, language) => {
42+
last_triggered = entry_row;
4343

4444
openDemo({
4545
application,
@@ -50,8 +50,8 @@ export default function Library({ application }) {
5050
if (!category_map.has(demo.category)) {
5151
category_map.set(demo.category, objects[`library_${demo.category}`]);
5252
}
53-
objects[`library_${demo.category}`].add(widget);
54-
widgets_map.set(demo.name, { widget, category: demo.category });
53+
objects[`library_${demo.category}`].add(entry_row);
54+
widgets_map.set(demo.name, { entry_row, category: demo.category });
5555
});
5656

5757
search_entry.connect("search-changed", () => {
@@ -74,7 +74,7 @@ export default function Library({ application }) {
7474
});
7575
action_library.connect("activate", () => {
7676
window.present();
77-
last_selected?.grab_focus();
77+
last_triggered?.grab_focus();
7878
});
7979
application.add_action(action_library);
8080
application.set_accels_for_action("app.library", ["<Control><Shift>O"]);

0 commit comments

Comments
 (0)