scroll buttons in carousels, sooort of
This commit is contained in:
parent
a63ca1c556
commit
f72f3044c1
2 changed files with 18 additions and 2 deletions
|
@ -26,7 +26,6 @@ template $AudreyUiAlbumCarousel: Adw.Bin {
|
|||
Button {
|
||||
valign: center;
|
||||
icon-name: "view-refresh-symbolic";
|
||||
sensitive: bind template.refresh-button-inactive inverted,
|
||||
clicked => $on_refresh_clicked() swapped;
|
||||
|
||||
styles [
|
||||
|
@ -42,6 +41,7 @@ template $AudreyUiAlbumCarousel: Adw.Bin {
|
|||
|
||||
Button {
|
||||
icon-name: "go-previous-symbolic";
|
||||
clicked => $on_scroll_left_clicked() swapped;
|
||||
|
||||
styles [
|
||||
"flat"
|
||||
|
@ -50,6 +50,7 @@ template $AudreyUiAlbumCarousel: Adw.Bin {
|
|||
|
||||
Button {
|
||||
icon-name: "go-next-symbolic";
|
||||
clicked => $on_scroll_right_clicked() swapped;
|
||||
|
||||
styles [
|
||||
"flat"
|
||||
|
@ -64,7 +65,7 @@ template $AudreyUiAlbumCarousel: Adw.Bin {
|
|||
]
|
||||
}
|
||||
|
||||
ScrolledWindow {
|
||||
ScrolledWindow scrolled {
|
||||
hexpand: true;
|
||||
vscrollbar-policy: never;
|
||||
hscrollbar-policy: external;
|
||||
|
|
|
@ -39,6 +39,9 @@ mod imp {
|
|||
|
||||
refresh_button_inactive: Cell<bool>,
|
||||
update_handle: Cell<Option<glib::JoinHandle<()>>>,
|
||||
|
||||
#[template_child]
|
||||
scrolled: TemplateChild<gtk::ScrolledWindow>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
@ -176,6 +179,18 @@ mod imp {
|
|||
fn on_refresh_clicked(&self) {
|
||||
self.update_model();
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn on_scroll_left_clicked(&self) {
|
||||
let adj = self.scrolled.hadjustment();
|
||||
adj.set_value(adj.value() - adj.page_size());
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn on_scroll_right_clicked(&self) {
|
||||
let adj = self.scrolled.hadjustment();
|
||||
adj.set_value(adj.value() + adj.page_size());
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for AlbumCarousel {
|
||||
|
|
Loading…
Reference in a new issue