ui/gtk/tree.c

changeset 152
62921b370c60
parent 151
11f3bb408051
child 163
b70e2a77dea0
equal deleted inserted replaced
151:11f3bb408051 152:62921b370c60
366 366
367 void ui_listview_update(UiList *list, int i) { 367 void ui_listview_update(UiList *list, int i) {
368 UiListView *view = list->obj; 368 UiListView *view = list->obj;
369 UiListModel *model = ui_list_model_new(view->obj, view->var, view->model); 369 UiListModel *model = ui_list_model_new(view->obj, view->var, view->model);
370 gtk_tree_view_set_model(GTK_TREE_VIEW(view->widget), GTK_TREE_MODEL(model)); 370 gtk_tree_view_set_model(GTK_TREE_VIEW(view->widget), GTK_TREE_MODEL(model));
371 g_object_unref(G_OBJECT(model));
371 // TODO: free old model 372 // TODO: free old model
372 } 373 }
373 374
374 void ui_listview_destroy(GtkWidget *w, UiListView *v) { 375 void ui_listview_destroy(GtkWidget *w, UiListView *v) {
376 gtk_tree_view_set_model(GTK_TREE_VIEW(w), NULL);
377 ui_destroy_boundvar(v->obj->ctx, v->var);
378 // TODO: destroy model?
379 free(v);
380 }
381
382 void ui_combobox_destroy(GtkWidget *w, UiListView *v) {
383 gtk_combo_box_set_model(GTK_COMBO_BOX(w), NULL);
375 ui_destroy_boundvar(v->obj->ctx, v->var); 384 ui_destroy_boundvar(v->obj->ctx, v->var);
376 // TODO: destroy model? 385 // TODO: destroy model?
377 free(v); 386 free(v);
378 } 387 }
379 388
496 uicbox->model = model->model; 505 uicbox->model = model->model;
497 506
498 g_signal_connect( 507 g_signal_connect(
499 combobox, 508 combobox,
500 "destroy", 509 "destroy",
501 G_CALLBACK(ui_listview_destroy), 510 G_CALLBACK(ui_combobox_destroy),
502 uicbox); 511 uicbox);
503 512
504 // bind var 513 // bind var
505 UiList *list = model->var->value; 514 UiList *list = model->var->value;
506 list->update = ui_combobox_modelupdate; 515 list->update = ui_combobox_modelupdate;

mercurial