application/main.c

branch
newapi
changeset 282
3a77b9048664
parent 279
2ad83650d797
child 290
0dcf13ba5a78
equal deleted inserted replaced
281:2533cdebf6ef 282:3a77b9048664
34 #include <cx/utils.h> 34 #include <cx/utils.h>
35 35
36 typedef struct { 36 typedef struct {
37 UiString *str1; 37 UiString *str1;
38 UiString *str2; 38 UiString *str2;
39 UiString *path;
39 UiDouble *progress; 40 UiDouble *progress;
40 UiList *list; 41 UiList *list;
41 UiInteger *radio; 42 UiInteger *radio;
42 } MyDocument; 43 } MyDocument;
43 44
72 MyDocument* create_doc(void) { 73 MyDocument* create_doc(void) {
73 MyDocument *doc = ui_document_new(sizeof(MyDocument)); 74 MyDocument *doc = ui_document_new(sizeof(MyDocument));
74 UiContext *docctx = ui_document_context(doc); 75 UiContext *docctx = ui_document_context(doc);
75 doc->str1 = ui_string_new(docctx, "str1"); 76 doc->str1 = ui_string_new(docctx, "str1");
76 doc->str1 = ui_string_new(docctx, "str2"); 77 doc->str1 = ui_string_new(docctx, "str2");
78 doc->path = ui_string_new(docctx, "path");
77 doc->progress = ui_double_new(docctx, "progress"); 79 doc->progress = ui_double_new(docctx, "progress");
78 doc->list = ui_list_new(docctx, "list"); 80 doc->list = ui_list_new(docctx, "list");
79 ui_list_append(doc->list, "test1"); 81 ui_list_append(doc->list, "test1");
80 ui_list_append(doc->list, "test2"); 82 ui_list_append(doc->list, "test2");
81 ui_list_append(doc->list, "test3"); 83 ui_list_append(doc->list, "test3");
108 110
109 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button); 111 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
110 ui_togglebutton(obj, .label = "Toggle"); 112 ui_togglebutton(obj, .label = "Toggle");
111 ui_checkbox(obj, .label = "Checkbox"); 113 ui_checkbox(obj, .label = "Checkbox");
112 114
113 ui_grid(obj, .fill = 1, .columnspacing = 5, .rowspacing = 5, .margin = 5) { 115 ui_grid(obj, .fill = 1, .columnspacing = 15, .rowspacing = 15, .margin = 15) {
114 ui_button(obj, .label = "cell1", .hexpand = TRUE); 116 ui_button(obj, .label = "cell1", .hexpand = TRUE);
115 ui_button(obj, .label = "cell2"); 117 ui_button(obj, .label = "cell2");
116 ui_newline(obj); 118 ui_newline(obj);
117 ui_button(obj, .label = "cell_colspan2", .colspan = 2); 119 ui_button(obj, .label = "cell_colspan2", .colspan = 2);
118 ui_newline(obj); 120 ui_newline(obj);
127 ui_progressbar(obj, .colspan = 2, .varname = "progress"); 129 ui_progressbar(obj, .colspan = 2, .varname = "progress");
128 ui_set(doc->progress, 0.75); 130 ui_set(doc->progress, 0.75);
129 ui_newline(obj); 131 ui_newline(obj);
130 132
131 ui_textfield(obj, .value = doc->str1); 133 ui_textfield(obj, .value = doc->str1);
134 ui_newline(obj);
135
136 ui_path_textfield(obj, .colspan = 2, .varname = "path");
137 ui_set(doc->path, "/test/path/123");
132 ui_newline(obj); 138 ui_newline(obj);
133 139
134 //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1); 140 //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1);
135 //model->getvalue = list_getvalue; 141 //model->getvalue = list_getvalue;
136 ui_combobox(obj, .hexpand = true, .vexpand = false, .colspan = 2, .varname = "list", .getvalue = list_getvalue); 142 ui_combobox(obj, .hexpand = true, .vexpand = false, .colspan = 2, .varname = "list", .getvalue = list_getvalue);

mercurial