annotate gtk4/dw.c @ 3005:522ef24b0aba default tip

GTK4: Fix even more deprecation warnings in GTK 4.10 and later. Migrate to GtkAlertDialog for 4.10 from GtkMessageDialog. Still need to center the dialog or something.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 20 Dec 2023 05:17:54 +0000
parents 0ea8d055e7df
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 * Dynamic Windows:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3 * A GTK like cross-platform GUI
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 * GTK4 forwarder module for portabilty.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5 *
2947
edb4307ac7ce Update copyright date, readme, license and changelog for upcoming release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2910
diff changeset
6 * (C) 2000-2023 Brian Smith <brian@dbsoft.org>
2751
ee1cfa7d645e Update copyright dates for the new year 2022.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2744
diff changeset
7 * (C) 2003-2022 Mark Hessling <mark@rexx.org>
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9 #include "dwconfig.h"
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 #include "dw.h"
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11 #include <glib/gi18n.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12 #include <string.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
13 #include <stdlib.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
14 #include <sys/utsname.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
15 #include <sys/socket.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
16 #include <sys/un.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
17 #include <sys/mman.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
18 #include <stdarg.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
19 #include <stdio.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
20 #include <unistd.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21 #include <ctype.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
22 #include <errno.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
23 #include <sys/time.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
24 #include <dirent.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
25 #include <sys/stat.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
26 #include <signal.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
27 #include <fcntl.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
28 #include <unistd.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
29 #include <math.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
30 #include <gdk/gdkkeysyms.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
31
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
32 #ifdef GDK_WINDOWING_X11
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
33 #include <gdk/x11/gdkx.h>
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
34 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36 #ifdef USE_WEBKIT
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
37 #ifdef USE_WEBKIT6
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
38 #include <webkit/webkit.h>
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
39 #else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40 #include <webkit2/webkit2.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
41 #endif
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
42 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
43
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
44 #include <gdk-pixbuf/gdk-pixbuf.h>
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
45
2857
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
46 #ifdef __FreeBSD__
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
47 #include <sys/param.h>
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
48 #include <sys/sysctl.h>
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
49 #endif
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
50
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51 #if __STDC_VERSION__ < 199901L
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52 # if __GNUC__ >= 2
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53 # define __func__ __FUNCTION__
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
54 # else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
55 # define __func__ "<unknown>"
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
56 # endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
58
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
59 /* Macros to encapsulate running functions on the main thread
2308
a9018bd91d04 GTK4: Fix DW_SIGNAL_ITEM_ENTER callbacks via the keyboard. Remove mouse
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2306
diff changeset
60 * #define _DW_SINGLE_THREADED to disable thread safety encapsulation.
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
61 * Parameters converted to a pointer array:
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
62 * [0] Pointer to the thread's event semaphore
2311
f6a6ea6b28fe Fix a minor typo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2310
diff changeset
63 * [1] Pointer to the function's return value
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
64 * [2] Pointer to function parameter 1
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
65 * ...
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
66 */
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
67 #ifndef _DW_SINGLE_THREADED
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
68 #define DW_FUNCTION_DEFINITION(func, rettype, ...) gboolean _##func(void **_args); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
69 rettype API func(__VA_ARGS__) {
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
70 #define DW_FUNCTION_ADD_PARAM void **_args = alloca(sizeof(void *)*4); \
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
71 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
72 _args[1] = (void *)NULL; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
73 _args[2] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
74 _args[3] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
75 #define DW_FUNCTION_ADD_PARAM1(param1) void **_args = alloca(sizeof(void *)*5); \
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
76 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
77 _args[1] = (void *)NULL; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
78 _args[2] = (void *)&param1; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
79 _args[3] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
80 _args[4] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
81 #define DW_FUNCTION_ADD_PARAM2(param1, param2) void **_args = alloca(sizeof(void *)*6); \
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
82 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
83 _args[1] = (void *)NULL; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
84 _args[2] = (void *)&param1; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
85 _args[3] = (void *)&param2; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
86 _args[4] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
87 _args[5] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
88 #define DW_FUNCTION_ADD_PARAM3(param1, param2, param3) void **_args = alloca(sizeof(void *)*7); \
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
89 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
90 _args[1] = (void *)NULL; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
91 _args[2] = (void *)&param1; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
92 _args[3] = (void *)&param2; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
93 _args[4] = (void *)&param3; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
94 _args[5] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
95 _args[6] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
96 #define DW_FUNCTION_ADD_PARAM4(param1, param2, param3, param4) void **_args = alloca(sizeof(void *)*8); \
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
97 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
98 _args[1] = (void *)NULL; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
99 _args[2] = (void *)&param1; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
100 _args[3] = (void *)&param2; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
101 _args[4] = (void *)&param3; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
102 _args[5] = (void *)&param4; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
103 _args[6] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
104 _args[7] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
105 #define DW_FUNCTION_ADD_PARAM5(param1, param2, param3, param4, param5) void **_args = alloca(sizeof(void *)*9); \
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
106 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
107 _args[1] = (void *)NULL; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
108 _args[2] = (void *)&param1; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
109 _args[3] = (void *)&param2; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
110 _args[4] = (void *)&param3; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
111 _args[5] = (void *)&param4; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
112 _args[6] = (void *)&param5; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
113 _args[7] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
114 _args[8] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
115 #define DW_FUNCTION_ADD_PARAM6(param1, param2, param3, param4, param5, param6) \
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
116 void **_args = alloca(sizeof(void *)*10); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
117 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
118 _args[1] = (void *)NULL; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
119 _args[2] = (void *)&param1; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
120 _args[3] = (void *)&param2; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
121 _args[4] = (void *)&param3; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
122 _args[5] = (void *)&param4; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
123 _args[6] = (void *)&param5; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
124 _args[7] = (void *)&param6; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
125 _args[8] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
126 _args[9] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
127 #define DW_FUNCTION_ADD_PARAM7(param1, param2, param3, param4, param5, param6, param7) \
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
128 void **_args = alloca(sizeof(void *)*11); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
129 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
130 _args[1] = (void *)NULL; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
131 _args[2] = (void *)&param1; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
132 _args[3] = (void *)&param2; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
133 _args[4] = (void *)&param3; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
134 _args[5] = (void *)&param4; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
135 _args[6] = (void *)&param5; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
136 _args[7] = (void *)&param6; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
137 _args[8] = (void *)&param7; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
138 _args[9] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
139 _args[10] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
140 #define DW_FUNCTION_ADD_PARAM8(param1, param2, param3, param4, param5, param6, param7, param8) \
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
141 void **_args = alloca(sizeof(void *)*12); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
142 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
143 _args[1] = (void *)NULL; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
144 _args[2] = (void *)&param1; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
145 _args[3] = (void *)&param2; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
146 _args[4] = (void *)&param3; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
147 _args[5] = (void *)&param4; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
148 _args[6] = (void *)&param5; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
149 _args[7] = (void *)&param6; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
150 _args[8] = (void *)&param7; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
151 _args[9] = (void *)&param8; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
152 _args[10] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
153 _args[11] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
154 #define DW_FUNCTION_ADD_PARAM9(param1, param2, param3, param4, param5, param6, param7, param8, param9) \
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
155 void **_args = alloca(sizeof(void *)*13); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
156 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
157 _args[1] = (void *)NULL; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
158 _args[2] = (void *)&param1; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
159 _args[3] = (void *)&param2; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
160 _args[4] = (void *)&param3; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
161 _args[5] = (void *)&param4; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
162 _args[6] = (void *)&param5; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
163 _args[7] = (void *)&param6; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
164 _args[8] = (void *)&param7; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
165 _args[9] = (void *)&param8; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
166 _args[10] = (void *)&param9; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
167 _args[11] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
168 _args[12] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
169 #define DW_FUNCTION_ADD_PARAM10(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10) \
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
170 void **_args = alloca(sizeof(void *)*14); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
171 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
172 _args[1] = (void *)NULL; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
173 _args[2] = (void *)&param1; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
174 _args[3] = (void *)&param2; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
175 _args[4] = (void *)&param3; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
176 _args[5] = (void *)&param4; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
177 _args[6] = (void *)&param5; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
178 _args[7] = (void *)&param6; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
179 _args[8] = (void *)&param7; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
180 _args[9] = (void *)&param8; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
181 _args[10] = (void *)&param9; \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
182 _args[11] = (void *)&param10; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
183 _args[12] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
184 _args[13] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
185 #define DW_FUNCTION_ADD_PARAM11(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11) \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
186 void **_args = alloca(sizeof(void *)*15); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
187 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
188 _args[1] = (void *)NULL; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
189 _args[2] = (void *)&param1; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
190 _args[3] = (void *)&param2; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
191 _args[4] = (void *)&param3; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
192 _args[5] = (void *)&param4; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
193 _args[6] = (void *)&param5; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
194 _args[7] = (void *)&param6; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
195 _args[8] = (void *)&param7; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
196 _args[9] = (void *)&param8; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
197 _args[10] = (void *)&param9; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
198 _args[11] = (void *)&param10; \
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
199 _args[12] = (void *)&param11; \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
200 _args[13] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
201 _args[14] = (void *)pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
202 #define DW_FUNCTION_ADD_PARAM12(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12) \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
203 void **_args = alloca(sizeof(void *)*16); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
204 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
205 _args[1] = (void *)NULL; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
206 _args[2] = (void *)&param1; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
207 _args[3] = (void *)&param2; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
208 _args[4] = (void *)&param3; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
209 _args[5] = (void *)&param4; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
210 _args[6] = (void *)&param5; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
211 _args[7] = (void *)&param6; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
212 _args[8] = (void *)&param7; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
213 _args[9] = (void *)&param8; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
214 _args[10] = (void *)&param9; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
215 _args[11] = (void *)&param10; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
216 _args[12] = (void *)&param11; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
217 _args[13] = (void *)&param12; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
218 _args[14] = (void *)pthread_getspecific(_dw_fg_color_key); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
219 _args[15] = (void *)pthread_getspecific(_dw_bg_color_key);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
220 #define DW_FUNCTION_RESTORE_PARAM1(param1, vartype1) \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
221 vartype1 param1 = *((vartype1 *)_args[2]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
222 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[3]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
223 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[4];
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
224 #define DW_FUNCTION_RESTORE_PARAM2(param1, vartype1, param2, vartype2) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
225 vartype1 param1 = *((vartype1 *)_args[2]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
226 vartype2 param2 = *((vartype2 *)_args[3]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
227 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[4]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
228 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[5];
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
229 #define DW_FUNCTION_RESTORE_PARAM3(param1, vartype1, param2, vartype2, param3, vartype3) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
230 vartype1 param1 = *((vartype1 *)_args[2]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
231 vartype2 param2 = *((vartype2 *)_args[3]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
232 vartype3 param3 = *((vartype3 *)_args[4]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
233 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[5]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
234 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[6];
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
235 #define DW_FUNCTION_RESTORE_PARAM4(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
236 vartype1 param1 = *((vartype1 *)_args[2]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
237 vartype2 param2 = *((vartype2 *)_args[3]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
238 vartype3 param3 = *((vartype3 *)_args[4]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
239 vartype4 param4 = *((vartype4 *)_args[5]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
240 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[6]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
241 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[7];
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
242 #define DW_FUNCTION_RESTORE_PARAM5(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
243 vartype1 param1 = *((vartype1 *)_args[2]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
244 vartype2 param2 = *((vartype2 *)_args[3]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
245 vartype3 param3 = *((vartype3 *)_args[4]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
246 vartype4 param4 = *((vartype4 *)_args[5]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
247 vartype5 param5 = *((vartype5 *)_args[6]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
248 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[7]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
249 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[8];
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
250 #define DW_FUNCTION_RESTORE_PARAM6(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
251 vartype1 param1 = *((vartype1 *)_args[2]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
252 vartype2 param2 = *((vartype2 *)_args[3]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
253 vartype3 param3 = *((vartype3 *)_args[4]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
254 vartype4 param4 = *((vartype4 *)_args[5]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
255 vartype5 param5 = *((vartype5 *)_args[6]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
256 vartype6 param6 = *((vartype6 *)_args[7]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
257 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[8]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
258 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[9];
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
259 #define DW_FUNCTION_RESTORE_PARAM7(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
260 vartype1 param1 = *((vartype1 *)_args[2]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
261 vartype2 param2 = *((vartype2 *)_args[3]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
262 vartype3 param3 = *((vartype3 *)_args[4]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
263 vartype4 param4 = *((vartype4 *)_args[5]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
264 vartype5 param5 = *((vartype5 *)_args[6]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
265 vartype6 param6 = *((vartype6 *)_args[7]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
266 vartype7 param7 = *((vartype7 *)_args[8]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
267 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[9]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
268 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[10];
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
269 #define DW_FUNCTION_RESTORE_PARAM8(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
270 vartype1 param1 = *((vartype1 *)_args[2]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
271 vartype2 param2 = *((vartype2 *)_args[3]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
272 vartype3 param3 = *((vartype3 *)_args[4]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
273 vartype4 param4 = *((vartype4 *)_args[5]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
274 vartype5 param5 = *((vartype5 *)_args[6]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
275 vartype6 param6 = *((vartype6 *)_args[7]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
276 vartype7 param7 = *((vartype7 *)_args[8]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
277 vartype8 param8 = *((vartype8 *)_args[9]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
278 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[10]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
279 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[11];
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
280 #define DW_FUNCTION_RESTORE_PARAM9(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
281 vartype1 param1 = *((vartype1 *)_args[2]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
282 vartype2 param2 = *((vartype2 *)_args[3]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
283 vartype3 param3 = *((vartype3 *)_args[4]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
284 vartype4 param4 = *((vartype4 *)_args[5]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
285 vartype5 param5 = *((vartype5 *)_args[6]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
286 vartype6 param6 = *((vartype6 *)_args[7]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
287 vartype7 param7 = *((vartype7 *)_args[8]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
288 vartype8 param8 = *((vartype8 *)_args[9]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
289 vartype9 param9 = *((vartype9 *)_args[10]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
290 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[11]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
291 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[12];
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
292 #define DW_FUNCTION_RESTORE_PARAM10(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10) \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
293 vartype1 param1 = *((vartype1 *)_args[2]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
294 vartype2 param2 = *((vartype2 *)_args[3]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
295 vartype3 param3 = *((vartype3 *)_args[4]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
296 vartype4 param4 = *((vartype4 *)_args[5]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
297 vartype5 param5 = *((vartype5 *)_args[6]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
298 vartype6 param6 = *((vartype6 *)_args[7]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
299 vartype7 param7 = *((vartype7 *)_args[8]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
300 vartype8 param8 = *((vartype8 *)_args[9]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
301 vartype9 param9 = *((vartype9 *)_args[10]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
302 vartype10 param10 = *((vartype10 *)_args[11]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
303 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[12]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
304 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[13];
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
305 #define DW_FUNCTION_RESTORE_PARAM11(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10, param11, vartype11) \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
306 vartype1 param1 = *((vartype1 *)_args[2]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
307 vartype2 param2 = *((vartype2 *)_args[3]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
308 vartype3 param3 = *((vartype3 *)_args[4]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
309 vartype4 param4 = *((vartype4 *)_args[5]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
310 vartype5 param5 = *((vartype5 *)_args[6]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
311 vartype6 param6 = *((vartype6 *)_args[7]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
312 vartype7 param7 = *((vartype7 *)_args[8]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
313 vartype8 param8 = *((vartype8 *)_args[9]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
314 vartype9 param9 = *((vartype9 *)_args[10]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
315 vartype10 param10 = *((vartype10 *)_args[11]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
316 vartype11 param11 = *((vartype11 *)_args[12]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
317 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[13]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
318 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[14];
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
319 #define DW_FUNCTION_RESTORE_PARAM12(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10, param11, vartype11, param12, vartype12) \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
320 vartype1 param1 = *((vartype1 *)_args[2]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
321 vartype2 param2 = *((vartype2 *)_args[3]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
322 vartype3 param3 = *((vartype3 *)_args[4]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
323 vartype4 param4 = *((vartype4 *)_args[5]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
324 vartype5 param5 = *((vartype5 *)_args[6]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
325 vartype6 param6 = *((vartype6 *)_args[7]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
326 vartype7 param7 = *((vartype7 *)_args[8]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
327 vartype8 param8 = *((vartype8 *)_args[9]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
328 vartype9 param9 = *((vartype9 *)_args[10]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
329 vartype10 param10 = *((vartype10 *)_args[11]); \
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
330 vartype11 param11 = *((vartype11 *)_args[12]); \
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
331 vartype12 param12 = *((vartype12 *)_args[13]); \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
332 GdkRGBA * DW_UNUSED(_dw_fg_color) = (GdkRGBA *)_args[14]; \
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
333 GdkRGBA * DW_UNUSED(_dw_bg_color) = (GdkRGBA *)_args[15];
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
334 #define DW_FUNCTION_END }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
335 #define DW_FUNCTION_NO_RETURN(func) dw_event_reset((HEV)_args[0]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
336 if(_dw_thread == (pthread_t)-1 || pthread_self() == _dw_thread) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
337 _##func(_args); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
338 else { \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
339 g_idle_add_full(G_PRIORITY_HIGH_IDLE, G_SOURCE_FUNC(_##func), (gpointer)_args, NULL); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
340 dw_event_wait((HEV)_args[0], DW_TIMEOUT_INFINITE); } \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
341 }\
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
342 gboolean _##func(void **_args) {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
343 #define DW_FUNCTION_RETURN(func, rettype) dw_event_reset((HEV)_args[0]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
344 if(_dw_thread == (pthread_t)-1 || pthread_self() == _dw_thread) \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
345 _##func(_args); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
346 else { \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
347 g_idle_add_full(G_PRIORITY_HIGH_IDLE, G_SOURCE_FUNC(_##func), (gpointer)_args, NULL); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
348 dw_event_wait((HEV)_args[0], DW_TIMEOUT_INFINITE); } { \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
349 void *tmp = _args[1]; \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
350 rettype myreturn = *((rettype *)tmp); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
351 free(tmp); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
352 return myreturn; } \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
353 } \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
354 gboolean _##func(void **_args) {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
355 #define DW_FUNCTION_RETURN_THIS(_retvar) { void *_myreturn = malloc(sizeof(_retvar)); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
356 memcpy(_myreturn, (void *)&_retvar, sizeof(_retvar)); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
357 _args[1] = _myreturn; } \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
358 dw_event_post((HEV)_args[0]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
359 return FALSE; }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
360 #define DW_FUNCTION_RETURN_NOTHING dw_event_post((HEV)_args[0]); \
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
361 return FALSE; }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
362 #else
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
363 #define DW_FUNCTION_DEFINITION(func, rettype, ...) rettype API func(__VA_ARGS__)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
364 #define DW_FUNCTION_ADD_PARAM1(param1)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
365 #define DW_FUNCTION_ADD_PARAM2(param1, param2)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
366 #define DW_FUNCTION_ADD_PARAM3(param1, param2, param3)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
367 #define DW_FUNCTION_ADD_PARAM4(param1, param2, param3, param4)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
368 #define DW_FUNCTION_ADD_PARAM5(param1, param2, param3, param4, param5)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
369 #define DW_FUNCTION_ADD_PARAM6(param1, param2, param3, param4, param5, param6)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
370 #define DW_FUNCTION_ADD_PARAM7(param1, param2, param3, param4, param5, param6, param7)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
371 #define DW_FUNCTION_ADD_PARAM8(param1, param2, param3, param4, param5, param6, param7, param8)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
372 #define DW_FUNCTION_ADD_PARAM9(param1, param2, param3, param4, param5, param6, param7, param8, param9)
2312
ada8f7610df0 GTK4: Fix building with -D_DW_SINGLE_THREADED and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2311
diff changeset
373 #define DW_FUNCTION_ADD_PARAM10(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
374 #define DW_FUNCTION_ADD_PARAM11(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
375 #define DW_FUNCTION_ADD_PARAM12(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12)
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
376 #define DW_FUNCTION_RESTORE_PARAM1(param1, vartype1)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
377 #define DW_FUNCTION_RESTORE_PARAM2(param1, vartype1, param2, vartype2)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
378 #define DW_FUNCTION_RESTORE_PARAM3(param1, vartype1, param2, vartype2, param3, vartype3)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
379 #define DW_FUNCTION_RESTORE_PARAM4(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
380 #define DW_FUNCTION_RESTORE_PARAM5(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
381 #define DW_FUNCTION_RESTORE_PARAM6(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
382 #define DW_FUNCTION_RESTORE_PARAM7(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
383 #define DW_FUNCTION_RESTORE_PARAM8(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
384 #define DW_FUNCTION_RESTORE_PARAM9(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
385 #define DW_FUNCTION_RESTORE_PARAM10(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
386 #define DW_FUNCTION_RESTORE_PARAM11(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10, param11, vartype11)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
387 #define DW_FUNCTION_RESTORE_PARAM12(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10, param11, vartype11, param12, vartype12)
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
388 #define DW_FUNCTION_END
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
389 #define DW_FUNCTION_NO_RETURN(func)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
390 #define DW_FUNCTION_RETURN(func, rettype)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
391 #define DW_FUNCTION_RETURN_THIS(retvar) return retvar;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
392 #define DW_FUNCTION_RETURN_NOTHING
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
393 #endif
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
394
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
395 /* ff = 255 = 1.0000
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
396 * ee = 238 = 0.9333
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
397 * cc = 204 = 0.8000
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
398 * bb = 187 = 0.7333
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
399 * aa = 170 = 0.6667
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
400 * 77 = 119 = 0.4667
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
401 * 00 = 0 = 0.0000
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
402 */
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
403 GdkRGBA _dw_colors[] =
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
404 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
405 { 0.0000, 0.0000, 0.0000, 1.0 }, /* 0 black */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
406 { 0.7333, 0.0000, 0.0000, 1.0 }, /* 1 red */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
407 { 0.0000, 0.7333, 0.0000, 1.0 }, /* 2 green */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
408 { 0.6667, 0.6667, 0.0000, 1.0 }, /* 3 yellow */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
409 { 0.0000, 0.0000, 0.8000, 1.0 }, /* 4 blue */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
410 { 0.7333, 0.0000, 0.7333, 1.0 }, /* 5 magenta */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
411 { 0.0000, 0.7333, 0.7333, 1.0 }, /* 6 cyan */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
412 { 0.7333, 0.7333, 0.7333, 1.0 }, /* 7 white */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
413 { 0.4667, 0.4667, 0.4667, 1.0 }, /* 8 grey */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
414 { 1.0000, 0.0000, 0.0000, 1.0 }, /* 9 bright red */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
415 { 0.0000, 1.0000, 0.0000, 1.0 }, /* 10 bright green */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
416 { 0.9333, 0.9333, 0.0000, 1.0 }, /* 11 bright yellow */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
417 { 0.0000, 0.0000, 1.0000, 1.0 }, /* 12 bright blue */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
418 { 1.0000, 0.0000, 1.0000, 1.0 }, /* 13 bright magenta */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
419 { 0.0000, 0.9333, 0.9333, 1.0 }, /* 14 bright cyan */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
420 { 1.0000, 1.0000, 1.0000, 1.0 }, /* 15 bright white */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
421 };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
422
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
423 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
424 * List those icons that have transparency first
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
425 */
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
426 static char *_dw_image_exts[] =
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
427 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
428 ".xpm",
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
429 ".png",
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
430 ".ico",
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
431 ".icns",
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
432 ".gif",
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
433 ".jpg",
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
434 ".jpeg",
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
435 ".tiff",
2312
ada8f7610df0 GTK4: Fix building with -D_DW_SINGLE_THREADED and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2311
diff changeset
436 ".bmp",
ada8f7610df0 GTK4: Fix building with -D_DW_SINGLE_THREADED and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2311
diff changeset
437 NULL
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
438 };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
439
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
440 #ifndef max
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
441 # define max(a,b) (((a) > (b)) ? (a) : (b))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
442 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
443
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
444 #ifndef min
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
445 # define min(a,b) (((a) < (b)) ? (a) : (b))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
446 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
447
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
448 static pthread_key_t _dw_fg_color_key;
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
449 static pthread_key_t _dw_bg_color_key;
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
450 static pthread_key_t _dw_event_key;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
451
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
452 static pthread_t _dw_thread = (pthread_t)-1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
453
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
454 static GList *_dw_dirty_list = NULL;
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
455
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
456 #define _DW_TREE_TYPE_CONTAINER 1
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
457 #define _DW_TREE_TYPE_TREE 2
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
458 #define _DW_TREE_TYPE_LISTBOX 3
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
459 #define _DW_TREE_TYPE_COMBOBOX 4
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
460
2319
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
461 #define _DW_RESOURCE_PATH "/org/dbsoft/dwindows/resources/"
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
462
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
463 /* Signal forwarder prototypes */
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
464 static gint _dw_button_press_event(GtkGestureSingle *gesture, int n_press, double x, double y, gpointer data);
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
465 static gint _dw_button_release_event(GtkGestureSingle *gesture, int n_press, double x, double y, gpointer data);
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
466 static gint _dw_motion_notify_event(GtkEventControllerMotion *controller, double x, double y, gpointer data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
467 static gboolean _dw_delete_event(GtkWidget *window, gpointer data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
468 static gint _dw_key_press_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
469 static gint _dw_generic_event(GtkWidget *widget, gpointer data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
470 static gint _dw_configure_event(GtkWidget *widget, int width, int height, gpointer data);
2309
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
471 static gint _dw_container_enter_event(GtkEventController *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data);
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
472 static gint _dw_combobox_select_event(GtkWidget *widget, gpointer data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
473 static gint _dw_expose_event(GtkWidget *widget, cairo_t *cr, int width, int height, gpointer data);
2371
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
474 static void _dw_set_focus_event(GObject *window, GParamSpec *pspec, gpointer data);
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
475 static gint _dw_tree_context_event(GtkGestureSingle *gesture, int n_press, double x, double y, gpointer data);
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
476 static gint _dw_value_changed_event(GtkWidget *widget, gpointer user_data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
477 static gint _dw_tree_select_event(GtkTreeSelection *sel, gpointer data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
478 static gint _dw_tree_expand_event(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
479 static gint _dw_switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
480 static gint _dw_column_click_event(GtkWidget *widget, gpointer data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
481 #ifdef USE_WEBKIT
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
482 static void _dw_html_result_event(GObject *object, GAsyncResult *result, gpointer script_data);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
483 static void _dw_html_changed_event(WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer data);
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
484 #ifdef USE_WEBKIT6
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
485 static void _dw_html_message_event(WebKitUserContentManager *manager, JSCValue *result, gpointer *data);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
486 #else
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
487 static void _dw_html_message_event(WebKitUserContentManager *manager, WebKitJavascriptResult *result, gpointer *data);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
488 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
489 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
490 static void _dw_signal_disconnect(gpointer data, GClosure *closure);
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
491 static void _dw_event_coordinates_to_window(GtkWidget *widget, double *x, double *y);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
492
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
493 GObject *_DWObject = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
494 GApplication *_DWApp = NULL;
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
495 GMainLoop *_DWMainLoop = NULL;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
496 static char _dw_app_id[_DW_APP_ID_SIZE+1] = { 0 };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
497 char *_DWDefaultFont = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
498 static char _dw_share_path[PATH_MAX+1] = { 0 };
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
499 static long _dw_mouse_last_x = 0;
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
500 static long _dw_mouse_last_y = 0;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
501
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
502 typedef struct _dw_signal_list
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
503 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
504 void *func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
505 char name[30];
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
506 char gname[30];
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
507 GObject *(*setup)(struct _dw_signal_list *, GObject *, void *, void *, void *);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
508
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
509 } DWSignalList;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
510
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
511 /* Signal setup function prototypes */
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
512 GObject *_dw_key_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data);
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
513 GObject *_dw_button_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data);
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
514 GObject *_dw_mouse_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data);
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
515 GObject *_dw_motion_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data);
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
516 GObject *_dw_draw_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data);
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
517 GObject *_dw_value_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data);
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
518 GObject *_dw_tree_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data);
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
519 GObject *_dw_focus_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data);
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
520 #ifdef USE_WEBKIT
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
521 GObject *_dw_html_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data);
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
522 #endif
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
523
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
524 typedef struct
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
525 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
526 HWND window;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
527 void *func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
528 gpointer data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
529 gint cid;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
530 void *intfunc;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
531
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
532 } DWSignalHandler;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
533
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
534 /* A list of signal forwarders, to account for parameter differences. */
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
535 static DWSignalList DWSignalTranslate[] = {
2371
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
536 { _dw_configure_event, DW_SIGNAL_CONFIGURE, "resize", NULL },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
537 { _dw_key_press_event, DW_SIGNAL_KEY_PRESS, "key-pressed", _dw_key_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
538 { _dw_button_press_event, DW_SIGNAL_BUTTON_PRESS, "pressed", _dw_mouse_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
539 { _dw_button_release_event, DW_SIGNAL_BUTTON_RELEASE, "released", _dw_mouse_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
540 { _dw_motion_notify_event, DW_SIGNAL_MOTION_NOTIFY, "motion", _dw_motion_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
541 { _dw_delete_event, DW_SIGNAL_DELETE, "close-request", NULL },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
542 { _dw_expose_event, DW_SIGNAL_EXPOSE, "draw", _dw_draw_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
543 { _dw_generic_event, DW_SIGNAL_CLICKED, "clicked", _dw_button_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
544 { _dw_container_enter_event, DW_SIGNAL_ITEM_ENTER, "key-pressed", _dw_key_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
545 { _dw_tree_context_event, DW_SIGNAL_ITEM_CONTEXT, "pressed", _dw_tree_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
546 { _dw_combobox_select_event, DW_SIGNAL_LIST_SELECT, "changed", NULL },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
547 { _dw_tree_select_event, DW_SIGNAL_ITEM_SELECT, "changed", _dw_tree_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
548 { _dw_set_focus_event, DW_SIGNAL_SET_FOCUS, "notify::is-active", _dw_focus_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
549 { _dw_value_changed_event, DW_SIGNAL_VALUE_CHANGED, "value-changed", _dw_value_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
550 { _dw_switch_page_event, DW_SIGNAL_SWITCH_PAGE, "switch-page", NULL },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
551 { _dw_column_click_event, DW_SIGNAL_COLUMN_CLICK, "activate", _dw_tree_setup },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
552 { _dw_tree_expand_event, DW_SIGNAL_TREE_EXPAND, "row-expanded", NULL },
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
553 #ifdef USE_WEBKIT
2371
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
554 { _dw_html_changed_event, DW_SIGNAL_HTML_CHANGED, "load-changed", NULL },
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
555 { _dw_html_result_event, DW_SIGNAL_HTML_RESULT, "", _dw_html_setup },
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
556 { _dw_html_message_event, DW_SIGNAL_HTML_MESSAGE, "", _dw_html_setup },
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
557 #endif
2371
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
558 { NULL, "", "", NULL }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
559 };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
560
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
561 /* Alignment flags */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
562 #define DW_CENTER 0.5f
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
563 #define DW_LEFT 0.0f
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
564 #define DW_RIGHT 1.0f
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
565 #define DW_TOP 0.0f
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
566 #define DW_BOTTOM 1.0f
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
567
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
568 static void _dw_msleep(long period)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
569 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
570 #ifdef __sun__
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
571 /* usleep() isn't threadsafe on Solaris */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
572 struct timespec req;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
573
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
574 req.tv_sec = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
575 if(period >= 1000)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
576 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
577 req.tv_sec = (int)(period / 1000);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
578 period -= (req.tv_sec * 1000);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
579 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
580 req.tv_nsec = period * 10000000;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
581
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
582 nanosleep(&req, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
583 #else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
584 usleep(period * 1000);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
585 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
586 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
587
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
588 /* Finds the translation function for a given signal name */
2628
d3d8a93124f1 GTK4: Fix compilation after style standarization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2626
diff changeset
589 static DWSignalList _dw_findsignal(const char *signame)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
590 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
591 int z=0;
2628
d3d8a93124f1 GTK4: Fix compilation after style standarization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2626
diff changeset
592 static DWSignalList empty = {0};
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
593
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
594 while(DWSignalTranslate[z].func)
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
595 {
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
596 if(strcasecmp(signame, DWSignalTranslate[z].name) == 0)
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
597 return DWSignalTranslate[z];
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
598 z++;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
599 }
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
600 return empty;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
601 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
602
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
603 static DWSignalHandler _dw_get_signal_handler(gpointer data)
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
604 {
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
605 DWSignalHandler sh = {0};
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
606
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
607 if(data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
608 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
609 void **params = (void **)data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
610 int counter = GPOINTER_TO_INT(params[0]);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
611 GtkWidget *widget = (GtkWidget *)params[2];
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
612 char text[101] = {0};
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
613
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
614 snprintf(text, 100, "_dw_sigwindow%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
615 sh.window = (HWND)g_object_get_data(G_OBJECT(widget), text);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
616 snprintf(text, 100, "_dw_sigfunc%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
617 sh.func = (void *)g_object_get_data(G_OBJECT(widget), text);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
618 snprintf(text, 100, "_dw_intfunc%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
619 sh.intfunc = (void *)g_object_get_data(G_OBJECT(widget), text);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
620 snprintf(text, 100, "_dw_sigdata%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
621 sh.data = g_object_get_data(G_OBJECT(widget), text);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
622 snprintf(text, 100, "_dw_sigcid%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
623 sh.cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), text));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
624 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
625 return sh;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
626 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
627
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
628 static void _dw_remove_signal_handler(GtkWidget *widget, int counter)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
629 {
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
630 char text[101] = {0};
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
631 gint cid;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
632
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
633 snprintf(text, 100, "_dw_sigcid%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
634 cid = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), text));
2660
650f8b062317 GTK: Check the Connection ID is positive non-zero before removing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2628
diff changeset
635 if(cid > 0)
650f8b062317 GTK: Check the Connection ID is positive non-zero before removing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2628
diff changeset
636 g_signal_handler_disconnect(G_OBJECT(widget), cid);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
637 g_object_set_data(G_OBJECT(widget), text, NULL);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
638 snprintf(text, 100, "_dw_sigwindow%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
639 g_object_set_data(G_OBJECT(widget), text, NULL);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
640 snprintf(text, 100, "_dw_sigfunc%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
641 g_object_set_data(G_OBJECT(widget), text, NULL);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
642 snprintf(text, 100, "_dw_intfunc%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
643 g_object_set_data(G_OBJECT(widget), text, NULL);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
644 snprintf(text, 100, "_dw_sigdata%d", counter);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
645 g_object_set_data(G_OBJECT(widget), text, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
646 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
647
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
648 static int _dw_set_signal_handler(GObject *object, HWND window, void *func, gpointer data, void *intfunc, void *discfunc)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
649 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
650 int counter = GPOINTER_TO_INT(g_object_get_data(object, "_dw_sigcounter"));
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
651 char text[101] = {0};
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
652
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
653 snprintf(text, 100, "_dw_sigwindow%d", counter);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
654 g_object_set_data(object, text, (gpointer)window);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
655 snprintf(text, 100, "_dw_sigfunc%d", counter);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
656 g_object_set_data(object, text, (gpointer)func);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
657 snprintf(text, 100, "_dw_intfunc%d", counter);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
658 g_object_set_data(object, text, (gpointer)intfunc);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
659 snprintf(text, 100, "_dw_discfunc%d", counter);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
660 g_object_set_data(object, text, (gpointer)discfunc);
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
661 snprintf(text, 100, "_dw_sigdata%d", counter);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
662 g_object_set_data(object, text, (gpointer)data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
663
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
664 counter++;
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
665 g_object_set_data(object, "_dw_sigcounter", GINT_TO_POINTER(counter));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
666
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
667 return counter - 1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
668 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
670 static void _dw_set_signal_handler_id(GObject *object, int counter, gint cid)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
671 {
2660
650f8b062317 GTK: Check the Connection ID is positive non-zero before removing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2628
diff changeset
672 if(cid > 0)
650f8b062317 GTK: Check the Connection ID is positive non-zero before removing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2628
diff changeset
673 {
2663
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
674 char text[101] = {0};
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
675
3b3be9f7f452 GTK3/4: Add some memory safety checks that were in GTK2 but missing from GTK 3/4.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2660
diff changeset
676 snprintf(text, 100, "_dw_sigcid%d", counter);
2660
650f8b062317 GTK: Check the Connection ID is positive non-zero before removing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2628
diff changeset
677 g_object_set_data(object, text, GINT_TO_POINTER(cid));
650f8b062317 GTK: Check the Connection ID is positive non-zero before removing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2628
diff changeset
678 }
650f8b062317 GTK: Check the Connection ID is positive non-zero before removing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2628
diff changeset
679 else
650f8b062317 GTK: Check the Connection ID is positive non-zero before removing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2628
diff changeset
680 dw_debug("WARNING: Dynamic Windows failed to connect signal.\n");
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
681 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
682
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
683 #ifdef USE_WEBKIT
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
684 static void _dw_html_result_event(GObject *object, GAsyncResult *result, gpointer script_data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
685 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
686 pthread_t saved_thread = _dw_thread;
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
687 #ifndef USE_WEBKIT6
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
688 WebKitJavascriptResult *js_result;
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
689 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
690 JSCValue *value;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
691 GError *error = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
692 int (*htmlresultfunc)(HWND, int, char *, void *, void *) = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
693 gint handlerdata = GPOINTER_TO_INT(g_object_get_data(object, "_dw_html_result_id"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
694 void *user_data = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
695
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
696 _dw_thread = (pthread_t)-1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
697 if(handlerdata)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
698 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
699 void *params[3] = { GINT_TO_POINTER(handlerdata-1), 0, object };
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
700 DWSignalHandler work = _dw_get_signal_handler(params);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
701
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
702 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
703 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
704 htmlresultfunc = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
705 user_data = work.data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
706 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
707 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
708
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
709 #ifdef USE_WEBKIT6
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
710 if(!(value = webkit_web_view_evaluate_javascript_finish(WEBKIT_WEB_VIEW(object), result, &error)))
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
711 #else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
712 if(!(js_result = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object), result, &error)))
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
713 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
714 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
715 if(htmlresultfunc)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
716 htmlresultfunc((HWND)object, DW_ERROR_UNKNOWN, error->message, script_data, user_data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
717 g_error_free (error);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
718 _dw_thread = saved_thread;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
719 return;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
720 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
722 #ifndef USE_WEBKIT6
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
723 value = webkit_javascript_result_get_js_value(js_result);
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
724 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
725 if(jsc_value_is_string(value))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
726 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
727 gchar *str_value = jsc_value_to_string(value);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
728 JSCException *exception = jsc_context_get_exception(jsc_value_get_context(value));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
729
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
730 if(htmlresultfunc)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
731 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
732 if(exception)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
733 htmlresultfunc((HWND)object, DW_ERROR_UNKNOWN, (char *)jsc_exception_get_message(exception), script_data, user_data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
734 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
735 htmlresultfunc((HWND)object, DW_ERROR_NONE, str_value, script_data, user_data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
736 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
737 g_free (str_value);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
738 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
739 else if(htmlresultfunc)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
740 htmlresultfunc((HWND)object, DW_ERROR_UNKNOWN, NULL, script_data, user_data);
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
741 #ifndef USE_WEBKIT6
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
742 webkit_javascript_result_unref (js_result);
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
743 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
744 _dw_thread = saved_thread;
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
745 }
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
746
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
747 #ifdef USE_WEBKIT6
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
748 static void _dw_html_message_event(WebKitUserContentManager *manager, JSCValue *result, gpointer *data)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
749 #else
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
750 static void _dw_html_message_event(WebKitUserContentManager *manager, WebKitJavascriptResult *result, gpointer *data)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
751 #endif
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
752 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
753 HWND window = (HWND)data[0];
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
754 int (*htmlmessagefunc)(HWND, char *, char *, void *) = NULL;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
755 void *user_data = NULL;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
756 gchar *name = (gchar *)data[1];
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
757 gint handlerdata;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
758
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
759 if(window && (handlerdata = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(window), "_dw_html_message_id"))))
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
760 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
761 void *params[3] = { GINT_TO_POINTER(handlerdata-1), 0, window };
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
762 DWSignalHandler work = _dw_get_signal_handler(params);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
763
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
764 if(work.window)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
765 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
766 htmlmessagefunc = work.func;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
767 user_data = work.data;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
768 }
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
769 }
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
770
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
771 if(jsc_value_is_string(result))
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
772 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
773 gchar *str_value = jsc_value_to_string(result);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
774 JSCException *exception = jsc_context_get_exception(jsc_value_get_context(result));
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
775
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
776 if(htmlmessagefunc && !exception)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
777 htmlmessagefunc(window, name, str_value, user_data);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
778
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
779 g_free(str_value);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
780
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
781 if(!exception)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
782 return;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
783 }
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
784 if(htmlmessagefunc)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
785 htmlmessagefunc(window, name, NULL, user_data);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
786 }
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
787
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
788 static void _dw_html_changed_event(WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer data)
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
789 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
790 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
791 char *location = (char *)webkit_web_view_get_uri(web_view);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
792 int status = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
793
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
794 switch (load_event) {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
795 case WEBKIT_LOAD_STARTED:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
796 status = DW_HTML_CHANGE_STARTED;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
797 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
798 case WEBKIT_LOAD_REDIRECTED:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
799 status = DW_HTML_CHANGE_REDIRECT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
800 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
801 case WEBKIT_LOAD_COMMITTED:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
802 status = DW_HTML_CHANGE_LOADING;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
803 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
804 case WEBKIT_LOAD_FINISHED:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
805 status = DW_HTML_CHANGE_COMPLETE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
806 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
807 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
808 if(status && location && work.window && work.func)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
809 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
810 int (*htmlchangedfunc)(HWND, int, char *, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
811
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
812 htmlchangedfunc(work.window, status, location, work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
813 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
814 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
815 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
816
2371
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
817 static void _dw_set_focus_event(GObject *window, GParamSpec *pspec, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
818 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
819 DWSignalHandler work = _dw_get_signal_handler(data);
2371
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
820 gboolean active;
2370
b18ef6c5b77a GTK4: The GtkWidget paramater to the activate-focus signal was removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2369
diff changeset
821
2371
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
822 g_object_get(window, "is-active", &active, NULL);
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
823
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
824 if(active && work.window)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
825 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
826 int (*setfocusfunc)(HWND, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
827
2371
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
828 setfocusfunc(work.window, work.data);
67f98f3e47f4 GTK4: Switch from "activate-focus" to "notify::is-active" for DW_SIGNAL_SET_FOCUS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2370
diff changeset
829 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
830 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
831
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
832 static gint _dw_button_press_event(GtkGestureSingle *gesture, int n_press, double x, double y, gpointer data)
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
833 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
834 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
835 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
836
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 int (*buttonfunc)(HWND, int, int, int, void *) = work.func;
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
840 int mybutton = gtk_gesture_single_get_current_button(gesture);
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
841
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
842 if(mybutton == 3)
2618
156ad91481eb WARNING: Standardize button press and release button parameter values.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2584
diff changeset
843 mybutton = DW_BUTTON2_MASK;
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
844 else if(mybutton == 2)
2618
156ad91481eb WARNING: Standardize button press and release button parameter values.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2584
diff changeset
845 mybutton = DW_BUTTON3_MASK;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
846
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
847 retval = buttonfunc(work.window, (int)x, (int)y, mybutton, work.data);
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
848
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
849 _dw_event_coordinates_to_window(work.window, &x, &y);
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
850
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
851 _dw_mouse_last_x = (long)x;
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
852 _dw_mouse_last_y = (long)y;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
856
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
857 static gint _dw_button_release_event(GtkGestureSingle *gesture, int n_press, double x, double y, gpointer data)
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
858 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
859 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
860 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
861
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
862 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
863 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
864 int (*buttonfunc)(HWND, int, int, int, void *) = work.func;
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
865 int mybutton = gtk_gesture_single_get_current_button(gesture);
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
866
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
867 if(mybutton == 3)
2618
156ad91481eb WARNING: Standardize button press and release button parameter values.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2584
diff changeset
868 mybutton = DW_BUTTON2_MASK;
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
869 else if(mybutton == 2)
2618
156ad91481eb WARNING: Standardize button press and release button parameter values.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2584
diff changeset
870 mybutton = DW_BUTTON3_MASK;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
871
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872 retval = buttonfunc(work.window, (int)x, (int)y, mybutton, work.data);
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
873
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
874 _dw_event_coordinates_to_window(work.window, &x, &y);
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
875
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
876 _dw_mouse_last_x = (long)x;
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
877 _dw_mouse_last_y = (long)y;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
878 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
879 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
880 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
881
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
882 static gint _dw_motion_notify_event(GtkEventControllerMotion *controller, double x, double y, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
883 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
884 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
885 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
886
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
887 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
888 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
889 int (*motionfunc)(HWND, int, int, int, void *) = work.func;
2278
18028fa53ef2 GTK4: Implement dw_pointer_query_pos(). Fix a macro typo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2277
diff changeset
890 GdkEvent *event = gtk_event_controller_get_current_event(GTK_EVENT_CONTROLLER(controller));
2277
ba81894924cb GTK4: Changes to handle the now opaque GdkEvent structure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2276
diff changeset
891 GdkModifierType state = gdk_event_get_modifier_state(event);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
892 int keys = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
893
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 if (state & GDK_BUTTON1_MASK)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
895 keys = DW_BUTTON1_MASK;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
896 if (state & GDK_BUTTON3_MASK)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
897 keys |= DW_BUTTON2_MASK;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898 if (state & GDK_BUTTON2_MASK)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
899 keys |= DW_BUTTON3_MASK;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 retval = motionfunc(work.window, (int)x, (int)y, keys, work.data);
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
902
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
903 _dw_event_coordinates_to_window(work.window, &x, &y);
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
904
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
905 _dw_mouse_last_x = (long)x;
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
906 _dw_mouse_last_y = (long)y;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
908 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
909 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
910
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
911 static gboolean _dw_delete_event(GtkWidget *window, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
912 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
913 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
914 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
915
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
916 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
917 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
918 int (*closefunc)(HWND, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
919
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
920 retval = closefunc(work.window, work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
921 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
922 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
923 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
924
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
925 static gint _dw_key_press_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
926 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
927 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
928 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
929
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
930 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
931 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
932 int (*keypressfunc)(HWND, char, int, int, void *, char *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
933 guint32 unichar = gdk_keyval_to_unicode(keyval);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
934 char utf8[7] = { 0 };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
935
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
936 g_unichar_to_utf8(unichar, utf8);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
937
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
938 retval = keypressfunc(work.window, (char)keycode, keyval,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
939 state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_ALT_MASK), work.data, utf8);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
940 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
941 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
942 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
943
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
944 static gint _dw_generic_event(GtkWidget *widget, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
945 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
946 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
947 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
948
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
949 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
950 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
951 int (*genericfunc)(HWND, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
952
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
953 retval = genericfunc(work.window, work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
954 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
955 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
956 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
957
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
958 static gint _dw_configure_event(GtkWidget *widget, int width, int height, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
959 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
960 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
961 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
962
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
963 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
964 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
965 int (*sizefunc)(HWND, int, int, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
966
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
967 retval = sizefunc(work.window, width, height, work.data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
968 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
969 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
970 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
971
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
972 cairo_t *_dw_cairo_update(GtkWidget *widget, int width, int height)
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
973 {
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
974 cairo_t *wincr = g_object_get_data(G_OBJECT(widget), "_dw_cr");
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
975 cairo_surface_t *surface = g_object_get_data(G_OBJECT(widget), "_dw_cr_surface");
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
976
2365
77686ad495ba GTK3/4: Optimizing dirty list management. Keep list as short as possible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2363
diff changeset
977 if(width == -1 && height == -1 && !wincr && g_list_find(_dw_dirty_list, widget) == NULL)
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
978 _dw_dirty_list = g_list_append(_dw_dirty_list, widget);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
979
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
980 if(width == -1)
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
981 width = gtk_widget_get_width(widget);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
982 if(height == -1)
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
983 height = gtk_widget_get_height(widget);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
984
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
985 if(!surface || GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "_dw_width")) != width ||
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
986 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "_dw_height")) != height)
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
987 {
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
988 if(surface)
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
989 cairo_surface_destroy(surface);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
990 surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
991 /* Save the cairo context for use in the drawing functions */
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
992 g_object_set_data(G_OBJECT(widget), "_dw_cr_surface", (gpointer)surface);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
993 g_object_set_data(G_OBJECT(widget), "_dw_width", GINT_TO_POINTER(width));
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
994 g_object_set_data(G_OBJECT(widget), "_dw_height", GINT_TO_POINTER(height));
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
995 }
2365
77686ad495ba GTK3/4: Optimizing dirty list management. Keep list as short as possible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2363
diff changeset
996 #ifdef DW_USE_CACHED_CR
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
997 return wincr;
2365
77686ad495ba GTK3/4: Optimizing dirty list management. Keep list as short as possible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2363
diff changeset
998 #else
77686ad495ba GTK3/4: Optimizing dirty list management. Keep list as short as possible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2363
diff changeset
999 return NULL;
77686ad495ba GTK3/4: Optimizing dirty list management. Keep list as short as possible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2363
diff changeset
1000 #endif
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
1001 }
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
1002
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1003 static gint _dw_expose_event(GtkWidget *widget, cairo_t *cr, int width, int height, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1004 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1005 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1006
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
1007 if(widget && GTK_IS_DRAWING_AREA(widget))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1008 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1009 DWExpose exp;
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
1010 int (*exposefunc)(HWND, DWExpose *, void *) = g_object_get_data(G_OBJECT(widget), "_dw_expose_func");
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1011
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
1012 _dw_cairo_update(widget, width, height);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
1013
2365
77686ad495ba GTK3/4: Optimizing dirty list management. Keep list as short as possible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2363
diff changeset
1014 /* Remove the currently drawn widget from the dirty list */
77686ad495ba GTK3/4: Optimizing dirty list management. Keep list as short as possible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2363
diff changeset
1015 _dw_dirty_list = g_list_remove(_dw_dirty_list, widget);
77686ad495ba GTK3/4: Optimizing dirty list management. Keep list as short as possible.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2363
diff changeset
1016
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1017 exp.x = exp.y = 0;
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
1018 exp.width = width;
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
1019 exp.height = height;
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
1020 g_object_set_data(G_OBJECT(widget), "_dw_cr", (gpointer)cr);
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
1021 retval = exposefunc((HWND)widget, &exp, data);
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
1022 g_object_set_data(G_OBJECT(widget), "_dw_cr", NULL);
2363
d7688c3ec43f GTK4: Remove widget from dirty list during expose event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2362
diff changeset
1023
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
1024 /* Copy the cached image to the output surface */
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
1025 cairo_set_source_surface(cr, g_object_get_data(G_OBJECT(widget), "_dw_cr_surface"), 0, 0);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
1026 cairo_rectangle(cr, 0, 0, width, height);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
1027 cairo_fill(cr);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1028 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1029 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1030 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1031
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1032 static gint _dw_combobox_select_event(GtkWidget *widget, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1033 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
1034 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1035 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1036
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1037 if(g_object_get_data(G_OBJECT(widget), "_dw_recursing"))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1038 return FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1039
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1040 if(work.window && GTK_IS_COMBO_BOX(widget))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1041 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1042 GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1043
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1044 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1045 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1046 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1047 GtkTreePath *path;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1048
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1049 g_object_set_data(G_OBJECT(widget), "_dw_recursing", GINT_TO_POINTER(1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051 if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1055 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1057 gint *indices = gtk_tree_path_get_indices(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1058
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1059 if(indices)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1060 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1061 int (*selectfunc)(HWND, int, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1062
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1063 retval = selectfunc(work.window, indices[0], work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1064 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1065 gtk_tree_path_free(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1066 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1067 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1068
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1069 g_object_set_data(G_OBJECT(widget), "_dw_recursing", NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1070 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1071 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1072 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1073 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1074
2757
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1075 /* Convert coordinate system from the widget to the window */
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
1076 static void _dw_event_coordinates_to_window(GtkWidget *widget, double *x, double *y)
2757
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1077 {
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1078 GtkRoot *root = (widget && GTK_IS_WIDGET(widget)) ? gtk_widget_get_root(widget) : NULL;
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1079
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1080 if(root && GTK_IS_WIDGET(root))
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1081 {
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1082 GtkWidget *parent = GTK_WIDGET(root);
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1083
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1084 /* If the parent is a window, try to use the box attached to it... */
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1085 if(GTK_IS_WINDOW(parent))
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1086 {
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1087 GtkWidget *box = g_object_get_data(G_OBJECT(parent), "_dw_grid");
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1088
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1089 if(box && GTK_IS_GRID(box))
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1090 parent = box;
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1091 }
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1092
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1093 graphene_point_t *treepoint = graphene_point_init(graphene_point_alloc(), (float)*x, (float)*y);
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1094 graphene_point_t *windowpoint = graphene_point_alloc();
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1095
2758
e1b5dbec0796 GTK4: Was still passing the root parameter to the transform function,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2757
diff changeset
1096 if(gtk_widget_compute_point(widget, parent, treepoint, windowpoint))
2757
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1097 {
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1098 *x = (double)windowpoint->x;
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1099 *y = (double)windowpoint->y;
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1100 }
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1101
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1102 graphene_point_free(treepoint);
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1103 graphene_point_free(windowpoint);
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1104 }
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1105 }
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1106
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1107 #define _DW_DATA_TYPE_STRING 0
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1108 #define _DW_DATA_TYPE_POINTER 1
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1109
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
1110 static gint _dw_tree_context_event(GtkGestureSingle *gesture, int n_press, double x, double y, gpointer data)
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
1111 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
1112 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1113 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1114
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1115 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1116 {
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
1117 int button = gtk_gesture_single_get_current_button(gesture);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1118
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1119 if(button == 3)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1120 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1121 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 char *text = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 void *itemdata = NULL;
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
1124 GtkWidget *widget = work.window;
2757
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1125
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1126 _dw_event_coordinates_to_window(widget, &x, &y);
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
1127
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
1128 _dw_mouse_last_x = (long)x;
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
1129 _dw_mouse_last_y = (long)y;
2757
b91bc30d0e4a GTK4: dw_menu_popup() coordinates are relative to the parent window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2751
diff changeset
1130
2335
1d413d869fa2 GTK4: Trees/Containers were not passing correct data due to missing scrolled
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2334
diff changeset
1131 /* Containers and trees are inside scrolled window widgets */
1d413d869fa2 GTK4: Trees/Containers were not passing correct data due to missing scrolled
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2334
diff changeset
1132 if(GTK_IS_SCROLLED_WINDOW(widget))
1d413d869fa2 GTK4: Trees/Containers were not passing correct data due to missing scrolled
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2334
diff changeset
1133 widget = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), "_dw_user"));
1d413d869fa2 GTK4: Trees/Containers were not passing correct data due to missing scrolled
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2334
diff changeset
1134
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1135 if(widget && GTK_IS_TREE_VIEW(widget))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1136 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1137 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1138 GtkTreeModel *store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1139 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1140
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1141 if(sel && gtk_tree_selection_get_mode(sel) != GTK_SELECTION_MULTIPLE &&
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1142 gtk_tree_selection_get_selected(sel, NULL, &iter))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1143 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1144 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1145 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1146 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, 2, &itemdata, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1147 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1148 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1149 {
2470
8f7c2f20c7c0 GTK4: Fill in the row data for contatiner context.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2441
diff changeset
1150 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, _DW_DATA_TYPE_POINTER, &itemdata, -1);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1151 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1152 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1153 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1154 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1155 GtkTreePath *path;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1156
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1157 gtk_tree_view_get_cursor(GTK_TREE_VIEW(widget), &path, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1158 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1159 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1160 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1161
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1162 if(gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1163 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1164 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1165 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1166 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, 2, &itemdata, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1167 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1168 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1169 {
2470
8f7c2f20c7c0 GTK4: Fill in the row data for contatiner context.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2441
diff changeset
1170 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, _DW_DATA_TYPE_POINTER, &itemdata, -1);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1171 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1172 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1173 gtk_tree_path_free(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1174 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1175 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1176 }
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
1177 retval = contextfunc(work.window, text, (int)x, (int)y, work.data, itemdata);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1178 if(text)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1179 g_free(text);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1180 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1181 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1182 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1183 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1184
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1185 static gint _dw_tree_select_event(GtkTreeSelection *sel, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1186 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1187 GtkWidget *item = NULL, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1188 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1189
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1190 if(widget)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1191 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
1192 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1193
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1194 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1195 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1196 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1197 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1198 char *text = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1199 void *itemdata = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1200 GtkTreeModel *store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1201
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1202 if(g_object_get_data(G_OBJECT(widget), "_dw_double_click"))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1203 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1204 g_object_set_data(G_OBJECT(widget), "_dw_double_click", GINT_TO_POINTER(0));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1205 return TRUE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1206 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1207
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1208 if(gtk_tree_selection_get_mode(sel) != GTK_SELECTION_MULTIPLE &&
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1209 gtk_tree_selection_get_selected(sel, NULL, &iter))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1210 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1211 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1212 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1213 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, 2, &itemdata, 3, &item, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1214 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1215 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1216 else if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1217 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1218 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, _DW_DATA_TYPE_POINTER, &itemdata, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1219 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1220 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1224
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1225 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1226 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1227 gint *indices = gtk_tree_path_get_indices(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1228
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1229 if(indices)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1230 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1231 int (*selectfunc)(HWND, int, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1232
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1233 retval = selectfunc(work.window, indices[0], work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1234 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1235 gtk_tree_path_free(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1236 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1237 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1238 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1239 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1240 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1241 GtkTreePath *path;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1242
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243 gtk_tree_view_get_cursor(GTK_TREE_VIEW(widget), &path, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1248 if(gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1249 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1250 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1251 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1252 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, 2, &itemdata, 3, &item, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1253 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1254 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1255 else if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1256 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1257 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, _DW_DATA_TYPE_POINTER, &itemdata, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1258 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1259 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1260 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1261 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1262 gint *indices = gtk_tree_path_get_indices(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1263
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1264 if(indices)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1265 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1266 int (*selectfunc)(HWND, int, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1267
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1268 retval = selectfunc(work.window, indices[0], work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1269 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1270 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1271 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1272 gtk_tree_path_free(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1273 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1274 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1275 if(text)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1276 g_free(text);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1280 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1281
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1282 static gint _dw_tree_expand_event(GtkTreeView *widget, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1283 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
1284 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1285 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1286
2317
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1287 if(work.window)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1288 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1289 int (*treeexpandfunc)(HWND, HTREEITEM, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1290 retval = treeexpandfunc(work.window, (HTREEITEM)iter, work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1291 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1292 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1293 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1294
2309
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1295 static gint _dw_container_enter_event(GtkEventController *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
1297 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1299
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1300 if(work.window && GTK_IS_WIDGET(work.window))
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1301 {
2309
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1302 GtkWidget *user = GTK_WIDGET(g_object_get_data(G_OBJECT(work.window), "_dw_user"));
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1303 GtkWidget *widget = user ? user : work.window;
2278
18028fa53ef2 GTK4: Implement dw_pointer_query_pos(). Fix a macro typo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2277
diff changeset
1304 GdkEvent *event = gtk_event_controller_get_current_event(GTK_EVENT_CONTROLLER(controller));
18028fa53ef2 GTK4: Implement dw_pointer_query_pos(). Fix a macro typo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2277
diff changeset
1305 GdkEventType type = gdk_event_get_event_type(event);
2308
a9018bd91d04 GTK4: Fix DW_SIGNAL_ITEM_ENTER callbacks via the keyboard. Remove mouse
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2306
diff changeset
1306 gint button = (type == GDK_BUTTON_PRESS) ? gdk_button_event_get_button(event) : -1;
a9018bd91d04 GTK4: Fix DW_SIGNAL_ITEM_ENTER callbacks via the keyboard. Remove mouse
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2306
diff changeset
1307
2309
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1308 /* Handle both key and button events together */
2277
ba81894924cb GTK4: Changes to handle the now opaque GdkEvent structure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2276
diff changeset
1309 if((type == GDK_BUTTON_PRESS && button == 1) || keyval == VK_RETURN)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1310 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1311 int (*contextfunc)(HWND, char *, void *, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1312 char *text = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1313 void *data = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1314
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1315 /* Sanity check */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1316 if(GTK_IS_TREE_VIEW(widget))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1317 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1318 GtkTreePath *path;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1319 GtkTreeModel *store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1320
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1321 gtk_tree_view_get_cursor(GTK_TREE_VIEW(widget), &path, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1322 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1323 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1324 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1325
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1326 if(gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1327 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1328 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1329 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1330 gtk_tree_model_get(store, &iter, _DW_DATA_TYPE_STRING, &text, _DW_DATA_TYPE_POINTER, &data, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1331 retval = contextfunc(work.window, text, work.data, data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1332 if(text)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1333 g_free(text);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1334 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1335 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1336 gtk_tree_path_free(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1337 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1338 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1339 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1340 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1341 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1342 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1343
2309
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1344 /* Just forward to the other handler, with bogus key info */
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1345 void _dw_container_enter_mouse(GtkEventController *controller, int n_press, double x, double y, gpointer data)
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1346 {
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1347 if(n_press == 2)
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1348 _dw_container_enter_event(GTK_EVENT_CONTROLLER(controller), 0, 0, 0, data);
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1349 }
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
1350
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1351 /* Return the logical page id from the physical page id */
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1352 int _dw_get_logical_page(HWND handle, unsigned long pageid)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1353 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1354 int z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1355 GtkWidget **pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1356 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1357
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1358 if(pagearray && thispage)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1359 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1360 for(z=0;z<256;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1361 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1362 if(thispage == pagearray[z])
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1363 return z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1364 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1365 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1366 return 256;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1367 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1368
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1369
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1370 static gint _dw_switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1371 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
1372 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1373 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1374
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1375 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1376 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1377 int (*switchpagefunc)(HWND, unsigned long, void *) = work.func;
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1378 retval = switchpagefunc(work.window, _dw_get_logical_page(GTK_WIDGET(notebook), page_num), work.data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1379 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1380 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1381 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1382
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1383 static gint _dw_column_click_event(GtkWidget *widget, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1384 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1385 void **params = data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1386 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1387
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1388 if(params && params[2])
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1389 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1390 GtkWidget *tree = (GtkWidget *)params[2];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1391 gint handlerdata = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tree), "_dw_column_click_id"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1392
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1393 if(handlerdata)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1394 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
1395 DWSignalHandler work;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1396
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1397 params[0] = GINT_TO_POINTER(handlerdata-1);
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
1398 work = _dw_get_signal_handler(params);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1399
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1400 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1401 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1402 int column_num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "_dw_column"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1403 int (*clickcolumnfunc)(HWND, int, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1404 retval = clickcolumnfunc(work.window, column_num, work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1405 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1406 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1407 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1408 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1409 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1410
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
1411 static int _dw_round_value(gfloat val)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1412 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1413 int newval = (int)val;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1414
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1415 if(val >= 0.5 + (gfloat)newval)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1416 newval++;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1417
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1418 return newval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1419 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1420
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1421 static gint _dw_value_changed_event(GtkWidget *widget, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1422 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1423 GtkWidget *slider, *spinbutton, *scrollbar;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1424 GtkAdjustment *adjustment = (GtkAdjustment *)widget;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1425 int max, val;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1426
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1427 if(!GTK_IS_ADJUSTMENT(adjustment))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1428 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(widget), "_dw_adjustment");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1429
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1430 slider = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_slider");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1431 spinbutton = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_spinbutton");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1432 scrollbar = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_scrollbar");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1433
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
1434 max = _dw_round_value(gtk_adjustment_get_upper(adjustment));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
1435 val = _dw_round_value(gtk_adjustment_get_value(adjustment));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1436
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1437 if(g_object_get_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event"))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1438 return FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1439
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1440 if(slider || spinbutton || scrollbar)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1441 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
1442 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1443
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1444 if (work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1445 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1446 int (*valuechangedfunc)(HWND, int, void *) = work.func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1447
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1448 if(slider && gtk_orientable_get_orientation(GTK_ORIENTABLE(slider)) == GTK_ORIENTATION_VERTICAL)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1449 valuechangedfunc(work.window, (max - val) - 1, work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1450 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1451 valuechangedfunc(work.window, val, work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1452 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1453 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1454 return FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1455 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1456
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1457 static gint _dw_default_key_press_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1458 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1459 GtkWidget *next = (GtkWidget *)data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1460
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1461 if(next)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1462 {
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1463 if(keyval == GDK_KEY_Return)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1464 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1465 if(GTK_IS_BUTTON(next))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1466 g_signal_emit_by_name(G_OBJECT(next), "clicked");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1467 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1468 gtk_widget_grab_focus(next);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1469 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1470 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1471 return FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1472 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1473
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1474 static void _dw_dialog_response(GtkDialog *dialog, int response_id, gpointer data)
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1475 {
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1476 DWDialog *dwdialog = (DWDialog *)data;
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1477
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1478 if(dwdialog)
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1479 dw_dialog_dismiss(dwdialog, DW_INT_TO_POINTER(response_id));
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1480 }
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1481
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1482 static GdkPixbuf *_dw_pixbuf_from_resource(unsigned int rid)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1483 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1484 char resource_path[201] = {0};
2319
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
1485
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
1486 snprintf(resource_path, 200, "%s%u.png", _DW_RESOURCE_PATH, rid);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1487 return gdk_pixbuf_new_from_resource(resource_path, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1488 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1489
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1490 static GdkPixbuf *_dw_find_pixbuf(HICN icon, unsigned long *userwidth, unsigned long *userheight)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1491 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1492 unsigned int id = GPOINTER_TO_INT(icon);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1493 GdkPixbuf *icon_pixbuf = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1494
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1495 /* Quick dropout for non-handle */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1496 if(!icon)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1497 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1498
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1499 if(id > 65535)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1500 icon_pixbuf = icon;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1501 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1502 icon_pixbuf = _dw_pixbuf_from_resource(id);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1503
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1504 if(userwidth)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1505 *userwidth = icon_pixbuf ? gdk_pixbuf_get_width(icon_pixbuf) : 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1506 if(userheight)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1507 *userheight = icon_pixbuf ? gdk_pixbuf_get_height(icon_pixbuf) : 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1508
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1509 return icon_pixbuf;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1510 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1511
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1512 /* Handle system notification click callbacks */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1513 static void _dw_notification_handler(GSimpleAction *action, GVariant *param, gpointer user_data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1514 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1515 char textbuf[101] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1516 int (*func)(HWND, void *);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1517 void *data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1518
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1519 snprintf(textbuf, 100, "dw-notification-%llu-func", DW_POINTER_TO_ULONGLONG(g_variant_get_uint64(param)));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1520 func = g_object_get_data(G_OBJECT(_DWApp), textbuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1521 g_object_set_data(G_OBJECT(_DWApp), textbuf, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1522 snprintf(textbuf, 100, "dw-notification-%llu-data", DW_POINTER_TO_ULONGLONG(g_variant_get_uint64(param)));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1523 data = g_object_get_data(G_OBJECT(_DWApp), textbuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1524 g_object_set_data(G_OBJECT(_DWApp), textbuf, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1525
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1526 if(func)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1527 func((HWND)DW_ULONGLONG_TO_POINTER(g_variant_get_uint64(param)), data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1528 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1529
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1530 /* Handle menu click callbacks */
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1531 static void _dw_menu_handler(GSimpleAction *action, GVariant *param, gpointer data)
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1532 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
1533 DWSignalHandler work = _dw_get_signal_handler(data);
2317
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1534 GVariant *action_state = g_action_get_state(G_ACTION(action));
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1535
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1536 /* Handle toggling checkable menu items automatically, before the callback */
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1537 if(action_state)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1538 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1539 gboolean active = g_variant_get_boolean(action_state);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1540 GVariant *new_state = g_variant_new_boolean(!active);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1541 g_simple_action_set_state(action, new_state);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
1542 }
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1543
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1544 if(work.window)
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1545 {
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1546 int (*genericfunc)(HWND, void *) = work.func;
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1547
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1548 genericfunc(work.window, work.data);
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1549 }
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1550 }
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
1551
2276
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1552 /* Internal function to add padding to boxes or other widgets */
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1553 static void _dw_widget_set_pad(GtkWidget *widget, int pad)
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1554 {
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1555 /* Set pad for each margin direction on the widget */
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1556 gtk_widget_set_margin_start(widget, pad);
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1557 gtk_widget_set_margin_end(widget, pad);
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1558 gtk_widget_set_margin_top(widget, pad);
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1559 gtk_widget_set_margin_bottom(widget, pad);
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1560 }
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
1561
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1562 static void _dw_app_activate(GApplication *app, gpointer user_data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1563 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1564 /* Not sure why this signal is required, but GLib gives warnings
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1565 * when this signal is not connected, so putting this here to
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1566 * quell the warning and can be used at a later point if needed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1567 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1568 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1569
2857
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1570 void _dw_init_path(char *arg)
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1571 {
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1572 char path[PATH_MAX+1] = {0};
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1573
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1574 #ifdef __linux__
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1575 if(readlink("/proc/self/exe", path, PATH_MAX) == -1)
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1576 #elif defined(__FreeBSD__)
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1577 int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1578 size_t length = PATH_MAX;
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1579
2858
ecfbc48e933a FreeBSD: Fix the executable path detection code on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2857
diff changeset
1580 if(sysctl(name, 4, path, &length, NULL, 0) == -1 || length <= 1)
2859
b5cd3242b5e7 Solaris: Add platform specific executable path detection.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2858
diff changeset
1581 #elif defined(__sun__)
b5cd3242b5e7 Solaris: Add platform specific executable path detection.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2858
diff changeset
1582 char procpath[101] = {0};
b5cd3242b5e7 Solaris: Add platform specific executable path detection.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2858
diff changeset
1583
2904
2b7babf491e1 Solaris: Fix warning because getpid() returns a long int.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2901
diff changeset
1584 snprintf(procpath, 100, "/proc/%ld/path/a.out", (long)getpid());
2859
b5cd3242b5e7 Solaris: Add platform specific executable path detection.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2858
diff changeset
1585
b5cd3242b5e7 Solaris: Add platform specific executable path detection.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2858
diff changeset
1586 if(readlink(procpath, path, PATH_MAX) == -1)
2857
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1587 #endif
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1588 strncpy(path, arg ? arg : "", PATH_MAX);
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1589
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1590 if(path[0])
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1591 {
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1592 char *pos = strrchr(path, '/');
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1593 char *binname = path;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1594
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1595 /* If we have a / then...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1596 * the binary name should be at the end.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1597 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1598 if(pos)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1599 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1600 binname = pos + 1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1601 *pos = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1602 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1603
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1604 if(*binname)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1605 {
2857
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1606 char *binpos = strstr(path, "/bin");
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1607
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1608 if(binpos)
2857
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1609 strncpy(_dw_share_path, path, (size_t)(binpos - path));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1610 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1611 strcpy(_dw_share_path, "/usr/local");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1612 strcat(_dw_share_path, "/share/");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1613 strcat(_dw_share_path, binname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1614 if(!_dw_app_id[0])
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1615 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1616 /* If we have a binary name, use that for the Application ID instead. */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1617 snprintf(_dw_app_id, _DW_APP_ID_SIZE, "%s.%s", DW_APP_DOMAIN_DEFAULT, binname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1618 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1619 }
2857
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1620 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1621 /* If that failed... just get the current directory */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1622 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1623 _dw_share_path[0] = '/';
2857
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1624 }
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1625
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1626 /*
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1627 * Initializes the Dynamic Windows engine.
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1628 * Parameters:
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1629 * newthread: True if this is the only thread.
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1630 * False if there is already a message loop running.
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1631 */
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1632 int API dw_init(int newthread, int argc, char *argv[])
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1633 {
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1634 /* Setup the private data directory */
59106bf7f9f4 GTK2/3/4: Refactor dw_init(), splitting off path detection into _dw_init_path().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2855
diff changeset
1635 _dw_init_path(argc > 0 ? argv[0] : NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1636
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1637 gtk_init();
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1638
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1639 _DWMainLoop = g_main_loop_new(NULL, FALSE);
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1640 g_main_loop_ref(_DWMainLoop);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1641
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1642 pthread_key_create(&_dw_fg_color_key, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1643 pthread_key_create(&_dw_bg_color_key, NULL);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
1644 pthread_key_create(&_dw_event_key, NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1645
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1646 _dw_init_thread();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1647
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1648 /* Create a global object for glib activities */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1649 _DWObject = g_object_new(G_TYPE_OBJECT, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1650
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1651 if(!_dw_app_id[0])
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1652 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1653 /* Generate an Application ID based on the PID if all else fails. */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1654 snprintf(_dw_app_id, _DW_APP_ID_SIZE, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, (int)getpid());
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1655 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1656
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1657 /* Initialize the application subsystem on supported versions...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1658 * we generate an application ID based on the binary name or PID
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1659 * instead of passing NULL to enable full application support.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1660 */
2860
9daee9d58956 GTK2/3/4: Handle deprecations in GLIB 2.74 and GTK 4.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2859
diff changeset
1661 #if GLIB_CHECK_VERSION(2,74,0)
9daee9d58956 GTK2/3/4: Handle deprecations in GLIB 2.74 and GTK 4.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2859
diff changeset
1662 _DWApp = g_application_new(_dw_app_id, G_APPLICATION_DEFAULT_FLAGS);
9daee9d58956 GTK2/3/4: Handle deprecations in GLIB 2.74 and GTK 4.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2859
diff changeset
1663 #else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1664 _DWApp = g_application_new(_dw_app_id, G_APPLICATION_FLAGS_NONE);
2860
9daee9d58956 GTK2/3/4: Handle deprecations in GLIB 2.74 and GTK 4.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2859
diff changeset
1665 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1666 if(_DWApp && g_application_register(_DWApp, NULL, NULL))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1667 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1668 /* Creat our notification handler for any notifications */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1669 GSimpleAction *action = g_simple_action_new("notification", G_VARIANT_TYPE_UINT64);
2330
58700e9fcba3 GTK3/4: Add call to g_set_prgname() with the Application ID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2329
diff changeset
1670
58700e9fcba3 GTK3/4: Add call to g_set_prgname() with the Application ID.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2329
diff changeset
1671 g_set_prgname(_dw_app_id);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1672 g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(_dw_notification_handler), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1673 g_action_map_add_action(G_ACTION_MAP(_DWApp), G_ACTION(action));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1674 g_signal_connect(_DWApp, "activate", G_CALLBACK(_dw_app_activate), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1675 g_application_activate(_DWApp);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1676 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1677 return TRUE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1678 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1679
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1680 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1681 * Runs a message loop for Dynamic Windows.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1682 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1683 void API dw_main(void)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1684 {
2306
558959a64772 GTK4: Fix thread safety while using dw_main() and fix an status text issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2305
diff changeset
1685 pthread_t orig = _dw_thread;
558959a64772 GTK4: Fix thread safety while using dw_main() and fix an status text issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2305
diff changeset
1686
558959a64772 GTK4: Fix thread safety while using dw_main() and fix an status text issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2305
diff changeset
1687 _dw_thread = pthread_self();
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1688 g_main_loop_run(_DWMainLoop);
2306
558959a64772 GTK4: Fix thread safety while using dw_main() and fix an status text issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2305
diff changeset
1689 _dw_thread = orig;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1690 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1691
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1692 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1693 * Causes running dw_main() to return.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1694 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1695 void API dw_main_quit(void)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1696 {
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1697 g_main_loop_quit(_DWMainLoop);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1698 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1699
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1700 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1701 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1702 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1703 * milliseconds: Number of milliseconds to run the loop for.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1704 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1705 void API dw_main_sleep(int milliseconds)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1706 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1707 struct timeval tv, start;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1708 pthread_t curr = pthread_self();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1709
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1710 gettimeofday(&start, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1711
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1712 if(_dw_thread == (pthread_t)-1 || _dw_thread == curr)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1713 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1714 pthread_t orig = _dw_thread;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1715
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1716 gettimeofday(&tv, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1717
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1718 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1719 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720 if(orig == (pthread_t)-1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 _dw_thread = curr;
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1722 if(curr == _dw_thread && g_main_context_pending(NULL))
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1723 g_main_context_iteration(NULL, FALSE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1724 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1725 _dw_msleep(1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1726 if(orig == (pthread_t)-1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1727 _dw_thread = orig;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1728 gettimeofday(&tv, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1729 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1730 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1731 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1732 _dw_msleep(milliseconds);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1733 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1734
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1735 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1736 * Processes a single message iteration and returns.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1737 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1738 void API dw_main_iteration(void)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1739 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1740 pthread_t orig = _dw_thread;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1741 pthread_t curr = pthread_self();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1742
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1743 if(_dw_thread == (pthread_t)-1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1744 _dw_thread = curr;
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1745 if(curr == _dw_thread && g_main_context_pending(NULL))
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1746 g_main_context_iteration(NULL, FALSE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1747 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748 sched_yield();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1749 if(orig == (pthread_t)-1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1750 _dw_thread = orig;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1751 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1752
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1753 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1754 * Free's memory allocated by dynamic windows.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1755 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1756 * ptr: Pointer to dynamic windows allocated
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1757 * memory to be free()'d.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1758 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
1759 void API dw_free(void *ptr)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1760 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1761 free(ptr);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1762 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1763
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1764 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1765 * Allocates and initializes a dialog struct.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1766 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1767 * data: User defined data to be passed to functions.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1768 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
1769 DWDialog * API dw_dialog_new(void *data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770 {
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1771 DWDialog *tmp = calloc(sizeof(DWDialog), 1);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1772
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1773 if(tmp)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1775 tmp->eve = dw_event_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1776 dw_event_reset(tmp->eve);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1777 tmp->data = data;
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1778 tmp->mainloop = g_main_loop_new(NULL, FALSE);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1779 g_main_loop_ref(tmp->mainloop);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1780 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1781 return tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1782 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1783
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1784 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1785 * Accepts a dialog struct and returns the given data to the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1786 * initial called of dw_dialog_wait().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1787 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789 * result: Data to be returned by dw_dialog_wait().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
1791 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1792 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1793 dialog->result = result;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1794 if(dialog->method)
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1795 g_main_loop_quit(dialog->mainloop);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1796 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797 dw_event_post(dialog->eve);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1798 dialog->done = TRUE;
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1799 return DW_ERROR_NONE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1800 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1801
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1802 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1803 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1804 * called by a signal handler with the given dialog struct.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1805 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1806 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1807 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
1808 void * API dw_dialog_wait(DWDialog *dialog)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1809 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1810 void *tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1811
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1812 if(!dialog)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1813 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1814
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1815 if(_dw_thread == (pthread_t)-1 || pthread_self() == _dw_thread)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1816 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1817 dialog->method = TRUE;
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1818 g_main_loop_run(dialog->mainloop);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1819 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1820 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1821 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1822 dialog->method = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1823 dw_event_wait(dialog->eve, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1824 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1825
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1826 dw_event_close(&dialog->eve);
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
1827 g_main_loop_unref(dialog->mainloop);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1828 tmp = dialog->result;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1829 free(dialog);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1830 return tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1831 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1832
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1833 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1834 * Displays a debug message on the console...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1835 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1836 * format: printf style format string.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 * ...: Additional variables for use in the format.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1839 void API dw_debug(const char *format, ...)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1840 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1841 va_list args;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1842
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1843 va_start(args, format);
2901
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1844 vfprintf(stderr, format, args);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1845 va_end(args);
2901
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1846 }
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1847
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1848 void API dw_vdebug(const char *format, va_list args)
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1849 {
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1850 vfprintf(stderr, format, args);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1851 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1852
3005
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1853 #if GTK_CHECK_VERSION(4,10,0)
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1854 static void _dw_alert_dialog_choose_response(GObject *gobject, GAsyncResult *result, gpointer data)
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1855 {
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1856 DWDialog *tmp = data;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1857 GError *error = NULL;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1858 int retval = gtk_alert_dialog_choose_finish(GTK_ALERT_DIALOG(gobject), result, &error);
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1859
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1860 if(error != NULL)
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1861 {
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1862 retval = -1;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1863 }
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1864 dw_dialog_dismiss(tmp, DW_INT_TO_POINTER(retval));
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1865 }
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1866
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1867 static char *_DW_BUTTON_OK = "Ok";
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1868 static char *_DW_BUTTON_YES = "Yes";
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1869 static char *_DW_BUTTON_NO = "No";
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1870 static char *_DW_BUTTON_CANCEL = "Cancel";
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1871 #endif
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1872
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1873 /* Internal version that does not use variable arguments */
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1874 DW_FUNCTION_DEFINITION(dw_messagebox_int, int, const char *title, int flags, char *outbuf)
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1875 DW_FUNCTION_ADD_PARAM3(title, flags, outbuf)
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1876 DW_FUNCTION_RETURN(dw_messagebox_int, int)
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1877 DW_FUNCTION_RESTORE_PARAM3(title, const char *, flags, int, outbuf, char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1878 {
3005
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1879 int response, retval = DW_MB_RETURN_OK;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1880 DWDialog *tmp = dw_dialog_new(NULL);
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1881 #if GTK_CHECK_VERSION(4,10,0)
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1882 GtkAlertDialog *ad = gtk_alert_dialog_new("%s", title);
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1883 char *buttons[4] = { 0 };
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1884 int button = 0;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1885
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1886 gtk_alert_dialog_set_message(ad, outbuf);
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1887 gtk_alert_dialog_set_modal(ad, TRUE);
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1888
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1889 if(flags & (DW_MB_OK | DW_MB_OKCANCEL))
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1890 buttons[button++] = _DW_BUTTON_OK;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1891 if(flags & (DW_MB_YESNO | DW_MB_YESNOCANCEL))
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1892 buttons[button++] = _DW_BUTTON_YES;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1893 if(flags & (DW_MB_YESNO | DW_MB_YESNOCANCEL))
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1894 buttons[button++] = _DW_BUTTON_NO;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1895 if(flags & (DW_MB_OKCANCEL | DW_MB_YESNOCANCEL))
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1896 buttons[button++] = _DW_BUTTON_CANCEL;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1897 gtk_alert_dialog_set_buttons(ad, (const char * const*)buttons);
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1898
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1899 gtk_alert_dialog_choose(ad, NULL, NULL, (GAsyncReadyCallback)_dw_alert_dialog_choose_response, tmp);
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1900
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1901 response = DW_POINTER_TO_INT(dw_dialog_wait(tmp));
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1902
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1903 if(response < 0 || response >= button || buttons[response] == _DW_BUTTON_OK)
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1904 retval = DW_MB_RETURN_OK;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1905 else if(buttons[response] == _DW_BUTTON_CANCEL)
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1906 retval = DW_MB_RETURN_CANCEL;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1907 else if(buttons[response] == _DW_BUTTON_YES)
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1908 retval = DW_MB_RETURN_YES;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1909 else if(buttons[response] == _DW_BUTTON_NO)
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1910 retval = DW_MB_RETURN_NO;
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1911 #else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1912 GtkMessageType gtkicon = GTK_MESSAGE_OTHER;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1913 GtkButtonsType gtkbuttons = GTK_BUTTONS_OK;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1914 GtkWidget *dialog;
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
1915 ULONG width, height;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1916
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1917 if(flags & DW_MB_ERROR)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1918 gtkicon = GTK_MESSAGE_ERROR;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1919 else if(flags & DW_MB_WARNING)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1920 gtkicon = GTK_MESSAGE_WARNING;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1921 else if(flags & DW_MB_INFORMATION)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1922 gtkicon = GTK_MESSAGE_INFO;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1923 else if(flags & DW_MB_QUESTION)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1924 gtkicon = GTK_MESSAGE_QUESTION;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1925
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1926 if(flags & DW_MB_OKCANCEL)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1927 gtkbuttons = GTK_BUTTONS_OK_CANCEL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1928 else if(flags & (DW_MB_YESNO | DW_MB_YESNOCANCEL))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1929 gtkbuttons = GTK_BUTTONS_YES_NO;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1930
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1931 dialog = gtk_message_dialog_new(NULL,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1932 GTK_DIALOG_USE_HEADER_BAR |
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1933 GTK_DIALOG_MODAL, gtkicon, gtkbuttons, "%s", title);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1934 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", outbuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1935 if(flags & DW_MB_YESNOCANCEL)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1936 gtk_dialog_add_button(GTK_DIALOG(dialog), "Cancel", GTK_RESPONSE_CANCEL);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
1937 gtk_widget_set_visible(GTK_WIDGET(dialog), TRUE);
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
1938 g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(_dw_dialog_response), (gpointer)tmp);
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
1939 /* Center the dialog on the screen since there is no parent */
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
1940 dw_window_get_pos_size((HWND)dialog, NULL, NULL, &width, &height);
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
1941 dw_window_set_pos((HWND)dialog, (dw_screen_width() - width)/2, (dw_screen_height() - height)/2);
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
1942 response = DW_POINTER_TO_INT(dw_dialog_wait(tmp));
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1943 if(GTK_IS_WINDOW(dialog))
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
1944 gtk_window_destroy(GTK_WINDOW(dialog));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1945 switch(response)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1946 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1947 case GTK_RESPONSE_OK:
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1948 retval = DW_MB_RETURN_OK;
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1949 break;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1950 case GTK_RESPONSE_CANCEL:
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1951 retval = DW_MB_RETURN_CANCEL;
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1952 break;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953 case GTK_RESPONSE_YES:
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1954 retval = DW_MB_RETURN_YES;
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1955 break;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1956 case GTK_RESPONSE_NO:
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1957 retval = DW_MB_RETURN_NO;
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1958 break;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1959 default:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1960 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1961 /* Handle the destruction of the dialog result */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1962 if(flags & (DW_MB_OKCANCEL | DW_MB_YESNOCANCEL))
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1963 retval = DW_MB_RETURN_CANCEL;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1964 else if(flags & DW_MB_YESNO)
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1965 retval = DW_MB_RETURN_NO;
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1966 }
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1967 }
3005
522ef24b0aba GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3004
diff changeset
1968 #endif
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1969 DW_FUNCTION_RETURN_THIS(retval);
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1970 }
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1971
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1972 /*
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1973 * Displays a Message Box with given text and title..
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1974 * Parameters:
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1975 * title: The title of the message box.
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1976 * flags: Defines buttons and icons to display
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1977 * format: printf style format string.
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1978 * ...: Additional variables for use in the format.
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1979 */
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1980 int API dw_messagebox(const char *title, int flags, const char *format, ...)
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1981 {
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1982 va_list args;
2901
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1983 int rc;
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1984
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1985 va_start(args, format);
2901
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1986 rc = dw_vmessagebox(title, flags, format, args);
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1987 va_end(args);
2901
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1988 return rc;
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1989 }
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1990
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1991 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args)
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1992 {
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1993 char outbuf[1025] = {0};
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1994
761b7a12b079 Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2860
diff changeset
1995 vsnprintf(outbuf, 1024, format, args);
2327
0d7f8136d771 GTK4: Move dw_messagebox() into thread safety protection using dw_messagebox_int().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2326
diff changeset
1996 return dw_messagebox_int(title, flags, outbuf);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1997 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1998
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1999 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2000 * Minimizes or Iconifies a top-level window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2001 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2002 * handle: The window handle to minimize.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2003 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2004 DW_FUNCTION_DEFINITION(dw_window_minimize, int, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2005 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2006 DW_FUNCTION_RETURN(dw_window_minimize, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2007 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2008 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2009 int retval = DW_ERROR_NONE;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2010
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
2011 if(handle && GTK_IS_WINDOW(handle))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
2012 gtk_window_minimize(GTK_WINDOW(handle));
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2013 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2014 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2015
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2016 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2017 * Makes the window topmost.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2018 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2019 * handle: The window handle to make topmost.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2020 */
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2021 #ifndef GDK_WINDOWING_X11
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
2022 int API dw_window_raise(HWND handle)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 {
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2024 return DW_ERROR_UNKNOWN;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2025 }
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2026 #else
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2027 DW_FUNCTION_DEFINITION(dw_window_raise, int, HWND handle)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2028 DW_FUNCTION_ADD_PARAM1(handle)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2029 DW_FUNCTION_RETURN(dw_window_raise, int)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2030 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2031 {
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2032 int retval = DW_ERROR_UNKNOWN;
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2033 GdkDisplay *display = gdk_display_get_default();
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2034
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2035 if(handle && GTK_IS_WINDOW(handle) && display && GDK_IS_X11_DISPLAY(display))
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2036 {
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2037 GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(handle));
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2038
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2039 if(surface)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2040 {
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2041 XRaiseWindow(GDK_SURFACE_XDISPLAY(surface), GDK_SURFACE_XID(surface));
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2042 retval = DW_ERROR_NONE;
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2043 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2044 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2045 DW_FUNCTION_RETURN_THIS(retval);
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2046 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2047 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2048
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2049 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2050 * Makes the window bottommost.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2051 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2052 * handle: The window handle to make bottommost.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2053 */
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2054 #ifndef GDK_WINDOWING_X11
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
2055 int API dw_window_lower(HWND handle)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2056 {
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2057 return DW_ERROR_UNKNOWN;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2058 }
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2059 #else
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2060 DW_FUNCTION_DEFINITION(dw_window_lower, int, HWND handle)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2061 DW_FUNCTION_ADD_PARAM1(handle)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2062 DW_FUNCTION_RETURN(dw_window_lower, int)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2063 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2064 {
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2065 int retval = DW_ERROR_UNKNOWN;
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2066 GdkDisplay *display = gdk_display_get_default();
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2067
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2068 if(handle && GTK_IS_WINDOW(handle) && display && GDK_IS_X11_DISPLAY(display))
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2069 {
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2070 GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(handle));
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2071
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2072 if(surface)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2073 {
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2074 XLowerWindow(GDK_SURFACE_XDISPLAY(surface), GDK_SURFACE_XID(surface));
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2075 retval = DW_ERROR_NONE;
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2076 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2077 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2078 DW_FUNCTION_RETURN_THIS(retval);
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2079 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
2080 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2081
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2082 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2083 * Makes the window visible.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2084 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2085 * handle: The window handle to make visible.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2086 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2087 DW_FUNCTION_DEFINITION(dw_window_show, int, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2088 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2089 DW_FUNCTION_RETURN(dw_window_show, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2090 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2091 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2092 int retval = DW_ERROR_NONE;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2093
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2094 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2095 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2096 if(GTK_IS_WINDOW(handle))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2097 {
2369
5b3b51ba5239 GTK4: Minor code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2368
diff changeset
2098 GtkWidget *defaultitem = GTK_WIDGET(g_object_get_data(G_OBJECT(handle), "_dw_defaultitem"));
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2099
2368
ec90b552b266 GTK4: Switch to using gtk_window_present() in dw_window_show().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2367
diff changeset
2100 gtk_window_present(GTK_WINDOW(handle));
2369
5b3b51ba5239 GTK4: Minor code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2368
diff changeset
2101
5b3b51ba5239 GTK4: Minor code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2368
diff changeset
2102 if(defaultitem)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2103 gtk_widget_grab_focus(defaultitem);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2104 }
2368
ec90b552b266 GTK4: Switch to using gtk_window_present() in dw_window_show().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2367
diff changeset
2105 else if(GTK_IS_WIDGET(handle))
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2106 gtk_widget_set_visible(handle, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2107 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2108 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2109 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2110
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2111 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2112 * Makes the window invisible.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2113 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2114 * handle: The window handle to make visible.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2115 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2116 DW_FUNCTION_DEFINITION(dw_window_hide, int, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2117 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2118 DW_FUNCTION_RETURN(dw_window_hide, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2119 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2120 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2121 int retval = DW_ERROR_NONE;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2122
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2123 if(handle && GTK_IS_WIDGET(handle))
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2124 gtk_widget_set_visible(handle, FALSE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2125 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2127
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2128 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2129 * Destroys a window and all of it's children.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2130 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2131 * handle: The window handle to destroy.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2133 DW_FUNCTION_DEFINITION(dw_window_destroy, int, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2134 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2135 DW_FUNCTION_RETURN(dw_window_destroy, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2136 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2137 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2138 int retval = DW_ERROR_NONE;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2139
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2140 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2141 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2142 if(GTK_IS_WINDOW(handle))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2143 gtk_window_destroy(GTK_WINDOW(handle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2144 else if(GTK_IS_WIDGET(handle))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2145 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2146 GtkWidget *box, *handle2 = handle;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2147
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2148 /* Check if we are removing a widget from a box */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2149 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2150 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2151 /* Get the number of items in the box... */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2152 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2153 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2154 int z;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2155
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2156 /* Figure out where in the grid this widget is and remove that row/column */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2157 if(boxtype == DW_VERT)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2158 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2159 for(z=0;z<boxcount;z++)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2160 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2161 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2162 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2163 gtk_grid_remove_row(GTK_GRID(box), z);
2329
47f8f950f377 GTK4: Fix crash by stopping processing after removing widget from the box.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2328
diff changeset
2164 handle2 = NULL;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2165 break;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2166 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2167 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2168 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2169 else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2170 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2171 for(z=0;z<boxcount;z++)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2172 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2173 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2174 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2175 gtk_grid_remove_column(GTK_GRID(box), z);
2329
47f8f950f377 GTK4: Fix crash by stopping processing after removing widget from the box.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2328
diff changeset
2176 handle2 = NULL;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2177 break;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2178 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2179 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2180 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2181
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2182 if(boxcount > 0)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2183 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2184 /* Decrease the count by 1 */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2185 boxcount--;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2186 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2187 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2188 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2189 /* Finally destroy the widget, make sure it is still
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2190 * a valid widget if it got removed from the grid.
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2191 */
2329
47f8f950f377 GTK4: Fix crash by stopping processing after removing widget from the box.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2328
diff changeset
2192 if(handle2 && GTK_IS_WIDGET(handle2))
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2193 g_object_unref(G_OBJECT(handle2));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2194 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2195 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2196 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2197 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2198
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2199 /* Causes entire window to be invalidated and redrawn.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2200 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2201 * handle: Toplevel window handle to be redrawn.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2202 */
2328
5363f953b22a GTK4: Implement dw_window_redraw() for render/drawing area widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2327
diff changeset
2203 DW_FUNCTION_DEFINITION(dw_window_redraw, void, HWND handle)
5363f953b22a GTK4: Implement dw_window_redraw() for render/drawing area widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2327
diff changeset
2204 DW_FUNCTION_ADD_PARAM1(handle)
5363f953b22a GTK4: Implement dw_window_redraw() for render/drawing area widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2327
diff changeset
2205 DW_FUNCTION_NO_RETURN(dw_window_redraw)
5363f953b22a GTK4: Implement dw_window_redraw() for render/drawing area widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2327
diff changeset
2206 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
5363f953b22a GTK4: Implement dw_window_redraw() for render/drawing area widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2327
diff changeset
2207 {
5363f953b22a GTK4: Implement dw_window_redraw() for render/drawing area widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2327
diff changeset
2208 if(handle && GTK_IS_DRAWING_AREA(handle))
5363f953b22a GTK4: Implement dw_window_redraw() for render/drawing area widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2327
diff changeset
2209 gtk_widget_queue_draw(GTK_WIDGET(handle));
5363f953b22a GTK4: Implement dw_window_redraw() for render/drawing area widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2327
diff changeset
2210 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2211 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2212
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2213 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2214 * Changes a window's parent to newparent.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2215 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2216 * handle: The window handle to destroy.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2217 * newparent: The window's new parent window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2218 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2219 DW_FUNCTION_DEFINITION(dw_window_reparent, void, HWND handle, HWND newparent)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2220 DW_FUNCTION_ADD_PARAM2(handle, newparent)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2221 DW_FUNCTION_NO_RETURN(dw_window_reparent)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2222 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, newparent, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2223 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2224 if(handle && GTK_IS_WIDGET(handle) && newparent && GTK_IS_WIDGET(newparent))
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2225 gtk_widget_set_parent(GTK_WIDGET(handle), GTK_WIDGET(newparent));
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2226 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2227 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230 * Sets the default font used on text based widgets.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2231 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2232 * fontname: Font name in Dynamic Windows format.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2233 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2234 void API dw_font_set_default(const char *fontname)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2235 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2236 char *oldfont = _DWDefaultFont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2237
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2238 _DWDefaultFont = strdup(fontname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2239
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2240 if(oldfont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2241 free(oldfont);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2242 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2243
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2244 /* Convert DW style font to CSS syntax (or Pango for older versions):
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2245 * font: font-style font-variant font-weight font-size/line-height font-family
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2246 */
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
2247 char *_dw_convert_font(const char *font)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2248 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2249 char *newfont = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2250
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2251 if(font)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2253 char *name = strchr(font, '.');
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2254 char *Italic = strstr(font, " Italic");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2255 char *Bold = strstr(font, " Bold");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2256
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2257 /* Detect Dynamic Windows style font name...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2258 * Format: ##.Fontname
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2259 * and convert to CSS or Pango syntax
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2260 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2261 if(name && (name++) && isdigit(*font))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2262 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2263 int size = atoi(font);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2264 int len = (Italic ? (Bold ? (Italic > Bold ? (Bold - name) : (Italic - name)) : (Italic - name)) : (Bold ? (Bold - name) : strlen(name)));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2265 char *newname = alloca(len+1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2266
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2267 memset(newname, 0, len+1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2268 strncpy(newname, name, len);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2269
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2270 newfont = g_strdup_printf("%s normal %s %dpx \"%s\"", Italic ? "italic" : "normal",
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2271 Bold ? "bold" : "normal", size, newname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2272 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2273 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274 return newfont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2275 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2276
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2277 /* Internal functions to convert to GTK3 style CSS */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2278 static void _dw_override_color(GtkWidget *widget, const char *element, GdkRGBA *color)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2279 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2280 gchar *dataname = g_strdup_printf ("_dw_color_%s", element);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2281 GtkCssProvider *provider = g_object_get_data(G_OBJECT(widget), dataname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2282 GtkStyleContext *scontext = gtk_widget_get_style_context(widget);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2283
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2284 /* If we have an old context from a previous override remove it */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2285 if(provider)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2286 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2287 gtk_style_context_remove_provider(scontext, GTK_STYLE_PROVIDER(provider));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2288 g_object_unref(provider);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2289 provider = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2290 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2291
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2292 /* If we have a new color, create a new provider and add it */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2293 if(color)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2294 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2295 gchar *scolor = gdk_rgba_to_string(color);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2296 gchar *css = g_strdup_printf ("* { %s: %s; }", element, scolor);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2297
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298 provider = gtk_css_provider_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 g_free(scolor);
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2300 gtk_css_provider_load_from_data(provider, css, -1);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301 g_free(css);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302 gtk_style_context_add_provider(scontext, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 g_object_set_data(G_OBJECT(widget), dataname, (gpointer)provider);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 g_free(dataname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2306 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308 static void _dw_override_font(GtkWidget *widget, const char *font)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2310 GtkCssProvider *provider = g_object_get_data(G_OBJECT(widget), "_dw_font");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311 GtkStyleContext *scontext = gtk_widget_get_style_context(widget);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2312
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2313 /* If we have an old context from a previous override remove it */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2314 if(provider)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2315 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2316 gtk_style_context_remove_provider(scontext, GTK_STYLE_PROVIDER(provider));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2317 g_object_unref(provider);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2318 provider = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2319 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2320
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2321 /* If we have a new font, create a new provider and add it */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2322 if(font)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2323 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2324 gchar *css = g_strdup_printf ("* { font: %s; }", font);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2325
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2326 provider = gtk_css_provider_new();
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2327 gtk_css_provider_load_from_data(provider, css, -1);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 g_free(css);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329 gtk_style_context_add_provider(scontext, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2330 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 g_object_set_data(G_OBJECT(widget), "_dw_font", (gpointer)provider);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2334 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335 * Sets the font used by a specified window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2336 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 * handle: The window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2338 * fontname: Name and size of the font in the form "size.fontname"
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2340 DW_FUNCTION_DEFINITION(dw_window_set_font, int, HWND handle, const char *fontname)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2341 DW_FUNCTION_ADD_PARAM2(handle, fontname)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2342 DW_FUNCTION_RETURN(dw_window_set_font, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2343 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, fontname, const char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2344 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345 GtkWidget *handle2 = handle;
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
2346 char *font = _dw_convert_font(fontname);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347 gpointer data;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2348 int retval = DW_ERROR_NONE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2349
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2350 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2351 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2352 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2353 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2354 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2355 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2356 /* If it is a groupox we want to operate on the frame label */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2357 else if(GTK_IS_FRAME(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2358 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2359 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2361 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2362 }
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2363 else if(GTK_IS_COMBO_BOX(handle))
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2364 {
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2365 GtkWidget *tmp = gtk_combo_box_get_child(GTK_COMBO_BOX(handle));
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2366 if(tmp)
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2367 handle2 = tmp;
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2368 }
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2369 else if(GTK_IS_BUTTON(handle))
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2370 {
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2371 GtkWidget *tmp = gtk_button_get_child(GTK_BUTTON(handle));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2372 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2373 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2374 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2375
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2376 /* Free old font name if one is allocated */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2377 data = g_object_get_data(G_OBJECT(handle2), "_dw_fontname");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2378 g_object_set_data(G_OBJECT(handle2), "_dw_fontname", (gpointer)font);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2379 if(data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2380 free(data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2381
2325
55524dbe6a54 GTK4: The font crash seems to affect GtkDrawingArea. So reenable the widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2324
diff changeset
2382 if(!GTK_IS_DRAWING_AREA(handle2))
55524dbe6a54 GTK4: The font crash seems to affect GtkDrawingArea. So reenable the widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2324
diff changeset
2383 _dw_override_font(handle2, font);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2384
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2385 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2386 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2387
3003
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2388 /* Internal function to convert from a pango font description to Dynamic Windows style font string */
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2389 char *_dw_font_from_pango_font_description(PangoFontDescription *pfont)
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2390 {
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2391 char *retfont = NULL;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2392
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2393 if(pfont)
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2394 {
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2395 char *font = pango_font_description_to_string(pfont);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2396 int len, x;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2397
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2398 retfont = strdup(font);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2399 len = strlen(font);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2400
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2401 /* Convert to Dynamic Windows format if we can... */
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2402 if(len > 0 && isdigit(font[len-1]))
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2403 {
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2404 int size;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2405
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2406 x=len-1;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2407 while(x > 0 && font[x] != ' ')
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2408 {
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2409 x--;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2410 }
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2411 size = atoi(&font[x]);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2412 /* If we were able to find a valid size... */
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2413 if(size > 0)
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2414 {
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2415 /* Null terminate after the name...
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2416 * and create the Dynamic Windows style font.
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2417 */
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2418 font[x] = 0;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2419 snprintf(retfont, len+1, "%d.%s", size, font);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2420 }
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2421 }
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2422 g_free(font);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2423 }
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2424 return retfont;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2425 }
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2426
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2427 #if GTK_CHECK_VERSION(4,10,0)
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2428 static void _dw_font_choose_response(GObject *gobject, GAsyncResult *result, gpointer data)
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2429 {
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2430 DWDialog *tmp = data;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2431 GError *error = NULL;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2432 char *fontname = NULL;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2433 PangoFontDescription *pfd = gtk_font_dialog_choose_font_finish(GTK_FONT_DIALOG(gobject), result, &error);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2434
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2435 if(error == NULL && pfd != NULL)
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2436 {
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2437 fontname = _dw_font_from_pango_font_description(pfd);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2438 pango_font_description_free(pfd);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2439 }
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2440 dw_dialog_dismiss(tmp, fontname);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2441 }
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2442 #endif
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2443
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2444 /* Allows the user to choose a font using the system's font chooser dialog.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2445 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2446 * currfont: current font
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2447 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2448 * A malloced buffer with the selected font or NULL on error.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2449 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2450 DW_FUNCTION_DEFINITION(dw_font_choose, char *, const char *currfont)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2451 DW_FUNCTION_ADD_PARAM1(currfont)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2452 DW_FUNCTION_RETURN(dw_font_choose, char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2453 DW_FUNCTION_RESTORE_PARAM1(currfont, const char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2454 {
3003
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2455 char *retfont = NULL;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2456 DWDialog *tmp = dw_dialog_new(NULL);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2457 #if GTK_CHECK_VERSION(4,10,0)
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2458 char *font = _dw_convert_font(currfont);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2459 PangoFontDescription *pfd = font ? pango_font_description_from_string(font) : NULL;
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2460 GtkFontDialog *fd = gtk_font_dialog_new();
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2461
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2462 gtk_font_dialog_choose_font(fd, NULL, pfd, NULL, (GAsyncReadyCallback)_dw_font_choose_response, tmp);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2463
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2464 retfont = dw_dialog_wait(tmp);
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2465 #else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2466 char *font = currfont ? strdup(currfont) : NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2467 char *name = font ? strchr(font, '.') : NULL;
3003
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2468 GtkFontChooser *fd;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2469
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2470 /* Detect Dynamic Windows style font name...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2471 * Format: ##.Fontname
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2472 * and convert to a Pango name
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 if(name && isdigit(*font))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 int size = atoi(font);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2477 *name = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478 name++;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 sprintf(font, "%s %d", name, size);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2480 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2481
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2482 fd = (GtkFontChooser *)gtk_font_chooser_dialog_new("Choose font", NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483 if(font)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2484 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2485 gtk_font_chooser_set_font(fd, font);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2486 free(font);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2487 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2488
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2489 gtk_widget_set_visible(GTK_WIDGET(fd), TRUE);
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
2490 g_signal_connect(G_OBJECT(fd), "response", G_CALLBACK(_dw_dialog_response), (gpointer)tmp);
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
2491
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
2492 if(DW_POINTER_TO_INT(dw_dialog_wait(tmp)) == GTK_RESPONSE_OK)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2493 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2494 char *fontname = gtk_font_chooser_get_font(fd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2495 if(fontname && (retfont = strdup(fontname)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2496 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2497 int len = strlen(fontname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2498 /* Convert to Dynamic Windows format if we can... */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2499 if(len > 0 && isdigit(fontname[len-1]))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2500 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2501 int size, x=len-1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2502
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2503 while(x > 0 && fontname[x] != ' ')
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2504 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2505 x--;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2506 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2507 size = atoi(&fontname[x]);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2508 /* If we were able to find a valid size... */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2509 if(size > 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2510 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2511 /* Null terminate after the name...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2512 * and create the Dynamic Windows style font.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2513 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2514 fontname[x] = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2515 snprintf(retfont, len+1, "%d.%s", size, fontname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2516 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2517 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2518 g_free(fontname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2519 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2520 }
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
2521 if(GTK_IS_WINDOW(fd))
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
2522 gtk_window_destroy(GTK_WINDOW(fd));
3003
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2523 #endif
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2524 DW_FUNCTION_RETURN_THIS(retfont);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2525 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2526
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2527 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2528 * Gets the font used by a specified window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2529 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2530 * handle: The window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2531 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2532 DW_FUNCTION_DEFINITION(dw_window_get_font, char *, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2533 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2534 DW_FUNCTION_RETURN(dw_window_get_font, char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2535 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2536 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2537 PangoFontDescription *pfont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2538 PangoContext *pcontext;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2539 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2540 char *font;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2541 char *retfont=NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2542
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2543 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2544 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2545 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2546 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2547 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2548 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2549 /* If it is a groupox we want to operate on the frame label */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2550 else if(GTK_IS_FRAME(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2551 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2552 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2553 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2554 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2555 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2556
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
2557 pcontext = gtk_widget_get_pango_context(handle2);
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
2558 if(pcontext)
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
2559 {
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
2560 pfont = pango_context_get_font_description(pcontext);
3003
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
2561 retfont = _dw_font_from_pango_font_description(pfont);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2562 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2563 DW_FUNCTION_RETURN_THIS(retfont);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2564 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2565
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2566 void _dw_free_gdk_colors(HWND handle)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2567 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2568 GdkRGBA *old = (GdkRGBA *)g_object_get_data(G_OBJECT(handle), "_dw_foregdk");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2569
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2570 if(old)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2571 free(old);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2572
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2573 old = (GdkRGBA *)g_object_get_data(G_OBJECT(handle), "_dw_backgdk");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2574
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2575 if(old)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2576 free(old);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2578
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2579 /* Free old color pointers and allocate new ones */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2580 static void _dw_save_gdk_colors(HWND handle, GdkRGBA fore, GdkRGBA back)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582 GdkRGBA *foregdk = malloc(sizeof(GdkRGBA));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2583 GdkRGBA *backgdk = malloc(sizeof(GdkRGBA));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2585 _dw_free_gdk_colors(handle);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2586
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2587 *foregdk = fore;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2588 *backgdk = back;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2589
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2590 g_object_set_data(G_OBJECT(handle), "_dw_foregdk", (gpointer)foregdk);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2591 g_object_set_data(G_OBJECT(handle), "_dw_backgdk", (gpointer)backgdk);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2592 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2593
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2594 static int _dw_set_color(HWND handle, unsigned long fore, unsigned long back)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2595 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 /* Remember that each color component in X11 use 16 bit no matter
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2597 * what the destination display supports. (and thus GDK)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 GdkRGBA forecolor = {0}, backcolor = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601 if(fore & DW_RGB_COLOR)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2602 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603 forecolor.alpha = 1.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2604 forecolor.red = (gdouble)DW_RED_VALUE(fore) / 255.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2605 forecolor.green = (gdouble)DW_GREEN_VALUE(fore) / 255.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2606 forecolor.blue = (gdouble)DW_BLUE_VALUE(fore) / 255.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2607 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2608 else if(fore != DW_CLR_DEFAULT)
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
2609 forecolor = _dw_colors[fore];
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2610
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 _dw_override_color(handle, "color", fore != DW_CLR_DEFAULT ? &forecolor : NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2613 if(back & DW_RGB_COLOR)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615 backcolor.alpha = 1.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616 backcolor.red = (gdouble)DW_RED_VALUE(back) / 255.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2617 backcolor.green = (gdouble)DW_GREEN_VALUE(back) / 255.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2618 backcolor.blue = (gdouble)DW_BLUE_VALUE(back) / 255.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2619 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2620 else if(back != DW_CLR_DEFAULT)
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
2621 backcolor = _dw_colors[back];
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2622
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2623 _dw_override_color(handle, "background-color", back != DW_CLR_DEFAULT ? &backcolor : NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2624
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2625 _dw_save_gdk_colors(handle, forecolor, backcolor);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2626
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627 return TRUE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2630 * Sets the colors used by a specified window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2632 * handle: The window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2633 * fore: Foreground color in RGB format.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 * back: Background color in RGB format.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2635 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2636 DW_FUNCTION_DEFINITION(dw_window_set_color, int, HWND handle, unsigned long fore, unsigned long back)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2637 DW_FUNCTION_ADD_PARAM3(handle, fore, back)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2638 DW_FUNCTION_RETURN(dw_window_set_color, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2639 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, fore, unsigned long, back, unsigned long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2640 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2641 GtkWidget *handle2 = handle;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2642 int retval = DW_ERROR_NONE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2643
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2644 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2645 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2646 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2647 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2648 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2649 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2650
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2651 _dw_set_color(handle2, fore, back);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2652
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2653 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2654 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2655
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2656 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2657 * Sets the font used by a specified window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2658 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2659 * handle: The window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2660 * border: Size of the window border in pixels.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2661 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
2662 int API dw_window_set_border(HWND handle, int border)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2663 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2664 /* TODO */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2665 return 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2666 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2667
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2668 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2669 * Changes the appearance of the mouse pointer.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2670 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2671 * handle: Handle to widget for which to change.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2672 * cursortype: ID of the pointer you want.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2673 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2674 DW_FUNCTION_DEFINITION(dw_window_set_pointer, void, HWND handle, int pointertype)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2675 DW_FUNCTION_ADD_PARAM2(handle, pointertype)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2676 DW_FUNCTION_NO_RETURN(dw_window_set_pointer)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2677 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, pointertype, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2678 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2679 if(pointertype > 65535)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2680 {
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2681 GdkPixbuf *pixbuf = _dw_find_pixbuf(GINT_TO_POINTER(pointertype), NULL, NULL);
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2682 GdkCursor *cursor = gdk_cursor_new_from_texture(gdk_texture_new_for_pixbuf(pixbuf), 0, 0, NULL);
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2683 if(cursor)
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2684 gtk_widget_set_cursor(GTK_WIDGET(handle), cursor);
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2685 }
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2686 if(pointertype == DW_POINTER_ARROW)
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2687 gtk_widget_set_cursor_from_name(GTK_WIDGET(handle), "default");
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2688 else if(pointertype == DW_POINTER_CLOCK)
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2689 gtk_widget_set_cursor_from_name(GTK_WIDGET(handle), "wait");
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2690 else if(pointertype == DW_POINTER_QUESTION)
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2691 gtk_widget_set_cursor_from_name(GTK_WIDGET(handle), "help");
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2692 else
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2693 gtk_widget_set_cursor(GTK_WIDGET(handle), NULL);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2694 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2695 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2696
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2697 /*
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2698 * Captures the mouse input to this window.
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2699 * Parameters:
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2700 * handle: Handle to receive mouse input.
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2701 */
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2702 #ifndef GDK_WINDOWING_X11
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
2703 void API dw_window_capture(HWND handle)
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2704 {
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2705 }
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2706 #else
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2707 static Display *_DWXGrabbedDisplay = NULL;
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2708
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2709 DW_FUNCTION_DEFINITION(dw_window_capture, void, HWND handle)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2710 DW_FUNCTION_ADD_PARAM1(handle)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2711 DW_FUNCTION_NO_RETURN(dw_window_capture)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2712 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2713 {
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2714 GdkDisplay *display = gdk_display_get_default();
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2715
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2716 if(_DWXGrabbedDisplay == NULL && handle && GTK_IS_WINDOW(handle) && display && GDK_IS_X11_DISPLAY(display))
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2717 {
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2718 GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(handle));
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2719
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2720 if(surface)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2721 {
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2722 if(XGrabPointer(GDK_SURFACE_XDISPLAY(surface), GDK_SURFACE_XID(surface), FALSE,
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2723 ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask,
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2724 GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == GrabSuccess)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2725 _DWXGrabbedDisplay = GDK_SURFACE_XDISPLAY(surface);
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2726
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2727 }
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2728 }
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2729 DW_FUNCTION_RETURN_NOTHING;
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2730 }
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2731 #endif
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2732
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2733 /*
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2734 * Releases previous mouse capture.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2735 */
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2736 #ifndef GDK_WINDOWING_X11
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
2737 void API dw_window_release(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2738 {
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2739 }
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2740 #else
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2741 DW_FUNCTION_DEFINITION(dw_window_release, void)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2742 DW_FUNCTION_ADD_PARAM
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2743 DW_FUNCTION_NO_RETURN(dw_window_release)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2744 {
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
2745 /* Don't need X11 test, _DWXGrabbedDisplay won't get set unless X11 */
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2746 if(_DWXGrabbedDisplay)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2747 {
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2748 XUngrabPointer(_DWXGrabbedDisplay, CurrentTime);
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2749 _DWXGrabbedDisplay = NULL;
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2750 }
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2751 DW_FUNCTION_RETURN_NOTHING;
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2752 }
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
2753 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2754
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2755 /* Window creation flags that will cause the window to have decorations */
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2756 #define _DW_DECORATION_FLAGS (DW_FCF_CLOSEBUTTON|DW_FCF_SYSMENU|DW_FCF_TITLEBAR|DW_FCF_MINMAX|DW_FCF_SIZEBORDER|DW_FCF_BORDER|DW_FCF_DLGBORDER)
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2757
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2758 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2759 * Create a new Window Frame.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2760 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2761 * owner: The Owner's window handle or HWND_DESKTOP.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2762 * title: The Window title.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2763 * flStyle: Style flags, see the PM reference.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2764 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2765 DW_FUNCTION_DEFINITION(dw_window_new, HWND, DW_UNUSED(HWND hwndOwner), const char *title, ULONG flStyle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2766 DW_FUNCTION_ADD_PARAM3(hwndOwner, title, flStyle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2767 DW_FUNCTION_RETURN(dw_window_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2768 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(hwndOwner), HWND, title, char *, flStyle, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2769 {
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2770 GtkWidget *box = dw_box_new(DW_VERT, 0);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2771 GtkWidget *grid = gtk_grid_new();
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2772 GtkWidget *tmp = gtk_window_new();
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2773
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2774 gtk_widget_set_visible(grid, TRUE);
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2775
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2776 /* Handle the window style flags */
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2777 gtk_window_set_title(GTK_WINDOW(tmp), title);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2778 gtk_window_set_resizable(GTK_WINDOW(tmp), (flStyle & DW_FCF_SIZEBORDER) ? TRUE : FALSE);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2779 /* Either the CLOSEBUTTON or SYSMENU flags should make it deletable */
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2780 gtk_window_set_deletable(GTK_WINDOW(tmp), (flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU)) ? TRUE : FALSE);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2781 gtk_window_set_decorated(GTK_WINDOW(tmp), (flStyle & _DW_DECORATION_FLAGS) ? TRUE : FALSE);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2782
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2783 gtk_widget_realize(tmp);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2784
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2785 if(flStyle & DW_FCF_FULLSCREEN)
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2786 gtk_window_fullscreen(GTK_WINDOW(tmp));
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2787 else
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2788 {
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2789 if(flStyle & DW_FCF_MAXIMIZE)
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2790 gtk_window_maximize(GTK_WINDOW(tmp));
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2791
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2792 if(flStyle & DW_FCF_MINIMIZE)
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2793 gtk_window_minimize(GTK_WINDOW(tmp));
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2794 }
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2795
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2796 gtk_grid_attach(GTK_GRID(grid), box, 0, 1, 1, 1);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2797 gtk_window_set_child(GTK_WINDOW(tmp), grid);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2798 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
2799 g_object_set_data(G_OBJECT(tmp), "_dw_grid", (gpointer)grid);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 g_object_set_data(G_OBJECT(tmp), "_dw_style", GINT_TO_POINTER(flStyle));
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2801 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 * Create a new Box to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 * pad: Number of pixels to pad around the box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
2810 DW_FUNCTION_DEFINITION(dw_box_new, HWND, int type, int pad)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
2811 DW_FUNCTION_ADD_PARAM2(type, pad)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
2812 DW_FUNCTION_RETURN(dw_box_new, HWND)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
2813 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
2814 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
2815 GtkWidget *tmp = gtk_grid_new();
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816 g_object_set_data(G_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type));
2276
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
2817 _dw_widget_set_pad(tmp, pad);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2818 gtk_widget_set_visible(tmp, TRUE);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
2819 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2820 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2821
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2822 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2823 * Create a new scrollable Box to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2824 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2825 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2826 * pad: Number of pixels to pad around the box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2827 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2828 DW_FUNCTION_DEFINITION(dw_scrollbox_new, HWND, int type, int pad)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2829 DW_FUNCTION_ADD_PARAM2(type, pad)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2830 DW_FUNCTION_RETURN(dw_scrollbox_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2831 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int)
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2832 {
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2833 GtkWidget *tmp, *box;
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2834
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2835 tmp = gtk_scrolled_window_new();
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2836 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tmp), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838 box = gtk_grid_new();
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2839
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2840 g_object_set_data(G_OBJECT(box), "_dw_boxtype", GINT_TO_POINTER(type));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box);
2276
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
2842 _dw_widget_set_pad(box, pad);
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
2843
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2844 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(tmp), box);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 g_object_set_data(G_OBJECT(tmp), "_dw_user", box);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2846 gtk_widget_set_visible(box, TRUE);
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2847 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2848
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2849 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2850 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2851
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2852 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2853 * Returns the position of the scrollbar in the scrollbox
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2854 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2855 * handle: Handle to the scrollbox to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2856 * orient: The vertical or horizontal scrollbar.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2857 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2858 DW_FUNCTION_DEFINITION(dw_scrollbox_get_pos, int, HWND handle, int orient)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2859 DW_FUNCTION_ADD_PARAM2(handle, orient)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2860 DW_FUNCTION_RETURN(dw_scrollbox_get_pos, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2861 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, orient, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2862 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2863 int val = DW_ERROR_UNKNOWN;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2864 GtkAdjustment *adjustment;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2865
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2866 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2867 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2868 if(orient == DW_HORZ)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2869 adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(handle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2870 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2871 adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2872 if(adjustment)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2873 val = _dw_round_value(gtk_adjustment_get_value(adjustment));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2874 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2875 DW_FUNCTION_RETURN_THIS(val);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2877
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2878 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2879 * Gets the range for the scrollbar in the scrollbox.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2880 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2881 * handle: Handle to the scrollbox to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2882 * orient: The vertical or horizontal scrollbar.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2883 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2884 DW_FUNCTION_DEFINITION(dw_scrollbox_get_range, int, HWND handle, int orient)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2885 DW_FUNCTION_ADD_PARAM2(handle, orient)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2886 DW_FUNCTION_RETURN(dw_scrollbox_get_range, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2887 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, orient, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2888 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2889 int range = DW_ERROR_UNKNOWN;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2890 GtkAdjustment *adjustment;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2891
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2892 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2893 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2894 if(orient == DW_HORZ)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2895 adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(handle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2896 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2897 adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2898 if(adjustment)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2899 range = _dw_round_value(gtk_adjustment_get_upper(adjustment));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2900 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2901 DW_FUNCTION_RETURN_THIS(range);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2902 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2903
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2904 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2905 * Create a new Group Box to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2906 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2907 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2908 * pad: Number of pixels to pad around the box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2909 * title: Text to be displayined in the group outline.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2910 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2911 DW_FUNCTION_DEFINITION(dw_groupbox_new, HWND, int type, int pad, const char *title)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2912 DW_FUNCTION_ADD_PARAM3(type, pad, title)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2913 DW_FUNCTION_RETURN(dw_groupbox_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2914 DW_FUNCTION_RESTORE_PARAM3(type, int, pad, int, title, const char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2915 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2916 GtkWidget *tmp, *frame = gtk_frame_new(NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2917 gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL);
2276
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
2918
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2919 tmp = gtk_grid_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2920 g_object_set_data(G_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2921 g_object_set_data(G_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp);
2276
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
2922 _dw_widget_set_pad(tmp, pad);
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
2923 gtk_frame_set_child(GTK_FRAME(frame), tmp);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2924 gtk_widget_set_visible(tmp, TRUE);
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2925 gtk_widget_set_visible(frame, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2926 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2927 dw_window_set_font(frame, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2928 DW_FUNCTION_RETURN_THIS(frame);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2929 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2930
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2931 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2932 * Create a bitmap object to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2933 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2934 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2935 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2936 DW_FUNCTION_DEFINITION(dw_bitmap_new, HWND, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2937 DW_FUNCTION_ADD_PARAM1(cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2938 DW_FUNCTION_RETURN(dw_bitmap_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2939 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2940 {
2366
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
2941 GtkWidget *tmp = gtk_picture_new();
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
2942 gtk_picture_set_can_shrink(GTK_PICTURE(tmp), TRUE);
2860
9daee9d58956 GTK2/3/4: Handle deprecations in GLIB 2.74 and GTK 4.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2859
diff changeset
2943 #if GTK_CHECK_VERSION(4,8,0)
9daee9d58956 GTK2/3/4: Handle deprecations in GLIB 2.74 and GTK 4.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2859
diff changeset
2944 gtk_picture_set_content_fit(GTK_PICTURE(tmp), GTK_CONTENT_FIT_CONTAIN);
9daee9d58956 GTK2/3/4: Handle deprecations in GLIB 2.74 and GTK 4.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2859
diff changeset
2945 #else
2367
0f340646a2ca GTK4: GtkPictures should be centered, not filled... don't clobber the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2366
diff changeset
2946 gtk_picture_set_keep_aspect_ratio(GTK_PICTURE(tmp), TRUE);
2860
9daee9d58956 GTK2/3/4: Handle deprecations in GLIB 2.74 and GTK 4.8.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2859
diff changeset
2947 #endif
2367
0f340646a2ca GTK4: GtkPictures should be centered, not filled... don't clobber the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2366
diff changeset
2948 gtk_widget_set_halign(GTK_WIDGET(tmp), GTK_ALIGN_CENTER);
0f340646a2ca GTK4: GtkPictures should be centered, not filled... don't clobber the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2366
diff changeset
2949 gtk_widget_set_valign(GTK_WIDGET(tmp), GTK_ALIGN_CENTER);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2950 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2951 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2952 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2953 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2954
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2955 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2956 * Create a notebook object to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2957 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2958 * id: An ID to be used for getting the resource from the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2959 * resource file.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2960 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2961 DW_FUNCTION_DEFINITION(dw_notebook_new, HWND, ULONG cid, int top)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2962 DW_FUNCTION_ADD_PARAM2(cid, top)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2963 DW_FUNCTION_RETURN(dw_notebook_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2964 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, top, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2965 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2966 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2967
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2968 tmp = gtk_notebook_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2969 if(top)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2970 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2971 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2972 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_BOTTOM);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2973 gtk_notebook_set_scrollable(GTK_NOTEBOOK(tmp), TRUE);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
2974 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2975 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2976 g_object_set_data(G_OBJECT(tmp), "_dw_pagearray", (gpointer)pagearray);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
2977 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2978 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2979
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2980 static unsigned int _dw_menugroup = 0;
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2981
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2982 /* Recurse into a menu setting the action groups on the menuparent widget */
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2983 void _dw_menu_set_group_recursive(HMENUI start, GtkWidget *menuparent)
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2984 {
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2985 int z, submenucount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(start), "_dw_submenucount"));
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2986
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2987 for(z=0;z<submenucount;z++)
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2988 {
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2989 char tempbuf[101] = {0};
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2990 HMENUI submenu;
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2991
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2992 snprintf(tempbuf, 100, "_dw_submenu%d", z);
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2993
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2994 if((submenu = g_object_get_data(G_OBJECT(start), tempbuf)))
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2995 {
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2996 if(!g_object_get_data(G_OBJECT(submenu), "_dw_menuparent"))
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2997 {
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2998 int menugroup = DW_POINTER_TO_INT(g_object_get_data(G_OBJECT(submenu), "_dw_menugroup"));
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
2999 GSimpleActionGroup *group = g_object_get_data(G_OBJECT(submenu), "_dw_group");
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3000 char tempbuf[25] = {0};
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3001
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3002 snprintf(tempbuf, 24, "menu%d", menugroup);
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3003
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3004 gtk_widget_insert_action_group(GTK_WIDGET(menuparent), tempbuf, G_ACTION_GROUP(group));
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3005 g_object_set_data(G_OBJECT(submenu), "_dw_menuparent", (gpointer)menuparent);
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3006 }
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3007 _dw_menu_set_group_recursive(submenu, menuparent);
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3008 }
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3009 }
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3010 }
2289
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3011
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3012 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3013 * Create a menu object to be popped up.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3014 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3015 * id: An ID to be used for getting the resource from the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3016 * resource file.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3017 */
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3018 DW_FUNCTION_DEFINITION(dw_menu_new, HMENUI, ULONG cid)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3019 DW_FUNCTION_ADD_PARAM1(cid)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3020 DW_FUNCTION_RETURN(dw_menu_new, HMENUI)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3021 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3022 {
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3023 GMenu *tmp = g_menu_new();
2288
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3024 /* Create the initial section and add it to the menu */
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3025 GMenu *section = g_menu_new();
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3026 GMenuItem *item = g_menu_item_new_section(NULL, G_MENU_MODEL(section));
2289
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3027 GSimpleActionGroup *group = g_simple_action_group_new();
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3028
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3029 g_menu_append_item(tmp, item);
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3030
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3031 g_object_set_data(G_OBJECT(tmp), "_dw_menugroup", GINT_TO_POINTER(++_dw_menugroup));
2289
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3032 g_object_set_data(G_OBJECT(tmp), "_dw_group", (gpointer)group);
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3033 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2288
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3034 g_object_set_data(G_OBJECT(tmp), "_dw_section", (gpointer)section);
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3035 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3036 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3037
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3038 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3039 * Create a menubar on a window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3040 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3041 * location: Handle of a window frame to be attached to.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3042 * If there is no box already packed into the "location", the menu will not appear
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3043 * so tell the user.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3044 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3045 DW_FUNCTION_DEFINITION(dw_menubar_new, HMENUI, HWND location)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3046 DW_FUNCTION_ADD_PARAM1(location)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3047 DW_FUNCTION_RETURN(dw_menubar_new, HMENUI)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3048 DW_FUNCTION_RESTORE_PARAM1(location, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3049 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3050 HMENUI tmp = 0;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3051 GtkWidget *box;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3052
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3053 if(GTK_IS_WINDOW(location) &&
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3054 (box = GTK_WIDGET(g_object_get_data(G_OBJECT(location), "_dw_grid"))))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3056 /* If there is an existing menu bar, remove it */
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3057 GtkWidget *oldmenu = GTK_WIDGET(g_object_get_data(G_OBJECT(location), "_dw_menubar"));
2288
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3058 GMenu *menu = g_menu_new();
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3059 /* Create the initial section and add it to the menu */
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3060 GMenu *section = g_menu_new();
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3061 GMenuItem *item = g_menu_item_new_section(NULL, G_MENU_MODEL(section));
2289
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3062 GSimpleActionGroup *group = g_simple_action_group_new();
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3063 char tempbuf[25] = {0};
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3064
2288
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3065 g_menu_append_item(menu, item);
2272
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3066
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
3067 if(oldmenu && GTK_IS_WIDGET(oldmenu))
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3068 gtk_grid_remove(GTK_GRID(box), tmp);
2272
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3069
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3070 /* Create a new menu bar */
2272
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3071 tmp = gtk_popover_menu_bar_new_from_model(G_MENU_MODEL(menu));
2289
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3072 snprintf(tempbuf, 24, "menu%d", ++_dw_menugroup);
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3073 gtk_widget_insert_action_group(GTK_WIDGET(tmp), tempbuf, G_ACTION_GROUP(group));
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3074 gtk_widget_set_visible(tmp, TRUE);
2289
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3075
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3076 /* Save pointers to each other */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3077 g_object_set_data(G_OBJECT(location), "_dw_menubar", (gpointer)tmp);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3078 g_object_set_data(G_OBJECT(tmp), "_dw_window", (gpointer)location);
2289
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3079 g_object_set_data(G_OBJECT(tmp), "_dw_menugroup", GINT_TO_POINTER(_dw_menugroup));
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
3080 g_object_set_data(G_OBJECT(tmp), "_dw_group", (gpointer)group);
2288
d0bb8f99ac45 GTK4: Implement menu separators.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2287
diff changeset
3081 g_object_set_data(G_OBJECT(tmp), "_dw_section", (gpointer)section);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3082 gtk_grid_attach(GTK_GRID(box), tmp, 0, 0, 1, 1);
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3083 _dw_menu_set_group_recursive(tmp, GTK_WIDGET(tmp));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3084 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3085 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3086 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089 * Destroys a menu created with dw_menubar_new or dw_menu_new.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 * menu: Handle of a menu.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3093 DW_FUNCTION_DEFINITION(dw_menu_destroy, void, HMENUI *menu)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3094 DW_FUNCTION_ADD_PARAM1(menu)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3095 DW_FUNCTION_NO_RETURN(dw_menu_destroy)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3096 DW_FUNCTION_RESTORE_PARAM1(menu, HMENUI *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3097 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3098 if(menu && *menu)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3099 {
2284
3361ce6070ce Add DW_FEATURE_TASK_BAR to the feature tests, for taskbar icon support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2282
diff changeset
3100 GtkWidget *window = NULL;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3101
2332
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3102 /* If it is attached to a window, try to delete the reference to it */
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3103 if((GTK_IS_POPOVER_MENU_BAR(*menu) || GTK_IS_POPOVER_MENU(*menu)) &&
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3104 (window = GTK_WIDGET(g_object_get_data(G_OBJECT(*menu), "_dw_window"))))
2332
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3105 {
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3106 if(GTK_IS_POPOVER_MENU_BAR(*menu))
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3107 g_object_set_data(G_OBJECT(window), "_dw_menubar", NULL);
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3108 else
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3109 g_object_set_data(G_OBJECT(window), "_dw_menu_popup", NULL);
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3110 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3111 /* Actually destroy the menu */
2284
3361ce6070ce Add DW_FEATURE_TASK_BAR to the feature tests, for taskbar icon support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2282
diff changeset
3112 if(GTK_IS_WIDGET(*menu) && window)
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3113 {
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3114 GtkWidget *box = GTK_WIDGET(g_object_get_data(G_OBJECT(window), "_dw_grid"));
2332
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3115
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3116 if(box && GTK_IS_GRID(box))
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3117 gtk_grid_remove(GTK_GRID(box), GTK_WIDGET(*menu));
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3118 else
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3119 g_object_unref(G_OBJECT(*menu));
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
3120 }
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3121 else if(G_IS_MENU(*menu))
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3122 g_object_unref(G_OBJECT(*menu));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 *menu = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3125 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127
2286
2d282d8fe911 GTK4: Change to how the action name is created, don't use the menu label...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2284
diff changeset
3128 char _dw_removetilde(char *dest, const char *src)
2272
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3129 {
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3130 int z, cur=0;
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3131 char accel = '\0';
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3132
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3133 for(z=0;z<strlen(src);z++)
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3134 {
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3135 if(src[z] == '~')
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3136 {
2286
2d282d8fe911 GTK4: Change to how the action name is created, don't use the menu label...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2284
diff changeset
3137 dest[cur] = '_';
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3138 accel = src[z+1];
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3139 }
2272
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3140 else
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3141 dest[cur] = src[z];
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3142 cur++;
2272
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3143 }
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3144 dest[cur] = 0;
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3145 return accel;
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3146 }
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3147
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3148
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150 * Adds a menuitem or submenu to an existing menu.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152 * menu: The handle to the existing menu.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3153 * title: The title text on the menu item to be added.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154 * id: An ID to be used for message passing.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155 * flags: Extended attributes to set on the menu.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156 * end: If TRUE memu is positioned at the end of the menu.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157 * check: If TRUE menu is "check"able.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158 * submenu: Handle to an existing menu to be a submenu or NULL.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3159 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3160 DW_FUNCTION_DEFINITION(dw_menu_append_item, HWND, HMENUI menu, const char *title, unsigned long id, unsigned long flags, int end, DW_UNUSED(int check), HMENUI submenu)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3161 DW_FUNCTION_ADD_PARAM7(menu, title, id, flags, end, check, submenu)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3162 DW_FUNCTION_RETURN(dw_menu_append_item, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3163 DW_FUNCTION_RESTORE_PARAM7(menu, HMENUI, title, const char *, id, unsigned long, flags, unsigned long, end, int, DW_UNUSED(check), int, submenu, HMENUI)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3164 {
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3165 GSimpleAction *action = NULL;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3166 HWND tmphandle = NULL;
2272
2ce302c43f48 GTK4: Initial menu functionality... basic creation works... no callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2271
diff changeset
3167 GMenuModel *menumodel;
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3168 char *temptitle = alloca(strlen(title)+1);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3169
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3170 if(menu)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3171 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3172 /* By default we add to the menu's current section */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3173 menumodel = g_object_get_data(G_OBJECT(menu), "_dw_section");
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3174 _dw_removetilde(temptitle, title);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3175
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3176 /* To add a separator we create a new section and add it */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3177 if (strlen(temptitle) == 0)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3178 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3179 GMenu *section = g_menu_new();
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3180
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3181 /* If we are creating a new section, add it to the core menu... not the section */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3182 if(GTK_IS_POPOVER_MENU_BAR(menu))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3183 menumodel = gtk_popover_menu_bar_get_menu_model(GTK_POPOVER_MENU_BAR(menu));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3184 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3185 menumodel = G_MENU_MODEL(menu);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3186
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3187 tmphandle = (HWND)g_menu_item_new_section(NULL, G_MENU_MODEL(section));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3188 g_object_set_data(G_OBJECT(menu), "_dw_section", (gpointer)section);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3189 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3190 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3191 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3192 char tempbuf[101] = {0};
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3193
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3194 if(submenu)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3195 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3196 if(G_IS_MENU(submenu))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3197 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3198 int submenucount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "_dw_submenucount"));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3199 GtkWidget *menuparent = GTK_WIDGET(g_object_get_data(G_OBJECT(menu), "_dw_menuparent"));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3200
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3201 /* If the menu being added to is a menu bar, that is the menuparent for submenus */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3202 if(GTK_IS_POPOVER_MENU_BAR(menu))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3203 menuparent = GTK_WIDGET(menu);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3204
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3205 snprintf(tempbuf, 100, "_dw_submenu%d", submenucount);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3206 submenucount++;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3207 tmphandle = (HWND)g_menu_item_new_submenu(temptitle, G_MENU_MODEL(submenu));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3208 g_object_set_data(G_OBJECT(menu), tempbuf, (gpointer)submenu);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3209 g_object_set_data(G_OBJECT(menu), "_dw_submenucount", GINT_TO_POINTER(submenucount));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3210
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3211 /* If we have a menu parent, use it to create the groups if needed */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3212 if(menuparent && !g_object_get_data(G_OBJECT(submenu), "_dw_menuparent"))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3213 _dw_menu_set_group_recursive(menu, menuparent);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3214 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3215 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3216 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3217 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3218 char numbuf[25] = {0};
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3219 GSimpleActionGroup *group = g_object_get_data(G_OBJECT(menu), "_dw_group");
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3220 int menugroup = DW_POINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "_dw_menugroup"));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3221 char *actionname;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3222
2326
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3223 /* Code to autogenerate a menu ID if not specified or invalid
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3224 * First pool is smaller for transient popup menus
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3225 */
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3226 if(id == (ULONG)-1)
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3227 {
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3228 static ULONG tempid = 60000;
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3229
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3230 tempid++;
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3231 id = tempid;
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3232
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3233 if(tempid > 65500)
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3234 tempid = 60000;
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3235 }
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3236 /* Second pool is larger for more static windows */
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3237 else if(!id || id >= 30000)
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3238 {
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3239 static ULONG menuid = 30000;
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3240
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3241 menuid++;
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3242 if(menuid > 60000)
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3243 menuid = 30000;
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3244 id = menuid;
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3245 }
258c1b9c29f4 GTK4: Implement DW_MENU_AUTO and DW_MENU_POPUP. These weren't necessary on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2325
diff changeset
3246
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3247 snprintf(tempbuf, 100, "menu%d.action%lu", menugroup, id);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3248 actionname = strchr(tempbuf, '.');
2317
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3249 if(check)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3250 action = g_simple_action_new_stateful(&actionname[1], NULL, g_variant_new_boolean (FALSE));
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3251 else
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3252 action = g_simple_action_new(&actionname[1], NULL);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3253 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3254 tmphandle=(HWND)g_menu_item_new(temptitle, tempbuf);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3255 snprintf(numbuf, 24, "%lu", id);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3256 g_object_set_data(G_OBJECT(menu), numbuf, (gpointer)tmphandle);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3257 g_object_set_data(G_OBJECT(tmphandle), "_dw_action", (gpointer)action);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3258 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3259 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3260
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3261 if(end)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3262 g_menu_append_item(G_MENU(menumodel), G_MENU_ITEM(tmphandle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3263 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3264 g_menu_prepend_item(G_MENU(menumodel), G_MENU_ITEM(tmphandle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3265
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3266 g_object_set_data(G_OBJECT(tmphandle), "_dw_id", GINT_TO_POINTER(id));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3267
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3268 if(action)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3269 g_simple_action_set_enabled(action, (flags & DW_MIS_DISABLED) ? FALSE : TRUE);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3270 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3271 DW_FUNCTION_RETURN_THIS(tmphandle);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3274 GMenuItem *_dw_find_submenu_id(HMENUI start, const char *name)
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3275 {
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3276 GMenuItem *tmp;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3277 int z, submenucount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(start), "_dw_submenucount"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3278
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3279 if((tmp = g_object_get_data(G_OBJECT(start), name)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3280 return tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3281
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3282 for(z=0;z<submenucount;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3283 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3284 char tempbuf[101] = {0};
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3285 GMenuItem *menuitem;
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3286 HMENUI submenu;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3287
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3288 snprintf(tempbuf, 100, "_dw_submenu%d", z);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3289
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3290 if((submenu = g_object_get_data(G_OBJECT(start), tempbuf)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3291 {
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3292 if((menuitem = _dw_find_submenu_id(submenu, name)))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3293 return menuitem;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3294 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3295 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3296 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3297 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3298
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3299 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3300 * Sets the state of a menu item check.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3301 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3302 * menu: The handle the the existing menu.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3303 * id: Menuitem id.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3304 * check: TRUE for checked FALSE for not checked.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3305 * deprecated: use dw_menu_item_set_state()
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3306 */
2317
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3307 DW_FUNCTION_DEFINITION(dw_menu_item_set_check, void, HMENUI menu, ULONG cid, int check)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3308 DW_FUNCTION_ADD_PARAM3(menu, cid, check)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3309 DW_FUNCTION_NO_RETURN(dw_menu_item_set_check)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3310 DW_FUNCTION_RESTORE_PARAM3(menu, HMENUI, cid, ULONG, check, int)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3311 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3312 if(menu)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3313 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3314 char numbuf[25] = {0};
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3315 GMenuItem *tmphandle;
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3316
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3317 snprintf(numbuf, 24, "%lu", cid);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3318 tmphandle = _dw_find_submenu_id(menu, numbuf);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3319
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3320 if(tmphandle && G_IS_MENU_ITEM(tmphandle))
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3321 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3322 GSimpleAction *action = g_object_get_data(G_OBJECT(tmphandle), "_dw_action");
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3323
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3324 if(action)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3325 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3326 GVariant *action_state = g_action_get_state(G_ACTION(action));
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3327 gboolean thischeck = check;
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3328
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3329 if(!action_state || (g_variant_get_boolean(action_state) != thischeck))
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3330 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3331 GVariant *new_state = g_variant_new_boolean(thischeck);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3332 g_simple_action_set_state(action, new_state);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3333 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3334 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3335 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3336 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3337 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341 * Sets the state of a menu item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 * menu: The handle the the existing menu.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344 * id: Menuitem id.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3345 * state: TRUE for checked FALSE for not checked.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346 */
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3347 DW_FUNCTION_DEFINITION(dw_menu_item_set_state, void, HMENUI menu, ULONG cid, ULONG state)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3348 DW_FUNCTION_ADD_PARAM3(menu, cid, state)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3349 DW_FUNCTION_NO_RETURN(dw_menu_item_set_state)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3350 DW_FUNCTION_RESTORE_PARAM3(menu, HMENUI, cid, ULONG, state, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3351 {
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3352 if(menu)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3353 {
2317
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3354 char numbuf[25] = {0};
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3355 GMenuItem *tmphandle;
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3356
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3357 snprintf(numbuf, 24, "%lu", cid);
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3358 tmphandle = _dw_find_submenu_id(menu, numbuf);
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3359
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3360 if(tmphandle && G_IS_MENU_ITEM(tmphandle))
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3361 {
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3362 GSimpleAction *action = g_object_get_data(G_OBJECT(tmphandle), "_dw_action");
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3363
2317
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3364 if(action)
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3365 {
2317
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3366 if((state & DW_MIS_CHECKED) || (state & DW_MIS_UNCHECKED))
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3367 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3368 GVariant *action_state = g_action_get_state(G_ACTION(action));
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3369 gboolean check = false;
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3370
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3371 if(state & DW_MIS_CHECKED)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3372 check = true;
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3373
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3374 if(!action_state || (g_variant_get_boolean(action_state) != check))
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3375 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3376 GVariant *new_state = g_variant_new_boolean(check);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3377 g_simple_action_set_state(action, new_state);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3378 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3379 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3380 if((state & DW_MIS_ENABLED) || (state & DW_MIS_DISABLED))
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3381 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3382 if(state & DW_MIS_ENABLED)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3383 g_simple_action_set_enabled(action, TRUE);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3384 else
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3385 g_simple_action_set_enabled(action, FALSE);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
3386 }
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3387 }
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3388 }
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3389 }
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3390 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3392
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3394 * Deletes the menu item specified.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 * menu: The handle to the menu in which the item was appended.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 * id: Menuitem id.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 */
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3401 DW_FUNCTION_DEFINITION(dw_menu_delete_item, int, HMENUI menu, ULONG cid)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3402 DW_FUNCTION_ADD_PARAM2(menu, cid)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3403 DW_FUNCTION_RETURN(dw_menu_delete_item, int)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3404 DW_FUNCTION_RESTORE_PARAM2(menu, HMENUI, cid, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3406 int ret = DW_ERROR_UNKNOWN;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407 char numbuf[25] = {0};
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3408 GMenuItem *tmphandle;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409
2310
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3410 if(menu)
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3411 {
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3412 snprintf(numbuf, 24, "%lu", cid);
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3413 tmphandle = _dw_find_submenu_id(menu, numbuf);
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3414
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3415 if(tmphandle && G_IS_MENU_ITEM(tmphandle))
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3416 {
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3417 /* g_menu_remove(menu, position); */
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3418 g_object_unref(G_OBJECT(tmphandle));
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3419 g_object_set_data(G_OBJECT(menu), numbuf, NULL);
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3420 ret = DW_ERROR_NONE;
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3421 }
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3422 }
5df7b1431d1a GTK4: Moved the rest of the menu functions into thread safety to try to fix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2309
diff changeset
3423 DW_FUNCTION_RETURN_THIS(ret);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425
2300
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3426 /* Delayed unparent of the popup menu from the parent */
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3427 gboolean _dw_idle_popover_unparent(gpointer data)
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3428 {
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3429 GtkWidget *self = GTK_WIDGET(data);
2331
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3430 GtkWidget *box, *window = g_object_get_data(G_OBJECT(self), "_dw_window");
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3431
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3432 if(window && GTK_IS_WINDOW(window) &&
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3433 (box = g_object_get_data(G_OBJECT(window), "_dw_grid")) && GTK_IS_GRID(box))
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3434 gtk_grid_remove(GTK_GRID(box), self);
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3435 else
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3436 gtk_widget_unparent(self);
2300
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3437 return false;
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3438 }
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3439
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3440 void _dw_popover_menu_closed(GtkPopover *self, gpointer data)
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3441 {
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3442 GtkWidget *parent = GTK_WIDGET(data);
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3443
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3444 /* Can't unparent immediately, since the "activate" signal happens second...
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3445 * so we have to delay unparenting until the "activate" handler runs.
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3446 */
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3447 if(GTK_IS_WIDGET(parent) && GTK_IS_POPOVER(self))
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3448 g_idle_add(G_SOURCE_FUNC(_dw_idle_popover_unparent), (gpointer)self);
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3449 }
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3450
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3451 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3452 * Pops up a context menu at given x and y coordinates.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3453 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3454 * menu: The handle the the existing menu.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3455 * parent: Handle to the window initiating the popup.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3456 * x: X coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3457 * y: Y coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3458 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3459 DW_FUNCTION_DEFINITION(dw_menu_popup, void, HMENUI *menu, HWND parent, int x, int y)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3460 DW_FUNCTION_ADD_PARAM4(menu, parent, x, y)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3461 DW_FUNCTION_NO_RETURN(dw_menu_popup)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3462 DW_FUNCTION_RESTORE_PARAM4(menu, HMENUI *, parent, HWND, x, int, y, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3463 {
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3464 if(menu && *menu && G_MENU(*menu))
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3465 {
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3466 GtkWidget *tmp = gtk_popover_menu_new_from_model_full(G_MENU_MODEL(*menu), GTK_POPOVER_MENU_NESTED);
2302
785775b9002f GTK4: Use gtk_popover_set_pointing_to() to position the popover instead of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2301
diff changeset
3467 GdkRectangle rect = { x, y, 1, 1 };
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
3468
2331
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3469 if(GTK_IS_WINDOW(parent))
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3470 {
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3471 GtkWidget *box = g_object_get_data(G_OBJECT(parent), "_dw_grid");
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3472
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3473 if(box && GTK_IS_GRID(box))
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3474 {
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3475 gtk_grid_attach(GTK_GRID(box), tmp, 65535, 65535, 1, 1);
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3476 g_object_set_data(G_OBJECT(tmp), "_dw_window", (gpointer)parent);
2332
594111e84e89 GTK4: Save pointer to the activate popup menu for a window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2331
diff changeset
3477 g_object_set_data(G_OBJECT(parent), "_dw_menu_popup", (gpointer)tmp);
2331
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3478 }
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3479 }
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3480 else
addbd7db1e5c GTK4: If parent passed to dw_menu_popup() is a GtkWindow, add the popup to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2330
diff changeset
3481 gtk_widget_set_parent(tmp, GTK_WIDGET(parent));
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
3482
2303
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3483 if(!g_object_get_data(G_OBJECT(*menu), "_dw_menuparent"))
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3484 {
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3485 int menugroup = DW_POINTER_TO_INT(g_object_get_data(G_OBJECT(*menu), "_dw_menugroup"));
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3486 GSimpleActionGroup *group = g_object_get_data(G_OBJECT(*menu), "_dw_group");
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3487 char tempbuf[25] = {0};
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3488
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3489 snprintf(tempbuf, 24, "menu%d", menugroup);
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3490
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3491 gtk_widget_insert_action_group(GTK_WIDGET(tmp), tempbuf, G_ACTION_GROUP(group));
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3492 g_object_set_data(G_OBJECT(*menu), "_dw_menuparent", (gpointer)tmp);
cdd8459add40 GTK4: Add code to setup the toplevel menu for popups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2302
diff changeset
3493 }
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
3494 _dw_menu_set_group_recursive(*menu, GTK_WIDGET(tmp));
2300
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3495 gtk_popover_set_autohide(GTK_POPOVER(tmp), TRUE);
2302
785775b9002f GTK4: Use gtk_popover_set_pointing_to() to position the popover instead of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2301
diff changeset
3496 gtk_popover_set_has_arrow (GTK_POPOVER(tmp), FALSE);
785775b9002f GTK4: Use gtk_popover_set_pointing_to() to position the popover instead of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2301
diff changeset
3497 gtk_popover_set_pointing_to(GTK_POPOVER(tmp), &rect);
2300
6e47d510dbbb GTK4: Since GTK4 needs to add the popup menu to the parent widget...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2299
diff changeset
3498 g_signal_connect(G_OBJECT(tmp), "closed", G_CALLBACK(_dw_popover_menu_closed), (gpointer)parent);
2299
27c20fa1615e GTK4: Fix a crash while trying to create a popup menu...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2295
diff changeset
3499 gtk_popover_popup(GTK_POPOVER(tmp));
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3500 *menu = NULL;
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
3501 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3502 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3504
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507 * Returns the current X and Y coordinates of the mouse pointer.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 * x: Pointer to variable to store X coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 * y: Pointer to variable to store Y coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3511 */
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
3512 void API dw_pointer_query_pos(long *x, long *y)
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
3513 {
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3514 if(x)
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
3515 *x = (long)_dw_mouse_last_x;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3516 if(y)
2759
cd6a306800f5 GTK4: New way of querying the mouse pointer position.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2758
diff changeset
3517 *y = (long)_dw_mouse_last_y;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3518 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3519
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3520 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3521 * Sets the X and Y coordinates of the mouse pointer.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3522 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3523 * x: X coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3524 * y: Y coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3525 */
2322
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3526 #ifndef GDK_WINDOWING_X11
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
3527 void API dw_pointer_set_pos(long x, long y)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3528 {
2322
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3529 }
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3530 #else
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3531 DW_FUNCTION_DEFINITION(dw_pointer_set_pos, void, long x, long y)
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3532 DW_FUNCTION_ADD_PARAM2(x, y)
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3533 DW_FUNCTION_NO_RETURN(dw_pointer_set_pos)
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3534 DW_FUNCTION_RESTORE_PARAM2(x, long, y, long)
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3535 {
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3536 GdkDisplay *display = gdk_display_get_default();
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3537
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
3538 if(display && GDK_IS_X11_DISPLAY(display))
2322
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3539 {
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3540 Display *xdisplay = gdk_x11_display_get_xdisplay(display);
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3541 Window xrootwin = gdk_x11_display_get_xrootwindow(display);
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3542
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3543 if(xdisplay)
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3544 XWarpPointer(xdisplay, None, xrootwin, 0, 0, 0, 0, (int)x, (int)y);
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3545 }
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3546 DW_FUNCTION_RETURN_NOTHING;
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3547 }
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
3548 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3549
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3550 #define _DW_TREE_CONTAINER 1
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3551 #define _DW_TREE_TREE 2
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3552 #define _DW_TREE_LISTBOX 3
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3553
2287
680212c356e3 GTK4: Refactor tree and fix DW_SIGNAL_ITEM_CONTEXT signals on tree view
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2286
diff changeset
3554 GtkWidget *_dw_tree_create(unsigned long id)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3555 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3556 GtkWidget *tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3557
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3558 tmp = gtk_scrolled_window_new();
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3559 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3560 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3561
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3562 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id));
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3563 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3564 return tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3565 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3566
2287
680212c356e3 GTK4: Refactor tree and fix DW_SIGNAL_ITEM_CONTEXT signals on tree view
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2286
diff changeset
3567 GtkWidget *_dw_tree_view_setup(GtkWidget *tmp, GtkTreeModel *store)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3568 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3569 GtkWidget *tree = gtk_tree_view_new_with_model(store);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3570 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(tree), FALSE);
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3571 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(tmp), tree);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3572 g_object_set_data(G_OBJECT(tmp), "_dw_user", (gpointer)tree);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 return tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 * Create a container object to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579 * id: An ID to be used for getting the resource from the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580 * resource file.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3581 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3582 DW_FUNCTION_DEFINITION(dw_container_new, HWND, ULONG cid, int multi)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3583 DW_FUNCTION_ADD_PARAM2(cid, multi)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3584 DW_FUNCTION_RETURN(dw_container_new, HWND)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3585 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 GtkWidget *tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3589 if((tmp = _dw_tree_create(cid)))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3590 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3591 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3592 g_object_set_data(G_OBJECT(tmp), "_dw_multi_sel", GINT_TO_POINTER(multi));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3593 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3594 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3595 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3596
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3597 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3598 * Create a tree object to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3599 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3600 * id: An ID to be used for getting the resource from the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3601 * resource file.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3602 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3603 DW_FUNCTION_DEFINITION(dw_tree_new, HWND, ULONG cid)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3604 DW_FUNCTION_ADD_PARAM1(cid)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3605 DW_FUNCTION_RETURN(dw_tree_new, HWND)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3606 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3607 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3608 GtkWidget *tmp, *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3609 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3610 GtkTreeViewColumn *col;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3611 GtkCellRenderer *rend;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3612 GtkTreeSelection *sel;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3613
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3614 if((tmp = _dw_tree_create(cid)))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3615 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3616 store = gtk_tree_store_new(4, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_POINTER);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3617 tree = _dw_tree_view_setup(tmp, GTK_TREE_MODEL(store));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3618 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_TREE));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3619 g_object_set_data(G_OBJECT(tree), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_TREE));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3620 col = gtk_tree_view_column_new();
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3621
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3622 rend = gtk_cell_renderer_pixbuf_new();
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3623 gtk_tree_view_column_pack_start(col, rend, FALSE);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3624 gtk_tree_view_column_add_attribute(col, rend, "pixbuf", 1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3625 rend = gtk_cell_renderer_text_new();
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3626 gtk_tree_view_column_pack_start(col, rend, TRUE);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3627 gtk_tree_view_column_add_attribute(col, rend, "text", 0);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3628
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3629 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3630 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3631 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3632
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3633 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3634 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3635 gtk_widget_set_visible(tree, TRUE);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3636
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3637 if(_DWDefaultFont)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3638 dw_window_set_font(tmp, _DWDefaultFont);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3639 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3640 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645 * Create a new static text window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 * text: The text to be display by the static text widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3650 DW_FUNCTION_DEFINITION(dw_text_new, HWND, const char *text, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3651 DW_FUNCTION_ADD_PARAM2(text, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3652 DW_FUNCTION_RETURN(dw_text_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3653 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3654 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3655 GtkWidget *tmp = gtk_label_new(text);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3656
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3657 /* Left and centered */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3658 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3659 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3660 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3661 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3662 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3663 dw_window_set_font(tmp, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3664 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3665 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3666
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3667 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3668 * Create a new status text window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3669 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3670 * text: The text to be display by the static text widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3671 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3672 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3673 DW_FUNCTION_DEFINITION(dw_status_text_new, HWND, const char *text, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3674 DW_FUNCTION_ADD_PARAM2(text, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3675 DW_FUNCTION_RETURN(dw_status_text_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3676 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3677 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3678 GtkWidget *tmp, *frame = gtk_frame_new(NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3679 tmp = gtk_label_new(text);
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3680 gtk_frame_set_child(GTK_FRAME(frame), tmp);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3681 gtk_widget_set_visible(tmp, TRUE);
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3682 gtk_widget_set_visible(frame, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3683
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3684 /* Left and centered */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3685 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3686 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3687 g_object_set_data(G_OBJECT(frame), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3688 g_object_set_data(G_OBJECT(frame), "_dw_label", (gpointer)tmp);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3689 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3690 dw_window_set_font(tmp, _DWDefaultFont);
2306
558959a64772 GTK4: Fix thread safety while using dw_main() and fix an status text issue.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2305
diff changeset
3691 DW_FUNCTION_RETURN_THIS(frame);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3692 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3693
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3694 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3695 * Create a new Multiline Editbox window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3696 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3697 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3699 DW_FUNCTION_DEFINITION(dw_mle_new, HWND, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3700 DW_FUNCTION_ADD_PARAM1(cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3701 DW_FUNCTION_RETURN(dw_mle_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3702 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3703 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3704 GtkWidget *tmp, *tmpbox = gtk_scrolled_window_new();
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3705 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tmpbox),
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3706 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3707 tmp = gtk_text_view_new();
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3708 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(tmpbox), tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3709 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_WORD);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3710
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3711 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3712 g_object_set_data(G_OBJECT(tmpbox), "_dw_user", (gpointer)tmp);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3713 gtk_widget_set_visible(tmp, TRUE);
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3714 gtk_widget_set_visible(tmpbox, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3715 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3716 dw_window_set_font(tmpbox, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3717 DW_FUNCTION_RETURN_THIS(tmpbox);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3718 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3719
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3720 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3721 * Create a new Entryfield window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3722 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3723 * text: The default text to be in the entryfield widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3724 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3725 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3726 DW_FUNCTION_DEFINITION(dw_entryfield_new, HWND, const char *text, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3727 DW_FUNCTION_ADD_PARAM2(text, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3728 DW_FUNCTION_RETURN(dw_entryfield_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3729 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3730 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3731 GtkEntryBuffer *buffer = gtk_entry_buffer_new(text, -1);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3732 GtkWidget *tmp = gtk_entry_new_with_buffer(buffer);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3733
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3734 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3735 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3736
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3737 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3738 dw_window_set_font(tmp, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3739 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3740 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3741
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3742 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3743 * Create a new Entryfield (password) window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3744 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3745 * text: The default text to be in the entryfield widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3746 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3747 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3748 DW_FUNCTION_DEFINITION(dw_entryfield_password_new, HWND, const char *text, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3749 DW_FUNCTION_ADD_PARAM2(text, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3750 DW_FUNCTION_RETURN(dw_entryfield_password_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3751 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3752 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3753 GtkEntryBuffer *buffer = gtk_entry_buffer_new(text, -1);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3754 GtkWidget *tmp = gtk_entry_new_with_buffer(buffer);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3755
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3756 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3757
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3758 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3759 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762 dw_window_set_font(tmp, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3763 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3767 * Create a new Combobox window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769 * text: The default text to be in the combpbox widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3770 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3771 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3772 DW_FUNCTION_DEFINITION(dw_combobox_new, HWND, const char *text, ULONG cid)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3773 DW_FUNCTION_ADD_PARAM2(text, cid)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3774 DW_FUNCTION_RETURN(dw_combobox_new, HWND)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3775 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3776 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3777 GtkWidget *tmp;
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3778 GtkEntryBuffer *buffer;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3779 GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3780 tmp = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3781 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(tmp), 0);
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3782 buffer = gtk_entry_get_buffer(GTK_ENTRY(gtk_combo_box_get_child(GTK_COMBO_BOX(tmp))));
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3783 gtk_entry_buffer_set_max_length(buffer, 0);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3784 gtk_entry_buffer_set_text(buffer, text, -1);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3785 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3786 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_COMBOBOX));
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3787 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3788 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3789 dw_window_set_font(tmp, _DWDefaultFont);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
3790 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3791 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3792
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3793 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3794 * Create a new button window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3795 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3796 * text: The text to be display by the static text widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3797 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3798 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3799 DW_FUNCTION_DEFINITION(dw_button_new, HWND, const char *text, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3800 DW_FUNCTION_ADD_PARAM2(text, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3801 DW_FUNCTION_RETURN(dw_button_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3802 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3803 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3804 GtkWidget *tmp = gtk_button_new_with_label(text);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3805 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3806 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3807 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3808 dw_window_set_font(tmp, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3809 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3810 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3811
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3812 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3813 * Create a new bitmap button window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3814 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3815 * text: Bubble help text to be displayed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3816 * id: An ID of a bitmap in the resource file.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3817 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3818 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new, HWND, const char *text, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3819 DW_FUNCTION_ADD_PARAM2(text, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3820 DW_FUNCTION_RETURN(dw_bitmapbutton_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3821 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3822 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3823 GtkWidget *tmp = gtk_button_new();
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3824 GtkWidget *bitmap = dw_bitmap_new(cid);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3826 if(bitmap)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3827 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3828 dw_window_set_bitmap(bitmap, cid, NULL);
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3829 gtk_button_set_child(GTK_BUTTON(tmp), bitmap);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3830 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3831 }
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3832 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3833 if(text)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3834 gtk_widget_set_tooltip_text(tmp, text);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3835 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3836 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3837 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3839 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3840 * Create a new bitmap button window (widget) to be packed from a file.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3841 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842 * label_text: Text to display on button. TBD when Windows works
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3843 * text: Bubble help text to be displayed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3844 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3845 * filename: Name of the file, omit extention to have
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3846 * DW pick the appropriate file extension.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 * (BMP on OS/2 or Windows, XPM on Unix)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3848 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3849 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new_from_file, HWND, const char *text, ULONG cid, const char *filename)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3850 DW_FUNCTION_ADD_PARAM3(text, cid, filename)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3851 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_file, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3852 DW_FUNCTION_RESTORE_PARAM3(text, const char *, cid, ULONG, filename, const char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3853 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3854 GtkWidget *tmp = gtk_button_new();
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3855 GtkWidget *bitmap = dw_bitmap_new(cid);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3856
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3857 if(bitmap)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3858 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3859 dw_window_set_bitmap(bitmap, 0, filename);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3860 gtk_button_set_child(GTK_BUTTON(tmp), bitmap);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3861 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3862 }
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3863 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3864 if(text)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3865 gtk_widget_set_tooltip_text(tmp, text);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3866 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3867 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3868 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3869
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3870 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3871 * Create a new bitmap button window (widget) to be packed from data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3872 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3873 * text: Bubble help text to be displayed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3874 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3875 * data: Raw data of image.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3876 * (BMP on OS/2 or Windows, XPM on Unix)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3877 * len: Length of raw data
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3878 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3879 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new_from_data, HWND, const char *text, ULONG cid, const char *data, int len)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3880 DW_FUNCTION_ADD_PARAM4(text, cid, data, len)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3881 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_data, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3882 DW_FUNCTION_RESTORE_PARAM4(text, const char *, cid, ULONG, data, const char *, len, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3883 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3884 GtkWidget *tmp = gtk_button_new();
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3885 GtkWidget *bitmap = dw_bitmap_new(cid);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3886
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3887 if(bitmap)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3888 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3889 dw_window_set_bitmap_from_data(bitmap, 0, data, len);
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3890 gtk_button_set_child(GTK_BUTTON(tmp), bitmap);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3891 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3892 }
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3893 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3894 if(text)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3895 gtk_widget_set_tooltip_text(tmp, text);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3896 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3897 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3898 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901 * Create a new spinbutton window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3903 * text: The text to be display by the static text widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3904 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3905 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3906 DW_FUNCTION_DEFINITION(dw_spinbutton_new, HWND, const char *text, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3907 DW_FUNCTION_ADD_PARAM2(text, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3908 DW_FUNCTION_RETURN(dw_spinbutton_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3909 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3910 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3911 GtkAdjustment *adj = (GtkAdjustment *)gtk_adjustment_new((float)atoi(text), -65536.0, 65536.0, 1.0, 5.0, 0.0);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3912 GtkWidget *tmp = gtk_spin_button_new(adj, 0, 0);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3913
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3914 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3915 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3916 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3917 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adj);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3918 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)tmp);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3919 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3920 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3921 dw_window_set_font(tmp, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3922 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3923 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3924
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3925 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3926 * Create a new radiobutton window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3927 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3928 * text: The text to be display by the static text widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3929 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3930 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3931 DW_FUNCTION_DEFINITION(dw_radiobutton_new, HWND, const char *text, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3932 DW_FUNCTION_ADD_PARAM2(text, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3933 DW_FUNCTION_RETURN(dw_radiobutton_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3934 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3935 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
3936 GtkWidget *tmp = gtk_toggle_button_new_with_label(text);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3937 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3938 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3939
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3940 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3941 dw_window_set_font(tmp, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3942 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3943 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3944
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3945 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3946 * Create a new slider window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3947 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3948 * vertical: TRUE or FALSE if slider is vertical.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3949 * increments: Number of increments available.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3950 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3951 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3952 DW_FUNCTION_DEFINITION(dw_slider_new, HWND, int vertical, int increments, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3953 DW_FUNCTION_ADD_PARAM3(vertical, increments, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3954 DW_FUNCTION_RETURN(dw_slider_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3955 DW_FUNCTION_RESTORE_PARAM3(vertical, int, increments, int, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3956
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3957 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3958 GtkAdjustment *adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3959 GtkWidget *tmp = gtk_scale_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3960
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3961 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3962 gtk_scale_set_draw_value(GTK_SCALE(tmp), 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3963 gtk_scale_set_digits(GTK_SCALE(tmp), 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3964 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3965 g_object_set_data(G_OBJECT(adjustment), "_dw_slider", (gpointer)tmp);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3966 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3967 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3968 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3969
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3970 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3971 * Create a new scrollbar window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3972 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3973 * vertical: TRUE or FALSE if scrollbar is vertical.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3974 * increments: Number of increments available.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3975 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3976 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3977 DW_FUNCTION_DEFINITION(dw_scrollbar_new, HWND, int vertical, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3978 DW_FUNCTION_ADD_PARAM2(vertical, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3979 DW_FUNCTION_RETURN(dw_scrollbar_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3980 DW_FUNCTION_RESTORE_PARAM2(vertical, int, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3981 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3982 GtkAdjustment *adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, 0, 1, 1, 1);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3983 GtkWidget *tmp = gtk_scrollbar_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3984
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3985 gtk_widget_set_can_focus(tmp, FALSE);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
3986 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3987 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3988 g_object_set_data(G_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3989 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3990 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3991 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3992
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3994 * Create a new percent bar window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3995 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3996 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3998 DW_FUNCTION_DEFINITION(dw_percent_new, HWND, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
3999 DW_FUNCTION_ADD_PARAM1(cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4000 DW_FUNCTION_RETURN(dw_percent_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4001 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4002
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4003 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4004 GtkWidget *tmp = gtk_progress_bar_new();
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
4005 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4006 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4007 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4008 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4009
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4010 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4011 * Create a new checkbox window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4012 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4013 * text: The text to be display by the static text widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4014 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4015 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4016 DW_FUNCTION_DEFINITION(dw_checkbox_new, HWND, const char *text, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4017 DW_FUNCTION_ADD_PARAM2(text, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4018 DW_FUNCTION_RETURN(dw_checkbox_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4019 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4020 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4021 GtkWidget *tmp = gtk_check_button_new_with_label(text);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
4022 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4023 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4024 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4025 dw_window_set_font(tmp, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4026 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4027 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4028
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4029 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4030 * Create a new listbox window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4031 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4032 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4033 * multi: Multiple select TRUE or FALSE.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4034 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4035 DW_FUNCTION_DEFINITION(dw_listbox_new, HWND, ULONG cid, int multi)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4036 DW_FUNCTION_ADD_PARAM2(cid, multi)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4037 DW_FUNCTION_RETURN(dw_listbox_new, HWND)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4038 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4039 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4040 GtkWidget *tmp, *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4041 GtkListStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4042 GtkTreeViewColumn *col;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4043 GtkCellRenderer *rend;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044 GtkTreeSelection *sel;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4045
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4046 if((tmp = _dw_tree_create(cid)))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4047 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4048 store = gtk_list_store_new(1, G_TYPE_STRING);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4049 tree = _dw_tree_view_setup(tmp, GTK_TREE_MODEL(store));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4050 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4051 g_object_set_data(G_OBJECT(tree), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4052
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4053 col = gtk_tree_view_column_new();
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4054 rend = gtk_cell_renderer_text_new();
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4055 gtk_tree_view_column_pack_start(col, rend, TRUE);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4056 gtk_tree_view_column_add_attribute(col, rend, "text", 0);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4057
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4058 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4059 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4060 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4061
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4062 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4063 if(multi)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4064 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4065 else
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4066 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
4067 gtk_widget_set_visible(tree, TRUE);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4068 if(_DWDefaultFont)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4069 dw_window_set_font(tmp, _DWDefaultFont);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4070 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4071 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4072 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4073
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4074 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4075 * Sets the icon used for a given window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4076 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4078 * id: An ID to be used to specify the icon.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4079 */
2319
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4080 DW_FUNCTION_DEFINITION(dw_window_set_icon, void, HWND handle, HICN icon)
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4081 DW_FUNCTION_ADD_PARAM2(handle, icon)
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4082 DW_FUNCTION_NO_RETURN(dw_window_set_icon)
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4083 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, icon, HICN)
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4084 {
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4085 if(handle && GTK_IS_WINDOW(handle))
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4086 {
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4087 int rid = GPOINTER_TO_INT(icon);
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4088
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4089 if(rid < 65536)
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4090 {
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4091 GdkDisplay *display = gdk_display_get_default();
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4092 GtkIconTheme *theme = gtk_icon_theme_get_for_display(display);
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4093
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4094 if(theme)
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4095 {
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4096 char resource_path[201] = {0};
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4097 char window_icon[25] = {0};
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4098
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4099 snprintf(resource_path, 200, "%s%u.png", _DW_RESOURCE_PATH, rid);
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4100 gtk_icon_theme_add_resource_path(theme, _DW_RESOURCE_PATH);
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4101 snprintf(window_icon, 24, "%u", rid);
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4102 gtk_window_set_icon_name(GTK_WINDOW(handle), window_icon);
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4103 }
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4104 }
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4105 }
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
4106 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 * Sets the bitmap used for a given static window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4111 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 * id: An ID to be used to specify the icon,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4114 * (pass 0 if you use the filename param)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4115 * filename: a path to a file (Bitmap on OS/2 or
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4116 * Windows and a pixmap on Unix, pass
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117 * NULL if you use the id param)
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4118 * Returns:
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4119 * DW_ERROR_NONE on success.
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4120 * DW_ERROR_UNKNOWN if the parameters were invalid.
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4121 * DW_ERROR_GENERAL if the bitmap was unable to be loaded.
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4122 */
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4123 DW_FUNCTION_DEFINITION(dw_window_set_bitmap, int, HWND handle, unsigned long id, const char *filename)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4124 DW_FUNCTION_ADD_PARAM3(handle, id, filename)
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4125 DW_FUNCTION_RETURN(dw_window_set_bitmap, int)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4126 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, id, ULONG, filename, const char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4127 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 GdkPixbuf *tmp = NULL;
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4129 int retval = DW_ERROR_UNKNOWN;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4130
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4131 if(id)
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
4132 tmp = _dw_find_pixbuf((HICN)id, NULL, NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4133 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4134 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4135 char *file = alloca(strlen(filename) + 6);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4136
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4137 strcpy(file, filename);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4138
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4139 /* check if we can read from this file (it exists and read permission) */
2282
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4140 if(access(file, 04) != 0)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4141 {
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
4142 int i = 0;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
4143
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144 /* Try with various extentions */
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
4145 while(_dw_image_exts[i] && !tmp)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 {
2282
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4147 strcpy(file, filename);
2312
ada8f7610df0 GTK4: Fix building with -D_DW_SINGLE_THREADED and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2311
diff changeset
4148 strcat(file, _dw_image_exts[i]);
2282
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4149 if(access(file, 04) == 0)
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
4150 tmp = gdk_pixbuf_new_from_file(file, NULL);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
4151 i++;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4152 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4153 }
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
4154 else
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4155 tmp = gdk_pixbuf_new_from_file(file, NULL);
2282
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4156 }
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4157
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4158 if(tmp)
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4159 {
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4160 if(GTK_IS_BUTTON(handle))
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4161 {
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
4162 GtkWidget *pixmap = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_bitmap");
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4163 if(pixmap)
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4164 {
2366
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
4165 gtk_picture_set_pixbuf(GTK_PICTURE(pixmap), tmp);
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4166 retval = DW_ERROR_NONE;
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4167 }
2366
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
4168 }
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
4169 else if(GTK_IS_PICTURE(handle))
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4170 {
2366
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
4171 gtk_picture_set_pixbuf(GTK_PICTURE(handle), tmp);
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4172 retval = DW_ERROR_NONE;
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4173 }
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4174 }
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4175 else
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4176 retval = DW_ERROR_GENERAL;
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4177 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4179
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4181 * Sets the bitmap used for a given static window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4184 * id: An ID to be used to specify the icon,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4185 * (pass 0 if you use the filename param)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4186 * data: the image data
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4187 * Bitmap on Windows and a pixmap on Unix, pass
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4188 * NULL if you use the id param)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4189 * len: length of data
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4190 * Returns:
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4191 * DW_ERROR_NONE on success.
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4192 * DW_ERROR_UNKNOWN if the parameters were invalid.
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4193 * DW_ERROR_GENERAL if the bitmap was unable to be loaded.
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4194 */
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4195 DW_FUNCTION_DEFINITION(dw_window_set_bitmap_from_data, int, HWND handle, unsigned long id, const char *data, int len)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4196 DW_FUNCTION_ADD_PARAM4(handle, id, data, len)
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4197 DW_FUNCTION_RETURN(dw_window_set_bitmap_from_data, int)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4198 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, id, ULONG, data, const char *, len, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4199 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4200 GdkPixbuf *tmp = NULL;
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4201 int retval = DW_ERROR_UNKNOWN;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4202
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4203 if(data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4204 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4205 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4206 * A real hack; create a temporary file and write the contents
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4207 * of the data to the file
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4208 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 char template[] = "/tmp/dwpixmapXXXXXX";
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 int written = -1, fd = mkstemp(template);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4212 if(fd != -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4213 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4214 written = write(fd, data, len);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4215 close(fd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4216 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217 /* Bail if we couldn't write full file */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4218 if(fd != -1 && written == len)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4219 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4220 tmp = gdk_pixbuf_new_from_file(template, NULL);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4221 /* remove our temporary file */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4222 unlink(template);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4223 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4224 }
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4225 else if(id)
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
4226 tmp = _dw_find_pixbuf((HICN)id, NULL, NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 if(GTK_IS_BUTTON(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232 GtkWidget *pixmap = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_bitmap");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234 if(pixmap)
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4235 {
2366
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
4236 gtk_picture_set_pixbuf(GTK_PICTURE(pixmap), tmp);
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4237 retval = DW_ERROR_NONE;
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4238 }
2366
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
4239 }
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
4240 else if(GTK_IS_PICTURE(handle))
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4241 {
2366
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
4242 gtk_picture_set_pixbuf(GTK_PICTURE(handle), tmp);
2854
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4243 retval = DW_ERROR_NONE;
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4244 }
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4245 }
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4246 else
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4247 retval = DW_ERROR_GENERAL;
8a5131cbbe93 GTK2/3/4: Add return values to dw_window_set_bitmap(_from_data).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2759
diff changeset
4248 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4249 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4250
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4251 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4252 * Sets the text used for a given window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4254 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 * text: The text associated with a given window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4256 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4257 DW_FUNCTION_DEFINITION(dw_window_set_text, void, HWND handle, const char *text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4258 DW_FUNCTION_ADD_PARAM2(handle, text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4259 DW_FUNCTION_NO_RETURN(dw_window_set_text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4260 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4261 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4262 if(GTK_IS_ENTRY(handle))
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4263 {
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4264 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(handle));
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4265 if(buffer)
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4266 gtk_entry_buffer_set_text(buffer, text, -1);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4267 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 else if(GTK_IS_COMBO_BOX(handle))
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4269 {
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4270 GtkWidget *entry = gtk_combo_box_get_child(GTK_COMBO_BOX(handle));
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4271 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(entry));
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4272 if(buffer)
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4273 gtk_entry_buffer_set_text(buffer, text, -1);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4274 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4275 else if(GTK_IS_LABEL(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4276 gtk_label_set_text(GTK_LABEL(handle), text);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4277 else if(GTK_IS_BUTTON(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4278 gtk_button_set_label(GTK_BUTTON(handle), text);
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4279 else if(GTK_IS_WINDOW(handle))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4280 gtk_window_set_title(GTK_WINDOW(handle), text);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4281 else if (GTK_IS_FRAME(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4282 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4283 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4284 * This is a groupbox or status_text
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4285 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4286 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_label");
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4287 if (tmp && GTK_IS_LABEL(tmp))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4288 gtk_label_set_text(GTK_LABEL(tmp), text);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4289 else /* assume groupbox */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4290 gtk_frame_set_label(GTK_FRAME(handle), text && *text ? text : NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4291 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4292 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4293 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4294
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4295 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296 * Sets the text used for a given window's floating bubble help.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4297 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4298 * handle: Handle to the window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4299 * bubbletext: The text in the floating bubble tooltip.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4301 DW_FUNCTION_DEFINITION(dw_window_set_tooltip, void, HWND handle, const char *bubbletext)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4302 DW_FUNCTION_ADD_PARAM2(handle, bubbletext)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4303 DW_FUNCTION_NO_RETURN(dw_window_set_tooltip)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4304 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, bubbletext, char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4306 if(bubbletext && *bubbletext)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4307 gtk_widget_set_tooltip_text(handle, bubbletext);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4308 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4309 gtk_widget_set_has_tooltip(handle, FALSE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4310 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4312
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4313 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4314 * Gets the text used for a given window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4315 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4316 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4317 * Returns:
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
4318 * text: The text associated with a given window.
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4319 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4320 DW_FUNCTION_DEFINITION(dw_window_get_text, char *, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4321 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4322 DW_FUNCTION_RETURN(dw_window_get_text, char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4323 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4324 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 const char *possible = NULL;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4326 char *retval = NULL;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 if(GTK_IS_ENTRY(handle))
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4329 {
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4330 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(handle));
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4331 possible = gtk_entry_buffer_get_text(buffer);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4332 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 else if(GTK_IS_COMBO_BOX(handle))
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4334 {
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4335 GtkWidget *entry = gtk_combo_box_get_child(GTK_COMBO_BOX(handle));
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4336 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(entry));
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4337 possible = gtk_entry_buffer_get_text(buffer);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
4338 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339 else if(GTK_IS_LABEL(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4340 possible = gtk_label_get_text(GTK_LABEL(handle));
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4341 retval = strdup(possible ? possible : "");
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4342 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4343 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4345 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346 * Disables given window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4347 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4350 DW_FUNCTION_DEFINITION(dw_window_disable, void, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4351 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4352 DW_FUNCTION_NO_RETURN(dw_window_disable)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4353 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 gtk_widget_set_sensitive(handle, FALSE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4356 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4357 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4360 * Enables given window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4362 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4364 DW_FUNCTION_DEFINITION(dw_window_enable, void, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4365 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4366 DW_FUNCTION_NO_RETURN(dw_window_enable)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4367 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 gtk_widget_set_sensitive(handle, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4370 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4372
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374 * Gets the child window handle with specified ID.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4375 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376 * handle: Handle to the parent window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 * id: Integer ID of the child.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4379 DW_FUNCTION_DEFINITION(dw_window_from_id, HWND, HWND handle, int id)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4380 DW_FUNCTION_ADD_PARAM2(handle, id)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4381 DW_FUNCTION_RETURN(dw_window_from_id, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4382 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, id, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4383 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4384 GtkWidget *retval = NULL;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4385
2275
51cb73faab6e GTK4: Implement dw_window_from_id().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2274
diff changeset
4386 if(handle && GTK_WIDGET(handle) && id)
51cb73faab6e GTK4: Implement dw_window_from_id().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2274
diff changeset
4387 {
51cb73faab6e GTK4: Implement dw_window_from_id().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2274
diff changeset
4388 GtkWidget *widget = gtk_widget_get_first_child(GTK_WIDGET(handle));
51cb73faab6e GTK4: Implement dw_window_from_id().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2274
diff changeset
4389
51cb73faab6e GTK4: Implement dw_window_from_id().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2274
diff changeset
4390 while(widget)
51cb73faab6e GTK4: Implement dw_window_from_id().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2274
diff changeset
4391 {
51cb73faab6e GTK4: Implement dw_window_from_id().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2274
diff changeset
4392 if(id == GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "_dw_id")))
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4393 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4394 retval = widget;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4395 widget = NULL;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4396 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4397 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4398 widget = gtk_widget_get_next_sibling(GTK_WIDGET(widget));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4399 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4400 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4401 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4402 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4403
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4404 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4405 * Adds text to an MLE box and returns the current point.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4406 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4407 * handle: Handle to the MLE to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4408 * buffer: Text buffer to be imported.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409 * startpoint: Point to start entering text.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4410 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4411 DW_FUNCTION_DEFINITION(dw_mle_import, unsigned int, HWND handle, const char *buffer, int startpoint)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4412 DW_FUNCTION_ADD_PARAM3(handle, buffer, startpoint)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4413 DW_FUNCTION_RETURN(dw_mle_import, unsigned int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4414 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, buffer, const char *, startpoint, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4415 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4416 unsigned int tmppoint = startpoint;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4417
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4418 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4419 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4420 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4421
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4422 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4423 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4424 GtkTextBuffer *tbuffer;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4425 GtkTextIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4426
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4427 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4428 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, startpoint);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4429 gtk_text_buffer_place_cursor(tbuffer, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4430 gtk_text_buffer_insert_at_cursor(tbuffer, buffer, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431 tmppoint = (startpoint > -1 ? startpoint : 0) + strlen(buffer);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4434 DW_FUNCTION_RETURN_THIS(tmppoint);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4438 * Grabs text from an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4439 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4440 * handle: Handle to the MLE to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4441 * buffer: Text buffer to be exported. MUST allow for trailing nul character.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4442 * startpoint: Point to start grabbing text.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4443 * length: Amount of text to be grabbed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4444 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4445 DW_FUNCTION_DEFINITION(dw_mle_export, void, HWND handle, char *buffer, int startpoint, int length)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4446 DW_FUNCTION_ADD_PARAM4(handle, buffer, startpoint, length)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4447 DW_FUNCTION_NO_RETURN(dw_mle_export)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4448 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, buffer, char *, startpoint, int, length, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4449 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4450 gchar *text;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4451
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4452 /* force the return value to nul in case the following tests fail */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4453 if(buffer)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4454 buffer[0] = '\0';
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4455 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4457 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4460 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4461 GtkTextBuffer *tbuffer;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462 GtkTextIter start, end;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4464 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4465 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4466 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4467 text = gtk_text_iter_get_text(&start, &end);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4468 if(text) /* Should this get freed? */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4469 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4470 if(buffer)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4471 strcpy(buffer, text);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4472 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4473 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4474 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4475 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4476 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4477
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4478 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4479 * Obtains information about an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4480 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4481 * handle: Handle to the MLE to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4482 * bytes: A pointer to a variable to return the total bytes.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4483 * lines: A pointer to a variable to return the number of lines.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4484 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4485 DW_FUNCTION_DEFINITION(dw_mle_get_size, void, HWND handle, unsigned long *bytes, unsigned long *lines)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4486 DW_FUNCTION_ADD_PARAM3(handle, bytes, lines)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4487 DW_FUNCTION_NO_RETURN(dw_mle_get_size)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4488 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, bytes, unsigned long *, lines, unsigned long *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4489 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4490 if(bytes)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4491 *bytes = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4492 if(lines)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4493 *lines = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4494
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4495 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4496 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4497 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4498
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 if(bytes)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4504 *bytes = gtk_text_buffer_get_char_count(buffer);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4505 if(lines)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506 *lines = gtk_text_buffer_get_line_count(buffer);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4507 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4508 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4509 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4511
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4512 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4513 * Deletes text from an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4514 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4515 * handle: Handle to the MLE to be deleted from.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4516 * startpoint: Point to start deleting text.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4517 * length: Amount of text to be deleted.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4518 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4519 DW_FUNCTION_DEFINITION(dw_mle_delete, void, HWND handle, int startpoint, int length)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4520 DW_FUNCTION_ADD_PARAM3(handle, startpoint, length)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4521 DW_FUNCTION_NO_RETURN(dw_mle_delete)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4522 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, startpoint, int, length, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4523 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4524 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4526 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4527
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4528 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4529 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4530 GtkTextBuffer *tbuffer;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4531 GtkTextIter start, end;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4532
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4533 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4534 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4536 gtk_text_buffer_delete(tbuffer, &start, &end);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4537 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4538 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4539 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4540 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4541
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4542 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4543 * Clears all text from an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4544 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4545 * handle: Handle to the MLE to be cleared.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4546 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4547 DW_FUNCTION_DEFINITION(dw_mle_clear, void, HWND handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4548 DW_FUNCTION_ADD_PARAM1(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4549 DW_FUNCTION_NO_RETURN(dw_mle_clear)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4550 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4551 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552 int length;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4553
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4554 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4559 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4560 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4562 length = -1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4563 gtk_text_buffer_set_text(buffer, "", length);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4566 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4568
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570 * Sets the visible line of an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4572 * handle: Handle to the MLE.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573 * line: Line to be visible.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4574 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4575 DW_FUNCTION_DEFINITION(dw_mle_set_visible, void, HWND handle, int line)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4576 DW_FUNCTION_ADD_PARAM2(handle, line)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4577 DW_FUNCTION_NO_RETURN(dw_mle_set_visible)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4578 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, line, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4579 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4580 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4581 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4582 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4583
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4584 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4585 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4586 GtkTextBuffer *tbuffer;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4587 GtkTextIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 GtkTextMark *mark = (GtkTextMark *)g_object_get_data(G_OBJECT(handle), "_dw_mark");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4589
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4590 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4591 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4592 gtk_text_iter_set_line(&iter, line);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4593 if(!mark)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4594 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4595 mark = gtk_text_buffer_create_mark(tbuffer, NULL, &iter, FALSE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4596 g_object_set_data(G_OBJECT(handle), "_dw_mark", (gpointer)mark);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4597 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4599 gtk_text_buffer_move_mark(tbuffer, mark, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(tmp), mark,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601 0, FALSE, 0, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4603 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4604 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4605 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4606
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4607 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4608 * Sets the editablity of an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4609 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4610 * handle: Handle to the MLE.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4611 * state: TRUE if it can be edited, FALSE for readonly.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4612 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4613 DW_FUNCTION_DEFINITION(dw_mle_set_editable, void, HWND handle, int state)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4614 DW_FUNCTION_ADD_PARAM2(handle, state)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4615 DW_FUNCTION_NO_RETURN(dw_mle_set_editable)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4616 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, state, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4617 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4619 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4620 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4622 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623 gtk_text_view_set_editable(GTK_TEXT_VIEW(tmp), state);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4624 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4625 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4626 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4627
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4628 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4629 * Sets the word wrap state of an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4630 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4631 * handle: Handle to the MLE.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4632 * state: TRUE if it wraps, FALSE if it doesn't.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4633 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4634 DW_FUNCTION_DEFINITION(dw_mle_set_word_wrap, void, HWND handle, int state)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4635 DW_FUNCTION_ADD_PARAM2(handle, state)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4636 DW_FUNCTION_NO_RETURN(dw_mle_set_word_wrap)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4637 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, state, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4643 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), state ? GTK_WRAP_WORD : GTK_WRAP_NONE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4646 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4647 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4648
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4649 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4650 * Sets the word auto complete state of an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4651 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4652 * handle: Handle to the MLE.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4653 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4654 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
4655 void API dw_mle_set_auto_complete(HWND handle, int state)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4656 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4657 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4658
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4660 * Sets the current cursor position of an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4661 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4662 * handle: Handle to the MLE to be positioned.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663 * point: Point to position cursor.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4665 DW_FUNCTION_DEFINITION(dw_mle_set_cursor, void, HWND handle, int point)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4666 DW_FUNCTION_ADD_PARAM2(handle, point)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4667 DW_FUNCTION_NO_RETURN(dw_mle_set_cursor)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4668 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, point, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4669 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4670 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4671 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4672 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4673
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4674 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4675 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4676 GtkTextBuffer *tbuffer;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4677 GtkTextIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4678 GtkTextMark *mark = (GtkTextMark *)g_object_get_data(G_OBJECT(handle), "_dw_mark");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4679
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4681 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4682 if(!mark)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4683 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4684 mark = gtk_text_buffer_create_mark(tbuffer, NULL, &iter, FALSE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 g_object_set_data(G_OBJECT(handle), "_dw_mark", (gpointer)mark);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4688 gtk_text_buffer_move_mark(tbuffer, mark, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4689 gtk_text_buffer_place_cursor(tbuffer, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(tmp), mark,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4691 0, FALSE, 0, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4692 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4693 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4694 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4695 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4698 * Finds text in an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4699 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700 * handle: Handle to the MLE to be cleared.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4701 * text: Text to search for.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4702 * point: Start point of search.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4703 * flags: Search specific flags.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4704 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4705 DW_FUNCTION_DEFINITION(dw_mle_search, int, HWND handle, const char *text, int point, DW_UNUSED(unsigned long flags))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4706 DW_FUNCTION_ADD_PARAM4(handle, text, point, flags)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4707 DW_FUNCTION_RETURN(dw_mle_search, int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4708 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, text, const char *, point, int, DW_UNUSED(flags), unsigned long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4709 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4710 int retval = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4711
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4712 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4713 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4714 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4715
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4716 if(tmp && GTK_IS_TEXT_VIEW(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4717 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4718 GtkTextBuffer *tbuffer;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4719 GtkTextIter iter, found;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4720
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4723 gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4724 retval = gtk_text_iter_get_offset(&found);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4727 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4728 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4729
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4730 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4731 * Stops redrawing of an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4732 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4733 * handle: Handle to the MLE to freeze.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4734 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
4735 void API dw_mle_freeze(HWND handle)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4736 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4737 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4739 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4740 * Resumes redrawing of an MLE box.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4741 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4742 * handle: Handle to the MLE to thaw.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
4744 void API dw_mle_thaw(HWND handle)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 /* Internal function to update the progress bar
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 * while in an indeterminate state.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751 gboolean _dw_update_progress_bar(gpointer data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753 if(g_object_get_data(G_OBJECT(data), "_dw_alive"))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4755 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(data));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756 return TRUE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4757 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4758 return FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762 * Sets the percent bar position.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 * handle: Handle to the percent bar to be set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 * position: Position of the percent bar withing the range.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4767 DW_FUNCTION_DEFINITION(dw_percent_set_pos, void, HWND handle, unsigned int position)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4768 DW_FUNCTION_ADD_PARAM2(handle, position)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4769 DW_FUNCTION_NO_RETURN(dw_percent_set_pos)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4770 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, unsigned int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 if(position == DW_PERCENT_INDETERMINATE)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 /* Check if we are indeterminate already */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775 if(!g_object_get_data(G_OBJECT(handle), "_dw_alive"))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777 /* If not become indeterminate... and start a timer to continue */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(handle));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 g_object_set_data(G_OBJECT(handle), "_dw_alive", GINT_TO_POINTER(1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4780 g_timeout_add(100, (GSourceFunc)_dw_update_progress_bar, (gpointer)handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4781 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4782 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4783 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4784 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785 /* Cancel the existing timer if one is there */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4786 g_object_set_data(G_OBJECT(handle), "_dw_alive", NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4787 /* Set the position like normal */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4788 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(handle), (gfloat)position/100);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4789 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
4790 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4791 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 * Returns the position of the slider.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4796 * handle: Handle to the slider to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4798 DW_FUNCTION_DEFINITION(dw_slider_get_pos, unsigned int, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4799 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4800 DW_FUNCTION_RETURN(dw_slider_get_pos, unsigned int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4801 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4803 int val = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4804 GtkAdjustment *adjustment;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4805
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4806 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4807 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4808 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4809 if(adjustment)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4810 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4811 int max = _dw_round_value(gtk_adjustment_get_upper(adjustment)) - 1;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4812 int thisval = _dw_round_value(gtk_adjustment_get_value(adjustment));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4813
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4814 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_VERTICAL)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4815 val = max - thisval;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4816 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4817 val = thisval;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4818 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4819 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4820 DW_FUNCTION_RETURN_THIS(val);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4822
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 * Sets the slider position.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826 * handle: Handle to the slider to be set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827 * position: Position of the slider withing the range.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4829 DW_FUNCTION_DEFINITION(dw_slider_set_pos, void, HWND handle, unsigned int position)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4830 DW_FUNCTION_ADD_PARAM2(handle, position)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4831 DW_FUNCTION_NO_RETURN(dw_slider_set_pos)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4832 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, unsigned int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4833 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 GtkAdjustment *adjustment;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4836 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4837 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4838 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4839 if(adjustment)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4840 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4841 int max = _dw_round_value(gtk_adjustment_get_upper(adjustment)) - 1;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4842
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4843 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_VERTICAL)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4844 gtk_adjustment_set_value(adjustment, (gfloat)(max - position));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4845 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4846 gtk_adjustment_set_value(adjustment, (gfloat)position);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4847 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4848 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4849 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4851
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4852 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4853 * Returns the position of the scrollbar.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4854 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4855 * handle: Handle to the scrollbar to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4856 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4857 DW_FUNCTION_DEFINITION(dw_scrollbar_get_pos, unsigned int, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4858 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4859 DW_FUNCTION_RETURN(dw_scrollbar_get_pos, unsigned int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4860 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4861 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4862 int val = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4863 GtkAdjustment *adjustment;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4864
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4865 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4866 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4867 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4868 if(adjustment)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4869 val = _dw_round_value(gtk_adjustment_get_value(adjustment));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4870 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4871 DW_FUNCTION_RETURN_THIS(val);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4872 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4873
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4874 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 * Sets the scrollbar position.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877 * handle: Handle to the scrollbar to be set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4878 * position: Position of the scrollbar withing the range.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4880 DW_FUNCTION_DEFINITION(dw_scrollbar_set_pos, void, HWND handle, unsigned int position)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4881 DW_FUNCTION_ADD_PARAM2(handle, position)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4882 DW_FUNCTION_NO_RETURN(dw_scrollbar_set_pos)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4883 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, unsigned int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4884
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4886 GtkAdjustment *adjustment;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4887
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4888 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4889 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4890 if((adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment")))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4891 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4892 g_object_set_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(1));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4893 gtk_adjustment_set_value(adjustment, (gfloat)position);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4894 g_object_set_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(0));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4895 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4896 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4897 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4898 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4899
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4900 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4901 * Sets the scrollbar range.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4902 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4903 * handle: Handle to the scrollbar to be set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4904 * range: Maximum range value.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4905 * visible: Visible area relative to the range.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4906 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4907 DW_FUNCTION_DEFINITION(dw_scrollbar_set_range, void, HWND handle, unsigned int range, unsigned int visible)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4908 DW_FUNCTION_ADD_PARAM3(handle, range, visible)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4909 DW_FUNCTION_NO_RETURN(dw_scrollbar_set_range)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4910 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, range, unsigned int, visible, unsigned int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4911 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4912 GtkAdjustment *adjustment;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4913
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4914 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4915 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4916 if((adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment")))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4917 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4918 gtk_adjustment_set_upper(adjustment, (gdouble)range);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4919 gtk_adjustment_set_page_increment(adjustment,(gdouble)visible);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4920 gtk_adjustment_set_page_size(adjustment, (gdouble)visible);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4921 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4922 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4923 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4924 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4925
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4927 * Sets the spinbutton value.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4928 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4929 * handle: Handle to the spinbutton to be set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 * position: Current value of the spinbutton.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4931 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4932 DW_FUNCTION_DEFINITION(dw_spinbutton_set_pos, void, HWND handle, long position)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4933 DW_FUNCTION_ADD_PARAM2(handle, position)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4934 DW_FUNCTION_NO_RETURN(dw_spinbutton_set_pos)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4935 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4936 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4937 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4938 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4939 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4940
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4941 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4942 * Sets the spinbutton limits.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 * handle: Handle to the spinbutton to be set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945 * position: Current value of the spinbutton.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4946 * position: Current value of the spinbutton.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4948 DW_FUNCTION_DEFINITION(dw_spinbutton_set_limits, void, HWND handle, long upper, long lower)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4949 DW_FUNCTION_ADD_PARAM3(handle, upper, lower)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4950 DW_FUNCTION_NO_RETURN(dw_spinbutton_set_limits)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4951 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, upper, long, lower, long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4953 long curval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4954 GtkAdjustment *adj;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4955
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4956 curval = dw_spinbutton_get_pos(handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4957 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4958 gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(handle), adj);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4959 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4960 * Set our internal relationships between the adjustment and the spinbutton
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4961 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4962 g_object_set_data(G_OBJECT(handle), "_dw_adjustment", (gpointer)adj);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4963 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)handle);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4964 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4965 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4966
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4967 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4968 * Sets the entryfield character limit.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4969 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4970 * handle: Handle to the spinbutton to be set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4971 * limit: Number of characters the entryfield will take.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4972 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4973 DW_FUNCTION_DEFINITION(dw_entryfield_set_limit, void, HWND handle, ULONG limit)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4974 DW_FUNCTION_ADD_PARAM2(handle, limit)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4975 DW_FUNCTION_NO_RETURN(dw_entryfield_set_limit)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4976 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, limit, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4977 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978 gtk_entry_set_max_length(GTK_ENTRY(handle), limit);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4979 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 * Returns the current value of the spinbutton.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 * handle: Handle to the spinbutton to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4987 DW_FUNCTION_DEFINITION(dw_spinbutton_get_pos, long, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4988 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4989 DW_FUNCTION_RETURN(dw_spinbutton_get_pos, long)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4990 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4991 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4992 long retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
4993 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997 * Returns the state of the checkbox.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4998 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4999 * handle: Handle to the checkbox to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5000 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5001 DW_FUNCTION_DEFINITION(dw_checkbox_get, int, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5002 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5003 DW_FUNCTION_RETURN(dw_checkbox_get, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5004 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5005 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5006 int retval = 0;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5007
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5008 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5009 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5010 if(GTK_IS_TOGGLE_BUTTON(handle))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5011 retval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(handle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5012 retval = gtk_check_button_get_active(GTK_CHECK_BUTTON(handle));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5013 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5014 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5015 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5016
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 * Sets the state of the checkbox.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 * handle: Handle to the checkbox to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021 * value: TRUE for checked, FALSE for unchecked.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5023 DW_FUNCTION_DEFINITION(dw_checkbox_set, void, HWND handle, int value)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5024 DW_FUNCTION_ADD_PARAM2(handle, value)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5025 DW_FUNCTION_NO_RETURN(dw_checkbox_set)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5026 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, value, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5027 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5028 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5029 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5030 if(GTK_IS_TOGGLE_BUTTON(handle))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5031 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5032 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5033 gtk_check_button_set_active(GTK_CHECK_BUTTON(handle), value);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5034 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5035 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5036 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5037
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5038 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5039 * Inserts an item into a tree window (widget) after another item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5040 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5041 * handle: Handle to the tree to be inserted.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5042 * item: Handle to the item to be positioned after.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5043 * title: The text title of the entry.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5044 * icon: Handle to coresponding icon.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5045 * parent: Parent handle or 0 if root.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5046 * itemdata: Item specific data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5047 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5048 DW_FUNCTION_DEFINITION(dw_tree_insert_after, HTREEITEM, HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5049 DW_FUNCTION_ADD_PARAM6(handle, item, title, icon, parent, itemdata)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5050 DW_FUNCTION_RETURN(dw_tree_insert_after, HTREEITEM)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5051 DW_FUNCTION_RESTORE_PARAM6(handle, HWND, item, HTREEITEM, title, char *, icon, HICN, parent, HTREEITEM, itemdata, void *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 GtkTreeIter *iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 GdkPixbuf *pixbuf;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057 HTREEITEM retval = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5059 if(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5060 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5061 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5062 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5063 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5064 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5065 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5066
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5067 pixbuf = _dw_find_pixbuf(icon, NULL, NULL);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5068
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5069 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5070 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5071 retval = (HTREEITEM)iter;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5072 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5073 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5074 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5077 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5078 * Inserts an item into a tree window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5080 * handle: Handle to the tree to be inserted.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5081 * title: The text title of the entry.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5082 * icon: Handle to coresponding icon.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5083 * parent: Parent handle or 0 if root.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084 * itemdata: Item specific data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5086 DW_FUNCTION_DEFINITION(dw_tree_insert, HTREEITEM, HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5087 DW_FUNCTION_ADD_PARAM5(handle, title, icon, parent, itemdata)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5088 DW_FUNCTION_RETURN(dw_tree_insert, HTREEITEM)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5089 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, title, char *, icon, HICN, parent, HTREEITEM, itemdata, void *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 GtkTreeIter *iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5094 GdkPixbuf *pixbuf;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095 HTREEITEM retval = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5096
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5097 if(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5098 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5099 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5100 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5101 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5102 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5103 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5104
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5105 pixbuf = _dw_find_pixbuf(icon, NULL, NULL);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5106
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5107 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5108 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5109 retval = (HTREEITEM)iter;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5110 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5111 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5112 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 * Sets the text and icon of an item in a tree window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 * handle: Handle to the tree containing the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 * item: Handle of the item to be modified.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 * title: The text title of the entry.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121 * icon: Handle to coresponding icon.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5122 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5123 DW_FUNCTION_DEFINITION(dw_tree_item_change, void, HWND handle, HTREEITEM item, const char *title, HICN icon)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5124 DW_FUNCTION_ADD_PARAM4(handle, item, title, icon)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5125 DW_FUNCTION_NO_RETURN(dw_tree_item_change)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5126 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, item, HTREEITEM, title, char *, icon, HICN)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5127 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5128 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5129 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130 GdkPixbuf *pixbuf;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5132 if(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5133 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5134 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5135 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5136 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5137 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5138 pixbuf = _dw_find_pixbuf(icon, NULL, NULL);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5139
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5140 gtk_tree_store_set(store, (GtkTreeIter *)item, 0, title, 1, pixbuf, -1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5141 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5142 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5143 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5144 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 * Sets the item data of a tree item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5148 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5149 * handle: Handle to the tree containing the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5150 * item: Handle of the item to be modified.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5151 * itemdata: User defined data to be associated with item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5152 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5153 DW_FUNCTION_DEFINITION(dw_tree_item_set_data, void, HWND handle, HTREEITEM item, void *itemdata)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5154 DW_FUNCTION_ADD_PARAM3(handle, item, itemdata)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5155 DW_FUNCTION_NO_RETURN(dw_tree_item_set_data)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5156 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(handle), HWND, item, HTREEITEM, itemdata, void *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5158 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5161 if(handle && item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5162 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5163 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5164 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5165 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5166 gtk_tree_store_set(store, (GtkTreeIter *)item, 2, itemdata, -1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5167 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5168 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5169 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5170
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5171 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5172 * Gets the text an item in a tree window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5173 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5174 * handle: Handle to the tree containing the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5175 * item: Handle of the item to be modified.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5176 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5177 DW_FUNCTION_DEFINITION(dw_tree_get_title, char *, HWND handle, HTREEITEM item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5178 DW_FUNCTION_ADD_PARAM2(handle, item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5179 DW_FUNCTION_RETURN(dw_tree_get_title, char *)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5180 DW_FUNCTION_RESTORE_PARAM2(DW_UNUSED(handle), HWND, item, HTREEITEM)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5181 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5182 char *text = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5183 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5184 GtkTreeModel *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5185
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5186 if(handle && item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5187 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5188 tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5189
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5190 if(tree && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5191 (store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5192 gtk_tree_model_get(store, (GtkTreeIter *)item, _DW_DATA_TYPE_STRING, &text, -1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5193 if(text)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5194 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5195 char *temp = text;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5196 text = strdup(temp);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5197 g_free(temp);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5198 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5199 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5200 DW_FUNCTION_RETURN_THIS(text);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5201 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5202
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5203 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5204 * Gets the text an item in a tree window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5205 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5206 * handle: Handle to the tree containing the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5207 * item: Handle of the item to be modified.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5208 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5209 DW_FUNCTION_DEFINITION(dw_tree_get_parent, HTREEITEM, HWND handle, HTREEITEM item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5210 DW_FUNCTION_ADD_PARAM2(handle, item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5211 DW_FUNCTION_RETURN(dw_tree_get_parent, HTREEITEM)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5212 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5213 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214 HTREEITEM parent = (HTREEITEM)0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5215 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 GtkTreeModel *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5218 if(handle && item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5219 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5220 tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5221
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5222 if(tree && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5223 (store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5224 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5225 GtkTreeIter iter;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5226
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5227 if(gtk_tree_model_iter_parent(store, &iter, (GtkTreeIter *)item))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5228 gtk_tree_model_get(store, &iter, 3, &parent, -1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5229 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5230 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5231 DW_FUNCTION_RETURN_THIS(parent);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 * Gets the item data of a tree item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 * handle: Handle to the tree containing the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5238 * item: Handle of the item to be modified.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5240 DW_FUNCTION_DEFINITION(dw_tree_item_get_data, void *, HWND handle, HTREEITEM item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5241 DW_FUNCTION_ADD_PARAM2(handle, item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5242 DW_FUNCTION_RETURN(dw_tree_item_get_data, void *)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5243 DW_FUNCTION_RESTORE_PARAM2(DW_UNUSED(handle), HWND, item, HTREEITEM)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5244 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5245 void *ret = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5246 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5247 GtkTreeModel *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5248
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5249 if(handle && item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5250 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5251 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5252 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5253 (store = (GtkTreeModel *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5254 gtk_tree_model_get(store, (GtkTreeIter *)item, 2, &ret, -1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5255 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5256 DW_FUNCTION_RETURN_THIS(ret);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5257 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5258
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5259 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5260 * Sets this item as the active selection.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5261 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5262 * handle: Handle to the tree window (widget) to be selected.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5263 * item: Handle to the item to be selected.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5264 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5265 DW_FUNCTION_DEFINITION(dw_tree_item_select, void, HWND handle, HTREEITEM item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5266 DW_FUNCTION_ADD_PARAM2(handle, item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5267 DW_FUNCTION_NO_RETURN(dw_tree_item_select)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5268 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5269 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5270 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5271 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5273 if(handle && item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5274 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5275 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5276 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5277 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5278 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5279 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5280 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5281
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5282 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree), path, NULL, FALSE);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5283 gtk_tree_selection_select_iter(sel, (GtkTreeIter *)item);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5284 gtk_tree_path_free(path);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5285 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5286 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5287 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5288 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5289
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5290 static void _dw_recursive_free(GtkTreeModel *store, GtkTreeIter parent)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5291 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5292 void *data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5293 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5294
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5295 gtk_tree_model_get(store, &parent, 3, &data, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296 if(data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5297 free(data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 gtk_tree_store_set(GTK_TREE_STORE(store), &parent, 3, NULL, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5299
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5300 if(gtk_tree_model_iter_children(store, &iter, &parent))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5302 do {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 _dw_recursive_free(GTK_TREE_MODEL(store), iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5305 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5306 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5307
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5309 * Removes all nodes from a tree.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5310 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5311 * handle: Handle to the window (widget) to be cleared.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5312 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5313 DW_FUNCTION_DEFINITION(dw_tree_clear, void, HWND handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5314 DW_FUNCTION_ADD_PARAM1(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5315 DW_FUNCTION_NO_RETURN(dw_tree_clear)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5316 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5317 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5318 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5319 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5320
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5321 if(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5322 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5323 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5324 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5325 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5326 {
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5327 GtkTreeIter iter;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5328
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5329 if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5330 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5331 do {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5332 _dw_recursive_free(GTK_TREE_MODEL(store), iter);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5333 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5334 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5335 gtk_tree_store_clear(store);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5337 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5338 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 * Expands a node on a tree.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344 * handle: Handle to the tree window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 * item: Handle to node to be expanded.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5347 DW_FUNCTION_DEFINITION(dw_tree_item_expand, void, HWND handle, HTREEITEM item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5348 DW_FUNCTION_ADD_PARAM2(handle, item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5349 DW_FUNCTION_NO_RETURN(dw_tree_item_expand)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5350 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5355 if(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5356 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5357 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5358 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5359 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5360 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5361 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5362 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path, FALSE);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5363 gtk_tree_path_free(path);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5364 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5365 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5366 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5369 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5370 * Collapses a node on a tree.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5372 * handle: Handle to the tree window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 * item: Handle to node to be collapsed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5375 DW_FUNCTION_DEFINITION(dw_tree_item_collapse, void, HWND handle, HTREEITEM item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5376 DW_FUNCTION_ADD_PARAM2(handle, item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5377 DW_FUNCTION_NO_RETURN(dw_tree_item_collapse)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5378 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5383 if(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5384 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5385 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5386 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5387 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5388 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5389 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5390 gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree), path);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5391 gtk_tree_path_free(path);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5392 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5393 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5394 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 * Removes a node from a tree.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5399 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 * handle: Handle to the window (widget) to be cleared.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 * item: Handle to node to be deleted.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5403 DW_FUNCTION_DEFINITION(dw_tree_item_delete, void, HWND handle, HTREEITEM item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5404 DW_FUNCTION_ADD_PARAM2(handle, item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5405 DW_FUNCTION_NO_RETURN(dw_tree_item_delete)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5406 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 GtkTreeStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5411 if(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5412 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5413 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5414 && GTK_IS_TREE_VIEW(tree) &&
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5415 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5416 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5417 gtk_tree_store_remove(store, (GtkTreeIter *)item);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5418 free(item);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5419 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5420 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5421 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5423
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 #define _DW_CONTAINER_STORE_EXTRA 2
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5425
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5426 static int _dw_container_setup_int(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5427 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5428 int z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5429 char numbuf[25] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 GtkWidget *tree;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431 GtkListStore *store;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 GtkTreeViewColumn *col;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433 GtkCellRenderer *rend;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 GtkTreeSelection *sel;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435 GType *array = calloc(count + _DW_CONTAINER_STORE_EXTRA + 1, sizeof(GType));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5436
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5437 /* Save some of the info so it is easily accessible */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438 g_object_set_data(G_OBJECT(handle), "_dw_cont_columns", GINT_TO_POINTER(count));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5439 g_object_set_data(G_OBJECT(handle), "_dw_cont_extra", GINT_TO_POINTER(extra));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5440
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5441 /* First param is row title */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5442 array[0] = G_TYPE_STRING;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5443 /* Second param is row data */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5444 array[1] = G_TYPE_POINTER;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5445 array[2] = G_TYPE_POINTER;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446 /* First loop... create array to create the store */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5447 for(z=0;z<count;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 if(z == 0 && flags[z] & DW_CFA_STRINGANDICON)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 array[_DW_CONTAINER_STORE_EXTRA] = GDK_TYPE_PIXBUF;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 array[_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_STRING;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 else if(flags[z] & DW_CFA_BITMAPORICON)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 array[z+_DW_CONTAINER_STORE_EXTRA+1] = GDK_TYPE_PIXBUF;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458 else if(flags[z] & DW_CFA_STRING)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460 array[z+_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_STRING;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5461 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 else if(flags[z] & DW_CFA_ULONG)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5463 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5464 array[z+_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_ULONG;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5465 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5466 else if(flags[z] & DW_CFA_TIME)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5467 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5468 array[z+_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_STRING;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5469 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5470 else if(flags[z] & DW_CFA_DATE)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5471 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5472 array[z+_DW_CONTAINER_STORE_EXTRA+1] = G_TYPE_STRING;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5473 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5475 /* Create the store and then the tree */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5476 store = gtk_list_store_newv(count + _DW_CONTAINER_STORE_EXTRA + 1, array);
2287
680212c356e3 GTK4: Refactor tree and fix DW_SIGNAL_ITEM_CONTEXT signals on tree view
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2286
diff changeset
5477 tree = _dw_tree_view_setup(handle, GTK_TREE_MODEL(store));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5478 g_object_set_data(G_OBJECT(tree), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479 /* Second loop... create the columns */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480 for(z=0;z<count;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5482 snprintf(numbuf, 24, "_dw_cont_col%d", z);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5483 g_object_set_data(G_OBJECT(tree), numbuf, GINT_TO_POINTER(flags[z]));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5484 col = gtk_tree_view_column_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5485 rend = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5486 void **params = calloc(sizeof(void *), 3);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5487
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5488 if(z == 0 && flags[z] & DW_CFA_STRINGANDICON)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5489 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5490 rend = gtk_cell_renderer_pixbuf_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5491 gtk_tree_view_column_pack_start(col, rend, FALSE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5492 gtk_tree_view_column_add_attribute(col, rend, "pixbuf", _DW_CONTAINER_STORE_EXTRA);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5493 rend = gtk_cell_renderer_text_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5494 gtk_tree_view_column_pack_start(col, rend, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5495 gtk_tree_view_column_add_attribute(col, rend, "text", _DW_CONTAINER_STORE_EXTRA+1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5496 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5497 else if(flags[z] & DW_CFA_BITMAPORICON)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5498 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5499 rend = gtk_cell_renderer_pixbuf_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5500 gtk_tree_view_column_pack_start(col, rend, FALSE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5501 gtk_tree_view_column_add_attribute(col, rend, "pixbuf", z+_DW_CONTAINER_STORE_EXTRA+1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5502 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5503 else if(flags[z] & DW_CFA_STRING)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5505 rend = gtk_cell_renderer_text_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506 gtk_tree_view_column_pack_start(col, rend, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 gtk_tree_view_column_set_resizable(col, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 else if(flags[z] & DW_CFA_ULONG)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512 rend = gtk_cell_renderer_text_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513 gtk_tree_view_column_pack_start(col, rend, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5514 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5515 gtk_tree_view_column_set_resizable(col, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5516 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5517 else if(flags[z] & DW_CFA_TIME)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5518 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5519 rend = gtk_cell_renderer_text_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5520 gtk_tree_view_column_pack_start(col, rend, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5521 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5522 gtk_tree_view_column_set_resizable(col, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5523 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5524 else if(flags[z] & DW_CFA_DATE)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5525 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5526 rend = gtk_cell_renderer_text_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5527 gtk_tree_view_column_pack_start(col, rend, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5528 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5529 gtk_tree_view_column_set_resizable(col, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5530 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5531 g_object_set_data(G_OBJECT(col), "_dw_column", GINT_TO_POINTER(z));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5532 params[2] = tree;
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
5533 g_signal_connect_data(G_OBJECT(col), "clicked", G_CALLBACK(_dw_column_click_event), (gpointer)params, _dw_signal_disconnect, 0);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5534 gtk_tree_view_column_set_title(col, titles[z]);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5535 if(flags[z] & DW_CFA_RIGHT)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5536 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5537 gtk_tree_view_column_set_alignment(col, 1.0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5538 if(rend)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5539 gtk_cell_renderer_set_alignment(rend, 1.0, 0.5);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5540 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5541 else if(flags[z] & DW_CFA_CENTER)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5542 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5543 gtk_tree_view_column_set_alignment(col, 0.5);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5544 if(rend)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5545 gtk_cell_renderer_set_alignment(rend, 0.5, 0.5);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5546 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5547 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5548 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5549 /* Finish up */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5550 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5551 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tree), TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5552 gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tree), TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5553 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554 if(g_object_get_data(G_OBJECT(handle), "_dw_multi_sel"))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
5558 gtk_widget_set_visible(tree, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5559 free(array);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561 dw_window_set_font(handle, _DWDefaultFont);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5563 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5565 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5566 * Sets up the container columns.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5567 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5568 * handle: Handle to the container to be configured.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5569 * flags: An array of unsigned longs with column flags.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5570 * titles: An array of strings with column text titles.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5571 * count: The number of columns (this should match the arrays).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5572 * separator: The column number that contains the main separator.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5573 * (this item may only be used in OS/2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5574 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5575 DW_FUNCTION_DEFINITION(dw_container_setup, int, HWND handle, unsigned long *flags, char **titles, int count, int separator)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5576 DW_FUNCTION_ADD_PARAM5(handle, flags, titles, count, separator)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5577 DW_FUNCTION_RETURN(dw_container_setup, int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5578 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, flags, unsigned long *, titles, char **, count, int, DW_UNUSED(separator), int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5579 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5580 int retval = _dw_container_setup_int(handle, flags, titles, count, separator, 0);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5581 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 * Configures the main filesystem columnn title for localization.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587 * handle: Handle to the container to be configured.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 * title: The title to be displayed in the main column.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5589 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 void API dw_filesystem_set_column_title(HWND handle, const char *title)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5592 char *newtitle = strdup(title ? title : "");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594 g_object_set_data(G_OBJECT(handle), "_dw_coltitle", newtitle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5596
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5597 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5598 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5599 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5600 * handle: Handle to the container to be configured.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5601 * flags: An array of unsigned longs with column flags.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5602 * titles: An array of strings with column text titles.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5603 * count: The number of columns (this should match the arrays).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5604 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5605 DW_FUNCTION_DEFINITION(dw_filesystem_setup, int, HWND handle, unsigned long *flags, char **titles, int count)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5606 DW_FUNCTION_ADD_PARAM4(handle, flags, titles, count)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5607 DW_FUNCTION_RETURN(dw_filesystem_setup, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5608 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, flags, unsigned long *, titles, char **, count, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5609 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5610 char **newtitles = malloc(sizeof(char *) * (count + 1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5611 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5612 char *coltitle = (char *)g_object_get_data(G_OBJECT(handle), "_dw_coltitle");
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5613 int retval;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5614
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5615 newtitles[0] = coltitle ? coltitle : "Filename";
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5616 newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5617
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5618 memcpy(&newtitles[1], titles, sizeof(char *) * count);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5619 memcpy(&newflags[1], flags, sizeof(unsigned long) * count);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5620
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5621 retval = _dw_container_setup_int(handle, newflags, newtitles, count + 1, 1, 1);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5622
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5623 if(coltitle)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5624 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5625 g_object_set_data(G_OBJECT(handle), "_dw_coltitle", NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5626 free(coltitle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5627 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5628 if(newtitles)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5629 free(newtitles);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5630 if(newflags)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5631 free(newflags);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
5632 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5634
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5635 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5636 * Obtains an icon from a module (or header in GTK).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5638 * module: Handle to module (DLL) in OS/2 and Windows.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5639 * id: A unsigned long id int the resources on OS/2 and
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5640 * Windows, on GTK this is converted to a pointer
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 * to an embedded XPM.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5642 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
5643 HICN API dw_icon_load(unsigned long module, unsigned long id)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5644 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5645 return (HICN)id;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5646 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5647
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5648 /* Internal function to keep HICNs from getting too big */
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5649 GdkPixbuf *_dw_icon_resize(GdkPixbuf *ret)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5650 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5651 if(ret)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5652 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5653 int pwidth = gdk_pixbuf_get_width(ret);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 int pheight = gdk_pixbuf_get_height(ret);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5656 if(pwidth > 24 || pheight > 24)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5657 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5658 GdkPixbuf *orig = ret;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5659 ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5660 g_object_unref(G_OBJECT(orig));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5661 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5662 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5663 return ret;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5664 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5665
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5666 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5667 * Obtains an icon from a file.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5669 * filename: Name of the file, omit extention to have
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5670 * DW pick the appropriate file extension.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5671 * (ICO on OS/2 or Windows, XPM on Unix)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5672 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5673 HICN API dw_icon_load_from_file(const char *filename)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5674 {
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5675 HICN retval = 0;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5676
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5677 if(filename && *filename)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5678 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5679 char *file = alloca(strlen(filename) + 6);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5680
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5681 strcpy(file, filename);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5682
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5683 /* check if we can read from this file (it exists and read permission) */
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5684 if(access(file, 04) != 0)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5685 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5686 int i = 0;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5687
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5688 /* Try with various extentions */
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5689 while(_dw_image_exts[i] && !retval)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5690 {
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5691 strcpy(file, filename);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5692 strcat(file, _dw_image_exts[i]);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5693 if(access(file, 04) == 0)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5694 retval = _dw_icon_resize(gdk_pixbuf_new_from_file(file, NULL));
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5695 i++;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 }
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5698 else
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5699 retval = _dw_icon_resize(gdk_pixbuf_new_from_file(file, NULL));
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5700 }
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5701 return retval;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5702 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5703
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5704 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5705 * Obtains an icon from data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5706 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5707 * data: Source of data for image.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5708 * len: length of data
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5709 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5710 HICN API dw_icon_load_from_data(const char *data, int len)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5711 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5712 int fd, written = -1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5713 char template[] = "/tmp/dwiconXXXXXX";
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5714 HICN ret = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5715
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5717 * A real hack; create a temporary file and write the contents
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5718 * of the data to the file
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5719 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5720 if((fd = mkstemp(template)) != -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5721 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5722 written = write(fd, data, len);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5723 close(fd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5724 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5725 /* Bail if we couldn't write full file */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5726 if(fd == -1 || written != len)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5727 return 0;
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
5728 ret = _dw_icon_resize(gdk_pixbuf_new_from_file(template, NULL));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 unlink(template);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5730 return ret;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5731 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5732
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 * Frees a loaded resource in OS/2 and Windows.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 * handle: Handle to icon returned by dw_icon_load().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
5738 void API dw_icon_free(HICN handle)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 int iicon = GPOINTER_TO_INT(handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 if(iicon > 65535)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5744 g_object_unref(handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5746 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5747
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749 * Allocates memory used to populate a container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5751 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5752 * rowcount: The number of items to be populated.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5753 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5754 DW_FUNCTION_DEFINITION(dw_container_alloc, void *, HWND handle, int rowcount)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5755 DW_FUNCTION_ADD_PARAM2(handle, rowcount)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5756 DW_FUNCTION_RETURN(dw_container_alloc, void *)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5757 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, rowcount, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759 int z, prevrowcount = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5762
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5764
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5766 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5767 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5768
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5769 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5771 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5772
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5773 prevrowcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5774
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5775 for(z=0;z<rowcount;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5776 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5777 gtk_list_store_append(store, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5778 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5779 g_object_set_data(G_OBJECT(cont), "_dw_insertpos", GINT_TO_POINTER(prevrowcount));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5780 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(rowcount + prevrowcount));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5781 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5782 DW_FUNCTION_RETURN_THIS(cont);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5783 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5784
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5785 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5786 * Internal representation of dw_container_set_item() extracted so we can pass
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5787 * two data pointers; icon and text for dw_filesystem_set_item().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5788 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5789 void _dw_container_set_item_int(HWND handle, void *pointer, int column, int row, void *data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5790 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5791 char numbuf[25] = {0}, textbuffer[101] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5792 int flag = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5793 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5794 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5795
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5796 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5800 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5802 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5804 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5805
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5806 snprintf(numbuf, 24, "_dw_cont_col%d", column);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5807 flag = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), numbuf));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5808 if(pointer)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5809 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5810 row += GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_insertpos"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5811 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5812
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5813 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, row))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5814 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5815 if(flag & DW_CFA_STRINGANDICON)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5816 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5817 void **thisdata = (void **)data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5818 HICN hicon = data ? *((HICN *)thisdata[0]) : 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5819 char *tmp = data ? (char *)thisdata[1] : NULL;
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
5820 GdkPixbuf *pixbuf = hicon ? _dw_find_pixbuf(hicon, NULL, NULL) : NULL;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5821
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5822 gtk_list_store_set(store, &iter, _DW_CONTAINER_STORE_EXTRA, pixbuf, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5823 gtk_list_store_set(store, &iter, _DW_CONTAINER_STORE_EXTRA + 1, tmp, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5824 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5825 else if(flag & DW_CFA_BITMAPORICON)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5826 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5827 HICN hicon = data ? *((HICN *)data) : 0;
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
5828 GdkPixbuf *pixbuf = hicon ? _dw_find_pixbuf(hicon, NULL, NULL) : NULL;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5829
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5830 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, pixbuf, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5831 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5832 else if(flag & DW_CFA_STRING)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5833 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5834 char *tmp = data ? *((char **)data) : NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5835 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, tmp, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5836 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837 else if(flag & DW_CFA_ULONG)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 ULONG tmp = data ? *((ULONG *)data): 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, tmp, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843 else if(flag & DW_CFA_DATE)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5845 if(data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5846 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5847 struct tm curtm;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5848 CDATE cdate = *((CDATE *)data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5849
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5850 memset( &curtm, 0, sizeof(curtm) );
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5851 curtm.tm_mday = cdate.day;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5852 curtm.tm_mon = cdate.month - 1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5853 curtm.tm_year = cdate.year - 1900;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5854
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5855 strftime(textbuffer, 100, "%x", &curtm);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5856 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5857 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, textbuffer, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5858 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5859 else if(flag & DW_CFA_TIME)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5860 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5861 if(data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5862 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5863 struct tm curtm;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5864 CTIME ctime = *((CTIME *)data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5865
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5866 memset( &curtm, 0, sizeof(curtm) );
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5867 curtm.tm_hour = ctime.hours;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5868 curtm.tm_min = ctime.minutes;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5869 curtm.tm_sec = ctime.seconds;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5871 strftime(textbuffer, 100, "%X", &curtm);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5873 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, textbuffer, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5875 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5876 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5877 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5878
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5880 * Sets an item in specified row and column to the given data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5881 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5882 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5883 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5884 * column: Zero based column of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5885 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5886 * data: Pointer to the data to be added.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5887 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5888 DW_FUNCTION_DEFINITION(dw_container_set_item, void, HWND handle, void *pointer, int column, int row, void *data)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5889 DW_FUNCTION_ADD_PARAM5(handle, pointer, column, row, data)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5890 DW_FUNCTION_NO_RETURN(dw_container_set_item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5891 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pointer, void *, column, int, row, int, data, void *)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5892 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5893 _dw_container_set_item_int(handle, pointer, column, row, data);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5894 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5895 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5896
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5897 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5898 * Changes an existing item in specified row and column to the given data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5899 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5900 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5901 * column: Zero based column of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5902 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5903 * data: Pointer to the data to be added.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5904 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5905 DW_FUNCTION_DEFINITION(dw_container_change_item, void, HWND handle, int column, int row, void *data)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5906 DW_FUNCTION_ADD_PARAM4(handle, column, row, data)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5907 DW_FUNCTION_NO_RETURN(dw_container_change_item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5908 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, column, int, row, int, data, void *)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5909 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5910 _dw_container_set_item_int(handle, NULL, column, row, data);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5911 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5912 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915 * Changes an existing item in specified row and column to the given data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5917 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918 * column: Zero based column of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 * data: Pointer to the data to be added.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5922 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 dw_filesystem_set_item(handle, NULL, column, row, data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5926
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5927 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928 * Changes an item in specified row and column to the given data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5929 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5930 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5931 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5932 * column: Zero based column of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5933 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5934 * data: Pointer to the data to be added.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5935 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5936 void API dw_filesystem_change_file(HWND handle, int row, const char *filename, HICN icon)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5937 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938 dw_filesystem_set_file(handle, NULL, row, filename, icon);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942 * Sets an item in specified row and column to the given data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5946 * column: Zero based column of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 * data: Pointer to the data to be added.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5949 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5950 DW_FUNCTION_DEFINITION(dw_filesystem_set_file, void, HWND handle, void *pointer, int row, const char *filename, HICN icon)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5951 DW_FUNCTION_ADD_PARAM5(handle, pointer, row, filename, icon)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5952 DW_FUNCTION_NO_RETURN(dw_filesystem_set_file)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5953 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pointer, void *, row, int, filename, char *, icon, HICN)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 void *data[2] = { (void *)&icon, (void *)filename };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5957 _dw_container_set_item_int(handle, pointer, 0, row, (void *)data);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5958 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5960
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5962 * Sets an item in specified row and column to the given data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5963 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 * column: Zero based column of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 * data: Pointer to the data to be added.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5970 DW_FUNCTION_DEFINITION(dw_filesystem_set_item, void, HWND handle, void *pointer, int column, int row, void *data)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5971 DW_FUNCTION_ADD_PARAM5(handle, pointer, column, row, data)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5972 DW_FUNCTION_NO_RETURN(dw_filesystem_set_item)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5973 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pointer, void *, column, int, row, int, data, void *)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5974 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5975 _dw_container_set_item_int(handle, pointer, column + 1, row, data);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5976 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980 * Gets column type for a container column
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 * column: Zero based column.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5985 DW_FUNCTION_DEFINITION(dw_container_get_column_type, int, HWND handle, int column)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5986 DW_FUNCTION_ADD_PARAM2(handle, column)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5987 DW_FUNCTION_RETURN(dw_container_get_column_type, int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5988 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, column, int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5989 {
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 int flag, rc = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5991 GtkWidget *cont = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5992
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5993 if((cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user")))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5994 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5995 char numbuf[25] = {0};
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5996
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5997 snprintf(numbuf, 24, "_dw_cont_col%d", column);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5998 flag = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), numbuf));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
5999
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6000 if(flag & DW_CFA_BITMAPORICON)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6001 rc = DW_CFA_BITMAPORICON;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6002 else if(flag & DW_CFA_STRING)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6003 rc = DW_CFA_STRING;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6004 else if(flag & DW_CFA_ULONG)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6005 rc = DW_CFA_ULONG;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6006 else if(flag & DW_CFA_DATE)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6007 rc = DW_CFA_DATE;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6008 else if(flag & DW_CFA_TIME)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6009 rc = DW_CFA_TIME;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6010 else
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6011 rc = 0;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6012 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6013 DW_FUNCTION_RETURN_THIS(rc);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6014 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6017 * Gets column type for a filesystem container column
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6018 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6019 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020 * column: Zero based column.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6021 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 int API dw_filesystem_get_column_type(HWND handle, int column)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6023 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6024 return dw_container_get_column_type( handle, column + 1 );
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6026
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6027 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 * Sets the alternating row colors for container window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6029 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 * handle: The window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6031 * oddcolor: Odd row background color in DW_RGB format or a default color index.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 * evencolor: Even row background color in DW_RGB format or a default color index.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6033 * DW_RGB_TRANSPARENT will disable coloring rows.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6034 * DW_CLR_DEFAULT will use the system default alternating row colors.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6035 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6036 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6037 {
2441
a80df2e7195d GTK4: Add a comment with the information about striped controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2410
diff changeset
6038 /* TODO: If we want to accomplish this, according to mclasen we can do it
a80df2e7195d GTK4: Add a comment with the information about striped controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2410
diff changeset
6039 * with CSS on a GtkListBox widget using the following CSS:
a80df2e7195d GTK4: Add a comment with the information about striped controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2410
diff changeset
6040 * "row: nth-child(even) { background: red; }"
a80df2e7195d GTK4: Add a comment with the information about striped controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2410
diff changeset
6041 * However he does not recommend we do it for performance reasons.
a80df2e7195d GTK4: Add a comment with the information about striped controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2410
diff changeset
6042 */
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6046 * Sets the width of a column in the container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 * handle: Handle to window (widget) of container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 * column: Zero based column of width being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050 * width: Width of column in pixels.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6052 DW_FUNCTION_DEFINITION(dw_container_set_column_width, void, HWND handle, int column, int width)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6053 DW_FUNCTION_ADD_PARAM3(handle, column, width)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6054 DW_FUNCTION_NO_RETURN(dw_container_set_column_width)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6055 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, column, int, width, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6056 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6058
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6059 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6060
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6062 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064 GtkTreeViewColumn *col = gtk_tree_view_get_column(GTK_TREE_VIEW(cont), column);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066 if(col && GTK_IS_TREE_VIEW_COLUMN(col))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 gtk_tree_view_column_set_fixed_width(GTK_TREE_VIEW_COLUMN(col), width);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6071 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6073
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074 /* Internal version for both */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6075 void _dw_container_set_row_data_int(HWND handle, void *pointer, int row, int type, void *data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6076 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6077 GtkWidget *cont = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6078 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6079
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6080 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088 if(pointer)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 row += GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_insertpos"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, row))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 gtk_list_store_set(store, &iter, type, (gpointer)data, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 * Sets the title of a row in the container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 * title: String title of the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6107 DW_FUNCTION_DEFINITION(dw_container_set_row_title, void, void *pointer, int row, const char *title)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6108 DW_FUNCTION_ADD_PARAM3(pointer, row, title)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6109 DW_FUNCTION_NO_RETURN(dw_container_set_row_title)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6110 DW_FUNCTION_RESTORE_PARAM3(pointer, void *, row, int, title, char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6111 {
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6112 _dw_container_set_row_data_int(pointer, pointer, row, _DW_DATA_TYPE_STRING, (void *)title);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6113 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6114 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6115
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6116 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6117 * Changes the title of a row already inserted in the container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6118 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 * handle: Handle to window (widget) of container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121 * title: String title of the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6122 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6123 DW_FUNCTION_DEFINITION(dw_container_change_row_title, void, HWND handle, int row, const char *title)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6124 DW_FUNCTION_ADD_PARAM3(handle, row, title)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6125 DW_FUNCTION_NO_RETURN(dw_container_change_row_title)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6126 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, row, int, title, char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6127 {
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6128 _dw_container_set_row_data_int(handle, NULL, row, _DW_DATA_TYPE_STRING, (void *)title);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6129 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6130 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133 * Sets the data of a row in the container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6134 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6136 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6137 * data: Data pointer.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6138 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6139 DW_FUNCTION_DEFINITION(dw_container_set_row_data, void, void *pointer, int row, void *data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6140 DW_FUNCTION_ADD_PARAM3(pointer, row, data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6141 DW_FUNCTION_NO_RETURN(dw_container_set_row_data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6142 DW_FUNCTION_RESTORE_PARAM3(pointer, void *, row, int, data, void *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143 {
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6144 _dw_container_set_row_data_int(pointer, pointer, row, _DW_DATA_TYPE_POINTER, data);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6145 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6147
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6148 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6149 * Changes the data of a row already inserted in the container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6150 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151 * handle: Handle to window (widget) of container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6152 * row: Zero based row of data being set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153 * data: Data pointer.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6154 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6155 DW_FUNCTION_DEFINITION(dw_container_change_row_data, void, HWND handle, int row, void *data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6156 DW_FUNCTION_ADD_PARAM3(handle, row, data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6157 DW_FUNCTION_NO_RETURN(dw_container_change_row_data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6158 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, row, int, data, void *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6159 {
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6160 _dw_container_set_row_data_int(handle, NULL, row, _DW_DATA_TYPE_POINTER, data);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6161 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6162 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6163
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6164 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6165 * Sets the title of a row in the container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6166 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6167 * handle: Handle to the container window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6168 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6169 * rowcount: The number of rows to be inserted.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6170 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
6171 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6172 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6173 /* Don't need to do anything here */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6174 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6175
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6176 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6177 * Removes the first x rows from a container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6178 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6179 * handle: Handle to the window (widget) to be deleted from.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180 * rowcount: The number of rows to be deleted.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6182 DW_FUNCTION_DEFINITION(dw_container_delete, void, HWND handle, int rowcount)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6183 DW_FUNCTION_ADD_PARAM2(handle, rowcount)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6184 DW_FUNCTION_NO_RETURN(dw_container_delete)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6185 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, rowcount, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6190 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6191
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6192 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6193 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6194 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6195
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6196 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6197 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6198 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6199 int rows, z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6200
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6201 rows = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6202
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6203 for(z=0;z<rowcount;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6204 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6205 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, 0))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6206 gtk_list_store_remove(store, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6207 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6208
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6209 if(rows - rowcount < 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6210 rows = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6211 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6212 rows -= rowcount;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6213
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6214 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(rows));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6215 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6216 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6217 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6218
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6219 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6220 * Removes all rows from a container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6221 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 * handle: Handle to the window (widget) to be cleared.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6223 * redraw: TRUE to cause the container to redraw immediately.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6224 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6225 DW_FUNCTION_DEFINITION(dw_container_clear, void, HWND handle, DW_UNUSED(int redraw))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6226 DW_FUNCTION_ADD_PARAM2(handle, redraw)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6227 DW_FUNCTION_NO_RETURN(dw_container_clear)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6228 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, DW_UNUSED(redraw), int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6230 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6233 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6234
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6235 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6236 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6237 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6238
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6239 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6240 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6241 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(0));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6242 g_object_set_data(G_OBJECT(cont), "_dw_insertpos", GINT_TO_POINTER(0));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6243
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6244 gtk_list_store_clear(store);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6245 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6246 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6247 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6248
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6249 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6250 * Scrolls container up or down.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6251 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6252 * handle: Handle to the window (widget) to be scrolled.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6253 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6254 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6255 * rows: The number of rows to be scrolled.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6256 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6257 DW_FUNCTION_DEFINITION(dw_container_scroll, void, HWND handle, int direction, long rows)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6258 DW_FUNCTION_ADD_PARAM3(handle, direction, rows)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6259 DW_FUNCTION_NO_RETURN(dw_container_scroll)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6260 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, direction, int, rows, long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6261 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6262 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6263
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6264 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6265
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6266 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6267 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6268 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6269 GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6270
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6271 if(adjust)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6272 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6273 gint rowcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6274 gdouble currpos = gtk_adjustment_get_value(adjust);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6275 gdouble upper = gtk_adjustment_get_upper(adjust);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6276 gdouble lower = gtk_adjustment_get_lower(adjust);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6277 gdouble change;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6278
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6279 /* Safety check */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6280 if(rowcount > 0)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6281 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6282 change = ((gdouble)rows/(gdouble)rowcount) * (upper - lower);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6283
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6284 switch(direction)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6285 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6286 case DW_SCROLL_TOP:
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6287 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6288 gtk_adjustment_set_value(adjust, lower);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6289 break;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6290 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6291 case DW_SCROLL_BOTTOM:
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6292 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6293 gtk_adjustment_set_value(adjust, upper);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6294 break;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6295 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6296 case DW_SCROLL_UP:
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6297 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6298 gdouble newpos = currpos - change;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6299 if(newpos < lower)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6300 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6301 newpos = lower;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6302 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6303 gtk_adjustment_set_value(adjust, newpos);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6304 break;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6305 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6306 case DW_SCROLL_DOWN:
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6307 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6308 gdouble newpos = currpos + change;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6309 if(newpos > upper)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6310 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6311 newpos = upper;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6312 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6313 gtk_adjustment_set_value(adjust, newpos);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6314 break;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6315 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6316 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6317 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6318 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6319 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6320 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6321 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6322
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6323 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6324 * Starts a new query of a container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6325 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6326 * handle: Handle to the window (widget) to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6327 * flags: If this parameter is DW_CRA_SELECTED it will only
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6328 * return items that are currently selected. Otherwise
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6329 * it will return all records in the container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6330 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6331 DW_FUNCTION_DEFINITION(dw_container_query_start, char *, HWND handle, unsigned long flags)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6332 DW_FUNCTION_ADD_PARAM2(handle, flags)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6333 DW_FUNCTION_RETURN(dw_container_query_start, char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6334 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6335 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6336 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6337 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6338 char *retval = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 int type = flags & DW_CR_RETDATA ? _DW_DATA_TYPE_POINTER : _DW_DATA_TYPE_STRING;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6341 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6343 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6345 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6346
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6347 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6348 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6349 /* These should be separate but right now this will work */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6350 if(flags & DW_CRA_SELECTED)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6351 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6352 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6353 GList *list = gtk_tree_selection_get_selected_rows(sel, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6354 if(list)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6355 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6356 GtkTreePath *path = g_list_nth_data(list, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6357
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6358 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6359 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6360 gint *indices = gtk_tree_path_get_indices(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6361
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6362 if(indices)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6363 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6364 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6365
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6366 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, indices[0]))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6367 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6368 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 g_object_set_data(G_OBJECT(cont), "_dw_querypos", GINT_TO_POINTER(1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6370 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6371 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6372 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6373 g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6374 g_list_free(list);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6375 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6376 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6377 else if(flags & DW_CRA_CURSORED)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6378 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6379 GtkTreePath *path;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6380
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6381 gtk_tree_view_get_cursor(GTK_TREE_VIEW(cont), &path, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6382 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6383 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6384 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6385
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6386 if(gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, path))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6387 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6388 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6389 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6390 gtk_tree_path_free(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6391 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6392 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6393 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6394 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6396
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6397 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, 0))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6398 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6399 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6400 g_object_set_data(G_OBJECT(cont), "_dw_querypos", GINT_TO_POINTER(1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6401 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6402 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6403 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6404 /* If there is a title, duplicate it and free the temporary copy */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6405 if(retval && type == _DW_DATA_TYPE_STRING)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6406 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6407 char *temp = retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6408 retval = strdup(temp);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6409 g_free(temp);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6410 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6411 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6412 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6413
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6414 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6415 * Continues an existing query of a container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6416 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6417 * handle: Handle to the window (widget) to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6418 * flags: If this parameter is DW_CRA_SELECTED it will only
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6419 * return items that are currently selected. Otherwise
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6420 * it will return all records in the container.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6421 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6422 DW_FUNCTION_DEFINITION(dw_container_query_next, char *, HWND handle, unsigned long flags)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6423 DW_FUNCTION_ADD_PARAM2(handle, flags)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6424 DW_FUNCTION_RETURN(dw_container_query_next, char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6425 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6426 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6427 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6428 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6429 char *retval = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6430 int type = flags & DW_CR_RETDATA ? _DW_DATA_TYPE_POINTER : _DW_DATA_TYPE_STRING;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6431
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6432 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6433
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6434 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6435 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6436 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6437
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6438 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6439 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6440 int pos = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_querypos"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6441 int count = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6442
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6443 /* These should be separate but right now this will work */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6444 if(flags & DW_CRA_SELECTED)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6445 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6446 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447 GList *list = gtk_tree_selection_get_selected_rows(sel, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6449 if(list)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6451 GtkTreePath *path = g_list_nth_data(list, pos);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6452
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6453 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6454 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6455 gint *indices = gtk_tree_path_get_indices(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6456
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6457 if(indices)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6458 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6459 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6460
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6461 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, indices[0]))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6462 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6463 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6464 g_object_set_data(G_OBJECT(cont), "_dw_querypos", GINT_TO_POINTER(pos+1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6465 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6466 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6467 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6468 g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6469 g_list_free(list);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6470 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6471 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6472 else if(flags & DW_CRA_CURSORED)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6473 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6474 /* There will only be one item cursored,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6475 * retrieve it with dw_container_query_start()
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6476 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6477 retval = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6478 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6479 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6480 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6481 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6482
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6483 if(pos < count && gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, pos))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6484 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6485 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, type, &retval, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6486 g_object_set_data(G_OBJECT(cont), "_dw_querypos", GINT_TO_POINTER(pos+1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6487 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6488 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6489 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6490 /* If there is a title, duplicate it and free the temporary copy */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6491 if(retval && type == _DW_DATA_TYPE_STRING)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6492 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6493 char *temp = retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6494 retval = strdup(temp);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6495 g_free(temp);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6496 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6497 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6498 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6499
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
6500 int _dw_find_iter(GtkListStore *store, GtkTreeIter *iter, void *data, int textcomp)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6501 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6502 int z, rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6503 void *thisdata;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504 int retval = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506 for(z=0;z<rows;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6507 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6508 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), iter, NULL, z))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6509 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6510 /* Get either string from position 0 or pointer from position 1 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6511 gtk_tree_model_get(GTK_TREE_MODEL(store), iter, textcomp ? _DW_DATA_TYPE_STRING : _DW_DATA_TYPE_POINTER, &thisdata, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6512 if((textcomp && thisdata && strcmp((char *)thisdata, (char *)data) == 0) || (!textcomp && thisdata == data))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6513 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6514 retval = TRUE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6515 z = rows;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6516 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6517 if(textcomp && thisdata)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6518 g_free(thisdata);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6519 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6520 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6521 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6522 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6523
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6524 void _dw_container_cursor_int(HWND handle, void *data, int textcomp)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6525 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6526 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6527 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6528
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6529 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6530
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6531 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6532 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6533 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6534
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6535 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6536 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6537 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6538
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
6539 if(_dw_find_iter(store, &iter, data, textcomp))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6540 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6541 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6542
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6543 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6544 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6545 gtk_tree_view_row_activated(GTK_TREE_VIEW(cont), path, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6546 gtk_tree_path_free(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6547 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6548 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6549 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6551
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6553 * Cursors the item with the text speficied, and scrolls to that item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6555 * handle: Handle to the window (widget) to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6556 * text: Text usually returned by dw_container_query().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6557 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6558 DW_FUNCTION_DEFINITION(dw_container_cursor, void, HWND handle, const char *text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6559 DW_FUNCTION_ADD_PARAM2(handle, text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6560 DW_FUNCTION_NO_RETURN(dw_container_cursor)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6561 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6562 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6563 _dw_container_cursor_int(handle, (void *)text, TRUE);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6564 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6565 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6566
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6567 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6568 * Cursors the item with the text speficied, and scrolls to that item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6569 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6570 * handle: Handle to the window (widget) to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6571 * text: Text usually returned by dw_container_query().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6572 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6573 DW_FUNCTION_DEFINITION(dw_container_cursor_by_data, void, HWND handle, void *data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6574 DW_FUNCTION_ADD_PARAM2(handle, data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6575 DW_FUNCTION_NO_RETURN(dw_container_cursor_by_data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6576 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, data, void *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6577 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6578 _dw_container_cursor_int(handle, data, FALSE);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6579 DW_FUNCTION_RETURN_NOTHING;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6580 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6581
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6582 void _dw_container_delete_row_int(HWND handle, void *data, int textcomp)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6584 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6586
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6587 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6588
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6589 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6590 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6591 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(cont));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6592
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6593 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6594 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6595 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6596 int rows = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cont), "_dw_rowcount"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6597
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
6598 if(_dw_find_iter(store, &iter, data, textcomp))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6599 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6600 gtk_list_store_remove(store, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6601 rows--;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6602 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6603
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6604 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(rows));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6605 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6606 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6607
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6608 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6609 * Deletes the item with the text speficied.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6610 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6611 * handle: Handle to the window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6612 * text: Text usually returned by dw_container_query().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6614 DW_FUNCTION_DEFINITION(dw_container_delete_row, void, HWND handle, const char *text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6615 DW_FUNCTION_ADD_PARAM2(handle, text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6616 DW_FUNCTION_NO_RETURN(dw_container_delete_row)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6617 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6618 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6619 _dw_container_delete_row_int(handle, (void *)text, TRUE);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6620 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6621 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6622
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6623 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6624 * Deletes the item with the text speficied.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6625 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6626 * handle: Handle to the window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6627 * text: Text usually returned by dw_container_query().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6628 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6629 DW_FUNCTION_DEFINITION(dw_container_delete_row_by_data, void, HWND handle, void *data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6630 DW_FUNCTION_ADD_PARAM2(handle, data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6631 DW_FUNCTION_NO_RETURN(dw_container_delete_row_by_data)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6632 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, data, void *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6633 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6634 _dw_container_delete_row_int(handle, data, FALSE);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6635 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6636 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6637
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6638 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6639 * Optimizes the column widths so that all data is visible.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6640 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6641 * handle: Handle to the window (widget) to be optimized.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6642 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6643 DW_FUNCTION_DEFINITION(dw_container_optimize, void, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6644 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6645 DW_FUNCTION_NO_RETURN(dw_container_optimize)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6646 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6647 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6648 GtkWidget *cont;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6649
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6650 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6651
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6652 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6653 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6654 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(cont));
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6655 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6656 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6657
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6658 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6659 * Inserts an icon into the taskbar.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6660 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6661 * handle: Window handle that will handle taskbar icon messages.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6662 * icon: Icon handle to display in the taskbar.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6663 * bubbletext: Text to show when the mouse is above the icon.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6664 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
6665 void API dw_taskbar_insert(HWND handle, HICN icon, const char *bubbletext)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6666 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
6667 /* TODO: Removed in GTK4.... no replacement? */
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6668 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6669
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6670 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6671 * Deletes an icon from the taskbar.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6672 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6673 * handle: Window handle that was used with dw_taskbar_insert().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6674 * icon: Icon handle that was used with dw_taskbar_insert().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6675 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
6676 void API dw_taskbar_delete(HWND handle, HICN icon)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6677 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
6678 /* TODO: Removed in GTK4.... no replacement? */
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6679 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6680
2341
1a630cddf384 GTK4: Remove render widgets from the dirty list when they are destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2340
diff changeset
6681 /* Make sure the widget is out of the dirty list if it is destroyed */
1a630cddf384 GTK4: Remove render widgets from the dirty list when they are destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2340
diff changeset
6682 static void _dw_render_destroy(GtkWidget *widget, gpointer data)
1a630cddf384 GTK4: Remove render widgets from the dirty list when they are destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2340
diff changeset
6683 {
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6684 cairo_surface_t *surface = (cairo_surface_t *)g_object_get_data(G_OBJECT(widget), "_dw_cr_surface");
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6685
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6686 if(surface)
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6687 cairo_surface_destroy(surface);
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6688
2341
1a630cddf384 GTK4: Remove render widgets from the dirty list when they are destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2340
diff changeset
6689 _dw_dirty_list = g_list_remove(_dw_dirty_list, widget);
1a630cddf384 GTK4: Remove render widgets from the dirty list when they are destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2340
diff changeset
6690 }
1a630cddf384 GTK4: Remove render widgets from the dirty list when they are destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2340
diff changeset
6691
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6692 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6693 * Creates a rendering context widget (window) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6694 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6695 * id: An id to be used with dw_window_from_id.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6696 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6697 * A handle to the widget or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6698 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6699 DW_FUNCTION_DEFINITION(dw_render_new, HWND, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6700 DW_FUNCTION_ADD_PARAM1(cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6701 DW_FUNCTION_RETURN(dw_render_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6702 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6703 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6704 GtkWidget *tmp = gtk_drawing_area_new();
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6705 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2341
1a630cddf384 GTK4: Remove render widgets from the dirty list when they are destroyed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2340
diff changeset
6706 g_signal_connect(G_OBJECT(tmp), "destroy", G_CALLBACK(_dw_render_destroy), NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6707 gtk_widget_set_can_focus(tmp, TRUE);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
6708 gtk_widget_set_visible(tmp, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6709 if(_DWDefaultFont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6710 dw_window_set_font(tmp, _DWDefaultFont);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6711 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6712 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6713
2355
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6714 /*
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6715 * Invalidate the render widget triggering an expose event.
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6716 * Parameters:
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6717 * handle: A handle to a render widget to be redrawn.
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6718 */
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6719 DW_FUNCTION_DEFINITION(dw_render_redraw, void, HWND handle)
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6720 DW_FUNCTION_ADD_PARAM1(handle)
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6721 DW_FUNCTION_NO_RETURN(dw_render_redraw)
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6722 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6723 {
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6724 if(handle && GTK_IS_WIDGET(handle))
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6725 gtk_widget_queue_draw(handle);
2356
6f4f7882363c GTK4: Fix compilation after last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2355
diff changeset
6726 DW_FUNCTION_RETURN_NOTHING;
2355
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6727 }
fad0821cb953 Add new function dw_render_redraw() which will trigger expose event on render widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2347
diff changeset
6728
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6729 /* Returns a GdkRGBA from a DW color */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6730 static GdkRGBA _dw_internal_color(unsigned long value)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6731 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6732 if(DW_RGB_COLOR & value)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6733 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6734 GdkRGBA color = { (gfloat)DW_RED_VALUE(value) / 255.0, (gfloat)DW_GREEN_VALUE(value) / 255.0, (gfloat)DW_BLUE_VALUE(value) / 255.0, 1.0 };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6735 return color;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6736 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6737 if (value < 16)
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
6738 return _dw_colors[value];
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
6739 return _dw_colors[0];
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6740 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6741
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6742 /* Sets the current foreground drawing color.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6743 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6744 * red: red value.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6745 * green: green value.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6746 * blue: blue value.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6747 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
6748 void API dw_color_foreground_set(unsigned long value)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6749 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6750 GdkRGBA color = _dw_internal_color(value);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6751 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6752
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6753 *foreground = color;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6754 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6755
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6756 /* Sets the current background drawing color.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6757 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6758 * red: red value.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6759 * green: green value.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6760 * blue: blue value.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6761 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
6762 void API dw_color_background_set(unsigned long value)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6763 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6764 GdkRGBA *background = pthread_getspecific(_dw_bg_color_key);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6765
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6766 if(value == DW_CLR_DEFAULT)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6767 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6768 if(background)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6769 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6770 pthread_setspecific(_dw_bg_color_key, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6771 free(background);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6772 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6773 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6774 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6775 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6776 GdkRGBA color = _dw_internal_color(value);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6777
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6778 if(!background)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6779 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6780 background = malloc(sizeof(GdkRGBA));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6781 pthread_setspecific(_dw_bg_color_key, background);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6782 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6783 *background = color;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6784 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6785 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6786
3004
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6787 #if GTK_CHECK_VERSION(4,10,0)
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6788 static void _dw_color_choose_response(GObject *gobject, GAsyncResult *result, gpointer data)
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6789 {
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6790 DWDialog *tmp = data;
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6791 GError *error = NULL;
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6792 GdkRGBA *newcol = gtk_color_dialog_choose_rgba_finish(GTK_COLOR_DIALOG(gobject), result, &error);
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6793
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6794 if(error != NULL && newcol != NULL)
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6795 {
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6796 g_free(newcol);
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6797 newcol = NULL;
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6798 }
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6799 dw_dialog_dismiss(tmp, newcol);
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6800 }
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6801 #endif
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6802
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6803 /* Allows the user to choose a color using the system's color chooser dialog.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6804 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6805 * value: current color
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6806 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6807 * The selected color or the current color if cancelled.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6808 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6809 DW_FUNCTION_DEFINITION(dw_color_choose, ULONG, ULONG value)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6810 DW_FUNCTION_ADD_PARAM1(value)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6811 DW_FUNCTION_RETURN(dw_color_choose, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6812 DW_FUNCTION_RESTORE_PARAM1(value, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6813 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6814 GdkRGBA color = _dw_internal_color(value);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6815 unsigned long retcolor = value;
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
6816 DWDialog *tmp = dw_dialog_new(NULL);
3004
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6817 #if GTK_CHECK_VERSION(4,10,0)
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6818 GtkColorDialog *cd = gtk_color_dialog_new();
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6819 GdkRGBA *newcol;
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6820
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6821 gtk_color_dialog_choose_rgba(cd, NULL, &color, NULL, (GAsyncReadyCallback)_dw_color_choose_response, tmp);
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6822
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6823 newcol = dw_dialog_wait(tmp);
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6824
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6825 if(newcol)
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6826 {
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6827 retcolor = DW_RGB((int)(newcol->red * 255), (int)(newcol->green * 255), (int)(newcol->blue * 255));
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6828 g_free(newcol);
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6829 }
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6830 #else
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6831 GtkColorChooser *cd;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6832
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6833 cd = (GtkColorChooser *)gtk_color_chooser_dialog_new("Choose color", NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6834 gtk_color_chooser_set_use_alpha(cd, FALSE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6835 gtk_color_chooser_set_rgba(cd, &color);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6836
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
6837 gtk_widget_set_visible(GTK_WIDGET(cd), TRUE);
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
6838 g_signal_connect(G_OBJECT(cd), "response", G_CALLBACK(_dw_dialog_response), (gpointer)tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6839
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
6840 if(DW_POINTER_TO_INT(dw_dialog_wait(tmp)) == GTK_RESPONSE_OK)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6841 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6842 gtk_color_chooser_get_rgba(cd, &color);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6843 retcolor = DW_RGB((int)(color.red * 255), (int)(color.green * 255), (int)(color.blue * 255));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6844 }
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
6845 if(GTK_IS_WINDOW(cd))
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
6846 gtk_window_destroy(GTK_WINDOW(cd));
3004
0ea8d055e7df GTK4: Fix even more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3003
diff changeset
6847 #endif
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
6848 DW_FUNCTION_RETURN_THIS(retcolor);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6849 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6850
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6851 /* Draw a point on a window (preferably a render window).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6852 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6853 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6854 * pixmap: Handle to the pixmap. (choose only one of these)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6855 * x: X coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6856 * y: Y coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6857 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6858 DW_FUNCTION_DEFINITION(dw_draw_point, void, HWND handle, HPIXMAP pixmap, int x, int y)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6859 DW_FUNCTION_ADD_PARAM4(handle, pixmap, x, y)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6860 DW_FUNCTION_NO_RETURN(dw_draw_point)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6861 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, pixmap, HPIXMAP, x, int, y, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6862 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6863 cairo_t *cr = NULL;
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
6864 int cached = FALSE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6865
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6866 if(handle)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6867 {
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6868 cairo_surface_t *surface;
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6869
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
6870 if((cr = _dw_cairo_update(handle, -1, -1)))
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
6871 cached = TRUE;
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6872 else if((surface = g_object_get_data(G_OBJECT(handle), "_dw_cr_surface")))
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6873 cr = cairo_create(surface);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6874 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875 else if(pixmap)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6876 cr = cairo_create(pixmap->image);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 if(cr)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6878 {
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6879 #ifdef _DW_SINGLE_THREADED
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6880 GdkRGBA *_dw_fg_color = pthread_getspecific(_dw_fg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6881 #endif
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6882
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6883 gdk_cairo_set_source_rgba(cr, _dw_fg_color);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6884 cairo_set_line_width(cr, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6885 cairo_move_to(cr, x, y);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6886 cairo_stroke(cr);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6887 /* If we are using a drawing context...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6888 * we don't own the cairo context so don't destroy it.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6889 */
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
6890 if(!cached)
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
6891 cairo_destroy(cr);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6892 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6893 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6894 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6895
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6896 /* Draw a line on a window (preferably a render window).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6897 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6898 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6899 * pixmap: Handle to the pixmap. (choose only one of these)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6900 * x1: First X coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6901 * y1: First Y coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6902 * x2: Second X coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6903 * y2: Second Y coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6904 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6905 DW_FUNCTION_DEFINITION(dw_draw_line, void, HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6906 DW_FUNCTION_ADD_PARAM6(handle, pixmap, x1, y1, x2, y2)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6907 DW_FUNCTION_NO_RETURN(dw_draw_line)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6908 DW_FUNCTION_RESTORE_PARAM6(handle, HWND, pixmap, HPIXMAP, x1, int, y1, int, x2, int, y2, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6909 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6910 cairo_t *cr = NULL;
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
6911 int cached = FALSE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913 if(handle)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6914 {
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6915 cairo_surface_t *surface;
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6916
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
6917 if((cr = _dw_cairo_update(handle, -1, -1)))
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
6918 cached = TRUE;
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6919 else if((surface = g_object_get_data(G_OBJECT(handle), "_dw_cr_surface")))
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6920 cr = cairo_create(surface);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6921 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6922 else if(pixmap)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6923 cr = cairo_create(pixmap->image);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6924 if(cr)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6925 {
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6926 #ifdef _DW_SINGLE_THREADED
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6927 GdkRGBA *_dw_fg_color = pthread_getspecific(_dw_fg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6928 #endif
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6929
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6930 gdk_cairo_set_source_rgba(cr, _dw_fg_color);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931 cairo_set_line_width(cr, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 cairo_move_to(cr, x1, y1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933 cairo_line_to(cr, x2, y2);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934 cairo_stroke(cr);
2280
7902be60c542 GTK4: More work on the draw and bitblt functions... still doesn't work
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2279
diff changeset
6935 /* If we are using a drawing context...
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 * we don't own the cairo context so don't destroy it.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 */
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
6938 if(!cached)
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
6939 cairo_destroy(cr);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6940 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6941 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6942 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6943
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6944 /* Draw a closed polygon on a window (preferably a render window).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6945 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6946 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6947 * pixmap: Handle to the pixmap. (choose only one of these)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6948 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6949 * number of points
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6950 * x[]: X coordinates.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6951 * y[]: Y coordinates.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6952 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6953 DW_FUNCTION_DEFINITION(dw_draw_polygon, void, HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6954 DW_FUNCTION_ADD_PARAM6(handle, pixmap, flags, npoints, x, y)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6955 DW_FUNCTION_NO_RETURN(dw_draw_polygon)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6956 DW_FUNCTION_RESTORE_PARAM6(handle, HWND, pixmap, HPIXMAP, flags, int, npoints, int, x, int *, y, int *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6957 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6958 cairo_t *cr = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6959 int z;
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
6960 int cached = FALSE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6961
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6962 if(handle)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6963 {
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6964 cairo_surface_t *surface;
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6965
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
6966 if((cr = _dw_cairo_update(handle, -1, -1)))
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
6967 cached = TRUE;
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6968 else if((surface = g_object_get_data(G_OBJECT(handle), "_dw_cr_surface")))
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
6969 cr = cairo_create(surface);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6970 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6971 else if(pixmap)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6972 cr = cairo_create(pixmap->image);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6973 if(cr)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6974 {
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6975 #ifdef _DW_SINGLE_THREADED
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6976 GdkRGBA *_dw_fg_color = pthread_getspecific(_dw_fg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6977 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6978
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6979 if(flags & DW_DRAW_NOAA)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6980 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6981
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
6982 gdk_cairo_set_source_rgba(cr, _dw_fg_color);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6983 cairo_set_line_width(cr, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6984 cairo_move_to(cr, x[0], y[0]);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6985 for(z=1;z<npoints;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6986 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6987 cairo_line_to(cr, x[z], y[z]);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6988 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6989 if(flags & DW_DRAW_FILL)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6990 cairo_fill(cr);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6991 cairo_stroke(cr);
2280
7902be60c542 GTK4: More work on the draw and bitblt functions... still doesn't work
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2279
diff changeset
6992 /* If we are using a drawing context...
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6993 * we don't own the cairo context so don't destroy it.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6994 */
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
6995 if(!cached)
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
6996 cairo_destroy(cr);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6997 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
6998 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6999 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7000
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7001 /* Draw a rectangle on a window (preferably a render window).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7002 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7003 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7004 * pixmap: Handle to the pixmap. (choose only one of these)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7005 * flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7006 * x: X coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7007 * y: Y coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7008 * width: Width of rectangle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7009 * height: Height of rectangle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7010 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7011 DW_FUNCTION_DEFINITION(dw_draw_rect, void, HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7012 DW_FUNCTION_ADD_PARAM7(handle, pixmap, flags, x, y, width, height)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7013 DW_FUNCTION_NO_RETURN(dw_draw_rect)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7014 DW_FUNCTION_RESTORE_PARAM7(handle, HWND, pixmap, HPIXMAP, flags, int, x, int, y, int, width, int, height, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7015 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7016 cairo_t *cr = NULL;
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
7017 int cached = FALSE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7018
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7019 if(handle)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7020 {
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7021 cairo_surface_t *surface;
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7022
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7023 if((cr = _dw_cairo_update(handle, -1, -1)))
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
7024 cached = TRUE;
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7025 else if((surface = g_object_get_data(G_OBJECT(handle), "_dw_cr_surface")))
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7026 cr = cairo_create(surface);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7027 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7028 else if(pixmap)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7029 cr = cairo_create(pixmap->image);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7030 if(cr)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7031 {
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7032 #ifdef _DW_SINGLE_THREADED
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7033 GdkRGBA *_dw_fg_color = pthread_getspecific(_dw_fg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7034 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7035
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7036 if(flags & DW_DRAW_NOAA)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7037 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7038
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7039 gdk_cairo_set_source_rgba(cr, _dw_fg_color);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7040 cairo_set_line_width(cr, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7041 cairo_move_to(cr, x, y);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7042 cairo_line_to(cr, x, y + height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7043 cairo_line_to(cr, x + width, y + height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7044 cairo_line_to(cr, x + width, y);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7045 if(flags & DW_DRAW_FILL)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7046 cairo_fill(cr);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7047 cairo_stroke(cr);
2280
7902be60c542 GTK4: More work on the draw and bitblt functions... still doesn't work
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2279
diff changeset
7048 /* If we are using a drawing context...
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7049 * we don't own the cairo context so don't destroy it.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7050 */
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7051 if(!cached)
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
7052 cairo_destroy(cr);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7053 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7054 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7055 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7056
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7057 /* Draw an arc on a window (preferably a render window).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7058 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7059 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7060 * pixmap: Handle to the pixmap. (choose only one of these)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7061 * flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7062 * DW_DRAW_FULL will draw a complete circle/elipse.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7063 * xorigin: X coordinate of center of arc.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7064 * yorigin: Y coordinate of center of arc.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7065 * x1: X coordinate of first segment of arc.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7066 * y1: Y coordinate of first segment of arc.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7067 * x2: X coordinate of second segment of arc.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7068 * y2: Y coordinate of second segment of arc.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7069 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7070 DW_FUNCTION_DEFINITION(dw_draw_arc, void, HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7071 DW_FUNCTION_ADD_PARAM9(handle, pixmap, flags, xorigin, yorigin, x1, y1, x2, y2)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7072 DW_FUNCTION_NO_RETURN(dw_draw_arc)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7073 DW_FUNCTION_RESTORE_PARAM9(handle, HWND, pixmap, HPIXMAP, flags, int, xorigin, int, yorigin, int, x1, int, y1, int, x2, int, y2, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7074 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7075 cairo_t *cr = NULL;
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
7076 int cached = FALSE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7077
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7078 if(handle)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7079 {
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7080 cairo_surface_t *surface;
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7081
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7082 if((cr = _dw_cairo_update(handle, -1, -1)))
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
7083 cached = TRUE;
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7084 else if((surface = g_object_get_data(G_OBJECT(handle), "_dw_cr_surface")))
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7085 cr = cairo_create(surface);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7086 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7087 else if(pixmap)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7088 cr = cairo_create(pixmap->image);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7089 if(cr)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7090 {
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7091 #ifdef _DW_SINGLE_THREADED
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7092 GdkRGBA *_dw_fg_color = pthread_getspecific(_dw_fg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7093 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7094 int width = abs(x2-x1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7095 float scale = fabs((float)(y2-y1))/(float)width;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7096
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7097 if(flags & DW_DRAW_NOAA)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7098 cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7099
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7100 gdk_cairo_set_source_rgba(cr, _dw_fg_color);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7101 cairo_set_line_width(cr, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7102 if(scale != 1.0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7103 cairo_scale(cr, 1.0, scale);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7104 if(flags & DW_DRAW_FULL)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7105 cairo_arc(cr, xorigin, yorigin / scale, width/2, 0, M_PI*2);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7106 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7107 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7108 double dx = xorigin - x1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7109 double dy = yorigin - y1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7110 double r = sqrt(dx*dx + dy*dy);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7111 double a1 = atan2((y1-yorigin), (x1-xorigin));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7112 double a2 = atan2((y2-yorigin), (x2-xorigin));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7113
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7114 cairo_arc(cr, xorigin, yorigin, r, a1, a2);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7115 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7116 if(flags & DW_DRAW_FILL)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7117 cairo_fill(cr);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7118 cairo_stroke(cr);
2280
7902be60c542 GTK4: More work on the draw and bitblt functions... still doesn't work
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2279
diff changeset
7119 /* If we are using a drawing context...
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7120 * we don't own the cairo context so don't destroy it.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7121 */
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7122 if(!cached)
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
7123 cairo_destroy(cr);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7124 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7125 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7126 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7127
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7128 /* Draw text on a window (preferably a render window).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7129 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7130 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7131 * pixmap: Handle to the pixmap. (choose only one of these)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7132 * x: X coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7133 * y: Y coordinate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7134 * text: Text to be displayed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7135 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7136 DW_FUNCTION_DEFINITION(dw_draw_text, void, HWND handle, HPIXMAP pixmap, int x, int y, const char *text)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7137 DW_FUNCTION_ADD_PARAM5(handle, pixmap, x, y, text)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7138 DW_FUNCTION_NO_RETURN(dw_draw_text)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7139 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pixmap, HPIXMAP, x, int, y, int, text, const char *)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7140 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7141 if(text)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7142 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7143 cairo_t *cr = NULL;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7144 PangoFontDescription *font;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7145 char *tmpname, *fontname = "monospace 10";
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7146 int cached = FALSE;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7147
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7148 if(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7149 {
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7150 cairo_surface_t *surface;
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7151
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7152 if((cr = _dw_cairo_update(handle, -1, -1)))
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7153 cached = TRUE;
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7154 else if((surface = g_object_get_data(G_OBJECT(handle), "_dw_cr_surface")))
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7155 cr = cairo_create(surface);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7156 if((tmpname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname")))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7157 fontname = tmpname;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7158 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7159 else if(pixmap)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7160 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7161 if(pixmap->font)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7162 fontname = pixmap->font;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7163 else if(pixmap->handle && (tmpname = (char *)g_object_get_data(G_OBJECT(pixmap->handle), "_dw_fontname")))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7164 fontname = tmpname;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7165 cr = cairo_create(pixmap->image);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7166 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7167 if(cr)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7168 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7169 font = pango_font_description_from_string(fontname);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7170 if(font)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7171 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7172 PangoContext *context = pango_cairo_create_context(cr);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7173
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7174 if(context)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7175 {
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7176 PangoLayout *layout = pango_layout_new(context);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7177
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7178 if(layout)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7179 {
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7180 #ifdef _DW_SINGLE_THREADED
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7181 GdkRGBA *_dw_fg_color = pthread_getspecific(_dw_fg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7182 GdkRGBA *_dw_bg_color = pthread_getspecific(_dw_bg_color_key);
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7183 #endif
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7184
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7185 pango_layout_set_font_description(layout, font);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7186 pango_layout_set_text(layout, text, strlen(text));
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7187
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7188 gdk_cairo_set_source_rgba(cr, _dw_fg_color);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7189 /* Create a background color attribute if required */
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7190 if(_dw_bg_color)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7191 {
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7192 PangoAttrList *list = pango_layout_get_attributes(layout);
2731
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7193 PangoAttribute *attr = pango_attr_background_new((guint16)(_dw_bg_color->red * 65535),
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7194 (guint16)(_dw_bg_color->green * 65535),
85917c0c52f1 GTK4: Same color thread safety passing changes as on iOS and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2663
diff changeset
7195 (guint16)(_dw_bg_color->blue* 65535));
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7196 if(!list)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7197 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7198 list = pango_attr_list_new();
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7199 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7200 pango_attr_list_change(list, attr);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7201 pango_layout_set_attributes(layout, list);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7202 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7203 /* Do the drawing */
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7204 cairo_move_to(cr, x, y);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7205 pango_cairo_show_layout (cr, layout);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7206
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7207 g_object_unref(layout);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7208 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7209 g_object_unref(context);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7210 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7211 pango_font_description_free(font);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7212 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7213 /* If we are using a drawing context...
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7214 * we don't own the cairo context so don't destroy it.
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7215 */
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7216 if(!cached)
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7217 cairo_destroy(cr);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7218 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7219 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
7220 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7221 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7222
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7223 /* Query the width and height of a text string.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7224 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7225 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7226 * pixmap: Handle to the pixmap. (choose only one of these)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7227 * text: Text to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7228 * width: Pointer to a variable to be filled in with the width.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7229 * height Pointer to a variable to be filled in with the height.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7230 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7231 DW_FUNCTION_DEFINITION(dw_font_text_extents_get, void, HWND handle, HPIXMAP pixmap, const char *text, int *width, int *height)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7232 DW_FUNCTION_ADD_PARAM5(handle, pixmap, text, width, height)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7233 DW_FUNCTION_NO_RETURN(dw_font_text_extents_get)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7234 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pixmap, HPIXMAP, text, const char *, width, int *, height, int *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7235 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7236 PangoFontDescription *font;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7237 char *fontname = NULL;
2336
dd1b2cc95c91 GTK4: Don't unref the PangoContext returned from gtk_widget_get_pango_context().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2335
diff changeset
7238 int free_fontname = FALSE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7239
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7240 if(text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7241 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7242 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7243 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7244 fontname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname");
2336
dd1b2cc95c91 GTK4: Don't unref the PangoContext returned from gtk_widget_get_pango_context().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2335
diff changeset
7245 if(fontname == NULL)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7246 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7247 fontname = dw_window_get_font(handle);
2336
dd1b2cc95c91 GTK4: Don't unref the PangoContext returned from gtk_widget_get_pango_context().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2335
diff changeset
7248 free_fontname = TRUE;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7249 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7250 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7251 else if(pixmap)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7252 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7253 if(pixmap->font)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7254 fontname = pixmap->font;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7255 else if(pixmap->handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7256 fontname = (char *)g_object_get_data(G_OBJECT(pixmap->handle), "_dw_fontname");
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7257 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7258
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7259 font = pango_font_description_from_string(fontname ? fontname : "monospace 10");
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7260 if(font)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7261 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7262 PangoContext *context = gtk_widget_get_pango_context(pixmap ? pixmap->handle : handle);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7263
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7264 if(context)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7265 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7266 PangoLayout *layout = pango_layout_new(context);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7267
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7268 if(layout)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7269 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7270 PangoRectangle rect;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7271
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7272 pango_layout_set_font_description(layout, font);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7273 pango_layout_set_text(layout, text, -1);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7274 pango_layout_get_pixel_extents(layout, NULL, &rect);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7275
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7276 if(width)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7277 *width = rect.width;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7278 if(height)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7279 *height = rect.height;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7280
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7281 g_object_unref(layout);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7282 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7283 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7284 pango_font_description_free(font);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7285 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7286 if(free_fontname)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7287 free(fontname);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7288 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7289 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7290 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7291
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7292 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7293 * Creates a pixmap with given parameters.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7294 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7295 * handle: Window handle the pixmap is associated with.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7296 * or zero to enable this pixmap to be written
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7297 * off the screen to reduce flicker
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7298 * width: Width of the pixmap in pixels.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7299 * height: Height of the pixmap in pixels.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7300 * depth: Color depth of the pixmap.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7301 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7302 * A handle to a pixmap or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7303 */
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7304 DW_FUNCTION_DEFINITION(dw_pixmap_new, HPIXMAP, HWND handle, unsigned long width, unsigned long height, DW_UNUSED(int depth))
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7305 DW_FUNCTION_ADD_PARAM4(handle, width, height, depth)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7306 DW_FUNCTION_RETURN(dw_pixmap_new, HPIXMAP)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7307 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, width, unsigned long, height, unsigned long, DW_UNUSED(depth), int)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7308 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7309 HPIXMAP pixmap = 0;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7310
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7311 if((pixmap = calloc(1,sizeof(struct _hpixmap))))
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7312 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7313 pixmap->width = width;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7314 pixmap->height = height;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7315 pixmap->handle = handle;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7316 /* Depth needs to be divided by 3... but for the RGB colorspace...
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7317 * only 8 bits per sample is allowed, so to avoid issues just pass 8 for now.
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7318 */
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7319 pixmap->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7320 pixmap->image = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7321 }
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7322 DW_FUNCTION_RETURN_THIS(pixmap);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7323 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7324
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7325 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7326 * Creates a pixmap from a file.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7327 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7328 * handle: Window handle the pixmap is associated with.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7329 * filename: Name of the file, omit extention to have
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7330 * DW pick the appropriate file extension.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7331 * (BMP on OS/2 or Windows, XPM on Unix)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7332 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7333 * A handle to a pixmap or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7334 */
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7335 DW_FUNCTION_DEFINITION(dw_pixmap_new_from_file, HPIXMAP, HWND handle, const char *filename)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7336 DW_FUNCTION_ADD_PARAM2(handle, filename)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7337 DW_FUNCTION_RETURN(dw_pixmap_new_from_file, HPIXMAP)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7338 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, filename, const char *)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7339 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7340 HPIXMAP pixmap = 0;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7341
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7342 if(filename && *filename && (pixmap = calloc(1,sizeof(struct _hpixmap))))
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7343 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7344 char *file = alloca(strlen(filename) + 6);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7345
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7346 strcpy(file, filename);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7347
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7348 /* check if we can read from this file (it exists and read permission) */
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7349 if(access(file, 04) != 0)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7350 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7351 int i = 0;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7352
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7353 /* Try with various extentions */
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7354 while(_dw_image_exts[i] && !pixmap->pixbuf)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7355 {
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7356 strcpy(file, filename);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7357 strcat(file, _dw_image_exts[i]);
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
7358 if(access(file, 04) == 0)
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7359 pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7360 i++;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7361 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7362 }
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7363 else
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7364 pixmap->pixbuf = gdk_pixbuf_new_from_file(file, NULL);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7365
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7366 if(pixmap->pixbuf)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7367 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7368 pixmap->image = cairo_image_surface_create_from_png(file);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7369 pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7370 pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7371 pixmap->handle = handle;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7372 }
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7373 else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7374 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7375 free(pixmap);
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7376 pixmap = 0;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7377 }
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7378 }
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7379 DW_FUNCTION_RETURN_THIS(pixmap);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7380 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7381
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7382 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7383 * Creates a pixmap from data
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7384 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7385 * handle: Window handle the pixmap is associated with.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7386 * data: Source of image data
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7387 * DW pick the appropriate file extension.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7388 * (BMP on OS/2 or Windows, XPM on Unix)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7389 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7390 * A handle to a pixmap or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7391 */
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7392 DW_FUNCTION_DEFINITION(dw_pixmap_new_from_data, HPIXMAP, HWND handle, const char *data, int len)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7393 DW_FUNCTION_ADD_PARAM3(handle, data, len)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7394 DW_FUNCTION_RETURN(dw_pixmap_new_from_data, HPIXMAP)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7395 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, data, const char *, len, int)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7396 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7397 HPIXMAP pixmap = 0;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7398
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7399 if(data && len > 0 && (pixmap = calloc(1,sizeof(struct _hpixmap))))
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7400 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7401 int fd, written = -1;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7402 char template[] = "/tmp/dwpixmapXXXXXX";
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7403
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7404 /*
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7405 * A real hack; create a temporary file and write the contents
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7406 * of the data to the file
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7407 */
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7408 if((fd = mkstemp(template)) != -1)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7409 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7410 written = write(fd, data, len);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7411 close(fd);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7412 }
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7413 /* Bail if we couldn't write full file */
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7414 if(fd != -1 && written == len)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7415 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7416 pixmap->pixbuf = gdk_pixbuf_new_from_file(template, NULL);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7417 pixmap->image = cairo_image_surface_create_from_png(template);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7418 pixmap->width = gdk_pixbuf_get_width(pixmap->pixbuf);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7419 pixmap->height = gdk_pixbuf_get_height(pixmap->pixbuf);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7420 /* remove our temporary file */
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7421 unlink(template);
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7422 pixmap->handle = handle;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7423 }
2316
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7424 else
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7425 {
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7426 free(pixmap);
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7427 pixmap = 0;
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7428 }
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7429 }
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7430 DW_FUNCTION_RETURN_THIS(pixmap);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7431 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7432
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7433 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7434 * Sets the transparent color for a pixmap
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7435 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7436 * pixmap: Handle to a pixmap returned by
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7437 * dw_pixmap_new..
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7438 * color: transparent color
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7439 * Note: This does nothing on GTK+ as transparency
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7440 * is handled automatically
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7441 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7442 void API dw_pixmap_set_transparent_color(HPIXMAP pixmap, unsigned long color)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7443 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7444 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7445
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7446 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7447 * Creates a pixmap from internal resource graphic specified by id.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7448 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7449 * handle: Window handle the pixmap is associated with.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7450 * id: Resource ID associated with requested pixmap.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7451 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7452 * A handle to a pixmap or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7453 */
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7454 DW_FUNCTION_DEFINITION(dw_pixmap_grab, HPIXMAP, HWND handle, ULONG id)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7455 DW_FUNCTION_ADD_PARAM2(handle, id)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7456 DW_FUNCTION_RETURN(dw_pixmap_grab, HPIXMAP)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7457 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, id, ULONG)
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7458 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7459 HPIXMAP pixmap = 0;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7460
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7461 if((pixmap = calloc(1,sizeof(struct _hpixmap))))
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7462 {
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7463 pixmap->pixbuf = gdk_pixbuf_copy(_dw_find_pixbuf((HICN)id, &pixmap->width, &pixmap->height));
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7464 pixmap->handle = handle;
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7465 }
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7466 DW_FUNCTION_RETURN_THIS(pixmap);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7467 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7468
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7469 static void _dw_flush_dirty(gpointer widget, gpointer data)
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7470 {
2340
d797d1cec06b GTK4: Remove some debug code and safety checks in new dw_flush() code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2339
diff changeset
7471 if(widget && GTK_IS_WIDGET(widget))
d797d1cec06b GTK4: Remove some debug code and safety checks in new dw_flush() code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2339
diff changeset
7472 gtk_widget_queue_draw(GTK_WIDGET(widget));
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7473 }
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7474
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 /* Call this after drawing to the screen to make sure
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476 * anything you have drawn is visible.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477 */
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7478 DW_FUNCTION_DEFINITION(dw_flush, void)
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7479 DW_FUNCTION_ADD_PARAM
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7480 DW_FUNCTION_NO_RETURN(dw_flush)
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7481 {
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7482 g_list_foreach(_dw_dirty_list, _dw_flush_dirty, NULL);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7483 g_list_free(_dw_dirty_list);
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7484 _dw_dirty_list = NULL;
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7485 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7486 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7487
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7488 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7489 * Sets the font used by a specified pixmap.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7490 * Normally the pixmap font is obtained from the associated window handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7491 * However this can be used to override that, or for pixmaps with no window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7492 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7493 * pixmap: Handle to a pixmap returned by dw_pixmap_new() or
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7494 * passed to the application via a callback.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7495 * fontname: Name and size of the font in the form "size.fontname"
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7496 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7497 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7498 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7499 int API dw_pixmap_set_font(HPIXMAP pixmap, const char *fontname)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7500 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7501 if(pixmap)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7502 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7503 char *oldfont = pixmap->font;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7504
2315
112595f9a645 GTK4: Remove unnecessary cruft and move pixmap functions into thread safety.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2314
diff changeset
7505 pixmap->font = _dw_convert_font(fontname);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7506
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7507 if(oldfont)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7508 free(oldfont);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7509 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7510 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7511 return DW_ERROR_GENERAL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7512 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7513
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7514 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7515 * Destroys an allocated pixmap.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7516 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7517 * pixmap: Handle to a pixmap returned by
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7518 * dw_pixmap_new..
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7519 */
2316
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7520 DW_FUNCTION_DEFINITION(dw_pixmap_destroy, void, HPIXMAP pixmap)
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7521 DW_FUNCTION_ADD_PARAM1(pixmap)
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7522 DW_FUNCTION_NO_RETURN(dw_pixmap_destroy)
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7523 DW_FUNCTION_RESTORE_PARAM1(pixmap, HPIXMAP)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7524 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7525 g_object_unref(G_OBJECT(pixmap->pixbuf));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7526 cairo_surface_destroy(pixmap->image);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7527 if(pixmap->font)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7528 free(pixmap->font);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7529 free(pixmap);
2316
1f85311baa65 GTK4: dw_pixmap_new_from_data() should return NULL on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2315
diff changeset
7530 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7531 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7532
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7533 /*
2950
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7534 * Returns the width of the pixmap, same as the DW_PIXMAP_WIDTH() macro,
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7535 * but exported as an API, for non-C language bindings.
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7536 */
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7537 unsigned long API dw_pixmap_get_width(HPIXMAP pixmap)
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7538 {
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7539 return pixmap ? pixmap->width : 0;
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7540 }
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7541
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7542 /*
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7543 * Returns the height of the pixmap, same as the DW_PIXMAP_HEIGHT() macro,
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7544 * but exported as an API, for non-C language bindings.
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7545 */
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7546 unsigned long API dw_pixmap_get_height(HPIXMAP pixmap)
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7547 {
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7548 return pixmap ? pixmap->height : 0;
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7549 }
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7550
0577a97fe36d Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2947
diff changeset
7551 /*
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7552 * Copies from one item to another.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7553 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7554 * dest: Destination window handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7555 * destp: Destination pixmap. (choose only one).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7556 * xdest: X coordinate of destination.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 * ydest: Y coordinate of destination.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558 * width: Width of area to copy.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7559 * height: Height of area to copy.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560 * src: Source window handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7561 * srcp: Source pixmap. (choose only one).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7562 * xsrc: X coordinate of source.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7563 * ysrc: Y coordinate of source.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7564 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7565 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7566 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7567 dw_pixmap_stretch_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, -1, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7568 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7569
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7570 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7571 * Copies from one surface to another allowing for stretching.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7572 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7573 * dest: Destination window handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7574 * destp: Destination pixmap. (choose only one).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7575 * xdest: X coordinate of destination.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7576 * ydest: Y coordinate of destination.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7577 * width: Width of the target area.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7578 * height: Height of the target area.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7579 * src: Source window handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7580 * srcp: Source pixmap. (choose only one).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7581 * xsrc: X coordinate of source.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7582 * ysrc: Y coordinate of source.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7583 * srcwidth: Width of area to copy.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7584 * srcheight: Height of area to copy.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7585 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7586 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7587 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7588 DW_FUNCTION_DEFINITION(dw_pixmap_stretch_bitblt, int, HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7589 DW_FUNCTION_ADD_PARAM12(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, srcwidth, srcheight)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7590 DW_FUNCTION_RETURN(dw_pixmap_stretch_bitblt, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7591 DW_FUNCTION_RESTORE_PARAM12(dest, HWND, destp, HPIXMAP, xdest, int, ydest, int, width, int, height, int, src, HWND, srcp, HPIXMAP, xsrc, int, ysrc, int, srcwidth, int, srcheight, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7592
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7593 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7594 cairo_t *cr = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7595 int retval = DW_ERROR_GENERAL;
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
7596 int cached = FALSE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7597
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7598 if(dest)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7599 {
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7600 cairo_surface_t *surface;
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7601
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7602 if((cr = _dw_cairo_update(dest, -1, -1)))
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
7603 cached = TRUE;
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7604 else if((surface = g_object_get_data(G_OBJECT(dest), "_dw_cr_surface")))
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7605 cr = cairo_create(surface);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7606 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7607 else if(destp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7608 cr = cairo_create(destp->image);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7609
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7610 if(cr)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7611 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7612 double xscale = 1, yscale = 1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7613
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7614 if(srcwidth != -1 && srcheight != -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7615 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7616 xscale = (double)width / (double)srcwidth;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7617 yscale = (double)height / (double)srcheight;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7618 cairo_scale(cr, xscale, yscale);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7619 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7620
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7621 if(src)
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7622 {
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7623 cairo_surface_t *surface = g_object_get_data(G_OBJECT(src), "_dw_cr_surface");
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7624 if(surface)
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7625 cairo_set_source_surface(cr, surface, (xdest + xsrc) / xscale, (ydest + ysrc) / yscale);
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7626 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7627 else if(srcp)
2362
4367da529f5a GTK4: Fix direct drawing onto render widgets. Can't cache the cairo_t.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2356
diff changeset
7628 cairo_set_source_surface(cr, srcp->image, (xdest + xsrc) / xscale, (ydest + ysrc) / yscale);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7629
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7630 cairo_rectangle(cr, xdest / xscale, ydest / yscale, width, height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7631 cairo_fill(cr);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7632 /* If we are using a drawing context...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7633 * we don't own the cairo context so don't destroy it.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7634 */
2337
ef078d219bfc GTK4: Add a shadow surface to GtkDrawingArea widgets, which all the drawing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2336
diff changeset
7635 if(!cached)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7636 cairo_destroy(cr);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7637 retval = DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7638 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
7639 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7640 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7641
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7642 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7643 * Emits a beep.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7644 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7645 * freq: Frequency.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7646 * dur: Duration.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7647 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7648 void API dw_beep(int freq, int dur)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7649 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7650 gdk_display_beep(gdk_display_get_default());
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7651 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7652
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
7653 void _dw_strlwr(char *buf)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7654 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7655 int z, len = strlen(buf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7656
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7657 for(z=0;z<len;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7658 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7659 if(buf[z] >= 'A' && buf[z] <= 'Z')
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7660 buf[z] -= 'A' - 'a';
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7661 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7662 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7663
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7664 /* Open a shared library and return a handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7665 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7666 * name: Base name of the shared library.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7667 * handle: Pointer to a module handle,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7668 * will be filled in with the handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7669 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7670 int API dw_module_load(const char *name, HMOD *handle)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7671 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7672 int len;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7673 char *newname;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7674 char errorbuf[1025] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7675
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7676
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7677 if(!handle)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7678 return -1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7679
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7680 if((len = strlen(name)) == 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7681 return -1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7682
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7683 /* Lenth + "lib" + ".so" + NULL */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7684 newname = malloc(len + 7);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7685
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7686 if(!newname)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7687 return -1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7688
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7689 sprintf(newname, "lib%s.so", name);
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
7690 _dw_strlwr(newname);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7691
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7692 *handle = dlopen(newname, RTLD_NOW);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7693 if(*handle == NULL)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7694 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7695 strncpy(errorbuf, dlerror(), 1024);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7696 printf("%s\n", errorbuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7697 sprintf(newname, "lib%s.so", name);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7698 *handle = dlopen(newname, RTLD_NOW);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7699 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7700
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7701 free(newname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7702
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7703 return (NULL == *handle) ? -1 : 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7704 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7705
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7706 /* Queries the address of a symbol within open handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7707 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7708 * handle: Module handle returned by dw_module_load()
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7709 * name: Name of the symbol you want the address of.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7710 * func: A pointer to a function pointer, to obtain
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7711 * the address.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7712 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7713 int API dw_module_symbol(HMOD handle, const char *name, void**func)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7714 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7715 if(!func || !name)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7716 return -1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7717
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7718 if(strlen(name) == 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7719 return -1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7720
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7721 *func = (void*)dlsym(handle, name);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7722 return (NULL == *func);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7723 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7724
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7725 /* Frees the shared library previously opened.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7726 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7727 * handle: Module handle returned by dw_module_load()
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7728 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7729 int API dw_module_close(HMOD handle)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7730 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7731 if(handle)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7732 return dlclose(handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7733 return 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7734 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7735
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7736 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7737 * Returns the handle to an unnamed mutex semaphore.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7738 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7739 HMTX API dw_mutex_new(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7740 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7741 HMTX mutex = malloc(sizeof(pthread_mutex_t));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7742
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7743 pthread_mutex_init(mutex, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7744 return mutex;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7745 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7746
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7747 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7748 * Closes a semaphore created by dw_mutex_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7749 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7750 * mutex: The handle to the mutex returned by dw_mutex_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7751 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7752 void API dw_mutex_close(HMTX mutex)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7753 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7754 if(mutex)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7755 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7756 pthread_mutex_destroy(mutex);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7757 free(mutex);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7758 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7759 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7760
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7761 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7762 * Tries to gain access to the semaphore, if it can't it blocks.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7763 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7764 * mutex: The handle to the mutex returned by dw_mutex_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7765 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7766 void API dw_mutex_lock(HMTX mutex)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7767 {
2338
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7768 /* We need to handle locks from the main thread differently...
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7769 * since we can't stop message processing... otherwise we
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7770 * will deadlock... so try to acquire the lock and continue
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7771 * processing messages in between tries.
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7772 */
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7773 if(_dw_thread == pthread_self())
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7774 {
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7775 while(pthread_mutex_trylock(mutex) != 0)
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7776 {
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7777 /* Process any pending events */
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7778 if(g_main_context_pending(NULL))
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7779 {
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7780 do
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7781 {
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7782 g_main_context_iteration(NULL, FALSE);
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7783 }
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7784 while(g_main_context_pending(NULL));
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7785 }
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7786 else
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7787 sched_yield();
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7788 }
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7789 }
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7790 else
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7791 {
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7792 pthread_mutex_lock(mutex);
b9b10bb1f689 GTK4: Port dw_mutex_lock() fix from Mac since the GTK4 thread safety is
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2337
diff changeset
7793 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7794 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7795
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7796 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7797 * Tries to gain access to the semaphore.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7798 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7799 * mutex: The handle to the mutex returned by dw_mutex_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7800 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7801 * DW_ERROR_NONE on success, DW_ERROR_TIMEOUT if it is already locked.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7802 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7803 int API dw_mutex_trylock(HMTX mutex)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7804 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7805 if(pthread_mutex_trylock(mutex) == 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7806 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7807 return DW_ERROR_TIMEOUT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7808 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7809
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7810 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7811 * Reliquishes the access to the semaphore.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7812 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7813 * mutex: The handle to the mutex returned by dw_mutex_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7814 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7815 void API dw_mutex_unlock(HMTX mutex)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7816 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7817 pthread_mutex_unlock(mutex);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7818 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7819
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7820 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7821 * Returns the handle to an unnamed event semaphore.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7822 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7823 HEV API dw_event_new(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7824 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7825 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7826
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7827 if(!eve)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7828 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7829
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7830 /* We need to be careful here, mutexes on Linux are
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7831 * FAST by default but are error checking on other
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7832 * systems such as FreeBSD and OS/2, perhaps others.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7833 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7834 pthread_mutex_init (&(eve->mutex), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7835 pthread_mutex_lock (&(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7836 pthread_cond_init (&(eve->event), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7837
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7838 pthread_mutex_unlock (&(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7839 eve->alive = 1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7840 eve->posted = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7841
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7842 return eve;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7843 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7844
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7845 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7846 * Resets a semaphore created by dw_event_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7847 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7848 * eve: The handle to the event returned by dw_event_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7849 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7850 int API dw_event_reset (HEV eve)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7851 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7852 if(!eve)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7853 return DW_ERROR_NON_INIT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7854
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7855 pthread_mutex_lock (&(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7856 pthread_cond_broadcast (&(eve->event));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7857 pthread_cond_init (&(eve->event), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7858 eve->posted = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7859 pthread_mutex_unlock (&(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7860 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7861 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7862
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7863 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7864 * Posts a semaphore created by dw_event_new(). Causing all threads
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7865 * waiting on this event in dw_event_wait to continue.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7866 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7867 * eve: The handle to the event returned by dw_event_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7868 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7869 int API dw_event_post (HEV eve)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7870 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7871 if(!eve)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7872 return DW_ERROR_NON_INIT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7873
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7874 pthread_mutex_lock (&(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7875 pthread_cond_broadcast (&(eve->event));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7876 eve->posted = 1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7877 pthread_mutex_unlock (&(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7878 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7879 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7880
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7881 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7882 * Waits on a semaphore created by dw_event_new(), until the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7883 * event gets posted or until the timeout expires.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7884 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7885 * eve: The handle to the event returned by dw_event_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7886 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7887 int API dw_event_wait(HEV eve, unsigned long timeout)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7888 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7889 int rc;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7890
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7891 if(!eve)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7892 return DW_ERROR_NON_INIT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7893
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7894 pthread_mutex_lock (&(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7895
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7896 if(eve->posted)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7897 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7898 pthread_mutex_unlock (&(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7899 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7900 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7901
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7902 if(timeout != -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7903 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7904 struct timeval now;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7905 struct timespec timeo;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7906
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7907 gettimeofday(&now, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7908 timeo.tv_sec = now.tv_sec + (timeout / 1000);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7909 timeo.tv_nsec = now.tv_usec * 1000;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7910 rc = pthread_cond_timedwait(&(eve->event), &(eve->mutex), &timeo);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7911 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7912 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7913 rc = pthread_cond_wait(&(eve->event), &(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7914
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7915 pthread_mutex_unlock (&(eve->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7916 if(!rc)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7917 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7918 if(rc == ETIMEDOUT)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7919 return DW_ERROR_TIMEOUT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7920 return DW_ERROR_GENERAL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7921 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7922
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7923 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7924 * Closes a semaphore created by dw_event_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7925 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7926 * eve: The handle to the event returned by dw_event_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7927 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
7928 int API dw_event_close(HEV *eve)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7929 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7930 if(!eve || !(*eve))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7931 return DW_ERROR_NON_INIT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7932
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7933 pthread_mutex_lock (&((*eve)->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7934 pthread_cond_destroy (&((*eve)->event));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7935 pthread_mutex_unlock (&((*eve)->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7936 pthread_mutex_destroy (&((*eve)->mutex));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7937 free(*eve);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7938 *eve = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7939
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7940 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7941 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7942
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
7943 struct _dw_seminfo {
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7944 int fd;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7945 int waiting;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7946 };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7947
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
7948 static void _dw_handle_sem(int *tmpsock)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7949 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7950 fd_set rd;
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
7951 struct _dw_seminfo *array = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7952 int listenfd = tmpsock[0];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7953 int bytesread, connectcount = 1, maxfd, z, posted = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7954 char command;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7955 sigset_t mask;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7956
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7957 sigfillset(&mask); /* Mask all allowed signals */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7958 pthread_sigmask(SIG_BLOCK, &mask, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7959
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7960 /* problems */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7961 if(tmpsock[1] == -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7962 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7963 free(array);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7964 return;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7965 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7966
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7967 array[0].fd = tmpsock[1];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7968 array[0].waiting = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7969
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7970 /* Free the memory allocated in dw_named_event_new. */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7971 free(tmpsock);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7972
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7973 while(1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7974 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7975 FD_ZERO(&rd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7976 FD_SET(listenfd, &rd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7977 int DW_UNUSED(result);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7978
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7979 maxfd = listenfd;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7980
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7981 /* Added any connections to the named event semaphore */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7982 for(z=0;z<connectcount;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7983 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7984 if(array[z].fd > maxfd)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7985 maxfd = array[z].fd;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7986
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7987 FD_SET(array[z].fd, &rd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7988 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7989
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7990 if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7991 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7992 free(array);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7993 return;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7994 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7995
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7996 if(FD_ISSET(listenfd, &rd))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7997 {
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
7998 struct _dw_seminfo *newarray;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7999 int newfd = accept(listenfd, 0, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8000
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8001 if(newfd > -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8002 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8003 /* Add new connections to the set */
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8004 newarray = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo)*(connectcount+1));
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8005 memcpy(newarray, array, sizeof(struct _dw_seminfo)*(connectcount));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8006
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8007 newarray[connectcount].fd = newfd;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8008 newarray[connectcount].waiting = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8009
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8010 connectcount++;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8011
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8012 /* Replace old array with new one */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8013 free(array);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8014 array = newarray;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8015 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8016 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8017
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8018 /* Handle any events posted to the semaphore */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8019 for(z=0;z<connectcount;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8020 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8021 if(FD_ISSET(array[z].fd, &rd))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8022 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8023 if((bytesread = read(array[z].fd, &command, 1)) < 1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8024 {
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8025 struct _dw_seminfo *newarray;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8026
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8027 /* Remove this connection from the set */
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8028 newarray = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo)*(connectcount-1));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8029 if(!z)
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8030 memcpy(newarray, &array[1], sizeof(struct _dw_seminfo)*(connectcount-1));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8031 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8032 {
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8033 memcpy(newarray, array, sizeof(struct _dw_seminfo)*z);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8034 if(z!=(connectcount-1))
2855
86286f528adf Fix new safety warnings reported by the new GCC on Linux.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2854
diff changeset
8035 memcpy(&newarray[z], &array[z+1], sizeof(struct _dw_seminfo)*(connectcount-(z+1)));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8036 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8037 connectcount--;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8038
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8039 /* Replace old array with new one */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8040 free(array);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8041 array = newarray;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8042 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8043 else if(bytesread == 1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8044 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8045 switch(command)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8046 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8047 case 0:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8048 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8049 /* Reset */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8050 posted = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8051 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8052 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8053 case 1:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8054 /* Post */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8055 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8056 int s;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8057 char tmp = (char)0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8058
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8059 posted = 1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8060
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8061 for(s=0;s<connectcount;s++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8062 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8063 /* The semaphore has been posted so
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8064 * we tell all the waiting threads to
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8065 * continue.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8066 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8067 if(array[s].waiting)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8068 result = write(array[s].fd, &tmp, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8069 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8070 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8071 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8072 case 2:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8073 /* Wait */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8074 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8075 char tmp = (char)0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8076
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8077 array[z].waiting = 1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8078
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8079 /* If we are posted exit immeditately */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8080 if(posted)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8081 result = write(array[z].fd, &tmp, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8082 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8083 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8084 case 3:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8085 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8086 /* Done Waiting */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8087 array[z].waiting = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8088 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8089 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8090 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8091 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8092 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8093 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8094 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8095 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8096
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8097 /* Using domain sockets on unix for IPC */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8098 /* Create a named event semaphore which can be
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8099 * opened from other processes.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8100 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8101 * eve: Pointer to an event handle to receive handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8102 * name: Name given to semaphore which can be opened
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8103 * by other processes.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8104 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8105 HEV API dw_named_event_new(const char *name)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8106 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8107 struct sockaddr_un un;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8108 int ev, *tmpsock = (int *)malloc(sizeof(int)*2);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8109 DWTID dwthread;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8110
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8111 if(!tmpsock)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8112 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8113
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8114 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8115 ev = socket(AF_UNIX, SOCK_STREAM, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8116 memset(&un, 0, sizeof(un));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8117 un.sun_family=AF_UNIX;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8118 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8119 strcpy(un.sun_path, "/tmp/.dw/");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8120 strcat(un.sun_path, name);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8121
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8122 /* just to be safe, this should be changed
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8123 * to support multiple instances.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8124 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8125 remove(un.sun_path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8126
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8127 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8128 listen(tmpsock[0], 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8129 connect(ev, (struct sockaddr *)&un, sizeof(un));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8130 tmpsock[1] = accept(tmpsock[0], 0, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8131
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8132 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8133 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8134 if(tmpsock[0] > -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8135 close(tmpsock[0]);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8136 if(tmpsock[1] > -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8137 close(tmpsock[1]);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8138 if(ev > -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8139 close(ev);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8140 free(tmpsock);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8141 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8142 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8143
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8144 /* Create a thread to handle this event semaphore */
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8145 pthread_create(&dwthread, NULL, (void *)_dw_handle_sem, (void *)tmpsock);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8146 return GINT_TO_POINTER(ev);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8147 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8148
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8149 /* Open an already existing named event semaphore.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8150 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8151 * eve: Pointer to an event handle to receive handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8152 * name: Name given to semaphore which can be opened
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8153 * by other processes.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8154 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8155 HEV API dw_named_event_get(const char *name)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8156 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8157 struct sockaddr_un un;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8158 int ev = socket(AF_UNIX, SOCK_STREAM, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8159 if(ev < 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8160 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8161
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8162 un.sun_family=AF_UNIX;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8163 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8164 strcpy(un.sun_path, "/tmp/.dw/");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8165 strcat(un.sun_path, name);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8166 connect(ev, (struct sockaddr *)&un, sizeof(un));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8167 return GINT_TO_POINTER(ev);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8168 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8169
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8170 /* Resets the event semaphore so threads who call wait
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8171 * on this semaphore will block.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8172 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8173 * eve: Handle to the semaphore obtained by
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8174 * an open or create call.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8175 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8176 int API dw_named_event_reset(HEV eve)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8177 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8178 /* signal reset */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8179 char tmp = (char)0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8180
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8181 if(GPOINTER_TO_INT(eve) < 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8182 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8183
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8184 if(write(GPOINTER_TO_INT(eve), &tmp, 1) == 1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8185 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8186 return DW_ERROR_GENERAL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8187 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8188
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8189 /* Sets the posted state of an event semaphore, any threads
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8190 * waiting on the semaphore will no longer block.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8191 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8192 * eve: Handle to the semaphore obtained by
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8193 * an open or create call.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8194 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8195 int API dw_named_event_post(HEV eve)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8196 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8197
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8198 /* signal post */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8199 char tmp = (char)1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8200
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8201 if(GPOINTER_TO_INT(eve) < 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8202 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8203
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8204 if(write(GPOINTER_TO_INT(eve), &tmp, 1) == 1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8205 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8206 return DW_ERROR_GENERAL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8207 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8208
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8209 /* Waits on the specified semaphore until it becomes
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8210 * posted, or returns immediately if it already is posted.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8211 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8212 * eve: Handle to the semaphore obtained by
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8213 * an open or create call.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8214 * timeout: Number of milliseconds before timing out
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8215 * or -1 if indefinite.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8216 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8217 int API dw_named_event_wait(HEV eve, unsigned long timeout)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8218 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8219 fd_set rd;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8220 struct timeval tv, *useme = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8221 int retval = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8222 char tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8223
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8224 if(GPOINTER_TO_INT(eve) < 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8225 return DW_ERROR_NON_INIT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8226
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8227 /* Set the timout or infinite */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8228 if(timeout != -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8229 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8230 tv.tv_sec = timeout / 1000;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8231 tv.tv_usec = timeout % 1000;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8232
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8233 useme = &tv;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8234 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8235
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8236 FD_ZERO(&rd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8237 FD_SET(GPOINTER_TO_INT(eve), &rd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8238
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8239 /* Signal wait */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8240 tmp = (char)2;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8241 retval = write(GPOINTER_TO_INT(eve), &tmp, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8242
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8243 if(retval == 1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8244 retval = select(GPOINTER_TO_INT(eve)+1, &rd, NULL, NULL, useme);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8245
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8246 /* Signal done waiting. */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8247 tmp = (char)3;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8248 if(retval == 1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8249 retval = write(GPOINTER_TO_INT(eve), &tmp, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8250
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8251 if(retval == 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8252 return DW_ERROR_TIMEOUT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8253 else if(retval == -1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8254 return DW_ERROR_INTERRUPT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8255
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8256 /* Clear the entry from the pipe so
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8257 * we don't loop endlessly. :)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8258 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8259 if(read(GPOINTER_TO_INT(eve), &tmp, 1) == 1)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8260 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8261 return DW_ERROR_GENERAL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8262 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8263
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8264 /* Release this semaphore, if there are no more open
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8265 * handles on this semaphore the semaphore will be destroyed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8266 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8267 * eve: Handle to the semaphore obtained by
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8268 * an open or create call.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8269 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8270 int API dw_named_event_close(HEV eve)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8271 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8272 /* Finally close the domain socket,
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8273 * cleanup will continue in _dw_handle_sem.
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8274 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8275 close(GPOINTER_TO_INT(eve));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8276 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8277 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8278
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8279 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8280 * Generally an internal function called from a newly created
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8281 * thread to setup the Dynamic Windows environment for the thread.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8282 * However it is exported so language bindings can call it when
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8283 * they create threads that require access to Dynamic Windows.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8284 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8285 void API _dw_init_thread(void)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8286 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8287 GdkRGBA *foreground = malloc(sizeof(GdkRGBA));
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8288 HEV event = dw_event_new();
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8289
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8290 foreground->alpha = foreground->red = foreground->green = foreground->blue = 0.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8291 pthread_setspecific(_dw_fg_color_key, foreground);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8292 pthread_setspecific(_dw_bg_color_key, NULL);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8293 pthread_setspecific(_dw_event_key, event);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8294 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8295
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8296 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8297 * Generally an internal function called from a terminating
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8298 * thread to cleanup the Dynamic Windows environment for the thread.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8299 * However it is exported so language bindings can call it when
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8300 * they exit threads that require access to Dynamic Windows.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8301 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8302 void API _dw_deinit_thread(void)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8303 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8304 GdkRGBA *foreground, *background;
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8305 HEV event;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8306
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8307 if((foreground = pthread_getspecific(_dw_fg_color_key)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8308 free(foreground);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8309 if((background = pthread_getspecific(_dw_bg_color_key)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8310 free(background);
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8311 if((event = pthread_getspecific(_dw_event_key)))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8312 dw_event_close(&event);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8313 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8314
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8315 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8316 * Setup thread independent color sets.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8317 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8318 void _dwthreadstart(void *data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8319 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8320 void (*threadfunc)(void *) = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8321 void **tmp = (void **)data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8322
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8323 threadfunc = (void (*)(void *))tmp[0];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8324
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8325 /* Initialize colors */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8326 _dw_init_thread();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8327
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8328 threadfunc(tmp[1]);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8329 free(tmp);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8330
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8331 /* Free colors */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8332 _dw_deinit_thread();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8333 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8334
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8335 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8336 * Allocates a shared memory region with a name.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8337 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8338 * handle: A pointer to receive a SHM identifier.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8339 * dest: A pointer to a pointer to receive the memory address.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8340 * size: Size in bytes of the shared memory region to allocate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8341 * name: A string pointer to a unique memory name.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8342 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8343 HSHM API dw_named_memory_new(void **dest, int size, const char *name)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8344 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8345 char namebuf[1025];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8346 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8347
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8348 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8349 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8350
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8351 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8352 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8353 free(handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8354 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8355 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8356
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8357 if(ftruncate(handle->fd, size))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8358 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8359 close(handle->fd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8360 free(handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8361 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8362 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8363
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8364 /* attach the shared memory segment to our process's address space. */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8365 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8366
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8367 if(*dest == MAP_FAILED)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8368 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8369 close(handle->fd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8370 *dest = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8371 free(handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8372 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8373 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8374
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8375 handle->size = size;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8376 handle->sid = getsid(0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8377 handle->path = strdup(namebuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8378
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8379 return handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8380 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8381
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8382 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8383 * Aquires shared memory region with a name.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8384 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8385 * dest: A pointer to a pointer to receive the memory address.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8386 * size: Size in bytes of the shared memory region to requested.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8387 * name: A string pointer to a unique memory name.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8388 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8389 HSHM API dw_named_memory_get(void **dest, int size, const char *name)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8390 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8391 char namebuf[1025];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8392 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8393
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8394 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8395 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8396
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8397 if((handle->fd = open(namebuf, O_RDWR)) < 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8398 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8399 free(handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8400 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8401 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8402
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8403 /* attach the shared memory segment to our process's address space. */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8405
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8406 if(*dest == MAP_FAILED)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8408 close(handle->fd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8409 *dest = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8410 free(handle);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8411 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8412 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8413
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8414 handle->size = size;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8415 handle->sid = -1;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8416 handle->path = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8417
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8418 return handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8419 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8420
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8421 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8422 * Frees a shared memory region previously allocated.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8423 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8424 * handle: Handle obtained from DB_named_memory_allocate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8425 * ptr: The memory address aquired with DB_named_memory_allocate.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8426 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8427 int API dw_named_memory_free(HSHM handle, void *ptr)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8428 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8429 struct _dw_unix_shm *h = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8430 int rc = munmap(ptr, h->size);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8431
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8432 close(h->fd);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8433 if(h->path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8434 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8435 /* Only remove the actual file if we are the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8436 * creator of the file.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8437 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8438 if(h->sid != -1 && h->sid == getsid(0))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8439 remove(h->path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8440 free(h->path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8441 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8442 return rc;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8443 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8444 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8445 * Creates a new thread with a starting point of func.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8446 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8447 * func: Function which will be run in the new thread.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8448 * data: Parameter(s) passed to the function.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8449 * stack: Stack size of new thread (OS/2 and Windows only).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8450 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8451 DWTID API dw_thread_new(void *func, void *data, int stack)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8452 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8453 DWTID gtkthread;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8454 void **tmp = malloc(sizeof(void *) * 2);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8455 int rc;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8456
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8457 tmp[0] = func;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8458 tmp[1] = data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8459
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8460 rc = pthread_create(&gtkthread, NULL, (void *)_dwthreadstart, (void *)tmp);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8461 if ( rc == 0 )
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8462 return gtkthread;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8463 return (DWTID)DW_ERROR_UNKNOWN;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8464 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8465
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8466 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8467 * Ends execution of current thread immediately.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8468 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8469 void API dw_thread_end(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8470 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8471 pthread_exit(NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8472 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8473
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8474 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8475 * Returns the current thread's ID.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8476 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8477 DWTID API dw_thread_id(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8478 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8479 return (DWTID)pthread_self();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8480 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8481
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8482 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8483 * Cleanly terminates a DW session, should be signal handler safe.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8484 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8485 void API dw_shutdown(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8486 {
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
8487 g_main_loop_unref(_DWMainLoop);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8488 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8489
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8490 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8491 * Cleanly terminates a DW session, should be signal handler safe.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8492 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8493 * exitcode: Exit code reported to the operating system.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8494 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8495 void API dw_exit(int exitcode)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8496 {
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
8497 dw_shutdown();
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8498 exit(exitcode);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8499 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8500
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8501 /* Internal function to get the recommended size of scrolled items */
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8502 void _dw_get_scrolled_size(GtkWidget *item, gint *thiswidth, gint *thisheight)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8503 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8504 GtkWidget *widget = g_object_get_data(G_OBJECT(item), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8505
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8506 *thisheight = *thiswidth = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8507
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8508 if(widget)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8509 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8510 if(g_object_get_data(G_OBJECT(widget), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_TREE))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8511 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8512 /* Set to half for tree */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8513 *thiswidth = (int)((_DW_SCROLLED_MAX_WIDTH + _DW_SCROLLED_MIN_WIDTH)/2);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8514 *thisheight = (int)((_DW_SCROLLED_MAX_HEIGHT + _DW_SCROLLED_MIN_HEIGHT)/2);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8515 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8516 else if(GTK_IS_TEXT_VIEW(widget))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8517 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8518 unsigned long bytes;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8519 int height, width;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8520 char *buf, *ptr;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8521 int wrap = (gtk_text_view_get_wrap_mode(GTK_TEXT_VIEW(widget)) == GTK_WRAP_WORD);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8522 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8523 int hscrolled = FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8524
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8525 *thiswidth = *thisheight = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8526
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8527 dw_mle_get_size(item, &bytes, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8528
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8529 ptr = buf = alloca(bytes + 2);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8530 dw_mle_export(item, buf, 0, (int)bytes);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8531 buf[bytes] = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8532 strcat(buf, "\r");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8533
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8534 /* MLE */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8535 while((ptr = strstr(buf, "\r")))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8536 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8537 ptr[0] = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8538 width = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8539 if(strlen(buf))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8540 dw_font_text_extents_get(item, NULL, buf, &width, &height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8541 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8542 dw_font_text_extents_get(item, NULL, testtext, NULL, &height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8543
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8544 if(wrap && width > _DW_SCROLLED_MAX_WIDTH)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8545 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8546 *thiswidth = _DW_SCROLLED_MAX_WIDTH;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8547 *thisheight += height * (width / _DW_SCROLLED_MAX_WIDTH);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8548 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8549 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8550 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8551 if(width > *thiswidth)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8552 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8553 if(width > _DW_SCROLLED_MAX_WIDTH)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8554 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8555 *thiswidth = _DW_SCROLLED_MAX_WIDTH;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8556 hscrolled = TRUE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8557 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8558 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8559 *thiswidth = width;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8560 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8561 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8562 *thisheight += height;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8563 if(ptr[1] == '\n')
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8564 buf = &ptr[2];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8565 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8566 buf = &ptr[1];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8567 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8568 if(hscrolled)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8569 *thisheight += 10;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8570 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8571 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8572 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8573 gtk_widget_measure(GTK_WIDGET(widget), GTK_ORIENTATION_HORIZONTAL, -1, thiswidth, NULL, NULL, NULL);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8574 gtk_widget_measure(GTK_WIDGET(widget), GTK_ORIENTATION_VERTICAL, -1, thisheight, NULL, NULL, NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8575
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8576 *thisheight += 20;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8577 *thiswidth += 20;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8578 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8579 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8580 if(*thiswidth < _DW_SCROLLED_MIN_WIDTH)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8581 *thiswidth = _DW_SCROLLED_MIN_WIDTH;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8582 if(*thiswidth > _DW_SCROLLED_MAX_WIDTH)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8583 *thiswidth = _DW_SCROLLED_MAX_WIDTH;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8584 if(*thisheight < _DW_SCROLLED_MIN_HEIGHT)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8585 *thisheight = _DW_SCROLLED_MIN_HEIGHT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8586 if(*thisheight > _DW_SCROLLED_MAX_HEIGHT)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8587 *thisheight = _DW_SCROLLED_MAX_HEIGHT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8588 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8589
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8590 /* Internal box packing function called by the other 3 functions */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8591 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8592 {
2366
b3efaae95735 GTK4: Apparenlty on GTK4 GtkImage is used for icons, switch to GtkPicture.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2365
diff changeset
8593 GtkWidget *tmp, *tmpitem;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8594
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8595 if(!box)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8596 return;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8597
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8598 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8599 * If you try and pack an item into itself VERY bad things can happen; like at least an
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8600 * infinite loop on GTK! Lets be safe!
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8601 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8602 if(box == item)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8603 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8604 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8605 return;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8606 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8607
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8608 /* If this is a special box, like: Window, Groupbox, Scrollbox...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8609 * get the internal box handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8610 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8611 if((tmp = g_object_get_data(G_OBJECT(box), "_dw_boxhandle")))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8612 box = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8613
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8614 /* Can't pack nothing with GTK, so create an empty label */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8615 if(!item)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8616 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8617 item = gtk_label_new("");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8618 g_object_set_data(G_OBJECT(item), "_dw_padding", GINT_TO_POINTER(1));
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
8619 gtk_widget_set_visible(item, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8620 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8621
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8622 /* Check if the item to be packed is a special box */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8623 tmpitem = (GtkWidget *)g_object_get_data(G_OBJECT(item), "_dw_boxhandle");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8624
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8625 /* Make sure our target box is valid */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8626 if(GTK_IS_GRID(box))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8627 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8628 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8629 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8630
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8631 /* If the item being packed is a box, then we use it's padding
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8632 * instead of the padding specified on the pack line, this is
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8633 * due to a bug in the OS/2 and Win32 renderer and a limitation
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8634 * of the GtkTable class.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8635 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8636 if(GTK_IS_GRID(item) || (tmpitem && GTK_IS_GRID(tmpitem)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8637 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8638 /* NOTE: I left in the ability to pack boxes with a size,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8639 * this eliminates that by forcing the size to 0.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8640 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8641 height = width = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8642 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8643
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8644 /* Do some sanity bounds checking */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8645 if(index < 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8646 index = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8647 if(index > boxcount)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8648 index = boxcount;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8649
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8650 g_object_set_data(G_OBJECT(item), "_dw_table", box);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8651 /* Set the expand attribute on the widgets now instead of the container */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8652 gtk_widget_set_vexpand(item, vsize);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8653 gtk_widget_set_hexpand(item, hsize);
2367
0f340646a2ca GTK4: GtkPictures should be centered, not filled... don't clobber the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2366
diff changeset
8654 /* Don't clobber the center alignment on pictures */
0f340646a2ca GTK4: GtkPictures should be centered, not filled... don't clobber the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2366
diff changeset
8655 if(!GTK_IS_PICTURE(item))
0f340646a2ca GTK4: GtkPictures should be centered, not filled... don't clobber the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2366
diff changeset
8656 {
0f340646a2ca GTK4: GtkPictures should be centered, not filled... don't clobber the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2366
diff changeset
8657 gtk_widget_set_valign(item, vsize ? GTK_ALIGN_FILL : GTK_ALIGN_START);
0f340646a2ca GTK4: GtkPictures should be centered, not filled... don't clobber the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2366
diff changeset
8658 gtk_widget_set_halign(item, hsize ? GTK_ALIGN_FILL : GTK_ALIGN_START);
0f340646a2ca GTK4: GtkPictures should be centered, not filled... don't clobber the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2366
diff changeset
8659 }
2276
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
8660 /* Set pad for each margin direction on the widget */
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
8661 _dw_widget_set_pad(item, pad);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8662 /* Add to the grid using insert...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8663 * rows for vertical boxes and columns for horizontal.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8664 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8665 if(boxtype == DW_VERT)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8666 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8667 gtk_grid_insert_row(GTK_GRID(box), index);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8668 gtk_grid_attach(GTK_GRID(box), item, 0, index, 1, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8669 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8670 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8671 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8672 gtk_grid_insert_column(GTK_GRID(box), index);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8673 gtk_grid_attach(GTK_GRID(box), item, index, 0, 1, 1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8674 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8675 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8676 /* Special case for scrolled windows */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8677 if(GTK_IS_SCROLLED_WINDOW(item))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8678 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8679 gint scrolledwidth = 0, scrolledheight = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8680
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8681 /* Pre-run the calculation code for MLE/Container/Tree if needed */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8682 if((width < 1 && !hsize) || (height < 1 && !vsize))
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8683 _dw_get_scrolled_size(item, &scrolledwidth, &scrolledheight);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8684
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8685 if(width > 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8686 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), width);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8687 else if(!hsize)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8688 gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(item), scrolledwidth);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8689 if(height > 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8690 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(item), height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8691 else if(!vsize)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8692 gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(item), scrolledheight);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8693 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8694 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8695 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8696 /* Set the requested size of the widget */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8697 if(width == -1 && (GTK_IS_COMBO_BOX(item) || GTK_IS_ENTRY(item)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8698 gtk_widget_set_size_request(item, 150, height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8699 else if(width == -1 && GTK_IS_SPIN_BUTTON(item))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8700 gtk_widget_set_size_request(item, 50, height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8701 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8702 gtk_widget_set_size_request(item, width, height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8703 }
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8704 if(GTK_IS_TOGGLE_BUTTON(item))
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8705 {
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8706 GtkToggleButton *groupstart = (GtkToggleButton *)g_object_get_data(G_OBJECT(box), "_dw_group");
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8707
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8708 if(groupstart)
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8709 gtk_toggle_button_set_group(GTK_TOGGLE_BUTTON(item), groupstart);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8710 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8711 g_object_set_data(G_OBJECT(box), "_dw_group", (gpointer)item);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8712 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8713 /* If we previously incremented the reference count... drop it now that it is packed */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8714 if(g_object_get_data(G_OBJECT(item), "_dw_refed"))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8715 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8716 g_object_unref(G_OBJECT(item));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8717 g_object_set_data(G_OBJECT(item), "_dw_refed", NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8718 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8719 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8720 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8721
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8722 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8723 * Remove windows (widgets) from the box they are packed into.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8724 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8725 * handle: Window handle of the packed item to be removed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8726 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8727 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8728 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8729 DW_FUNCTION_DEFINITION(dw_box_unpack, int, HWND handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8730 DW_FUNCTION_ADD_PARAM1(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8731 DW_FUNCTION_RETURN(dw_box_unpack, int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8732 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8733 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8734 int retcode = DW_ERROR_GENERAL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8735
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8736 if(GTK_IS_WIDGET(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8737 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8738 GtkWidget *box, *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8739
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8740 /* Check if we are removing a widget from a box */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8741 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8742 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8743 /* Get the number of items in the box... */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8744 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8745 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8746
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8747 if(boxcount > 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8748 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8749 /* Decrease the count by 1 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8750 boxcount--;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8751 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8752 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8753 /* If we haven't incremented the reference count... raise it before removal */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8754 if(!g_object_get_data(G_OBJECT(handle2), "_dw_refed"))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8755 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8756 g_object_ref(G_OBJECT(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8757 g_object_set_data(G_OBJECT(handle2), "_dw_refed", GINT_TO_POINTER(1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8758 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8759 /* Remove the widget from the box */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8760 /* Figure out where in the grid this widget is and remove that row/column */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8761 if(boxtype == DW_VERT)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8762 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8763 int z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8764
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8765 for(z=0;z<boxcount;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8766 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8767 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8768 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8769 gtk_grid_remove_row(GTK_GRID(box), z);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8770 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8771 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8772 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8773 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8774 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8775 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8776 int z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8777
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8778 for(z=0;z<boxcount;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8779 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8780 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8781 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8782 gtk_grid_remove_column(GTK_GRID(box), z);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8783 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8784 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8785 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8786 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8787 retcode = DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8788 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8789 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8790 DW_FUNCTION_RETURN_THIS(retcode);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8791 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8792
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8793 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8794 * Remove windows (widgets) from a box at an arbitrary location.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8795 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8796 * box: Window handle of the box to be removed from.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8797 * index: 0 based index of packed items.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8798 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8799 * Handle to the removed item on success, 0 on failure or padding.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8800 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8801 DW_FUNCTION_DEFINITION(dw_box_unpack_at_index, HWND, HWND box, int index)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8802 DW_FUNCTION_ADD_PARAM2(box, index)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8803 DW_FUNCTION_RETURN(dw_box_unpack_at_index, HWND)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8804 DW_FUNCTION_RESTORE_PARAM2(box, HWND, index, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8805 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8806 HWND retval = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8807
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8808 /* Check if we are removing a widget from a box */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8809 if(GTK_IS_GRID(box))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8810 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8811 /* Get the number of items in the box... */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8812 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8813 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8814 GtkWidget *item = (boxtype == DW_VERT) ? gtk_grid_get_child_at(GTK_GRID(box), 0, index) : gtk_grid_get_child_at(GTK_GRID(box), index, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8815
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8816 if(boxcount > 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8817 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8818 /* Decrease the count by 1 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8819 boxcount--;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8820 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8821 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8822 /* If we haven't incremented the reference count... raise it before removal */
2265
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
8823 if(item && g_object_get_data(G_OBJECT(item), "_dw_padding") && GTK_IS_WIDGET(item))
63bb97e94cd3 GTK4: More work on conversion... the amount of changes is really ridiculous.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2264
diff changeset
8824 g_object_unref(G_OBJECT(item));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8825 else if(item)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8826 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8827 if(!g_object_get_data(G_OBJECT(item), "_dw_refed"))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8828 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8829 g_object_ref(G_OBJECT(item));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8830 g_object_set_data(G_OBJECT(item), "_dw_refed", GINT_TO_POINTER(1));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8831 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8832 /* Remove the widget from the box */
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8833 gtk_grid_remove(GTK_GRID(box), item);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8834 if(boxtype == DW_VERT)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8835 gtk_grid_remove_row(GTK_GRID(box), index);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8836 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8837 gtk_grid_remove_column(GTK_GRID(box), index);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8838 retval = item;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8839 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8840 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8841 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8842 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8843
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8844 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8845 * Pack windows (widgets) into a box at an arbitrary location.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8846 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8847 * box: Window handle of the box to be packed into.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8848 * item: Window handle of the item to pack.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8849 * index: 0 based index of packed items.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8850 * width: Width in pixels of the item or -1 to be self determined.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8851 * height: Height in pixels of the item or -1 to be self determined.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8852 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8853 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8854 * pad: Number of pixels of padding around the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8855 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8856 DW_FUNCTION_DEFINITION(dw_box_pack_at_index, void, HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8857 DW_FUNCTION_ADD_PARAM8(box, item, index, width, height, hsize, vsize, pad)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8858 DW_FUNCTION_NO_RETURN(dw_box_pack_at_index)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8859 DW_FUNCTION_RESTORE_PARAM8(box, HWND, item, HWND, index, int, width, int, height, int, hsize, int, vsize, int, pad, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8860 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8861 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()");
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8862 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8863 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8864
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8865 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8866 * Pack windows (widgets) into a box from the start (or top).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8867 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8868 * box: Window handle of the box to be packed into.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8869 * item: Window handle of the item to pack.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8870 * width: Width in pixels of the item or -1 to be self determined.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8871 * height: Height in pixels of the item or -1 to be self determined.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8872 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8873 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8874 * pad: Number of pixels of padding around the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8875 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8876 DW_FUNCTION_DEFINITION(dw_box_pack_start, void, HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8877 DW_FUNCTION_ADD_PARAM7(box, item, width, height, hsize, vsize, pad)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8878 DW_FUNCTION_NO_RETURN(dw_box_pack_start)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8879 DW_FUNCTION_RESTORE_PARAM7(box, HWND, item, HWND, width, int, height, int, hsize, int, vsize, int, pad, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8880 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8881 /* 65536 is the table limit on GTK...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8882 * seems like a high enough value we will never hit it here either.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8883 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8884 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()");
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8885 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8886 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8887
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8888 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8889 * Pack windows (widgets) into a box from the end (or bottom).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8890 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8891 * box: Window handle of the box to be packed into.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8892 * item: Window handle of the item to pack.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8893 * width: Width in pixels of the item or -1 to be self determined.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8894 * height: Height in pixels of the item or -1 to be self determined.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8895 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8896 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8897 * pad: Number of pixels of padding around the item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8898 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8899 DW_FUNCTION_DEFINITION(dw_box_pack_end, void, HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8900 DW_FUNCTION_ADD_PARAM7(box, item, width, height, hsize, vsize, pad)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8901 DW_FUNCTION_NO_RETURN(dw_box_pack_end)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8902 DW_FUNCTION_RESTORE_PARAM7(box, HWND, item, HWND, width, int, height, int, hsize, int, vsize, int, pad, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8903 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8904 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()");
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8905 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8906 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8907
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8908 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8909 * Sets the size of a given window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8910 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8911 * handle: Window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8912 * width: New width in pixels.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8913 * height: New height in pixels.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8914 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8915 DW_FUNCTION_DEFINITION(dw_window_set_size, void, HWND handle, ULONG width, ULONG height)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8916 DW_FUNCTION_ADD_PARAM3(handle, width, height)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8917 DW_FUNCTION_NO_RETURN(dw_window_set_size)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8918 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, width, ULONG, height, ULONG)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8919 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8920 if(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8921 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8922 if(GTK_IS_WINDOW(handle))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8923 gtk_window_set_default_size(GTK_WINDOW(handle), width, height);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8924 else if(GTK_IS_WIDGET(handle))
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8925 gtk_widget_set_size_request(GTK_WIDGET(handle), width, height);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8926 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
8927 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8928 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8929
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8930 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8931 * Gets the size the system thinks the widget should be.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8932 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8933 * handle: Window handle of the item to be back.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8934 * width: Width in pixels of the item or NULL if not needed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8935 * height: Height in pixels of the item or NULL if not needed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8936 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8937 DW_FUNCTION_DEFINITION(dw_window_get_preferred_size, void, HWND handle, int *width, int *height)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8938 DW_FUNCTION_ADD_PARAM3(handle, width, height)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8939 DW_FUNCTION_NO_RETURN(dw_window_get_preferred_size)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8940 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, width, int *, height, int *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8941 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8942 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8943 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8944 gint scrolledwidth, scrolledheight;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8945
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
8946 _dw_get_scrolled_size(handle, &scrolledwidth, &scrolledheight);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8947
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8948 if(width)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8949 *width = scrolledwidth;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8950 if(height)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8951 *height = scrolledheight;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8952 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8953 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8954 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8955 if(width)
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8956 gtk_widget_measure(GTK_WIDGET(handle), GTK_ORIENTATION_HORIZONTAL, -1, width, NULL, NULL, NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8957 if(height)
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8958 gtk_widget_measure(GTK_WIDGET(handle), GTK_ORIENTATION_VERTICAL, -1, height, NULL, NULL, NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8959 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
8960 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8961 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8962
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8963 /* Internal version to simplify the code with multiple versions of GTK */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8964 int _dw_get_screen_width(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8965 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8966 GdkDisplay *display = gdk_display_get_default();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8967
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8968 if(display)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8969 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8970 GListModel *monitors = gdk_display_get_monitors(display);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
8971 GdkMonitor *monitor = GDK_MONITOR(g_list_model_get_object(monitors, 0));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8972
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8973 if(monitor)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8974 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8975 GdkRectangle rc = { 0, 0, 0 ,0 };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8976 gdk_monitor_get_geometry(monitor, &rc);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8977 return rc.width;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8978 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8979 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8980 return 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8981 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8982
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8983 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8984 * Returns the width of the screen.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8985 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8986 DW_FUNCTION_DEFINITION(dw_screen_width, int)
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8987 DW_FUNCTION_ADD_PARAM
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8988 DW_FUNCTION_RETURN(dw_screen_width, int)
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8989 {
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8990 int retval = _dw_get_screen_width();
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8991 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8992 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8993
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8994 /* Internal version to simplify the code with multiple versions of GTK */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
8995 int _dw_get_screen_height(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8996 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8997 GdkDisplay *display = gdk_display_get_default();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8998
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8999 if(display)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9000 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
9001 GListModel *monitors = gdk_display_get_monitors(display);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
9002 GdkMonitor *monitor = GDK_MONITOR(g_list_model_get_object(monitors, 0));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9003
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9004 if(monitor)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9005 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9006 GdkRectangle rc = { 0, 0, 0 ,0 };
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9007 gdk_monitor_get_geometry(monitor, &rc);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9008 return rc.height;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9009 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9010 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9011 return 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9012 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9013
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9014 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9015 * Returns the height of the screen.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9016 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9017 DW_FUNCTION_DEFINITION(dw_screen_height, int)
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9018 DW_FUNCTION_ADD_PARAM
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9019 DW_FUNCTION_RETURN(dw_screen_height, int)
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9020 {
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9021 int retval = _dw_get_screen_height();
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9022 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9023 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9024
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9025 /* This should return the current color depth */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9026 unsigned long API dw_color_depth_get(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9027 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
9028 /* TODO: Make this work on GTK4... with no GdkVisual */
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
9029 return 32;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9030 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9031
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9032 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9033 * Sets the gravity of a given window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9034 * Gravity controls which corner of the screen and window the position is relative to.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9035 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9036 * handle: Window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9037 * horz: DW_GRAV_LEFT (default), DW_GRAV_RIGHT or DW_GRAV_CENTER.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9038 * vert: DW_GRAV_TOP (default), DW_GRAV_BOTTOM or DW_GRAV_CENTER.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9039 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9040 void API dw_window_set_gravity(HWND handle, int horz, int vert)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9041 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9042 dw_window_set_data(handle, "_dw_grav_horz", DW_INT_TO_POINTER(horz));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9043 dw_window_set_data(handle, "_dw_grav_vert", DW_INT_TO_POINTER(vert));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9044 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9045
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9046 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9047 * Sets the position of a given window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9048 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9049 * handle: Window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9050 * x: X location from the bottom left.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9051 * y: Y location from the bottom left.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9052 */
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9053 #ifndef GDK_WINDOWING_X11
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9054 void API dw_window_set_pos(HWND handle, long x, long y)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9055 {
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9056 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9057 #else
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9058 DW_FUNCTION_DEFINITION(dw_window_set_pos, void, HWND handle, long x, long y)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9059 DW_FUNCTION_ADD_PARAM3(handle, x, y)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9060 DW_FUNCTION_NO_RETURN(dw_window_set_pos)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9061 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, x, long, y, long)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9062 {
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9063 GdkDisplay *display = gdk_display_get_default();
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9064
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9065 if(handle && GTK_IS_WINDOW(handle) && display && GDK_IS_X11_DISPLAY(display))
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9066 {
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9067 GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(handle));
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9068
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9069 if(surface)
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9070 {
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9071 XMoveWindow(GDK_SURFACE_XDISPLAY(surface),
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9072 GDK_SURFACE_XID(surface),
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9073 x, y);
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9074 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9075 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9076 DW_FUNCTION_RETURN_NOTHING;
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9077 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9078 #endif
2322
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
9079
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9080 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9081 * Sets the position and size of a given window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9082 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9083 * handle: Window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9084 * x: X location from the bottom left.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9085 * y: Y location from the bottom left.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9086 * width: Width of the widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9087 * height: Height of the widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9088 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9089 void API dw_window_set_pos_size(HWND handle, long x, long y, unsigned long width, unsigned long height)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9090 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9091 dw_window_set_size(handle, width, height);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9092 dw_window_set_pos(handle, x, y);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9093 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9094
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9095 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9096 * Gets the position and size of a given window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9097 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9098 * handle: Window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9099 * x: X location from the bottom left.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9100 * y: Y location from the bottom left.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9101 * width: Width of the widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9102 * height: Height of the widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9103 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9104 DW_FUNCTION_DEFINITION(dw_window_get_pos_size, void, HWND handle, long *x, long *y, ULONG *width, ULONG *height)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9105 DW_FUNCTION_ADD_PARAM5(handle, x, y, width, height)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9106 DW_FUNCTION_NO_RETURN(dw_window_get_pos_size)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9107 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, x, long *, y, long *, width, ULONG *, height, ULONG *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9108 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9109 if(handle && GTK_IS_WIDGET(handle))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9110 {
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9111 GtkRequisition size;
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9112
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9113 /* If the widget hasn't been shown, it returns 0 so use this as backup */
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9114 gtk_widget_get_preferred_size(GTK_WIDGET(handle), NULL, &size);
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9115
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9116 if(width)
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9117 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9118 *width = (ULONG)gtk_widget_get_width(GTK_WIDGET(handle));
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9119 if(!*width)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9120 *width = (ULONG)size.width;
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9121 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9122 if(height)
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9123 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9124 *height = (ULONG)gtk_widget_get_height(GTK_WIDGET(handle));
2321
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9125 if(!*height)
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9126 *height = (ULONG)size.height;
52ca7647f665 GTK4: Implement pointer grabbing using Xlib and center message boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2320
diff changeset
9127 }
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9128
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9129 #ifdef GDK_WINDOWING_X11
2336
dd1b2cc95c91 GTK4: Don't unref the PangoContext returned from gtk_widget_get_pango_context().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2335
diff changeset
9130 if(x || y)
dd1b2cc95c91 GTK4: Don't unref the PangoContext returned from gtk_widget_get_pango_context().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2335
diff changeset
9131 {
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9132 GdkDisplay *display = gdk_display_get_default();
2336
dd1b2cc95c91 GTK4: Don't unref the PangoContext returned from gtk_widget_get_pango_context().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2335
diff changeset
9133 GdkSurface *surface;
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9134
2336
dd1b2cc95c91 GTK4: Don't unref the PangoContext returned from gtk_widget_get_pango_context().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2335
diff changeset
9135 if(display && GDK_IS_X11_DISPLAY(display) && (surface = gtk_native_get_surface(GTK_NATIVE(handle))))
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9136 {
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9137 XWindowAttributes xwa;
2322
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
9138 int ix = 0, iy = 0;
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9139 Window child, xrootwin = gdk_x11_display_get_xrootwindow(display);
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9140
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9141 XTranslateCoordinates(GDK_SURFACE_XDISPLAY(surface), GDK_SURFACE_XID(surface),
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9142 xrootwin, 0, 0, &ix, &iy, &child);
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9143 XGetWindowAttributes(GDK_SURFACE_XDISPLAY(surface),
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9144 GDK_SURFACE_XID(surface), &xwa);
2324
610c66b17fbc GTK4: Put Xlib calls in GDK_IS_X11_DISPLAY() code checks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2323
diff changeset
9145
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9146 if(x)
2322
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
9147 *x = (long)(ix - xwa.x);
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9148 if(y)
2322
ebcaedfa7ff4 GTK4: Implement dw_pointer_set_pos() with Xlib. Also translate coordinate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2321
diff changeset
9149 *y = (long)(ix - xwa.y);
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9150 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9151 }
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9152 #else
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9153 if(x)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9154 *x = 0;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9155 if(y)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9156 *y = 0;
2320
829228de003f GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2319
diff changeset
9157 #endif
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9158 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9159 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9160 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9161
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9162 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9163 * Sets the style of a given window (widget).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9164 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9165 * handle: Window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9166 * width: New width in pixels.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9167 * height: New height in pixels.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9168 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9169 DW_FUNCTION_DEFINITION(dw_window_set_style, void, HWND handle, ULONG style, ULONG mask)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9170 DW_FUNCTION_ADD_PARAM3(handle, style, mask)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9171 DW_FUNCTION_NO_RETURN(dw_window_set_style)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9172 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, style, ULONG, mask, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9173 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9174 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9175
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9176 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9177 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9178 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9179 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9180 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9181 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9182 else if(GTK_IS_FRAME(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9183 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9184 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_label");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9185 if(tmp && GTK_IS_LABEL(tmp))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9186 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9187 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9188 else if(GTK_IS_BUTTON(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9189 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9190 if(mask & DW_BS_NOBORDER)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9191 {
2318
5951752fa7af GTK4: Implement borderless button style for buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2317
diff changeset
9192 GtkStyleContext *context = gtk_widget_get_style_context(GTK_WIDGET(handle));
5951752fa7af GTK4: Implement borderless button style for buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2317
diff changeset
9193
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9194 if(style & DW_BS_NOBORDER)
2318
5951752fa7af GTK4: Implement borderless button style for buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2317
diff changeset
9195 gtk_style_context_add_class(context, "flat");
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9196 else
2318
5951752fa7af GTK4: Implement borderless button style for buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2317
diff changeset
9197 gtk_style_context_remove_class(context, "flat");
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9198 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9199 }
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
9200 if(GTK_IS_LABEL(handle2))
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9201 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9202 gfloat x=DW_LEFT, y=DW_CENTER;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9203 /* horizontal... */
2319
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
9204 if(style & DW_DT_CENTER)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9205 x = DW_CENTER;
2319
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
9206 if(style & DW_DT_RIGHT)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9207 x = DW_RIGHT;
2319
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
9208 if(style & DW_DT_LEFT)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9209 x = DW_LEFT;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9210 /* vertical... */
2319
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
9211 if(style & DW_DT_VCENTER)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9212 y = DW_CENTER;
2319
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
9213 if(style & DW_DT_TOP)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9214 y = DW_TOP;
2319
36522ed00ef8 GTK4: Some general code cleanup and an attempt to get dw_window_set_icon()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2318
diff changeset
9215 if(style & DW_DT_BOTTOM)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9216 y = DW_BOTTOM;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9217 gtk_label_set_xalign(GTK_LABEL(handle2), x);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9218 gtk_label_set_yalign(GTK_LABEL(handle2), y);
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
9219 if(style & DW_DT_WORDBREAK)
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
9220 gtk_label_set_wrap(GTK_LABEL(handle), TRUE);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
9221 }
2317
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9222 if(G_IS_MENU_ITEM(handle2))
2282
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
9223 {
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
9224 GSimpleAction *action = g_object_get_data(G_OBJECT(handle2), "_dw_action");
b045bb67922d GTK4: Implement resizing of images in the layout manager.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2281
diff changeset
9225
2317
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9226 if(action)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9227 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9228 if(mask & (DW_MIS_ENABLED | DW_MIS_DISABLED))
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9229 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9230 if((style & DW_MIS_ENABLED) || (style & DW_MIS_DISABLED))
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9231 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9232 if(style & DW_MIS_ENABLED)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9233 g_simple_action_set_enabled(action, TRUE);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9234 else
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9235 g_simple_action_set_enabled(action, FALSE);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9236 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9237 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9238 if(mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED))
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9239 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9240 GVariant *action_state = g_action_get_state(G_ACTION(action));
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9241 gboolean check = false;
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9242
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9243 if(style & DW_MIS_CHECKED)
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9244 check = true;
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9245
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9246 if(!action_state || (g_variant_get_boolean(action_state) != check))
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9247 {
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9248 GVariant *new_state = g_variant_new_boolean(check);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9249 g_simple_action_set_state(action, new_state);
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9250 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9251 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9252 }
a2020f907a6c GTK4: Implement checkable menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2316
diff changeset
9253 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9254 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9255 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9256
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9257 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9258 * Adds a new page to specified notebook.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9259 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9260 * handle: Window (widget) handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9261 * flags: Any additional page creation flags.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9262 * front: If TRUE page is added at the beginning.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9263 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9264 DW_FUNCTION_DEFINITION(dw_notebook_page_new, ULONG, HWND handle, DW_UNUSED(ULONG flags), int front)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9265 DW_FUNCTION_ADD_PARAM3(handle, flags, front)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9266 DW_FUNCTION_RETURN(dw_notebook_page_new, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9267 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, DW_UNUSED(flags), ULONG, front, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9268 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9269 GtkWidget **pagearray;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9270 ULONG retval = 256;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9271 int z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9272
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9273 pagearray = (GtkWidget **)g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9274
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9275 if(pagearray)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9276 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9277 for(z=0;z<256;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9278 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9279 if(!pagearray[z])
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9280 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9281 char text[101] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9282 int num = z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9283
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9284 if(front)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9285 num |= 1 << 16;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9286
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9287 snprintf(text, 100, "_dw_page%d", z);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9288 /* Save the real id and the creation flags */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9289 g_object_set_data(G_OBJECT(handle), text, GINT_TO_POINTER(num));
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9290 retval = (ULONG)z;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9291 z = 256;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9292 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9293 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9294 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9295 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9296 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9297
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9298 /* Return the physical page id from the logical page id */
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
9299 int _dw_get_physical_page(HWND handle, unsigned long pageid)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9300 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9301 int z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9302 GtkWidget *thispage, **pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9303
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9304 if(pagearray)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9305 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9306 for(z=0;z<256;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9307 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9308 if((thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9309 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9310 if(thispage == pagearray[pageid])
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9311 return z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9312 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9313 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9314 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9315 return 256;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9316 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9317
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9318 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9319 * Remove a page from a notebook.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9320 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9321 * handle: Handle to the notebook widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9322 * pageid: ID of the page to be destroyed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9323 */
2909
3fe7641f027c WARNING: Fix an API inconsistency in dw_notebook_page_destroy/set()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2904
diff changeset
9324 DW_FUNCTION_DEFINITION(dw_notebook_page_destroy, void, HWND handle, unsigned long pageid)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9325 DW_FUNCTION_ADD_PARAM2(handle, pageid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9326 DW_FUNCTION_NO_RETURN(dw_notebook_page_destroy)
2910
927fcf85b132 GTK4: Fix pageid type to be unsigned long in the macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2909
diff changeset
9327 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, pageid, unsigned long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9328 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9329 GtkWidget **pagearray;
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
9330 int realpage = _dw_get_physical_page(handle, pageid);
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
9331
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9332 if(realpage > -1 && realpage < 256)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9333 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9334 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9335 if((pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray")))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9336 pagearray[pageid] = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9337 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9338 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9339 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9340
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9341 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9342 * Queries the currently visible page ID.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9343 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9344 * handle: Handle to the notebook widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9345 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9346 DW_FUNCTION_DEFINITION(dw_notebook_page_get, ULONG, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9347 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9348 DW_FUNCTION_RETURN(dw_notebook_page_get, ULONG)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9349 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9350 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9351 ULONG retval;
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
9352 int phys = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle));
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
9353
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
9354 retval = _dw_get_logical_page(handle, phys);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9355 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9356 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9357
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9358 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9359 * Sets the currently visibale page ID.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9360 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9361 * handle: Handle to the notebook widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9362 * pageid: ID of the page to be made visible.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9363 */
2909
3fe7641f027c WARNING: Fix an API inconsistency in dw_notebook_page_destroy/set()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2904
diff changeset
9364 DW_FUNCTION_DEFINITION(dw_notebook_page_set, void, HWND handle, unsigned long pageid)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9365 DW_FUNCTION_ADD_PARAM2(handle, pageid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9366 DW_FUNCTION_NO_RETURN(dw_notebook_page_set)
2910
927fcf85b132 GTK4: Fix pageid type to be unsigned long in the macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2909
diff changeset
9367 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, pageid, unsigned long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9368 {
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
9369 int realpage = _dw_get_physical_page(handle, pageid);
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
9370
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9371 if(realpage > -1 && realpage < 256)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9372 gtk_notebook_set_current_page(GTK_NOTEBOOK(handle), pageid);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9373 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9374 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9375
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9376
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9377 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9378 * Sets the text on the specified notebook tab.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9379 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9380 * handle: Notebook handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9381 * pageid: Page ID of the tab to set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9382 * text: Pointer to the text to set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9383 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9384 DW_FUNCTION_DEFINITION(dw_notebook_page_set_text, void, HWND handle, ULONG pageid, const char *text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9385 DW_FUNCTION_ADD_PARAM3(handle, pageid, text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9386 DW_FUNCTION_NO_RETURN(dw_notebook_page_set_text)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9387 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, pageid, ULONG, text, const char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9388 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9389 GtkWidget *child;
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
9390 int realpage = _dw_get_physical_page(handle, pageid);
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
9391
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9392 if(realpage < 0 || realpage > 255)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9393 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9394 char ptext[101] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9395 int num;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9396
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9397 snprintf(ptext, 100, "_dw_page%d", (int)pageid);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9398 num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), ptext));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9399 realpage = 0xFF & num;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9400 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9401
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9402 if(realpage > -1 && realpage < 256)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9403 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9404 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9405 if(child)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9406 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9407 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9408 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9409 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9410
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9411 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9412 * Sets the text on the specified notebook tab status area.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9413 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9414 * handle: Notebook handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9415 * pageid: Page ID of the tab to set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9416 * text: Pointer to the text to set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9417 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9418 void API dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, const char *text)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9419 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9420 /* TODO (if possible) */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9421 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9422
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9423 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9424 * Packs the specified box into the notebook page.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9425 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9426 * handle: Handle to the notebook to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9427 * pageid: Page ID in the notebook which is being packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9428 * page: Box handle to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9429 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9430 DW_FUNCTION_DEFINITION(dw_notebook_pack, void, HWND handle, ULONG pageid, HWND page)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9431 DW_FUNCTION_ADD_PARAM3(handle, pageid, page)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9432 DW_FUNCTION_NO_RETURN(dw_notebook_pack)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9433 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, pageid, ULONG, page, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9434 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9435 GtkWidget *label, *child, *oldlabel, **pagearray;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9436 const gchar *text = NULL;
2276
d7f0254f7d1e GTK4: Attempt fixing box and item padding using gtk_widget_set_margin_*().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2275
diff changeset
9437 int num, z, realpage = -1;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9438 char ptext[101] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9439
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9440 snprintf(ptext, 100, "_dw_page%d", (int)pageid);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9441 num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), ptext));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9442 g_object_set_data(G_OBJECT(handle), ptext, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9443 pagearray = (GtkWidget **)g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9444
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9445 if(pagearray)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9446 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9447 /* The page already exists... so get it's current page */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9448 if(pagearray[pageid])
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9449 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9450 for(z=0;z<256;z++)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9451 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9452 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9453 if(child == pagearray[pageid])
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9454 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9455 oldlabel = gtk_notebook_get_tab_label(GTK_NOTEBOOK(handle), child);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9456 if(oldlabel)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9457 text = gtk_label_get_text(GTK_LABEL(oldlabel));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9458 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), z);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9459 realpage = z;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9460 break;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9461 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9462 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9463 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9464
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9465 pagearray[pageid] = page;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9466
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9467 label = gtk_label_new(text ? text : "");
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9468
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9469 if(realpage != -1)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9470 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, realpage);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9471 else if(num & ~(0xFF))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9472 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 0);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9473 else
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9474 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9475 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9476 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9477 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9478
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9479 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9480 * Appends the specified text to the listbox's (or combobox) entry list.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9481 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9482 * handle: Handle to the listbox to be appended to.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9483 * text: Text to append into listbox.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9484 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
9485 void API dw_listbox_append(HWND handle, const char *text)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9486 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9487 dw_listbox_insert(handle, text, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9488 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9489
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9490 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9491 * Inserts the specified text int the listbox's (or combobox) entry list at the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9492 * position indicated.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9493 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9494 * handle: Handle to the listbox to be appended to.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9495 * text: Text to insert into listbox.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9496 * pos: 0-based index into listbox. -1 will append
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9497 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9498 DW_FUNCTION_DEFINITION(dw_listbox_insert, void, HWND handle, const char *text, int pos)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9499 DW_FUNCTION_ADD_PARAM3(handle, text, pos)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9500 DW_FUNCTION_NO_RETURN(dw_listbox_insert)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9501 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, const char *, pos, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9502 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9503 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9504 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9505
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9506 /* Get the inner handle for scrolled controls */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9507 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9508 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9509 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9510 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9511 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9512 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9513 if(handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9514 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9515 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9516
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9517 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9518 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9519 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9520 else if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9521 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9522
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9523 if(store)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9524 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9525 if(pos < 0)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9526 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9527 /* Insert an entry at the end */
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9528 gtk_list_store_append(store, &iter);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9529 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9530 else
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9531 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9532 /* Insert at position */
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9533 gtk_list_store_insert(store, &iter, pos);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9534 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9535 gtk_list_store_set (store, &iter, 0, text, -1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9536 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9537 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9538 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9539 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9540
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9541 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9542 * Appends the specified text items to the listbox's (or combobox) entry list.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9543 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9544 * handle: Handle to the listbox to be appended to.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9545 * text: Text strings to append into listbox.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9546 * count: Number of text strings to append
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9547 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9548 DW_FUNCTION_DEFINITION(dw_listbox_list_append, void, HWND handle, char **text, int count)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9549 DW_FUNCTION_ADD_PARAM3(handle, text, count)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9550 DW_FUNCTION_NO_RETURN(dw_listbox_list_append)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9551 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, char **, count, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9552 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9553 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9554 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9555
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9556 /* Get the inner handle for scrolled controls */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9557 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9558 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9559 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9560 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9561 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9562 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9563 if(handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9564 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9565 int z;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9566 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9567
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9568 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9569 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9570 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9571 else if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9572 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9573
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9574 if(store)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9575 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9576 /* Insert entries at the end */
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9577 for(z=0;z<count;z++)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9578 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9579 gtk_list_store_append(store, &iter);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9580 gtk_list_store_set (store, &iter, 0, text[z], -1);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9581 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9582 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9583 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9584 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9585 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9586
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9587 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9588 * Clears the listbox's (or combobox) list of all entries.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9589 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9590 * handle: Handle to the listbox to be cleared.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9591 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9592 DW_FUNCTION_DEFINITION(dw_listbox_clear, void, HWND handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9593 DW_FUNCTION_ADD_PARAM1(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9594 DW_FUNCTION_NO_RETURN(dw_listbox_clear)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9595 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9596
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9597 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9598 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9599 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9600
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9601 /* Get the inner handle for scrolled controls */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9602 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9603 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9604 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9605 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9606 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9607 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9608 if(handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9609 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9610 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9611 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9612 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9613 else if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9614 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9615
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9616 if(store)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9617 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9618 /* Clear the list */
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9619 gtk_list_store_clear(store);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9620 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9621 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9622 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9623 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9624
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9625 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9626 * Returns the listbox's item count.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9627 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9628 * handle: Handle to the listbox to be counted
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9629 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9630 DW_FUNCTION_DEFINITION(dw_listbox_count, int, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9631 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9632 DW_FUNCTION_RETURN(dw_listbox_count, int)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9633 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9634 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9635 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9636 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9637 int retval = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9638
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9639 /* Get the inner handle for scrolled controls */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9640 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9641 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9642 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9643 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9644 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9645 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9646 if(handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9647 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9648 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9649 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9650 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9651 else if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9652 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9653
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9654 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9655 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9656 /* Get the number of children at the top level */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9657 retval = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9658 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9659 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
9660 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9661 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9662
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9663 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9664 * Sets the topmost item in the viewport.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9665 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9666 * handle: Handle to the listbox to be cleared.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9667 * top: Index to the top item.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9668 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9669 DW_FUNCTION_DEFINITION(dw_listbox_set_top, void, HWND handle, int top)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9670 DW_FUNCTION_ADD_PARAM2(handle, top)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9671 DW_FUNCTION_NO_RETURN(dw_listbox_set_top)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9672 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, top, int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9673
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9674 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9675 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9676
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9677 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9678 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9679 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9680 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9681 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9682 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9683 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9684 if(handle2 && GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9685 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9686 GtkAdjustment *adjust = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9687 GtkListStore *store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9688
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9689 if(store && adjust)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9690 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9691 /* Get the number of children at the top level */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9692 gint rowcount = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9693 gdouble pagesize = gtk_adjustment_get_page_size(adjust);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9694 gdouble upper = gtk_adjustment_get_upper(adjust) - pagesize;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9695 gdouble lower = gtk_adjustment_get_lower(adjust);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9696 gdouble change;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9697
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9698 /* Safety check */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9699 if(rowcount > 1)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9700 {
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9701 /* Verify the range */
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9702 rowcount--;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9703 if(top > rowcount)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9704 top = rowcount;
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9705
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9706 change = ((gdouble)top/(gdouble)rowcount) * (upper - lower);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9707
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9708 gtk_adjustment_set_value(adjust, change + lower);
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9709 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9710 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9711 }
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9712 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9713 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9714
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9715 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9716 * Copies the given index item's text into buffer.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9717 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9718 * handle: Handle to the listbox to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9719 * index: Index into the list to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9720 * buffer: Buffer where text will be copied.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9721 * length: Length of the buffer (including NULL).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9722 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9723 DW_FUNCTION_DEFINITION(dw_listbox_get_text, void, HWND handle, unsigned int index, char *buffer, unsigned int length)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9724 DW_FUNCTION_ADD_PARAM4(handle, index, buffer, length)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9725 DW_FUNCTION_NO_RETURN(dw_listbox_get_text)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9726 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, index, unsigned int, buffer, char *, length, unsigned int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9727
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9728 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9729 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9730 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9731
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9732 /* Get the inner handle for scrolled controls */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9733 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9734 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9735 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9736 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9737 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9738 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9739 if(handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9740 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9741 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9742 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9743 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9744 else if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9745 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9746
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9747 if(store && index < gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9748 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9749 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9750
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9751 /* Get the nth child at the top level */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9752 if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, index))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9753 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9754 /* Get the text */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9755 gchar *text;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9756 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, _DW_DATA_TYPE_STRING, &text, -1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9757 if(text)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9758 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9759 strncpy(buffer, text, length);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9760 g_free(text);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9761 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9762 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9763 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9764 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9765 buffer[0] = '\0';
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9766 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9767 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9768
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9769 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9770 * Sets the text of a given listbox entry.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9771 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9772 * handle: Handle to the listbox to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9773 * index: Index into the list to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9774 * buffer: Buffer where text will be copied.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9775 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9776 DW_FUNCTION_DEFINITION(dw_listbox_set_text, void, HWND handle, unsigned int index, const char *buffer)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9777 DW_FUNCTION_ADD_PARAM3(handle, index, buffer)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9778 DW_FUNCTION_NO_RETURN(dw_listbox_set_text)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9779 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, unsigned int, buffer, char *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9780 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9781 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9782 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9783
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9784 /* Get the inner handle for scrolled controls */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9785 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9786 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9787 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9788 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9789 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9790 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9791 if(handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9792 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9793 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9794 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9795 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9796 else if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9797 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9798
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9799 if(store && index < gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9800 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9801 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9802
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9803 /* Get the nth child at the top level */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9804 if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, index))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9805 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9806 /* Update the text */
2744
608796a91527 GTK3/4: Committing a fix from Mark Hessling for dw_listbox_set_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2731
diff changeset
9807 gtk_list_store_set(store, &iter, 0, buffer, -1);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9808 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9809 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9810 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9811 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9812 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9813
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9814 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9815 * Returns the index to the current selected item or -1 when done.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9816 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9817 * handle: Handle to the listbox to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9818 * where: Either the previous return or -1 to restart.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9819 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9820 DW_FUNCTION_DEFINITION(dw_listbox_selected_multi, int, HWND handle, int where)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9821 DW_FUNCTION_ADD_PARAM2(handle, where)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9822 DW_FUNCTION_RETURN(dw_listbox_selected_multi, int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9823 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, where, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9824 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9825 GtkWidget *handle2;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9826 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9827 int retval = DW_LIT_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9828
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9829 handle2 = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9830
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9831 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9832 if(handle2 && GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9833 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9834
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9835 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9836 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9837 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9838 GList *list = gtk_tree_selection_get_selected_rows(sel, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9839
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9840 if(list)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9841 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9842 int counter = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9843 GtkTreePath *path = g_list_nth_data(list, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9844
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9845 while(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9846 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9847 gint *indices = gtk_tree_path_get_indices(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9848
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9849 if(indices && indices[0] > where)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9850 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9851 retval = indices[0];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9852 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9853 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9854
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9855 counter++;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9856 path = g_list_nth_data(list, counter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9857 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9858
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9859 g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9860 g_list_free(list);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9861 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9862 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9863 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9864 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9865
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9866 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9867 * Returns the index to the item in the list currently selected.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9868 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9869 * handle: Handle to the listbox to be queried.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9870 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9871 DW_FUNCTION_DEFINITION(dw_listbox_selected, int, HWND handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9872 DW_FUNCTION_ADD_PARAM1(handle)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9873 DW_FUNCTION_RETURN(dw_listbox_selected, int)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9874 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9875 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9876 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9877 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9878 unsigned int retval = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9879
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9880 /* Get the inner handle for scrolled controls */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9881 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9882 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9883 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9884 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9885 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9886 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9887 if(handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9888 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9889 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9890 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9891 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9892 else if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9893 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9894
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9895 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9896 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9897 if(GTK_IS_TREE_VIEW(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9898 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9899 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9900 GList *list = gtk_tree_selection_get_selected_rows(sel, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9901 if(list)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9902 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9903 GtkTreePath *path = g_list_nth_data(list, 0);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9904 gint *indices = gtk_tree_path_get_indices(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9905
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9906 if(indices)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9907 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9908 retval = indices[0];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9909 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9910
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9911 g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9912 g_list_free(list);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9913 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9914 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9915 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9916 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9917 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9918 GtkTreePath *path;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9919
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9920 if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(handle2), &iter))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9921 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9922 path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9923 if(path)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9924 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9925 gint *indices = gtk_tree_path_get_indices(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9926
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9927 if(indices)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9928 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9929 retval = indices[0];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9930 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9931 gtk_tree_path_free(path);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9932 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9933 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9934 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9935 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9936 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9937 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9938 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9939
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9940 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9941 * Sets the selection state of a given index.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9942 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9943 * handle: Handle to the listbox to be set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9944 * index: Item index.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9945 * state: TRUE if selected FALSE if unselected.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9946 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9947 DW_FUNCTION_DEFINITION(dw_listbox_select, void, HWND handle, int index, int state)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9948 DW_FUNCTION_ADD_PARAM3(handle, index, state)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9949 DW_FUNCTION_NO_RETURN(dw_listbox_select)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9950 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, int, state, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9951 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9952 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9953 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9954
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9955 /* Get the inner handle for scrolled controls */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9956 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9957 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9958 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9959 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9960 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9961 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9962 if(handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9963 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9964 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9965 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9966 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9967 else if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9968 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9969
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9970 if(store && index < gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9971 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9972 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9973
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9974 /* Get the nth child at the top level */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9975 if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, index))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9976 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9977 if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9978 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9979 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(handle2), &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9980 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9981 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9982 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9983 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9984 if(state)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9985 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9986 /* Select the item */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9987 gtk_tree_selection_select_iter(sel, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9988 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9989 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9990 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9991 /* Deselect the item */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9992 gtk_tree_selection_unselect_iter(sel, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9993 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9994 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9995 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9996 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9997 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
9998 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9999 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10000
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10001 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10002 * Deletes the item with given index from the list.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10003 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10004 * handle: Handle to the listbox to be set.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10005 * index: Item index.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10006 */
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
10007 DW_FUNCTION_DEFINITION(dw_listbox_delete, void, HWND handle, int index)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
10008 DW_FUNCTION_ADD_PARAM2(handle, index)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
10009 DW_FUNCTION_NO_RETURN(dw_listbox_delete)
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
10010 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, index, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10011 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10012 GtkWidget *handle2 = handle;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10013 GtkListStore *store = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10014
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10015 /* Get the inner handle for scrolled controls */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10016 if(GTK_IS_SCROLLED_WINDOW(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10017 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10018 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10019 if(tmp)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10020 handle2 = tmp;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10021 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10022 if(handle2)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10023 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10024 /* Make sure it is the correct tree type */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10025 if(GTK_IS_TREE_VIEW(handle2) && g_object_get_data(G_OBJECT(handle2), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_LISTBOX))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10026 store = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10027 else if(GTK_IS_COMBO_BOX(handle2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10028 store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(handle2));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10029
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10030 if(store)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10031 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10032 GtkTreeIter iter;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10033
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10034 /* Get the nth child at the top level */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10035 if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, NULL, index))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10036 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10037 gtk_list_store_remove(store, &iter);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10038 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10039 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10040 }
2304
ae6f678cb1a9 GTK4: Implement thread safety system based on the new MacOS thread code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2303
diff changeset
10041 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10042 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10043
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10044 /* Function to do delayed positioning */
2301
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10045 gboolean _dw_splitbar_set_percent(gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10046 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10047 GtkWidget *widget = data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10048 float *percent = (float *)g_object_get_data(G_OBJECT(widget), "_dw_percent");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10049
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10050 if(percent)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10051 {
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10052 int width, height;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10053 #if GTK_CHECK_VERSION(4,12,0)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10054 width = gtk_widget_get_width(widget);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10055 height = gtk_widget_get_height(widget);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10056 #else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10057 GtkAllocation alloc;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10058
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10059 gtk_widget_get_allocation(widget, &alloc);
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10060 width = alloc.width;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10061 height = alloc.height;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10062 #endif
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10063
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10064 if(width > 10 && height > 10)
2301
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10065 {
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10066 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(widget)) == GTK_ORIENTATION_HORIZONTAL)
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10067 gtk_paned_set_position(GTK_PANED(widget), (int)(width * (*percent / 100.0)));
2301
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10068 else
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10069 gtk_paned_set_position(GTK_PANED(widget), (int)(height * (*percent / 100.0)));
2301
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10070 g_object_set_data(G_OBJECT(widget), "_dw_percent", NULL);
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10071 free(percent);
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10072 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10073 else
2301
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10074 return TRUE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10075 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10076 return FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10077 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10078
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10079 /* Reposition the bar according to the percentage */
2301
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10080 static gint _dw_splitbar_realize(GtkWidget *widget, gpointer data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10081 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10082 float *percent = (float *)g_object_get_data(G_OBJECT(widget), "_dw_percent");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10083
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10084 /* Prevent infinite recursion ;) */
2295
2a208d5400c5 GTK4: "size-allocate" signal is gone, so switch to using "realize".
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2292
diff changeset
10085 if(!percent)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10086 return FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10087
2301
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10088 g_idle_add(_dw_splitbar_set_percent, widget);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10089 return FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10090 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10091
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10092 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10093 * Creates a splitbar window (widget) with given parameters.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10094 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10095 * type: Value can be DW_VERT or DW_HORZ.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10096 * topleft: Handle to the window to be top or left.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10097 * bottomright: Handle to the window to be bottom or right.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10098 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10099 * A handle to a splitbar window or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10100 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10101 DW_FUNCTION_DEFINITION(dw_splitbar_new, HWND, int type, HWND topleft, HWND bottomright, unsigned long cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10102 DW_FUNCTION_ADD_PARAM4(type, topleft, bottomright, cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10103 DW_FUNCTION_RETURN(dw_splitbar_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10104 DW_FUNCTION_RESTORE_PARAM4(type, int, topleft, HWND, bottomright, HWND, cid, unsigned long)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10105 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10106 GtkWidget *tmp = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10107 float *percent = malloc(sizeof(float));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10108
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10109 tmp = gtk_paned_new(type == DW_HORZ ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10110 gtk_paned_set_start_child(GTK_PANED(tmp), topleft);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10111 gtk_paned_set_resize_start_child(GTK_PANED(tmp), TRUE);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10112 gtk_paned_set_shrink_start_child(GTK_PANED(tmp), FALSE);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10113 gtk_paned_set_end_child(GTK_PANED(tmp), bottomright);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10114 gtk_paned_set_resize_end_child(GTK_PANED(tmp), TRUE);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10115 gtk_paned_set_shrink_end_child(GTK_PANED(tmp), FALSE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10116 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10117 *percent = 50.0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10118 g_object_set_data(G_OBJECT(tmp), "_dw_percent", (gpointer)percent);
2301
69b06073a87d GTK4: The "realize" signal is not quite the same as "size-allocate" so if
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2300
diff changeset
10119 g_signal_connect(G_OBJECT(tmp), "realize", G_CALLBACK(_dw_splitbar_realize), NULL);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
10120 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10121 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10122 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10123
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10124 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10125 * Sets the position of a splitbar (pecentage).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10126 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10127 * handle: The handle to the splitbar returned by dw_splitbar_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10128 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10129 DW_FUNCTION_DEFINITION(dw_splitbar_set, void, HWND handle, float percent)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10130 DW_FUNCTION_ADD_PARAM2(handle, percent)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10131 DW_FUNCTION_NO_RETURN(dw_splitbar_set)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10132 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, percent, float)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10133 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10134 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10135 int size = 0, position;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10136
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10137 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_HORIZONTAL)
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10138 {
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10139 #if GTK_CHECK_VERSION(4,12,0)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10140 size = gtk_widget_get_width(handle);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10141 #else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10142 size = gtk_widget_get_allocated_width(handle);
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10143 #endif
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10144 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10145 else
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10146 {
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10147 #if GTK_CHECK_VERSION(4,12,0)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10148 size = gtk_widget_get_height(handle);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10149 #else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10150 size = gtk_widget_get_allocated_height(handle);
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10151 #endif
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10152 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10153
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10154 if(mypercent)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10155 *mypercent = percent;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10156
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10157 if(size > 10)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10158 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10159 position = (int)((float)size * (percent / 100.0));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10160
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10161 gtk_paned_set_position(GTK_PANED(handle), position);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10162 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10163 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10164 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10165
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10166 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10167 * Gets the position of a splitbar (pecentage).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10168 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10169 * handle: The handle to the splitbar returned by dw_splitbar_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10170 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10171 DW_FUNCTION_DEFINITION(dw_splitbar_get, float, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10172 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10173 DW_FUNCTION_RETURN(dw_splitbar_get, float)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10174 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10175 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10176 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10177 float retval = 0.0;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10178
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10179 if(percent)
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10180 retval = *percent;
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10181 DW_FUNCTION_RETURN_THIS(retval);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10182 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10183
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10184 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10185 * Creates a calendar window (widget) with given parameters.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10186 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10187 * id: Unique identifier for calendar widget
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10188 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10189 * A handle to a calendar window or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10190 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10191 DW_FUNCTION_DEFINITION(dw_calendar_new, HWND, ULONG cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10192 DW_FUNCTION_ADD_PARAM1(cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10193 DW_FUNCTION_RETURN(dw_calendar_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10194 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10195 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10196 GtkWidget *tmp = gtk_calendar_new();
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10197 GTimeZone *tz = g_time_zone_new_local();
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10198 GDateTime *now = g_date_time_new_now(tz);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10199
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
10200 gtk_widget_set_visible(tmp, TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10201 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10202 /* select today */
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10203 gtk_calendar_set_show_day_names(GTK_CALENDAR(tmp), TRUE);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10204 gtk_calendar_set_show_heading(GTK_CALENDAR(tmp), TRUE);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10205 gtk_calendar_select_day(GTK_CALENDAR(tmp), now);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10206 g_date_time_unref(now);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10207 g_time_zone_unref(tz);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10208 DW_FUNCTION_RETURN_THIS(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10209 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10210
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10211 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10212 * Sets the current date of a calendar
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10213 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10214 * handle: The handle to the calendar returned by dw_calendar_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10215 * year...
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10216 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10217 DW_FUNCTION_DEFINITION(dw_calendar_set_date, void, HWND handle, unsigned int year, unsigned int month, unsigned int day)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10218 DW_FUNCTION_ADD_PARAM4(handle, year, month, day)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10219 DW_FUNCTION_NO_RETURN(dw_calendar_set_date)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10220 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, year, unsigned int, month, unsigned int, day, unsigned int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10221 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10222 if(GTK_IS_CALENDAR(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10223 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10224 GTimeZone *tz = g_time_zone_new_local();
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10225 GDateTime *datetime = g_date_time_new(tz, year, month, day, 0, 0, 0);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10226 gtk_calendar_select_day(GTK_CALENDAR(handle), datetime);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10227 g_date_time_unref(datetime);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10228 g_time_zone_unref(tz);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10229 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10230 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10231 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10232
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10233 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10234 * Gets the position of a splitbar (pecentage).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10235 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10236 * handle: The handle to the splitbar returned by dw_splitbar_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10237 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10238 DW_FUNCTION_DEFINITION(dw_calendar_get_date, void, HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10239 DW_FUNCTION_ADD_PARAM4(handle, year, month, day)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10240 DW_FUNCTION_NO_RETURN(dw_calendar_get_date)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10241 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, year, unsigned int *, month, unsigned int *, day, unsigned int *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10242 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10243 if(GTK_IS_CALENDAR(handle))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10244 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10245 GDateTime *datetime = gtk_calendar_get_date(GTK_CALENDAR(handle));
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10246 if(year)
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10247 *year = g_date_time_get_year(datetime);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10248 if(month)
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10249 *month = g_date_time_get_month(datetime);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10250 if(day)
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10251 *day = g_date_time_get_day_of_month(datetime);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10252 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10253 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10254 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10255
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10256 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10257 * Sets the current focus item for a window/dialog.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10258 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10259 * handle: Handle to the dialog item to be focused.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10260 * Remarks:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10261 * This is for use after showing the window/dialog.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10262 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10263 DW_FUNCTION_DEFINITION(dw_window_set_focus, void, HWND handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10264 DW_FUNCTION_ADD_PARAM1(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10265 DW_FUNCTION_NO_RETURN(dw_window_set_focus)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10266 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10267 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10268 if(handle)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10269 gtk_widget_grab_focus(handle);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10270 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10271 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10272
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10273 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10274 * Sets the default focus item for a window/dialog.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10275 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10276 * window: Toplevel window or dialog.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10277 * defaultitem: Handle to the dialog item to be default.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10278 * Remarks:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10279 * This is for use before showing the window/dialog.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10280 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10281 void API dw_window_default(HWND window, HWND defaultitem)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10282 {
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10283 if(window)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10284 g_object_set_data(G_OBJECT(window), "_dw_defaultitem", (gpointer)defaultitem);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10285 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10286
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10287 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10288 * Sets window to click the default dialog item when an ENTER is pressed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10289 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10290 * window: Window (widget) to look for the ENTER press.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10291 * next: Window (widget) to move to next (or click)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10292 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10293 DW_FUNCTION_DEFINITION(dw_window_click_default, void, HWND window, HWND next)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10294 DW_FUNCTION_ADD_PARAM2(window, next)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10295 DW_FUNCTION_NO_RETURN(dw_window_click_default)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10296 DW_FUNCTION_RESTORE_PARAM2(window, HWND, next, HWND)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10297 {
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
10298 if(window && next && GTK_IS_WIDGET(window) && GTK_IS_WIDGET(next))
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
10299 {
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
10300 GtkEventController *controller = gtk_event_controller_key_new();
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
10301 gtk_widget_add_controller(GTK_WIDGET(window), controller);
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
10302 g_signal_connect(G_OBJECT(controller), "key-pressed", G_CALLBACK(_dw_default_key_press_event), next);
2267
7ac85e938b71 GTK4: Don't try to link webkit on GTK4... it doesn't support it yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2266
diff changeset
10303 }
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10304 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10305 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10306
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10307
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10308 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10309 * Creates a new system notification if possible.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10310 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10311 * title: The short title of the notification.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10312 * imagepath: Path to an image to display or NULL if none.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10313 * description: A longer description of the notification,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10314 * or NULL if none is necessary.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10315 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10316 * A handle to the notification which can be used to attach a "clicked" event if desired,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10317 * or NULL if it fails or notifications are not supported by the system.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10318 * Remarks:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10319 * This will create a system notification that will show in the notifaction panel
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10320 * on supported systems, which may be clicked to perform another task.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10321 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10322 HWND API dw_notification_new(const char *title, const char *imagepath, const char *description, ...)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10323 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10324 GNotification *notification = g_notification_new(title);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10325
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10326 if(notification)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10327 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10328 if(description)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10329 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10330 va_list args;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10331 char outbuf[1025] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10332
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10333 va_start(args, description);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10334 vsnprintf(outbuf, 1024, description, args);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10335 va_end(args);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10336
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10337 g_notification_set_body(notification, outbuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10338 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10339 if(imagepath)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10340 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10341 GFile *file = g_file_new_for_path(imagepath);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10342 GBytes *bytes = g_file_load_bytes(file, NULL, NULL, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10343
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10344 if(bytes)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10345 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10346 GIcon *icon = g_bytes_icon_new(bytes);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10347
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10348 if(icon)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10349 g_notification_set_icon(notification, G_ICON(icon));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10350 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10351 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10352 g_notification_set_default_action_and_target(notification, "app.notification", "t",
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10353 (guint64)DW_POINTER_TO_ULONGLONG(notification));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10354 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10355 return (HWND)notification;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10356 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10357
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10358 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10359 * Sends a notification created by dw_notification_new() after attaching signal handler.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10360 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10361 * notification: The handle to the notification returned by dw_notification_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10362 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10363 * DW_ERROR_NONE on success, DW_ERROR_UNKNOWN on error or not supported.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10364 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10365 int API dw_notification_send(HWND notification)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10366 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10367 if(notification)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10368 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10369 char id[101] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10370
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10371 /* Generate a unique ID based on the notification handle,
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10372 * so we can use it to remove the notification in dw_window_destroy().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10373 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10374 snprintf(id, 100, "dw-notification-%llu", DW_POINTER_TO_ULONGLONG(notification));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10375 g_application_send_notification(_DWApp, id, (GNotification *)notification);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10376 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10377 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10378 return DW_ERROR_UNKNOWN;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10379 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10380
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10381 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10382 * Returns some information about the current operating environment.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10383 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10384 * env: Pointer to a DWEnv struct.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10385 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10386 void API dw_environment_query(DWEnv *env)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10387 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10388 struct utsname name;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10389 char tempbuf[_DW_ENV_STRING_SIZE] = { 0 }, *dot;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10390
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10391 uname(&name);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10392 memset(env, '\0', sizeof(DWEnv));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10393 strncpy(env->osName, name.sysname, sizeof(env->osName)-1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10394 strncpy(tempbuf, name.release, sizeof(tempbuf)-1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10395
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10396 strncpy(env->buildDate, __DATE__, sizeof(env->buildDate)-1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10397 strncpy(env->buildTime, __TIME__, sizeof(env->buildTime)-1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10398 #ifdef USE_WEBKIT
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10399 strncpy(env->htmlEngine, "WEBKIT2", sizeof(env->htmlEngine)-1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10400 #else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10401 strncpy(env->htmlEngine, "N/A", sizeof(env->htmlEngine)-1);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10402 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10403 env->DWMajorVersion = DW_MAJOR_VERSION;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10404 env->DWMinorVersion = DW_MINOR_VERSION;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10405 #ifdef VER_REV
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10406 env->DWSubVersion = VER_REV;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10407 #else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10408 env->DWSubVersion = DW_SUB_VERSION;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10409 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10410
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10411 if((dot = strchr(tempbuf, '.')) != NULL)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10412 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10413 *dot = '\0';
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10414 env->MajorVersion = atoi(tempbuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10415 env->MinorVersion = atoi(&dot[1]);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10416 return;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10417 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10418 env->MajorVersion = atoi(tempbuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10419 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10420
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10421 #if GTK_CHECK_VERSION(4,10,0)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10422 static void _dw_file_browse_response(GObject *gobject, GAsyncResult *result, gpointer data)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10423 {
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10424 DWDialog *tmp = data;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10425 GError *error = NULL;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10426 char *filename = NULL;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10427 GFile *file = NULL;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10428
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10429 /* Bail out if there is no DWDialog */
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10430 if(!tmp)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10431 return;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10432
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10433 switch(DW_POINTER_TO_INT(tmp->data))
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10434 {
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10435 case DW_DIRECTORY_OPEN:
3003
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
10436 file = gtk_file_dialog_select_folder_finish(GTK_FILE_DIALOG(gobject), result, &error);
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10437 break;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10438 case DW_FILE_OPEN:
3003
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
10439 file = gtk_file_dialog_open_finish(GTK_FILE_DIALOG(gobject), result, &error);
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10440 break;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10441 case DW_FILE_SAVE:
3003
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
10442 file = gtk_file_dialog_save_finish(GTK_FILE_DIALOG(gobject), result, &error);
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10443 break;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10444 default:
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10445 break;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10446 }
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10447
3003
dc33d380d614 GTK4: Fix more deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3002
diff changeset
10448 if(error == NULL && file != NULL)
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10449 {
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10450 filename = g_file_get_path(file);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10451 g_object_unref(G_OBJECT(file));
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10452 }
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10453 dw_dialog_dismiss(tmp, filename);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10454 }
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10455 #endif
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10456
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10457 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10458 * Opens a file dialog and queries user selection.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10459 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10460 * title: Title bar text for dialog.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10461 * defpath: The default path of the open dialog.
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10462 * ext: Default file extension.
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10463 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10464 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10465 * NULL on error. A malloced buffer containing
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10466 * the file path on success.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10467 *
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10468 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10469 DW_FUNCTION_DEFINITION(dw_file_browse, char *, const char *title, const char *defpath, const char *ext, int flags)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10470 DW_FUNCTION_ADD_PARAM4(title, defpath, ext, flags)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10471 DW_FUNCTION_RETURN(dw_file_browse, char *)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10472 DW_FUNCTION_RESTORE_PARAM4(title, const char *, defpath, const char *, ext, const char *, flags, int)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10473 {
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10474 char buf[1001] = {0};
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10475 char *filename = NULL;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10476 DWDialog *tmp = dw_dialog_new(DW_INT_TO_POINTER(flags));
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10477 #if GTK_CHECK_VERSION(4,10,0)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10478 GtkFileDialog *dialog = gtk_file_dialog_new();
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10479
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10480 gtk_file_dialog_set_title(dialog, title);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10481 if(defpath)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10482 {
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10483 GFile *path = g_file_new_for_path(defpath);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10484
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10485 /* See if the path exists */
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10486 if(path)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10487 {
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10488 /* If the path is a directory... set the current folder */
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10489 if(g_file_query_file_type(path, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10490 gtk_file_dialog_set_initial_folder(dialog, path);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10491 else
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10492 gtk_file_dialog_set_initial_file(dialog, path);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10493
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10494 g_object_unref(G_OBJECT(path));
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10495 }
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10496 }
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10497 if(ext)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10498 {
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10499 GListStore *filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10500 GtkFileFilter *filter = gtk_file_filter_new();
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10501 snprintf(buf, 1000, "*.%s", ext);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10502 gtk_file_filter_add_pattern(filter, (gchar *)buf);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10503 snprintf(buf, 1000, "\"%s\" files", ext);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10504 gtk_file_filter_set_name(filter, (gchar *)buf);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10505 g_list_store_append(filters, filter);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10506 filter = gtk_file_filter_new();
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10507 gtk_file_filter_add_pattern(filter, (gchar *)"*");
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10508 gtk_file_filter_set_name(filter, (gchar *)"All Files");
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10509 g_list_store_append(filters, filter);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10510 gtk_file_dialog_set_filters(dialog, G_LIST_MODEL(filters));
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10511 }
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10512
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10513 switch(flags)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10514 {
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10515 case DW_DIRECTORY_OPEN:
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10516 gtk_file_dialog_select_folder(dialog, NULL, NULL, (GAsyncReadyCallback)_dw_file_browse_response, tmp);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10517 break;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10518 case DW_FILE_OPEN:
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10519 gtk_file_dialog_open(dialog, NULL, NULL, (GAsyncReadyCallback)_dw_file_browse_response, tmp);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10520 break;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10521 case DW_FILE_SAVE:
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10522 gtk_file_dialog_save(dialog, NULL, NULL, (GAsyncReadyCallback)_dw_file_browse_response, tmp);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10523 break;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10524 default:
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10525 dw_messagebox( "Coding error", DW_MB_OK|DW_MB_ERROR, "dw_file_browse() flags argument invalid.");
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10526 tmp = NULL;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10527 break;
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10528 }
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10529
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10530 if(tmp)
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10531 filename = dw_dialog_wait(tmp);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10532 #else
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10533 GtkWidget *filew;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10534 GtkFileChooserAction action;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10535 gchar *button = NULL;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10536
2346
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10537 switch(flags)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10538 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10539 case DW_DIRECTORY_OPEN:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10540 action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10541 button = _("_Open");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10542 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10543 case DW_FILE_OPEN:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10544 action = GTK_FILE_CHOOSER_ACTION_OPEN;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10545 button = _("_Open");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10546 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10547 case DW_FILE_SAVE:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10548 action = GTK_FILE_CHOOSER_ACTION_SAVE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10549 button = _("_Save");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10550 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10551 default:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10552 dw_messagebox( "Coding error", DW_MB_OK|DW_MB_ERROR, "dw_file_browse() flags argument invalid.");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10553 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10554 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10555
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10556 if(button)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10557 {
2346
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10558 filew = gtk_file_chooser_dialog_new(title,
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10559 NULL,
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10560 action,
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10561 _("_Cancel"), GTK_RESPONSE_CANCEL,
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10562 button, GTK_RESPONSE_ACCEPT,
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10563 NULL);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10564
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10565 if(ext)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10566 {
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10567 GtkFileFilter *filter = gtk_file_filter_new();
2346
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10568 snprintf(buf, 1000, "*.%s", ext);
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10569 gtk_file_filter_add_pattern(filter, (gchar *)buf);
2347
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10570 snprintf(buf, 1000, "\"%s\" files", ext);
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10571 gtk_file_filter_set_name(filter, (gchar *)buf);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10572 gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filew), filter);
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10573 filter = gtk_file_filter_new();
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10574 gtk_file_filter_add_pattern(filter, (gchar *)"*");
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10575 gtk_file_filter_set_name(filter, (gchar *)"All Files");
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10576 gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filew), filter);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10577 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10578
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10579 if(defpath)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10580 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10581 GFile *path = g_file_new_for_path(defpath);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10582
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10583 /* See if the path exists */
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10584 if(path)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10585 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10586 /* If the path is a directory... set the current folder */
2346
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10587 if(g_file_query_file_type(path, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY)
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10588 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filew), path, NULL);
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10589 else
7b04d1b9f2eb GTK4: Fix warning message from dW_file_browse() and code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2341
diff changeset
10590 gtk_file_chooser_set_file(GTK_FILE_CHOOSER(filew), path, NULL);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10591
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10592 g_object_unref(G_OBJECT(path));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10593 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10594 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10595
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
10596 gtk_widget_set_visible(GTK_WIDGET(filew), TRUE);
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10597 g_signal_connect(G_OBJECT(filew), "response", G_CALLBACK(_dw_dialog_response), (gpointer)tmp);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10598
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10599 if(DW_POINTER_TO_INT(dw_dialog_wait(tmp)) == GTK_RESPONSE_ACCEPT)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10600 {
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10601 GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(filew));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10602 filename = g_file_get_path(file);
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10603 g_object_unref(G_OBJECT(file));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10604 }
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10605
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10606 if(GTK_IS_WINDOW(filew))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10607 gtk_window_destroy(GTK_WINDOW(filew));
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10608 }
3002
a70d8ce6151c GTK4: Fix a number of deprecation warnings in GTK 4.10 and later.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2998
diff changeset
10609 #endif
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10610 DW_FUNCTION_RETURN_THIS(filename);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10611 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10612
2347
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10613 static void _dw_exec_launched(GAppLaunchContext *context, GAppInfo *info, GVariant *platform_data, gpointer data)
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10614 {
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10615 g_variant_lookup(platform_data, "pid", "i", data);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10616 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10617
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10618 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10619 * Execute and external program in a seperate session.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10620 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10621 * program: Program name with optional path.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10622 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10623 * params: An array of pointers to string arguements.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10624 * Returns:
2347
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10625 * DW_ERROR_UNKNOWN on error.
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10626 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10627 int API dw_exec(const char *program, int type, char **params)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10628 {
2347
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10629 GAppInfo *appinfo = NULL;
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10630 char *commandline;
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10631 int retval = DW_ERROR_UNKNOWN;
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10632
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10633 /* Generate a command line from the parameters */
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10634 if(params && *params)
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10635 {
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10636 int z = 0, len = 0;
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10637
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10638 while(params[z])
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10639 {
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10640 len+=strlen(params[z]) + 1;
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10641 z++;
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10642 }
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10643 z=1;
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10644 commandline = calloc(1, len);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10645 strcpy(commandline, params[0]);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10646 while(params[z])
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10647 {
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10648 strcat(commandline, " ");
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10649 strcat(commandline, params[z]);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10650 z++;
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10651 }
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10652 }
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10653 else
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10654 commandline = strdup(program);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10655
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10656 /* Attempt to use app preferences to launch the application, using the selected Terminal if necessary */
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10657 if((appinfo = g_app_info_create_from_commandline(commandline, NULL,
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10658 type == DW_EXEC_CON ? G_APP_INFO_CREATE_NEEDS_TERMINAL : G_APP_INFO_CREATE_NONE, NULL)))
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10659 {
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10660 GAppLaunchContext *context = g_app_launch_context_new();
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10661
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10662 g_signal_connect(G_OBJECT(context), "launched", G_CALLBACK(_dw_exec_launched), (gpointer)&retval);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10663
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10664 g_app_info_launch(appinfo, NULL, context, NULL);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10665
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10666 g_object_unref(appinfo);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10667 g_object_unref(context);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10668 }
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10669 free(commandline);
e5d4c86a0c93 GTK4: Rewrite dw_exec() using GLib. Will port to GTK2 and 3 as well.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2346
diff changeset
10670 return retval;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10671 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10672
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10673 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10674 * Loads a web browser pointed at the given URL.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10675 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10676 * url: Uniform resource locator.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10677 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10678 int API dw_browse(const char *url)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10679 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10680 /* If possible load the URL/URI using gvfs... */
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10681 gtk_show_uri(NULL, url, GDK_CURRENT_TIME);
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10682 return DW_ERROR_NONE;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10683 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10684
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10685 #ifdef USE_WEBKIT
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10686 /* Helper function to get the web view handle */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10687 WebKitWebView *_dw_html_web_view(GtkWidget *widget)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10688 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10689 if(widget)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10690 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10691 WebKitWebView *web_view = (WebKitWebView *)widget;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10692 if(WEBKIT_IS_WEB_VIEW(web_view))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10693 return web_view;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10694 #ifndef USE_WEBKIT2
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10695 web_view = (WebKitWebView *)g_object_get_data(G_OBJECT(widget), "_dw_web_view");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10696 if(WEBKIT_IS_WEB_VIEW(web_view))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10697 return web_view;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10698 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10699 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10700 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10701 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10702 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10703 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10704 * Causes the embedded HTML widget to take action.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10705 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10706 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10707 * action: One of the DW_HTML_* constants.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10708 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10709 void API dw_html_action(HWND handle, int action)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10710 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10711 #ifdef USE_WEBKIT
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10712 WebKitWebView *web_view;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10713
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10714 if((web_view = _dw_html_web_view(handle)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10715 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10716 switch(action)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10717 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10718 case DW_HTML_GOBACK:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10719 webkit_web_view_go_back(web_view);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10720 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10721 case DW_HTML_GOFORWARD:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10722 webkit_web_view_go_forward(web_view);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10723 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10724 case DW_HTML_GOHOME:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10725 webkit_web_view_load_uri(web_view, DW_HOME_URL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10726 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10727 case DW_HTML_RELOAD:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10728 webkit_web_view_reload(web_view);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10729 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10730 case DW_HTML_STOP:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10731 webkit_web_view_stop_loading(web_view);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10732 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10733 case DW_HTML_PRINT:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10734 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10735 WebKitPrintOperation *operation = webkit_print_operation_new(web_view);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10736 webkit_print_operation_run_dialog(operation, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10737 g_object_unref(operation);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10738 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10739 break;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10740 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10741 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10742 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10743 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10744
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10745 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10746 * Render raw HTML code in the embedded HTML widget..
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10747 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10748 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10749 * string: String buffer containt HTML code to
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10750 * be rendered.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10751 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10752 * 0 on success.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10753 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10754 int API dw_html_raw(HWND handle, const char *string)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10755 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10756 #ifdef USE_WEBKIT
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10757 WebKitWebView *web_view;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10758
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10759 if((web_view = _dw_html_web_view(handle)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10760 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10761 webkit_web_view_load_html(web_view, string, "file:///");
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
10762 gtk_widget_set_visible(GTK_WIDGET(handle), TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10763 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10764 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10765 #else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10766 return DW_ERROR_UNKNOWN;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10767 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10768 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10769
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10770 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10771 * Render file or web page in the embedded HTML widget..
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10772 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10773 * handle: Handle to the window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10774 * url: Universal Resource Locator of the web or
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10775 * file object to be rendered.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10776 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10777 * 0 on success.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10778 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10779 int API dw_html_url(HWND handle, const char *url)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10780 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10781 #ifdef USE_WEBKIT
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10782 WebKitWebView *web_view;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10783
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10784 if((web_view = _dw_html_web_view(handle)))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10785 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10786 webkit_web_view_load_uri(web_view, url);
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
10787 gtk_widget_set_visible(GTK_WIDGET(handle), TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10788 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10789 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10790 #else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10791 return DW_ERROR_UNKNOWN;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10792 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10793 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10794
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10795 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10796 * Executes the javascript contained in "script" in the HTML window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10797 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10798 * handle: Handle to the HTML window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10799 * script: Javascript code to execute.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10800 * scriptdata: Data passed to the signal handler.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10801 * Notes: A DW_SIGNAL_HTML_RESULT event will be raised with scriptdata.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10802 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10803 * DW_ERROR_NONE (0) on success.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10804 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10805 int API dw_html_javascript_run(HWND handle, const char *script, void *scriptdata)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10806 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10807 #ifdef USE_WEBKIT
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10808 WebKitWebView *web_view;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10809
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10810 if(script && (web_view = _dw_html_web_view(handle)))
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10811 #ifdef USE_WEBKIT6
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10812 webkit_web_view_evaluate_javascript(web_view, script, strlen(script), NULL, NULL, NULL, _dw_html_result_event, scriptdata);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10813 #else
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
10814 webkit_web_view_run_javascript(web_view, script, NULL, _dw_html_result_event, scriptdata);
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10815 #endif
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10816 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10817 #else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10818 return DW_ERROR_UNKNOWN;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10819 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10820 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10821
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10822 /* Free the name when the signal disconnects */
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10823 void _dw_html_message_disconnect(gpointer gdata, GClosure *closure)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10824 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10825 gpointer *data = (gpointer *)gdata;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10826
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10827 if(data)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10828 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10829 gchar *name = (gchar *)data[1];
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10830
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10831 if(name)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10832 g_free(name);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10833 free(data);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10834 }
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10835 }
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10836
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10837 /*
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10838 * Install a javascript function with name that can call native code.
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10839 * Parameters:
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10840 * handle: Handle to the HTML window.
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10841 * name: Javascript function name.
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10842 * Notes: A DW_SIGNAL_HTML_MESSAGE event will be raised with scriptdata.
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10843 * Returns:
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10844 * DW_ERROR_NONE (0) on success.
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10845 */
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10846 int API dw_html_javascript_add(HWND handle, const char *name)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10847 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10848 #ifdef USE_WEBKIT
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10849 WebKitWebView *web_view= _dw_html_web_view(handle);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10850 WebKitUserContentManager *manager;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10851
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10852 if(web_view && (manager = webkit_web_view_get_user_content_manager(web_view)) && name)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10853 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10854 /* Script to inject that will call the handler we are adding */
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10855 gchar *script = g_strdup_printf("function %s(body) {window.webkit.messageHandlers.%s.postMessage(body);}",
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10856 name, name);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10857 gchar *signal = g_strdup_printf("script-message-received::%s", name);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10858 WebKitUserScript *userscript = webkit_user_script_new(script, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10859 WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_START, NULL, NULL);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10860 gpointer *data = calloc(sizeof(gpointer), 2);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10861
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10862 data[0] = handle;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10863 data[1] = g_strdup(name);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10864 g_signal_connect_data(manager, signal, G_CALLBACK(_dw_html_message_event), data, _dw_html_message_disconnect, 0);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10865 webkit_user_content_manager_register_script_message_handler(manager, name
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10866 #if USE_WEBKIT6
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10867 , NULL
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10868 #endif
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10869 );
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10870 webkit_user_content_manager_add_script(manager, userscript);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10871
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10872 g_free(script);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10873 g_free(signal);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10874 return DW_ERROR_NONE;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10875 }
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10876 #endif
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10877 return DW_ERROR_UNKNOWN;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10878 }
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
10879
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10880 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10881 * Create a new HTML window (widget) to be packed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10882 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10883 * id: An ID to be used with dw_window_from_id() or 0L.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10884 */
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10885 DW_FUNCTION_DEFINITION(dw_html_new, HWND, DW_UNUSED(ULONG cid))
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10886 DW_FUNCTION_ADD_PARAM1(cid)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10887 DW_FUNCTION_RETURN(dw_html_new, HWND)
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10888 DW_FUNCTION_RESTORE_PARAM1(DW_UNUSED(cid), ULONG)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10889 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10890 GtkWidget *widget = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10891 #ifdef USE_WEBKIT
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10892 WebKitWebView *web_view;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10893 WebKitSettings *settings;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10894
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10895 web_view = (WebKitWebView *)webkit_web_view_new();
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10896 settings = webkit_web_view_get_settings(web_view);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10897 /* Make sure java script is enabled */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10898 webkit_settings_set_enable_javascript(settings, TRUE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10899 webkit_web_view_set_settings(web_view, settings);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10900 widget = (GtkWidget *)web_view;
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10901 g_object_set_data(G_OBJECT(widget), "_dw_id", GINT_TO_POINTER(cid));
2998
4861e9f49907 GTK4: Here we go down this rabbit hole again. GTK 4.10 is deprecating tons of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2997
diff changeset
10902 gtk_widget_set_visible(widget, TRUE);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10903 #else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10904 dw_debug( "HTML widget not available; you do not have access to webkit.\n" );
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10905 #endif
2305
047ad6a5cc1d GTK4: Add more functions to the thread safety system... might need to do
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2304
diff changeset
10906 DW_FUNCTION_RETURN_THIS(widget);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10907 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10908
2274
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10909 static void _dw_clipboard_callback(GObject *object, GAsyncResult *res, gpointer data)
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10910 {
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10911 DWDialog *tmp = (DWDialog *)data;
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10912
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10913 if(tmp && tmp->data)
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10914 {
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10915 char *text = gdk_clipboard_read_text_finish(GDK_CLIPBOARD(tmp->data), res, NULL);
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10916
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10917 dw_dialog_dismiss(tmp, text ? strdup(text) : text);
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10918 }
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10919 }
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10920
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10921 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10922 * Gets the contents of the default clipboard as text.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10923 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10924 * None.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10925 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10926 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10927 * be converted to text.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10928 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10929 char * API dw_clipboard_get_text(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10930 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10931 GdkDisplay *display = gdk_display_get_default();
2274
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10932 GdkClipboard *clipboard;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10933 char *ret = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10934
2274
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10935 if((clipboard = gdk_display_get_clipboard(display)))
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10936 {
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10937 DWDialog *tmp = dw_dialog_new(DW_POINTER(clipboard));
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10938
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10939 gdk_clipboard_read_text_async(clipboard, NULL, _dw_clipboard_callback, (gpointer)tmp);
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10940
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10941 ret = (char *)dw_dialog_wait(tmp);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10942 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10943 return ret;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10944 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10945
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10946 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10947 * Sets the contents of the default clipboard to the supplied text.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10948 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10949 * Text.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10950 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
10951 void API dw_clipboard_set_text(const char *str, int len)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10952 {
2266
bb0690c04413 GTK4: First buildable version... although tons still left to do.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2265
diff changeset
10953 GdkDisplay *display = gdk_display_get_default();
2274
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10954 GdkClipboard *clipboard;
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10955
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10956 if((clipboard = gdk_display_get_clipboard(display)))
b0bdd54bb2e8 GTK4: Implemented clipboard.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2273
diff changeset
10957 gdk_clipboard_set_text(clipboard, str);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10958 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10959
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10960 /* Internal function to create the drawable pixmap and call the function */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10961 static void _dw_draw_page(GtkPrintOperation *operation, GtkPrintContext *context, int page_nr)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10962 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10963 cairo_t *cr = gtk_print_context_get_cairo_context(context);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10964 void *drawdata = g_object_get_data(G_OBJECT(operation), "_dw_drawdata");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10965 int (*drawfunc)(HPRINT, HPIXMAP, int, void *) = g_object_get_data(G_OBJECT(operation), "_dw_drawfunc");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10966 int result = 0;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10967 HPIXMAP pixmap;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10968
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10969 if(cr && drawfunc && (pixmap = calloc(1,sizeof(struct _hpixmap))))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10970 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10971 pixmap->image = cairo_get_group_target(cr);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10972 pixmap->handle = (HWND)operation;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10973 pixmap->width = gtk_print_context_get_width(context);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10974 pixmap->height = gtk_print_context_get_height(context);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10975 result = drawfunc((HPRINT)operation, pixmap, page_nr, drawdata);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10976 if(result)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10977 gtk_print_operation_draw_page_finish(operation);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10978 free(pixmap);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10979 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10980 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10981
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10982 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10983 * Creates a new print object.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10984 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10985 * jobname: Name of the print job to show in the queue.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10986 * flags: Flags to initially configure the print object.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10987 * pages: Number of pages to print.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10988 * drawfunc: The pointer to the function to be used as the callback.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10989 * drawdata: User data to be passed to the handler function.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10990 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10991 * A handle to the print object or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10992 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10993 HPRINT API dw_print_new(const char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10994 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10995 GtkPrintOperation *op;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10996
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10997 if(!drawfunc)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10998 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10999
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11000 if((op = gtk_print_operation_new()))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11001 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11002 gtk_print_operation_set_n_pages(op, pages);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11003 gtk_print_operation_set_job_name(op, jobname ? jobname : "Dynamic Windows Print Job");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11004 g_object_set_data(G_OBJECT(op), "_dw_drawfunc", drawfunc);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11005 g_object_set_data(G_OBJECT(op), "_dw_drawdata", drawdata);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11006 g_signal_connect(op, "draw_page", G_CALLBACK(_dw_draw_page), NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11007 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11008 return (HPRINT)op;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11009 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11010
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11011 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11012 * Runs the print job, causing the draw page callbacks to fire.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11013 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11014 * print: Handle to the print object returned by dw_print_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11015 * flags: Flags to run the print job.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11016 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11017 * DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11018 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11019 int API dw_print_run(HPRINT print, unsigned long flags)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11020 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11021 GtkPrintOperationResult res;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11022 GtkPrintOperation *op = (GtkPrintOperation *)print;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11023
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11024 res = gtk_print_operation_run(op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11025 return (res == GTK_PRINT_OPERATION_RESULT_ERROR ? DW_ERROR_UNKNOWN : DW_ERROR_NONE);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11026 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11027
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11028 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11029 * Cancels the print job, typically called from a draw page callback.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11030 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11031 * print: Handle to the print object returned by dw_print_new().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11032 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11033 void API dw_print_cancel(HPRINT print)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11034 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11035 GtkPrintOperation *op = (GtkPrintOperation *)print;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11036
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11037 gtk_print_operation_cancel(op);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11038 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11039
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11040 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11041 * Returns a pointer to a static buffer which contains the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11042 * current user directory. Or the root directory (C:\ on
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11043 * OS/2 and Windows).
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11044 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
11045 char * API dw_user_dir(void)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11046 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11047 static char _user_dir[1024] = "";
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11048
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11049 if(!_user_dir[0])
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11050 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11051 char *home = getenv("HOME");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11052
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11053 if(home)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11054 strcpy(_user_dir, home);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11055 else
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11056 strcpy(_user_dir, "/");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11057 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11058 return _user_dir;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11059 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11060
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11061 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11062 * Returns a pointer to a static buffer which containes the
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11063 * private application data directory.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11064 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11065 char * API dw_app_dir(void)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11066 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11067 return _dw_share_path;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11068 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11069
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11070 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11071 * Sets the application ID used by this Dynamic Windows application instance.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11072 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11073 * appid: A string typically in the form: com.company.division.application
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11074 * appname: The application name used on Windows or NULL.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11075 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11076 * DW_ERROR_NONE after successfully setting the application ID.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11077 * DW_ERROR_UNKNOWN if unsupported on this system.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11078 * DW_ERROR_GENERAL if the application ID is not allowed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11079 * Remarks:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11080 * This must be called before dw_init(). If dw_init() is called first
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11081 * it will create a unique ID in the form: org.dbsoft.dwindows.application
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11082 * or if the application name cannot be detected: org.dbsoft.dwindows.pid.#
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11083 * The appname is only required on Windows. If NULL is passed the detected
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11084 * application name will be used, but a prettier name may be desired.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11085 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
11086 int API dw_app_id_set(const char *appid, const char *appname)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11087 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11088 if(g_application_id_is_valid(appid))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11089 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11090 strncpy(_dw_app_id, appid, _DW_APP_ID_SIZE);
2333
d0f884083c63 GTK: Use appname in dw_app_id_set() to set g_set_application_name().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2332
diff changeset
11091 if(appname)
d0f884083c63 GTK: Use appname in dw_app_id_set() to set g_set_application_name().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2332
diff changeset
11092 g_set_application_name(appname);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11093 return DW_ERROR_NONE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11094 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11095 return DW_ERROR_GENERAL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11096 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11097
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11098 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11099 * Call a function from the window (widget)'s context.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11100 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11101 * handle: Window handle of the widget.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11102 * function: Function pointer to be called.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11103 * data: Pointer to the data to be passed to the function.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11104 */
2334
29220ecf8db8 GTK4: dw_window_function() actually calls on the main thread now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2333
diff changeset
11105 DW_FUNCTION_DEFINITION(dw_window_function, void, DW_UNUSED(HWND handle), void *function, void *data)
29220ecf8db8 GTK4: dw_window_function() actually calls on the main thread now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2333
diff changeset
11106 DW_FUNCTION_ADD_PARAM3(handle, function, data)
29220ecf8db8 GTK4: dw_window_function() actually calls on the main thread now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2333
diff changeset
11107 DW_FUNCTION_NO_RETURN(dw_window_function)
29220ecf8db8 GTK4: dw_window_function() actually calls on the main thread now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2333
diff changeset
11108 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(handle), HWND, function, void *, data, void *)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11109 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11110 void (* windowfunc)(void *);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11111
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11112 windowfunc = function;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11113
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11114 if(windowfunc)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11115 windowfunc(data);
2334
29220ecf8db8 GTK4: dw_window_function() actually calls on the main thread now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2333
diff changeset
11116 DW_FUNCTION_RETURN_NOTHING;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11117 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11118
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11119 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11120 * Add a named user data item to a window handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11121 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11122 * window: Window handle of signal to be called back.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11123 * dataname: A string pointer identifying which signal to be hooked.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11124 * data: User data to be passed to the handler function.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11125 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
11126 void API dw_window_set_data(HWND window, const char *dataname, void *data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11127 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11128 HWND thiswindow = window;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11129
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11130 if(!window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11131 return;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11132
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11133 if(GTK_IS_SCROLLED_WINDOW(window))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11134 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11135 thiswindow = (HWND)g_object_get_data(G_OBJECT(window), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11136 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11137 if(thiswindow && G_IS_OBJECT(thiswindow))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11138 g_object_set_data(G_OBJECT(thiswindow), dataname, (gpointer)data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11139 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11140
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11141 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11142 * Gets a named user data item to a window handle.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11143 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11144 * window: Window handle of signal to be called back.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11145 * dataname: A string pointer identifying which signal to be hooked.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11146 * data: User data to be passed to the handler function.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11147 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
11148 void * API dw_window_get_data(HWND window, const char *dataname)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11149 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11150 HWND thiswindow = window;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11151 void *ret = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11152
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11153 if(!window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11154 return NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11155
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11156 if(GTK_IS_SCROLLED_WINDOW(window))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11157 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11158 thiswindow = (HWND)g_object_get_data(G_OBJECT(window), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11159 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11160 if(G_IS_OBJECT(thiswindow))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11161 ret = (void *)g_object_get_data(G_OBJECT(thiswindow), dataname);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11162 return ret;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11163 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11164
2532
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11165 /*
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11166 * Compare two window handles.
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11167 * Parameters:
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11168 * window1: First window handle to compare.
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11169 * window2: Second window handle to compare.
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11170 * Returns:
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11171 * TRUE if the windows are the same object, FALSE if not.
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11172 */
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11173 int API dw_window_compare(HWND window1, HWND window2)
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11174 {
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11175 /* If anything special is require to compare... do it
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11176 * here otherwise just compare the handles.
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11177 */
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11178 if(window1 && window2 && window1 == window2)
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11179 return TRUE;
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11180 return FALSE;
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11181 }
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2508
diff changeset
11182
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11183 /* Internal function to get the state of the timer before firing */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11184 gboolean _dw_timer_func(gpointer data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11185 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11186 void (*sigfunc)(void *data) = NULL;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11187 void *sdata;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11188 char tmpbuf[31] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11189 int *tag = data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11190
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11191 if(tag)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11192 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11193 snprintf(tmpbuf, 30, "_dw_timer%d", *tag);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11194 sigfunc = g_object_get_data(G_OBJECT(_DWObject), tmpbuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11195 snprintf(tmpbuf, 30, "_dw_timerdata%d", *tag);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11196 sdata = g_object_get_data(G_OBJECT(_DWObject), tmpbuf);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11197 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11198 if(!sigfunc)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11199 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11200 if(tag)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11201 free(tag);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11202 return FALSE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11203 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11204 sigfunc(sdata);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11205 return TRUE;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11206 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11207
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11208 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11209 * Add a callback to a timer event.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11210 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11211 * interval: Milliseconds to delay between calls.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11212 * sigfunc: The pointer to the function to be used as the callback.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11213 * data: User data to be passed to the handler function.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11214 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11215 * Timer ID for use with dw_timer_disconnect(), 0 on error.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11216 */
2584
2acc7ba5dea0 Add HTIMER type and change dw_timer_() functions to use it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2532
diff changeset
11217 HTIMER API dw_timer_connect(int interval, void *sigfunc, void *data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11218 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11219 int *tag;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11220 char tmpbuf[31] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11221
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11222 tag = calloc(1, sizeof(int));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11223
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11224 *tag = g_timeout_add(interval, (GSourceFunc)_dw_timer_func, (gpointer)tag);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11225 snprintf(tmpbuf, 30, "_dw_timer%d", *tag);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11226 g_object_set_data(G_OBJECT(_DWObject), tmpbuf, sigfunc);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11227 snprintf(tmpbuf, 30, "_dw_timerdata%d", *tag);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11228 g_object_set_data(G_OBJECT(_DWObject), tmpbuf, data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11229 return *tag;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11230 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11231
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11232 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11233 * Removes timer callback.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11234 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11235 * id: Timer ID returned by dw_timer_connect().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11236 */
2584
2acc7ba5dea0 Add HTIMER type and change dw_timer_() functions to use it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2532
diff changeset
11237 void API dw_timer_disconnect(HTIMER id)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11238 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11239 char tmpbuf[31] = {0};
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11240
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11241 snprintf(tmpbuf, 30, "_dw_timer%d", id);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11242 g_object_set_data(G_OBJECT(_DWObject), tmpbuf, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11243 snprintf(tmpbuf, 30, "_dw_timerdata%d", id);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11244 g_object_set_data(G_OBJECT(_DWObject), tmpbuf, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11245 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11246
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11247 /* Get the actual signal window handle not the user window handle
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11248 * Should mimic the code in dw_signal_connect() below.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11249 */
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
11250 static HWND _dw_find_signal_window(HWND window, const char *signame)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11251 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11252 HWND thiswindow = window;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11253
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11254 if(GTK_IS_SCROLLED_WINDOW(thiswindow))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11255 thiswindow = (HWND)g_object_get_data(G_OBJECT(window), "_dw_user");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11256 else if(GTK_IS_SCALE(thiswindow) || GTK_IS_SCROLLBAR(thiswindow) || GTK_IS_SPIN_BUTTON(thiswindow))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11257 thiswindow = (GtkWidget *)g_object_get_data(G_OBJECT(thiswindow), "_dw_adjustment");
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11258 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11259 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11260 return thiswindow;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11261 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11262
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11263 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11264 * Add a callback to a window event.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11265 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11266 * window: Window handle of signal to be called back.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11267 * signame: A string pointer identifying which signal to be hooked.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11268 * sigfunc: The pointer to the function to be used as the callback.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11269 * data: User data to be passed to the handler function.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11270 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
11271 void API dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11272 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11273 dw_signal_connect_data(window, signame, sigfunc, NULL, data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11274 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11275
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11276 /* Internal function to free any allocated signal data..
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11277 * and call any required function to free additional memory.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11278 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11279 static void _dw_signal_disconnect(gpointer data, GClosure *closure)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11280 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11281 if(data)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11282 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11283 void **params = (void **)data;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11284 void (*discfunc)(HWND, void *) = params[1];
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11285
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11286 if(discfunc)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11287 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
11288 DWSignalHandler work = _dw_get_signal_handler(data);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11289
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11290 if(work.window)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11291 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11292 discfunc(work.window, work.data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11293 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11294 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11295 free(data);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11296 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11297 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11298
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11299 #define _DW_INTERNAL_CALLBACK_PARAMS 4
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11300
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11301 /* Signal setup functions */
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11302 GObject *_dw_key_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11303 {
2309
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11304 /* Special case for item enter... we need a mouse callback too */
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11305 if(strcmp(signal->name, DW_SIGNAL_ITEM_ENTER) == 0)
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11306 {
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11307 GtkGesture *gesture = gtk_gesture_click_new();
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11308 gtk_widget_add_controller(GTK_WIDGET(object), GTK_EVENT_CONTROLLER(gesture));
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11309 int cid, sigid = _dw_set_signal_handler(G_OBJECT(object), (HWND)object, sigfunc, data, (gpointer)_dw_container_enter_mouse, discfunc);
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11310 void **newparams = calloc(sizeof(void *), 3);
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11311
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11312 newparams[0] = DW_INT_TO_POINTER(sigid);
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11313 newparams[2] = DW_POINTER(object);
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11314 cid = g_signal_connect_data(G_OBJECT(gesture), "pressed", G_CALLBACK(_dw_container_enter_mouse), newparams, _dw_signal_disconnect, 0);
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11315 _dw_set_signal_handler_id(object, sigid, cid);
e238178186ff GTK: Add a secondary callback for the mouse enter, but keep the logic in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2308
diff changeset
11316 }
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11317 if(GTK_IS_WIDGET(object))
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11318 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11319 GtkEventController *controller = gtk_event_controller_key_new();
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11320 gtk_widget_add_controller(GTK_WIDGET(object), controller);
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11321 return G_OBJECT(controller);
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11322 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11323 return object;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11324 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11325
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11326 GObject *_dw_button_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11327 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11328 /* Special case for handling notification signals, which aren't really signals */
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11329 if(G_IS_NOTIFICATION(object) && strcmp(signal->name, DW_SIGNAL_CLICKED) == 0)
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11330 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11331 char textbuf[101] = {0};
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11332 snprintf(textbuf, 100, "dw-notification-%llu-func", DW_POINTER_TO_ULONGLONG(object));
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11333 g_object_set_data(G_OBJECT(_DWApp), textbuf, DW_POINTER(sigfunc));
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11334 snprintf(textbuf, 100, "dw-notification-%llu-data", DW_POINTER_TO_ULONGLONG(object));
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11335 g_object_set_data(G_OBJECT(_DWApp), textbuf, DW_POINTER(data));
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11336 return NULL;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11337 }
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11338 /* GTK signal name for check buttons is "toggled" not "clicked" */
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11339 else if(GTK_IS_CHECK_BUTTON(object) && strcmp(signal->name, DW_SIGNAL_CLICKED) == 0)
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11340 strcpy(signal->gname, "toggled");
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11341 /* For menu items, get the G(Simple)Action and the signal is "activate" */
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11342 else if(G_IS_MENU_ITEM(object) && strcmp(signal->name, DW_SIGNAL_CLICKED) == 0)
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11343 {
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11344 GSimpleAction *action = G_SIMPLE_ACTION(g_object_get_data(object, "_dw_action"));
2289
26a76f94f8d8 GTK4: Added action groups to the menus, because everything says we need
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2288
diff changeset
11345
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11346 if(action)
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11347 {
2291
ce1b9e558584 GTK4: Fix minor logic error causing menu activation callbacks to fail.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2290
diff changeset
11348 int cid, sigid = _dw_set_signal_handler(G_OBJECT(object), (HWND)object, sigfunc, data, (gpointer)_dw_menu_handler, discfunc);
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
11349 void **newparams = calloc(sizeof(void *), 3);
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
11350
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
11351 newparams[0] = DW_INT_TO_POINTER(sigid);
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11352 newparams[1] = discfunc;
2290
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
11353 newparams[2] = DW_POINTER(object);
3c3f0023ae02 GTK4: Fix menu action setup by adding code to install group actions into
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2289
diff changeset
11354 cid = g_signal_connect_data(G_OBJECT(action), "activate", G_CALLBACK(_dw_menu_handler), newparams, _dw_signal_disconnect, 0);
2273
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11355 _dw_set_signal_handler_id(object, sigid, cid);
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11356 }
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11357 return NULL;
95796965bb01 GTK4: More menu work, something still isn't working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2272
diff changeset
11358 }
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11359 return object;
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11360 }
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11361
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11362 GObject *_dw_mouse_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data)
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11363 {
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11364 if(GTK_IS_WIDGET(object))
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11365 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11366 GtkGesture *gesture = gtk_gesture_click_new();
2339
6ad84c425bbd GTK4: Enable all mouse buttons in callbacks, not just button 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2338
diff changeset
11367 gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 0);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11368 gtk_widget_add_controller(GTK_WIDGET(object), GTK_EVENT_CONTROLLER(gesture));
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11369 return G_OBJECT(gesture);
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11370 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11371 return object;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11372 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11373
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11374 GObject *_dw_motion_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11375 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11376 if(GTK_IS_WIDGET(object))
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11377 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11378 GtkEventController *controller = gtk_event_controller_motion_new();
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11379 gtk_widget_add_controller(GTK_WIDGET(object), controller);
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11380 return G_OBJECT(controller);
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11381 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11382 return object;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11383 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11384
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11385 GObject *_dw_draw_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11386 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11387 if(GTK_IS_DRAWING_AREA(object))
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11388 {
2281
0e93b09ed0e1 GTK4: Cache the cairo context during the drawing area callback. This allows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2280
diff changeset
11389 g_object_set_data(object, "_dw_expose_func", sigfunc);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11390 gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(object), signal->func, data, NULL);
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11391 return NULL;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11392 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11393 return object;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11394 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11395
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11396 GObject *_dw_tree_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11397 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11398 if(GTK_IS_TREE_VIEW(object))
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11399 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11400 if(strcmp(signal->name, DW_SIGNAL_COLUMN_CLICK) == 0)
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11401 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11402 /* We don't actually need a signal handler here... just need to assign the handler ID
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11403 * Since the handlers for the columns were already created in _dw_container_setup()
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11404 */
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11405 int sigid = _dw_set_signal_handler(object, (HWND)object, sigfunc, data, signal->func, discfunc);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11406 g_object_set_data(object, "_dw_column_click_id", GINT_TO_POINTER(sigid+1));
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11407 return NULL;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11408 }
2270
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
11409 else if(strcmp(signal->name, DW_SIGNAL_ITEM_SELECT) == 0)
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
11410 {
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
11411 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(object));
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
11412 return G_OBJECT(sel);
819f2492c85f GTK4: More signal cleanup, fix various issues with windows and dialogs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2269
diff changeset
11413 }
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11414 else
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11415 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11416 GtkGesture *gesture = gtk_gesture_click_new();
2287
680212c356e3 GTK4: Refactor tree and fix DW_SIGNAL_ITEM_CONTEXT signals on tree view
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2286
diff changeset
11417 /* Set button to return to 3 for context secondary clicks */
680212c356e3 GTK4: Refactor tree and fix DW_SIGNAL_ITEM_CONTEXT signals on tree view
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2286
diff changeset
11418 if(strcmp(signal->name, DW_SIGNAL_ITEM_CONTEXT) == 0)
680212c356e3 GTK4: Refactor tree and fix DW_SIGNAL_ITEM_CONTEXT signals on tree view
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2286
diff changeset
11419 gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 3);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11420 gtk_widget_add_controller(GTK_WIDGET(object), GTK_EVENT_CONTROLLER(gesture));
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11421 return G_OBJECT(gesture);
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11422 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11423 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11424 return object;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11425 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11426
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11427 GObject *_dw_value_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11428 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11429 if(GTK_IS_SCALE(object) || GTK_IS_SCROLLBAR(object) || GTK_IS_SPIN_BUTTON(object))
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11430 return G_OBJECT(g_object_get_data(object, "_dw_adjustment"));
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11431 return object;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11432 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11433
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11434 GObject *_dw_focus_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11435 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11436 if(GTK_IS_COMBO_BOX(object) && strcmp(signal->name, DW_SIGNAL_SET_FOCUS) == 0)
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11437 return G_OBJECT(gtk_combo_box_get_child(GTK_COMBO_BOX(object)));
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11438 return object;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11439 }
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11440
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11441 #ifdef USE_WEBKIT
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11442 GObject *_dw_html_setup(struct _dw_signal_list *signal, GObject *object, void *sigfunc, void *discfunc, void *data)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11443 {
2978
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11444 if(WEBKIT_IS_WEB_VIEW(object))
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11445 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11446 if(strcmp(signal->name, DW_SIGNAL_HTML_RESULT) == 0)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11447 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11448 /* We don't actually need a signal handler here... just need to assign the handler ID
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11449 * Since the handler is created in dw_html_javasript_run()
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11450 */
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11451 int sigid = _dw_set_signal_handler(object, (HWND)object, sigfunc, data, signal->func, discfunc);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11452 g_object_set_data(object, "_dw_html_result_id", GINT_TO_POINTER(sigid+1));
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11453 return NULL;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11454 }
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11455 else if(strcmp(signal->name, DW_SIGNAL_HTML_MESSAGE) == 0)
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11456 {
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11457 /* We don't actually need a signal handler here... just need to assign the handler ID
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11458 * Since the handler is created in dw_html_javasript_add()
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11459 */
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11460 int sigid = _dw_set_signal_handler(object, (HWND)object, sigfunc, data, signal->func, discfunc);
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11461 g_object_set_data(object, "_dw_html_message_id", GINT_TO_POINTER(sigid+1));
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11462 return NULL;
d84182f0054e GTK4: Support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2950
diff changeset
11463 }
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11464 }
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11465 return object;
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11466 }
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11467 #endif
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11468
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11469 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11470 * Add a callback to a window event with a closure callback.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11471 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11472 * window: Window handle of signal to be called back.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11473 * signame: A string pointer identifying which signal to be hooked.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11474 * sigfunc: The pointer to the function to be used as the callback.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11475 * discfunc: The pointer to the function called when this handler is removed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11476 * data: User data to be passed to the handler function.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11477 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
11478 void API dw_signal_connect_data(HWND window, const char *signame, void *sigfunc, void *discfunc, void *data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11479 {
2628
d3d8a93124f1 GTK4: Fix compilation after style standarization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2626
diff changeset
11480 DWSignalList signal = _dw_findsignal(signame);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11481
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11482 if(signal.func)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11483 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11484 GObject *object = (GObject *)window;
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11485 void **params;
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11486 int sigid;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11487 gint cid;
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11488
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11489 /*
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11490 * If the window we are setting the signal on is a scrolled window we need to get
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11491 * the "real" widget type. thiswindow is the "real" widget type
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11492 */
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11493 if (GTK_IS_SCROLLED_WINDOW(window)
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11494 #ifdef USE_WEBKIT
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11495 && !(object = G_OBJECT(_dw_html_web_view(window)))
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11496 #endif
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11497 )
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11498 object = (GObject *)g_object_get_data(G_OBJECT(window), "_dw_user");
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11499
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11500 /* Do object class specific setup */
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11501 if(signal.setup)
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11502 object = signal.setup(&signal, object, sigfunc, discfunc, data);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11503
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11504 if(!object)
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11505 return;
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11506
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11507 params = calloc(_DW_INTERNAL_CALLBACK_PARAMS, sizeof(void *));
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11508 sigid = _dw_set_signal_handler(object, window, sigfunc, data, signal.func, discfunc);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11509 params[0] = DW_INT_TO_POINTER(sigid);
2292
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11510 /* Save the disconnect function pointer */
fa19fce045aa GTK4: Remove unnecessary parameter to the setup functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2291
diff changeset
11511 params[1] = discfunc;
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11512 params[2] = DW_POINTER(object);
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11513 cid = g_signal_connect_data(object, signal.gname, G_CALLBACK(signal.func), params, _dw_signal_disconnect, 0);
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11514 _dw_set_signal_handler_id(object, sigid, cid);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11515 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11516 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11517
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11518 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11519 * Removes callbacks for a given window with given name.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11520 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11521 * window: Window handle of callback to be removed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11522 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
11523 void API dw_signal_disconnect_by_name(HWND window, const char *signame)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11524 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11525 int z, count;
2628
d3d8a93124f1 GTK4: Fix compilation after style standarization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2626
diff changeset
11526 DWSignalList signal;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11527 void **params = alloca(sizeof(void *) * 3);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11528
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
11529 params[2] = _dw_find_signal_window(window, signame);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11530 count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(params[2]), "_dw_sigcounter"));
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11531 signal = _dw_findsignal(signame);
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11532
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11533 if(signal.func)
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11534 {
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11535 for(z=0;z<count;z++)
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11536 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
11537 DWSignalHandler sh;
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11538
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11539 params[0] = GINT_TO_POINTER(z);
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11540 sh = _dw_get_signal_handler(params);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11541
2269
a26cfd4bbffe GTK4: More work on signal handlers, and disable the font CSS override.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2268
diff changeset
11542 if(sh.intfunc == signal.func)
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11543 _dw_remove_signal_handler((HWND)params[2], z);
2268
fefeb5b4e512 GTK4: Complete refactoring of the signal system to be more simple and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2267
diff changeset
11544 }
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11545 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11546 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11547
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11548 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11549 * Removes all callbacks for a given window.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11550 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11551 * window: Window handle of callback to be removed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11552 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
11553 void API dw_signal_disconnect_by_window(HWND window)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11554 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11555 HWND thiswindow;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11556 int z, count;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11557
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
11558 thiswindow = _dw_find_signal_window(window, NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11559 count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(thiswindow), "_dw_sigcounter"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11560
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11561 for(z=0;z<count;z++)
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11562 _dw_remove_signal_handler(thiswindow, z);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11563 g_object_set_data(G_OBJECT(thiswindow), "_dw_sigcounter", NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11564 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11565
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11566 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11567 * Removes all callbacks for a given window with specified data.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11568 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11569 * window: Window handle of callback to be removed.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11570 * data: Pointer to the data to be compared against.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11571 */
2323
4b04943319c5 GTK4: Move a few more functions into thread safety. Add API to functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2322
diff changeset
11572 void API dw_signal_disconnect_by_data(HWND window, void *data)
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11573 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11574 int z, count;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11575 void **params = alloca(sizeof(void *) * 3);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11576
2314
eda7642d80df GTK4: Code cleanup, add _dw prefix to internal functions and structures.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2313
diff changeset
11577 params[2] = _dw_find_signal_window(window, NULL);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11578 count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(params[2]), "_dw_sigcounter"));
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11579
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11580 for(z=0;z<count;z++)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11581 {
2626
401a3b9f21ba Massive continuation of code style standardization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2618
diff changeset
11582 DWSignalHandler sh;
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11583
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11584 params[0] = GINT_TO_POINTER(z);
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11585 sh = _dw_get_signal_handler(params);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11586
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11587 if(sh.data == data)
2271
1c52cd5a817f GTK4: More refactoring, and started working on menus, but not entirely sure
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2270
diff changeset
11588 _dw_remove_signal_handler((HWND)params[2], z);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11589 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11590 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11591
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11592 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11593 * Converts a UTF-8 encoded string into a wide string.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11594 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11595 * utf8string: UTF-8 encoded source string.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11596 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11597 * Wide string that needs to be freed with dw_free()
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11598 * or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11599 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11600 wchar_t * API dw_utf8_to_wchar(const char *utf8string)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11601 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11602 wchar_t *retval = NULL, *freeme;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11603
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11604 if(sizeof(wchar_t) == sizeof(gunichar))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11605 freeme = retval = (wchar_t *)g_utf8_to_ucs4(utf8string, -1, NULL, NULL, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11606 else if(sizeof(wchar_t) == sizeof(gunichar2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11607 freeme = retval = (wchar_t *)g_utf8_to_utf16(utf8string, -1, NULL, NULL, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11608 if(retval)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11609 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11610 retval = wcsdup(retval);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11611 g_free(freeme);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11612 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11613 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11614 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11615
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11616 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11617 * Converts a wide string into a UTF-8 encoded string.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11618 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11619 * wstring: Wide source string.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11620 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11621 * UTF-8 encoded string that needs to be freed with dw_free()
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11622 * or NULL on failure.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11623 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11624 char * API dw_wchar_to_utf8(const wchar_t *wstring)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11625 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11626 char *retval = NULL, *freeme;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11627
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11628 if(sizeof(wchar_t) == sizeof(gunichar))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11629 freeme = retval = g_ucs4_to_utf8((gunichar *)wstring, -1, NULL, NULL, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11630 else if(sizeof(wchar_t) == sizeof(gunichar2))
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11631 freeme = retval = g_utf16_to_utf8((gunichar2 *)wstring, -1, NULL, NULL, NULL);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11632 if(retval)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11633 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11634 retval = strdup(retval);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11635 g_free(freeme);
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11636 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11637 return retval;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11638 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11639
2506
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11640 DW_FUNCTION_DEFINITION(dw_x11_check, int, int trueresult, int falseresult)
2508
cb795bba48a4 GTK4: Fix the new dw_x11_check() function that is thread safe.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2506
diff changeset
11641 DW_FUNCTION_ADD_PARAM2(trueresult, falseresult)
cb795bba48a4 GTK4: Fix the new dw_x11_check() function that is thread safe.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2506
diff changeset
11642 DW_FUNCTION_RETURN(dw_x11_check, int)
cb795bba48a4 GTK4: Fix the new dw_x11_check() function that is thread safe.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2506
diff changeset
11643 DW_FUNCTION_RESTORE_PARAM2(trueresult, int, falseresult, int)
2506
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11644 {
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11645 int retval = falseresult;
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11646 #ifdef GDK_WINDOWING_X11
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11647 GdkDisplay *display = gdk_display_get_default();
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11648
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11649 if(display && GDK_IS_X11_DISPLAY(display))
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11650 {
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11651 retval = trueresult;
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11652 }
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11653 #endif
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11654 DW_FUNCTION_RETURN_THIS(retval);
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11655 }
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11656
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11657 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11658 * Gets the state of the requested library feature.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11659 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11660 * feature: The requested feature for example DW_FEATURE_DARK_MODE
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11661 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11662 * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11663 * DW_FEATURE_DISABLED if the feature is supported but disabled.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11664 * DW_FEATURE_ENABLED if the feature is supported and enabled.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11665 * Other value greater than 1, same as enabled but with extra info.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11666 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11667 int API dw_feature_get(DWFEATURE feature)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11668 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11669 switch(feature)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11670 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11671 #ifdef USE_WEBKIT
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11672 case DW_FEATURE_HTML:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11673 case DW_FEATURE_HTML_RESULT:
2980
7e273fec75ae GTK3/4: Add feature support for DW_FEATURE_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2978
diff changeset
11674 case DW_FEATURE_HTML_MESSAGE:
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11675 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11676 case DW_FEATURE_NOTIFICATION:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11677 case DW_FEATURE_UTF8_UNICODE:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11678 case DW_FEATURE_MLE_WORD_WRAP:
2410
0286ac44d347 Add DW_FEATURE_TREE feature test, since iOS does not suppor tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2371
diff changeset
11679 case DW_FEATURE_TREE:
2997
8450b87e960c GTK2/3/4: Implement DW_FEATURE_RENDER_SAFE. GTK2: Disabled by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2980
diff changeset
11680 case DW_FEATURE_RENDER_SAFE:
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11681 return DW_FEATURE_ENABLED;
2506
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11682 case DW_FEATURE_WINDOW_PLACEMENT:
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11683 return dw_x11_check(DW_FEATURE_ENABLED, DW_FEATURE_UNSUPPORTED);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11684 default:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11685 return DW_FEATURE_UNSUPPORTED;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11686 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11687 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11688
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11689 /*
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11690 * Sets the state of the requested library feature.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11691 * Parameters:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11692 * feature: The requested feature for example DW_FEATURE_DARK_MODE
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11693 * state: DW_FEATURE_DISABLED, DW_FEATURE_ENABLED or any value greater than 1.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11694 * Returns:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11695 * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11696 * DW_ERROR_NONE if the feature is supported and successfully configured.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11697 * DW_ERROR_GENERAL if the feature is supported but could not be configured.
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11698 * Remarks:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11699 * These settings are typically used during dw_init() so issue before
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11700 * setting up the library with dw_init().
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11701 */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11702 int API dw_feature_set(DWFEATURE feature, int state)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11703 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11704 switch(feature)
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11705 {
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11706 /* These features are supported but not configurable */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11707 #ifdef USE_WEBKIT
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11708 case DW_FEATURE_HTML:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11709 case DW_FEATURE_HTML_RESULT:
2980
7e273fec75ae GTK3/4: Add feature support for DW_FEATURE_HTML_MESSAGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2978
diff changeset
11710 case DW_FEATURE_HTML_MESSAGE:
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11711 #endif
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11712 case DW_FEATURE_NOTIFICATION:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11713 case DW_FEATURE_UTF8_UNICODE:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11714 case DW_FEATURE_MLE_WORD_WRAP:
2410
0286ac44d347 Add DW_FEATURE_TREE feature test, since iOS does not suppor tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2371
diff changeset
11715 case DW_FEATURE_TREE:
2997
8450b87e960c GTK2/3/4: Implement DW_FEATURE_RENDER_SAFE. GTK2: Disabled by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2980
diff changeset
11716 case DW_FEATURE_RENDER_SAFE:
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11717 return DW_ERROR_GENERAL;
2506
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11718 case DW_FEATURE_WINDOW_PLACEMENT:
fa976a5bc7bd Add DW_FEATURE_WINDOW_PLACEMENT for platforms supporting arbitrary window placement.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2470
diff changeset
11719 return dw_x11_check(DW_ERROR_GENERAL, DW_FEATURE_UNSUPPORTED);
2264
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11720 /* These features are supported and configurable */
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11721 default:
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11722 return DW_FEATURE_UNSUPPORTED;
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11723 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11724 }
5c981407b0f3 GTK4: Add experimental support for GTK4... This is in progress and doesn't
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11725
2313
c6ea79c74c03 GTK4: Remove some lingering eventbox code from GTK3.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2312
diff changeset
11726