add UiListSelection wrapper functions

Wed, 13 Aug 2025 18:56:18 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 13 Aug 2025 18:56:18 +0200
changeset 693
3e1cd004da0a
parent 692
40e1c2045ef3
child 694
1493b6ca77e5

add UiListSelection wrapper functions

ui/common/types.c file | annotate | diff | comparison | revisions
ui/common/wrapper.c file | annotate | diff | comparison | revisions
ui/common/wrapper.h file | annotate | diff | comparison | revisions
ui/ui/toolkit.h file | annotate | diff | comparison | revisions
--- a/ui/common/types.c	Tue Aug 12 14:56:10 2025 +0200
+++ b/ui/common/types.c	Wed Aug 13 18:56:18 2025 +0200
@@ -177,6 +177,14 @@
     }
 }
 
+UiListSelection ui_list_get_selection(UiList *list) {
+    if(list->getselection) {
+        return list->getselection(list);
+    } else {
+        return (UiListSelection){0, NULL};
+    }
+}
+
 void ui_list_addobsv(UiList *list, ui_callback f, void *data) {
     list->observers = ui_add_observer(list->observers, f, data);
 }
--- a/ui/common/wrapper.c	Tue Aug 12 14:56:10 2025 +0200
+++ b/ui/common/wrapper.c	Wed Aug 13 18:56:18 2025 +0200
@@ -218,3 +218,25 @@
 void ui_sublist_item_set_eventdata(UiSubListItem *item, void *eventdata) {
     item->eventdata = NULL;
 }
+
+/* ---------------------------- UiListSelection ---------------------------- */
+
+UiListSelection* ui_list_get_selection_allocated(UiList *list) {
+    UiListSelection *sel = malloc(sizeof(UiListSelection));
+    *sel = ui_list_get_selection(list);
+    return sel;
+    
+}
+
+int ui_list_selection_get_count(UiListSelection *sel) {
+    return sel->count;
+}
+
+int* ui_list_selection_get_rows(UiListSelection *sel) {
+    return sel->rows;
+}
+
+void ui_list_selection_free(UiListSelection *sel) {
+    ui_listselection_free(*sel);
+    free(sel);
+}
--- a/ui/common/wrapper.h	Tue Aug 12 14:56:10 2025 +0200
+++ b/ui/common/wrapper.h	Wed Aug 13 18:56:18 2025 +0200
@@ -74,6 +74,10 @@
 UIEXPORT int ui_event_get_int(UiEvent *event);
 UIEXPORT int ui_event_get_set(UiEvent *event);
 
+UIEXPORT UiListSelection* ui_list_get_selection_allocated(UiList *list);
+UIEXPORT int ui_list_selection_get_count(UiListSelection *sel);
+UIEXPORT int* ui_list_selection_get_rows(UiListSelection *sel);
+UIEXPORT void ui_list_selection_free(UiListSelection *sel);
 
 
 #ifdef __cplusplus
--- a/ui/ui/toolkit.h	Tue Aug 12 14:56:10 2025 +0200
+++ b/ui/ui/toolkit.h	Wed Aug 13 18:56:18 2025 +0200
@@ -612,6 +612,7 @@
 UIEXPORT void ui_list_clear(UiList *list);
 UIEXPORT void ui_list_update(UiList *list);
 UIEXPORT void ui_list_update_row(UiList *list, int row);
+UIEXPORT UiListSelection ui_list_get_selection(UiList *list);
 UIEXPORT void ui_list_addobsv(UiList *list, ui_callback f, void *data);
 UIEXPORT void ui_list_notify(UiList *list);
 

mercurial