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
|
|
@ -163,6 +163,8 @@ impl LpApplication {
|
||||||
|
|
||||||
self.set_accels_for_action("win.image-left", &["Left", "Page_Down"]);
|
self.set_accels_for_action("win.image-left", &["Left", "Page_Down"]);
|
||||||
self.set_accels_for_action("win.image-right", &["Right", "Page_Up"]);
|
self.set_accels_for_action("win.image-right", &["Right", "Page_Up"]);
|
||||||
|
self.set_accels_for_action("win.image-left-instant", &["<Alt>Left"]);
|
||||||
|
self.set_accels_for_action("win.image-right-instant", &["<Alt>Right"]);
|
||||||
self.set_accels_for_action("win.first", &["Home"]);
|
self.set_accels_for_action("win.first", &["Home"]);
|
||||||
self.set_accels_for_action("win.last", &["End"]);
|
self.set_accels_for_action("win.last", &["End"]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ impl LpImageView {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Move forward or backwards
|
/// 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() {
|
if let Some(current_file) = self.current_file() {
|
||||||
let new_file = match direction {
|
let new_file = match direction {
|
||||||
Direction::Forward => self.model().after(¤t_file),
|
Direction::Forward => self.model().after(¤t_file),
|
||||||
|
|
@ -362,7 +362,7 @@ impl LpImageView {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(new_file) = new_file {
|
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");
|
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 {
|
let Some(current_page) = self.sliding_view().pages().swap_remove(&file.uri()) else {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Current path not available in sliding_view for scrolling: {}",
|
"Current path not available in sliding_view for scrolling: {}",
|
||||||
|
|
@ -461,7 +461,11 @@ impl LpImageView {
|
||||||
return;
|
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 {
|
fn sliding_view(&self) -> LpSlidingView {
|
||||||
|
|
@ -531,7 +535,7 @@ impl LpImageView {
|
||||||
if self.model().contains(&trash_restore) {
|
if self.model().contains(&trash_restore) {
|
||||||
self.set_trash_restore(gio::File::NONE);
|
self.set_trash_restore(gio::File::NONE);
|
||||||
self.update_sliding_view(&trash_restore);
|
self.update_sliding_view(&trash_restore);
|
||||||
self.scroll_sliding_view(&trash_restore);
|
self.scroll_sliding_view(&trash_restore, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -554,6 +554,16 @@ impl LpSlidingView {
|
||||||
.cloned()
|
.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
|
/// Move to specified page with animation
|
||||||
pub fn animate_to(&self, page: &LpImagePage) {
|
pub fn animate_to(&self, page: &LpImagePage) {
|
||||||
if let Some(index) = self.index_of(page) {
|
if let Some(index) = self.index_of(page) {
|
||||||
|
|
|
||||||
|
|
@ -146,26 +146,42 @@ mod imp {
|
||||||
});
|
});
|
||||||
|
|
||||||
klass.install_action("win.next", None, move |win, _, _| {
|
klass.install_action("win.next", None, move |win, _, _| {
|
||||||
win.imp().image_view.navigate(Direction::Forward);
|
win.imp().image_view.navigate(Direction::Forward, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
klass.install_action("win.previous", None, move |win, _, _| {
|
klass.install_action("win.previous", None, move |win, _, _| {
|
||||||
win.imp().image_view.navigate(Direction::Back);
|
win.imp().image_view.navigate(Direction::Back, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
klass.install_action("win.image-right", None, move |win, _, _| {
|
klass.install_action("win.image-right", None, move |win, _, _| {
|
||||||
if win.direction() == gtk::TextDirection::Rtl {
|
if win.direction() == gtk::TextDirection::Rtl {
|
||||||
win.imp().image_view.navigate(Direction::Back);
|
win.imp().image_view.navigate(Direction::Back, true);
|
||||||
} else {
|
} else {
|
||||||
win.imp().image_view.navigate(Direction::Forward);
|
win.imp().image_view.navigate(Direction::Forward, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
klass.install_action("win.image-right-instant", None, move |win, _, _| {
|
||||||
|
if win.direction() == gtk::TextDirection::Rtl {
|
||||||
|
win.imp().image_view.navigate(Direction::Back, false);
|
||||||
|
} else {
|
||||||
|
win.imp().image_view.navigate(Direction::Forward, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
klass.install_action("win.image-left", None, move |win, _, _| {
|
klass.install_action("win.image-left", None, move |win, _, _| {
|
||||||
if win.direction() == gtk::TextDirection::Rtl {
|
if win.direction() == gtk::TextDirection::Rtl {
|
||||||
win.imp().image_view.navigate(Direction::Forward);
|
win.imp().image_view.navigate(Direction::Forward, true);
|
||||||
} else {
|
} else {
|
||||||
win.imp().image_view.navigate(Direction::Back);
|
win.imp().image_view.navigate(Direction::Back, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
klass.install_action("win.image-left-instant", None, move |win, _, _| {
|
||||||
|
if win.direction() == gtk::TextDirection::Rtl {
|
||||||
|
win.imp().image_view.navigate(Direction::Forward, false);
|
||||||
|
} else {
|
||||||
|
win.imp().image_view.navigate(Direction::Back, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -279,11 +295,11 @@ mod imp {
|
||||||
|
|
||||||
self.forward_click_gesture
|
self.forward_click_gesture
|
||||||
.connect_pressed(clone!(@weak obj => move |_,_,_,_| {
|
.connect_pressed(clone!(@weak obj => move |_,_,_,_| {
|
||||||
obj.image_view().navigate(Direction::Forward);
|
obj.image_view().navigate(Direction::Forward, true);
|
||||||
}));
|
}));
|
||||||
self.backward_click_gesture
|
self.backward_click_gesture
|
||||||
.connect_pressed(clone!(@weak obj => move |_,_,_,_| {
|
.connect_pressed(clone!(@weak obj => move |_,_,_,_| {
|
||||||
obj.image_view().navigate(Direction::Back);
|
obj.image_view().navigate(Direction::Back, true);
|
||||||
}));
|
}));
|
||||||
self.properties_button
|
self.properties_button
|
||||||
.connect_toggled(clone!(@weak obj => move |_| {
|
.connect_toggled(clone!(@weak obj => move |_| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue