Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Sep 23, 2024
1 parent b96b41d commit 7d0aa6c
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 71 deletions.
42 changes: 22 additions & 20 deletions build-aux/wip/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,30 @@ if (!exists(`${path}/.flatpak/repo`)) {
}

if (!exists(`${path}/.flatpak/flatpak-builder`)) {
const module_name = app_module.name;

const manifest_relative_path =
Gio.File.new_for_path(path).get_relative_path(manifest_file);

const prefix = [
"flatpak-builder",
"--ccache",
"--force-clean",
"--disable-updates",
];

const suffix = [
`--state-dir=${path}/.flatpak/flatpak-builder`,
`--stop-at=${module_name}`,
`${path}/.flatpak/repo`,
manifest_relative_path,
];
await downloadSources();
await buildModules();
}

// downloads sources (de-initializes)
const prefix = [
"flatpak-builder",
"--ccache",
"--force-clean",
"--disable-updates",
];
const suffix = [
`--state-dir=${path}/.flatpak/flatpak-builder`,
`--stop-at=${app_module.name}`,
`${path}/.flatpak/repo`,
Gio.File.new_for_path(path).get_relative_path(manifest_file),
];

// de-initializes
async function downloadSources() {
await run([...prefix, "--download-only", ...suffix]);
// builds modules (de-initializes)
}

// de-initializes
async function buildModules() {
await run([
...prefix,
"--disable-download",
Expand Down
52 changes: 31 additions & 21 deletions src/Library/Library.blp
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ Adw.Window window {
]
}

SearchEntry search_entry {
search-delay: 100;
placeholder-text: _("Search demos");
activates-default: true;
width-request: 400;
margin-top: 32;
}
}
Box {
spacing: 6;

SearchEntry search_entry {
search-delay: 100;
placeholder-text: _("Search demos");
activates-default: true;
hexpand: true;
margin-top: 32;
}

Box {
DropDown dropdown_language {
halign: end;
margin-end: 12;
hexpand: true;
}
DropDown dropdown_language {
valign: end;
}

DropDown dropdown_category {
halign: end;
DropDown dropdown_category {
valign: end;
}
}
}

Expand Down Expand Up @@ -229,15 +229,25 @@ Adw.Window window {
margin-top: 12;
orientation: vertical;

Label results_empty {
Box results_empty {
orientation: vertical;
visible: false;
margin-top: 46;
margin-bottom: 70;
label: _("No results");
spacing: 6;

styles [
"title-4"
]
Label {
label: _("No results");

styles [
"title-4"
]
}

Button button_reset {
label: _("Reset filters");
halign: center;
}
}

Label {
Expand Down
56 changes: 26 additions & 30 deletions src/Library/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
decode,
demos_dir,
getLanguage,
makeDropdownFlat,
settings as global_settings,
quitOnLastWindowClose,
} from "../util.js";
Expand All @@ -29,63 +28,62 @@ export default function Library({ application }) {
dropdown_category,
dropdown_language,
results_empty,
button_reset,
} = objects;
window.application = application;
picture_illustration.set_resource(illustration);
makeDropdownFlat(dropdown_category);
makeDropdownFlat(dropdown_language);

if (__DEV__) {
window.add_css_class("devel");
}

let last_triggered;
let current_category = 0;
let current_language = 0;

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

const demos = getDemos();
const widgets_map = new Map();
const category_map = new Map();
const language_model = new Gtk.StringList();
const category_model = new Gtk.StringList();
language_model.append(_("All Languages"));
category_model.append(_("All Categories"));
const language_check = [_("All Languages")];
const category_check = [_("All Categories")];

const language_model = new Gtk.StringList();
language_model.append(_("Any Language"));
dropdown_language.set_model(language_model);
const language_check = [_("Any Language")];
const language_labels = {
javascript: _("JavaScript"),
python: _("Python"),
rust: _("Rust"),
vala: _("Vala"),
typescript: _("TypeScript"),
};
Object.values(language_labels).forEach((str) => language_model.push(str));

const category_model = new Gtk.StringList();
category_model.append(_("Any Category"));
dropdown_category.set_model(category_model);
const category_check = [_("Any Category")];
const category_labels = {
user_interface: _("User Interface"),
platform: _("Platform APIs"),
uncategorized: _("Uncategorized"),
tools: _("Tools"),
network: _("Network"),
controls: _("Controls"),
feedback: _("Feedback"),
layout: _("Layout"),
network: _("Network"),
feedback: _("Feedback"),
navigation: _("Navigation"),
tools: _("Tools"),
uncategorized: _("Uncategorized"),
user_interface: _("User Interface"),
platform: _("Platform APIs"),
};
Object.values(category_labels).forEach((str) => category_model.push(str));

demos.forEach((demo) => {
demo.languages.forEach((lang) => {
if (!language_check.includes(lang)) {
language_check.push(lang);
language_model.append(language_labels[lang]);
}
});

if (!category_check.includes(demo.category)) {
category_check.push(demo.category);
category_model.append(category_labels[demo.category]);
}

const entry_row = new EntryRow({ demo: demo });
Expand Down Expand Up @@ -113,10 +111,10 @@ export default function Library({ application }) {
});
});

dropdown_language.set_model(language_model);
dropdown_category.set_model(category_model);

function updateList() {
const current_category = dropdown_category.get_selected();
const current_language = dropdown_language.get_selected();

const search_term = search_entry.get_text().toLowerCase();
const visible_categories = new Set();
let results_found = false;
Expand Down Expand Up @@ -152,15 +150,13 @@ export default function Library({ application }) {
}

search_entry.connect("search-changed", updateList);
dropdown_category.connect("notify::selected", updateList);
dropdown_language.connect("notify::selected", updateList);

dropdown_category.connect("notify::selected", () => {
current_category = dropdown_category.get_selected();
updateList();
});

dropdown_language.connect("notify::selected", () => {
current_language = dropdown_language.get_selected();
updateList();
button_reset.connect("clicked", () => {
search_entry.text = "";
dropdown_category.selected = 0;
dropdown_language.selected = 0;
});

const action_library = new Gio.SimpleAction({
Expand Down

0 comments on commit 7d0aa6c

Please sign in to comment.