window: Add missing shortcuts
Add shortcuts - F9 Image properties - F10 Main menu - Ctrl +/- for zoom - Ctrl 0 for best fit - Ctrl [Shift] R for rotate - Escape to leave fullscrenen Updated help overlay accordingly.
This commit is contained in:
parent
583794a3ec
commit
f1593203a0
5 changed files with 200 additions and 14 deletions
|
|
@ -62,6 +62,8 @@ mod imp {
|
|||
#[template_child]
|
||||
pub headerbar: TemplateChild<gtk::HeaderBar>,
|
||||
#[template_child]
|
||||
pub properties_button: TemplateChild<gtk::ToggleButton>,
|
||||
#[template_child]
|
||||
pub menu_button: TemplateChild<gtk::MenuButton>,
|
||||
#[template_child]
|
||||
pub toast_overlay: TemplateChild<adw::ToastOverlay>,
|
||||
|
|
@ -106,6 +108,20 @@ mod imp {
|
|||
win.zoom_to(level.unwrap().get().unwrap());
|
||||
});
|
||||
|
||||
klass.install_action("win.zoom-best-fit", None, move |win, _, _| {
|
||||
win.zoom_best_fit();
|
||||
});
|
||||
|
||||
klass.install_action("win.leave-fullscreen", None, move |win, _, _| {
|
||||
win.toggle_fullscreen(false);
|
||||
});
|
||||
|
||||
klass.install_action("win.toggle-properties", None, move |win, _, _| {
|
||||
win.imp()
|
||||
.properties_button
|
||||
.set_active(!win.imp().properties_button.is_active());
|
||||
});
|
||||
|
||||
klass.install_action("win.open", None, move |win, _, _| {
|
||||
win.pick_file();
|
||||
});
|
||||
|
|
@ -284,6 +300,12 @@ impl LpWindow {
|
|||
self.imp().image_view.zoom_to(level);
|
||||
}
|
||||
|
||||
fn zoom_best_fit(&self) {
|
||||
if let Some(page) = self.imp().image_view.current_page() {
|
||||
page.image().zoom_best_fit();
|
||||
}
|
||||
}
|
||||
|
||||
fn pick_file(&self) {
|
||||
let chooser = gtk::FileChooserNative::new(
|
||||
Some("Open Image"),
|
||||
|
|
@ -403,6 +425,10 @@ impl LpWindow {
|
|||
self.action_set_enabled("win.print", enabled);
|
||||
self.action_set_enabled("win.rotate", enabled);
|
||||
self.action_set_enabled("win.copy", enabled);
|
||||
self.action_set_enabled("win.zoom-best-fit", enabled);
|
||||
self.action_set_enabled("win.zoom-in", enabled);
|
||||
self.action_set_enabled("win.zoom-to", enabled);
|
||||
self.action_set_enabled("win.toggle-properties", enabled);
|
||||
}
|
||||
|
||||
// Adapted from https://gitlab.gnome.org/GNOME/eog/-/blob/master/src/eog-window.c:eog_window_obtain_desired_size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue