@@ -26,7 +26,9 @@ public final class Gtk3Backend: AppBackend {
2626 public let defaultTableRowContentHeight = 20
2727 public let defaultTableCellVerticalPadding = 4
2828 public let defaultPaddingAmount = 10
29+ public let requiresToggleSwitchSpacer = false
2930 public let scrollBarWidth = 0
31+ public let defaultToggleStyle = ToggleStyle . button
3032
3133 var gtkApp : Application
3234
@@ -116,6 +118,11 @@ public final class Gtk3Backend: AppBackend {
116118 return SIMD2 ( size. width, size. height)
117119 }
118120
121+ public func isWindowProgrammaticallyResizable( _ window: Window ) -> Bool {
122+ // TODO: Detect whether window is fullscreen
123+ return true
124+ }
125+
119126 public func setSize( ofWindow window: Window , to newSize: SIMD2 < Int > ) {
120127 let child = window. child! as! CustomRootWidget
121128 child. preemptAllocatedSize (
@@ -217,7 +224,16 @@ public final class Gtk3Backend: AppBackend {
217224
218225 public func openExternalURL( _ url: URL ) throws {
219226 // Used instead of gtk_uri_launcher_launch to maintain <4.10 compatibility
220- gtk_show_uri ( nil , url. absoluteString, guint ( GDK_CURRENT_TIME) )
227+ var error : UnsafeMutablePointer < GError > ? = nil
228+ gtk_show_uri ( nil , url. absoluteString, guint ( GDK_CURRENT_TIME) , & error)
229+
230+ if let error {
231+ throw Gtk3Error (
232+ code: Int ( error. pointee. code) ,
233+ domain: Int ( error. pointee. domain) ,
234+ message: String ( cString: error. pointee. message)
235+ )
236+ }
221237 }
222238
223239 class ThreadActionContext {
@@ -898,18 +914,18 @@ public final class Gtk3Backend: AppBackend {
898914 gtk_native_dialog_show ( chooser. gobjectPointer. cast ( ) )
899915 }
900916
901- public func createClickTarget ( wrapping child: Widget ) -> Widget {
917+ public func createTapGestureTarget ( wrapping child: Widget ) -> Widget {
902918 let eventBox = Gtk3 . EventBox ( )
903919 eventBox. setChild ( to: child)
904920 eventBox. aboveChild = true
905921 return eventBox
906922 }
907923
908- public func updateClickTarget (
909- _ clickTarget : Widget ,
910- clickHandler handleClick : @escaping ( ) -> Void
924+ public func updateTapGestureTarget (
925+ _ tapGestureTarget : Widget ,
926+ action : @escaping ( ) -> Void
911927 ) {
912- clickTarget . onButtonPress = { _, buttonEvent in
928+ tapGestureTarget . onButtonPress = { _, buttonEvent in
913929 let eventType = buttonEvent. type
914930 guard
915931 eventType == GDK_BUTTON_PRESS
@@ -918,7 +934,7 @@ public final class Gtk3Backend: AppBackend {
918934 else {
919935 return
920936 }
921- handleClick ( )
937+ action ( )
922938 }
923939 }
924940
@@ -987,3 +1003,13 @@ extension UnsafeMutablePointer {
9871003 return UnsafeMutablePointer < T > ( mutating: pointer)
9881004 }
9891005}
1006+
1007+ struct Gtk3Error : LocalizedError {
1008+ var code : Int
1009+ var domain : Int
1010+ var message : String
1011+
1012+ var errorDescription : String ? {
1013+ " gerror: code= \( code) , domain= \( domain) , message= \( message) "
1014+ }
1015+ }
0 commit comments