[niepce] niepce: Cargo format
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] niepce: Cargo format
- Date: Wed, 11 Dec 2019 01:18:47 +0000 (UTC)
commit a459f8410ba5278b94f5b5ed0aae8728c7c45664
Author: Hubert Figuière <hub figuiere net>
Date: Sun Oct 27 17:05:23 2019 -0400
niepce: Cargo format
src/libraryclient/clientimpl.rs | 110 +++++++------------
src/libraryclient/clientinterface.rs | 9 +-
src/libraryclient/mod.rs | 170 +++++++++++++++++++-----------
src/niepce/mod.rs | 2 -
src/niepce/ui/dialogs/confirm.rs | 23 ++--
src/niepce/ui/dialogs/requestnewfolder.rs | 30 +++---
src/niepce/ui/imagetoolbar.rs | 19 ++--
src/niepce/ui/mod.rs | 2 -
8 files changed, 192 insertions(+), 173 deletions(-)
---
diff --git a/src/libraryclient/clientimpl.rs b/src/libraryclient/clientimpl.rs
index fba5caa..ac6de46 100644
--- a/src/libraryclient/clientimpl.rs
+++ b/src/libraryclient/clientimpl.rs
@@ -20,18 +20,18 @@
use std::collections::VecDeque;
use std::path::PathBuf;
use std::sync;
-use std::sync::mpsc;
use std::sync::atomic;
+use std::sync::mpsc;
use std::thread;
-use npc_fwk::base::PropertyValue;
-use npc_engine::db::{Library, LibraryId};
+use super::clientinterface::{ClientInterface, ClientInterfaceSync};
use npc_engine::db::library::Managed;
-use npc_engine::library::op::Op;
+use npc_engine::db::{Library, LibraryId};
use npc_engine::library::commands;
use npc_engine::library::notification::LibNotification;
-use super::clientinterface::{ClientInterface,ClientInterfaceSync};
+use npc_engine::library::op::Op;
use npc_engine::root::eng::NiepceProperties as Np;
+use npc_fwk::base::PropertyValue;
pub struct ClientImpl {
terminate: sync::Arc<atomic::AtomicBool>,
@@ -45,19 +45,18 @@ impl Drop for ClientImpl {
}
impl ClientImpl {
-
pub fn new(dir: PathBuf, sender: npc_fwk::toolkit::Sender<LibNotification>) -> ClientImpl {
let tasks = sync::Arc::new((sync::Mutex::new(VecDeque::new()), sync::Condvar::new()));
let mut terminate = sync::Arc::new(atomic::AtomicBool::new(false));
let tasks2 = tasks.clone();
let terminate2 = terminate.clone();
- /* let thread = */ thread::spawn(move || {
+ /* let thread = */
+ thread::spawn(move || {
let library = Library::new(&dir, None, sender);
Self::main(&mut terminate, &tasks, &library);
});
-
ClientImpl {
terminate: terminate2,
tasks: tasks2,
@@ -69,12 +68,12 @@ impl ClientImpl {
self.tasks.1.notify_one();
}
- fn main(terminate: &mut sync::Arc<atomic::AtomicBool>,
- tasks: &sync::Arc<(sync::Mutex<VecDeque<Op>>, sync::Condvar)>,
- library: &Library) {
-
+ fn main(
+ terminate: &mut sync::Arc<atomic::AtomicBool>,
+ tasks: &sync::Arc<(sync::Mutex<VecDeque<Op>>, sync::Condvar)>,
+ library: &Library,
+ ) {
while !terminate.load(atomic::Ordering::Relaxed) {
-
let elem: Option<Op>;
{
let mut queue = tasks.0.lock().unwrap();
@@ -100,109 +99,78 @@ impl ClientImpl {
}
pub fn schedule_op<F>(&mut self, f: F)
- where F: Fn(&Library) -> bool + Send + Sync + 'static {
-
+ where
+ F: Fn(&Library) -> bool + Send + Sync + 'static,
+ {
let op = Op::new(f);
let mut queue = self.tasks.0.lock().unwrap();
queue.push_back(op);
self.tasks.1.notify_all();
}
-
}
impl ClientInterface for ClientImpl {
/// get all the keywords
fn get_all_keywords(&mut self) {
- self.schedule_op(move |lib| {
- commands::cmd_list_all_keywords(&lib)
- });
+ self.schedule_op(move |lib| commands::cmd_list_all_keywords(&lib));
}
fn query_keyword_content(&mut self, keyword_id: LibraryId) {
- self.schedule_op(move |lib| {
- commands::cmd_query_keyword_content(&lib, keyword_id)
- });
+ self.schedule_op(move |lib| commands::cmd_query_keyword_content(&lib, keyword_id));
}
fn count_keyword(&mut self, id: LibraryId) {
- self.schedule_op(move |lib| {
- commands::cmd_count_keyword(&lib, id)
- });
+ self.schedule_op(move |lib| commands::cmd_count_keyword(&lib, id));
}
/// get all the folder
fn get_all_folders(&mut self) {
- self.schedule_op(move |lib| {
- commands::cmd_list_all_folders(&lib)
- });
+ self.schedule_op(move |lib| commands::cmd_list_all_folders(&lib));
}
fn query_folder_content(&mut self, folder_id: LibraryId) {
- self.schedule_op(move |lib| {
- commands::cmd_query_folder_content(&lib, folder_id)
- });
+ self.schedule_op(move |lib| commands::cmd_query_folder_content(&lib, folder_id));
}
fn count_folder(&mut self, folder_id: LibraryId) {
- self.schedule_op(move |lib| {
- commands::cmd_count_folder(&lib, folder_id)
- });
+ self.schedule_op(move |lib| commands::cmd_count_folder(&lib, folder_id));
}
fn create_folder(&mut self, name: String, path: Option<String>) {
- self.schedule_op(move |lib| {
- commands::cmd_create_folder(&lib, &name, path.clone()) != 0
- });
+ self.schedule_op(move |lib| commands::cmd_create_folder(&lib, &name, path.clone()) != 0);
}
fn delete_folder(&mut self, id: LibraryId) {
- self.schedule_op(move |lib| {
- commands::cmd_delete_folder(&lib, id)
- });
+ self.schedule_op(move |lib| commands::cmd_delete_folder(&lib, id));
}
fn request_metadata(&mut self, file_id: LibraryId) {
- self.schedule_op(move |lib| {
- commands::cmd_request_metadata(&lib, file_id)
- });
+ self.schedule_op(move |lib| commands::cmd_request_metadata(&lib, file_id));
}
/// set the metadata
fn set_metadata(&mut self, file_id: LibraryId, meta: Np, value: &PropertyValue) {
let value2 = value.clone();
- self.schedule_op(move |lib| {
- commands::cmd_set_metadata(&lib, file_id, meta, &value2)
- });
+ self.schedule_op(move |lib| commands::cmd_set_metadata(&lib, file_id, meta, &value2));
}
fn write_metadata(&mut self, file_id: LibraryId) {
- self.schedule_op(move |lib| {
- commands::cmd_write_metadata(&lib, file_id)
- });
+ self.schedule_op(move |lib| commands::cmd_write_metadata(&lib, file_id));
}
- fn move_file_to_folder(&mut self, file_id: LibraryId, from: LibraryId,
- to: LibraryId) {
- self.schedule_op(move |lib| {
- commands::cmd_move_file_to_folder(&lib, file_id, from, to)
- });
+ fn move_file_to_folder(&mut self, file_id: LibraryId, from: LibraryId, to: LibraryId) {
+ self.schedule_op(move |lib| commands::cmd_move_file_to_folder(&lib, file_id, from, to));
}
/// get all the labels
fn get_all_labels(&mut self) {
- self.schedule_op(move |lib| {
- commands::cmd_list_all_labels(&lib)
- });
+ self.schedule_op(move |lib| commands::cmd_list_all_labels(&lib));
}
fn create_label(&mut self, name: String, colour: String) {
- self.schedule_op(move |lib| {
- commands::cmd_create_label(&lib, &name, &colour) != 0
- });
+ self.schedule_op(move |lib| commands::cmd_create_label(&lib, &name, &colour) != 0);
}
fn delete_label(&mut self, label_id: LibraryId) {
- self.schedule_op(move |lib| {
- commands::cmd_delete_label(&lib, label_id)
- });
+ self.schedule_op(move |lib| commands::cmd_delete_label(&lib, label_id));
}
/// update a label
fn update_label(&mut self, label_id: LibraryId, new_name: String, new_colour: String) {
@@ -213,30 +181,25 @@ impl ClientInterface for ClientImpl {
/// tell to process the Xmp update Queue
fn process_xmp_update_queue(&mut self, write_xmp: bool) {
- self.schedule_op(move |lib| {
- commands::cmd_process_xmp_update_queue(&lib, write_xmp)
- });
+ self.schedule_op(move |lib| commands::cmd_process_xmp_update_queue(&lib, write_xmp));
}
/// Import files from a directory
/// @param dir the directory
/// @param manage true if imports have to be managed
fn import_files(&mut self, dir: String, files: Vec<String>, manage: Managed) {
- self.schedule_op(move |lib| {
- commands::cmd_import_files(&lib, &dir, &files, manage)
- });
+ self.schedule_op(move |lib| commands::cmd_import_files(&lib, &dir, &files, manage));
}
}
-
impl ClientInterfaceSync for ClientImpl {
-
fn create_label_sync(&mut self, name: String, colour: String) -> LibraryId {
// can't use futures::sync::oneshot
let (tx, rx) = mpsc::sync_channel::<LibraryId>(1);
self.schedule_op(move |lib| {
- tx.send(commands::cmd_create_label(&lib, &name, &colour)).unwrap();
+ tx.send(commands::cmd_create_label(&lib, &name, &colour))
+ .unwrap();
true
});
@@ -260,7 +223,8 @@ impl ClientInterfaceSync for ClientImpl {
let (tx, rx) = mpsc::sync_channel::<LibraryId>(1);
self.schedule_op(move |lib| {
- tx.send(commands::cmd_create_folder(&lib, &name, path.clone())).unwrap();
+ tx.send(commands::cmd_create_folder(&lib, &name, path.clone()))
+ .unwrap();
true
});
diff --git a/src/libraryclient/clientinterface.rs b/src/libraryclient/clientinterface.rs
index 2372900..773ab70 100644
--- a/src/libraryclient/clientinterface.rs
+++ b/src/libraryclient/clientinterface.rs
@@ -17,14 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-use npc_fwk::base::PropertyValue;
-use npc_engine::db::LibraryId;
use npc_engine::db::library::Managed;
+use npc_engine::db::LibraryId;
use npc_engine::root::eng::NiepceProperties as Np;
+use npc_fwk::base::PropertyValue;
/// Client interface.
pub trait ClientInterface {
-
/// get all the keywords
fn get_all_keywords(&mut self);
fn query_keyword_content(&mut self, id: LibraryId);
@@ -42,8 +41,7 @@ pub trait ClientInterface {
fn set_metadata(&mut self, id: LibraryId, meta: Np, value: &PropertyValue);
fn write_metadata(&mut self, id: LibraryId);
- fn move_file_to_folder(&mut self, file_id: LibraryId, from: LibraryId,
- to: LibraryId);
+ fn move_file_to_folder(&mut self, file_id: LibraryId, from: LibraryId, to: LibraryId);
/// get all the labels
fn get_all_labels(&mut self);
fn create_label(&mut self, label: String, colour: String);
@@ -63,7 +61,6 @@ pub trait ClientInterface {
/// Sync client interface
pub trait ClientInterfaceSync {
-
/// Create a keyword. Return the id for the keyword.
/// If the keyword already exists, return its `LibraryId`.
fn create_keyword_sync(&mut self, keyword: String) -> LibraryId;
diff --git a/src/libraryclient/mod.rs b/src/libraryclient/mod.rs
index a3d0b3e..e2d9c02 100644
--- a/src/libraryclient/mod.rs
+++ b/src/libraryclient/mod.rs
@@ -20,31 +20,33 @@
pub mod clientimpl;
pub mod clientinterface;
-pub use self::clientinterface::{ClientInterface,ClientInterfaceSync};
+pub use self::clientinterface::{ClientInterface, ClientInterfaceSync};
use libc::{c_char, c_void};
use std::ffi::CStr;
use std::path::PathBuf;
use std::sync::Arc;
-use npc_fwk::base::PropertyValue;
-use npc_fwk::toolkit::PortableChannel;
use self::clientimpl::ClientImpl;
-use npc_engine::db::LibraryId;
use npc_engine::db::library::Managed;
-use npc_engine::library::notification::{LibNotification, LcChannel};
-use npc_engine::root::fwk::FileList;
+use npc_engine::db::LibraryId;
+use npc_engine::library::notification::{LcChannel, LibNotification};
use npc_engine::root::eng::NiepceProperties as Np;
+use npc_engine::root::fwk::FileList;
+use npc_fwk::base::PropertyValue;
+use npc_fwk::toolkit::PortableChannel;
/// Wrap the libclient Arc so that it can be passed around
/// Used in the ffi for example.
pub struct LibraryClientWrapper {
- client: Arc<LibraryClient>
+ client: Arc<LibraryClient>,
}
impl LibraryClientWrapper {
pub fn new(dir: PathBuf, sender: glib::Sender<LibNotification>) -> LibraryClientWrapper {
- LibraryClientWrapper { client: Arc::new(LibraryClient::new(dir, sender)) }
+ LibraryClientWrapper {
+ client: Arc::new(LibraryClient::new(dir, sender)),
+ }
}
/// unwrap the mutable client Arc
@@ -58,15 +60,14 @@ impl LibraryClientWrapper {
pub struct LibraryClient {
pimpl: ClientImpl,
- trash_id: LibraryId
+ trash_id: LibraryId,
}
impl LibraryClient {
-
pub fn new(dir: PathBuf, sender: glib::Sender<LibNotification>) -> LibraryClient {
LibraryClient {
pimpl: ClientImpl::new(dir, sender),
- trash_id: 0
+ trash_id: 0,
}
}
@@ -77,7 +78,6 @@ impl LibraryClient {
pub fn set_trash_id(&mut self, id: LibraryId) {
self.trash_id = id;
}
-
}
impl ClientInterface for LibraryClient {
@@ -122,8 +122,7 @@ impl ClientInterface for LibraryClient {
self.pimpl.write_metadata(id);
}
- fn move_file_to_folder(&mut self, file_id: LibraryId, from: LibraryId,
- to: LibraryId) {
+ fn move_file_to_folder(&mut self, file_id: LibraryId, from: LibraryId, to: LibraryId) {
self.pimpl.move_file_to_folder(file_id, from, to);
}
/// get all the labels
@@ -152,7 +151,6 @@ impl ClientInterface for LibraryClient {
fn import_files(&mut self, dir: String, files: Vec<String>, manage: Managed) {
self.pimpl.import_files(dir, files, manage);
}
-
}
impl ClientInterfaceSync for LibraryClient {
@@ -170,7 +168,10 @@ impl ClientInterfaceSync for LibraryClient {
}
#[no_mangle]
-pub unsafe extern "C" fn lcchannel_new(cb: extern fn(n: *const LibNotification, data: *mut c_void) -> i32,
data: *mut c_void) -> *mut LcChannel {
+pub unsafe extern "C" fn lcchannel_new(
+ cb: extern "C" fn(n: *const LibNotification, data: *mut c_void) -> i32,
+ data: *mut c_void,
+) -> *mut LcChannel {
let (sender, receiver) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
let source_id = receiver.attach(None, move |n: LibNotification| {
let mut continuation = false;
@@ -179,7 +180,9 @@ pub unsafe extern "C" fn lcchannel_new(cb: extern fn(n: *const LibNotification,
}
glib::Continue(continuation)
});
- Box::into_raw(Box::new(PortableChannel::<LibNotification>(sender, source_id)))
+ Box::into_raw(Box::new(PortableChannel::<LibNotification>(
+ sender, source_id,
+ )))
}
#[no_mangle]
@@ -195,9 +198,15 @@ pub unsafe extern "C" fn lcchannel_destroy(obj: *mut LcChannel) {
}
#[no_mangle]
-pub unsafe extern "C" fn libraryclient_new(path: *const c_char, channel: *const LcChannel) -> *mut
LibraryClientWrapper {
+pub unsafe extern "C" fn libraryclient_new(
+ path: *const c_char,
+ channel: *const LcChannel,
+) -> *mut LibraryClientWrapper {
let dir = PathBuf::from(&*CStr::from_ptr(path).to_string_lossy());
- Box::into_raw(Box::new(LibraryClientWrapper::new(dir, (*channel).0.clone())))
+ Box::into_raw(Box::new(LibraryClientWrapper::new(
+ dir,
+ (*channel).0.clone(),
+ )))
}
#[no_mangle]
@@ -226,15 +235,19 @@ pub extern "C" fn libraryclient_get_all_folders(client: &mut LibraryClientWrappe
}
#[no_mangle]
-pub extern "C" fn libraryclient_query_folder_content(client: &mut LibraryClientWrapper,
- folder_id: LibraryId) {
+pub extern "C" fn libraryclient_query_folder_content(
+ client: &mut LibraryClientWrapper,
+ folder_id: LibraryId,
+) {
client.unwrap_mut().query_folder_content(folder_id);
}
#[no_mangle]
-pub unsafe extern "C" fn libraryclient_create_folder_sync(client: &mut LibraryClientWrapper,
- n: *const c_char,
- p: *const c_char) -> LibraryId {
+pub unsafe extern "C" fn libraryclient_create_folder_sync(
+ client: &mut LibraryClientWrapper,
+ n: *const c_char,
+ p: *const c_char,
+) -> LibraryId {
let name = String::from(CStr::from_ptr(n).to_string_lossy());
let path = if p.is_null() {
None
@@ -245,53 +258,64 @@ pub unsafe extern "C" fn libraryclient_create_folder_sync(client: &mut LibraryCl
}
#[no_mangle]
-pub extern "C" fn libraryclient_delete_folder(client: &mut LibraryClientWrapper,
- id: LibraryId) {
+pub extern "C" fn libraryclient_delete_folder(client: &mut LibraryClientWrapper, id: LibraryId) {
client.unwrap_mut().delete_folder(id);
}
#[no_mangle]
-pub extern "C" fn libraryclient_count_folder(client: &mut LibraryClientWrapper,
- folder_id: LibraryId) {
+pub extern "C" fn libraryclient_count_folder(
+ client: &mut LibraryClientWrapper,
+ folder_id: LibraryId,
+) {
client.unwrap_mut().count_folder(folder_id);
}
#[no_mangle]
-pub extern "C" fn libraryclient_query_keyword_content(client: &mut LibraryClientWrapper,
- keyword_id: LibraryId) {
+pub extern "C" fn libraryclient_query_keyword_content(
+ client: &mut LibraryClientWrapper,
+ keyword_id: LibraryId,
+) {
client.unwrap_mut().query_keyword_content(keyword_id);
}
#[no_mangle]
-pub extern "C" fn libraryclient_count_keyword(client: &mut LibraryClientWrapper,
- id: LibraryId) {
+pub extern "C" fn libraryclient_count_keyword(client: &mut LibraryClientWrapper, id: LibraryId) {
client.unwrap_mut().count_keyword(id);
}
#[no_mangle]
-pub extern "C" fn libraryclient_request_metadata(client: &mut LibraryClientWrapper,
- file_id: LibraryId) {
+pub extern "C" fn libraryclient_request_metadata(
+ client: &mut LibraryClientWrapper,
+ file_id: LibraryId,
+) {
client.unwrap_mut().request_metadata(file_id);
}
#[no_mangle]
-pub extern "C" fn libraryclient_set_metadata(client: &mut LibraryClientWrapper,
- file_id: LibraryId,
- meta: Np, value: &PropertyValue) {
+pub extern "C" fn libraryclient_set_metadata(
+ client: &mut LibraryClientWrapper,
+ file_id: LibraryId,
+ meta: Np,
+ value: &PropertyValue,
+) {
client.unwrap_mut().set_metadata(file_id, meta, value);
}
#[no_mangle]
-pub extern "C" fn libraryclient_write_metadata(client: &mut LibraryClientWrapper,
- file_id: LibraryId) {
+pub extern "C" fn libraryclient_write_metadata(
+ client: &mut LibraryClientWrapper,
+ file_id: LibraryId,
+) {
client.unwrap_mut().write_metadata(file_id);
}
#[no_mangle]
-pub extern "C" fn libraryclient_move_file_to_folder(client: &mut LibraryClientWrapper,
- file_id: LibraryId,
- from: LibraryId,
- to: LibraryId) {
+pub extern "C" fn libraryclient_move_file_to_folder(
+ client: &mut LibraryClientWrapper,
+ file_id: LibraryId,
+ from: LibraryId,
+ to: LibraryId,
+) {
client.unwrap_mut().move_file_to_folder(file_id, from, to);
}
@@ -301,48 +325,70 @@ pub extern "C" fn libraryclient_get_all_labels(client: &mut LibraryClientWrapper
}
#[no_mangle]
-pub unsafe extern "C" fn libraryclient_create_label(client: &mut LibraryClientWrapper,
- s: *const c_char, c: *const c_char) {
+pub unsafe extern "C" fn libraryclient_create_label(
+ client: &mut LibraryClientWrapper,
+ s: *const c_char,
+ c: *const c_char,
+) {
let name = CStr::from_ptr(s).to_string_lossy();
let colour = CStr::from_ptr(c).to_string_lossy();
- client.unwrap_mut().create_label(String::from(name), String::from(colour));
+ client
+ .unwrap_mut()
+ .create_label(String::from(name), String::from(colour));
}
#[no_mangle]
pub unsafe extern "C" fn libraryclient_create_label_sync(
- client: &mut LibraryClientWrapper, s: *const c_char, c: *const c_char) -> LibraryId {
+ client: &mut LibraryClientWrapper,
+ s: *const c_char,
+ c: *const c_char,
+) -> LibraryId {
let name = CStr::from_ptr(s).to_string_lossy();
let colour = CStr::from_ptr(c).to_string_lossy();
- client.unwrap_mut().create_label_sync(String::from(name), String::from(colour))
+ client
+ .unwrap_mut()
+ .create_label_sync(String::from(name), String::from(colour))
}
#[no_mangle]
-pub extern "C" fn libraryclient_delete_label(client: &mut LibraryClientWrapper,
- label_id: LibraryId) {
+pub extern "C" fn libraryclient_delete_label(
+ client: &mut LibraryClientWrapper,
+ label_id: LibraryId,
+) {
client.unwrap_mut().delete_label(label_id);
}
#[no_mangle]
-pub unsafe extern "C" fn libraryclient_update_label(client: &mut LibraryClientWrapper,
- label_id: LibraryId,
- s: *const c_char, c: *const c_char) {
+pub unsafe extern "C" fn libraryclient_update_label(
+ client: &mut LibraryClientWrapper,
+ label_id: LibraryId,
+ s: *const c_char,
+ c: *const c_char,
+) {
let name = CStr::from_ptr(s).to_string_lossy();
let colour = CStr::from_ptr(c).to_string_lossy();
- client.unwrap_mut().update_label(label_id, String::from(name), String::from(colour));
+ client
+ .unwrap_mut()
+ .update_label(label_id, String::from(name), String::from(colour));
}
#[no_mangle]
-pub extern "C" fn libraryclient_process_xmp_update_queue(client: &mut LibraryClientWrapper,
- write_xmp: bool) {
+pub extern "C" fn libraryclient_process_xmp_update_queue(
+ client: &mut LibraryClientWrapper,
+ write_xmp: bool,
+) {
client.unwrap_mut().process_xmp_update_queue(write_xmp);
}
#[no_mangle]
-pub unsafe extern "C" fn libraryclient_import_files(client: &mut LibraryClientWrapper,
- dir: *const c_char, cfiles: &mut FileList,
- manage: Managed) {
+pub unsafe extern "C" fn libraryclient_import_files(
+ client: &mut LibraryClientWrapper,
+ dir: *const c_char,
+ cfiles: &mut FileList,
+ manage: Managed,
+) {
let folder = CStr::from_ptr(dir).to_string_lossy();
- let mut files: Vec<String> = vec!();
+ let mut files: Vec<String> = vec![];
{
let len = cfiles.size();
for i in 0..len {
@@ -351,5 +397,7 @@ pub unsafe extern "C" fn libraryclient_import_files(client: &mut LibraryClientWr
files.push(String::from(cstr));
}
}
- client.unwrap_mut().import_files(String::from(folder), files, manage);
+ client
+ .unwrap_mut()
+ .import_files(String::from(folder), files, manage);
}
diff --git a/src/niepce/mod.rs b/src/niepce/mod.rs
index e22bb4a..6bae95d 100644
--- a/src/niepce/mod.rs
+++ b/src/niepce/mod.rs
@@ -1,3 +1 @@
-
-
pub mod ui;
diff --git a/src/niepce/ui/dialogs/confirm.rs b/src/niepce/ui/dialogs/confirm.rs
index ce3c825..0f3310a 100644
--- a/src/niepce/ui/dialogs/confirm.rs
+++ b/src/niepce/ui/dialogs/confirm.rs
@@ -21,23 +21,26 @@ use libc::c_char;
use std::ffi::CStr;
use glib::translate::*;
-use gtk::prelude::*;
use gtk;
+use gtk::prelude::*;
+use gtk::MessageDialog;
use gtk_sys;
-use gtk::{
- MessageDialog,
-};
#[no_mangle]
-pub unsafe extern "C" fn dialog_confirm(message: *const c_char,
- parent: *mut gtk_sys::GtkWindow) -> bool {
-
+pub unsafe extern "C" fn dialog_confirm(
+ message: *const c_char,
+ parent: *mut gtk_sys::GtkWindow,
+) -> bool {
let mut result: bool = false;
let msg = CStr::from_ptr(message).to_string_lossy();
let parent = gtk::Window::from_glib_none(parent);
- let dialog = MessageDialog::new(Some(&parent), gtk::DialogFlags::MODAL,
- gtk::MessageType::Question, gtk::ButtonsType::YesNo,
- &*msg);
+ let dialog = MessageDialog::new(
+ Some(&parent),
+ gtk::DialogFlags::MODAL,
+ gtk::MessageType::Question,
+ gtk::ButtonsType::YesNo,
+ &*msg,
+ );
if dialog.run() == gtk::ResponseType::Yes.into() {
result = true;
diff --git a/src/niepce/ui/dialogs/requestnewfolder.rs b/src/niepce/ui/dialogs/requestnewfolder.rs
index 992268f..3d4f4a4 100644
--- a/src/niepce/ui/dialogs/requestnewfolder.rs
+++ b/src/niepce/ui/dialogs/requestnewfolder.rs
@@ -19,26 +19,28 @@
use gettextrs::gettext;
use glib::translate::*;
-use gtk::prelude::*;
use gtk;
+use gtk::prelude::*;
+use gtk::{Dialog, Entry, Label};
use gtk_sys;
-use gtk::{
- Dialog,
- Entry,
- Label,
-};
-use libraryclient::{ClientInterface,LibraryClientWrapper};
+use libraryclient::{ClientInterface, LibraryClientWrapper};
#[no_mangle]
-pub unsafe extern "C" fn dialog_request_new_folder(client: &mut LibraryClientWrapper,
- parent: *mut gtk_sys::GtkWindow) {
+pub unsafe extern "C" fn dialog_request_new_folder(
+ client: &mut LibraryClientWrapper,
+ parent: *mut gtk_sys::GtkWindow,
+) {
let parent = gtk::Window::from_glib_none(parent);
let dialog = Dialog::new_with_buttons(
- Some("New folder"), Some(&parent),
+ Some("New folder"),
+ Some(&parent),
gtk::DialogFlags::MODAL,
- &[(&gettext("OK"), gtk::ResponseType::Ok.into()),
- (&gettext("Cancel"), gtk::ResponseType::Cancel.into())]);
+ &[
+ (&gettext("OK"), gtk::ResponseType::Ok.into()),
+ (&gettext("Cancel"), gtk::ResponseType::Cancel.into()),
+ ],
+ );
let label = Label::new_with_mnemonic(Some(gettext("Folder _name:").as_str()));
dialog.get_content_area().pack_start(&label, true, false, 4);
let entry = Entry::new();
@@ -51,6 +53,8 @@ pub unsafe extern "C" fn dialog_request_new_folder(client: &mut LibraryClientWra
let folder_name = entry.get_text();
dialog.destroy();
if !cancel && folder_name.is_some() {
- client.unwrap_mut().create_folder(folder_name.unwrap().to_string(), None);
+ client
+ .unwrap_mut()
+ .create_folder(folder_name.unwrap().to_string(), None);
}
}
diff --git a/src/niepce/ui/imagetoolbar.rs b/src/niepce/ui/imagetoolbar.rs
index bd5006c..21bb669 100644
--- a/src/niepce/ui/imagetoolbar.rs
+++ b/src/niepce/ui/imagetoolbar.rs
@@ -17,10 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
use glib::translate::*;
-use gtk::prelude::*;
use gtk;
+use gtk::prelude::*;
use gtk_sys;
#[no_mangle]
@@ -28,13 +27,17 @@ pub extern "C" fn image_toolbar_new() -> *mut gtk_sys::GtkToolbar {
let toolbar = gtk::Toolbar::new();
let icon = gtk::Image::new_from_icon_name(
- Some("go-previous-symbolic"), gtk::IconSize::SmallToolbar.into());
+ Some("go-previous-symbolic"),
+ gtk::IconSize::SmallToolbar.into(),
+ );
let tool_item = gtk::ToolButton::new(Some(&icon), None);
tool_item.set_action_name(Some("shell.PrevImage"));
toolbar.add(&tool_item);
let icon = gtk::Image::new_from_icon_name(
- Some("go-next-symbolic"), gtk::IconSize::SmallToolbar.into());
+ Some("go-next-symbolic"),
+ gtk::IconSize::SmallToolbar.into(),
+ );
let tool_item = gtk::ToolButton::new(Some(&icon), None);
tool_item.set_action_name(Some("shell.NextImage"));
toolbar.add(&tool_item);
@@ -43,13 +46,17 @@ pub extern "C" fn image_toolbar_new() -> *mut gtk_sys::GtkToolbar {
toolbar.add(&separator);
let icon = gtk::Image::new_from_icon_name(
- Some("object-rotate-left-symbolic"), gtk::IconSize::SmallToolbar.into());
+ Some("object-rotate-left-symbolic"),
+ gtk::IconSize::SmallToolbar.into(),
+ );
let tool_item = gtk::ToolButton::new(Some(&icon), None);
tool_item.set_action_name(Some("shell.RotateLeft"));
toolbar.add(&tool_item);
let icon = gtk::Image::new_from_icon_name(
- Some("object-rotate-right-symbolic"), gtk::IconSize::SmallToolbar.into());
+ Some("object-rotate-right-symbolic"),
+ gtk::IconSize::SmallToolbar.into(),
+ );
let tool_item = gtk::ToolButton::new(Some(&icon), None);
tool_item.set_action_name(Some("shell.RotateRight"));
toolbar.add(&tool_item);
diff --git a/src/niepce/ui/mod.rs b/src/niepce/ui/mod.rs
index 45d37c6..fdbc266 100644
--- a/src/niepce/ui/mod.rs
+++ b/src/niepce/ui/mod.rs
@@ -1,4 +1,2 @@
-
-
pub mod dialogs;
pub mod imagetoolbar;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]