]> uap-core.de Git - note.git/commitdiff
fix image attachments not shown in gtk3
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 6 Apr 2025 06:48:36 +0000 (08:48 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 6 Apr 2025 06:48:36 +0000 (08:48 +0200)
application/attachment.c
application/gtk-text.c
application/notebook.c
application/window.c
ui/gtk/container.c

index dbd17efd8204f3d1f0f3f8668a0b8843ee09fc15..a64c6fce326f62a1387e4bcccea457e87297120e 100644 (file)
@@ -84,7 +84,7 @@ void attachment_set_image(Attachment *attachment, void *img) {
  */
 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,
index ab238bfa919d7f3d8932f36bfff6073285e8c1fd..07118002b6db17227d11ae9798cf2c4bf305a041 100644 (file)
@@ -316,6 +316,9 @@ static void editor_attach_image(NoteEditor *editor, GdkPixbuf *pixbuf, char *att
     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
index 295aed645777ed30167294750327e12abc8718c5..2342415f3cf29ee5bda65ccf3f51f419041ecf47 100644 (file)
@@ -142,6 +142,8 @@ void notebookmodel_attach_note(NotebookModel *model, Resource *note) {
     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);
     }
index da70f241f43c43835601948664cbbfd3ddf96576..bfc9b8defa29bb5bb295e8b232ef8ac4c574ca83 100644 (file)
@@ -89,12 +89,13 @@ void window_create() {
                         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);
index 1508bc0a90a4d0c434d8fa849ac19f706a6d5f34..054a7ceb880802a780fc4d40c4315a45f58ff0df 100644 (file)
@@ -1116,7 +1116,7 @@ static void remove_item(void *data, void *item) {
 
 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;
@@ -1146,7 +1146,7 @@ static void update_itemlist(UiList *list, int c) {
     // 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) {
@@ -1175,6 +1175,10 @@ static void update_itemlist(UiList *list, int c) {
         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) {
@@ -1221,7 +1225,7 @@ UIWIDGET ui_itemlist_create(UiObject *obj, UiItemListContainerArgs args) {
                 "destroy",
                 G_CALLBACK(destroy_itemlist_container),
                 container);
-    
+       
     return box;
 }