Skip to content

Commit 26e63a1

Browse files
committed
Fix Library category filtering
1 parent dfb44ab commit 26e63a1

3 files changed

Lines changed: 54 additions & 45 deletions

File tree

build-aux/wip/run.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,21 @@ if (!exists(`${path}/_build`)) {
108108
"_build",
109109
"-Dprofile=development",
110110
]);
111-
} else {
112-
await buildCommand(["meson", "install", "-C", "_build"]);
113-
// await buildCommand([
114-
// `troll/gjspack/bin/gjspack`,
115-
// `--appid=${flatpak_id}`,
116-
// "--prefix=/re/sonny/Workbench",
117-
// `--project-root=.`,
118-
// `--resource-root=./src`,
119-
// "--blueprint-compiler=/app/bin/blueprint-compiler",
120-
// "--no-executable",
121-
// `${path}/src/main.js`,
122-
// `/app/share/${flatpak_id}.src.gresource`,
123-
// ]);
124111
}
125112

113+
await buildCommand(["meson", "install", "-C", "_build"]);
114+
// await buildCommand([
115+
// `troll/gjspack/bin/gjspack`,
116+
// `--appid=${flatpak_id}`,
117+
// "--prefix=/re/sonny/Workbench",
118+
// `--project-root=.`,
119+
// `--resource-root=./src`,
120+
// "--blueprint-compiler=/app/bin/blueprint-compiler",
121+
// "--no-executable",
122+
// `${path}/src/main.js`,
123+
// `/app/share/${flatpak_id}.src.gresource`,
124+
// ]);
125+
126126
// starts workbench
127127
await runCommand([manifest.command]);
128128

@@ -211,7 +211,7 @@ async function run(_) {
211211
return exec(_, { verbose: argv.verbose });
212212
}
213213

214-
async function exec(argv, { cancellable = null, verbose = false }) {
214+
async function exec(argv, { cancellable = null /*, verbose = false*/ }) {
215215
argv = argv.map((arg) => {
216216
return arg.toString();
217217
});
@@ -220,9 +220,12 @@ async function exec(argv, { cancellable = null, verbose = false }) {
220220

221221
let cancelId = 0;
222222

223-
const flags = verbose
224-
? Gio.SubprocessFlags.NONE
225-
: Gio.SubprocessFlags.STDOUT_SILENCE;
223+
// meson uses stdout for logs
224+
// const flags = verbose
225+
// ? Gio.SubprocessFlags.NONE
226+
// : Gio.SubprocessFlags.STDOUT_SILENCE;
227+
228+
const flags = Gio.SubprocessFlags.NONE;
226229

227230
const proc = new Gio.Subprocess({
228231
argv,

demos

src/Library/Library.js

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,27 @@ export default function Library({ application }) {
4343

4444
const demos = getDemos();
4545
const widgets_map = new Map();
46-
const category_map = new Map();
46+
// const category_map = new Map(
47+
48+
// );
49+
50+
// if (!category_map.has(demo.category)) {
51+
// category_map.set(demo.category, objects[`library_${demo.category}`]);
52+
// }
53+
const categories = [
54+
{ id: "uncategorized", label: _("Uncategorized"), index: 1 },
55+
{ id: "tools", label: _("Tools"), index: 2 },
56+
{ id: "network", label: _("Network"), index: 3 },
57+
{ id: "controls", label: _("Controls"), index: 4 },
58+
{ id: "layout", label: _("Layout"), index: 5 },
59+
{ id: "feedback", label: _("Feedback"), index: 6 },
60+
{ id: "navigation", label: _("Navigation"), index: 7 },
61+
{ id: "user_interface", label: _("User Interface"), index: 8 },
62+
{ id: "platform", label: _("Platform APIs"), index: 9 },
63+
];
64+
categories.forEach((category) => {
65+
category.widget = objects[`library_${category.id}`];
66+
});
4767

4868
const language_model = new Gtk.StringList();
4969
language_model.append(_("Any Language"));
@@ -60,20 +80,8 @@ export default function Library({ application }) {
6080

6181
const category_model = new Gtk.StringList();
6282
category_model.append(_("Any Category"));
83+
categories.forEach((category) => category_model.append(category.label));
6384
dropdown_category.set_model(category_model);
64-
const category_check = [_("Any Category")];
65-
const category_labels = {
66-
uncategorized: _("Uncategorized"),
67-
tools: _("Tools"),
68-
network: _("Network"),
69-
controls: _("Controls"),
70-
layout: _("Layout"),
71-
feedback: _("Feedback"),
72-
navigation: _("Navigation"),
73-
user_interface: _("User Interface"),
74-
platform: _("Platform APIs"),
75-
};
76-
Object.values(category_labels).forEach((str) => category_model.append(str));
7785

7886
demos.forEach((demo) => {
7987
demo.languages.forEach((lang) => {
@@ -82,10 +90,6 @@ export default function Library({ application }) {
8290
}
8391
});
8492

85-
if (!category_check.includes(demo.category)) {
86-
category_check.push(demo.category);
87-
}
88-
8993
const entry_row = new EntryRow({ demo: demo });
9094
if (demo.name === "Welcome") last_triggered = entry_row;
9195

@@ -98,13 +102,13 @@ export default function Library({ application }) {
98102
language,
99103
}).catch(console.error);
100104
});
101-
if (!category_map.has(demo.category)) {
102-
category_map.set(demo.category, objects[`library_${demo.category}`]);
103-
}
104-
objects[`library_${demo.category}`].append(entry_row);
105+
const category = categories.find(
106+
(category) => category.id === demo.category,
107+
);
108+
category.widget.append(entry_row);
105109
widgets_map.set(demo.name, {
106110
entry_row,
107-
category_index: category_check.indexOf(demo.category),
111+
category_index: category.index,
108112
languages_index: demo.languages.map((lang) =>
109113
language_check.indexOf(lang),
110114
),
@@ -132,19 +136,21 @@ export default function Library({ application }) {
132136
entry_row.visible = is_match;
133137
if (is_match) {
134138
results_found = true;
135-
visible_categories.add(category_check[category_index]);
139+
visible_categories.add(
140+
categories.find((cat) => cat.index === category_index).id,
141+
);
136142
}
137143
},
138144
);
139145

140-
category_map.forEach((category_widget, category_name) => {
141-
const label = objects[`label_${category_name}`];
146+
categories.forEach((category) => {
147+
const label = objects[`label_${category.id}`];
142148
if (label)
143149
label.visible =
144150
current_category === 0 &&
145151
current_language === 0 &&
146152
search_term === "";
147-
category_widget.visible = visible_categories.has(category_name);
153+
category.widget.visible = visible_categories.has(category.id);
148154
});
149155
results_empty.set_visible(!results_found);
150156
}

0 commit comments

Comments
 (0)