ui/gtk/list.c

changeset 1136
e6fc42b4248d
parent 1057
b0bc313dea43
--- a/ui/gtk/list.c	Wed May 20 20:00:35 2026 +0200
+++ b/ui/gtk/list.c	Sat May 23 21:38:30 2026 +0200
@@ -33,6 +33,7 @@
 
 #include "../common/context.h"
 #include "../common/object.h"
+#include "../common/action.h"
 #include "container.h"
 
 #include <cx/array_list.h>
@@ -83,14 +84,19 @@
     tableview->multiselection = args->multiselection;
     tableview->onactivate = args->onactivate;
     tableview->onactivatedata = args->onactivatedata;
+    tableview->onactivate_action = args->onactivate_action ? strdup(args->onactivate_action) : NULL;
     tableview->onselection = args->onselection;
     tableview->onselectiondata = args->onselectiondata;
+    tableview->onselection_action = args->onselection_action ? strdup(args->onselection_action) : NULL;
     tableview->ondragstart = args->ondragstart;
     tableview->ondragstartdata = args->ondragstartdata;
+    tableview->ondragstart_action = args->ondragstart_action ? strdup(args->ondragstart_action) : NULL;
     tableview->ondragcomplete = args->ondragcomplete;
     tableview->ondragcompletedata = args->ondragcompletedata;
+    tableview->ondragcomplete_action = args->ondragcomplete_action ? strdup(args->ondragcomplete_action) : NULL;
     tableview->ondrop = args->ondrop;
     tableview->ondropdata = args->ondropdata;
+    tableview->ondrop_action = args->ondrop_action ? strdup(args->ondrop_action) : NULL;
     tableview->selection.count = 0;
     tableview->selection.rows = NULL;
     tableview->current_row = -1;
@@ -508,7 +514,7 @@
     }
     
     // event handling
-    if(args->onactivate) {
+    if(args->onactivate || args->onactivate_action) {
         // columnview and listview can use the same callback function, because
         // the first parameter (which is technically a different pointer type)
         // is ignored
@@ -806,7 +812,7 @@
     return sel;
 }
 
-static void listview_event(ui_callback cb, void *cbdata, UiListView *view) {
+static void listview_event(ui_callback cb, void *cbdata, const char *action, UiListView *view) {
     UiEvent event;
     event.obj = view->obj;
     event.document = event.obj->ctx->document;
@@ -818,6 +824,10 @@
     if(cb) {
         cb(&event, cbdata);
     }
+    
+    if(action) {
+        uic_action_callback(&event, action);
+    }
 }
 
 static void listview_update_selection(UiListView *view) {
@@ -868,14 +878,14 @@
     if(view->selection.count == 0) {
         listview_update_selection(view);
     }
-    listview_event(view->onactivate, view->onactivatedata, view);
+    listview_event(view->onactivate, view->onactivatedata, view->onactivate_action, view);
 }
 
 void ui_listview_selection_changed(GtkSelectionModel* self, guint position, guint n_items, gpointer userdata) {
     UiListView *view = userdata;
     listview_update_selection(view);
     if(ui_selection_events_is_enabled()) {
-        listview_event(view->onselection, view->onselectiondata, view);
+        listview_event(view->onselection, view->onselectiondata, view->onselection_action, view);
     }
 }
 
@@ -2171,6 +2181,11 @@
 */
 
 void ui_listview_destroy(GtkWidget *w, UiListView *v) {
+    free(v->onactivate_action);
+    free(v->onselection_action);
+    free(v->ondragstart_action);
+    free(v->ondragcomplete_action);
+    free(v->ondrop_action);
     //gtk_tree_view_set_model(GTK_TREE_VIEW(w), NULL);
     if(v->var) {
         ui_destroy_boundvar(v->obj->ctx, v->var);

mercurial