Implement Properties

Implement a properties sidebar. In order to prevent
the UI from freezing, we use futures to load and cancel
loading file information. We also make use of
`gdk_pixbuf` and `svg_metadata` in order to get the file's
metadata before the file fully loads, meaning there's
little to no delay between changing files and seeing
the metadata for large images.

The properties widget uses expressions and
properties to avoid glue code for setting each label,
allowing us to have a clean separation between UI
and data.
This commit is contained in:
Christopher Davis 2022-07-26 11:31:11 -04:00
parent 1e95dd4cbb
commit ba4661031f
12 changed files with 664 additions and 45 deletions

View file

@ -37,6 +37,25 @@ pub fn query_attributes(file: &gio::File, attributes: Vec<&str>) -> anyhow::Resu
.context("Failed to query string")
}
pub async fn query_attributes_future(
file: &gio::File,
attributes: Vec<&str>,
) -> anyhow::Result<gio::FileInfo> {
let mut attr_str = String::from(*attributes.get(0).context("No attributes")?);
for attr in &attributes[1..] {
write!(attr_str, ",{}", attr)?;
}
file.query_info_future(
&attr_str,
gio::FileQueryInfoFlags::empty(),
glib::Priority::default(),
)
.await
.context("Failed to query attributes")
}
pub fn compare_by_name(file_a: &gio::File, file_b: &gio::File) -> std::cmp::Ordering {
let name_a = get_file_display_name(file_a).unwrap_or_default();
let name_b = get_file_display_name(file_b).unwrap_or_default();