[niepce] libfolder: Properly implement storing the folder path
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] libfolder: Properly implement storing the folder path
- Date: Fri, 27 Oct 2017 02:03:38 +0000 (UTC)
commit 299469fac4ea785255af0931967cc5fb303d2805
Author: Hubert Figuière <hub figuiere net>
Date: Thu Oct 26 19:39:49 2017 -0400
libfolder: Properly implement storing the folder path
Cargo.toml | 2 +-
src/engine/Makefile.am | 1 -
src/engine/db/libfolder.cpp | 38 -------------------------
src/engine/db/libfolder.hpp | 50 ---------------------------------
src/engine/db/libfolder.rs | 24 +++++----------
src/engine/db/library.rs | 6 ++--
src/niepce/ui/workspacecontroller.hpp | 1 -
7 files changed, 12 insertions(+), 110 deletions(-)
---
diff --git a/Cargo.toml b/Cargo.toml
index 0e47c19..12fa2f4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,7 +16,7 @@ rusqlite = { version = "0.12.0", features = ["functions"] }
[build-dependencies]
bindgen = "0.30.0"
-cbindgen = { version = "0.1.25", git = "https://github.com/eqrion/cbindgen.git" }
+cbindgen = { version = "=0.1.26" }
pkg-config = "0.3.9"
[lib]
diff --git a/src/engine/Makefile.am b/src/engine/Makefile.am
index e232e07..465447e 100644
--- a/src/engine/Makefile.am
+++ b/src/engine/Makefile.am
@@ -20,7 +20,6 @@ noinst_LIBRARIES = libniepceengine.a libniepceengineglue.a
libniepceengine_a_SOURCES = \
db/libfile.hpp db/libfile.cpp \
- db/libfolder.hpp db/libfolder.cpp \
db/label.hpp db/label.cpp \
db/libmetadata.hpp db/libmetadata.cpp \
db/storage.hpp \
diff --git a/src/engine/db/libfolder.rs b/src/engine/db/libfolder.rs
index 2a478f6..9c196a7 100644
--- a/src/engine/db/libfolder.rs
+++ b/src/engine/db/libfolder.rs
@@ -18,7 +18,6 @@
*/
use libc::c_char;
-use std::ffi::CStr;
use std::ffi::CString;
use rusqlite;
@@ -46,6 +45,7 @@ impl From<i32> for FolderVirtualType {
pub struct LibFolder {
id: LibraryId,
name: String,
+ path: String,
locked: bool,
expanded: bool,
virt: FolderVirtualType,
@@ -53,9 +53,11 @@ pub struct LibFolder {
}
impl LibFolder {
- pub fn new(id: LibraryId, name: &str) -> LibFolder {
+ pub fn new(id: LibraryId, name: &str, path: &str) -> LibFolder {
LibFolder {
- id: id, name: String::from(name), locked: false,
+ id: id, name: String::from(name),
+ path: String::from(path),
+ locked: false,
expanded: false, virt: FolderVirtualType::NONE,
cstr: CString::new("").unwrap(),
}
@@ -98,7 +100,7 @@ impl LibFolder {
impl FromDb for LibFolder {
fn read_db_columns() -> &'static str {
- "id,name,virtual,locked,expanded"
+ "id,name,virtual,locked,expanded,path"
}
fn read_db_tables() -> &'static str {
@@ -111,8 +113,9 @@ impl FromDb for LibFolder {
let virt_type: i32 = row.get(2);
let locked = row.get(3);
let expanded = row.get(4);
+ let path: String = row.get_checked(5).unwrap_or(String::from(""));
- let mut libfolder = LibFolder::new(id, &name);
+ let mut libfolder = LibFolder::new(id, &name, &path);
libfolder.set_virtual_type(FolderVirtualType::from(virt_type));
libfolder.set_locked(locked);
libfolder.set_expanded(expanded);
@@ -122,17 +125,6 @@ impl FromDb for LibFolder {
}
#[no_mangle]
-pub extern "C" fn engine_db_libfolder_new(id: i64, name: *const c_char) -> *mut LibFolder {
- let lf = Box::new(LibFolder::new(id, &*unsafe { CStr::from_ptr(name) }.to_string_lossy()));
- Box::into_raw(lf)
-}
-
-#[no_mangle]
-pub extern "C" fn engine_db_libfolder_delete(lf: *mut LibFolder) {
- unsafe { Box::from_raw(lf) };
-}
-
-#[no_mangle]
pub extern "C" fn engine_db_libfolder_id(obj: &LibFolder) -> i64 {
obj.id() as i64
}
diff --git a/src/engine/db/library.rs b/src/engine/db/library.rs
index 96d321f..cbff68a 100644
--- a/src/engine/db/library.rs
+++ b/src/engine/db/library.rs
@@ -155,8 +155,8 @@ impl Library {
expanded INTEGER DEFAULT 0, \
parent_id INTEGER)", &[]).unwrap();
let trash_type = libfolder::FolderVirtualType::TRASH as i32;
- conn.execute("insert into folders (name, locked, virtual, parent_id) \
- values (:1, 1, :2, 0)",
+ conn.execute("insert into folders (name, locked, virtual, parent_id, path) \
+ values (:1, 1, :2, 0, '')",
&[&"Trash", &trash_type]).unwrap();
conn.execute("CREATE TABLE files (id INTEGER PRIMARY KEY,\
@@ -273,7 +273,7 @@ impl Library {
}
let id = conn.last_insert_rowid();
dbg_out!("last row inserted {}", id);
- return Some(LibFolder::new(id, &foldername));
+ return Some(LibFolder::new(id, &foldername, &folder));
}
}
}
diff --git a/src/niepce/ui/workspacecontroller.hpp b/src/niepce/ui/workspacecontroller.hpp
index b2a2733..1b04094 100644
--- a/src/niepce/ui/workspacecontroller.hpp
+++ b/src/niepce/ui/workspacecontroller.hpp
@@ -30,7 +30,6 @@
#include <gtkmm/label.h>
#include <gtkmm/treestore.h>
-#include "engine/db/libfolder.hpp"
#include "fwk/toolkit/uicontroller.hpp"
#include "fwk/toolkit/notification.hpp"
#include "niepce/ui/niepcewindow.hpp"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]