53 |
55 |
54 void action_open(UiEvent *event, void *data) { |
56 void action_open(UiEvent *event, void *data) { |
55 //printf("check1: %s\n", event->intval ? "true" : "false"); |
57 //printf("check1: %s\n", event->intval ? "true" : "false"); |
56 //printf("check1: %s\n", ui_getint(event->obj, "check1") ? "true" : "false"); |
58 //printf("check1: %s\n", ui_getint(event->obj, "check1") ? "true" : "false"); |
57 TestDocument *doc = event->document; |
59 TestDocument *doc = event->document; |
|
60 TestWindowData *wd = event->window; |
58 printf("check1: %s\n", ui_getval(doc->check1) ? "true" : "false"); |
61 printf("check1: %s\n", ui_getval(doc->check1) ? "true" : "false"); |
|
62 |
|
63 char *path = ui_openfiledialog(event->obj); |
|
64 if(path) { |
|
65 UcxBuffer *buf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); |
|
66 FILE *file = fopen(path, "r"); |
|
67 if(file) { |
|
68 ucx_stream_hcopy(file, buf, fread, ucx_buffer_write); |
|
69 ucx_buffer_putc(buf, '\0'); |
|
70 ui_setval(wd->text, buf->space); |
|
71 fclose(file); |
|
72 } |
|
73 ucx_buffer_free(buf); |
|
74 } |
59 } |
75 } |
60 |
76 |
61 void action_save(UiEvent *event, void *data) { |
77 void action_save(UiEvent *event, void *data) { |
62 TestWindowData *wd = event->window; |
78 TestWindowData *wd = event->window; |
63 printf("Text: {%s}\n", ui_getval(wd->text)); |
79 printf("Text: {%s}\n", ui_getval(wd->text)); |