window: Copy metadata instead of image if selected
This commit is contained in:
parent
b56d650086
commit
307c864c6e
4 changed files with 38 additions and 10 deletions
|
|
@ -17,8 +17,8 @@
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes" context="shortcut window">Copy Image to Clipboard</property>
|
<property name="title" translatable="yes" context="shortcut window">Copy Image or Metadata to Clipboard</property>
|
||||||
<property name="action-name">win.copy</property>
|
<property name="accelerator"><Ctrl>C</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|
@ -269,5 +269,4 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<attribute name="label" translatable="yes">_Copy</attribute>
|
<attribute name="label" translatable="yes">_Copy</attribute>
|
||||||
<attribute name="action">win.copy</attribute>
|
<attribute name="action">win.copy-image</attribute>
|
||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,21 @@ mod imp {
|
||||||
Self::bind_template(klass);
|
Self::bind_template(klass);
|
||||||
Self::Type::bind_template_callbacks(klass);
|
Self::Type::bind_template_callbacks(klass);
|
||||||
|
|
||||||
|
klass.add_binding(
|
||||||
|
gdk::Key::c,
|
||||||
|
gdk::ModifierType::CONTROL_MASK,
|
||||||
|
|window, _| {
|
||||||
|
if window.has_metadata_selected() {
|
||||||
|
// Pass on to normal copy handler to copy selected metadata
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
window.copy_image();
|
||||||
|
true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
|
||||||
// Set up actions
|
// Set up actions
|
||||||
klass.install_action("win.toggle-fullscreen", None, move |win, _, _| {
|
klass.install_action("win.toggle-fullscreen", None, move |win, _, _| {
|
||||||
win.toggle_fullscreen(!win.is_fullscreened());
|
win.toggle_fullscreen(!win.is_fullscreened());
|
||||||
|
|
@ -225,8 +240,8 @@ mod imp {
|
||||||
win.print();
|
win.print();
|
||||||
});
|
});
|
||||||
|
|
||||||
klass.install_action("win.copy", None, move |win, _, _| {
|
klass.install_action("win.copy-image", None, move |win, _, _| {
|
||||||
win.copy();
|
win.copy_image();
|
||||||
});
|
});
|
||||||
|
|
||||||
klass.install_action_async("win.trash", None, |win, _, _| async move {
|
klass.install_action_async("win.trash", None, |win, _, _| async move {
|
||||||
|
|
@ -561,7 +576,21 @@ impl LpWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy(&self) {
|
/// Returns true if some text in metadata is currently selected
|
||||||
|
fn has_metadata_selected(&self) -> bool {
|
||||||
|
if let Some(focus_widget) = self.focus_widget() {
|
||||||
|
if focus_widget.is_ancestor(&*self.imp().properties_view) {
|
||||||
|
if let Ok(label) = focus_widget.downcast::<gtk::Label>() {
|
||||||
|
return label.selection_bounds().is_some();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Copy image to clipboard or metadata text if selected
|
||||||
|
fn copy_image(&self) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
|
|
||||||
if let Err(e) = imp.image_view.copy() {
|
if let Err(e) = imp.image_view.copy() {
|
||||||
|
|
@ -685,7 +714,7 @@ impl LpWindow {
|
||||||
self.action_set_enabled("win.print", enabled);
|
self.action_set_enabled("win.print", enabled);
|
||||||
self.action_set_enabled("win.rotate_cw", enabled);
|
self.action_set_enabled("win.rotate_cw", enabled);
|
||||||
self.action_set_enabled("win.rotate_ccw", enabled);
|
self.action_set_enabled("win.rotate_ccw", enabled);
|
||||||
self.action_set_enabled("win.copy", enabled);
|
self.action_set_enabled("win.copy-image", enabled);
|
||||||
self.action_set_enabled("win.zoom-best-fit", enabled);
|
self.action_set_enabled("win.zoom-best-fit", enabled);
|
||||||
self.action_set_enabled("win.zoom-to-exact", enabled);
|
self.action_set_enabled("win.zoom-to-exact", enabled);
|
||||||
self.action_set_enabled("win.toggle-properties", enabled);
|
self.action_set_enabled("win.toggle-properties", enabled);
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@
|
||||||
<child type="start">
|
<child type="start">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="icon-name">edit-copy-symbolic</property>
|
<property name="icon-name">edit-copy-symbolic</property>
|
||||||
<property name="action-name">win.copy</property>
|
<property name="action-name">win.copy-image</property>
|
||||||
<property name="tooltip-text" translatable="yes">Copy to Clipboard</property>
|
<property name="tooltip-text" translatable="yes">Copy to Clipboard</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue