Skip to content

Commit 41a778a

Browse files
committed
Update for gtk-4.14
1 parent 85b4f82 commit 41a778a

File tree

7 files changed

+226
-31
lines changed

7 files changed

+226
-31
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016, 2017, 2018, 2019 Rene Hexel
1+
Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Rene Hexel
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ After that, use the (usual) Build and Test buttons to build/test this package.
9696
To build, download Swift from https://swift.org/download/ -- if you are using macOS, make sure you have the command line tools installed as well). Test that your compiler works using `swift --version`, which should give you something like
9797

9898
$ swift --version
99-
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
99+
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
100100
Target: arm64-apple-macosx14.0
101101

102102
on macOS, or on Linux you should get something like:
103103

104104
$ swift --version
105-
Swift version 5.9 (swift-5.9-RELEASE)
105+
Swift version 5.10 (swift-5.10-RELEASE)
106106
Target: x86_64-unknown-linux-gnu
107107

108108
### Gtk 3.22 or higher
109109

110-
The Swift wrappers have been tested with glib-2.56, 2.58, 2.60, 2.62, 2.64, 2.66, 2.68, 2.70, 2.72, 2.74, 2.76 and 2.78, and gdk/gtk 3.22, 3.24 as well as 4.0, 4.2, 4.4, 4.6, 4.8, and 4.10 on the `gtk4` branch. They should work with higher versions, but YMMV. Also make sure you have `gobject-introspection` and its `.gir` files installed.
110+
The Swift wrappers have been tested with glib-2.56, 2.58, 2.60, 2.62, 2.64, 2.66, 2.68, 2.70, 2.72, 2.74, 2.76, 2.78 and 2.80, and gdk/gtk 3.22, 3.24 as well as 4.0, 4.2, 4.4, 4.6, 4.8, 4.10, 4.12, and 4.14 on the `gtk4` branch. They should work with higher versions, but YMMV. Also make sure you have `gobject-introspection` and its `.gir` files installed.
111111

112112
#### Linux
113113

Sources/CGLib/glib_bridging.h

+16
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
#include <glib/gversionmacros.h>
44
#undef __GLIB_H_INSIDE__
55

6+
struct _GAllocator {};
67
struct _GAsyncQueue {};
78
struct _GBookmarkFile {};
89
struct _GBinding {};
910
struct _GBytes {};
11+
struct _GCache {};
1012
struct _GChecksum {};
1113
struct _GData {};
1214
struct _GDatagramBased {};
@@ -21,6 +23,7 @@ struct _GMainLoop {};
2123
struct _GMappedFile {};
2224
struct _GMarkupParseContext {};
2325
struct _GMatchInfo {};
26+
struct _GMemChunk {};
2427
struct _GMemoryMonitor {};
2528
struct _GModule {};
2629
struct _GMutexLocker {};
@@ -31,6 +34,7 @@ struct _GPatternSpec {};
3134
struct _GPowerProfileMonitor {};
3235
struct _GRand {};
3336
struct _GRegex {};
37+
struct _GRelation {};
3438
struct _GSequence {};
3539
struct _GSequenceNode {};
3640
struct _GSequenceIter {};
@@ -368,3 +372,15 @@ typedef GUriParamsFlags GURIParamsFlags;
368372
typedef GUriHideFlags GURIHideFlags;
369373
typedef struct _GTreeNode GTreeNode;
370374
typedef struct _GStrvBuilder GStrvBuilder;
375+
376+
#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 80
377+
extern GType g_threaded_resolver_get_type(void);
378+
379+
struct _GThreadedResolver {};
380+
struct _GThreadedResolverClass
381+
{
382+
GResolverClass parent_class;
383+
};
384+
typedef struct _GThreadedResolver GThreadedResolver;
385+
typedef struct _GThreadedResolverClass GThreadedResolverClass;
386+
#endif

Sources/GLib/GLib.swift

+178-6
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ extension LogLevelFlags: Hashable {}
145145
/// - level: log level (defaults to `.debug`)
146146
@inlinable public func g_log(messagePtr: UnsafePointer<CChar>?, level: LogLevelFlags = .debug) {
147147
guard let msg = messagePtr else { return }
148-
#if swift(<5.2)
148+
#if swift(<5.2)
149149
g_logv(nil, level.value, msg, CVaListPointer(_fromUnsafeMutablePointer: UnsafeMutableRawPointer(mutating: msg)))
150-
#else
150+
#else
151151
guard GLIB_MAJOR_VERSION > 2 || GLIB_MINOR_VERSION >= 50 else {
152152
print(String(cString: msg))
153153
return
@@ -161,7 +161,7 @@ extension LogLevelFlags: Hashable {}
161161
logStructuredArray(logLevel: level, fields: &fields, nFields: fields.count)
162162
}
163163
}
164-
#endif
164+
#endif
165165
}
166166

167167
/// Logging function
@@ -178,9 +178,9 @@ extension LogLevelFlags: Hashable {}
178178
withUnsafeMutableBytes(of: &buffer) {
179179
guard let buffer = $0.baseAddress else { return }
180180
let msg = buffer.assumingMemoryBound(to: CChar.self)
181-
#if swift(<5.2)
181+
#if swift(<5.2)
182182
g_logv(domain, level.value, msg, CVaListPointer(_fromUnsafeMutablePointer: buffer))
183-
#else
183+
#else
184184
guard GLIB_MAJOR_VERSION > 2 || GLIB_MINOR_VERSION >= 50 else {
185185
print(message)
186186
return
@@ -199,7 +199,7 @@ extension LogLevelFlags: Hashable {}
199199
}
200200
}
201201
}
202-
#endif
202+
#endif
203203
}
204204
}
205205
#endif
@@ -216,3 +216,175 @@ extension LogLevelFlags: Hashable {}
216216
g_log(message, level: .warning)
217217
}
218218
}
219+
220+
#if os(macOS) || os(Linux)
221+
/// Change the mode oft a filesystem object.
222+
///
223+
/// This function is a wrapper around the `chmod()` system call,
224+
/// changing the mode of the filesystem object pointed to by `path`.
225+
///
226+
/// - Parameters:
227+
/// - path: The filesystem path of the object to query.
228+
/// - mode: The new mode for the object.
229+
/// - Returns: `0` on success, `-1` on error.
230+
@inlinable
231+
public func g_chmod(_ path: UnsafePointer<CChar>, _ mode: gint) -> CInt {
232+
return chmod(path, mode_t(mode))
233+
}
234+
235+
/// Create a file.
236+
///
237+
/// This function is a wrapper around the `creat()` system call,
238+
/// creating a filesystem object pointed to by `path`.
239+
///
240+
/// - Parameters:
241+
/// - path: The filesystem path of the object to create.
242+
/// - mode: The new mode for the object.
243+
/// - Returns: `0` on success, `-1` on error.
244+
@inlinable
245+
public func g_creat(_ path: UnsafePointer<CChar>, _ mode: gint) -> CInt {
246+
return creat(path, mode_t(mode))
247+
}
248+
249+
/// Open or create a buiffered stream.
250+
///
251+
/// This function is a wrapper around the `fopen()` system call,
252+
/// creating a filesystem stream object pointed to by `path`.
253+
///
254+
/// - Parameters:
255+
/// - path: The filesystem path of the object to open.
256+
/// - mode: The new mode for the object when created.
257+
/// - Returns: a pointer to the new stream object, `nil` on error.
258+
@inlinable
259+
public func g_fopen(_ path: UnsafePointer<CChar>, _ mode: UnsafePointer<CChar>) -> UnsafeMutablePointer<FILE>? {
260+
return fopen(path, mode)
261+
}
262+
263+
/// Repen a buiffered stream.
264+
///
265+
/// This function is a wrapper around the `freopen()` system call,
266+
/// reopening a filesystem stream object pointed to by `path` and
267+
/// associates the stream with the given file pointer.
268+
///
269+
/// - Parameters:
270+
/// - path: The filesystem path of the object to open.
271+
/// - mode: The new mode for the object when created.
272+
/// - stream: The stream to associate with the file pointer.
273+
/// - Returns: a pointer to the stream object, `nil` on error.
274+
@inlinable
275+
public func g_freopen(_ path: UnsafePointer<CChar>, _ mode: UnsafePointer<CChar>, _ stream: UnsafeMutablePointer<FILE>!) -> UnsafeMutablePointer<FILE>? {
276+
return freopen(path, mode, stream)
277+
}
278+
279+
/// Syncronize a filesystem object.
280+
///
281+
/// This function is a wrapper around the `fsync()` system call,
282+
/// synchronising the files descriptor passed in.
283+
///
284+
/// - Parameters:
285+
/// - fileDescriptor: The file descriptor to syncronise.
286+
/// - Returns: `0` on success, `-1` on error.
287+
@inlinable
288+
public func g_fsync(_ fileDescriptor: CInt) -> CInt {
289+
return fsync(fileDescriptor)
290+
}
291+
292+
/// Get information about a filesystem object.
293+
///
294+
/// This function is a wrapper around the `lstat()` system call,
295+
/// returning information about the file pointed to by `path`,
296+
/// without following symbolic links.
297+
///
298+
/// - Parameters:
299+
/// - path: The filesystem path of the object to query.
300+
/// - buf: A `GStatBuf` structure to fill in with information about the file.
301+
/// - Returns: `0` on success, `-1` on error.
302+
@inlinable
303+
public func g_lstat(_ path: UnsafePointer<CChar>, _ buf: UnsafeMutablePointer<GStatBuf>!) -> CInt {
304+
return lstat(path, buf)
305+
}
306+
307+
/// Create a directory.
308+
///
309+
/// This function is a wrapper around the `mkdir()` system call,
310+
/// creating a directory pointed to by `path`.
311+
///
312+
/// - Parameters:
313+
/// - path: The filesystem path of the directory to create.
314+
/// - mode: The new mode for the directory.
315+
/// - Returns: `0` on success, `-1` on error.
316+
@inlinable
317+
public func g_mkdir(_ path: UnsafePointer<CChar>, _ mode: gint) -> CInt {
318+
return mkdir(path, mode_t(mode))
319+
}
320+
321+
/// Open a file.
322+
///
323+
/// This function is a wrapper around the `open()` system call,
324+
/// opening a filesystem object pointed to by `path`.
325+
///
326+
/// - Parameters:
327+
/// - path: The filesystem path of the object to open.
328+
/// - flags: The flags to use when opening the object.
329+
/// - mode: The new mode for the object.
330+
/// - Returns: `0` on success, `-1` on error.
331+
@inlinable
332+
public func g_open(_ path: UnsafePointer<CChar>, _ flags: CInt, _ mode: gint = 0) -> CInt {
333+
return open(path, flags, mode_t(mode))
334+
}
335+
336+
/// Remove a filesystem object.
337+
///
338+
/// This function is a wrapper around the `remove()` system call,
339+
/// removing the filesystem object pointed to by `path`.
340+
///
341+
/// - Parameter path: The filesystem path of the object to remove.
342+
/// - Returns: `0` on success, `-1` on error.
343+
@inlinable
344+
public func g_remove(_ path: UnsafePointer<CChar>) -> CInt {
345+
return remove(path)
346+
}
347+
348+
/// Rename a filesystem object.
349+
///
350+
/// This function is a wrapper around the `rename()` system call,
351+
/// renaming the filesystem object pointed to by `old` to `new`.
352+
///
353+
/// - Parameters:
354+
/// - old: The old filesystem path.
355+
/// - new: The new filesystem path.
356+
/// - Returns: `0` on success, `-1` on error.
357+
@inlinable
358+
public func g_rename(_ old: UnsafePointer<CChar>, _ new: UnsafePointer<CChar>) -> CInt {
359+
return rename(old, new)
360+
}
361+
362+
/// Get information about a filesystem object.
363+
///
364+
/// This function is a wrapper around the `stat()` system call,
365+
/// returning information about the file pointed to by `path`.
366+
///
367+
/// - Parameters:
368+
/// - path: The filesystem path of the object to query.
369+
/// - buf: A `GStatBuf` structure to fill in with information about the file.
370+
/// - Returns: `0` on success, `-1` on error.
371+
@inlinable
372+
public func g_stat(_ path: UnsafePointer<CChar>, _ buf: UnsafeMutablePointer<GStatBuf>!) -> CInt {
373+
return stat(path, buf)
374+
}
375+
376+
/// Set filesystem object times.
377+
///
378+
/// This function is a wrapper around the `utime()` system call,
379+
/// setting time information about the file pointed to by `path`.
380+
///
381+
/// - Parameters:
382+
/// - path: The filesystem path of the object to query.
383+
/// - times: Pointer to a`utimbuf` structure with information about the file access and modification times.
384+
/// - Returns: `0` on success, `-1` on error.
385+
@inlinable
386+
public func g_utime(_ path: UnsafePointer<CChar>, _ times: UnsafePointer<utimbuf>!) -> CInt {
387+
return utime(path, times)
388+
}
389+
#endif
390+
+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
VaClosureMarshal
22
SignalCVaMarshaller
33
signalSetVaMarshaller
4+
IOCondition
5+

Sources/GModule/GModule-2.0.verbatim

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MODULE_IMPL_AR
2+
MODULE_IMPL_DL
3+
MODULE_IMPL_NONE
4+
MODULE_IMPL_WIN32

Sources/Gtk/Gtk-3.0.awk

+22-21
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,32 @@
55
BEGIN { depr_init = 0 ; comment = 0 ; slist = 0 ; overr = 0 ; ostock = 0 ;
66
no_fields = 0 ; close_comment = 0; icon_size = 0 ; grp = 0
77
}
8-
/Creates a new `GtkRecentChooserMenu` widget\.$/ { overr = 1 }
8+
/Creates a new ``RecentChooserMenu`` widget\.$/ { overr = 1 }
99
/a swatch representing the current selected color. When the button/ { overr = 1 }
1010
#/Creates a new dialog box/ { overr = 1 }
1111
/Creates a new font picker widget/ { overr = 1 }
1212
/Creates a new toggle button/ { overr = 1 }
13-
/Creates a new GtkModelButton/ { overr = 1 ; sub("GtkModelButton", "`GtkModelButton`") }
14-
/Creates a new `GtkAboutDialog`\.$/ { overr = 1 }
15-
/Creates a new `GtkCellRendererAccel`/ { overr = 1 }
16-
/Creates a new `GtkCellRendererCombo`/ { overr = 1 }
17-
/Creates a new `GtkCellRendererSpin`/ { overr = 1 }
18-
/Creates a new `GtkCheckButton`/ { overr = 1 }
19-
/Creates a new `GtkCheckMenuItem`/ { overr = 1 }
20-
/Creates a new `GtkComboBoxText`/ { overr = 1 }
21-
/Creates a new `GtkImageMenuItem` with an empty label/ { overr = 1 }
22-
/Creates a new `GtkImageMenuItem` containing a label/ { overr = 1 }
23-
/Creates a new `GtkMenuButton`/ { overr = 1 }
24-
/Creates a new `GtkMenuToolButton`/ { overr = 1 }
25-
/Creates a `GtkSearchEntry`/ { overr = 1 }
26-
/Creates a new `GtkSeparatorMenuItem`/ { overr = 1 }
27-
/Create a new `GtkSeparatorToolItem`/ { overr = 1 }
28-
/Creates a new `GtkTearoffMenuItem`/ { overr = 1 }
29-
/Creates a new `GtkToggleAction`/ { overr = 1 }
30-
/Creates a new `GtkToggleButton`/ { overr = 1 }
31-
/Creates a new `GtkToggleToolButton`/ { overr = 1 }
32-
/Creates a new `GtkRecentAction`/ { ostock = 1 }
13+
/Creates a new GtkModelButton/ { overr = 1 ; sub("GtkModelButton", "``ModelButton``") }
14+
/Create a new GtkSeparatorToolItem/ { overr = 1 ; sub("GtkSeparatorToolItem", "``SeparatorToolItem``.") }
15+
/Creates a new ``AboutDialog``\.$/ { overr = 1 }
16+
/Creates a new ``CellRendererAccel`/ { overr = 1 }
17+
/Creates a new ``CellRendererCombo`/ { overr = 1 }
18+
/Creates a new ``CellRendererSpin`/ { overr = 1 }
19+
/Creates a new ``CheckButton`/ { overr = 1 }
20+
/Creates a new ``CheckMenuItem`/ { overr = 1 }
21+
/Creates a new ``ComboBoxText`/ { overr = 1 }
22+
/Creates a new ``ImageMenuItem`` with an empty label/ { overr = 1 }
23+
/Creates a new ``ImageMenuItem`` containing a label/ { overr = 1 }
24+
/Creates a new ``MenuButton`/ { overr = 1 }
25+
/Creates a new ``MenuToolButton`/ { overr = 1 }
26+
/Creates a ``SearchEntry`/ { overr = 1 }
27+
/Creates a new ``SeparatorMenuItem`/ { overr = 1 }
28+
/Create a new ``SeparatorToolItem`/ { overr = 1 }
29+
/Creates a new ``TearoffMenuItem`/ { overr = 1 }
30+
/Creates a new ``ToggleAction`/ { overr = 1 }
31+
/Creates a new ``ToggleButton`/ { overr = 1 }
32+
/Creates a new ``ToggleToolButton`/ { overr = 1 }
33+
/Creates a new ``RecentAction`/ { ostock = 1 }
3334
/ the file belongs to/ { grp = 1 }
3435
/open .* ColorSelection/ { depr_init = 1 }
3536
/public .* ColorSelection/ { depr_init = 1 }

0 commit comments

Comments
 (0)