edit_window: Add "Done" menu replacing "Save" button

This commit is contained in:
Sophie Herold 2025-01-14 00:12:53 +01:00
parent 1801683bfe
commit 507b7b24f9
2 changed files with 73 additions and 12 deletions

View file

@ -40,8 +40,6 @@ mod imp {
toolbar_view: TemplateChild<adw::ToolbarView>,
#[template_child]
cancel: TemplateChild<gtk::Button>,
#[template_child]
save: TemplateChild<gtk::Button>,
#[property(get, construct_only)]
original_image: OnceCell<LpImage>,
@ -57,6 +55,14 @@ mod imp {
fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
klass.install_action("edit.save-copy", None, |obj, _, _| {
glib::spawn_future_local(glib::clone!(
#[weak]
obj,
async move { obj.imp().save_image().await }
));
});
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
@ -81,14 +87,6 @@ mod imp {
obj.window().show_image();
}
));
self.save.connect_clicked(glib::clone!(
#[weak]
obj,
move |_| {
glib::spawn_future_local(async move { obj.imp().save_image().await });
}
));
}
}

View file

@ -16,9 +16,72 @@
</object>
</child>
<child type="end">
<object class="GtkButton" id="save">
<property name="label" translatable="true">_Save</property>
<object class="GtkMenuButton" id="save">
<property name="label" translatable="true">_Done</property>
<property name="use-underline">true</property>
<property name="popover">
<object class="GtkPopover">
<style>
<class name="menu" />
</style>
<property name="child">
<object class="GtkListBox">
<property name="selection-mode">none</property>
<child>
<object class="GtkListBoxRow">
<property name="action-name">edit.save-copy</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="label">Save as Copy…</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Keep original and create a new file</property>
<property name="xalign">0</property>
<style>
<class name="dim-label" />
<class name="caption" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="label">Replace Original…</property>
<property name="xalign">0</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Original image will be moved to the trash</property>
<property name="xalign">0</property>
<style>
<class name="dim-label" />
<class name="caption" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</property>
<style>
<class name="suggested-action" />
</style>