[niepce] npc_engine: libfile::FileType is now CamelCase
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] npc_engine: libfile::FileType is now CamelCase
- Date: Wed, 5 Feb 2020 02:01:25 +0000 (UTC)
commit f19a67bebd89ef6d2c6e4723a65a948c38a754c2
Author: Hubert Figuière <hub figuiere net>
Date: Wed Jan 29 01:49:50 2020 -0500
npc_engine: libfile::FileType is now CamelCase
crates/npc-engine/src/db/filebundle.rs | 34 ++++++++++----------
crates/npc-engine/src/db/libfile.rs | 44 +++++++++++++-------------
crates/npc-engine/src/db/libmetadata.rs | 14 ++++----
crates/npc-engine/src/db/library.rs | 4 +--
src/niepce/modules/darkroom/darkroommodule.cpp | 6 ++--
src/niepce/ui/library_cell_renderer.rs | 12 +++----
6 files changed, 57 insertions(+), 57 deletions(-)
---
diff --git a/crates/npc-engine/src/db/filebundle.rs b/crates/npc-engine/src/db/filebundle.rs
index 64399b8..07260c8 100644
--- a/crates/npc-engine/src/db/filebundle.rs
+++ b/crates/npc-engine/src/db/filebundle.rs
@@ -1,7 +1,7 @@
/*
* niepce - engine/db/filebundle.rs
*
- * Copyright (C) 2017-2019 Hubert Figuière
+ * Copyright (C) 2017-2020 Hubert Figuière
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -88,7 +88,7 @@ impl Default for FileBundle {
impl FileBundle {
pub fn new() -> FileBundle {
FileBundle {
- bundle_type: FileType::UNKNOWN,
+ bundle_type: FileType::Unknown,
main: String::new(),
xmp_sidecar: String::new(),
jpeg: String::new(),
@@ -150,29 +150,29 @@ impl FileBundle {
IsRaw::Yes => {
if !self.main.is_empty() && self.jpeg.is_empty() {
self.jpeg = self.main.clone();
- self.bundle_type = FileType::RAW_JPEG;
+ self.bundle_type = FileType::RawJpeg;
} else {
- self.bundle_type = FileType::RAW;
+ self.bundle_type = FileType::Raw;
}
self.main = String::from(path);
}
IsRaw::No => {
if !self.main.is_empty() {
self.jpeg = String::from(path);
- self.bundle_type = FileType::RAW_JPEG;
+ self.bundle_type = FileType::RawJpeg;
} else {
self.main = String::from(path);
- self.bundle_type = FileType::IMAGE;
+ self.bundle_type = FileType::Image;
}
}
},
MType::Xmp => self.xmp_sidecar = String::from(path),
MType::Movie => match self.bundle_type {
- FileType::UNKNOWN => {
+ FileType::Unknown => {
self.main = String::from(path);
- self.bundle_type = FileType::VIDEO;
+ self.bundle_type = FileType::Video;
}
- FileType::IMAGE => {
+ FileType::Image => {
self.sidecars.push(Sidecar::Live(String::from(path)));
}
_ => {
@@ -253,7 +253,7 @@ mod test {
let mut iter = bundles_list.iter();
if let Some(b) = iter.next() {
- assert_eq!(b.bundle_type(), FileType::RAW_JPEG);
+ assert_eq!(b.bundle_type(), FileType::RawJpeg);
assert_eq!(b.main(), "/foo/bar/dcs_0001.nef");
assert_eq!(b.jpeg(), "/foo/bar/dcs_0001.jpg");
assert_eq!(b.xmp_sidecar(), "/foo/bar/dcs_0001.xmp");
@@ -262,7 +262,7 @@ mod test {
}
if let Some(b) = iter.next() {
- assert_eq!(b.bundle_type(), FileType::RAW_JPEG);
+ assert_eq!(b.bundle_type(), FileType::RawJpeg);
assert_eq!(b.main(), "/foo/bar/img_0001.cr2");
assert_eq!(b.jpeg(), "/foo/bar/img_0001.jpg");
assert_eq!(b.xmp_sidecar(), "/foo/bar/img_0001.xmp");
@@ -271,7 +271,7 @@ mod test {
}
if let Some(b) = iter.next() {
- assert_eq!(b.bundle_type(), FileType::IMAGE);
+ assert_eq!(b.bundle_type(), FileType::Image);
assert_eq!(b.main(), "/foo/bar/img_0142.jpg");
assert!(b.jpeg().is_empty());
assert!(b.xmp_sidecar().is_empty());
@@ -285,7 +285,7 @@ mod test {
}
if let Some(b) = iter.next() {
- assert_eq!(b.bundle_type(), FileType::IMAGE);
+ assert_eq!(b.bundle_type(), FileType::Image);
assert_eq!(b.main(), "/foo/bar/img_0143.jpg");
assert!(b.jpeg().is_empty());
assert!(b.xmp_sidecar().is_empty());
@@ -299,7 +299,7 @@ mod test {
}
if let Some(b) = iter.next() {
- assert_eq!(b.bundle_type(), FileType::RAW);
+ assert_eq!(b.bundle_type(), FileType::Raw);
assert_eq!(b.main(), "/foo/bar/img_0144.crw");
assert!(b.jpeg().is_empty());
assert!(b.xmp_sidecar().is_empty());
@@ -313,7 +313,7 @@ mod test {
}
if let Some(b) = iter.next() {
- assert_eq!(b.bundle_type(), FileType::VIDEO);
+ assert_eq!(b.bundle_type(), FileType::Video);
assert_eq!(b.main(), "/foo/bar/mvi_0145.mov");
assert!(b.jpeg().is_empty());
assert!(b.xmp_sidecar().is_empty());
@@ -333,7 +333,7 @@ mod test {
b.jpeg(),
b.xmp_sidecar() /*, b.sidecars()*/
);
- assert_eq!(b.bundle_type(), FileType::RAW_JPEG);
+ assert_eq!(b.bundle_type(), FileType::RawJpeg);
assert_eq!(b.main(), "/foo/bar/scs_3445.raf");
assert_eq!(b.jpeg(), "/foo/bar/scs_3445.jpg");
assert_eq!(b.xmp_sidecar(), "/foo/bar/scs_3445.jpg.xmp");
@@ -349,7 +349,7 @@ mod test {
b.jpeg(),
b.xmp_sidecar() /*, b.sidecars()*/
);
- assert_eq!(b.bundle_type(), FileType::RAW_JPEG);
+ assert_eq!(b.bundle_type(), FileType::RawJpeg);
assert_eq!(b.main(), "/foo/bar/scs_3446.raf");
assert_eq!(b.jpeg(), "/foo/bar/scs_3446.jpg");
assert!(b.xmp_sidecar().is_empty());
diff --git a/crates/npc-engine/src/db/libfile.rs b/crates/npc-engine/src/db/libfile.rs
index 95bef67..c8c0efc 100644
--- a/crates/npc-engine/src/db/libfile.rs
+++ b/crates/npc-engine/src/db/libfile.rs
@@ -32,14 +32,13 @@ use npc_fwk;
use npc_fwk::base::PropertyIndex;
#[repr(i32)]
-#[allow(non_camel_case_types)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum FileType {
- UNKNOWN = 0,
- RAW = 1,
- RAW_JPEG = 2,
- IMAGE = 3,
- VIDEO = 4,
+ Unknown = 0,
+ Raw = 1,
+ RawJpeg = 2,
+ Image = 3,
+ Video = 4,
}
#[repr(i32)]
@@ -67,12 +66,12 @@ impl From<i32> for FileStatus {
impl From<i32> for FileType {
fn from(t: i32) -> Self {
match t {
- 0 => FileType::UNKNOWN,
- 1 => FileType::RAW,
- 2 => FileType::RAW_JPEG,
- 3 => FileType::IMAGE,
- 4 => FileType::VIDEO,
- _ => FileType::UNKNOWN,
+ 0 => FileType::Unknown,
+ 1 => FileType::Raw,
+ 2 => FileType::RawJpeg,
+ 3 => FileType::Image,
+ 4 => FileType::Video,
+ _ => FileType::Unknown,
}
}
}
@@ -80,11 +79,11 @@ impl From<i32> for FileType {
impl Into<i32> for FileType {
fn into(self) -> i32 {
match self {
- FileType::UNKNOWN => 0,
- FileType::RAW => 1,
- FileType::RAW_JPEG => 2,
- FileType::IMAGE => 3,
- FileType::VIDEO => 4,
+ FileType::Unknown => 0,
+ FileType::Raw => 1,
+ FileType::RawJpeg => 2,
+ FileType::Image => 3,
+ FileType::Video => 4,
}
}
}
@@ -122,7 +121,7 @@ impl LibFile {
rating: 0,
label: 0,
flag: 0,
- file_type: FileType::UNKNOWN,
+ file_type: FileType::Unknown,
}
}
@@ -247,13 +246,14 @@ impl FromDb for LibFile {
*/
pub fn mimetype_to_filetype(mime: &npc_fwk::MimeType) -> FileType {
if mime.is_digicam_raw() {
- return FileType::RAW;
+ FileType::Raw
} else if mime.is_image() {
- return FileType::IMAGE;
+ FileType::Image
} else if mime.is_movie() {
- return FileType::VIDEO;
+ FileType::Video
+ } else {
+ FileType::Unknown
}
- FileType::UNKNOWN
}
#[no_mangle]
diff --git a/crates/npc-engine/src/db/libmetadata.rs b/crates/npc-engine/src/db/libmetadata.rs
index d881dfa..77fa771 100644
--- a/crates/npc-engine/src/db/libmetadata.rs
+++ b/crates/npc-engine/src/db/libmetadata.rs
@@ -62,7 +62,7 @@ impl LibMetadata {
xmp: XmpMeta::new(),
id,
sidecars: vec![],
- file_type: FileType::UNKNOWN,
+ file_type: FileType::Unknown,
name: String::new(),
folder: String::new(),
}
@@ -73,7 +73,7 @@ impl LibMetadata {
xmp,
id,
sidecars: vec![],
- file_type: FileType::UNKNOWN,
+ file_type: FileType::Unknown,
name: String::new(),
folder: String::new(),
}
@@ -239,11 +239,11 @@ impl LibMetadata {
eng::NpFileTypeProp => {
// XXX this to string convert should be elsewhere
let file_type = match self.file_type {
- FileType::UNKNOWN => "Unknown",
- FileType::RAW => "RAW",
- FileType::RAW_JPEG => "RAW + JPEG",
- FileType::IMAGE => "Image",
- FileType::VIDEO => "Video",
+ FileType::Unknown => "Unknown",
+ FileType::Raw => "RAW",
+ FileType::RawJpeg => "RAW + JPEG",
+ FileType::Image => "Image",
+ FileType::Video => "Video",
};
props.set_value(*prop_id, PropertyValue::String(String::from(file_type)));
}
diff --git a/crates/npc-engine/src/db/library.rs b/crates/npc-engine/src/db/library.rs
index 8a46f4d..73fd0c8 100644
--- a/crates/npc-engine/src/db/library.rs
+++ b/crates/npc-engine/src/db/library.rs
@@ -340,7 +340,7 @@ impl Library {
pub fn add_jpeg_file_to_bundle(&self, file_id: LibraryId, fsfile_id: LibraryId) -> Result<()> {
if let Some(ref conn) = self.dbconn {
- let filetype: i32 = libfile::FileType::RAW_JPEG.into();
+ let filetype: i32 = libfile::FileType::RawJpeg.into();
let c = conn.execute(
"UPDATE files SET jpeg_file=?1, file_type=?3 WHERE id=?2;",
&[&fsfile_id, &file_id, &filetype],
@@ -664,7 +664,7 @@ impl Library {
// Until we get better metadata support for RAW files, we use the Exif reconcile
// from the sidecar JPEG to get the initial metadata.
let meta = if let Some(bundle) = bundle {
- if bundle.bundle_type() == libfile::FileType::RAW_JPEG {
+ if bundle.bundle_type() == libfile::FileType::RawJpeg {
npc_fwk::XmpMeta::new_from_file(bundle.jpeg(), false)
} else {
npc_fwk::XmpMeta::new_from_file(file, false)
diff --git a/src/niepce/modules/darkroom/darkroommodule.cpp b/src/niepce/modules/darkroom/darkroommodule.cpp
index 06ef0bb..27e46d7 100644
--- a/src/niepce/modules/darkroom/darkroommodule.cpp
+++ b/src/niepce/modules/darkroom/darkroommodule.cpp
@@ -1,7 +1,7 @@
/*
* niepce - ui/darkroommodule.cpp
*
- * Copyright (C) 2008-2014 Hubert Figuiere
+ * Copyright (C) 2008-2020 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -52,8 +52,8 @@ void DarkroomModule::reload_image()
// currently we treat RAW + JPEG as RAW.
// TODO: have a way to actually choose the JPEG.
auto file_type = engine_db_libfile_file_type(file.get());
- bool isRaw = (file_type == eng::FileType::RAW)
- || (file_type == eng::FileType::RAW_JPEG);
+ bool isRaw = (file_type == eng::FileType::Raw)
+ || (file_type == eng::FileType::RawJpeg);
std::string path = engine_db_libfile_path(file.get());
m_image->reload(path, isRaw, engine_db_libfile_orientation(file.get()));
}
diff --git a/src/niepce/ui/library_cell_renderer.rs b/src/niepce/ui/library_cell_renderer.rs
index 7884c82..5d48eda 100644
--- a/src/niepce/ui/library_cell_renderer.rs
+++ b/src/niepce/ui/library_cell_renderer.rs
@@ -516,14 +516,14 @@ impl CellRendererImpl for LibraryCellRendererPriv {
if self.draw_emblem.get() {
let file_type = match &*file {
Some(f) => f.0.file_type(),
- None => FileType::UNKNOWN,
+ None => FileType::Unknown,
};
let emblem: Pixbuf = match file_type {
- FileType::RAW => EMBLEMS.raw.clone(),
- FileType::RAW_JPEG => EMBLEMS.raw_jpeg.clone(),
- FileType::IMAGE => EMBLEMS.img.clone(),
- FileType::VIDEO => EMBLEMS.video.clone(),
- FileType::UNKNOWN => EMBLEMS.unknown.clone(),
+ FileType::Raw => EMBLEMS.raw.clone(),
+ FileType::RawJpeg => EMBLEMS.raw_jpeg.clone(),
+ FileType::Image => EMBLEMS.img.clone(),
+ FileType::Video => EMBLEMS.video.clone(),
+ FileType::Unknown => EMBLEMS.unknown.clone(),
};
let left = Self::do_draw_format_emblem(cr, &emblem, &r);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]