ui/gtk/list.c

changeset 683
ba226c243f3f
parent 680
a4795b40e679
child 684
3c9b430fb160
--- a/ui/gtk/list.c	Tue Jul 29 21:12:04 2025 +0200
+++ b/ui/gtk/list.c	Tue Jul 29 21:15:49 2025 +0200
@@ -626,14 +626,20 @@
         void *value = list->get(list, i);
         if(value) {
             ObjWrapper *obj = obj_wrapper_new(value, i);
+            UiListSelection sel = list->getselection(list);
             // TODO: if index i is selected, the selection is lost
             // is it possible to update the item without removing it?
+            // workaround: save selection and reapply it
             int count = g_list_model_get_n_items(G_LIST_MODEL(view->liststore));
             if(count <= i) {
                 g_list_store_splice(view->liststore, i, 0, (void **)&obj, 1);
             } else {
                 g_list_store_splice(view->liststore, i, 1, (void **)&obj, 1);
             }
+            if(sel.count > 0) {
+                list->setselection(list, sel);
+            }
+            ui_listselection_free(sel);
         }
     }
 }

mercurial