imageView: Use custom slide widget and IndexSet
Use IndexSet to allow direct access by Path and also allow an arbitrary ordering that was not possible with Vec. Also add monitoring of file changes in the directory. Use a custom LpSlidingView instead of AdwCarousel because Carousel was never designed for this job and suffered of bugs. LpSlidingView does not support swiping gestures yet since they currently don't work yet anyways #24. Use a new algorithm to fill the LpSlidingView that is stateless and covers all potential changes in the directory. This not only fixes bugs but would also work with changed sorting orders. This also adds build time template XML validation since it was useful for the refactoring #46. Closes #9, #11, #30, #33, #42
This commit is contained in:
parent
73764810eb
commit
f2357513da
21 changed files with 1010 additions and 553 deletions
|
|
@ -15,7 +15,7 @@ pub struct GPSCoord {
|
|||
}
|
||||
|
||||
impl GPSCoord {
|
||||
fn to_f64(&self) -> f64 {
|
||||
fn to_f64(self) -> f64 {
|
||||
let sign = if self.sing { 1. } else { -1. };
|
||||
|
||||
let min = self.min.unwrap_or_default();
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ mod obj;
|
|||
pub use gps::GPSLocation;
|
||||
pub use obj::LpImageMetadata;
|
||||
|
||||
use gio::prelude::*;
|
||||
|
||||
use crate::i18n::*;
|
||||
|
||||
use gtk::glib;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum ImageMetadata {
|
||||
Exif(exif::Exif),
|
||||
|
|
@ -44,16 +44,14 @@ impl std::fmt::Debug for ImageMetadata {
|
|||
}
|
||||
|
||||
impl ImageMetadata {
|
||||
pub fn load(file: &gio::File) -> Self {
|
||||
if let Some(path) = file.path() {
|
||||
log::debug!("Loading metadata for {:?}", path);
|
||||
if let Ok(file) = std::fs::File::open(path) {
|
||||
let mut bufreader = std::io::BufReader::new(&file);
|
||||
let exifreader = exif::Reader::new();
|
||||
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);
|
||||
let exifreader = exif::Reader::new();
|
||||
|
||||
if let Ok(exif) = exifreader.read_from_container(&mut bufreader) {
|
||||
return Self::Exif(exif);
|
||||
}
|
||||
if let Ok(exif) = exifreader.read_from_container(&mut bufreader) {
|
||||
return Self::Exif(exif);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,16 +7,17 @@ use gtk::glib;
|
|||
use once_cell::sync::Lazy;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::path::Path;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct LpImageMetadata(ObjectSubclass<imp::LpImageMetadata>);
|
||||
}
|
||||
|
||||
impl LpImageMetadata {
|
||||
pub fn load(file: &gio::File) -> Self {
|
||||
pub fn load(path: &Path) -> Self {
|
||||
let obj = glib::Object::new::<Self>(&[]);
|
||||
|
||||
let metadata = ImageMetadata::load(file);
|
||||
let metadata = ImageMetadata::load(path);
|
||||
obj.imp().metadata.replace(metadata);
|
||||
|
||||
obj
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue