window: Add status pages
This commit is contained in:
@@ -47,6 +47,10 @@ template $Window: Adw.ApplicationWindow {
|
|||||||
Adw.NavigationPage {
|
Adw.NavigationPage {
|
||||||
title: bind template.title;
|
title: bind template.title;
|
||||||
|
|
||||||
|
styles [
|
||||||
|
"view",
|
||||||
|
]
|
||||||
|
|
||||||
child: Adw.ToolbarView {
|
child: Adw.ToolbarView {
|
||||||
[top]
|
[top]
|
||||||
Adw.HeaderBar {
|
Adw.HeaderBar {
|
||||||
@@ -125,68 +129,102 @@ template $Window: Adw.ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content: ScrolledWindow {
|
content: Adw.ViewStack {
|
||||||
hscrollbar-policy: never;
|
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>;
|
||||||
|
|
||||||
child: GridView grid {
|
Adw.ViewStackPage {
|
||||||
name: "grid";
|
name: "grid";
|
||||||
single-click-activate: true;
|
|
||||||
activate => $_activate_game();
|
|
||||||
|
|
||||||
model: NoSelection {
|
child: ScrolledWindow {
|
||||||
model: SortListModel {
|
hscrollbar-policy: never;
|
||||||
sorter: CustomSorter sorter {};
|
|
||||||
|
|
||||||
model: FilterListModel {
|
child: GridView grid {
|
||||||
watch-items: true;
|
name: "grid";
|
||||||
|
single-click-activate: true;
|
||||||
|
activate => $_activate_game();
|
||||||
|
|
||||||
filter: EveryFilter {
|
model: NoSelection {
|
||||||
AnyFilter {
|
model: SortListModel {
|
||||||
StringFilter {
|
sorter: CustomSorter sorter {};
|
||||||
expression: expr item as <$Game>.name;
|
|
||||||
search: bind template.search-text;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringFilter {
|
model: FilterListModel {
|
||||||
expression: expr item as <$Game>.developer;
|
watch-items: true;
|
||||||
search: bind template.search-text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BoolFilter {
|
filter: EveryFilter {
|
||||||
expression: expr item as <$Game>.hidden;
|
AnyFilter {
|
||||||
invert: bind template.show-hidden inverted;
|
StringFilter {
|
||||||
}
|
expression: expr item as <$Game>.name;
|
||||||
|
search: bind template.search-text;
|
||||||
|
}
|
||||||
|
|
||||||
BoolFilter {
|
StringFilter {
|
||||||
expression: expr item as <$Game>.removed;
|
expression: expr item as <$Game>.developer;
|
||||||
invert: true;
|
search: bind template.search-text;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BoolFilter {
|
BoolFilter {
|
||||||
expression: expr item as <$Game>.blacklisted;
|
expression: expr item as <$Game>.hidden;
|
||||||
invert: true;
|
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;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
model: bind template.games;
|
factory: BuilderListItemFactory {
|
||||||
|
template ListItem {
|
||||||
|
child: $GameItem {
|
||||||
|
game: bind template.item;
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
factory: BuilderListItemFactory {
|
Adw.ViewStackPage {
|
||||||
template ListItem {
|
name: "empty-search";
|
||||||
child: $GameItem {
|
|
||||||
game: bind template.item;
|
child: Adw.StatusPage {
|
||||||
};
|
icon-name: "edit-find-symbolic";
|
||||||
}
|
title: _("No Games Found");
|
||||||
|
description: _("Try a different search");
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
};
|
|
||||||
|
|
||||||
styles [
|
Adw.ViewStackPage {
|
||||||
"view",
|
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");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import locale
|
|||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from typing import Any
|
from typing import Any, TypeVar
|
||||||
|
|
||||||
from gi.repository import Adw, Gdk, Gio, GLib, GObject, Gtk
|
from gi.repository import Adw, Gdk, Gio, GLib, GObject, Gtk
|
||||||
|
|
||||||
@@ -25,6 +25,8 @@ SORT_MODES = {
|
|||||||
"oldest": ("added", True),
|
"oldest": ("added", True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
|
||||||
@Gtk.Template.from_resource(f"{PREFIX}/window.ui")
|
@Gtk.Template.from_resource(f"{PREFIX}/window.ui")
|
||||||
class Window(Adw.ApplicationWindow):
|
class Window(Adw.ApplicationWindow):
|
||||||
@@ -83,6 +85,10 @@ class Window(Adw.ApplicationWindow):
|
|||||||
),
|
),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@Gtk.Template.Callback()
|
||||||
|
def _if_else(self, _obj, condition: bool, first: _T, second: _T) -> _T:
|
||||||
|
return first if condition else second
|
||||||
|
|
||||||
@Gtk.Template.Callback()
|
@Gtk.Template.Callback()
|
||||||
def _activate_game(self, grid: Gtk.GridView, position: int):
|
def _activate_game(self, grid: Gtk.GridView, position: int):
|
||||||
if isinstance(model := grid.props.model, Gio.ListModel):
|
if isinstance(model := grid.props.model, Gio.ListModel):
|
||||||
|
|||||||
Reference in New Issue
Block a user