edit_window: Add "Done" menu replacing "Save" button
This commit is contained in:
parent
1801683bfe
commit
507b7b24f9
2 changed files with 73 additions and 12 deletions
|
|
@ -40,8 +40,6 @@ mod imp {
|
||||||
toolbar_view: TemplateChild<adw::ToolbarView>,
|
toolbar_view: TemplateChild<adw::ToolbarView>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
cancel: TemplateChild<gtk::Button>,
|
cancel: TemplateChild<gtk::Button>,
|
||||||
#[template_child]
|
|
||||||
save: TemplateChild<gtk::Button>,
|
|
||||||
|
|
||||||
#[property(get, construct_only)]
|
#[property(get, construct_only)]
|
||||||
original_image: OnceCell<LpImage>,
|
original_image: OnceCell<LpImage>,
|
||||||
|
|
@ -57,6 +55,14 @@ mod imp {
|
||||||
|
|
||||||
fn class_init(klass: &mut Self::Class) {
|
fn class_init(klass: &mut Self::Class) {
|
||||||
Self::bind_template(klass);
|
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>) {
|
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||||
|
|
@ -81,14 +87,6 @@ mod imp {
|
||||||
obj.window().show_image();
|
obj.window().show_image();
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
self.save.connect_clicked(glib::clone!(
|
|
||||||
#[weak]
|
|
||||||
obj,
|
|
||||||
move |_| {
|
|
||||||
glib::spawn_future_local(async move { obj.imp().save_image().await });
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,72 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton" id="save">
|
<object class="GtkMenuButton" id="save">
|
||||||
<property name="label" translatable="true">_Save</property>
|
<property name="label" translatable="true">_Done</property>
|
||||||
<property name="use-underline">true</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>
|
<style>
|
||||||
<class name="suggested-action" />
|
<class name="suggested-action" />
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue