extern "C" {
#endif
-#define APP_STATE_NOTEBOOK_SELECTED 100
-#define APP_STATE_NOTE_SELECTED 110
+#define APP_STATE_NOTEBOOK_SELECTED 100
+#define APP_STATE_NOTE_SELECTED 110
+#define APP_STATE_NOTE_HAS_ATTACHMENTS 201
-#define VIEW_FLAGS_NO_BROWSER 1
+#define VIEW_FLAGS_NO_BROWSER 1
// typedefs for NotebookModel and NoteModel are in types.h
UIWIDGET splitpane;
UIWIDGET document_tabview;
UIWIDGET textview;
+ UIWIDGET attachments;
/*
* is the note list visible (splitpane child 0)
UiGeneric *html;
/*
- * text note paragraph types
+ * List elements: AttachmentObj*
+ */
+ UiList *attachments;
+
+ /*
+ * Text note paragraph types
+ * List elements: char*
*/
UiList *textnote_para;
bool modified;
};
+typedef struct AttachmentObj {
+ int a;
+} AttachmentObj;
void application_init();
BufferEmbeddedObjects *embedded_objects = g_object_get_data(G_OBJECT(buffer), "embedded");
cxListAdd(embedded_objects->objects, em);
+
+ // add attachment to note
+ MainWindow *wdata = editor->obj->window;
+ Note *note = wdata->current_notebook->current_note;
+ NoteModel *model = note->model;
+
+ // TODO: this is just a test
+ ui_list_append(model->attachments, em);
+ ui_list_update(model->attachments);
}
#if GTK_CHECK_VERSION(4, 0, 0)
model->text = ui_text_new(model->ctx, "note_text");
model->html = ui_generic_new(model->ctx, "note_html");
+ model->attachments = ui_list_new(model->ctx, "note_attachments");
+
ui_set(model->type, 1);
//ui_set_group(model->ctx, APP_STATE_NOTE_SELECTED);
ui_button(obj, .icon = "insert-image");
ui_button(obj, .icon = "insert-link");
}
+ ui_hbox_w(obj, wdata->attachments, .margin = 10, .fill = UI_OFF) {
+ ui_scrolledwindow(obj, .name = "note_attachments_sw") {
+ ui_itemlist(obj, .varname = "note_attachments", .container = UI_CONTAINER_HBOX, .create_ui = attachment_item, .userdata = wdata);
+ }
+ }
+ //ui_set_visible(wdata->attachments, FALSE);
+ //ui_widget_set_groups(obj->ctx, wdata->attachments, (ui_enablefunc)ui_set_visible, APP_STATE_NOTE_HAS_ATTACHMENTS, -1);
wdata->textview = ui_textarea(obj, .varname = "note_text", .vfill = TRUE, .hfill = TRUE, .hexpand = TRUE, .vexpand = TRUE, .colspan = 2, .groups = UI_GROUPS(APP_STATE_NOTE_SELECTED), .fill = UI_ON);
editor_init_textview(obj, ui_textarea_gettextwidget(wdata->textview));
}
ui_show(obj);
}
+void attachment_item(UiObject *obj, int index, void *elm, void *userdata) {
+ ui_button(obj, .label = "Attachment Dummy");
+}
+
MainWindow* window_init_data(UiObject *obj) {
MainWindow *wdata = ui_calloc(obj->ctx, 1, sizeof(MainWindow));
obj->window = wdata;
void* window_notelist_getvalue(void *data, int col);
+void attachment_item(UiObject *obj, int index, void *elm, void *userdata);
+
void action_notebook_selected(UiEvent *event, void *userdata);
void action_note_selected(UiEvent *event, void *userdata);
void action_note_activated(UiEvent *event, void *userdata);
to->from_ctx = from->from_ctx;
}
+ ui_setop_enable(TRUE);
+
// copy binding
// we don't copy the observer, because the from var has never one
switch(from->type) {
break;
}
}
+
+ ui_setop_enable(FALSE);
}
void uic_save_var2(UiVar *var) {
value->data2 = ui_create_undomgr();
}
- g_signal_connect(
- buf,
- "changed",
- G_CALLBACK(ui_textbuf_changed),
- uitext);
-
// register undo manager
g_signal_connect(
buf,
}
#endif
+static GtkTextBuffer* create_textbuffer(UiTextArea *textarea) {
+ GtkTextBuffer *buf = gtk_text_buffer_new(NULL);
+ if(textarea) {
+ g_signal_connect(
+ buf,
+ "changed",
+ G_CALLBACK(ui_textbuf_changed),
+ textarea);
+ } else {
+ fprintf(stderr, "Error: create_textbuffer: textarea == NULL\n");
+ }
+ return buf;
+}
+
UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs args) {
UiObject* current = uic_current_obj(obj);
UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_TEXT);
uitext->onchange = args.onchange;
uitext->onchangedata = args.onchangedata;
+ g_object_set_data(G_OBJECT(text_area), "ui_textarea", uitext);
+
g_signal_connect(
text_area,
"destroy",
if(value->data1 && value->datatype == UI_TEXT_TYPE_BUFFER) {
buf = value->data1;
} else {
- buf = gtk_text_buffer_new(NULL);
+ buf = create_textbuffer(uitext);
if(value->value.ptr) {
gtk_text_buffer_set_text(buf, value->value.ptr, -1);
value->value.free(value->value.ptr);
void ui_textarea_restore(UiText *text) {
GtkWidget *textarea = text->obj;
if(!text->data1) {
- text->data1 = gtk_text_buffer_new(NULL);
+ text->data1 = create_textbuffer(g_object_get_data(G_OBJECT(textarea), "ui_textarea"));
text->datatype = UI_TEXT_TYPE_BUFFER;
}
gtk_text_view_set_buffer(GTK_TEXT_VIEW(textarea), text->data1);
e.document = textarea->ctx->document;
e.eventdata = value;
e.intval = 0;
+ e.set = ui_get_setop();
if(textarea->onchange) {
textarea->onchange(&e, textarea->onchangedata);
e.document = textfield->obj->ctx->document;
e.eventdata = value;
e.intval = 0;
+ e.set = ui_get_setop();
if(textfield->onchange) {
textfield->onchange(&e, textfield->onchangedata);
e.document = textfield->obj->ctx->document;
e.eventdata = NULL;
e.intval = 0;
+ e.set = ui_get_setop();
textfield->onactivate(&e, textfield->onactivatedata);
}
}
evt.document = evt.obj->ctx->document;
evt.eventdata = elm->path;
evt.intval = event->value0;
+ evt.set = ui_get_setop();
event->callback(&evt, event->userdata);
free(path.ptr);
}
}
void ui_set_visible(UIWIDGET widget, int visible) {
- // TODO: gtk4
-#if GTK_MAJOR_VERSION <= 3
+#if GTK_MAJOR_VERSION >= 4
+ gtk_widget_set_visible(widget, visible);
+#else
if(visible) {
gtk_widget_set_no_show_all(widget, FALSE);
gtk_widget_show_all(widget);
#define ui_headerbar0(obj) for(ui_headerbar_create(obj, (UiHeaderbarArgs){ 0 });ui_container_finish(obj);ui_container_begin_close(obj))
#define ui_sidebar0(obj) for(ui_sidebar_create(obj, (UiSidebarArgs){ 0 });ui_container_finish(obj);ui_container_begin_close(obj))
+#define ui_vbox_w(obj, w, ...) for(w = ui_vbox_create(obj, (UiContainerArgs){ __VA_ARGS__ });ui_container_finish(obj);ui_container_begin_close(obj))
+#define ui_hbox_w(obj, w, ...) for(w = ui_hbox_create(obj, (UiContainerArgs){ __VA_ARGS__ });ui_container_finish(obj);ui_container_begin_close(obj))
+#define ui_grid_w(obj, w, ...) for(w = ui_grid_create(obj, (UiContainerArgs){ __VA_ARGS__ });ui_container_finish(obj);ui_container_begin_close(obj))
#define ui_tabview_w(obj, w, ...) for(w = ui_tabview_create(obj, (UiTabViewArgs){ __VA_ARGS__ });ui_container_finish(obj);ui_container_begin_close(obj))
#define ui_hsplitpane(obj, ...) for(ui_hsplitpane_create(obj, (UiSplitPaneArgs){ __VA_ARGS__ });ui_container_finish(obj);ui_container_begin_close(obj))