imageView: Remove expression for fullscreen icon
This commit is contained in:
parent
fceec31971
commit
33bcd4a7ac
4 changed files with 16 additions and 15 deletions
|
|
@ -829,7 +829,8 @@ impl LpImage {
|
||||||
async fn set_file_loaded(&self, file: &gio::File) {
|
async fn set_file_loaded(&self, file: &gio::File) {
|
||||||
let imp = self.imp();
|
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()));
|
imp.file.replace(Some(file.clone()));
|
||||||
self.reload_file_info().await;
|
self.reload_file_info().await;
|
||||||
self.setup_file_monitor().await;
|
self.setup_file_monitor().await;
|
||||||
|
|
@ -845,7 +846,8 @@ impl LpImage {
|
||||||
imp.file.replace(Some(file.clone()));
|
imp.file.replace(Some(file.clone()));
|
||||||
self.reload_file_info().await;
|
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 {
|
if self.metadata().mime_type() != prev_mime_type {
|
||||||
self.load(file).await;
|
self.load(file).await;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,8 @@ mod imp {
|
||||||
pub(super) controls_box_end: TemplateChild<gtk::Widget>,
|
pub(super) controls_box_end: TemplateChild<gtk::Widget>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub(super) controls_box_end_events: TemplateChild<gtk::EventControllerMotion>,
|
pub(super) controls_box_end_events: TemplateChild<gtk::EventControllerMotion>,
|
||||||
|
#[template_child]
|
||||||
|
pub(super) fullscreen_button: TemplateChild<gtk::Button>,
|
||||||
|
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub sliding_view: TemplateChild<LpSlidingView>,
|
pub sliding_view: TemplateChild<LpSlidingView>,
|
||||||
|
|
@ -102,7 +104,6 @@ mod imp {
|
||||||
|
|
||||||
fn class_init(klass: &mut Self::Class) {
|
fn class_init(klass: &mut Self::Class) {
|
||||||
Self::bind_template(klass);
|
Self::bind_template(klass);
|
||||||
Self::Type::bind_template_callbacks(klass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||||
|
|
@ -275,7 +276,6 @@ glib::wrapper! {
|
||||||
@implements gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
|
@implements gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gtk::template_callbacks]
|
|
||||||
impl LpImageView {
|
impl LpImageView {
|
||||||
pub fn set_images_from_files(&self, files: Vec<gio::File>) {
|
pub fn set_images_from_files(&self, files: Vec<gio::File>) {
|
||||||
// Add image to recently used file. Does not work in Flatpaks:
|
// Add image to recently used file. Does not work in Flatpaks:
|
||||||
|
|
@ -622,13 +622,14 @@ impl LpImageView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
pub fn on_fullscreen_changed(&self, is_fullscreened: bool) {
|
||||||
fn get_fullscreen_icon(&self, fullscreened: bool) -> &'static str {
|
let icon = if is_fullscreened {
|
||||||
if fullscreened {
|
|
||||||
"view-restore-symbolic"
|
"view-restore-symbolic"
|
||||||
} else {
|
} else {
|
||||||
"view-fullscreen-symbolic"
|
"view-fullscreen-symbolic"
|
||||||
}
|
};
|
||||||
|
|
||||||
|
self.imp().fullscreen_button.set_icon_name(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn zoom_out(&self) {
|
pub fn zoom_out(&self) {
|
||||||
|
|
|
||||||
|
|
@ -81,13 +81,6 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="fullscreen_button">
|
<object class="GtkButton" id="fullscreen_button">
|
||||||
<property name="halign">end</property>
|
<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="action-name">win.toggle-fullscreen</property>
|
||||||
<property name="tooltip-text" translatable="yes">Toggle Fullscreen</property>
|
<property name="tooltip-text" translatable="yes">Toggle Fullscreen</property>
|
||||||
<style>
|
<style>
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,7 @@ mod imp {
|
||||||
);
|
);
|
||||||
|
|
||||||
obj.on_current_page_changed();
|
obj.on_current_page_changed();
|
||||||
|
obj.on_fullscreen_changed();
|
||||||
|
|
||||||
self.image_view.connect_current_page_notify(
|
self.image_view.connect_current_page_notify(
|
||||||
glib::clone!(@weak obj => move |_| obj.on_current_page_changed()),
|
glib::clone!(@weak obj => move |_| obj.on_current_page_changed()),
|
||||||
|
|
@ -1002,6 +1003,10 @@ impl LpWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_fullscreen_changed(&self) {
|
fn on_fullscreen_changed(&self) {
|
||||||
|
self.imp()
|
||||||
|
.image_view
|
||||||
|
.on_fullscreen_changed(self.is_fullscreened());
|
||||||
|
|
||||||
self.update_headerbar_style();
|
self.update_headerbar_style();
|
||||||
|
|
||||||
if !self.is_fullscreened() {
|
if !self.is_fullscreened() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue