edit_window: Disable "Done" if image is unchanged

This commit is contained in:
Sophie Herold 2025-01-15 22:10:30 +01:00
parent 84e58f28df
commit bbc61a3215
2 changed files with 17 additions and 6 deletions

View file

@ -41,7 +41,7 @@ mod imp {
#[template_child]
cancel: TemplateChild<gtk::Button>,
#[template_child]
done: TemplateChild<gtk::MenuButton>,
pub(crate) done: TemplateChild<gtk::MenuButton>,
#[property(get, construct_only)]
original_image: OnceCell<LpImage>,
@ -263,6 +263,16 @@ impl LpEditWindow {
pub fn set_operations(&self, operations: Option<Arc<glycin::Operations>>) {
let imp = self.imp();
let done_sensitive = operations
.as_ref()
.is_some_and(|x| !x.operations().is_empty());
if done_sensitive {
imp.done.add_css_class("suggested-action");
} else {
imp.done.remove_css_class("suggested-action");
}
imp.done.set_sensitive(done_sensitive);
imp.operations.replace(operations);
}

View file

@ -19,6 +19,10 @@
<object class="GtkMenuButton" id="done">
<property name="label" translatable="true">_Done</property>
<property name="use-underline">true</property>
<property name="sensitive">false</property>
<style>
<class name="raised" />
</style>
<property name="popover">
<object class="GtkPopover">
<style>
@ -46,7 +50,7 @@
<property name="label" translatable="yes">Keep original and create a new file</property>
<property name="xalign">0</property>
<style>
<class name="dim-label" />
<class name="dimmed" />
<class name="caption" />
</style>
</object>
@ -74,7 +78,7 @@
<property name="label" translatable="yes">Original image will be moved to the trash</property>
<property name="xalign">0</property>
<style>
<class name="dim-label" />
<class name="dimmed" />
<class name="caption" />
</style>
</object>
@ -87,9 +91,6 @@
</property>
</object>
</property>
<style>
<class name="suggested-action" />
</style>
</object>
</child>
</object>