application/main.c

Wed, 04 Dec 2024 08:55:49 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 04 Dec 2024 08:55:49 +0100
branch
newapi
changeset 404
384f6d1f5784
parent 402
96a055be7f0b
child 406
0ebf9d7b23e8
permissions
-rw-r--r--

add first working cocoa code

0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
144
29d98cff4f56 UiInteger uses int64 now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 143
diff changeset
4 * Copyright 2017 Olaf Wintermann. All rights reserved.
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
404
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
31 #include <string.h>
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include <ui/ui.h>
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 164
diff changeset
34 #include <cx/buffer.h>
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 164
diff changeset
35 #include <cx/utils.h>
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36
404
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
37 #ifndef UI_COCOA
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
38
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
39 typedef struct {
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
40 UiString *str1;
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
41 UiString *str2;
282
3a77b9048664 add path textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 279
diff changeset
42 UiString *path;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
43 UiText *text;
266
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
44 UiDouble *progress;
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
45 UiList *list;
390
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
46 UiList *list2;
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
47 UiList *menulist;
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
48 UiInteger *radio;
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
49 UiInteger *tabview;
339
b68b5f984074 add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
50 UiGeneric *image;
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
51 } MyDocument;
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
52
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
53 MyDocument *doc1;
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
54 MyDocument *doc2;
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
55
333
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
56 UIWIDGET tabview;
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
57
347
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
58 static UiCondVar *cond;
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
59 static int thr_end = 0;
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
60 static int thr_started = 0;
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
61
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
62 int threadfunc(void *data) {
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
63 printf("thr wait for data...\n");
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
64 ui_condvar_wait(cond);
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
65 printf("thr data received: {%s} [%d]\n", cond->data, cond->intdata);
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
66 ui_condvar_destroy(cond);
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
67 cond = NULL;
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
68
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
69 return 0;
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
70 }
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
71
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
72 void action_start_thread(UiEvent *event, void *data) {
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
73 if(!thr_started) {
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
74 cond = ui_condvar_create();
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
75 ui_job(event->obj, threadfunc, NULL, NULL, NULL);
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
76 thr_started = 1;
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
77 }
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
78 }
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
79
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
80 void action_notify_thread(UiEvent *event, void *data) {
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
81 if(!thr_end) {
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
82 ui_condvar_signal(cond, "hello thread", 123);
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
83 thr_end = 1;
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
84 }
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
85 }
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
86
162
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 158
diff changeset
87 void action_menu(UiEvent *event, void *userdata) {
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
88
145
853685152c1d adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 144
diff changeset
89 }
853685152c1d adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 144
diff changeset
90
279
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
91 void action_file_selected(UiEvent *event, void *userdata) {
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
92 UiFileList *files = event->eventdata;
339
b68b5f984074 add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
93 MyDocument *doc = event->document;
279
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
94 printf("files: %d\n", (int)files->nfiles);
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
95 if(files->nfiles > 0) {
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
96 printf("selected file: %s\n", files->files[0]);
339
b68b5f984074 add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
97 ui_image_load_file(doc->image, files->files[0]);
279
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
98 }
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
99 }
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
100
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
101 void action_button(UiEvent *event, void *userdata) {
339
b68b5f984074 add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
102 ui_openfiledialog(event->obj, UI_FILEDIALOG_SELECT_SINGLE, action_file_selected, NULL);
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
103 }
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
104
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
105 void action_switch(UiEvent *event, void *userdata) {
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
106
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
107 }
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
108
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
109 void action_toolbar_button(UiEvent *event, void *userdata) {
320
be224cf1f50e add alternative ui_dialog implementation for libadwaita
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
110 printf("toolbar button\n");
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
111
320
be224cf1f50e add alternative ui_dialog implementation for libadwaita
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
112 ui_dialog(event->obj, .title = "Dialog Title", .content = "Content Label", .button1_label = "btn1", .button2_label = "btn2", .input = TRUE, .closebutton_label = "Cancel");
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
113 }
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
114
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
115 void action_dialog_button(UiEvent *event, void *userdata) {
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
116 ui_close(event->obj);
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
117 }
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
118
402
96a055be7f0b add textfield onactivate event (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 390
diff changeset
119 void action_dialog_onactivate(UiEvent *event, void *userdata) {
96a055be7f0b add textfield onactivate event (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 390
diff changeset
120 printf("textfield activate\n");
96a055be7f0b add textfield onactivate event (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 390
diff changeset
121 ui_close(event->obj);
96a055be7f0b add textfield onactivate event (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 390
diff changeset
122 }
96a055be7f0b add textfield onactivate event (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 390
diff changeset
123
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
124 void action_toolbar_dialog(UiEvent *event, void *userdata) {
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
125
345
d2ccc543f432 add style for dialog window default button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 344
diff changeset
126 UiObject *dialog = ui_dialog_window(event->obj, .title = "Dialog Window", .lbutton1 = "Cancel 1", .lbutton2 = "Btn2", .rbutton3 = "Btn3", .rbutton4 = "Login 4", .onclick = action_dialog_button, .default_button = 4, .show_closebutton = UI_OFF);
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
127
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
128 ui_vbox(dialog, .margin = 10, .spacing = 10) {
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
129 ui_label(dialog, .label = "Enter password:");
402
96a055be7f0b add textfield onactivate event (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 390
diff changeset
130 ui_passwordfield(dialog, .varname = "password", .onactivate = action_dialog_onactivate);
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
131 }
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
132
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
133 ui_show(dialog);
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
134 }
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
135
336
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
136 void action_toolbar_newwindow(UiEvent *event, void *userdata) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
137 UiObject *obj = ui_simple_window("New Window", NULL);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
138
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
139 ui_headerbar0(obj) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
140 ui_headerbar_start(obj) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
141 ui_button(obj, .label = "Open");
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
142 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
143 ui_headerbar_end(obj) {
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
144 ui_button(obj, .label = "Test");
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
145 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
146 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
147
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
148 ui_textarea(obj, .varname="text");
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
149
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
150 ui_show(obj);
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
151 }
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
152
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
153 MyDocument* create_doc(void) {
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
154 MyDocument *doc = ui_document_new(sizeof(MyDocument));
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
155 UiContext *docctx = ui_document_context(doc);
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
156 doc->str1 = ui_string_new(docctx, "str1");
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
157 doc->str1 = ui_string_new(docctx, "str2");
282
3a77b9048664 add path textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 279
diff changeset
158 doc->path = ui_string_new(docctx, "path");
266
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
159 doc->progress = ui_double_new(docctx, "progress");
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
160 doc->list = ui_list_new(docctx, "list");
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
161 ui_list_append(doc->list, "test1");
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
162 ui_list_append(doc->list, "test2");
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
163 ui_list_append(doc->list, "test3");
390
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
164 doc->list2 = ui_list_new(docctx, "list2");
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
165 ui_list_append(doc->list2, "test1");
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
166 ui_list_append(doc->list2, "test2");
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
167 ui_list_append(doc->list2, "test3");
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
168 doc->radio = ui_int_new(docctx, "radio");
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
169 doc->tabview = ui_int_new(docctx, "tabview");
339
b68b5f984074 add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
170 doc->image = ui_generic_new(docctx, "image");
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
171 //doc->text = ui_text_new(docctx, "text");
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
172 return doc;
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
173 }
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
174
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
175 UiIcon *icon = NULL;
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
176
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
177 static void* list_getvalue(void *elm, int col) {
269
3380100e20f5 implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 268
diff changeset
178 /*
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
179 if(col == 0) {
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
180 if(!icon) {
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
181 icon = ui_icon("folder", 24);
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
182 }
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
183 return icon;
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
184 }
269
3380100e20f5 implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 268
diff changeset
185 */
3380100e20f5 implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 268
diff changeset
186
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
187 char *str = elm;
270
9389313ac00f port combobox to new API (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 269
diff changeset
188 return col == 0 ? str : "x";
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
189 }
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
190
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
191 static UiList *menu_list;
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
192 int new_item_count = 0;
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
193
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
194 void action_add_menu_item(UiEvent *event, void *userdata) {
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
195 char str[64];
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
196 snprintf(str, 64, "new item %d", new_item_count++);
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
197
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
198 ui_list_append(menu_list, strdup(str));
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
199 ui_list_notify(menu_list);
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
200 }
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
201
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
202 void action_menu_list(UiEvent *event, void *userdata) {
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
203 printf("menu list item: %d\n", event->intval);
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
204 }
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
205
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
206 static int tab_x = 0;
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
207 void action_tab2_button(UiEvent *event, void *userdata) {
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
208 MyDocument *doc = event->document;
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
209 printf("current page: %d\n", (int)ui_get(doc->tabview));
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
210 ui_set(doc->tabview, 0);
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
211 }
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
212
343
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
213
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
214 void action_group1(UiEvent *event, void *userdata) {
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
215 UiContext *ctx = event->obj->ctx;
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
216 if(userdata) {
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
217 ui_unset_group(ctx, 1);
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
218 } else {
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
219 ui_set_group(ctx, 1);
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
220 }
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
221 }
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
222
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
223 void action_group2(UiEvent *event, void *userdata) {
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
224 UiContext *ctx = event->obj->ctx;
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
225 if(userdata) {
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
226 ui_unset_group(ctx, 2);
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
227 } else {
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
228 ui_set_group(ctx, 2);
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
229 }
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
230 }
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
231
383
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
232 static UiObject *ref_window;
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
233
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
234 void action_button_ref(UiEvent *event, void *userdata) {
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
235 UiObject *obj = event->obj;
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
236 printf("action_button_ref: %u\n", obj->ref);
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
237 ui_object_ref(obj);
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
238 ref_window = obj;
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
239 }
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
240
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
241 void action_button_unref(UiEvent *event, void *userdata) {
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
242 UiObject *obj = userdata;
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
243 printf("action_button_unref: %u\n", obj->ref);
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
244 ui_object_unref(obj);
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
245 }
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
246
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
247 void action_toolbar_unrefwindow(UiEvent *event, void *userdata) {
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
248 UiObject *obj = ui_simple_window("Unref", NULL);
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
249 ui_grid(obj, .margin = 20) {
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
250 ui_button(obj, .label = "Unref", .onclick = action_button_unref, .onclickdata = ref_window);
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
251 }
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
252 ui_show(obj);
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
253 }
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
254
389
d15eca5fd8b3 implement image viewer context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 388
diff changeset
255 UiMenuBuilder *menubuilder;
d15eca5fd8b3 implement image viewer context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 388
diff changeset
256
390
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
257 void* table_getvalue(void *row, int col) {
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
258 return row;
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
259 }
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
260
133
6dd780cbc8c6 using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
261 void application_startup(UiEvent *event, void *data) {
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
262 // global list
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
263 UiContext *global = ui_global_context();
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
264 menu_list = ui_list_new(global, "menulist");
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
265 ui_list_append(menu_list, "menu list item 1");
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
266 ui_list_append(menu_list, "menu list item 2");
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
267 ui_list_append(menu_list, "menu list item 3");
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
268
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
269
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
270
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 139
diff changeset
271 UiObject *obj = ui_window("Test", NULL);
137
c9b8b9e0cfe8 adds drawingarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
272
266
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
273 MyDocument *doc = create_doc();
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
274 ui_attach_document(obj->ctx, doc);
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
275
332
7e7c05af8f3a implement stack set/get/remove (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 331
diff changeset
276 ui_tabview(obj, .spacing=10, .margin=10, .tabview = UI_TABVIEW_NAVIGATION_SIDE, .varname="tabview") {
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
277 ui_tab(obj, "Tab 1") {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
278 ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
279 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
280 ui_togglebutton(obj, .label = "Toggle");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
281 ui_checkbox(obj, .label = "My Checkbox");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
282 }
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
283 ui_grid(obj, .fill = UI_OFF, .columnspacing = 15, .rowspacing = 15, .margin = 15) {
343
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
284 ui_button(obj, .label = "Activate Group 1", .hexpand = TRUE, .onclick = action_group1);
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
285 ui_button(obj, .label = "Disable Group 1", .onclick = action_group1, .onclickdata = "disable");
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
286 ui_newline(obj);
343
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
287 ui_button(obj, .label = "Activate Group 2", .hexpand = TRUE, .onclick = action_group2);
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
288 ui_button(obj, .label = "Disable Group 2", .onclick = action_group2, .onclickdata = "disable");
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
289 ui_newline(obj);
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
290
54f5d7eb1335 implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 340
diff changeset
291 ui_button(obj, .label = "Groups 1,2", .colspan = 2, .groups = UI_GROUPS(1, 2));
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
292 ui_newline(obj);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
293
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
294 ui_label(obj, .label = "Label Col 1", .align = UI_ALIGN_LEFT);
358
98b26a19cbeb add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
295 ui_label(obj, .label = "Label Col 2", .style = UI_LABEL_STYLE_TITLE, .align = UI_ALIGN_RIGHT);
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
296 ui_newline(obj);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
297
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
298 ui_spinner(obj, .step = 5);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
299 ui_newline(obj);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
300
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
301 ui_progressbar(obj, .colspan = 2, .varname = "progress");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
302 ui_set(doc->progress, 0.75);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
303 ui_newline(obj);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
304
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
305 ui_textfield(obj, .value = doc->str1);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
306 ui_newline(obj);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
307
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
308 //ui_button(obj, .label="Test");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
309 ui_path_textfield(obj, .varname = "path");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
310 ui_set(doc->path, "/test/path/longdirectoryname/123");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
311 ui_newline(obj);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
312
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
313 //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
314 //model->getvalue = list_getvalue;
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
315 ui_combobox(obj, .hexpand = true, .vexpand = false, .colspan = 2, .varname = "list", .getvalue = list_getvalue);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
316 ui_newline(obj);
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
317
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
318 ui_hbox0(obj) {
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
319 ui_radiobutton(obj, .label = "Radio 1", .varname = "radio");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
320 ui_radiobutton(obj, .label = "Radio 2", .varname = "radio");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
321 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio");
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
322 }
390
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
323 ui_newline(obj);
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
324
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
325 UiModel *model = ui_model(obj->ctx, UI_STRING, "col1", -1);
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
326 model->getvalue = table_getvalue;
b130f80ec7f9 implement list/table contextmenu (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 389
diff changeset
327 ui_table(obj, .model = model, .list = doc->list2, .colspan = 2, .hexpand = TRUE, .contextmenu = menubuilder);
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
328 }
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
329 }
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
330 ui_tab(obj, "Tab 2") {
347
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
331 ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread);
6f0d0b0d97f5 add conditional variable API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 345
diff changeset
332 ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread);
383
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
333 ui_button(obj, .label = "Obj Ref", .onclick=action_button_ref);
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
334 ui_button(obj, .label = "Obj Unref", .onclick=action_button_unref, .onclickdata = obj);
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
335 ui_button(obj, .label = "Button 5", .onclick=action_tab2_button);
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
336 ui_button(obj, .label = "Button 6", .onclick=action_tab2_button);
331
cdad8b7e83db implement side navigation tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 328
diff changeset
337 }
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
338 ui_tab(obj, "Tab 3") {
333
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
339 UiTabViewArgs args = {0};
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
340 UI_CTN(obj, tabview=ui_tabview_create(obj, args)) {
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
341 UiObject *tab1 = ui_tabview_add(tabview, "Sub 1", -1);
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
342 ui_button(tab1, .label = "Button 1");
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
343
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
344
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
345 UiObject *tab2 = ui_tabview_add(tabview, "Sub 2", -1);
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
346 ui_button(tab2, .label = "Button 2");
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
347 }
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
348 }
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
349 ui_tab(obj, "Tab 4") {
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 333
diff changeset
350 ui_textarea(obj, .varname = "text");
333
634e3ce80afe implement gtk3 stack tabview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 332
diff changeset
351 }
339
b68b5f984074 add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
352 ui_tab(obj, "Tab 5") {
b68b5f984074 add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
353 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
389
d15eca5fd8b3 implement image viewer context menus (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 388
diff changeset
354 ui_imageviewer(obj, .varname = "image", .style_class = "imageviewer", .contextmenu = menubuilder);
339
b68b5f984074 add minimally working image viewer (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 336
diff changeset
355 }
350
70305d427f25 fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
356
70305d427f25 fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
357 ui_tab(obj, "Tab 6") {
354
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
358 ui_scrolledwindow(obj, .fill = UI_ON) {
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
359 ui_expander(obj, .label = "Expander", .margin = 10, .spacing = 10) {
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
360 ui_label(obj, .label = "Test");
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
361 ui_button(obj, .label = "Button");
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
362 }
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
363
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
364 ui_frame(obj, .label = "Frame", .margin = 10, .spacing = 10) {
358
98b26a19cbeb add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
365 ui_label(obj, .label = "Title", .style = UI_LABEL_STYLE_TITLE);
98b26a19cbeb add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
366 ui_label(obj, .label = "Sub-Title", .style = UI_LABEL_STYLE_SUBTITLE);
98b26a19cbeb add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
367 ui_label(obj, .label = "Dim Label", .style = UI_LABEL_STYLE_DIM);
98b26a19cbeb add more label styles (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 354
diff changeset
368 ui_label(obj, .label = "No Style");
354
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
369 }
baf9bcc98d87 add expander container (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 352
diff changeset
370
351
63db7e35e2e9 implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
371 for(int i=0;i<100;i++) {
63db7e35e2e9 implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
372 char labelstr[32];
63db7e35e2e9 implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
373 snprintf(labelstr, 32, "button %d", i);
63db7e35e2e9 implement scrolledwindow sub container type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 350
diff changeset
374 ui_button(obj, .label = labelstr);
350
70305d427f25 fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
375 }
70305d427f25 fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
376 }
70305d427f25 fix ui_scrolledwindow (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 347
diff changeset
377 }
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 259
diff changeset
378 }
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 259
diff changeset
379
328
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
380 /*
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
381
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
382 */
059cba080ab4 implement new tabview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 322
diff changeset
383
133
6dd780cbc8c6 using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
384 ui_show(obj);
95
29f5cd5f5367 added drawing area (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
385 }
111
40dbf1a7526a added close handler to UiContext (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 110
diff changeset
386
29
c96169444d88 added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
387 int main(int argc, char** argv) {
88
04c81be1c5a0 added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
388 ui_init("app1", argc, argv);
133
6dd780cbc8c6 using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
389 ui_onstartup(application_startup, NULL);
88
04c81be1c5a0 added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
390
133
6dd780cbc8c6 using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
391 // menu
255
ebdce2bb62be minimal working menubar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
392 ui_menu("File") {
ebdce2bb62be minimal working menubar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
393 ui_menuitem(.label = "Test");
ebdce2bb62be minimal working menubar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
394 }
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
395
388
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
396 ui_contextmenu(&menubuilder) {
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
397 ui_menuitem(.label = "Context Item 1");
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
398 ui_menuitem(.label = "Context Item 2");
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
399 ui_menu("Context Submenu") {
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
400 ui_menuitem(.label = "Context Sub Item");
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
401 }
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
402 }
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
403
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
404 ui_menu("Edit") {
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
405 ui_menuitem(.label = "Undo");
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
406 ui_menuseparator();
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
407 ui_menu("Submenu") {
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
408 ui_menuitem(.label = "Subitem");
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
409 }
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
410 }
473c03f85197 add menu builder API
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 383
diff changeset
411
308
4efc7c19e31d simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
412 ui_toolbar_item("Test", .label = "Test", .onclick = action_toolbar_button);
336
56c12f44c2d3 add custom headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
413 ui_toolbar_item("Test2", .label = "New Window", .onclick = action_toolbar_newwindow);
344
870dd3d41d83 add dialog window (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 343
diff changeset
414 ui_toolbar_item("Test3", .label = "Dialog", .onclick = action_toolbar_dialog);
383
03599608d555 add UiObject reference counting (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 358
diff changeset
415 ui_toolbar_item("Test4", .label = "Unref Window", .onclick = action_toolbar_unrefwindow);
308
4efc7c19e31d simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
416 ui_toolbar_item("Test5", .label = "Test 5", .onclick = action_toolbar_button);
4efc7c19e31d simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
417 ui_toolbar_item("Test6", .label = "Test 6", .onclick = action_toolbar_button);
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
418 ui_toolbar_toggleitem("Toggle", .label = "Toggle", .onchange = action_toolbar_button);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
419 ui_toolbar_menu("Menu", .label = "Menu") {
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
420 ui_menuitem("Secondary Test", .onclick = action_toolbar_button, NULL);
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
421 ui_menu("Secondary Sub") {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
422 ui_menuitem("Secondary subitem", NULL, NULL);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
423 }
322
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
424 ui_menuseparator();
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
425 ui_menu_itemlist(.varname = "menulist", .onselect=action_menu_list);
322
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
426 ui_menuseparator();
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
427 ui_menuitem("last", .onclick = action_add_menu_item);
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
428 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
429
322
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
430 ui_toolbar_appmenu() {
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
431 ui_menuitem("New");
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
432 ui_menuitem("Open");
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
433 ui_menuitem("Save");
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
434
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
435 ui_menuseparator();
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
436
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
437 ui_menuitem("Close");
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
438 }
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
439
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
440 ui_toolbar_add_default("Test", UI_TOOLBAR_LEFT);
306
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
441 ui_toolbar_add_default("Test6", UI_TOOLBAR_LEFT);
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
442 ui_toolbar_add_default("Toggle", UI_TOOLBAR_LEFT);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
443 ui_toolbar_add_default("Menu", UI_TOOLBAR_LEFT);
89
9a7e4a335b2b added toolbar (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 88
diff changeset
444
306
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
445 ui_toolbar_add_default("Test2", UI_TOOLBAR_CENTER);
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
446 ui_toolbar_add_default("Test3", UI_TOOLBAR_CENTER);
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
447
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
448 ui_toolbar_add_default("Test4", UI_TOOLBAR_RIGHT);
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
449 ui_toolbar_add_default("Test5", UI_TOOLBAR_RIGHT);
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
450
88
04c81be1c5a0 added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
451 ui_main();
29
c96169444d88 added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
452
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 return (EXIT_SUCCESS);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 }
404
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
455
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
456 #endif
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
457
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
458 #ifdef UI_COCOA
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
459
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
460 void application_startup(UiEvent *event, void *data) {
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
461
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
462 }
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
463
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
464 int main(int argc, char** argv) {
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
465 ui_init("app1", argc, argv);
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
466 ui_onstartup(application_startup, NULL);
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
467 ui_main();
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
468 return (EXIT_SUCCESS);
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
469 }
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
470
384f6d1f5784 add first working cocoa code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 402
diff changeset
471 #endif

mercurial