From 33bcd4a7ac6e506495576e2dc16d07626db68983 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Mon, 4 Dec 2023 18:22:47 +0100 Subject: [PATCH] imageView: Remove expression for fullscreen icon --- src/widgets/image.rs | 6 ++++-- src/widgets/image_view.rs | 13 +++++++------ src/widgets/image_view.ui | 7 ------- src/window.rs | 5 +++++ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/widgets/image.rs b/src/widgets/image.rs index 0e8f9d8..352632d 100644 --- a/src/widgets/image.rs +++ b/src/widgets/image.rs @@ -829,7 +829,8 @@ impl LpImage { async fn set_file_loaded(&self, file: &gio::File) { let imp = self.imp(); - // Do not check if same file since it might be set via initialized with `Self::init` before + // Do not check if same file since it might be set via initialized with + // `Self::init` before imp.file.replace(Some(file.clone())); self.reload_file_info().await; self.setup_file_monitor().await; @@ -845,7 +846,8 @@ impl LpImage { imp.file.replace(Some(file.clone())); self.reload_file_info().await; - // Reload if mime type changed since other decoding path might be responsible now + // Reload if mime type changed since other decoding path might be responsible + // now if self.metadata().mime_type() != prev_mime_type { self.load(file).await; return; diff --git a/src/widgets/image_view.rs b/src/widgets/image_view.rs index 4a84f83..b53d5e5 100644 --- a/src/widgets/image_view.rs +++ b/src/widgets/image_view.rs @@ -73,6 +73,8 @@ mod imp { pub(super) controls_box_end: TemplateChild, #[template_child] pub(super) controls_box_end_events: TemplateChild, + #[template_child] + pub(super) fullscreen_button: TemplateChild, #[template_child] pub sliding_view: TemplateChild, @@ -102,7 +104,6 @@ mod imp { fn class_init(klass: &mut Self::Class) { Self::bind_template(klass); - Self::Type::bind_template_callbacks(klass); } fn instance_init(obj: &glib::subclass::InitializingObject) { @@ -275,7 +276,6 @@ glib::wrapper! { @implements gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable; } -#[gtk::template_callbacks] impl LpImageView { pub fn set_images_from_files(&self, files: Vec) { // Add image to recently used file. Does not work in Flatpaks: @@ -622,13 +622,14 @@ impl LpImageView { } } - #[template_callback] - fn get_fullscreen_icon(&self, fullscreened: bool) -> &'static str { - if fullscreened { + pub fn on_fullscreen_changed(&self, is_fullscreened: bool) { + let icon = if is_fullscreened { "view-restore-symbolic" } else { "view-fullscreen-symbolic" - } + }; + + self.imp().fullscreen_button.set_icon_name(icon); } pub fn zoom_out(&self) { diff --git a/src/widgets/image_view.ui b/src/widgets/image_view.ui index 7766a31..829255e 100644 --- a/src/widgets/image_view.ui +++ b/src/widgets/image_view.ui @@ -81,13 +81,6 @@ end - - - - LpImageView - - - win.toggle-fullscreen Toggle Fullscreen