application/main.c

Thu, 03 Oct 2024 15:37:55 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 03 Oct 2024 15:37:55 +0200
branch
newapi
changeset 322
22f6dadd9f46
parent 320
be224cf1f50e
child 328
059cba080ab4
permissions
-rw-r--r--

implement ui_menuseparator (GTK4)

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>
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include <ui/ui.h>
174
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 164
diff changeset
33 #include <cx/buffer.h>
0358f1d9c506 upgrade ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 164
diff changeset
34 #include <cx/utils.h>
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
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;
266
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
40 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
41 UiList *list;
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
42 UiList *menulist;
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
43 UiInteger *radio;
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
44 } MyDocument;
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
45
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
46 MyDocument *doc1;
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
47 MyDocument *doc2;
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
48
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
49
162
18892c0a9adc ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 158
diff changeset
50 void action_menu(UiEvent *event, void *userdata) {
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
51
145
853685152c1d adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 144
diff changeset
52 }
853685152c1d adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 144
diff changeset
53
279
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
54 void action_file_selected(UiEvent *event, void *userdata) {
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
55 UiFileList *files = event->eventdata;
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
56 printf("files: %d\n", (int)files->nfiles);
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
57 if(files->nfiles > 0) {
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
58 printf("selected file: %s\n", files->files[0]);
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
59 }
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
60 }
2ad83650d797 implement file dialog (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 278
diff changeset
61
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
62 void action_button(UiEvent *event, void *userdata) {
317
b30415965ec3 implement ui_savefiledialog name parameter (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 315
diff changeset
63 ui_savefiledialog(event->obj, "myfile.txt", action_file_selected, NULL);
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
64 }
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
65
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
66 void action_switch(UiEvent *event, void *userdata) {
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
67
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
68 }
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
69
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
70 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
71 printf("toolbar button\n");
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
72
320
be224cf1f50e add alternative ui_dialog implementation for libadwaita
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 317
diff changeset
73 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
74 }
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
75
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
76 MyDocument* create_doc(void) {
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
77 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
78 UiContext *docctx = ui_document_context(doc);
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
79 doc->str1 = ui_string_new(docctx, "str1");
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
80 doc->str1 = ui_string_new(docctx, "str2");
282
3a77b9048664 add path textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 279
diff changeset
81 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
82 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
83 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
84 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
85 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
86 ui_list_append(doc->list, "test3");
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
87 doc->radio = ui_int_new(docctx, "radio");
163
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
88 return doc;
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
89 }
b70e2a77dea0 refactore document system to support document trees
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 162
diff changeset
90
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
91 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
92
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
93 static void* list_getvalue(void *elm, int col) {
269
3380100e20f5 implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 268
diff changeset
94 /*
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
95 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
96 if(!icon) {
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
97 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
98 }
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
99 return icon;
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
100 }
269
3380100e20f5 implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 268
diff changeset
101 */
3380100e20f5 implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 268
diff changeset
102
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
103 char *str = elm;
270
9389313ac00f port combobox to new API (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 269
diff changeset
104 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
105 }
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
106
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
107 static UiList *menu_list;
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
108 int new_item_count = 0;
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
109
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
110 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
111 char str[64];
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
112 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
113
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
114 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
115 ui_list_notify(menu_list);
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
116 }
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
117
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
118 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
119 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
120 }
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
121
133
6dd780cbc8c6 using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
122 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
123 // global list
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
124 UiContext *global = ui_global_context();
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
125 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
126 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
127 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
128 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
129
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
130
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
131
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 139
diff changeset
132 UiObject *obj = ui_window("Test", NULL);
137
c9b8b9e0cfe8 adds drawingarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 136
diff changeset
133
266
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
134 MyDocument *doc = create_doc();
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
135 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
136
304
d554b2a60105 fix gtk box margin
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 301
diff changeset
137 ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) {
d554b2a60105 fix gtk box margin
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 301
diff changeset
138 ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
d554b2a60105 fix gtk box margin
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 301
diff changeset
139 ui_togglebutton(obj, .label = "Toggle");
d554b2a60105 fix gtk box margin
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 301
diff changeset
140 ui_checkbox(obj, .label = "My Checkbox");
d554b2a60105 fix gtk box margin
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 301
diff changeset
141 }
d554b2a60105 fix gtk box margin
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 301
diff changeset
142 ui_grid(obj, .fill = UI_OFF, .columnspacing = 15, .rowspacing = 15, .margin = 15) {
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 259
diff changeset
143 ui_button(obj, .label = "cell1", .hexpand = TRUE);
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 259
diff changeset
144 ui_button(obj, .label = "cell2");
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 259
diff changeset
145 ui_newline(obj);
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 259
diff changeset
146 ui_button(obj, .label = "cell_colspan2", .colspan = 2);
261
b39f0e61fd99 add new label (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 260
diff changeset
147 ui_newline(obj);
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 259
diff changeset
148
261
b39f0e61fd99 add new label (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 260
diff changeset
149 ui_label(obj, .label = "Label Col 1", .align = UI_ALIGN_LEFT);
b39f0e61fd99 add new label (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 260
diff changeset
150 ui_label(obj, .label = "Label Col 2", .align = UI_ALIGN_RIGHT);
264
24d9a92fd048 update spinner entry widget api (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 261
diff changeset
151 ui_newline(obj);
24d9a92fd048 update spinner entry widget api (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 261
diff changeset
152
24d9a92fd048 update spinner entry widget api (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 261
diff changeset
153 ui_spinner(obj, .step = 5);
266
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
154 ui_newline(obj);
264
24d9a92fd048 update spinner entry widget api (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 261
diff changeset
155
266
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
156 ui_progressbar(obj, .colspan = 2, .varname = "progress");
37d5b49b1c91 fix progressbar using the wrong var type (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 265
diff changeset
157 ui_set(doc->progress, 0.75);
267
79dd183dd4cb port textfield to new API (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 266
diff changeset
158 ui_newline(obj);
79dd183dd4cb port textfield to new API (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 266
diff changeset
159
79dd183dd4cb port textfield to new API (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 266
diff changeset
160 ui_textfield(obj, .value = doc->str1);
268
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
161 ui_newline(obj);
1b321a0c624f port table to new API, replace custom tree model with GtkListStore
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
162
310
4918f9132552 add gtk4 pathbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 308
diff changeset
163 //ui_button(obj, .label="Test");
4918f9132552 add gtk4 pathbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 308
diff changeset
164 ui_path_textfield(obj, .varname = "path");
4918f9132552 add gtk4 pathbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 308
diff changeset
165 ui_set(doc->path, "/test/path/longdirectoryname/123");
282
3a77b9048664 add path textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 279
diff changeset
166 ui_newline(obj);
3a77b9048664 add path textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 279
diff changeset
167
269
3380100e20f5 implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 268
diff changeset
168 //UiModel *model = ui_model(obj->ctx, UI_ICON_TEXT, "Col 1", UI_STRING, "Col 2", -1);
3380100e20f5 implement listview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 268
diff changeset
169 //model->getvalue = list_getvalue;
270
9389313ac00f port combobox to new API (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 269
diff changeset
170 ui_combobox(obj, .hexpand = true, .vexpand = false, .colspan = 2, .varname = "list", .getvalue = list_getvalue);
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
171 ui_newline(obj);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
172
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
173 ui_hbox0(obj) {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
174 ui_radiobutton(obj, .label = "Radio 1", .varname = "radio");
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
175 ui_radiobutton(obj, .label = "Radio 2", .varname = "radio");
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
176 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio");
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
177 }
260
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 259
diff changeset
178 }
eebb0626d020 implement grid colspan/rowspan (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 259
diff changeset
179
133
6dd780cbc8c6 using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
180 ui_show(obj);
95
29f5cd5f5367 added drawing area (Gtk)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
181 }
111
40dbf1a7526a added close handler to UiContext (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 110
diff changeset
182
29
c96169444d88 added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
183 int main(int argc, char** argv) {
88
04c81be1c5a0 added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
184 ui_init("app1", argc, argv);
133
6dd780cbc8c6 using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
185 ui_onstartup(application_startup, NULL);
88
04c81be1c5a0 added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
186
133
6dd780cbc8c6 using GtkApplication now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
187 // menu
255
ebdce2bb62be minimal working menubar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
188 ui_menu("File") {
ebdce2bb62be minimal working menubar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
189 ui_menuitem(.label = "Test");
ebdce2bb62be minimal working menubar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 253
diff changeset
190 }
253
087cc9216f28 initial newapi GTK port
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 174
diff changeset
191
308
4efc7c19e31d simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
192 ui_toolbar_item("Test", .label = "Test", .onclick = action_toolbar_button);
4efc7c19e31d simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
193 ui_toolbar_item("Test2", .label = "Test 2", .onclick = action_toolbar_button);
4efc7c19e31d simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
194 ui_toolbar_item("Test3", .label = "Test 3", .onclick = action_toolbar_button);
4efc7c19e31d simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
195 ui_toolbar_item("Test4", .label = "Test 4", .onclick = action_toolbar_button);
4efc7c19e31d simplify gtk button code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 306
diff changeset
196 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
197 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
198 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
199 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
200 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
201 ui_menu("Secondary Sub") {
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
202 ui_menuitem("Secondary subitem", NULL, NULL);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
203 }
322
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
204 ui_menuseparator();
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
205 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
206 ui_menuseparator();
311
450a813dc2a5 implement GTK4 gmenu item and item list
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 310
diff changeset
207 ui_menuitem("last", .onclick = action_add_menu_item);
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
208 }
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
209
322
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
210 ui_toolbar_appmenu() {
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
211 ui_menuitem("New");
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
212 ui_menuitem("Open");
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
213 ui_menuitem("Save");
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
214
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
215 ui_menuseparator();
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
216
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
217 ui_menuitem("Close");
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
218 }
22f6dadd9f46 implement ui_menuseparator (GTK4)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 320
diff changeset
219
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
220 ui_toolbar_add_default("Test", UI_TOOLBAR_LEFT);
306
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
221 ui_toolbar_add_default("Test6", UI_TOOLBAR_LEFT);
275
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
222 ui_toolbar_add_default("Toggle", UI_TOOLBAR_LEFT);
132c7bcc6997 implement new toolbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 270
diff changeset
223 ui_toolbar_add_default("Menu", UI_TOOLBAR_LEFT);
89
9a7e4a335b2b added toolbar (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 88
diff changeset
224
306
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
225 ui_toolbar_add_default("Test2", UI_TOOLBAR_CENTER);
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
226 ui_toolbar_add_default("Test3", UI_TOOLBAR_CENTER);
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
227
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
228 ui_toolbar_add_default("Test4", UI_TOOLBAR_RIGHT);
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
229 ui_toolbar_add_default("Test5", UI_TOOLBAR_RIGHT);
d02e1149cdb9 add headerbar (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 304
diff changeset
230
88
04c81be1c5a0 added textarea (WPF)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
231 ui_main();
29
c96169444d88 added locale support (Cocoa) and ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 28
diff changeset
232
0
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 return (EXIT_SUCCESS);
1f419bd32da1 added files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 }

mercurial