propertiesView: Add button to copy coordiantes
Copy location coordinates in a machine readable format for use in other apps. Closes #164 Part-of: <https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/371>
This commit is contained in:
parent
0dc71357f1
commit
8b60dc7dcb
3 changed files with 68 additions and 5 deletions
|
|
@ -20,6 +20,7 @@ use std::cell::{OnceCell, RefCell};
|
|||
|
||||
use adw::prelude::*;
|
||||
use adw::subclass::prelude::*;
|
||||
use glib::translate::IntoGlib;
|
||||
use glib::Properties;
|
||||
use gtk::CompositeTemplate;
|
||||
|
||||
|
|
@ -91,6 +92,10 @@ mod imp {
|
|||
obj.imp().open_directory().await;
|
||||
});
|
||||
|
||||
klass.install_action("properties.copy-location", None, move |obj, _, _| {
|
||||
obj.imp().copy_location();
|
||||
});
|
||||
|
||||
klass.install_action("properties.open-location", None, move |obj, _, _| {
|
||||
obj.imp().open_location();
|
||||
});
|
||||
|
|
@ -280,6 +285,26 @@ mod imp {
|
|||
};
|
||||
}
|
||||
|
||||
/// Copy GPS location
|
||||
fn copy_location(&self) {
|
||||
let obj = self.obj();
|
||||
|
||||
if let Some(location) = obj.image().and_then(|x| x.metadata().gps_location()) {
|
||||
let clipboard = obj.display().clipboard();
|
||||
clipboard.set_text(&location.machine_readable());
|
||||
let _ = obj.activate_action(
|
||||
"win.show-toast",
|
||||
Some(
|
||||
&(
|
||||
gettext("Image Coordinates Copied"),
|
||||
adw::ToastPriority::Normal.into_glib(),
|
||||
)
|
||||
.to_variant(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Open GPS location in apps like Maps via `geo:` URI
|
||||
fn open_location(&self) {
|
||||
let obj = self.obj();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue