pub fn init_from_model(&mut self, model: &entity::note::Model) {
self.text.set(model.content.as_str());
- let tab = match(model.kind) {
+ let tab = match model.kind {
NoteType::PlainTextNote => NoteTypeTabView::TextArea,
NoteType::MDTextNote => NoteTypeTabView::TextArea,
- _ => NoteTypeTabView::Empty
};
self.note_type.set(tab as i64);
}
use ui_rs::{action, ui_actions, UiModel};
use ui_rs::ui::*;
-use entity::note::{Model as Note, NoteType};
-use crate::window::NoteTypeTabView;
+use entity::note::{Model as Note};
#[derive(UiModel, Default)]
pub struct Notebook {
#[action]
pub fn note_selected(&mut self, event: &ActionEvent) {
- if let (EventType::ListSelection(s)) = event.event_type {
+ if let EventType::ListSelection(s) = event.event_type {
if let Some(note) = s.selected_element(self.notes.data()) {
// detach the current note
if let Some(current) = &self.selected_note {
}
// Create the new note
- let mut note_data: crate::note::Note = Default::default();
+ let note_data: crate::note::Note = Default::default();
// TODO: setting the text here is the right thing to do, but for some
// reasons it doesn't work yet. Fix this shit.
//note_data.text.set(note.content.as_str());
});
let proxy = doc.doc_proxy();
e.data.backend.get_notes(nb.collection_id, |result|{
- proxy.call_mainthread(|nb| {
+ proxy.call_mainthread(|_, nb| {
match result {
Ok(notes) => {
nb.set_notes(notes);
.model(&model)
.fill(true)
.getvalue(note_getvalue)
- .onselection_action(("note_selected"))
+ .onselection_action("note_selected")
.create();
});
}
pub enum NoteTypeTabView {
- Empty = 0,
+ _Empty = 0,
TextArea = 1
}
\ No newline at end of file
}
}
- pub fn new(mut data: T) -> UiDoc<T> {
+ pub fn new(data: T) -> UiDoc<T> {
UiDoc::new2(data, |_,_| {})
}
- pub fn new2<F>(mut data: T, init: F) -> UiDoc<T>
+ pub fn new2<F>(data: T, init: F) -> UiDoc<T>
where F: FnOnce(&mut T, &UiDoc<T>) {
unsafe {
let doc = ui_document_new(mem::size_of::<*mut T>());
}
pub fn call_mainthread<F>(self, f: F)
- where F: FnOnce(&mut T) + Send + 'static {
+ where F: FnOnce(&UiDoc<T>, &mut T) + Send + 'static {
call_mainthread(|| {
let doc: UiDoc<T> = UiDoc::from_ptr(self.ptr);
unsafe {
let data = doc.get_data_ptr();
- f(&mut *data);
+ f(&doc, &mut *data);
}
drop(self);
});
}
None
}
+
+ pub fn count(&self) -> usize {
+ unsafe {
+ ui_list_selection_get_count(self.ptr) as usize
+ }
+ }
}