application: Shortcuts for non-animated next/prev
Don't animate switching between images for Alt+Arrow. Closes #45
This commit is contained in:
parent
fc1a44776a
commit
6958f427bd
4 changed files with 45 additions and 13 deletions
|
|
@ -354,7 +354,7 @@ impl LpImageView {
|
|||
}
|
||||
|
||||
/// Move forward or backwards
|
||||
pub fn navigate(&self, direction: Direction) {
|
||||
pub fn navigate(&self, direction: Direction, animated: bool) {
|
||||
if let Some(current_file) = self.current_file() {
|
||||
let new_file = match direction {
|
||||
Direction::Forward => self.model().after(¤t_file),
|
||||
|
|
@ -362,7 +362,7 @@ impl LpImageView {
|
|||
};
|
||||
|
||||
if let Some(new_file) = new_file {
|
||||
self.scroll_sliding_view(&new_file);
|
||||
self.scroll_sliding_view(&new_file, animated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -452,7 +452,7 @@ impl LpImageView {
|
|||
self.notify("is-next-available");
|
||||
}
|
||||
|
||||
fn scroll_sliding_view(&self, file: &gio::File) {
|
||||
fn scroll_sliding_view(&self, file: &gio::File, animated: bool) {
|
||||
let Some(current_page) = self.sliding_view().pages().swap_remove(&file.uri()) else {
|
||||
log::error!(
|
||||
"Current path not available in sliding_view for scrolling: {}",
|
||||
|
|
@ -461,7 +461,11 @@ impl LpImageView {
|
|||
return;
|
||||
};
|
||||
|
||||
self.sliding_view().animate_to(¤t_page);
|
||||
if animated {
|
||||
self.sliding_view().animate_to(¤t_page);
|
||||
} else {
|
||||
self.sliding_view().instant_to(¤t_page);
|
||||
}
|
||||
}
|
||||
|
||||
fn sliding_view(&self) -> LpSlidingView {
|
||||
|
|
@ -531,7 +535,7 @@ impl LpImageView {
|
|||
if self.model().contains(&trash_restore) {
|
||||
self.set_trash_restore(gio::File::NONE);
|
||||
self.update_sliding_view(&trash_restore);
|
||||
self.scroll_sliding_view(&trash_restore);
|
||||
self.scroll_sliding_view(&trash_restore, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -554,6 +554,16 @@ impl LpSlidingView {
|
|||
.cloned()
|
||||
}
|
||||
|
||||
/// Move to specified page without animation
|
||||
pub fn instant_to(&self, page: &LpImagePage) {
|
||||
if let Some(index) = self.index_of(page) {
|
||||
self.set_current_page(Some(page));
|
||||
self.set_position(index as f64 - self.position_shift());
|
||||
} else {
|
||||
log::error!("Page not in LpSlidingView {}", page.file().uri());
|
||||
}
|
||||
}
|
||||
|
||||
/// Move to specified page with animation
|
||||
pub fn animate_to(&self, page: &LpImagePage) {
|
||||
if let Some(index) = self.index_of(page) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue