Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library: Remove usage of Adw.PreferencesRow #955

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Library/EntryRow.blp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using Gtk 4.0;
using Adw 1;

template $EntryRow: Adw.PreferencesRow {
template $EntryRow: Adw.ActionRow {
activatable: true;

accessibility {
labelled-by: title_label;
described-by: description_label;
}

title: bind title_label.label;

[prefix]
Box contents {
orientation: horizontal;

Box labels_box {
margin-top: 6;
margin-start: 12;
margin-bottom: 6;
spacing: 3;
orientation: vertical;
Expand Down Expand Up @@ -43,13 +43,13 @@ template $EntryRow: Adw.PreferencesRow {
margin-top: 3;
}
}
}

Image {
icon-name: "go-next-symbolic";
margin-end: 12;
margin-start: 6;
hexpand: true;
halign: end;
}
[suffix]
Image {
icon-name: "go-next-symbolic";
margin-start: 6;
hexpand: true;
halign: end;
}
}
8 changes: 4 additions & 4 deletions src/Library/EntryRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GObject from "gi://GObject";
import { getLanguage } from "../util.js";
import Template from "./EntryRow.blp" with { type: "uri" };

class EntryRow extends Adw.PreferencesRow {
class EntryRow extends Adw.ActionRow {
constructor({ demo, ...params } = {}) {
super(params);

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

activate_action.connect("activate", () => {
this.emit("activated", null);
this.emit("triggered", null);
});
action_group.add_action(activate_action);

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

button.connect("clicked", () => {
this.emit("activated", language);
this.emit("triggered", language);
});

return button;
Expand All @@ -68,7 +68,7 @@ export default GObject.registerClass(
),
},
Signals: {
activated: {
triggered: {
param_types: [GObject.TYPE_JSOBJECT],
},
},
Expand Down
16 changes: 8 additions & 8 deletions src/Library/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ export default function Library({ application }) {
window.add_css_class("devel");
}

let last_selected;
let last_triggered;

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

const demos = getDemos();
const widgets_map = new Map();
const category_map = new Map();
demos.forEach((demo) => {
const widget = new EntryRow({ demo: demo });
if (demo.name === "Welcome") last_selected = widget;
const entry_row = new EntryRow({ demo: demo });
if (demo.name === "Welcome") last_triggered = entry_row;

widget.connect("activated", (_self, language) => {
last_selected = widget;
entry_row.connect("triggered", (_self, language) => {
last_triggered = entry_row;

openDemo({
application,
Expand All @@ -50,8 +50,8 @@ export default function Library({ application }) {
if (!category_map.has(demo.category)) {
category_map.set(demo.category, objects[`library_${demo.category}`]);
}
objects[`library_${demo.category}`].add(widget);
widgets_map.set(demo.name, { widget, category: demo.category });
objects[`library_${demo.category}`].add(entry_row);
widgets_map.set(demo.name, { entry_row, category: demo.category });
});

search_entry.connect("search-changed", () => {
Expand All @@ -74,7 +74,7 @@ export default function Library({ application }) {
});
action_library.connect("activate", () => {
window.present();
last_selected?.grab_focus();
last_triggered?.grab_focus();
});
application.add_action(action_library);
application.set_accels_for_action("app.library", ["<Control><Shift>O"]);
Expand Down
Loading