ui/gtk/tree.c

changeset 146
dd0ae1c62a72
parent 142
46448d38885c
child 147
2e384acc89a6
equal deleted inserted replaced
145:853685152c1d 146:dd0ae1c62a72
62 #endif 62 #endif
63 #else 63 #else
64 // TODO: implement for gtk2 64 // TODO: implement for gtk2
65 #endif 65 #endif
66 66
67 UiModel *model = ui_model_info(obj->ctx, UI_STRING, "", -1); 67 UiModel *model = ui_model(obj->ctx, UI_STRING, "", -1);
68 model->getvalue = getvalue; 68 model->getvalue = getvalue;
69 UiList *list = var->value; 69 UiList *list = var->value;
70 UiListModel *listmodel = ui_list_model_new(var, model); 70 UiListModel *listmodel = ui_list_model_new(var, model);
71 gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(listmodel)); 71 gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(listmodel));
72 72
151 151
152 gtk_tree_view_column_pack_end(column, textrenderer, TRUE); 152 gtk_tree_view_column_pack_end(column, textrenderer, TRUE);
153 gtk_tree_view_column_pack_start(column, iconrenderer, FALSE); 153 gtk_tree_view_column_pack_start(column, iconrenderer, FALSE);
154 154
155 155
156 gtk_tree_view_column_add_attribute(column, iconrenderer, "icon-name", i); 156 gtk_tree_view_column_add_attribute(column, iconrenderer, "pixbuf", i);
157 gtk_tree_view_column_add_attribute(column, textrenderer, "text", i+1); 157 gtk_tree_view_column_add_attribute(column, textrenderer, "text", i+1);
158 158
159 addi++; 159 addi++;
160 } else { 160 } else {
161 GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); 161 GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
181 UiListModel *listmodel = ui_list_model_new(var, model); 181 UiListModel *listmodel = ui_list_model_new(var, model);
182 gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(listmodel)); 182 gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(listmodel));
183 183
184 // add TreeView as observer to the UiList to update the TreeView if the 184 // add TreeView as observer to the UiList to update the TreeView if the
185 // data changes 185 // data changes
186 UiListView *tableview = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiListView)); 186 UiListView *tableview = malloc(sizeof(UiListView));
187 tableview->ctx = obj->ctx; 187 tableview->ctx = obj->ctx;
188 tableview->widget = view; 188 tableview->widget = view;
189 tableview->var = var; 189 tableview->var = var;
190 tableview->model = model; 190 tableview->model = model;
191 g_signal_connect( 191 g_signal_connect(
371 } 371 }
372 return NULL; 372 return NULL;
373 } 373 }
374 374
375 UIWIDGET ui_combobox_var(UiObject *obj, UiVar *var, ui_getvaluefunc getvalue, ui_callback f, void *udata) { 375 UIWIDGET ui_combobox_var(UiObject *obj, UiVar *var, ui_getvaluefunc getvalue, ui_callback f, void *udata) {
376 UiModel *model = ui_model_info(obj->ctx, UI_STRING, "", -1); 376 UiModel *model = ui_model(obj->ctx, UI_STRING, "", -1);
377 model->getvalue = getvalue; 377 model->getvalue = getvalue;
378 UiListModel *listmodel = ui_list_model_new(var, model); 378 UiListModel *listmodel = ui_list_model_new(var, model);
379 379
380 GtkWidget *combobox = ui_create_combobox(obj, listmodel, f, udata); 380 GtkWidget *combobox = ui_create_combobox(obj, listmodel, f, udata);
381 UiContainer *ct = uic_get_current_container(obj); 381 UiContainer *ct = uic_get_current_container(obj);

mercurial