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