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