imageView: Remove expression for fullscreen icon

This commit is contained in:
Sophie Herold 2023-12-04 18:22:47 +01:00
parent fceec31971
commit 33bcd4a7ac
4 changed files with 16 additions and 15 deletions

View file

@ -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;

View file

@ -73,6 +73,8 @@ mod imp {
pub(super) controls_box_end: TemplateChild<gtk::Widget>,
#[template_child]
pub(super) controls_box_end_events: TemplateChild<gtk::EventControllerMotion>,
#[template_child]
pub(super) fullscreen_button: TemplateChild<gtk::Button>,
#[template_child]
pub sliding_view: TemplateChild<LpSlidingView>,
@ -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<Self>) {
@ -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<gio::File>) {
// 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) {

View file

@ -81,13 +81,6 @@
<child>
<object class="GtkButton" id="fullscreen_button">
<property name="halign">end</property>
<binding name="icon-name">
<closure type="gchararray" function="get_fullscreen_icon">
<lookup type="GtkWindow" name="fullscreened">
<lookup type="GtkWidget" name="root">LpImageView</lookup>
</lookup>
</closure>
</binding>
<property name="action-name">win.toggle-fullscreen</property>
<property name="tooltip-text" translatable="yes">Toggle Fullscreen</property>
<style>

View file

@ -290,6 +290,7 @@ mod imp {
);
obj.on_current_page_changed();
obj.on_fullscreen_changed();
self.image_view.connect_current_page_notify(
glib::clone!(@weak obj => move |_| obj.on_current_page_changed()),
@ -1002,6 +1003,10 @@ impl LpWindow {
}
fn on_fullscreen_changed(&self) {
self.imp()
.image_view
.on_fullscreen_changed(self.is_fullscreened());
self.update_headerbar_style();
if !self.is_fullscreened() {