diff -r c51e58359db8 -r 681b930abe84 ui/gtk/list.c --- a/ui/gtk/list.c Sun Oct 27 11:34:25 2024 +0100 +++ b/ui/gtk/list.c Sun Oct 27 12:08:10 2024 +0100 @@ -180,7 +180,7 @@ #endif UiModel *model = ui_model(obj->ctx, UI_STRING, "", -1); - model->getvalue = args.getvalue; + model->getvalue = args.getvalue ? args.getvalue : ui_strmodel_getvalue; UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.list, args.varname, UI_VAR_LIST); @@ -586,7 +586,7 @@ UiObject* current = uic_current_obj(obj); UiModel *model = ui_model(obj->ctx, UI_STRING, "", -1); - model->getvalue = args.getvalue; + model->getvalue = args.getvalue ? args.getvalue : ui_strmodel_getvalue; UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.list, args.varname, UI_VAR_LIST); @@ -625,7 +625,8 @@ // bind var if(list) { list->update = ui_combobox_modelupdate; - // TODO: combobox getselection + list->getselection = ui_combobox_getselection; + list->setselection = ui_combobox_setselection; list->obj = uicbox; } @@ -674,3 +675,18 @@ gtk_combo_box_set_model(GTK_COMBO_BOX(view->widget), GTK_TREE_MODEL(store)); } +UiListSelection ui_combobox_getselection(UiList *list) { + UiListView *combobox = list->obj; + UiListSelection ret; + ret.rows = malloc(sizeof(int*)); + ret.count = 1; + ret.rows[0] = gtk_combo_box_get_active(GTK_COMBO_BOX(combobox->widget)); + return ret; +} + +void ui_combobox_setselection(UiList *list, UiListSelection selection) { + UiListView *combobox = list->obj; + if(selection.count > 0) { + gtk_combo_box_set_active(GTK_COMBO_BOX(combobox->widget), selection.rows[0]); + } +}