decoder: Use GFile instead of PathBuf
This allows to show images from locations that don't have a representation with path. This also works around not being able to read files in trash:/// Closes #56 Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/174>
This commit is contained in:
parent
032707a210
commit
fad8bb7939
15 changed files with 119 additions and 107 deletions
|
|
@ -9,12 +9,11 @@ mod obj;
|
|||
pub use gps::GPSLocation;
|
||||
pub use obj::LpImageMetadata;
|
||||
|
||||
use crate::util;
|
||||
use crate::util::gettext::*;
|
||||
use crate::util::{self, ToBufRead};
|
||||
|
||||
use gtk::glib;
|
||||
|
||||
use std::path::Path;
|
||||
use crate::deps::*;
|
||||
use gio::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum ImageMetadata {
|
||||
|
|
@ -45,10 +44,9 @@ impl std::fmt::Debug for ImageMetadata {
|
|||
}
|
||||
|
||||
impl ImageMetadata {
|
||||
pub fn load(path: &Path) -> Self {
|
||||
log::debug!("Loading metadata for {:?}", path);
|
||||
if let Ok(file) = std::fs::File::open(path) {
|
||||
let mut bufreader = std::io::BufReader::new(&file);
|
||||
pub fn load(file: &gio::File) -> Self {
|
||||
log::debug!("Loading metadata for {}", file.uri());
|
||||
if let Ok(mut bufreader) = file.to_buf_read() {
|
||||
let exifreader = exif::Reader::new();
|
||||
|
||||
if let Ok(exif) = exifreader.read_from_container(&mut bufreader) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue