image_view: Add directory navigation

This commit adds directory navigation to Image Viewer.
Currently it only sorts images by name, instead of following
directory sorting like the mockups.
This commit is contained in:
Christopher Davis 2021-09-05 05:51:34 -07:00
parent 1841789525
commit 84208d2887
7 changed files with 191 additions and 28 deletions

23
src/util.rs Normal file
View file

@ -0,0 +1,23 @@
use gio::prelude::*;
use glib::translate::*;
pub fn utf8_collate_key_for_filename(filename: &String) -> String {
unsafe {
from_glib_full(glib::ffi::g_utf8_collate_key_for_filename(
filename.to_glib_none().0,
filename.len() as isize,
))
}
}
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::NONE_CANCELLABLE,
)
.ok()?;
Some(info.display_name().to_string())
}