application/main.c

branch
newapi
changeset 275
132c7bcc6997
parent 270
9389313ac00f
child 278
a8faf8757450
equal deleted inserted replaced
274:9e2aee097b69 275:132c7bcc6997
36 typedef struct { 36 typedef struct {
37 UiString *str1; 37 UiString *str1;
38 UiString *str2; 38 UiString *str2;
39 UiDouble *progress; 39 UiDouble *progress;
40 UiList *list; 40 UiList *list;
41 UiInteger *radio;
41 } MyDocument; 42 } MyDocument;
42 43
43 MyDocument *doc1; 44 MyDocument *doc1;
44 MyDocument *doc2; 45 MyDocument *doc2;
45 46
54 55
55 void action_switch(UiEvent *event, void *userdata) { 56 void action_switch(UiEvent *event, void *userdata) {
56 57
57 } 58 }
58 59
60 void action_toolbar_button(UiEvent *event, void *userdata) {
61
62 }
59 63
60 MyDocument* create_doc(void) { 64 MyDocument* create_doc(void) {
61 MyDocument *doc = ui_document_new(sizeof(MyDocument)); 65 MyDocument *doc = ui_document_new(sizeof(MyDocument));
62 UiContext *docctx = ui_document_context(doc); 66 UiContext *docctx = ui_document_context(doc);
63 doc->str1 = ui_string_new(docctx, "str1"); 67 doc->str1 = ui_string_new(docctx, "str1");
65 doc->progress = ui_double_new(docctx, "progress"); 69 doc->progress = ui_double_new(docctx, "progress");
66 doc->list = ui_list_new(docctx, "list"); 70 doc->list = ui_list_new(docctx, "list");
67 ui_list_append(doc->list, "test1"); 71 ui_list_append(doc->list, "test1");
68 ui_list_append(doc->list, "test2"); 72 ui_list_append(doc->list, "test2");
69 ui_list_append(doc->list, "test3"); 73 ui_list_append(doc->list, "test3");
74 doc->radio = ui_int_new(docctx, "radio");
70 return doc; 75 return doc;
71 } 76 }
72 77
73 UiIcon *icon = NULL; 78 UiIcon *icon = NULL;
74 79
119 ui_newline(obj); 124 ui_newline(obj);
120 125
121 //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1); 126 //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1);
122 //model->getvalue = list_getvalue; 127 //model->getvalue = list_getvalue;
123 ui_combobox(obj, .hexpand = true, .vexpand = false, .colspan = 2, .varname = "list", .getvalue = list_getvalue); 128 ui_combobox(obj, .hexpand = true, .vexpand = false, .colspan = 2, .varname = "list", .getvalue = list_getvalue);
129 ui_newline(obj);
130
131 ui_hbox0(obj) {
132 ui_radiobutton(obj, .label = "Radio 1", .varname = "radio");
133 ui_radiobutton(obj, .label = "Radio 2", .varname = "radio");
134 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio");
135 }
124 } 136 }
125 137
126 ui_show(obj); 138 ui_show(obj);
127 } 139 }
128 140
133 // menu 145 // menu
134 ui_menu("File") { 146 ui_menu("File") {
135 ui_menuitem(.label = "Test"); 147 ui_menuitem(.label = "Test");
136 } 148 }
137 149
138 150 ui_toolbar_item("Test", .label = "Test", .icon = "terminal", .onclick = action_toolbar_button);
151 ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button);
152 ui_toolbar_menu("Menu", .label = "Menu") {
153 ui_menuitem("Secondary Test", NULL, NULL);
154 ui_menu("Secondary Sub") {
155 ui_menuitem("Secondary subitem", NULL, NULL);
156 }
157 }
158
159 ui_toolbar_add_default("Test", UI_TOOLBAR_LEFT);
160 ui_toolbar_add_default("Toggle", UI_TOOLBAR_LEFT);
161 ui_toolbar_add_default("Menu", UI_TOOLBAR_LEFT);
139 162
140 ui_main(); 163 ui_main();
141 164
142 return (EXIT_SUCCESS); 165 return (EXIT_SUCCESS);
143 } 166 }

mercurial