window: Fix title not changed when no image shown

Closes #279
This commit is contained in:
Sophie Herold 2023-11-29 20:15:42 +01:00
parent 7d36c93029
commit 4b510412e1
4 changed files with 19 additions and 18 deletions

View file

@ -132,6 +132,14 @@ mod imp {
// Manually mange widget layout, see `WidgetImpl` for details
obj.set_layout_manager(None::<gtk::LayoutManager>);
self.sliding_view.connect_current_page_notify(
glib::clone!(@weak obj => move |_| obj.page_changed()),
);
self.sliding_view.connect_target_page_reached(
glib::clone!(@weak obj => move || obj.target_page_reached()),
);
let signal_group = glib::SignalGroup::new::<LpImage>();
obj.connect_notify_local(
Some("current-page"),
@ -574,11 +582,10 @@ impl LpImageView {
self.imp().drag_source.clone()
}
#[template_callback]
fn page_changed_cb(&self) {
self.notify("current-page");
self.notify("is-previous-available");
self.notify("is-next-available");
fn page_changed(&self) {
self.notify_current_page();
self.notify_is_next_available();
self.notify_is_previous_available();
let Some(new_page) = self.current_page() else {
log::debug!("Page changed but no current page");
@ -590,9 +597,8 @@ impl LpImageView {
}
}
#[template_callback]
/// Called when page change animation completed
fn target_page_reached_cb(&self) {
fn target_page_reached(&self) {
let current_page = self.current_page();
if self.imp().preserve_content.get() {