parent
7d36c93029
commit
4b510412e1
4 changed files with 19 additions and 18 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,7 @@
|
|||
<object class="GtkOverlay" id="bin_child">
|
||||
<property name="hexpand">True</property>
|
||||
<child>
|
||||
<object class="LpSlidingView" id="sliding_view">
|
||||
<signal name="notify::current-page" handler="page_changed_cb" swapped="yes" />
|
||||
<signal name="target-page-reached" handler="target_page_reached_cb" swapped="yes" />
|
||||
</object>
|
||||
<object class="LpSlidingView" id="sliding_view" />
|
||||
</child>
|
||||
<child type="overlay">
|
||||
<object class="GtkBox" id="controls_box_start">
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
use crate::config;
|
||||
use crate::util::{self, Direction, Position};
|
||||
use crate::widgets::{LpDragOverlay, LpImage, LpImageView, LpPropertiesView};
|
||||
use crate::widgets::{LpDragOverlay, LpImage, LpImagePage, LpImageView, LpPropertiesView};
|
||||
|
||||
/// Show window after X milliseconds even if image dimensions are not known yet
|
||||
const SHOW_WINDOW_AFTER: u64 = 2000;
|
||||
|
|
@ -884,7 +884,9 @@ impl LpWindow {
|
|||
// have multiple `match` or `if let` branches, and without needing
|
||||
// to unwrap.
|
||||
#[template_callback]
|
||||
fn window_title(&self, file: Option<&gio::File>) -> String {
|
||||
fn window_title(&self, current_page: Option<&LpImagePage>) -> String {
|
||||
let file = current_page.and_then(|x| x.image().file());
|
||||
|
||||
// ensure that templates are initialized
|
||||
if file.is_none() {
|
||||
gettext("Image Viewer")
|
||||
|
|
|
|||
|
|
@ -65,11 +65,7 @@
|
|||
<signal name="notify::fullscreened" handler="on_fullscreened" swapped="yes" />
|
||||
<binding name="title">
|
||||
<closure type="gchararray" function="window_title">
|
||||
<lookup name="file">
|
||||
<lookup name="image">
|
||||
<lookup name="current-page">image_view</lookup>
|
||||
</lookup>
|
||||
</lookup>
|
||||
<lookup name="current-page">image_view</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<child>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue