diff --git a/resources/ui/item.ui b/resources/ui/item.ui
index ae0be467..9cff20c8 100644
--- a/resources/ui/item.ui
+++ b/resources/ui/item.ui
@@ -40,11 +40,11 @@
@@ -52,21 +52,52 @@
-
- never
- fill
- 3
+
+ 700
+ False
-
- 700
- False
+
+ never
+ fill
+ 3
horizontal
diff --git a/src/ui/widgets/item.rs b/src/ui/widgets/item.rs
index 5c7abb03..ca7587f1 100644
--- a/src/ui/widgets/item.rs
+++ b/src/ui/widgets/item.rs
@@ -1,6 +1,8 @@
use glib::Object;
use gtk::prelude::*;
use gtk::{gio, glib};
+use adw::subclass::prelude::*;
+
mod imp {
use crate::ui::network::{self, runtime};
use adw::subclass::prelude::*;
@@ -45,6 +47,18 @@ mod imp {
fn class_init(klass: &mut Self::Class) {
klass.bind_template();
+ klass.install_action("item.first", None, move |window, _action, _parameter| {
+ window.itemfirst();
+ });
+ klass.install_action("item.previous", None, move |window, _action, _parameter| {
+ window.itemprevious();
+ });
+ klass.install_action("item.next", None, move |window, _action, _parameter| {
+ window.itemnext();
+ });
+ klass.install_action("item.last", None, move |window, _action, _parameter| {
+ window.itemlast();
+ });
}
fn instance_init(obj: &InitializingObject) {
@@ -267,4 +281,32 @@ impl ItemPage {
osd.append(&logo);
osd.add_css_class("logo");
}
+
+ pub fn itemfirst(&self) {
+ let imp = self.imp();
+ imp.itemlist.scroll_to(0, gtk::ListScrollFlags::SELECT, None);
+ }
+
+ pub fn itemprevious(&self) {
+ let imp = self.imp();
+ let selection = &imp.selection;
+ let position = selection.selected();
+ if position > 0 {
+ imp.itemlist.scroll_to(position - 1, gtk::ListScrollFlags::SELECT, None);
+ }
+ }
+
+ pub fn itemnext(&self) {
+ let imp = self.imp();
+ let selection = &imp.selection;
+ let position = selection.selected();
+ if position < imp.itemlist.model().unwrap().n_items() {
+ imp.itemlist.scroll_to(position + 1, gtk::ListScrollFlags::SELECT, None);
+ }
+ }
+
+ pub fn itemlast(&self) {
+ let imp = self.imp();
+ imp.itemlist.scroll_to(imp.itemlist.model().unwrap().n_items() - 1, gtk::ListScrollFlags::SELECT, None);
+ }
}