*/
void attachment_item(UiObject *obj, int index, void *elm, void *userdata) {
Attachment *attachment = elm;
-
+
if(attachment->type == NOTE_ATTACHMENT_IMAGE) {
UIWIDGET imgviewer = ui_imageviewer(obj,
.value = attachment->ui->img,
GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(buffer, &iter);
GtkWidget *image = embedded_image_create(pixbuf);
gtk_text_view_add_child_at_anchor(textview, image, anchor);
+#if GTK_MAJOR_VERSION < 4
+ gtk_widget_show_all(image);
+#endif
// remember widget and store a reference in the textbuffer
// TODO: we need a cleanup strategy
ui_set_group(model->window->obj->ctx, APP_STATE_NOTE_SELECTED);
model->current_note = note;
+ ui_list_update(note->model->attachments);
+
if(!note->content_loaded) {
note_load_content(model->window->obj, model, note);
}
ui_button(obj, .icon = "insert-link");
}
ui_hbox_w(obj, wdata->attachments, .margin = 10, .fill = UI_OFF) {
- void *sw;
- ui_scrolledwindow_w(obj, sw, .name = "note_attachments_sw") {
+ //UIWIDGET sw;
+ //ui_scrolledwindow_w(obj, sw, .name = "note_attachments_sw") {
ui_itemlist(obj, .varname = "note_attachments", .container = UI_CONTAINER_HBOX, .create_ui = attachment_item, .userdata = wdata);
- }
- ui_widget_set_size(sw, -1, 120);
+ //}
+ //ui_widget_set_size(sw, -1, 120);
}
+ ui_widget_set_size(wdata->attachments, -1, 120);
//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);
static void update_itemlist(UiList *list, int c) {
UiGtkItemListContainer *ct = list->obj;
-
+
CxMap *new_items = cxHashMapCreateSimple(CX_STORE_POINTERS);
new_items->collection.advanced_destructor = remove_item;
new_items->collection.destructor_data = ct;
// add all items
int index = 0;
elm = list->first(list);
- while(elm) {
+ while(elm) {
CxHashKey key = cx_hash_key(&elm, sizeof(void*));
UiObject *item_obj = cxMapGet(ct->current_items, key);
if(item_obj) {
elm = list->next(list);
index++;
}
+
+#if GTK_MAJOR_VERSION < 4
+ gtk_widget_show_all(ct->widget);
+#endif
}
static void destroy_itemlist_container(GtkWidget *w, UiGtkItemListContainer *container) {
"destroy",
G_CALLBACK(destroy_itemlist_container),
container);
-
+
return box;
}