edit_window: Disable "Done" if image is unchanged
This commit is contained in:
parent
84e58f28df
commit
bbc61a3215
2 changed files with 17 additions and 6 deletions
|
|
@ -41,7 +41,7 @@ mod imp {
|
||||||
#[template_child]
|
#[template_child]
|
||||||
cancel: TemplateChild<gtk::Button>,
|
cancel: TemplateChild<gtk::Button>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
done: TemplateChild<gtk::MenuButton>,
|
pub(crate) done: TemplateChild<gtk::MenuButton>,
|
||||||
|
|
||||||
#[property(get, construct_only)]
|
#[property(get, construct_only)]
|
||||||
original_image: OnceCell<LpImage>,
|
original_image: OnceCell<LpImage>,
|
||||||
|
|
@ -263,6 +263,16 @@ impl LpEditWindow {
|
||||||
pub fn set_operations(&self, operations: Option<Arc<glycin::Operations>>) {
|
pub fn set_operations(&self, operations: Option<Arc<glycin::Operations>>) {
|
||||||
let imp = self.imp();
|
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);
|
imp.operations.replace(operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@
|
||||||
<object class="GtkMenuButton" id="done">
|
<object class="GtkMenuButton" id="done">
|
||||||
<property name="label" translatable="true">_Done</property>
|
<property name="label" translatable="true">_Done</property>
|
||||||
<property name="use-underline">true</property>
|
<property name="use-underline">true</property>
|
||||||
|
<property name="sensitive">false</property>
|
||||||
|
<style>
|
||||||
|
<class name="raised" />
|
||||||
|
</style>
|
||||||
<property name="popover">
|
<property name="popover">
|
||||||
<object class="GtkPopover">
|
<object class="GtkPopover">
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -46,7 +50,7 @@
|
||||||
<property name="label" translatable="yes">Keep original and create a new file</property>
|
<property name="label" translatable="yes">Keep original and create a new file</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<style>
|
<style>
|
||||||
<class name="dim-label" />
|
<class name="dimmed" />
|
||||||
<class name="caption" />
|
<class name="caption" />
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -74,7 +78,7 @@
|
||||||
<property name="label" translatable="yes">Original image will be moved to the trash</property>
|
<property name="label" translatable="yes">Original image will be moved to the trash</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
<style>
|
<style>
|
||||||
<class name="dim-label" />
|
<class name="dimmed" />
|
||||||
<class name="caption" />
|
<class name="caption" />
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
|
|
@ -87,9 +91,6 @@
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
<style>
|
|
||||||
<class name="suggested-action" />
|
|
||||||
</style>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue