.closebutton_label = "Cancel",
.result = delete_result);
free(msg.ptr);
-}
\ No newline at end of file
+}
*/
Note *current_note;
+ /*
+ * some actions might trigger unwanted selection events
+ * if this is true, selection events for the notes list are not handled
+ */
+ UiBool disable_selection_events;
+
/*
* The mempool used to allocate the current list of notes
*/
if(note->note_id == 0) {
// new note
note_store_new_note_async(obj, note, NULL, NULL);
+ notebook->disable_selection_events = TRUE;
ui_list_append(notebook->notes, note);
ui_list_update(notebook->notes);
+ notebook->disable_selection_events = FALSE;
} else {
note_store_save_note_async(obj, note, NULL, NULL);
}
void notebookmodel_detach_current_note(NotebookModel *model) {
if(model->current_note) {
+ Note *current_note = model->current_note;
// TODO: model->modified doesnt work yet, remove || 1 when it works
- if(model->current_note->model->modified || 1) {
+ if(current_note->model->modified || 1) {
note_save(model->window->obj, model, model->current_note);
}
// TODO: in theory ui_detach_document2 should save the state
// of all vars, but it seems this doesn't work
// without note_save, the content is not saved (internally)
- if(model->current_note->model) {
- ui_detach_document2(model->ctx, model->current_note->model);
+ if(current_note->model) {
+ ui_detach_document2(model->ctx, current_note->model);
}
model->current_note = NULL;
}
return 0; // should not happen
}
+ if(notebook->disable_selection_events) {
+ return 0;
+ }
+
if(sel->count != 1) {
notebookmodel_detach_current_note(notebook);
return 0;
UIEXPORT void ui_list_update(UiList *list) {
if(list->update) {
- list->update(list, 0);
+ ui_setop_enable(TRUE);
+ list->update(list, -1);
+ ui_setop_enable(FALSE);
}
}