ui/gtk/toolkit.c

Wed, 27 Nov 2024 18:45:08 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 27 Nov 2024 18:45:08 +0100
changeset 95
e92c72705da4
parent 88
e27526429d85
child 96
493959648de6
permissions
-rw-r--r--

add upload/download list, resolves #512

0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2017 Olaf Wintermann. All rights reserved.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2483f517c562 add existing toolkit code
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
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <string.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include <stdbool.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "toolkit.h"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 #include "toolbar.h"
51
e324291ca9f8 add resource preview window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 48
diff changeset
36 #include "icon.h"
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include "../common/document.h"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 #include "../common/properties.h"
32
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
39 #include "../common/menu.h"
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
40 #include "../common/toolbar.h"
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
41 #include "../common/threadpool.h"
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 #include <cx/utils.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 #include <cx/string.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 #include <cx/printf.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 #include <pthread.h>
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
49 #ifdef UI_APPLICATION
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
50 UI_APPLICATION app;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 #endif
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
53 static const char *application_name;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 static ui_callback startup_func;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 static void *startup_data;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 static ui_callback open_func;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 void *open_data;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 static ui_callback exit_func;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 void *exit_data;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 static ui_callback appclose_fnc;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 static void *appclose_udata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 static UiObject *active_window;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 static int scale_factor = 1;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
69 UIEXPORT void ui_init(const char *appname, int argc, char **argv) {
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
70 application_name = appname;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 uic_init_global_context();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
73 #if GTK_MAJOR_VERSION >= 4
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
74 gtk_init();
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
75 #else
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 gtk_init(&argc, &argv);
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
77 #endif
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
32
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
79 ui_css_init();
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 uic_docmgr_init();
88
e27526429d85 add context menu, implement 'Select All'
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 87
diff changeset
81 uic_menu_init();
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
82 uic_toolbar_init();
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 ui_image_init();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 uic_load_app_properties();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
86 #if GTK_MAJOR_VERSION >= 4
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
87 scale_factor = 1; // TODO
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
88 #elif defined(UI_SUPPORTS_SCALE)
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 scale_factor = gdk_monitor_get_scale_factor(
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 gdk_display_get_primary_monitor(gdk_display_get_default()));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 #endif
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93
29
3fc287f06305 add minimal working download
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
94 const char* ui_appname() {
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 return application_name;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 void ui_onstartup(ui_callback f, void *userdata) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 startup_func = f;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 startup_data = userdata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 void ui_onopen(ui_callback f, void *userdata) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 open_func = f;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 open_data = userdata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 void ui_onexit(ui_callback f, void *userdata) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 exit_func = f;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 exit_data = userdata;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 #ifndef UI_GTK2
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 static void app_startup(GtkApplication* app, gpointer userdata) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 if(startup_func) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 startup_func(NULL, startup_data);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 static void app_activate(GtkApplication* app, gpointer userdata) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 printf("activate\n");
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 #endif
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 void ui_main() {
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
127 #ifdef UI_APPLICATION
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 cxmutstr appid = cx_asprintf(
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 "ui.%s",
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 application_name ? application_name : "application1");
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
131 app = UI_APPLICATION_NEW(appid.ptr);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 g_signal_connect (app, "startup", G_CALLBACK (app_startup), NULL);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 g_signal_connect (app, "activate", G_CALLBACK (app_activate), NULL);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 g_application_run(G_APPLICATION (app), 0, NULL);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 g_object_unref (app);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 free(appid.ptr);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 #else
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 if(startup_func) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 startup_func(NULL, startup_data);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 gtk_main();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 #endif
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 if(exit_func) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 exit_func(NULL, exit_data);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 uic_store_app_properties();
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 #ifndef UI_GTK2
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 void ui_app_quit() {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 g_application_quit(G_APPLICATION(app));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 GtkApplication* ui_get_application() {
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
156 return GTK_APPLICATION(app);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 #endif
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 void ui_show(UiObject *obj) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 uic_check_group_widgets(obj->ctx);
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
162 #if GTK_MAJOR_VERSION >= 4
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
163 gtk_window_present(GTK_WINDOW(obj->widget));
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
164 #elif GTK_MAJOR_VERSION <= 3
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 gtk_widget_show_all(obj->widget);
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
166 #endif
86
8e7c57c23133 add reference counting to download window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 70
diff changeset
167 obj->ref++;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 void ui_close(UiObject *obj) {
69
d8991e166f2a add toolkit window close fix
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 60
diff changeset
171 uic_context_prepare_close(obj->ctx);
56
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
172 #if GTK_CHECK_VERSION(4, 0, 0)
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
173 gtk_window_close(GTK_WINDOW(obj->widget));
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
174 #else
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
175 gtk_widget_destroy(obj->widget);
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
176 #endif
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 static gboolean ui_job_finished(void *data) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 UiJob *job = data;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 UiEvent event;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 event.obj = job->obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 event.window = job->obj->window;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 event.document = job->obj->ctx->document;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 event.intval = 0;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 event.eventdata = NULL;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 job->finish_callback(&event, job->finish_data);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 free(job);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 return FALSE;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 static void* ui_jobthread(void *data) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 UiJob *job = data;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 int result = job->job_func(job->job_data);
39
ef4e2f560fa5 fix gtk executing ui_job_finished even if no finish callback was set
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 32
diff changeset
198 if(!result && job->finish_callback) {
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 g_idle_add(ui_job_finished, job);
39
ef4e2f560fa5 fix gtk executing ui_job_finished even if no finish callback was set
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 32
diff changeset
200 } else {
ef4e2f560fa5 fix gtk executing ui_job_finished even if no finish callback was set
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 32
diff changeset
201 free(job);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 return NULL;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205
32
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
206 static gboolean ui_idle_func(void *data) {
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
207 UiJob *job = data;
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
208 job->job_func(job->job_data);
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
209 free(job);
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
210 return FALSE;
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
211 }
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
212
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
213 void ui_call_mainthread(ui_threadfunc tf, void* td) {
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
214 UiJob *job = malloc(sizeof(UiJob));
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
215 job->job_func = tf;
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
216 job->job_data = td;
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
217 job->finish_callback = NULL;
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
218 job->finish_data = NULL;
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
219 job->obj = NULL;
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
220 g_idle_add(ui_idle_func, job);
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
221 }
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
222
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 UiJob *job = malloc(sizeof(UiJob));
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 job->obj = obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 job->job_func = tf;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 job->job_data = td;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 job->finish_callback = f;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 job->finish_data = fd;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 pthread_t pid;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 pthread_create(&pid, NULL, ui_jobthread, job);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 void ui_set_enabled(UIWIDGET widget, int enabled) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 gtk_widget_set_sensitive(widget, enabled);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238 void ui_set_show_all(UIWIDGET widget, int value) {
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
239 // TODO: gtk4
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
240 #if GTK_MAJOR_VERSION <= 3
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 gtk_widget_set_no_show_all(widget, !value);
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
242 #endif
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 void ui_set_visible(UIWIDGET widget, int visible) {
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
246 // TODO: gtk4
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
247 #if GTK_MAJOR_VERSION <= 3
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 if(visible) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 gtk_widget_set_no_show_all(widget, FALSE);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 gtk_widget_show_all(widget);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 } else {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 gtk_widget_hide(widget);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 }
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
254 #endif
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 void ui_clipboard_set(char *str) {
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
258 #if GTK_MAJOR_VERSION >= 4
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
259 // TODO: gtk4: needs widget
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
260 #else
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 GtkClipboard *cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 gtk_clipboard_set_text(cb, str, strlen(str));
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
263 #endif
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 char* ui_clipboard_get() {
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
267 #if GTK_MAJOR_VERSION >= 4
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
268 // TODO: gtk4: needs widget
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
269 return NULL;
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
270 #else
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 GtkClipboard *cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 char *str = gtk_clipboard_wait_for_text(cb);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 if(str) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 char *copy = strdup(str);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 g_free(str);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 return copy;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 } else {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 return NULL;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 }
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
280 #endif
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 int ui_get_scalefactor() {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 return scale_factor;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 void ui_destroy_userdata(GtkWidget *object, void *userdata) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 free(userdata);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 void ui_destroy_vardata(GtkWidget *object, UiVarEventData *data) {
32
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
292 if(data->var) {
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
293 ui_destroy_boundvar(data->obj->ctx, data->var);
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
294 }
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 free(data);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298 void ui_destroy_boundvar(UiContext *ctx, UiVar *var) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 uic_unbind_var(var);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301 if(var->type == UI_VAR_SPECIAL) {
60
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
302 ui_free(var->from_ctx, var);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 } else {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304 ui_free(var->from_ctx, var);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305 // TODO: free or unbound
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306 //uic_remove_bound_var(ctx, var);
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 void ui_set_active_window(UiObject *obj) {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 active_window = obj;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 UiObject *ui_get_active_window() {
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 return active_window;
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318
32
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
319 #if GTK_MAJOR_VERSION >= 3
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
320
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
321 static GtkCssProvider* ui_gtk_css_provider;
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
322
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
323 #if GTK_MAJOR_VERSION == 4
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
324 static const char *ui_gtk_css =
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
325 "#path-textfield-box {\n"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
326 " background-color: alpha(currentColor, 0.1);"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
327 " border-radius: 6px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
328 " padding: 0px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
329 "}\n"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
330 ".pathbar-extra-button {\n"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
331 " border-top-right-radius: 6px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
332 " border-bottom-right-radius: 6px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
333 " border-top-left-radius: 0px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
334 " border-bottom-left-radius: 0px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
335 "}\n"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
336 "#pathbar button {\n"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
337 " margin: 3px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
338 " border-radius: 4px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
339 " padding-top: 0px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
340 " padding-bottom: 0px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
341 " padding-left: 8px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
342 " padding-right: 8px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
343 "}\n"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
344 "#path-textfield-box entry {\n"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
345 " background-color: #00000000;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
346 " border-top-left-radius: 6px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
347 " border-bottom-left-radius: 6px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
348 " border-top-right-radius: 0px;"
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
349 " border-bottom-right-radius: 0px;"
48
ae61523bce20 improve pathbar visuals
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 45
diff changeset
350 "}\n"
ae61523bce20 improve pathbar visuals
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 45
diff changeset
351 ".pathbar-button-inactive {\n"
ae61523bce20 improve pathbar visuals
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 45
diff changeset
352 " color: alpha(currentColor, 0.5);"
ae61523bce20 improve pathbar visuals
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 45
diff changeset
353 "}\n"
56
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
354 ".ui_test {\n"
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
355 " background-color: red;\n"
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
356 "}\n"
60
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
357 ".ui_label_title {\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
358 " font-weight: bold;\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
359 "}\n"
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
360 ;
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
361
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
362 #elif GTK_MAJOR_VERSION == 3
32
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
363 static const char *ui_gtk_css =
60
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
364 "#path-textfield-box {\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
365 " background-color: @theme_base_color;\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
366 " border-radius: 5px;\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
367 " padding: 0px;\n"
87
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
368 "}\n"
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
369 ".pathbar-button-inactive {\n"
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
370 " color: alpha(currentColor, 0.5);"
5360027fb282 download/upload refactoring, add cancel button, resolves #498 fixes #506
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 86
diff changeset
371 "}\n"
60
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
372 ".ui_test {\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
373 " background-color: red;\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
374 "}\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
375 ".ui_label_title {\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
376 " font-weight: bold;\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
377 "}\n"
ee4e4742391e add settings window and implement repository editing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 56
diff changeset
378 ;
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
379 #endif
32
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
380
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
381 void ui_css_init(void) {
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
382 ui_gtk_css_provider = gtk_css_provider_new();
42
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
383
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
384 #ifdef UI_GTK3
32
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
385 gtk_css_provider_load_from_data(ui_gtk_css_provider, ui_gtk_css, -1, NULL);
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
386
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
387 GdkScreen *screen = gdk_screen_get_default();
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
388 gtk_style_context_add_provider_for_screen(
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
389 screen,
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
390 GTK_STYLE_PROVIDER(ui_gtk_css_provider),
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
391 GTK_STYLE_PROVIDER_PRIORITY_USER);
42
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
392 #endif /* UI_GTK3 */
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
393
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
394 #ifdef UI_GTK4
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
395
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
396
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
397 #if GTK_MINOR_VERSION < 12
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
398 gtk_css_provider_load_from_data(ui_gtk_css_provider, ui_gtk_css, -1);
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
399 #else
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
400 gtk_css_provider_load_from_string(ui_gtk_css_provider, ui_gtk_css);
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
401 #endif /* GTK_MINOR_VERSION < 12 */
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
402
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
403 GdkDisplay *display = gdk_display_get_default();
44
473954dc6b74 update toolkit: gtk4 improvements
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 42
diff changeset
404 gtk_style_context_add_provider_for_display(display, GTK_STYLE_PROVIDER(ui_gtk_css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
42
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
405
9af327d0e0e4 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
406 #endif /* UI_GTK4 */
32
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
407 }
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
408
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
409
e5f4d8af567e update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
410
45
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
411 #endif
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
412
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
413 void ui_set_name_and_style(GtkWidget *widget, const char *name, const char *style_classes) {
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
414 if(name) {
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
415 gtk_widget_set_name(widget, name);
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
416 }
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
417 if(style_classes) {
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
418 cxstring *cls = NULL;
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
419 size_t numClasses = cx_strsplit_a(cxDefaultAllocator, cx_str(style_classes), CX_STR(" "), 128, &cls);
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
420 for(int i=0;i<numClasses;i++) {
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
421 cxmutstr m = cx_strdup(cls[i]);
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
422 #if GTK_MAJOR_VERSION >= 4
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
423 gtk_widget_add_css_class(widget, m.ptr);
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
424 #elif GTK_MAJOR_VERSION >= 3
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
425 GtkStyleContext *ctx = gtk_widget_get_style_context(widget);
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
426 gtk_style_context_add_class(ctx, m.ptr);
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
427 #endif
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
428 free(m.ptr);
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
429 }
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
430 free(cls);
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
431
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
432 }
ab71409644b0 update toolkit, fix download/upload progressbar
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
433 }
56
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
434
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
435 void ui_set_widget_groups(UiContext *ctx, GtkWidget *widget, const int *groups) {
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
436 if(!groups) {
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
437 return;
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
438 }
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
439 size_t ngroups = uic_group_array_size(groups);
70
94144a948aff fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
440 ui_set_widget_ngroups(ctx, widget, groups, ngroups);
56
294d5515583a add authentication dialog
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
441 }
70
94144a948aff fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
442
94144a948aff fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
443 void ui_set_widget_ngroups(UiContext *ctx, GtkWidget *widget, const int *groups, size_t ngroups) {
94144a948aff fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
444 if(ngroups > 0) {
94144a948aff fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
445 uic_add_group_widget_i(ctx, widget, (ui_enablefunc)ui_set_enabled, groups, ngroups);
94144a948aff fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
446 ui_set_enabled(widget, FALSE);
94144a948aff fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
447 }
94144a948aff fix generic file icon on gtk3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
448 }

mercurial