window: Put prev/next accels at window level
Tried to make things more stateless and RefCell usage for robust - Use object properties to control the action enabled/disabled - Borrow model RefCell for only one line or use .replace() - Don't pass models around and borrow as short as possible instead Fixes #20
This commit is contained in:
parent
ba77ee1a32
commit
36000ff65c
4 changed files with 102 additions and 48 deletions
|
|
@ -101,6 +101,18 @@ mod imp {
|
|||
win.toggle_fullscreen(!win.is_fullscreened());
|
||||
});
|
||||
|
||||
klass.install_action("win.next", None, move |win, _, _| {
|
||||
win.imp()
|
||||
.image_view
|
||||
.navigate(adw::NavigationDirection::Forward);
|
||||
});
|
||||
|
||||
klass.install_action("win.previous", None, move |win, _, _| {
|
||||
win.imp()
|
||||
.image_view
|
||||
.navigate(adw::NavigationDirection::Back);
|
||||
});
|
||||
|
||||
klass.install_action("win.zoom-out", None, move |win, _, _| {
|
||||
win.zoom_out();
|
||||
});
|
||||
|
|
@ -219,6 +231,28 @@ mod imp {
|
|||
}),
|
||||
);
|
||||
|
||||
// action win.previous status
|
||||
self.image_view.connect_notify_local(
|
||||
Some("is-previous-available"),
|
||||
glib::clone!(@weak obj => move |_, _| {
|
||||
obj.action_set_enabled(
|
||||
"win.previous",
|
||||
obj.imp().image_view.is_previous_available(),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
// action win.next status
|
||||
self.image_view.connect_notify_local(
|
||||
Some("is-next-available"),
|
||||
glib::clone!(@weak obj => move |_, _| {
|
||||
obj.action_set_enabled(
|
||||
"win.next",
|
||||
obj.imp().image_view.is_next_available(),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
self.status_page
|
||||
.set_icon_name(Some(&format!("{}-symbolic", config::APP_ID)));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue