166 ui_list_append(doc->list2, "test2"); |
168 ui_list_append(doc->list2, "test2"); |
167 ui_list_append(doc->list2, "test3"); |
169 ui_list_append(doc->list2, "test3"); |
168 doc->radio = ui_int_new(docctx, "radio"); |
170 doc->radio = ui_int_new(docctx, "radio"); |
169 doc->tabview = ui_int_new(docctx, "tabview"); |
171 doc->tabview = ui_int_new(docctx, "tabview"); |
170 doc->image = ui_generic_new(docctx, "image"); |
172 doc->image = ui_generic_new(docctx, "image"); |
|
173 |
|
174 doc->srclist1 = ui_list_new(docctx, "srclist1"); |
|
175 doc->srclist2 = ui_list_new(docctx, "srclist2"); |
|
176 ui_list_append(doc->srclist1, "test1"); |
|
177 ui_list_append(doc->srclist1, "test2"); |
|
178 ui_list_append(doc->srclist1, "test3"); |
|
179 ui_list_append(doc->srclist2, "x1"); |
|
180 ui_list_append(doc->srclist2, "x2"); |
|
181 |
|
182 |
|
183 |
171 //doc->text = ui_text_new(docctx, "text"); |
184 //doc->text = ui_text_new(docctx, "text"); |
172 return doc; |
185 return doc; |
173 } |
186 } |
174 |
187 |
175 UiIcon *icon = NULL; |
188 UiIcon *icon = NULL; |
250 ui_button(obj, .label = "Unref", .onclick = action_button_unref, .onclickdata = ref_window); |
263 ui_button(obj, .label = "Unref", .onclick = action_button_unref, .onclickdata = ref_window); |
251 } |
264 } |
252 ui_show(obj); |
265 ui_show(obj); |
253 } |
266 } |
254 |
267 |
|
268 void action_sourcelist_activate(UiEvent *event, void *userdata) { |
|
269 printf("sourcelist %s index %d\n", event->eventdata, event->intval); |
|
270 } |
|
271 |
255 UiMenuBuilder *menubuilder; |
272 UiMenuBuilder *menubuilder; |
256 |
273 |
257 void* table_getvalue(void *row, int col) { |
274 void* table_getvalue(void *row, int col) { |
258 return row; |
275 return row; |
|
276 } |
|
277 |
|
278 void sourcelist_getvalue(void *sublistdata, void *rowdata, int index, UiSubListItem *item) { |
|
279 item->label = strdup(rowdata); |
|
280 item->eventdata = sublistdata; |
259 } |
281 } |
260 |
282 |
261 void application_startup(UiEvent *event, void *data) { |
283 void application_startup(UiEvent *event, void *data) { |
262 // global list |
284 // global list |
263 UiContext *global = ui_global_context(); |
285 UiContext *global = ui_global_context(); |
268 |
290 |
269 |
291 |
270 |
292 |
271 UiObject *obj = ui_sidebar_window("Test", NULL); |
293 UiObject *obj = ui_sidebar_window("Test", NULL); |
272 |
294 |
273 ui_sidebar(obj, .margin = 8, .spacing = 8) { |
|
274 ui_button(obj, .label = "Button 1", .style_class = "flat"); |
|
275 ui_button(obj, .label = "Button 2", .style_class = "flat"); |
|
276 ui_button(obj, .label = "Button 3", .style_class = "flat"); |
|
277 ui_button(obj, .label = "Button 4", .style_class = "flat"); |
|
278 ui_button(obj, .label = "Button 5", .style_class = "flat"); |
|
279 } |
|
280 |
|
281 MyDocument *doc = create_doc(); |
295 MyDocument *doc = create_doc(); |
282 ui_attach_document(obj->ctx, doc); |
296 ui_attach_document(obj->ctx, doc); |
|
297 |
|
298 ui_sidebar(obj, .margin = 0, .spacing = 0) { |
|
299 ui_sourcelist(obj, .fill = UI_ON, |
|
300 .getvalue = sourcelist_getvalue, |
|
301 .sublists = UI_SUBLISTS(UI_SUBLIST(.varname = "srclist1", .header = "Header 1", .userdata = "Sublist1"), UI_SUBLIST(.varname = "srclist2", .header = "Header 2", .userdata = "Sublist2")), |
|
302 .onactivate = action_sourcelist_activate); |
|
303 } |
283 |
304 |
284 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") { |
305 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") { |
285 ui_tab(obj, "Tab 1") { |
306 ui_tab(obj, "Tab 1") { |
286 ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) { |
307 ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) { |
287 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); |
308 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); |
312 |
333 |
313 ui_textfield(obj, .value = doc->str1); |
334 ui_textfield(obj, .value = doc->str1); |
314 ui_newline(obj); |
335 ui_newline(obj); |
315 |
336 |
316 //ui_button(obj, .label="Test"); |
337 //ui_button(obj, .label="Test"); |
317 ui_path_textfield(obj, .varname = "path"); |
338 ui_path_textfield(obj, .varname = "path", .hfill = TRUE, .hexpand = TRUE); |
318 ui_set(doc->path, "/test/path/longdirectoryname/123"); |
339 ui_set(doc->path, "/test/path/longdirectoryname/123"); |
319 ui_newline(obj); |
340 ui_newline(obj); |
320 |
341 |
321 //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1); |
342 //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1); |
322 //model->getvalue = list_getvalue; |
343 //model->getvalue = list_getvalue; |