60 MyDocument *doc = ui_document_new(sizeof(MyDocument)); |
61 MyDocument *doc = ui_document_new(sizeof(MyDocument)); |
61 UiContext *docctx = ui_document_context(doc); |
62 UiContext *docctx = ui_document_context(doc); |
62 doc->str1 = ui_string_new(docctx, "str1"); |
63 doc->str1 = ui_string_new(docctx, "str1"); |
63 doc->str1 = ui_string_new(docctx, "str2"); |
64 doc->str1 = ui_string_new(docctx, "str2"); |
64 doc->progress = ui_double_new(docctx, "progress"); |
65 doc->progress = ui_double_new(docctx, "progress"); |
|
66 doc->list = ui_list_new(docctx, "list"); |
|
67 ui_list_append(doc->list, "test1"); |
|
68 ui_list_append(doc->list, "test2"); |
|
69 ui_list_append(doc->list, "test3"); |
65 return doc; |
70 return doc; |
|
71 } |
|
72 |
|
73 UiIcon *icon = NULL; |
|
74 |
|
75 static void* list_getvalue(void *elm, int col) { |
|
76 if(col == 0) { |
|
77 if(!icon) { |
|
78 icon = ui_icon("folder", 24); |
|
79 } |
|
80 return icon; |
|
81 } |
|
82 char *str = elm; |
|
83 return col == 1 ? str : "x"; |
66 } |
84 } |
67 |
85 |
68 void application_startup(UiEvent *event, void *data) { |
86 void application_startup(UiEvent *event, void *data) { |
69 |
87 |
70 UiObject *obj = ui_window("Test", NULL); |
88 UiObject *obj = ui_window("Test", NULL); |
93 ui_progressbar(obj, .colspan = 2, .varname = "progress"); |
111 ui_progressbar(obj, .colspan = 2, .varname = "progress"); |
94 ui_set(doc->progress, 0.75); |
112 ui_set(doc->progress, 0.75); |
95 ui_newline(obj); |
113 ui_newline(obj); |
96 |
114 |
97 ui_textfield(obj, .value = doc->str1); |
115 ui_textfield(obj, .value = doc->str1); |
|
116 ui_newline(obj); |
|
117 |
|
118 UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1); |
|
119 model->getvalue = list_getvalue; |
|
120 ui_table(obj, .hexpand = true, .vexpand = true, .colspan = 2, .varname = "list", .model = model); |
98 } |
121 } |
99 |
122 |
100 ui_show(obj); |
123 ui_show(obj); |
101 } |
124 } |
102 |
125 |