properties: Add creator, rights, lens, software
This commit is contained in:
parent
18d44da9e9
commit
4adf22c4e5
4 changed files with 118 additions and 4 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -1276,9 +1276,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gufo-exif"
|
name = "gufo-exif"
|
||||||
version = "0.5.0-alpha"
|
version = "0.5.0-alpha.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6a31aca18913da24cf6aaf0d3ffd905608463ffb75d0af42c2f0bf3afc7b987"
|
checksum = "1597401629a6778cbea663e6af6680fbcd07ab243cc8eee9bc5ef5d2c9e5eab8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"gufo-common",
|
"gufo-common",
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
mod file;
|
mod file;
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
@ -61,12 +62,23 @@ impl Metadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_key_value(&mut self, key_value: BTreeMap<String, String>) {
|
||||||
|
let result = self.metadata.add_key_value(key_value);
|
||||||
|
|
||||||
|
if let Err(err) = &result {
|
||||||
|
tracing::warn!("Failed to add key-value data: {err}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_image_info(&mut self, image_info: ImageDetails) {
|
pub fn set_image_info(&mut self, image_info: ImageDetails) {
|
||||||
if let Some(exif_raw) = image_info.metadata_exif() {
|
if let Some(exif_raw) = image_info.metadata_exif() {
|
||||||
self.set_exif_bytes(exif_raw.to_owned());
|
self.set_exif_bytes(exif_raw.to_owned());
|
||||||
}
|
}
|
||||||
if let Some(exif_xmp) = image_info.metadata_xmp() {
|
if let Some(xmp_raw) = image_info.metadata_xmp() {
|
||||||
self.set_xmp_bytes(exif_xmp.to_owned());
|
self.set_xmp_bytes(xmp_raw.to_owned());
|
||||||
|
}
|
||||||
|
if let Some(key_value) = image_info.metadata_key_value() {
|
||||||
|
self.set_key_value(key_value.to_owned());
|
||||||
}
|
}
|
||||||
self.image_info = Some(image_info);
|
self.image_info = Some(image_info);
|
||||||
}
|
}
|
||||||
|
|
@ -309,6 +321,56 @@ impl Metadata {
|
||||||
self.metadata.make()
|
self.metadata.make()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn camera_owner_name(&self) -> Option<String> {
|
||||||
|
self.metadata.camera_owner_name()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn creator(&self) -> Option<String> {
|
||||||
|
self.metadata.creator()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn lens(&self) -> Option<String> {
|
||||||
|
if let Some(lens) = self.metadata.lens_specification()
|
||||||
|
&& lens.min_f_number_max_focal_length.numerator > 0
|
||||||
|
&& lens.min_f_number_max_focal_length.denominator > 0
|
||||||
|
{
|
||||||
|
let mut s = if lens.min_focal_length == lens.max_focal_length {
|
||||||
|
format!("{}\u{202F}mm", lens.min_focal_length.as_f32())
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"{}–{}\u{202F}mm",
|
||||||
|
lens.min_focal_length.as_f32(),
|
||||||
|
lens.max_focal_length.as_f32()
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if lens.min_f_number_min_focal_length == lens.min_f_number_max_focal_length {
|
||||||
|
s.push_str(&format!(
|
||||||
|
" \u{192}\u{2215}{}",
|
||||||
|
lens.min_f_number_min_focal_length.as_f32()
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
s.push_str(&format!(
|
||||||
|
" \u{192}\u{2215}{}–{}",
|
||||||
|
lens.min_f_number_min_focal_length.as_f32(),
|
||||||
|
lens.min_f_number_max_focal_length.as_f32()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(s)
|
||||||
|
} else {
|
||||||
|
self.metadata.lens_model()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn rights(&self) -> Option<String> {
|
||||||
|
self.metadata.rights()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn software(&self) -> Option<String> {
|
||||||
|
self.metadata.software()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn gps_location(&self) -> Option<gufo::common::geography::Location> {
|
pub fn gps_location(&self) -> Option<gufo::common::geography::Location> {
|
||||||
self.metadata.gps_location()
|
self.metadata.gps_location()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,10 @@ mod imp {
|
||||||
#[template_child]
|
#[template_child]
|
||||||
originally_created: TemplateChild<adw::ActionRow>,
|
originally_created: TemplateChild<adw::ActionRow>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
|
creator: TemplateChild<adw::ActionRow>,
|
||||||
|
#[template_child]
|
||||||
|
rights: TemplateChild<adw::ActionRow>,
|
||||||
|
#[template_child]
|
||||||
user_comment: TemplateChild<adw::ActionRow>,
|
user_comment: TemplateChild<adw::ActionRow>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
aperture: TemplateChild<adw::ActionRow>,
|
aperture: TemplateChild<adw::ActionRow>,
|
||||||
|
|
@ -83,6 +87,10 @@ mod imp {
|
||||||
focal_length: TemplateChild<adw::ActionRow>,
|
focal_length: TemplateChild<adw::ActionRow>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
maker_model: TemplateChild<adw::ActionRow>,
|
maker_model: TemplateChild<adw::ActionRow>,
|
||||||
|
#[template_child]
|
||||||
|
lens: TemplateChild<adw::ActionRow>,
|
||||||
|
#[template_child]
|
||||||
|
software: TemplateChild<adw::ActionRow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
|
|
@ -227,12 +235,16 @@ mod imp {
|
||||||
let has_details = [
|
let has_details = [
|
||||||
Self::update_row(&self.location, metadata.gps_location_place()),
|
Self::update_row(&self.location, metadata.gps_location_place()),
|
||||||
Self::update_row(&self.originally_created, metadata.originally_created()),
|
Self::update_row(&self.originally_created, metadata.originally_created()),
|
||||||
|
Self::update_row(&self.creator, metadata.creator()),
|
||||||
|
Self::update_row(&self.rights, metadata.rights()),
|
||||||
Self::update_row(&self.user_comment, metadata.user_comment()),
|
Self::update_row(&self.user_comment, metadata.user_comment()),
|
||||||
Self::update_row(&self.aperture, metadata.f_number()),
|
Self::update_row(&self.aperture, metadata.f_number()),
|
||||||
Self::update_row(&self.exposure, metadata.exposure_time()),
|
Self::update_row(&self.exposure, metadata.exposure_time()),
|
||||||
Self::update_row(&self.iso, metadata.iso()),
|
Self::update_row(&self.iso, metadata.iso()),
|
||||||
Self::update_row(&self.focal_length, metadata.focal_length()),
|
Self::update_row(&self.focal_length, metadata.focal_length()),
|
||||||
Self::update_row(&self.maker_model, metadata.maker_model()),
|
Self::update_row(&self.maker_model, metadata.maker_model()),
|
||||||
|
Self::update_row(&self.lens, metadata.lens()),
|
||||||
|
Self::update_row(&self.software, metadata.software()),
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
.any(|x| *x);
|
.any(|x| *x);
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,26 @@
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow" id="creator">
|
||||||
|
<property name="title" translatable="yes">Creator</property>
|
||||||
|
<property name="subtitle-selectable">True</property>
|
||||||
|
<property name="use-markup">False</property>
|
||||||
|
<style>
|
||||||
|
<class name="property" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow" id="rights">
|
||||||
|
<property name="title" translatable="yes">Copyright</property>
|
||||||
|
<property name="subtitle-selectable">True</property>
|
||||||
|
<property name="use-markup">False</property>
|
||||||
|
<style>
|
||||||
|
<class name="property" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwActionRow" id="user_comment">
|
<object class="AdwActionRow" id="user_comment">
|
||||||
<property name="title" translatable="yes">Comment</property>
|
<property name="title" translatable="yes">Comment</property>
|
||||||
|
|
@ -214,6 +234,26 @@
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow" id="lens">
|
||||||
|
<property name="title" translatable="yes">Lens</property>
|
||||||
|
<property name="subtitle-selectable">True</property>
|
||||||
|
<property name="use-markup">False</property>
|
||||||
|
<style>
|
||||||
|
<class name="property" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="AdwActionRow" id="software">
|
||||||
|
<property name="title" translatable="yes">Software</property>
|
||||||
|
<property name="subtitle-selectable">True</property>
|
||||||
|
<property name="use-markup">False</property>
|
||||||
|
<style>
|
||||||
|
<class name="property" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue