cxListAdd(note->resource->attachments, attachment);
}
-void note_save(UiObject *obj, NotebookModel *notebook, Note *note) {
+void note_save(UiObject *obj, NotebookModel *notebook, Note *note, execresult_func result, void *userdata) {
NoteModel *m = note->model;
char *title = ui_get(m->title);
if(note->resource_id == 0) {
// new note
- note_store_new_note_async(obj, note, NULL, NULL);
+ note_store_new_note_async(obj, note, result, userdata);
} else {
- note_store_update_note_async(obj, note, NULL, NULL);
+ note_store_update_note_async(obj, note, result, userdata);
}
if(note->resource->attachments) {
#include "application.h"
#include "editor.h"
+#include "store.h"
#include <regex.h>
void note_add_attachment(Note *note, Attachment *attachment);
-void note_save(UiObject *obj, NotebookModel *notebook, Note *note);
+void note_save(UiObject *obj, NotebookModel *notebook, Note *note, execresult_func result, void *userdata);
void note_update_current_style(NoteModel *note, MDActiveStyles *style);
if(model->current_note) {
// TODO: model->modified doesnt work yet, remove || 1 when it works
if(model->current_note->model->modified || 1) {
- note_save(model->window->obj, model, model->current_note);
+ note_save(model->window->obj, model, model->current_note, NULL, NULL);
}
// TODO: workaround for a toolkit bug, that reattaching a document
Note *current_note = model->current_note;
// TODO: model->modified doesnt work yet, remove || 1 when it works
if(current_note->model->modified || 1) {
- note_save(model->window->obj, model, model->current_note);
+ note_save(model->window->obj, model, model->current_note, NULL, NULL);
}
// TODO: in theory ui_detach_document2 should save the state
// of all vars, but it seems this doesn't work
#include <cx/array_list.h>
#include <cx/hash_map.h>
+static void note_saved(UiEvent *event, int error, void *userdata) {
+ ui_app_unref();
+}
+
static void window_closed(UiEvent *event, MainWindow *wdata) {
+ // save current note
+ NotebookModel *notebook = wdata->current_notebook;
+ if(notebook && notebook->current_note && notebook->current_note->model) {
+ Note *note = notebook->current_note;
+ //if(note->model->modified) {
+ note_save(application_global_obj(), notebook, note, note_saved, NULL);
+ ui_app_ref();
+ //}
+ }
+
note_store_remove_listener(wdata);
}
}
}
+void ui_app_ref(void) {
+ // TODO
+}
+
+void ui_app_unref(void) {
+ // TODO
+}
+
/* ------------------- Window Visibility functions ------------------- */
void ui_show(UiObject *obj) {
}
}
+
+void ui_app_ref(void) {
+#ifdef UI_APPLICATION
+ g_application_hold(G_APPLICATION(app));
+#else
+ // TODO
+#endif
+}
+
+void ui_app_unref(void) {
+#ifdef UI_APPLICATION
+ g_application_release(G_APPLICATION(app));
+#else
+ // TODO
+#endif
+}
+
+
#ifndef UI_GTK2
void ui_app_quit() {
g_application_quit(G_APPLICATION(app)); // TODO: fix, does not work
obj->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#endif
+#if GTK_MAJOR_VERSION < 4
+ const char *window_pos = ui_get_property("ui.gtk.window.position");
+ GtkWindowPosition wpos = GTK_WIN_POS_CENTER;
+ if(window_pos) {
+ if(!strcmp(window_pos, "none")) {
+ wpos = GTK_WIN_POS_NONE;
+ } else if(!strcmp(window_pos, "center")) {
+ //wpos = GTK_WIN_POS_CENTER;
+ } else if(!strcmp(window_pos, "mouse")) {
+ wpos = GTK_WIN_POS_MOUSE;
+ } else if(!strcmp(window_pos, "center_always")) {
+ wpos = GTK_WIN_POS_CENTER_ALWAYS;
+ } else {
+ fprintf(stderr, "Error: unknown value '%s' for property ui.gtk.window.positionhint", window_pos);
+ }
+ }
+ gtk_window_set_position(GTK_WINDOW(obj->widget), wpos);
+#endif
+
#if GTK_CHECK_VERSION(4, 0, 0)
obj->ctx->action_map = G_ACTION_MAP(obj->widget);
#endif
}
}
+void ui_app_ref(void) {
+ // TODO
+}
+
+void ui_app_unref(void) {
+ // TODO
+}
+
void ui_app_quit() {
XtAppSetExitFlag(app);
}
}
}
+void ui_app_ref(void) {
+ // TODO
+}
+
+void ui_app_unref(void) {
+ // TODO
+}
+
void ui_show(UiObject *obj) {
obj->widget->show();
}
UIEXPORT void ui_object_set(UiObject *obj, const char *key, void *data);
UIEXPORT void* ui_object_get(UiObject *obj, const char *key);
+UIEXPORT void ui_app_ref(void);
+UIEXPORT void ui_app_unref(void);
+
#ifdef __cplusplus
}
#endif
uic_store_app_properties();
}
+void ui_app_ref(void) {
+ // TODO
+}
+
+void ui_app_unref(void) {
+ // TODO
+}
+
void ui_show(UiObject *obj) {
ui_set_visible(obj->widget, TRUE);
}