window: Implement drag and drop

The main page is no longer a lie.
This commit is contained in:
Christopher Davis 2021-12-27 15:03:31 -08:00
parent 5d9567507c
commit be70bdafe5
5 changed files with 67 additions and 11 deletions

View file

@ -13,13 +13,24 @@ pub fn utf8_collate_key_for_filename(filename: &str) -> String {
}
pub fn get_file_display_name(file: &gio::File) -> Option<String> {
let info = file
.query_info(
*gio::FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
gio::FileQueryInfoFlags::empty(),
gio::Cancellable::NONE,
)
.ok()?;
let info = query_attributes(file, vec![&gio::FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME]).ok()?;
Some(info.display_name().to_string())
}
pub fn query_attributes(
file: &gio::File,
attributes: Vec<&str>,
) -> Result<gio::FileInfo, glib::Error> {
let mut attributes = attributes;
let mut attr_str = String::from(attributes.remove(0));
for attr in attributes {
attr_str.push_str(&format!(",{}", attr));
}
file.query_info(
&attr_str,
gio::FileQueryInfoFlags::empty(),
gio::Cancellable::NONE,
)
}