edit/crop: Pre-select correct orientation
This commit is contained in:
parent
c97db38788
commit
a2147bb8bd
1 changed files with 17 additions and 1 deletions
|
|
@ -50,7 +50,7 @@ pub enum LpAspectRatio {
|
||||||
R16to9,
|
R16to9,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Default, glib::Enum)]
|
#[derive(Debug, Clone, Copy, Default, glib::Enum, glib::Variant)]
|
||||||
#[enum_type(name = "LpOrientation")]
|
#[enum_type(name = "LpOrientation")]
|
||||||
pub enum LpOrientation {
|
pub enum LpOrientation {
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -173,6 +173,8 @@ mod imp {
|
||||||
obj.imp().selection_changed();
|
obj.imp().selection_changed();
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
|
let _ = self.apply_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dispose(&self) {
|
fn dispose(&self) {
|
||||||
|
|
@ -313,6 +315,7 @@ mod imp {
|
||||||
self.image.set_operations(None)?;
|
self.image.set_operations(None)?;
|
||||||
obj.edit_window().set_operations(None);
|
obj.edit_window().set_operations(None);
|
||||||
self.reset_selection();
|
self.reset_selection();
|
||||||
|
|
||||||
let res = self.obj().activate_action(
|
let res = self.obj().activate_action(
|
||||||
"edit-crop.aspect-ratio",
|
"edit-crop.aspect-ratio",
|
||||||
Some(&LpAspectRatio::default().to_variant()),
|
Some(&LpAspectRatio::default().to_variant()),
|
||||||
|
|
@ -321,6 +324,19 @@ mod imp {
|
||||||
log::error!("Failed to call action edit-crop.aspect-ratio: {err}");
|
log::error!("Failed to call action edit-crop.aspect-ratio: {err}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let (w, h) = self.image.image_size();
|
||||||
|
let orientation = if h > w {
|
||||||
|
LpOrientation::Portrait
|
||||||
|
} else {
|
||||||
|
LpOrientation::Landscape
|
||||||
|
};
|
||||||
|
let res = self
|
||||||
|
.obj()
|
||||||
|
.activate_action("edit-crop.orientation", Some(&orientation.to_variant()));
|
||||||
|
if let Err(err) = res {
|
||||||
|
log::error!("Failed to call action edit-crop.orientation: {err}");
|
||||||
|
}
|
||||||
|
|
||||||
self.obj().action_set_enabled("edit-crop.reset", false);
|
self.obj().action_set_enabled("edit-crop.reset", false);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue