ui/gtk/tree.c

changeset 128
c284c15509a8
parent 124
80609f9675f1
child 129
5babf09f5f19
--- a/ui/gtk/tree.c	Wed Jul 13 16:40:59 2016 +0200
+++ b/ui/gtk/tree.c	Sat Sep 17 19:32:44 2016 +0200
@@ -134,33 +134,14 @@
 UIWIDGET ui_table_var(UiObject *obj, UiListPtr *list, UiModelInfo *modelinfo) {
     // create treeview
     GtkWidget *view = gtk_tree_view_new();
-    int addi = 0;
     for(int i=0;i<modelinfo->columns;i++) {
-        GtkTreeViewColumn *column = NULL;
-        if(modelinfo->types[i] == UI_ICON_TEXT) {
-            column = gtk_tree_view_column_new();
-            gtk_tree_view_column_set_title(column, modelinfo->titles[i]);
-            
-            GtkCellRenderer *iconrenderer = gtk_cell_renderer_pixbuf_new();
-            GtkCellRenderer *textrenderer = gtk_cell_renderer_text_new();
-            
-            gtk_tree_view_column_pack_end(column, textrenderer, TRUE);
-            gtk_tree_view_column_pack_start(column, iconrenderer, FALSE);
-            
-            
-            gtk_tree_view_column_add_attribute(column, iconrenderer, "icon-name", i);
-            gtk_tree_view_column_add_attribute(column, textrenderer, "text", i+1);
-            
-            addi++;
-        } else {
-            GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
-            column = gtk_tree_view_column_new_with_attributes(
+        GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
+        GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(
                 modelinfo->titles[i],
                 renderer,
                 "text",
-                i + addi,
+                i,
                 NULL);
-        }
         gtk_tree_view_column_set_resizable(column, TRUE);
         gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
     }
@@ -252,7 +233,8 @@
 
 void ui_listview_update(UiEvent *event, UiTableView *view) {
     UiListModel *model = ui_list_model_new(view->list, view->modelinfo);
-    gtk_tree_view_set_model(GTK_TREE_VIEW(view->widget), GTK_TREE_MODEL(model));   
+    gtk_tree_view_set_model(GTK_TREE_VIEW(view->widget), NULL);
+    gtk_tree_view_set_model(GTK_TREE_VIEW(view->widget), GTK_TREE_MODEL(model));
     
     // TODO: free old model
 }

mercurial