application/main.c

branch
newapi
changeset 339
b68b5f984074
parent 336
56c12f44c2d3
child 340
2dd42bd4fe5d
equal deleted inserted replaced
338:6d827f85e0f5 339:b68b5f984074
41 UiDouble *progress; 41 UiDouble *progress;
42 UiList *list; 42 UiList *list;
43 UiList *menulist; 43 UiList *menulist;
44 UiInteger *radio; 44 UiInteger *radio;
45 UiInteger *tabview; 45 UiInteger *tabview;
46 UiGeneric *image;
46 } MyDocument; 47 } MyDocument;
47 48
48 MyDocument *doc1; 49 MyDocument *doc1;
49 MyDocument *doc2; 50 MyDocument *doc2;
50 51
54 55
55 } 56 }
56 57
57 void action_file_selected(UiEvent *event, void *userdata) { 58 void action_file_selected(UiEvent *event, void *userdata) {
58 UiFileList *files = event->eventdata; 59 UiFileList *files = event->eventdata;
60 MyDocument *doc = event->document;
59 printf("files: %d\n", (int)files->nfiles); 61 printf("files: %d\n", (int)files->nfiles);
60 if(files->nfiles > 0) { 62 if(files->nfiles > 0) {
61 printf("selected file: %s\n", files->files[0]); 63 printf("selected file: %s\n", files->files[0]);
64 ui_image_load_file(doc->image, files->files[0]);
62 } 65 }
63 } 66 }
64 67
65 void action_button(UiEvent *event, void *userdata) { 68 void action_button(UiEvent *event, void *userdata) {
66 ui_savefiledialog(event->obj, "myfile.txt", action_file_selected, NULL); 69 ui_openfiledialog(event->obj, UI_FILEDIALOG_SELECT_SINGLE, action_file_selected, NULL);
67 } 70 }
68 71
69 void action_switch(UiEvent *event, void *userdata) { 72 void action_switch(UiEvent *event, void *userdata) {
70 73
71 } 74 }
104 ui_list_append(doc->list, "test1"); 107 ui_list_append(doc->list, "test1");
105 ui_list_append(doc->list, "test2"); 108 ui_list_append(doc->list, "test2");
106 ui_list_append(doc->list, "test3"); 109 ui_list_append(doc->list, "test3");
107 doc->radio = ui_int_new(docctx, "radio"); 110 doc->radio = ui_int_new(docctx, "radio");
108 doc->tabview = ui_int_new(docctx, "tabview"); 111 doc->tabview = ui_int_new(docctx, "tabview");
112 doc->image = ui_generic_new(docctx, "image");
109 //doc->text = ui_text_new(docctx, "text"); 113 //doc->text = ui_text_new(docctx, "text");
110 return doc; 114 return doc;
111 } 115 }
112 116
113 UiIcon *icon = NULL; 117 UiIcon *icon = NULL;
222 ui_button(tab2, .label = "Button 2"); 226 ui_button(tab2, .label = "Button 2");
223 } 227 }
224 } 228 }
225 ui_tab(obj, "Tab 4") { 229 ui_tab(obj, "Tab 4") {
226 ui_textarea(obj, .varname = "text"); 230 ui_textarea(obj, .varname = "text");
231 }
232 ui_tab(obj, "Tab 5") {
233 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
234 ui_imageviewer(obj, .varname = "image");
227 } 235 }
228 } 236 }
229 237
230 /* 238 /*
231 239

mercurial