add UI_BOOL_EDITABLE table model type (GTK)

Wed, 08 Oct 2025 22:00:20 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 08 Oct 2025 22:00:20 +0200
changeset 820
7ce561f92632
parent 819
5f6ca885d048
child 821
2aa2f75f8da4

add UI_BOOL_EDITABLE table model type (GTK)

ui/gtk/list.c file | annotate | diff | comparison | revisions
ui/ui/tree.h file | annotate | diff | comparison | revisions
--- a/ui/gtk/list.c	Wed Oct 08 18:38:42 2025 +0200
+++ b/ui/gtk/list.c	Wed Oct 08 22:00:20 2025 +0200
@@ -245,7 +245,10 @@
         GtkEventController *focus_controller = gtk_event_controller_focus_new();
         g_signal_connect(focus_controller, "leave", G_CALLBACK(cell_entry_leave_focus), entry_data);
         gtk_widget_add_controller(textfield, focus_controller);
-    } else {
+    } else if(type == UI_BOOL_EDITABLE) {
+        GtkWidget *checkbox = gtk_check_button_new();
+        gtk_list_item_set_child(item, checkbox);
+    }else {
         GtkWidget *label = gtk_label_new(NULL);
         gtk_label_set_xalign(GTK_LABEL(label), 0);
         gtk_list_item_set_child(item, label);
@@ -390,6 +393,11 @@
             ENTRY_SET_TEXT(child, data);
             break;
         }
+        case UI_BOOL_EDITABLE: {
+            intptr_t i = (intptr_t)data;
+            gtk_check_button_set_active(GTK_CHECK_BUTTON(child), (gboolean)i);
+            break;
+        }
     }
     
     if(attributes != listview->current_row_attributes) {
--- a/ui/ui/tree.h	Wed Oct 08 18:38:42 2025 +0200
+++ b/ui/ui/tree.h	Wed Oct 08 22:00:20 2025 +0200
@@ -52,13 +52,15 @@
     UI_ICON,
     UI_ICON_TEXT,
     UI_ICON_TEXT_FREE,
-    UI_STRING_EDITABLE
+    UI_STRING_EDITABLE,
+    UI_BOOL_EDITABLE
 } UiModelType;
 
 typedef struct UiCellValue {
     union {
         const char *string;
         int64_t i;
+        UiBool b;
     };
     UiModelType type;
 } UiCellValue;

mercurial