Files
cartridges/cartridges/ui/window.blp
2025-12-29 01:29:04 +01:00

344 lines
10 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><Shift>n";
action: "action(win.add-collection)";
arguments: "''";
}
Shortcut {
trigger: "<Control>z";
action: "action(win.undo)";
}
Shortcut {
trigger: "F9";
action: "action(win.show-sidebar)";
}
Shortcut {
trigger: "<Control>w";
action: "action(window.close)";
}
}
Adw.Breakpoint {
condition ("max-width: 730px") // 3 columns + 48px of inherent padding
setters {
split_view.collapsed: true;
}
}
content: Adw.NavigationView navigation_view {
Adw.NavigationPage {
title: bind template.title;
tag: "games";
styles [
"view",
]
child: Adw.OverlaySplitView split_view {
sidebar-width-unit: px;
min-sidebar-width: 224; // Width of 1 column
max-sidebar-width: bind split_view.min-sidebar-width;
sidebar: Adw.NavigationPage {
title: bind template.title;
child: Adw.ToolbarView {
[top]
Adw.HeaderBar {
show-title: bind $_show_sidebar_title(template.settings as <Settings>.gtk-decoration-layout) as <bool>;
[start]
Button {
visible: bind split_view.show-sidebar;
action-name: "win.show-sidebar";
icon-name: "sidebar-show-symbolic";
tooltip-text: _("Toggle Sidebar");
}
}
content: Adw.Sidebar sidebar {
activated => $_navigate();
setup-menu => $_setup_sidebar_menu();
notify::selected => $_update_selection();
Adw.SidebarSection {
Adw.SidebarItem {
icon-name: "view-grid-symbolic";
title: _("All Games");
}
}
Adw.SidebarSection collections {
title: _("Collections");
menu-model: menu collection_menu {};
}
Adw.SidebarSection {
Adw.SidebarItem new_collection_item {
icon-name: "list-add-symbolic";
title: _("New Collection");
}
}
};
};
};
content: Adw.NavigationPage {
title: _("Games");
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 {
visible: bind split_view.show-sidebar inverted;
action-name: "win.show-sidebar";
icon-name: "sidebar-show-symbolic";
tooltip-text: _("Toggle Sidebar");
}
[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 {
visible-child-name: bind $_if_else(
grid.model as <NoSelection>.n-items,
"grid",
$_if_else(
template.search-text,
"empty-search",
$_if_else(
template.collection,
"empty-collection",
$_if_else(template.show-hidden, "empty-hidden", "empty") as <string>
) 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 {
$CollectionFilter collection_filter {
collection: bind template.collection;
}
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.model;
};
};
};
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-collection";
child: Adw.StatusPage {
icon-name: bind template.collection as <$Collection>.icon-name;
title: bind $_format(_("No Games in {}"), template.collection as <$Collection>.name) as <string>;
};
}
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();
}
};
}