window: Adjust to image size when opening
Give LpImage a native with that should feel nice. When opening a new window with a new image the window size is determined by LpImage's natural width. The image size and EXIF data is loaded before the image such that the window can be shown in the right dimension while loading the actual image.
This commit is contained in:
parent
68221bacba
commit
e04992b46d
12 changed files with 389 additions and 79 deletions
14
src/util.rs
14
src/util.rs
|
|
@ -5,7 +5,7 @@ use glib::translate::*;
|
|||
|
||||
use anyhow::Context;
|
||||
|
||||
use std::fmt::Write;
|
||||
use std::fmt::{Debug, Write};
|
||||
|
||||
pub fn utf8_collate_key_for_filename(filename: &str) -> String {
|
||||
unsafe {
|
||||
|
|
@ -62,3 +62,15 @@ pub fn compare_by_name(file_a: &gio::File, file_b: &gio::File) -> std::cmp::Orde
|
|||
|
||||
utf8_collate_key_for_filename(&name_a).cmp(&utf8_collate_key_for_filename(&name_b))
|
||||
}
|
||||
|
||||
pub async fn spawn<T: Debug + Send + 'static>(
|
||||
name: &str,
|
||||
f: impl Fn() -> T + Send + 'static,
|
||||
) -> async_std::io::Result<T> {
|
||||
log::trace!("Starting thread '{name}'");
|
||||
|
||||
Ok(async_std::task::Builder::new()
|
||||
.name(name.to_string())
|
||||
.spawn(async_global_executor::spawn_blocking(f))?
|
||||
.await)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue