ui/gtk/model.c

changeset 129
5babf09f5f19
parent 128
c284c15509a8
child 140
c03c338a7dcf
--- a/ui/gtk/model.c	Sat Sep 17 19:32:44 2016 +0200
+++ b/ui/gtk/model.c	Sat Sep 17 19:57:55 2016 +0200
@@ -105,14 +105,14 @@
     return G_TYPE_INVALID;
 }
 
-static void ui_model_set_value(UiModelType type, void *data, GValue *value) {
+static void ui_model_set_value(GType type, void *data, GValue *value) {
     switch(type) {
-        case UI_STRING: {
+        case G_TYPE_STRING: {
             value->g_type = G_TYPE_STRING;
             g_value_set_string(value, data);
             return;
         }
-        case UI_INTEGER: {
+        case G_TYPE_INT: {
             value->g_type = G_TYPE_INT;
             int *i = data;
             g_value_set_int(value, *i);
@@ -126,11 +126,20 @@
     UiListModel *model = g_object_new(list_model_type, NULL);
     model->info = info;
     model->list = list;
-    model->columntypes = malloc(sizeof(GType));
-    model->numcolumns = info->columns;
+    model->columntypes = calloc(sizeof(GType), 2 * info->columns);
+    int ncol = 0;
     for(int i=0;i<info->columns;i++) {
-        model->columntypes[i] = ui_gtk_type(info->types[i]);
+        UiModelType type = info->types[i];
+        if(type == UI_ICON_TEXT) {
+            model->columntypes[ncol] = G_TYPE_STRING;
+            ncol++;
+            model->columntypes[ncol] = G_TYPE_STRING;
+        } else {
+            model->columntypes[ncol] = ui_gtk_type(info->types[i]);
+        }
+        ncol++;
     }
+    model->numcolumns = ncol;
     return model;
 }
 
@@ -237,7 +246,7 @@
     //list->current = iter->user_data3;
     if(model->info->getvalue) {
         void *data = model->info->getvalue(iter->user_data3, column);
-        ui_model_set_value(model->info->types[column], data, value);
+        ui_model_set_value(model->columntypes[column], data, value);
     } else {
         value->g_type = G_TYPE_INVALID;
     }

mercurial