246 lines
6.8 KiB
Plaintext
246 lines
6.8 KiB
Plaintext
using Gtk 4.0;
|
|
using Adw 1;
|
|
|
|
template $Window: Adw.ApplicationWindow {
|
|
realize => $_setup_gamepad_monitor();
|
|
title: _("Cartridges");
|
|
|
|
ShortcutController {
|
|
Shortcut {
|
|
trigger: "<Control>f";
|
|
action: "action(win.search)";
|
|
}
|
|
|
|
Shortcut {
|
|
trigger: "<Control>h";
|
|
action: "action(win.show-hidden)";
|
|
}
|
|
|
|
Shortcut {
|
|
trigger: "<Control>n";
|
|
action: "action(win.add)";
|
|
}
|
|
|
|
Shortcut {
|
|
trigger: "<Control>z";
|
|
action: "action(win.undo)";
|
|
}
|
|
|
|
Shortcut {
|
|
trigger: "<Control>w";
|
|
action: "action(window.close)";
|
|
}
|
|
}
|
|
|
|
content: Adw.NavigationView navigation_view {
|
|
Adw.NavigationPage {
|
|
title: bind template.title;
|
|
tag: "games";
|
|
|
|
styles [
|
|
"view",
|
|
]
|
|
|
|
child: Adw.ToolbarView {
|
|
[top]
|
|
Adw.HeaderBar header_bar {
|
|
title-widget: Adw.Clamp clamp {
|
|
tightening-threshold: bind clamp.maximum-size;
|
|
|
|
child: CenterBox title_box {
|
|
hexpand: true;
|
|
|
|
center-widget: SearchEntry search_entry {
|
|
hexpand: true;
|
|
placeholder-text: _("Search games");
|
|
search-started => $_search_started();
|
|
search-changed => $_search_changed();
|
|
activate => $_search_activate();
|
|
stop-search => $_stop_search();
|
|
};
|
|
|
|
end-widget: MenuButton sort_button {
|
|
icon-name: "filter-symbolic";
|
|
tooltip-text: _("Sort & Filter");
|
|
margin-start: 6;
|
|
|
|
menu-model: menu {
|
|
section {
|
|
label: _("Sort");
|
|
|
|
item {
|
|
label: _("Last Played");
|
|
action: "win.sort-mode";
|
|
target: "last_played";
|
|
}
|
|
|
|
item {
|
|
label: _("A-Z");
|
|
action: "win.sort-mode";
|
|
target: "a-z";
|
|
}
|
|
|
|
item {
|
|
label: _("Z-A");
|
|
action: "win.sort-mode";
|
|
target: "z-a";
|
|
}
|
|
|
|
item {
|
|
label: _("Newest");
|
|
action: "win.sort-mode";
|
|
target: "newest";
|
|
}
|
|
|
|
item {
|
|
label: _("Oldest");
|
|
action: "win.sort-mode";
|
|
target: "oldest";
|
|
}
|
|
}
|
|
|
|
section {
|
|
item (_("Show Hidden Games"), "win.show-hidden")
|
|
}
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
[start]
|
|
Button {
|
|
icon-name: "list-add-symbolic";
|
|
tooltip-text: _("Add Game");
|
|
action-name: "win.add";
|
|
}
|
|
|
|
[end]
|
|
MenuButton main_menu_button {
|
|
icon-name: "open-menu-symbolic";
|
|
tooltip-text: _("Main Menu");
|
|
primary: true;
|
|
|
|
menu-model: menu {
|
|
item (_("Keyboard Shortcuts"), "app.shortcuts")
|
|
item (_("About Cartridges"), "app.about")
|
|
};
|
|
}
|
|
}
|
|
|
|
content: Adw.ToastOverlay toast_overlay {
|
|
child: Adw.ViewStack {
|
|
enable-transitions: true;
|
|
visible-child-name: bind $_if_else(
|
|
grid.model as <NoSelection>.n-items,
|
|
"grid",
|
|
$_if_else(
|
|
template.search-text,
|
|
"empty-search",
|
|
$_if_else(template.show-hidden, "empty-hidden", "empty") as <string>
|
|
) as <string>
|
|
) as <string>;
|
|
|
|
Adw.ViewStackPage {
|
|
name: "grid";
|
|
|
|
child: ScrolledWindow {
|
|
hscrollbar-policy: never;
|
|
|
|
child: GridView grid {
|
|
name: "grid";
|
|
single-click-activate: true;
|
|
activate => $_show_details();
|
|
|
|
model: NoSelection {
|
|
model: SortListModel {
|
|
sorter: $GameSorter sorter {};
|
|
|
|
model: FilterListModel {
|
|
watch-items: true;
|
|
|
|
filter: EveryFilter {
|
|
AnyFilter {
|
|
StringFilter {
|
|
expression: expr item as <$Game>.name;
|
|
search: bind template.search-text;
|
|
}
|
|
|
|
StringFilter {
|
|
expression: expr item as <$Game>.developer;
|
|
search: bind template.search-text;
|
|
}
|
|
}
|
|
|
|
BoolFilter {
|
|
expression: expr item as <$Game>.hidden;
|
|
invert: bind template.show-hidden inverted;
|
|
}
|
|
|
|
BoolFilter {
|
|
expression: expr item as <$Game>.removed;
|
|
invert: true;
|
|
}
|
|
|
|
BoolFilter {
|
|
expression: expr item as <$Game>.blacklisted;
|
|
invert: true;
|
|
}
|
|
};
|
|
|
|
model: bind template.games;
|
|
};
|
|
};
|
|
};
|
|
|
|
factory: BuilderListItemFactory {
|
|
template ListItem {
|
|
child: $GameItem {
|
|
game: bind template.item;
|
|
position: bind template.position;
|
|
};
|
|
}
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
Adw.ViewStackPage {
|
|
name: "empty-search";
|
|
|
|
child: Adw.StatusPage {
|
|
icon-name: "edit-find-symbolic";
|
|
title: _("No Games Found");
|
|
description: _("Try a different search");
|
|
};
|
|
}
|
|
|
|
Adw.ViewStackPage {
|
|
name: "empty-hidden";
|
|
|
|
child: Adw.StatusPage {
|
|
icon-name: "view-conceal-symbolic";
|
|
title: _("No Hidden Games");
|
|
description: _("Games you hide will appear here");
|
|
};
|
|
}
|
|
|
|
Adw.ViewStackPage {
|
|
name: "empty";
|
|
|
|
child: Adw.StatusPage {
|
|
icon-name: bind template.application as <Application>.application-id;
|
|
title: _("No Games");
|
|
description: _("Use the + button to add games");
|
|
};
|
|
}
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
$GameDetails details {
|
|
sort-changed => $_sort_changed();
|
|
}
|
|
};
|
|
}
|