Gen: re-run gen script
- commit
- 42eb86ea7d14607789a5dc287ca02cc33bce5a1e
- author
- jwijenbergh · · 2024-03-05 12:03 UTC
- committer
- jwijenbergh · · 2024-03-05 12:07 UTC
- parent
- 867f32f
- signature
- GPG Unverified
1A2298F6C34F96E5The key is unknown
261 files · +6159 -2300
M v4/adw/adw-about-window.go +12 -3
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gsk" | |
| 12 | 13 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| @@ -905,15 +906,23 @@ func (c *AboutWindow) SetGoPointer(ptr uintptr) { | |||
| 905 | 906 | // | |
| 906 | 907 | // Applications may connect to it to override the default behavior, which is | |
| 907 | 908 | // to call [func@Gtk.show_uri]. | |
| 908 | - | func (x *AboutWindow) ConnectActivateLink(cb func(AboutWindow, string) bool) uint32 { | |
| 909 | + | func (x *AboutWindow) ConnectActivateLink(cb *func(AboutWindow, string) bool) uint32 { | |
| 910 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 911 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 912 | + | return gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr) | |
| 913 | + | } | |
| 914 | + | ||
| 909 | 915 | fcb := func(clsPtr uintptr, UriVarp string) bool { | |
| 910 | 916 | fa := AboutWindow{} | |
| 911 | 917 | fa.Ptr = clsPtr | |
| 918 | + | cbFn := *cb | |
| 912 | 919 | ||
| 913 | - | return cb(fa, UriVarp) | |
| 920 | + | return cbFn(fa, UriVarp) | |
| 914 | 921 | ||
| 915 | 922 | } | |
| 916 | - | return gobject.SignalConnect(x.GoPointer(), "activate-link", purego.NewCallback(fcb)) | |
| 923 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 924 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 925 | + | return gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr) | |
| 917 | 926 | } | |
| 918 | 927 | ||
| 919 | 928 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-action-row.go +11 -3
| @@ -265,15 +265,23 @@ func (c *ActionRow) SetGoPointer(ptr uintptr) { | |||
| 265 | 265 | } | |
| 266 | 266 | ||
| 267 | 267 | // This signal is emitted after the row has been activated. | |
| 268 | - | func (x *ActionRow) ConnectActivated(cb func(ActionRow)) uint32 { | |
| 268 | + | func (x *ActionRow) ConnectActivated(cb *func(ActionRow)) uint32 { | |
| 269 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 270 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 271 | + | return gobject.SignalConnect(x.GoPointer(), "activated", cbRefPtr) | |
| 272 | + | } | |
| 273 | + | ||
| 269 | 274 | fcb := func(clsPtr uintptr) { | |
| 270 | 275 | fa := ActionRow{} | |
| 271 | 276 | fa.Ptr = clsPtr | |
| 277 | + | cbFn := *cb | |
| 272 | 278 | ||
| 273 | - | cb(fa) | |
| 279 | + | cbFn(fa) | |
| 274 | 280 | ||
| 275 | 281 | } | |
| 276 | - | return gobject.SignalConnect(x.GoPointer(), "activated", purego.NewCallback(fcb)) | |
| 282 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 283 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 284 | + | return gobject.SignalConnect(x.GoPointer(), "activated", cbRefPtr) | |
| 277 | 285 | } | |
| 278 | 286 | ||
| 279 | 287 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-animation-target.go +2 -2
| @@ -69,10 +69,10 @@ var xNewCallbackAnimationTarget func(uintptr, uintptr, uintptr) uintptr | |||
| 69 | 69 | ||
| 70 | 70 | // Creates a new `AdwAnimationTarget` that calls the given @callback during | |
| 71 | 71 | // the animation. | |
| 72 | - | func NewCallbackAnimationTarget(CallbackVar AnimationTargetFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) *CallbackAnimationTarget { | |
| 72 | + | func NewCallbackAnimationTarget(CallbackVar *AnimationTargetFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) *CallbackAnimationTarget { | |
| 73 | 73 | var cls *CallbackAnimationTarget | |
| 74 | 74 | ||
| 75 | - | cret := xNewCallbackAnimationTarget(purego.NewCallback(CallbackVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 75 | + | cret := xNewCallbackAnimationTarget(glib.NewCallback(CallbackVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 76 | 76 | ||
| 77 | 77 | if cret == 0 { | |
| 78 | 78 | return nil | |
M v4/adw/adw-animation.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| 11 | 12 | ) | |
| @@ -285,15 +286,23 @@ func (c *Animation) SetGoPointer(ptr uintptr) { | |||
| 285 | 286 | ||
| 286 | 287 | // This signal is emitted when the animation has been completed, either on its | |
| 287 | 288 | // own or via calling [method@Animation.skip]. | |
| 288 | - | func (x *Animation) ConnectDone(cb func(Animation)) uint32 { | |
| 289 | + | func (x *Animation) ConnectDone(cb *func(Animation)) uint32 { | |
| 290 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 291 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 292 | + | return gobject.SignalConnect(x.GoPointer(), "done", cbRefPtr) | |
| 293 | + | } | |
| 294 | + | ||
| 289 | 295 | fcb := func(clsPtr uintptr) { | |
| 290 | 296 | fa := Animation{} | |
| 291 | 297 | fa.Ptr = clsPtr | |
| 298 | + | cbFn := *cb | |
| 292 | 299 | ||
| 293 | - | cb(fa) | |
| 300 | + | cbFn(fa) | |
| 294 | 301 | ||
| 295 | 302 | } | |
| 296 | - | return gobject.SignalConnect(x.GoPointer(), "done", purego.NewCallback(fcb)) | |
| 303 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 304 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 305 | + | return gobject.SignalConnect(x.GoPointer(), "done", cbRefPtr) | |
| 297 | 306 | } | |
| 298 | 307 | ||
| 299 | 308 | func init() { | |
M v4/adw/adw-banner.go +11 -3
| @@ -162,15 +162,23 @@ func (c *Banner) SetGoPointer(ptr uintptr) { | |||
| 162 | 162 | // This signal is emitted after the action button has been clicked. | |
| 163 | 163 | // | |
| 164 | 164 | // It can be used as an alternative to setting an action. | |
| 165 | - | func (x *Banner) ConnectButtonClicked(cb func(Banner)) uint32 { | |
| 165 | + | func (x *Banner) ConnectButtonClicked(cb *func(Banner)) uint32 { | |
| 166 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 167 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 168 | + | return gobject.SignalConnect(x.GoPointer(), "button-clicked", cbRefPtr) | |
| 169 | + | } | |
| 170 | + | ||
| 166 | 171 | fcb := func(clsPtr uintptr) { | |
| 167 | 172 | fa := Banner{} | |
| 168 | 173 | fa.Ptr = clsPtr | |
| 174 | + | cbFn := *cb | |
| 169 | 175 | ||
| 170 | - | cb(fa) | |
| 176 | + | cbFn(fa) | |
| 171 | 177 | ||
| 172 | 178 | } | |
| 173 | - | return gobject.SignalConnect(x.GoPointer(), "button-clicked", purego.NewCallback(fcb)) | |
| 179 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 180 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 181 | + | return gobject.SignalConnect(x.GoPointer(), "button-clicked", cbRefPtr) | |
| 174 | 182 | } | |
| 175 | 183 | ||
| 176 | 184 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-carousel.go +12 -3
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| 12 | 13 | ) | |
| @@ -320,15 +321,23 @@ func (c *Carousel) SetGoPointer(ptr uintptr) { | |||
| 320 | 321 | // It can be used to implement "infinite scrolling" by amending the pages | |
| 321 | 322 | // after every scroll. Note that an empty carousel is indicated by | |
| 322 | 323 | // `(int)index == -1`. | |
| 323 | - | func (x *Carousel) ConnectPageChanged(cb func(Carousel, uint)) uint32 { | |
| 324 | + | func (x *Carousel) ConnectPageChanged(cb *func(Carousel, uint)) uint32 { | |
| 325 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 326 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 327 | + | return gobject.SignalConnect(x.GoPointer(), "page-changed", cbRefPtr) | |
| 328 | + | } | |
| 329 | + | ||
| 324 | 330 | fcb := func(clsPtr uintptr, IndexVarp uint) { | |
| 325 | 331 | fa := Carousel{} | |
| 326 | 332 | fa.Ptr = clsPtr | |
| 333 | + | cbFn := *cb | |
| 327 | 334 | ||
| 328 | - | cb(fa, IndexVarp) | |
| 335 | + | cbFn(fa, IndexVarp) | |
| 329 | 336 | ||
| 330 | 337 | } | |
| 331 | - | return gobject.SignalConnect(x.GoPointer(), "page-changed", purego.NewCallback(fcb)) | |
| 338 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 339 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 340 | + | return gobject.SignalConnect(x.GoPointer(), "page-changed", cbRefPtr) | |
| 332 | 341 | } | |
| 333 | 342 | ||
| 334 | 343 | // Gets the progress @self will snap back to after the gesture is canceled. | |
M v4/adw/adw-entry-row.go +22 -6
| @@ -259,27 +259,43 @@ func (c *EntryRow) SetGoPointer(ptr uintptr) { | |||
| 259 | 259 | // Emitted when the apply button is pressed. | |
| 260 | 260 | // | |
| 261 | 261 | // See [property@EntryRow:show-apply-button]. | |
| 262 | - | func (x *EntryRow) ConnectApply(cb func(EntryRow)) uint32 { | |
| 262 | + | func (x *EntryRow) ConnectApply(cb *func(EntryRow)) uint32 { | |
| 263 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 264 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 265 | + | return gobject.SignalConnect(x.GoPointer(), "apply", cbRefPtr) | |
| 266 | + | } | |
| 267 | + | ||
| 263 | 268 | fcb := func(clsPtr uintptr) { | |
| 264 | 269 | fa := EntryRow{} | |
| 265 | 270 | fa.Ptr = clsPtr | |
| 271 | + | cbFn := *cb | |
| 266 | 272 | ||
| 267 | - | cb(fa) | |
| 273 | + | cbFn(fa) | |
| 268 | 274 | ||
| 269 | 275 | } | |
| 270 | - | return gobject.SignalConnect(x.GoPointer(), "apply", purego.NewCallback(fcb)) | |
| 276 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 277 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 278 | + | return gobject.SignalConnect(x.GoPointer(), "apply", cbRefPtr) | |
| 271 | 279 | } | |
| 272 | 280 | ||
| 273 | 281 | // Emitted when the embedded entry is activated. | |
| 274 | - | func (x *EntryRow) ConnectEntryActivated(cb func(EntryRow)) uint32 { | |
| 282 | + | func (x *EntryRow) ConnectEntryActivated(cb *func(EntryRow)) uint32 { | |
| 283 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 284 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 285 | + | return gobject.SignalConnect(x.GoPointer(), "entry-activated", cbRefPtr) | |
| 286 | + | } | |
| 287 | + | ||
| 275 | 288 | fcb := func(clsPtr uintptr) { | |
| 276 | 289 | fa := EntryRow{} | |
| 277 | 290 | fa.Ptr = clsPtr | |
| 291 | + | cbFn := *cb | |
| 278 | 292 | ||
| 279 | - | cb(fa) | |
| 293 | + | cbFn(fa) | |
| 280 | 294 | ||
| 281 | 295 | } | |
| 282 | - | return gobject.SignalConnect(x.GoPointer(), "entry-activated", purego.NewCallback(fcb)) | |
| 296 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 297 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 298 | + | return gobject.SignalConnect(x.GoPointer(), "entry-activated", cbRefPtr) | |
| 283 | 299 | } | |
| 284 | 300 | ||
| 285 | 301 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-message-dialog.go +14 -5
| @@ -8,6 +8,7 @@ import ( | |||
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | 10 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 11 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 12 | 13 | "github.com/jwijenbergh/puregotk/v4/gsk" | |
| 13 | 14 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| @@ -278,9 +279,9 @@ var xMessageDialogChoose func(uintptr, uintptr, uintptr, uintptr) | |||
| 278 | 279 | // | |
| 279 | 280 | // The @callback will be called when the alert is dismissed. It should call | |
| 280 | 281 | // [method@MessageDialog.choose_finish] to obtain the result. | |
| 281 | - | func (x *MessageDialog) Choose(CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 282 | + | func (x *MessageDialog) Choose(CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 282 | 283 | ||
| 283 | - | xMessageDialogChoose(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 284 | + | xMessageDialogChoose(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 284 | 285 | ||
| 285 | 286 | } | |
| 286 | 287 | ||
| @@ -627,15 +628,23 @@ func (c *MessageDialog) SetGoPointer(ptr uintptr) { | |||
| 627 | 628 | // if the dialog was closed by pressing <kbd>Escape</kbd> or with a system | |
| 628 | 629 | // action, @response will be set to the value of | |
| 629 | 630 | // [property@MessageDialog:close-response]. | |
| 630 | - | func (x *MessageDialog) ConnectResponse(cb func(MessageDialog, string)) uint32 { | |
| 631 | + | func (x *MessageDialog) ConnectResponse(cb *func(MessageDialog, string)) uint32 { | |
| 632 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 633 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 634 | + | return gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr) | |
| 635 | + | } | |
| 636 | + | ||
| 631 | 637 | fcb := func(clsPtr uintptr, ResponseVarp string) { | |
| 632 | 638 | fa := MessageDialog{} | |
| 633 | 639 | fa.Ptr = clsPtr | |
| 640 | + | cbFn := *cb | |
| 634 | 641 | ||
| 635 | - | cb(fa, ResponseVarp) | |
| 642 | + | cbFn(fa, ResponseVarp) | |
| 636 | 643 | ||
| 637 | 644 | } | |
| 638 | - | return gobject.SignalConnect(x.GoPointer(), "response", purego.NewCallback(fcb)) | |
| 645 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 646 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 647 | + | return gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr) | |
| 639 | 648 | } | |
| 640 | 649 | ||
| 641 | 650 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-split-button.go +22 -6
| @@ -319,27 +319,43 @@ func (c *SplitButton) SetGoPointer(ptr uintptr) { | |||
| 319 | 319 | // | |
| 320 | 320 | // This is an action signal. Applications should never connect to this signal, | |
| 321 | 321 | // but use the [signal@SplitButton::clicked] signal. | |
| 322 | - | func (x *SplitButton) ConnectActivate(cb func(SplitButton)) uint32 { | |
| 322 | + | func (x *SplitButton) ConnectActivate(cb *func(SplitButton)) uint32 { | |
| 323 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 324 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 325 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 326 | + | } | |
| 327 | + | ||
| 323 | 328 | fcb := func(clsPtr uintptr) { | |
| 324 | 329 | fa := SplitButton{} | |
| 325 | 330 | fa.Ptr = clsPtr | |
| 331 | + | cbFn := *cb | |
| 326 | 332 | ||
| 327 | - | cb(fa) | |
| 333 | + | cbFn(fa) | |
| 328 | 334 | ||
| 329 | 335 | } | |
| 330 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 336 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 337 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 338 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 331 | 339 | } | |
| 332 | 340 | ||
| 333 | 341 | // Emitted when the button has been activated (pressed and released). | |
| 334 | - | func (x *SplitButton) ConnectClicked(cb func(SplitButton)) uint32 { | |
| 342 | + | func (x *SplitButton) ConnectClicked(cb *func(SplitButton)) uint32 { | |
| 343 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 344 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 345 | + | return gobject.SignalConnect(x.GoPointer(), "clicked", cbRefPtr) | |
| 346 | + | } | |
| 347 | + | ||
| 335 | 348 | fcb := func(clsPtr uintptr) { | |
| 336 | 349 | fa := SplitButton{} | |
| 337 | 350 | fa.Ptr = clsPtr | |
| 351 | + | cbFn := *cb | |
| 338 | 352 | ||
| 339 | - | cb(fa) | |
| 353 | + | cbFn(fa) | |
| 340 | 354 | ||
| 341 | 355 | } | |
| 342 | - | return gobject.SignalConnect(x.GoPointer(), "clicked", purego.NewCallback(fcb)) | |
| 356 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 357 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 358 | + | return gobject.SignalConnect(x.GoPointer(), "clicked", cbRefPtr) | |
| 343 | 359 | } | |
| 344 | 360 | ||
| 345 | 361 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-swipe-tracker.go +45 -12
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| 11 | 12 | ) | |
| @@ -174,15 +175,23 @@ func (c *SwipeTracker) SetGoPointer(ptr uintptr) { | |||
| 174 | 175 | ||
| 175 | 176 | // This signal is emitted right before a swipe will be started, after the | |
| 176 | 177 | // drag threshold has been passed. | |
| 177 | - | func (x *SwipeTracker) ConnectBeginSwipe(cb func(SwipeTracker)) uint32 { | |
| 178 | + | func (x *SwipeTracker) ConnectBeginSwipe(cb *func(SwipeTracker)) uint32 { | |
| 179 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 180 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 181 | + | return gobject.SignalConnect(x.GoPointer(), "begin-swipe", cbRefPtr) | |
| 182 | + | } | |
| 183 | + | ||
| 178 | 184 | fcb := func(clsPtr uintptr) { | |
| 179 | 185 | fa := SwipeTracker{} | |
| 180 | 186 | fa.Ptr = clsPtr | |
| 187 | + | cbFn := *cb | |
| 181 | 188 | ||
| 182 | - | cb(fa) | |
| 189 | + | cbFn(fa) | |
| 183 | 190 | ||
| 184 | 191 | } | |
| 185 | - | return gobject.SignalConnect(x.GoPointer(), "begin-swipe", purego.NewCallback(fcb)) | |
| 192 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 193 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 194 | + | return gobject.SignalConnect(x.GoPointer(), "begin-swipe", cbRefPtr) | |
| 186 | 195 | } | |
| 187 | 196 | ||
| 188 | 197 | // This signal is emitted as soon as the gesture has stopped. | |
| @@ -191,42 +200,66 @@ func (x *SwipeTracker) ConnectBeginSwipe(cb func(SwipeTracker)) uint32 { | |||
| 191 | 200 | // value to @to with an animation using @velocity as the initial velocity, | |
| 192 | 201 | // provided in pixels per second. [class@SpringAnimation] is usually a good | |
| 193 | 202 | // fit for this. | |
| 194 | - | func (x *SwipeTracker) ConnectEndSwipe(cb func(SwipeTracker, float64, float64)) uint32 { | |
| 203 | + | func (x *SwipeTracker) ConnectEndSwipe(cb *func(SwipeTracker, float64, float64)) uint32 { | |
| 204 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 205 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 206 | + | return gobject.SignalConnect(x.GoPointer(), "end-swipe", cbRefPtr) | |
| 207 | + | } | |
| 208 | + | ||
| 195 | 209 | fcb := func(clsPtr uintptr, VelocityVarp float64, ToVarp float64) { | |
| 196 | 210 | fa := SwipeTracker{} | |
| 197 | 211 | fa.Ptr = clsPtr | |
| 212 | + | cbFn := *cb | |
| 198 | 213 | ||
| 199 | - | cb(fa, VelocityVarp, ToVarp) | |
| 214 | + | cbFn(fa, VelocityVarp, ToVarp) | |
| 200 | 215 | ||
| 201 | 216 | } | |
| 202 | - | return gobject.SignalConnect(x.GoPointer(), "end-swipe", purego.NewCallback(fcb)) | |
| 217 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 218 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 219 | + | return gobject.SignalConnect(x.GoPointer(), "end-swipe", cbRefPtr) | |
| 203 | 220 | } | |
| 204 | 221 | ||
| 205 | 222 | // This signal is emitted when a possible swipe is detected. | |
| 206 | 223 | // | |
| 207 | 224 | // The @direction value can be used to restrict the swipe to a certain | |
| 208 | 225 | // direction. | |
| 209 | - | func (x *SwipeTracker) ConnectPrepare(cb func(SwipeTracker, NavigationDirection)) uint32 { | |
| 226 | + | func (x *SwipeTracker) ConnectPrepare(cb *func(SwipeTracker, NavigationDirection)) uint32 { | |
| 227 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 228 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 229 | + | return gobject.SignalConnect(x.GoPointer(), "prepare", cbRefPtr) | |
| 230 | + | } | |
| 231 | + | ||
| 210 | 232 | fcb := func(clsPtr uintptr, DirectionVarp NavigationDirection) { | |
| 211 | 233 | fa := SwipeTracker{} | |
| 212 | 234 | fa.Ptr = clsPtr | |
| 235 | + | cbFn := *cb | |
| 213 | 236 | ||
| 214 | - | cb(fa, DirectionVarp) | |
| 237 | + | cbFn(fa, DirectionVarp) | |
| 215 | 238 | ||
| 216 | 239 | } | |
| 217 | - | return gobject.SignalConnect(x.GoPointer(), "prepare", purego.NewCallback(fcb)) | |
| 240 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 241 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 242 | + | return gobject.SignalConnect(x.GoPointer(), "prepare", cbRefPtr) | |
| 218 | 243 | } | |
| 219 | 244 | ||
| 220 | 245 | // This signal is emitted every time the progress value changes. | |
| 221 | - | func (x *SwipeTracker) ConnectUpdateSwipe(cb func(SwipeTracker, float64)) uint32 { | |
| 246 | + | func (x *SwipeTracker) ConnectUpdateSwipe(cb *func(SwipeTracker, float64)) uint32 { | |
| 247 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 248 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 249 | + | return gobject.SignalConnect(x.GoPointer(), "update-swipe", cbRefPtr) | |
| 250 | + | } | |
| 251 | + | ||
| 222 | 252 | fcb := func(clsPtr uintptr, ProgressVarp float64) { | |
| 223 | 253 | fa := SwipeTracker{} | |
| 224 | 254 | fa.Ptr = clsPtr | |
| 255 | + | cbFn := *cb | |
| 225 | 256 | ||
| 226 | - | cb(fa, ProgressVarp) | |
| 257 | + | cbFn(fa, ProgressVarp) | |
| 227 | 258 | ||
| 228 | 259 | } | |
| 229 | - | return gobject.SignalConnect(x.GoPointer(), "update-swipe", purego.NewCallback(fcb)) | |
| 260 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 261 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 262 | + | return gobject.SignalConnect(x.GoPointer(), "update-swipe", cbRefPtr) | |
| 230 | 263 | } | |
| 231 | 264 | ||
| 232 | 265 | // Retrieves the orientation of the @orientable. | |
M v4/adw/adw-tab-bar.go +23 -6
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| 12 | 13 | ) | |
| @@ -286,15 +287,23 @@ func (c *TabBar) SetGoPointer(ptr uintptr) { | |||
| 286 | 287 | // [method@TabBar.setup_extra_drop_target]. | |
| 287 | 288 | // | |
| 288 | 289 | // See [signal@Gtk.DropTarget::drop]. | |
| 289 | - | func (x *TabBar) ConnectExtraDragDrop(cb func(TabBar, uintptr, uintptr) bool) uint32 { | |
| 290 | + | func (x *TabBar) ConnectExtraDragDrop(cb *func(TabBar, uintptr, uintptr) bool) uint32 { | |
| 291 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 292 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 293 | + | return gobject.SignalConnect(x.GoPointer(), "extra-drag-drop", cbRefPtr) | |
| 294 | + | } | |
| 295 | + | ||
| 290 | 296 | fcb := func(clsPtr uintptr, PageVarp uintptr, ValueVarp uintptr) bool { | |
| 291 | 297 | fa := TabBar{} | |
| 292 | 298 | fa.Ptr = clsPtr | |
| 299 | + | cbFn := *cb | |
| 293 | 300 | ||
| 294 | - | return cb(fa, PageVarp, ValueVarp) | |
| 301 | + | return cbFn(fa, PageVarp, ValueVarp) | |
| 295 | 302 | ||
| 296 | 303 | } | |
| 297 | - | return gobject.SignalConnect(x.GoPointer(), "extra-drag-drop", purego.NewCallback(fcb)) | |
| 304 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 305 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 306 | + | return gobject.SignalConnect(x.GoPointer(), "extra-drag-drop", cbRefPtr) | |
| 298 | 307 | } | |
| 299 | 308 | ||
| 300 | 309 | // This signal is emitted when the dropped content is preloaded. | |
| @@ -306,15 +315,23 @@ func (x *TabBar) ConnectExtraDragDrop(cb func(TabBar, uintptr, uintptr) bool) ui | |||
| 306 | 315 | // [method@TabBar.setup_extra_drop_target]. | |
| 307 | 316 | // | |
| 308 | 317 | // See [property@Gtk.DropTarget:value]. | |
| 309 | - | func (x *TabBar) ConnectExtraDragValue(cb func(TabBar, uintptr, uintptr) gdk.DragAction) uint32 { | |
| 318 | + | func (x *TabBar) ConnectExtraDragValue(cb *func(TabBar, uintptr, uintptr) gdk.DragAction) uint32 { | |
| 319 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 320 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 321 | + | return gobject.SignalConnect(x.GoPointer(), "extra-drag-value", cbRefPtr) | |
| 322 | + | } | |
| 323 | + | ||
| 310 | 324 | fcb := func(clsPtr uintptr, PageVarp uintptr, ValueVarp uintptr) gdk.DragAction { | |
| 311 | 325 | fa := TabBar{} | |
| 312 | 326 | fa.Ptr = clsPtr | |
| 327 | + | cbFn := *cb | |
| 313 | 328 | ||
| 314 | - | return cb(fa, PageVarp, ValueVarp) | |
| 329 | + | return cbFn(fa, PageVarp, ValueVarp) | |
| 315 | 330 | ||
| 316 | 331 | } | |
| 317 | - | return gobject.SignalConnect(x.GoPointer(), "extra-drag-value", purego.NewCallback(fcb)) | |
| 332 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 333 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 334 | + | return gobject.SignalConnect(x.GoPointer(), "extra-drag-value", cbRefPtr) | |
| 318 | 335 | } | |
| 319 | 336 | ||
| 320 | 337 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-tab-button.go +22 -6
| @@ -116,27 +116,43 @@ func (c *TabButton) SetGoPointer(ptr uintptr) { | |||
| 116 | 116 | // | |
| 117 | 117 | // This is an action signal. Applications should never connect to this signal, | |
| 118 | 118 | // but use the [signal@TabButton::clicked] signal. | |
| 119 | - | func (x *TabButton) ConnectActivate(cb func(TabButton)) uint32 { | |
| 119 | + | func (x *TabButton) ConnectActivate(cb *func(TabButton)) uint32 { | |
| 120 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 121 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 122 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 123 | + | } | |
| 124 | + | ||
| 120 | 125 | fcb := func(clsPtr uintptr) { | |
| 121 | 126 | fa := TabButton{} | |
| 122 | 127 | fa.Ptr = clsPtr | |
| 128 | + | cbFn := *cb | |
| 123 | 129 | ||
| 124 | - | cb(fa) | |
| 130 | + | cbFn(fa) | |
| 125 | 131 | ||
| 126 | 132 | } | |
| 127 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 133 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 134 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 135 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 128 | 136 | } | |
| 129 | 137 | ||
| 130 | 138 | // Emitted when the button has been activated (pressed and released). | |
| 131 | - | func (x *TabButton) ConnectClicked(cb func(TabButton)) uint32 { | |
| 139 | + | func (x *TabButton) ConnectClicked(cb *func(TabButton)) uint32 { | |
| 140 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 141 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 142 | + | return gobject.SignalConnect(x.GoPointer(), "clicked", cbRefPtr) | |
| 143 | + | } | |
| 144 | + | ||
| 132 | 145 | fcb := func(clsPtr uintptr) { | |
| 133 | 146 | fa := TabButton{} | |
| 134 | 147 | fa.Ptr = clsPtr | |
| 148 | + | cbFn := *cb | |
| 135 | 149 | ||
| 136 | - | cb(fa) | |
| 150 | + | cbFn(fa) | |
| 137 | 151 | ||
| 138 | 152 | } | |
| 139 | - | return gobject.SignalConnect(x.GoPointer(), "clicked", purego.NewCallback(fcb)) | |
| 153 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 154 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 155 | + | return gobject.SignalConnect(x.GoPointer(), "clicked", cbRefPtr) | |
| 140 | 156 | } | |
| 141 | 157 | ||
| 142 | 158 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-tab-overview.go +34 -9
| @@ -8,6 +8,7 @@ import ( | |||
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | 10 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 11 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 12 | 13 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| 13 | 14 | ) | |
| @@ -379,16 +380,24 @@ func (c *TabOverview) SetGoPointer(ptr uintptr) { | |||
| 379 | 380 | // | |
| 380 | 381 | // The signal handler is expected to create a new page in the corresponding | |
| 381 | 382 | // [class@TabView] and return it. | |
| 382 | - | func (x *TabOverview) ConnectCreateTab(cb func(TabOverview) TabPage) uint32 { | |
| 383 | + | func (x *TabOverview) ConnectCreateTab(cb *func(TabOverview) TabPage) uint32 { | |
| 384 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 385 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 386 | + | return gobject.SignalConnect(x.GoPointer(), "create-tab", cbRefPtr) | |
| 387 | + | } | |
| 388 | + | ||
| 383 | 389 | fcb := func(clsPtr uintptr) uintptr { | |
| 384 | 390 | fa := TabOverview{} | |
| 385 | 391 | fa.Ptr = clsPtr | |
| 392 | + | cbFn := *cb | |
| 386 | 393 | ||
| 387 | - | CreateTabCls := cb(fa) | |
| 394 | + | CreateTabCls := cbFn(fa) | |
| 388 | 395 | return CreateTabCls.Ptr | |
| 389 | 396 | ||
| 390 | 397 | } | |
| 391 | - | return gobject.SignalConnect(x.GoPointer(), "create-tab", purego.NewCallback(fcb)) | |
| 398 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 399 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 400 | + | return gobject.SignalConnect(x.GoPointer(), "create-tab", cbRefPtr) | |
| 392 | 401 | } | |
| 393 | 402 | ||
| 394 | 403 | // This signal is emitted when content is dropped onto a tab. | |
| @@ -397,15 +406,23 @@ func (x *TabOverview) ConnectCreateTab(cb func(TabOverview) TabPage) uint32 { | |||
| 397 | 406 | // [method@TabOverview.setup_extra_drop_target]. | |
| 398 | 407 | // | |
| 399 | 408 | // See [signal@Gtk.DropTarget::drop]. | |
| 400 | - | func (x *TabOverview) ConnectExtraDragDrop(cb func(TabOverview, uintptr, uintptr) bool) uint32 { | |
| 409 | + | func (x *TabOverview) ConnectExtraDragDrop(cb *func(TabOverview, uintptr, uintptr) bool) uint32 { | |
| 410 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 411 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 412 | + | return gobject.SignalConnect(x.GoPointer(), "extra-drag-drop", cbRefPtr) | |
| 413 | + | } | |
| 414 | + | ||
| 401 | 415 | fcb := func(clsPtr uintptr, PageVarp uintptr, ValueVarp uintptr) bool { | |
| 402 | 416 | fa := TabOverview{} | |
| 403 | 417 | fa.Ptr = clsPtr | |
| 418 | + | cbFn := *cb | |
| 404 | 419 | ||
| 405 | - | return cb(fa, PageVarp, ValueVarp) | |
| 420 | + | return cbFn(fa, PageVarp, ValueVarp) | |
| 406 | 421 | ||
| 407 | 422 | } | |
| 408 | - | return gobject.SignalConnect(x.GoPointer(), "extra-drag-drop", purego.NewCallback(fcb)) | |
| 423 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 424 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 425 | + | return gobject.SignalConnect(x.GoPointer(), "extra-drag-drop", cbRefPtr) | |
| 409 | 426 | } | |
| 410 | 427 | ||
| 411 | 428 | // This signal is emitted when the dropped content is preloaded. | |
| @@ -417,15 +434,23 @@ func (x *TabOverview) ConnectExtraDragDrop(cb func(TabOverview, uintptr, uintptr | |||
| 417 | 434 | // [method@TabOverview.setup_extra_drop_target]. | |
| 418 | 435 | // | |
| 419 | 436 | // See [property@Gtk.DropTarget:value]. | |
| 420 | - | func (x *TabOverview) ConnectExtraDragValue(cb func(TabOverview, uintptr, uintptr) gdk.DragAction) uint32 { | |
| 437 | + | func (x *TabOverview) ConnectExtraDragValue(cb *func(TabOverview, uintptr, uintptr) gdk.DragAction) uint32 { | |
| 438 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 439 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 440 | + | return gobject.SignalConnect(x.GoPointer(), "extra-drag-value", cbRefPtr) | |
| 441 | + | } | |
| 442 | + | ||
| 421 | 443 | fcb := func(clsPtr uintptr, PageVarp uintptr, ValueVarp uintptr) gdk.DragAction { | |
| 422 | 444 | fa := TabOverview{} | |
| 423 | 445 | fa.Ptr = clsPtr | |
| 446 | + | cbFn := *cb | |
| 424 | 447 | ||
| 425 | - | return cb(fa, PageVarp, ValueVarp) | |
| 448 | + | return cbFn(fa, PageVarp, ValueVarp) | |
| 426 | 449 | ||
| 427 | 450 | } | |
| 428 | - | return gobject.SignalConnect(x.GoPointer(), "extra-drag-value", purego.NewCallback(fcb)) | |
| 451 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 452 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 453 | + | return gobject.SignalConnect(x.GoPointer(), "extra-drag-value", cbRefPtr) | |
| 429 | 454 | } | |
| 430 | 455 | ||
| 431 | 456 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-tab-view.go +78 -21
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gtk" | |
| 12 | 13 | ) | |
| @@ -1300,15 +1301,23 @@ func (c *TabView) SetGoPointer(ptr uintptr) { | |||
| 1300 | 1301 | // | |
| 1301 | 1302 | // A typical reason to connect to this signal is to show a confirmation dialog | |
| 1302 | 1303 | // for closing a tab. | |
| 1303 | - | func (x *TabView) ConnectClosePage(cb func(TabView, uintptr) bool) uint32 { | |
| 1304 | + | func (x *TabView) ConnectClosePage(cb *func(TabView, uintptr) bool) uint32 { | |
| 1305 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1306 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1307 | + | return gobject.SignalConnect(x.GoPointer(), "close-page", cbRefPtr) | |
| 1308 | + | } | |
| 1309 | + | ||
| 1304 | 1310 | fcb := func(clsPtr uintptr, PageVarp uintptr) bool { | |
| 1305 | 1311 | fa := TabView{} | |
| 1306 | 1312 | fa.Ptr = clsPtr | |
| 1313 | + | cbFn := *cb | |
| 1307 | 1314 | ||
| 1308 | - | return cb(fa, PageVarp) | |
| 1315 | + | return cbFn(fa, PageVarp) | |
| 1309 | 1316 | ||
| 1310 | 1317 | } | |
| 1311 | - | return gobject.SignalConnect(x.GoPointer(), "close-page", purego.NewCallback(fcb)) | |
| 1318 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1319 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1320 | + | return gobject.SignalConnect(x.GoPointer(), "close-page", cbRefPtr) | |
| 1312 | 1321 | } | |
| 1313 | 1322 | ||
| 1314 | 1323 | // Emitted when a tab should be transferred into a new window. | |
| @@ -1317,46 +1326,70 @@ func (x *TabView) ConnectClosePage(cb func(TabView, uintptr) bool) uint32 { | |||
| 1317 | 1326 | // | |
| 1318 | 1327 | // The signal handler is expected to create a new window, position it as | |
| 1319 | 1328 | // needed and return its `AdwTabView` that the page will be transferred into. | |
| 1320 | - | func (x *TabView) ConnectCreateWindow(cb func(TabView) TabView) uint32 { | |
| 1329 | + | func (x *TabView) ConnectCreateWindow(cb *func(TabView) TabView) uint32 { | |
| 1330 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1331 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1332 | + | return gobject.SignalConnect(x.GoPointer(), "create-window", cbRefPtr) | |
| 1333 | + | } | |
| 1334 | + | ||
| 1321 | 1335 | fcb := func(clsPtr uintptr) uintptr { | |
| 1322 | 1336 | fa := TabView{} | |
| 1323 | 1337 | fa.Ptr = clsPtr | |
| 1338 | + | cbFn := *cb | |
| 1324 | 1339 | ||
| 1325 | - | CreateWindowCls := cb(fa) | |
| 1340 | + | CreateWindowCls := cbFn(fa) | |
| 1326 | 1341 | return CreateWindowCls.Ptr | |
| 1327 | 1342 | ||
| 1328 | 1343 | } | |
| 1329 | - | return gobject.SignalConnect(x.GoPointer(), "create-window", purego.NewCallback(fcb)) | |
| 1344 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1345 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1346 | + | return gobject.SignalConnect(x.GoPointer(), "create-window", cbRefPtr) | |
| 1330 | 1347 | } | |
| 1331 | 1348 | ||
| 1332 | 1349 | // Emitted after the indicator icon on @page has been activated. | |
| 1333 | 1350 | // | |
| 1334 | 1351 | // See [property@TabPage:indicator-icon] and | |
| 1335 | 1352 | // [property@TabPage:indicator-activatable]. | |
| 1336 | - | func (x *TabView) ConnectIndicatorActivated(cb func(TabView, uintptr)) uint32 { | |
| 1353 | + | func (x *TabView) ConnectIndicatorActivated(cb *func(TabView, uintptr)) uint32 { | |
| 1354 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1355 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1356 | + | return gobject.SignalConnect(x.GoPointer(), "indicator-activated", cbRefPtr) | |
| 1357 | + | } | |
| 1358 | + | ||
| 1337 | 1359 | fcb := func(clsPtr uintptr, PageVarp uintptr) { | |
| 1338 | 1360 | fa := TabView{} | |
| 1339 | 1361 | fa.Ptr = clsPtr | |
| 1362 | + | cbFn := *cb | |
| 1340 | 1363 | ||
| 1341 | - | cb(fa, PageVarp) | |
| 1364 | + | cbFn(fa, PageVarp) | |
| 1342 | 1365 | ||
| 1343 | 1366 | } | |
| 1344 | - | return gobject.SignalConnect(x.GoPointer(), "indicator-activated", purego.NewCallback(fcb)) | |
| 1367 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1368 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1369 | + | return gobject.SignalConnect(x.GoPointer(), "indicator-activated", cbRefPtr) | |
| 1345 | 1370 | } | |
| 1346 | 1371 | ||
| 1347 | 1372 | // Emitted when a page has been created or transferred to @self. | |
| 1348 | 1373 | // | |
| 1349 | 1374 | // A typical reason to connect to this signal would be to connect to page | |
| 1350 | 1375 | // signals for things such as updating window title. | |
| 1351 | - | func (x *TabView) ConnectPageAttached(cb func(TabView, uintptr, int)) uint32 { | |
| 1376 | + | func (x *TabView) ConnectPageAttached(cb *func(TabView, uintptr, int)) uint32 { | |
| 1377 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1378 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1379 | + | return gobject.SignalConnect(x.GoPointer(), "page-attached", cbRefPtr) | |
| 1380 | + | } | |
| 1381 | + | ||
| 1352 | 1382 | fcb := func(clsPtr uintptr, PageVarp uintptr, PositionVarp int) { | |
| 1353 | 1383 | fa := TabView{} | |
| 1354 | 1384 | fa.Ptr = clsPtr | |
| 1385 | + | cbFn := *cb | |
| 1355 | 1386 | ||
| 1356 | - | cb(fa, PageVarp, PositionVarp) | |
| 1387 | + | cbFn(fa, PageVarp, PositionVarp) | |
| 1357 | 1388 | ||
| 1358 | 1389 | } | |
| 1359 | - | return gobject.SignalConnect(x.GoPointer(), "page-attached", purego.NewCallback(fcb)) | |
| 1390 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1391 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1392 | + | return gobject.SignalConnect(x.GoPointer(), "page-attached", cbRefPtr) | |
| 1360 | 1393 | } | |
| 1361 | 1394 | ||
| 1362 | 1395 | // Emitted when a page has been removed or transferred to another view. | |
| @@ -1368,27 +1401,43 @@ func (x *TabView) ConnectPageAttached(cb func(TabView, uintptr, int)) uint32 { | |||
| 1368 | 1401 | // this function as the child might merely be moved to another window; use | |
| 1369 | 1402 | // child dispose handler for that or do it in sync with your | |
| 1370 | 1403 | // [method@TabView.close_page_finish] calls. | |
| 1371 | - | func (x *TabView) ConnectPageDetached(cb func(TabView, uintptr, int)) uint32 { | |
| 1404 | + | func (x *TabView) ConnectPageDetached(cb *func(TabView, uintptr, int)) uint32 { | |
| 1405 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1406 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1407 | + | return gobject.SignalConnect(x.GoPointer(), "page-detached", cbRefPtr) | |
| 1408 | + | } | |
| 1409 | + | ||
| 1372 | 1410 | fcb := func(clsPtr uintptr, PageVarp uintptr, PositionVarp int) { | |
| 1373 | 1411 | fa := TabView{} | |
| 1374 | 1412 | fa.Ptr = clsPtr | |
| 1413 | + | cbFn := *cb | |
| 1375 | 1414 | ||
| 1376 | - | cb(fa, PageVarp, PositionVarp) | |
| 1415 | + | cbFn(fa, PageVarp, PositionVarp) | |
| 1377 | 1416 | ||
| 1378 | 1417 | } | |
| 1379 | - | return gobject.SignalConnect(x.GoPointer(), "page-detached", purego.NewCallback(fcb)) | |
| 1418 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1419 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1420 | + | return gobject.SignalConnect(x.GoPointer(), "page-detached", cbRefPtr) | |
| 1380 | 1421 | } | |
| 1381 | 1422 | ||
| 1382 | 1423 | // Emitted after @page has been reordered to @position. | |
| 1383 | - | func (x *TabView) ConnectPageReordered(cb func(TabView, uintptr, int)) uint32 { | |
| 1424 | + | func (x *TabView) ConnectPageReordered(cb *func(TabView, uintptr, int)) uint32 { | |
| 1425 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1426 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1427 | + | return gobject.SignalConnect(x.GoPointer(), "page-reordered", cbRefPtr) | |
| 1428 | + | } | |
| 1429 | + | ||
| 1384 | 1430 | fcb := func(clsPtr uintptr, PageVarp uintptr, PositionVarp int) { | |
| 1385 | 1431 | fa := TabView{} | |
| 1386 | 1432 | fa.Ptr = clsPtr | |
| 1433 | + | cbFn := *cb | |
| 1387 | 1434 | ||
| 1388 | - | cb(fa, PageVarp, PositionVarp) | |
| 1435 | + | cbFn(fa, PageVarp, PositionVarp) | |
| 1389 | 1436 | ||
| 1390 | 1437 | } | |
| 1391 | - | return gobject.SignalConnect(x.GoPointer(), "page-reordered", purego.NewCallback(fcb)) | |
| 1438 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1439 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1440 | + | return gobject.SignalConnect(x.GoPointer(), "page-reordered", cbRefPtr) | |
| 1392 | 1441 | } | |
| 1393 | 1442 | ||
| 1394 | 1443 | // Emitted when a context menu is opened or closed for @page. | |
| @@ -1397,15 +1446,23 @@ func (x *TabView) ConnectPageReordered(cb func(TabView, uintptr, int)) uint32 { | |||
| 1397 | 1446 | // | |
| 1398 | 1447 | // It can be used to set up menu actions before showing the menu, for example | |
| 1399 | 1448 | // disable actions not applicable to @page. | |
| 1400 | - | func (x *TabView) ConnectSetupMenu(cb func(TabView, uintptr)) uint32 { | |
| 1449 | + | func (x *TabView) ConnectSetupMenu(cb *func(TabView, uintptr)) uint32 { | |
| 1450 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1451 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1452 | + | return gobject.SignalConnect(x.GoPointer(), "setup-menu", cbRefPtr) | |
| 1453 | + | } | |
| 1454 | + | ||
| 1401 | 1455 | fcb := func(clsPtr uintptr, PageVarp uintptr) { | |
| 1402 | 1456 | fa := TabView{} | |
| 1403 | 1457 | fa.Ptr = clsPtr | |
| 1458 | + | cbFn := *cb | |
| 1404 | 1459 | ||
| 1405 | - | cb(fa, PageVarp) | |
| 1460 | + | cbFn(fa, PageVarp) | |
| 1406 | 1461 | ||
| 1407 | 1462 | } | |
| 1408 | - | return gobject.SignalConnect(x.GoPointer(), "setup-menu", purego.NewCallback(fcb)) | |
| 1463 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1464 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1465 | + | return gobject.SignalConnect(x.GoPointer(), "setup-menu", cbRefPtr) | |
| 1409 | 1466 | } | |
| 1410 | 1467 | ||
| 1411 | 1468 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/adw/adw-toast.go +22 -6
| @@ -440,27 +440,43 @@ func (c *Toast) SetGoPointer(ptr uintptr) { | |||
| 440 | 440 | // Emitted after the button has been clicked. | |
| 441 | 441 | // | |
| 442 | 442 | // It can be used as an alternative to setting an action. | |
| 443 | - | func (x *Toast) ConnectButtonClicked(cb func(Toast)) uint32 { | |
| 443 | + | func (x *Toast) ConnectButtonClicked(cb *func(Toast)) uint32 { | |
| 444 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 445 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 446 | + | return gobject.SignalConnect(x.GoPointer(), "button-clicked", cbRefPtr) | |
| 447 | + | } | |
| 448 | + | ||
| 444 | 449 | fcb := func(clsPtr uintptr) { | |
| 445 | 450 | fa := Toast{} | |
| 446 | 451 | fa.Ptr = clsPtr | |
| 452 | + | cbFn := *cb | |
| 447 | 453 | ||
| 448 | - | cb(fa) | |
| 454 | + | cbFn(fa) | |
| 449 | 455 | ||
| 450 | 456 | } | |
| 451 | - | return gobject.SignalConnect(x.GoPointer(), "button-clicked", purego.NewCallback(fcb)) | |
| 457 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 458 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 459 | + | return gobject.SignalConnect(x.GoPointer(), "button-clicked", cbRefPtr) | |
| 452 | 460 | } | |
| 453 | 461 | ||
| 454 | 462 | // Emitted when the toast has been dismissed. | |
| 455 | - | func (x *Toast) ConnectDismissed(cb func(Toast)) uint32 { | |
| 463 | + | func (x *Toast) ConnectDismissed(cb *func(Toast)) uint32 { | |
| 464 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 465 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 466 | + | return gobject.SignalConnect(x.GoPointer(), "dismissed", cbRefPtr) | |
| 467 | + | } | |
| 468 | + | ||
| 456 | 469 | fcb := func(clsPtr uintptr) { | |
| 457 | 470 | fa := Toast{} | |
| 458 | 471 | fa.Ptr = clsPtr | |
| 472 | + | cbFn := *cb | |
| 459 | 473 | ||
| 460 | - | cb(fa) | |
| 474 | + | cbFn(fa) | |
| 461 | 475 | ||
| 462 | 476 | } | |
| 463 | - | return gobject.SignalConnect(x.GoPointer(), "dismissed", purego.NewCallback(fcb)) | |
| 477 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 478 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 479 | + | return gobject.SignalConnect(x.GoPointer(), "dismissed", cbRefPtr) | |
| 464 | 480 | } | |
| 465 | 481 | ||
| 466 | 482 | func init() { | |
M v4/gdk/gdkclipboard.go +23 -13
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -107,9 +109,9 @@ var xClipboardReadAsync func(uintptr, []string, int, uintptr, uintptr, uintptr) | |||
| 107 | 109 | // | |
| 108 | 110 | // The clipboard will choose the most suitable mime type from the given list | |
| 109 | 111 | // to fulfill the request, preferring the ones listed first. | |
| 110 | - | func (x *Clipboard) ReadAsync(MimeTypesVar []string, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 112 | + | func (x *Clipboard) ReadAsync(MimeTypesVar []string, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 111 | 113 | ||
| 112 | - | xClipboardReadAsync(x.GoPointer(), MimeTypesVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 114 | + | xClipboardReadAsync(x.GoPointer(), MimeTypesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 113 | 115 | ||
| 114 | 116 | } | |
| 115 | 117 | ||
| @@ -146,9 +148,9 @@ var xClipboardReadTextAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 146 | 148 | // This is a simple wrapper around [method@Gdk.Clipboard.read_value_async]. | |
| 147 | 149 | // Use that function or [method@Gdk.Clipboard.read_async] directly if you | |
| 148 | 150 | // need more control over the operation. | |
| 149 | - | func (x *Clipboard) ReadTextAsync(CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 151 | + | func (x *Clipboard) ReadTextAsync(CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 150 | 152 | ||
| 151 | - | xClipboardReadTextAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 153 | + | xClipboardReadTextAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 152 | 154 | ||
| 153 | 155 | } | |
| 154 | 156 | ||
| @@ -178,9 +180,9 @@ var xClipboardReadTextureAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 178 | 180 | // This is a simple wrapper around [method@Gdk.Clipboard.read_value_async]. | |
| 179 | 181 | // Use that function or [method@Gdk.Clipboard.read_async] directly if you | |
| 180 | 182 | // need more control over the operation. | |
| 181 | - | func (x *Clipboard) ReadTextureAsync(CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 183 | + | func (x *Clipboard) ReadTextureAsync(CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 182 | 184 | ||
| 183 | - | xClipboardReadTextureAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 185 | + | xClipboardReadTextureAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 184 | 186 | ||
| 185 | 187 | } | |
| 186 | 188 | ||
| @@ -218,9 +220,9 @@ var xClipboardReadValueAsync func(uintptr, []interface{}, int, uintptr, uintptr, | |||
| 218 | 220 | // For local clipboard contents that are available in the given `GType`, | |
| 219 | 221 | // the value will be copied directly. Otherwise, GDK will try to use | |
| 220 | 222 | // [func@content_deserialize_async] to convert the clipboard's data. | |
| 221 | - | func (x *Clipboard) ReadValueAsync(TypeVar []interface{}, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 223 | + | func (x *Clipboard) ReadValueAsync(TypeVar []interface{}, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 222 | 224 | ||
| 223 | - | xClipboardReadValueAsync(x.GoPointer(), TypeVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 225 | + | xClipboardReadValueAsync(x.GoPointer(), TypeVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 224 | 226 | ||
| 225 | 227 | } | |
| 226 | 228 | ||
| @@ -330,9 +332,9 @@ var xClipboardStoreAsync func(uintptr, int, uintptr, uintptr, uintptr) | |||
| 330 | 332 | // | |
| 331 | 333 | // This function is called automatically when a [class@Gtk.Application] is | |
| 332 | 334 | // shut down, so you likely don't need to call it. | |
| 333 | - | func (x *Clipboard) StoreAsync(IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 335 | + | func (x *Clipboard) StoreAsync(IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 334 | 336 | ||
| 335 | - | xClipboardStoreAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 337 | + | xClipboardStoreAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 336 | 338 | ||
| 337 | 339 | } | |
| 338 | 340 | ||
| @@ -361,15 +363,23 @@ func (c *Clipboard) SetGoPointer(ptr uintptr) { | |||
| 361 | 363 | } | |
| 362 | 364 | ||
| 363 | 365 | // Emitted when the clipboard changes ownership. | |
| 364 | - | func (x *Clipboard) ConnectChanged(cb func(Clipboard)) uint32 { | |
| 366 | + | func (x *Clipboard) ConnectChanged(cb *func(Clipboard)) uint32 { | |
| 367 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 368 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 369 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 370 | + | } | |
| 371 | + | ||
| 365 | 372 | fcb := func(clsPtr uintptr) { | |
| 366 | 373 | fa := Clipboard{} | |
| 367 | 374 | fa.Ptr = clsPtr | |
| 375 | + | cbFn := *cb | |
| 368 | 376 | ||
| 369 | - | cb(fa) | |
| 377 | + | cbFn(fa) | |
| 370 | 378 | ||
| 371 | 379 | } | |
| 372 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 380 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 381 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 382 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 373 | 383 | } | |
| 374 | 384 | ||
| 375 | 385 | func init() { | |
M v4/gdk/gdkcontentdeserializer.go +6 -6
| @@ -25,9 +25,9 @@ var xContentDeserializeAsync func(uintptr, string, []interface{}, int, uintptr, | |||
| 25 | 25 | // | |
| 26 | 26 | // When the operation is finished, @callback will be called. You must then | |
| 27 | 27 | // call [func@Gdk.content_deserialize_finish] to get the result of the operation. | |
| 28 | - | func ContentDeserializeAsync(StreamVar *gio.InputStream, MimeTypeVar string, TypeVar []interface{}, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 28 | + | func ContentDeserializeAsync(StreamVar *gio.InputStream, MimeTypeVar string, TypeVar []interface{}, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 29 | 29 | ||
| 30 | - | xContentDeserializeAsync(StreamVar.GoPointer(), MimeTypeVar, TypeVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 30 | + | xContentDeserializeAsync(StreamVar.GoPointer(), MimeTypeVar, TypeVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 31 | 31 | ||
| 32 | 32 | } | |
| 33 | 33 | ||
| @@ -48,9 +48,9 @@ func ContentDeserializeFinish(ResultVar gio.AsyncResult, ValueVar *gobject.Value | |||
| 48 | 48 | var xContentRegisterDeserializer func(string, []interface{}, uintptr, uintptr, uintptr) | |
| 49 | 49 | ||
| 50 | 50 | // Registers a function to deserialize object of a given type. | |
| 51 | - | func ContentRegisterDeserializer(MimeTypeVar string, TypeVar []interface{}, DeserializeVar ContentDeserializeFunc, DataVar uintptr, NotifyVar glib.DestroyNotify) { | |
| 51 | + | func ContentRegisterDeserializer(MimeTypeVar string, TypeVar []interface{}, DeserializeVar *ContentDeserializeFunc, DataVar uintptr, NotifyVar *glib.DestroyNotify) { | |
| 52 | 52 | ||
| 53 | - | xContentRegisterDeserializer(MimeTypeVar, TypeVar, purego.NewCallback(DeserializeVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 53 | + | xContentRegisterDeserializer(MimeTypeVar, TypeVar, glib.NewCallback(DeserializeVar), DataVar, glib.NewCallback(NotifyVar)) | |
| 54 | 54 | ||
| 55 | 55 | } | |
| 56 | 56 | ||
| @@ -194,9 +194,9 @@ func (x *ContentDeserializer) ReturnSuccess() { | |||
| 194 | 194 | var xContentDeserializerSetTaskData func(uintptr, uintptr, uintptr) | |
| 195 | 195 | ||
| 196 | 196 | // Associate data with the current deserialization operation. | |
| 197 | - | func (x *ContentDeserializer) SetTaskData(DataVar uintptr, NotifyVar glib.DestroyNotify) { | |
| 197 | + | func (x *ContentDeserializer) SetTaskData(DataVar uintptr, NotifyVar *glib.DestroyNotify) { | |
| 198 | 198 | ||
| 199 | - | xContentDeserializerSetTaskData(x.GoPointer(), DataVar, purego.NewCallback(NotifyVar)) | |
| 199 | + | xContentDeserializerSetTaskData(x.GoPointer(), DataVar, glib.NewCallback(NotifyVar)) | |
| 200 | 200 | ||
| 201 | 201 | } | |
| 202 | 202 | ||
M v4/gdk/gdkcontentprovider.go +13 -5
| @@ -192,9 +192,9 @@ var xContentProviderWriteMimeTypeAsync func(uintptr, string, uintptr, int, uintp | |||
| 192 | 192 | // not supported, `G_IO_ERROR_NOT_SUPPORTED` will be reported. | |
| 193 | 193 | // | |
| 194 | 194 | // The given @stream will not be closed. | |
| 195 | - | func (x *ContentProvider) WriteMimeTypeAsync(MimeTypeVar string, StreamVar *gio.OutputStream, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 195 | + | func (x *ContentProvider) WriteMimeTypeAsync(MimeTypeVar string, StreamVar *gio.OutputStream, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 196 | 196 | ||
| 197 | - | xContentProviderWriteMimeTypeAsync(x.GoPointer(), MimeTypeVar, StreamVar.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 197 | + | xContentProviderWriteMimeTypeAsync(x.GoPointer(), MimeTypeVar, StreamVar.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 198 | 198 | ||
| 199 | 199 | } | |
| 200 | 200 | ||
| @@ -223,15 +223,23 @@ func (c *ContentProvider) SetGoPointer(ptr uintptr) { | |||
| 223 | 223 | } | |
| 224 | 224 | ||
| 225 | 225 | // Emitted whenever the content provided by this provider has changed. | |
| 226 | - | func (x *ContentProvider) ConnectContentChanged(cb func(ContentProvider)) uint32 { | |
| 226 | + | func (x *ContentProvider) ConnectContentChanged(cb *func(ContentProvider)) uint32 { | |
| 227 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 228 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 229 | + | return gobject.SignalConnect(x.GoPointer(), "content-changed", cbRefPtr) | |
| 230 | + | } | |
| 231 | + | ||
| 227 | 232 | fcb := func(clsPtr uintptr) { | |
| 228 | 233 | fa := ContentProvider{} | |
| 229 | 234 | fa.Ptr = clsPtr | |
| 235 | + | cbFn := *cb | |
| 230 | 236 | ||
| 231 | - | cb(fa) | |
| 237 | + | cbFn(fa) | |
| 232 | 238 | ||
| 233 | 239 | } | |
| 234 | - | return gobject.SignalConnect(x.GoPointer(), "content-changed", purego.NewCallback(fcb)) | |
| 240 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 241 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 242 | + | return gobject.SignalConnect(x.GoPointer(), "content-changed", cbRefPtr) | |
| 235 | 243 | } | |
| 236 | 244 | ||
| 237 | 245 | func init() { | |
M v4/gdk/gdkcontentserializer.go +6 -6
| @@ -19,9 +19,9 @@ type ContentSerializeFunc func(uintptr) | |||
| 19 | 19 | var xContentRegisterSerializer func([]interface{}, string, uintptr, uintptr, uintptr) | |
| 20 | 20 | ||
| 21 | 21 | // Registers a function to serialize objects of a given type. | |
| 22 | - | func ContentRegisterSerializer(TypeVar []interface{}, MimeTypeVar string, SerializeVar ContentSerializeFunc, DataVar uintptr, NotifyVar glib.DestroyNotify) { | |
| 22 | + | func ContentRegisterSerializer(TypeVar []interface{}, MimeTypeVar string, SerializeVar *ContentSerializeFunc, DataVar uintptr, NotifyVar *glib.DestroyNotify) { | |
| 23 | 23 | ||
| 24 | - | xContentRegisterSerializer(TypeVar, MimeTypeVar, purego.NewCallback(SerializeVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 24 | + | xContentRegisterSerializer(TypeVar, MimeTypeVar, glib.NewCallback(SerializeVar), DataVar, glib.NewCallback(NotifyVar)) | |
| 25 | 25 | ||
| 26 | 26 | } | |
| 27 | 27 | ||
| @@ -34,9 +34,9 @@ var xContentSerializeAsync func(uintptr, string, *gobject.Value, int, uintptr, u | |||
| 34 | 34 | // | |
| 35 | 35 | // When the operation is finished, @callback will be called. You must then | |
| 36 | 36 | // call [func@Gdk.content_serialize_finish] to get the result of the operation. | |
| 37 | - | func ContentSerializeAsync(StreamVar *gio.OutputStream, MimeTypeVar string, ValueVar *gobject.Value, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 37 | + | func ContentSerializeAsync(StreamVar *gio.OutputStream, MimeTypeVar string, ValueVar *gobject.Value, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 38 | 38 | ||
| 39 | - | xContentSerializeAsync(StreamVar.GoPointer(), MimeTypeVar, ValueVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 39 | + | xContentSerializeAsync(StreamVar.GoPointer(), MimeTypeVar, ValueVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 40 | 40 | ||
| 41 | 41 | } | |
| 42 | 42 | ||
| @@ -195,9 +195,9 @@ func (x *ContentSerializer) ReturnSuccess() { | |||
| 195 | 195 | var xContentSerializerSetTaskData func(uintptr, uintptr, uintptr) | |
| 196 | 196 | ||
| 197 | 197 | // Associate data with the current serialization operation. | |
| 198 | - | func (x *ContentSerializer) SetTaskData(DataVar uintptr, NotifyVar glib.DestroyNotify) { | |
| 198 | + | func (x *ContentSerializer) SetTaskData(DataVar uintptr, NotifyVar *glib.DestroyNotify) { | |
| 199 | 199 | ||
| 200 | - | xContentSerializerSetTaskData(x.GoPointer(), DataVar, purego.NewCallback(NotifyVar)) | |
| 200 | + | xContentSerializerSetTaskData(x.GoPointer(), DataVar, glib.NewCallback(NotifyVar)) | |
| 201 | 201 | ||
| 202 | 202 | } | |
| 203 | 203 | ||
M v4/gdk/gdkdevice.go +23 -6
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/pango" | |
| 11 | 12 | ) | |
| @@ -327,27 +328,43 @@ func (c *Device) SetGoPointer(ptr uintptr) { | |||
| 327 | 328 | // example, user switches from the USB mouse to a tablet); in | |
| 328 | 329 | // that case the logical device will change to reflect the axes | |
| 329 | 330 | // and keys on the new physical device. | |
| 330 | - | func (x *Device) ConnectChanged(cb func(Device)) uint32 { | |
| 331 | + | func (x *Device) ConnectChanged(cb *func(Device)) uint32 { | |
| 332 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 333 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 334 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 335 | + | } | |
| 336 | + | ||
| 331 | 337 | fcb := func(clsPtr uintptr) { | |
| 332 | 338 | fa := Device{} | |
| 333 | 339 | fa.Ptr = clsPtr | |
| 340 | + | cbFn := *cb | |
| 334 | 341 | ||
| 335 | - | cb(fa) | |
| 342 | + | cbFn(fa) | |
| 336 | 343 | ||
| 337 | 344 | } | |
| 338 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 345 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 346 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 347 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 339 | 348 | } | |
| 340 | 349 | ||
| 341 | 350 | // Emitted on pen/eraser devices whenever tools enter or leave proximity. | |
| 342 | - | func (x *Device) ConnectToolChanged(cb func(Device, uintptr)) uint32 { | |
| 351 | + | func (x *Device) ConnectToolChanged(cb *func(Device, uintptr)) uint32 { | |
| 352 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 353 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 354 | + | return gobject.SignalConnect(x.GoPointer(), "tool-changed", cbRefPtr) | |
| 355 | + | } | |
| 356 | + | ||
| 343 | 357 | fcb := func(clsPtr uintptr, ToolVarp uintptr) { | |
| 344 | 358 | fa := Device{} | |
| 345 | 359 | fa.Ptr = clsPtr | |
| 360 | + | cbFn := *cb | |
| 346 | 361 | ||
| 347 | - | cb(fa, ToolVarp) | |
| 362 | + | cbFn(fa, ToolVarp) | |
| 348 | 363 | ||
| 349 | 364 | } | |
| 350 | - | return gobject.SignalConnect(x.GoPointer(), "tool-changed", purego.NewCallback(fcb)) | |
| 365 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 366 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 367 | + | return gobject.SignalConnect(x.GoPointer(), "tool-changed", cbRefPtr) | |
| 351 | 368 | } | |
| 352 | 369 | ||
| 353 | 370 | func init() { | |
M v4/gdk/gdkdisplay.go +57 -15
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -474,63 +476,103 @@ func (c *Display) SetGoPointer(ptr uintptr) { | |||
| 474 | 476 | } | |
| 475 | 477 | ||
| 476 | 478 | // Emitted when the connection to the windowing system for @display is closed. | |
| 477 | - | func (x *Display) ConnectClosed(cb func(Display, bool)) uint32 { | |
| 479 | + | func (x *Display) ConnectClosed(cb *func(Display, bool)) uint32 { | |
| 480 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 481 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 482 | + | return gobject.SignalConnect(x.GoPointer(), "closed", cbRefPtr) | |
| 483 | + | } | |
| 484 | + | ||
| 478 | 485 | fcb := func(clsPtr uintptr, IsErrorVarp bool) { | |
| 479 | 486 | fa := Display{} | |
| 480 | 487 | fa.Ptr = clsPtr | |
| 488 | + | cbFn := *cb | |
| 481 | 489 | ||
| 482 | - | cb(fa, IsErrorVarp) | |
| 490 | + | cbFn(fa, IsErrorVarp) | |
| 483 | 491 | ||
| 484 | 492 | } | |
| 485 | - | return gobject.SignalConnect(x.GoPointer(), "closed", purego.NewCallback(fcb)) | |
| 493 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 494 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 495 | + | return gobject.SignalConnect(x.GoPointer(), "closed", cbRefPtr) | |
| 486 | 496 | } | |
| 487 | 497 | ||
| 488 | 498 | // Emitted when the connection to the windowing system for @display is opened. | |
| 489 | - | func (x *Display) ConnectOpened(cb func(Display)) uint32 { | |
| 499 | + | func (x *Display) ConnectOpened(cb *func(Display)) uint32 { | |
| 500 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 501 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 502 | + | return gobject.SignalConnect(x.GoPointer(), "opened", cbRefPtr) | |
| 503 | + | } | |
| 504 | + | ||
| 490 | 505 | fcb := func(clsPtr uintptr) { | |
| 491 | 506 | fa := Display{} | |
| 492 | 507 | fa.Ptr = clsPtr | |
| 508 | + | cbFn := *cb | |
| 493 | 509 | ||
| 494 | - | cb(fa) | |
| 510 | + | cbFn(fa) | |
| 495 | 511 | ||
| 496 | 512 | } | |
| 497 | - | return gobject.SignalConnect(x.GoPointer(), "opened", purego.NewCallback(fcb)) | |
| 513 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 514 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 515 | + | return gobject.SignalConnect(x.GoPointer(), "opened", cbRefPtr) | |
| 498 | 516 | } | |
| 499 | 517 | ||
| 500 | 518 | // Emitted whenever a new seat is made known to the windowing system. | |
| 501 | - | func (x *Display) ConnectSeatAdded(cb func(Display, uintptr)) uint32 { | |
| 519 | + | func (x *Display) ConnectSeatAdded(cb *func(Display, uintptr)) uint32 { | |
| 520 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 521 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 522 | + | return gobject.SignalConnect(x.GoPointer(), "seat-added", cbRefPtr) | |
| 523 | + | } | |
| 524 | + | ||
| 502 | 525 | fcb := func(clsPtr uintptr, SeatVarp uintptr) { | |
| 503 | 526 | fa := Display{} | |
| 504 | 527 | fa.Ptr = clsPtr | |
| 528 | + | cbFn := *cb | |
| 505 | 529 | ||
| 506 | - | cb(fa, SeatVarp) | |
| 530 | + | cbFn(fa, SeatVarp) | |
| 507 | 531 | ||
| 508 | 532 | } | |
| 509 | - | return gobject.SignalConnect(x.GoPointer(), "seat-added", purego.NewCallback(fcb)) | |
| 533 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 534 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 535 | + | return gobject.SignalConnect(x.GoPointer(), "seat-added", cbRefPtr) | |
| 510 | 536 | } | |
| 511 | 537 | ||
| 512 | 538 | // Emitted whenever a seat is removed by the windowing system. | |
| 513 | - | func (x *Display) ConnectSeatRemoved(cb func(Display, uintptr)) uint32 { | |
| 539 | + | func (x *Display) ConnectSeatRemoved(cb *func(Display, uintptr)) uint32 { | |
| 540 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 541 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 542 | + | return gobject.SignalConnect(x.GoPointer(), "seat-removed", cbRefPtr) | |
| 543 | + | } | |
| 544 | + | ||
| 514 | 545 | fcb := func(clsPtr uintptr, SeatVarp uintptr) { | |
| 515 | 546 | fa := Display{} | |
| 516 | 547 | fa.Ptr = clsPtr | |
| 548 | + | cbFn := *cb | |
| 517 | 549 | ||
| 518 | - | cb(fa, SeatVarp) | |
| 550 | + | cbFn(fa, SeatVarp) | |
| 519 | 551 | ||
| 520 | 552 | } | |
| 521 | - | return gobject.SignalConnect(x.GoPointer(), "seat-removed", purego.NewCallback(fcb)) | |
| 553 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 554 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 555 | + | return gobject.SignalConnect(x.GoPointer(), "seat-removed", cbRefPtr) | |
| 522 | 556 | } | |
| 523 | 557 | ||
| 524 | 558 | // Emitted whenever a setting changes its value. | |
| 525 | - | func (x *Display) ConnectSettingChanged(cb func(Display, string)) uint32 { | |
| 559 | + | func (x *Display) ConnectSettingChanged(cb *func(Display, string)) uint32 { | |
| 560 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 561 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 562 | + | return gobject.SignalConnect(x.GoPointer(), "setting-changed", cbRefPtr) | |
| 563 | + | } | |
| 564 | + | ||
| 526 | 565 | fcb := func(clsPtr uintptr, SettingVarp string) { | |
| 527 | 566 | fa := Display{} | |
| 528 | 567 | fa.Ptr = clsPtr | |
| 568 | + | cbFn := *cb | |
| 529 | 569 | ||
| 530 | - | cb(fa, SettingVarp) | |
| 570 | + | cbFn(fa, SettingVarp) | |
| 531 | 571 | ||
| 532 | 572 | } | |
| 533 | - | return gobject.SignalConnect(x.GoPointer(), "setting-changed", purego.NewCallback(fcb)) | |
| 573 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 574 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 575 | + | return gobject.SignalConnect(x.GoPointer(), "setting-changed", cbRefPtr) | |
| 534 | 576 | } | |
| 535 | 577 | ||
| 536 | 578 | var xDisplayGetDefault func() uintptr | |
M v4/gdk/gdkdisplaymanager.go +13 -3
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -168,15 +170,23 @@ func (c *DisplayManager) SetGoPointer(ptr uintptr) { | |||
| 168 | 170 | } | |
| 169 | 171 | ||
| 170 | 172 | // Emitted when a display is opened. | |
| 171 | - | func (x *DisplayManager) ConnectDisplayOpened(cb func(DisplayManager, uintptr)) uint32 { | |
| 173 | + | func (x *DisplayManager) ConnectDisplayOpened(cb *func(DisplayManager, uintptr)) uint32 { | |
| 174 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 175 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 176 | + | return gobject.SignalConnect(x.GoPointer(), "display-opened", cbRefPtr) | |
| 177 | + | } | |
| 178 | + | ||
| 172 | 179 | fcb := func(clsPtr uintptr, DisplayVarp uintptr) { | |
| 173 | 180 | fa := DisplayManager{} | |
| 174 | 181 | fa.Ptr = clsPtr | |
| 182 | + | cbFn := *cb | |
| 175 | 183 | ||
| 176 | - | cb(fa, DisplayVarp) | |
| 184 | + | cbFn(fa, DisplayVarp) | |
| 177 | 185 | ||
| 178 | 186 | } | |
| 179 | - | return gobject.SignalConnect(x.GoPointer(), "display-opened", purego.NewCallback(fcb)) | |
| 187 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 188 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 189 | + | return gobject.SignalConnect(x.GoPointer(), "display-opened", cbRefPtr) | |
| 180 | 190 | } | |
| 181 | 191 | ||
| 182 | 192 | var xDisplayManagerGet func() uintptr | |
M v4/gdk/gdkdrag.go +36 -9
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -211,41 +214,65 @@ func (c *Drag) SetGoPointer(ptr uintptr) { | |||
| 211 | 214 | } | |
| 212 | 215 | ||
| 213 | 216 | // Emitted when the drag operation is cancelled. | |
| 214 | - | func (x *Drag) ConnectCancel(cb func(Drag, DragCancelReason)) uint32 { | |
| 217 | + | func (x *Drag) ConnectCancel(cb *func(Drag, DragCancelReason)) uint32 { | |
| 218 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 219 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 220 | + | return gobject.SignalConnect(x.GoPointer(), "cancel", cbRefPtr) | |
| 221 | + | } | |
| 222 | + | ||
| 215 | 223 | fcb := func(clsPtr uintptr, ReasonVarp DragCancelReason) { | |
| 216 | 224 | fa := Drag{} | |
| 217 | 225 | fa.Ptr = clsPtr | |
| 226 | + | cbFn := *cb | |
| 218 | 227 | ||
| 219 | - | cb(fa, ReasonVarp) | |
| 228 | + | cbFn(fa, ReasonVarp) | |
| 220 | 229 | ||
| 221 | 230 | } | |
| 222 | - | return gobject.SignalConnect(x.GoPointer(), "cancel", purego.NewCallback(fcb)) | |
| 231 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 232 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 233 | + | return gobject.SignalConnect(x.GoPointer(), "cancel", cbRefPtr) | |
| 223 | 234 | } | |
| 224 | 235 | ||
| 225 | 236 | // Emitted when the destination side has finished reading all data. | |
| 226 | 237 | // | |
| 227 | 238 | // The drag object can now free all miscellaneous data. | |
| 228 | - | func (x *Drag) ConnectDndFinished(cb func(Drag)) uint32 { | |
| 239 | + | func (x *Drag) ConnectDndFinished(cb *func(Drag)) uint32 { | |
| 240 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 241 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 242 | + | return gobject.SignalConnect(x.GoPointer(), "dnd-finished", cbRefPtr) | |
| 243 | + | } | |
| 244 | + | ||
| 229 | 245 | fcb := func(clsPtr uintptr) { | |
| 230 | 246 | fa := Drag{} | |
| 231 | 247 | fa.Ptr = clsPtr | |
| 248 | + | cbFn := *cb | |
| 232 | 249 | ||
| 233 | - | cb(fa) | |
| 250 | + | cbFn(fa) | |
| 234 | 251 | ||
| 235 | 252 | } | |
| 236 | - | return gobject.SignalConnect(x.GoPointer(), "dnd-finished", purego.NewCallback(fcb)) | |
| 253 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 254 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 255 | + | return gobject.SignalConnect(x.GoPointer(), "dnd-finished", cbRefPtr) | |
| 237 | 256 | } | |
| 238 | 257 | ||
| 239 | 258 | // Emitted when the drop operation is performed on an accepting client. | |
| 240 | - | func (x *Drag) ConnectDropPerformed(cb func(Drag)) uint32 { | |
| 259 | + | func (x *Drag) ConnectDropPerformed(cb *func(Drag)) uint32 { | |
| 260 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 261 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 262 | + | return gobject.SignalConnect(x.GoPointer(), "drop-performed", cbRefPtr) | |
| 263 | + | } | |
| 264 | + | ||
| 241 | 265 | fcb := func(clsPtr uintptr) { | |
| 242 | 266 | fa := Drag{} | |
| 243 | 267 | fa.Ptr = clsPtr | |
| 268 | + | cbFn := *cb | |
| 244 | 269 | ||
| 245 | - | cb(fa) | |
| 270 | + | cbFn(fa) | |
| 246 | 271 | ||
| 247 | 272 | } | |
| 248 | - | return gobject.SignalConnect(x.GoPointer(), "drop-performed", purego.NewCallback(fcb)) | |
| 273 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 274 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 275 | + | return gobject.SignalConnect(x.GoPointer(), "drop-performed", cbRefPtr) | |
| 249 | 276 | } | |
| 250 | 277 | ||
| 251 | 278 | var xDragBegin func(uintptr, uintptr, uintptr, DragAction, float64, float64) uintptr | |
M v4/gdk/gdkdrop.go +4 -4
| @@ -152,9 +152,9 @@ var xDropReadAsync func(uintptr, []string, int, uintptr, uintptr, uintptr) | |||
| 152 | 152 | ||
| 153 | 153 | // Asynchronously read the dropped data from a `GdkDrop` | |
| 154 | 154 | // in a format that complies with one of the mime types. | |
| 155 | - | func (x *Drop) ReadAsync(MimeTypesVar []string, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 155 | + | func (x *Drop) ReadAsync(MimeTypesVar []string, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 156 | 156 | ||
| 157 | - | xDropReadAsync(x.GoPointer(), MimeTypesVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 157 | + | xDropReadAsync(x.GoPointer(), MimeTypesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 158 | 158 | ||
| 159 | 159 | } | |
| 160 | 160 | ||
| @@ -198,9 +198,9 @@ var xDropReadValueAsync func(uintptr, []interface{}, int, uintptr, uintptr, uint | |||
| 198 | 198 | // For local drag-and-drop operations that are available in the given | |
| 199 | 199 | // `GType`, the value will be copied directly. Otherwise, GDK will | |
| 200 | 200 | // try to use [func@Gdk.content_deserialize_async] to convert the data. | |
| 201 | - | func (x *Drop) ReadValueAsync(TypeVar []interface{}, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 201 | + | func (x *Drop) ReadValueAsync(TypeVar []interface{}, IoPriorityVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 202 | 202 | ||
| 203 | - | xDropReadValueAsync(x.GoPointer(), TypeVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 203 | + | xDropReadValueAsync(x.GoPointer(), TypeVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 204 | 204 | ||
| 205 | 205 | } | |
| 206 | 206 | ||
M v4/gdk/gdkframeclock.go +78 -21
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -236,44 +237,68 @@ func (c *FrameClock) SetGoPointer(ptr uintptr) { | |||
| 236 | 237 | // This signal ends processing of the frame. | |
| 237 | 238 | // | |
| 238 | 239 | // Applications should generally not handle this signal. | |
| 239 | - | func (x *FrameClock) ConnectAfterPaint(cb func(FrameClock)) uint32 { | |
| 240 | + | func (x *FrameClock) ConnectAfterPaint(cb *func(FrameClock)) uint32 { | |
| 241 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 242 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 243 | + | return gobject.SignalConnect(x.GoPointer(), "after-paint", cbRefPtr) | |
| 244 | + | } | |
| 245 | + | ||
| 240 | 246 | fcb := func(clsPtr uintptr) { | |
| 241 | 247 | fa := FrameClock{} | |
| 242 | 248 | fa.Ptr = clsPtr | |
| 249 | + | cbFn := *cb | |
| 243 | 250 | ||
| 244 | - | cb(fa) | |
| 251 | + | cbFn(fa) | |
| 245 | 252 | ||
| 246 | 253 | } | |
| 247 | - | return gobject.SignalConnect(x.GoPointer(), "after-paint", purego.NewCallback(fcb)) | |
| 254 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 255 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 256 | + | return gobject.SignalConnect(x.GoPointer(), "after-paint", cbRefPtr) | |
| 248 | 257 | } | |
| 249 | 258 | ||
| 250 | 259 | // Begins processing of the frame. | |
| 251 | 260 | // | |
| 252 | 261 | // Applications should generally not handle this signal. | |
| 253 | - | func (x *FrameClock) ConnectBeforePaint(cb func(FrameClock)) uint32 { | |
| 262 | + | func (x *FrameClock) ConnectBeforePaint(cb *func(FrameClock)) uint32 { | |
| 263 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 264 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 265 | + | return gobject.SignalConnect(x.GoPointer(), "before-paint", cbRefPtr) | |
| 266 | + | } | |
| 267 | + | ||
| 254 | 268 | fcb := func(clsPtr uintptr) { | |
| 255 | 269 | fa := FrameClock{} | |
| 256 | 270 | fa.Ptr = clsPtr | |
| 271 | + | cbFn := *cb | |
| 257 | 272 | ||
| 258 | - | cb(fa) | |
| 273 | + | cbFn(fa) | |
| 259 | 274 | ||
| 260 | 275 | } | |
| 261 | - | return gobject.SignalConnect(x.GoPointer(), "before-paint", purego.NewCallback(fcb)) | |
| 276 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 277 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 278 | + | return gobject.SignalConnect(x.GoPointer(), "before-paint", cbRefPtr) | |
| 262 | 279 | } | |
| 263 | 280 | ||
| 264 | 281 | // Used to flush pending motion events that are being batched up and | |
| 265 | 282 | // compressed together. | |
| 266 | 283 | // | |
| 267 | 284 | // Applications should not handle this signal. | |
| 268 | - | func (x *FrameClock) ConnectFlushEvents(cb func(FrameClock)) uint32 { | |
| 285 | + | func (x *FrameClock) ConnectFlushEvents(cb *func(FrameClock)) uint32 { | |
| 286 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 287 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 288 | + | return gobject.SignalConnect(x.GoPointer(), "flush-events", cbRefPtr) | |
| 289 | + | } | |
| 290 | + | ||
| 269 | 291 | fcb := func(clsPtr uintptr) { | |
| 270 | 292 | fa := FrameClock{} | |
| 271 | 293 | fa.Ptr = clsPtr | |
| 294 | + | cbFn := *cb | |
| 272 | 295 | ||
| 273 | - | cb(fa) | |
| 296 | + | cbFn(fa) | |
| 274 | 297 | ||
| 275 | 298 | } | |
| 276 | - | return gobject.SignalConnect(x.GoPointer(), "flush-events", purego.NewCallback(fcb)) | |
| 299 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 300 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 301 | + | return gobject.SignalConnect(x.GoPointer(), "flush-events", cbRefPtr) | |
| 277 | 302 | } | |
| 278 | 303 | ||
| 279 | 304 | // Emitted as the second step of toolkit and application processing | |
| @@ -281,15 +306,23 @@ func (x *FrameClock) ConnectFlushEvents(cb func(FrameClock)) uint32 { | |||
| 281 | 306 | // | |
| 282 | 307 | // Any work to update sizes and positions of application elements | |
| 283 | 308 | // should be performed. GTK normally handles this internally. | |
| 284 | - | func (x *FrameClock) ConnectLayout(cb func(FrameClock)) uint32 { | |
| 309 | + | func (x *FrameClock) ConnectLayout(cb *func(FrameClock)) uint32 { | |
| 310 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 311 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 312 | + | return gobject.SignalConnect(x.GoPointer(), "layout", cbRefPtr) | |
| 313 | + | } | |
| 314 | + | ||
| 285 | 315 | fcb := func(clsPtr uintptr) { | |
| 286 | 316 | fa := FrameClock{} | |
| 287 | 317 | fa.Ptr = clsPtr | |
| 318 | + | cbFn := *cb | |
| 288 | 319 | ||
| 289 | - | cb(fa) | |
| 320 | + | cbFn(fa) | |
| 290 | 321 | ||
| 291 | 322 | } | |
| 292 | - | return gobject.SignalConnect(x.GoPointer(), "layout", purego.NewCallback(fcb)) | |
| 323 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 324 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 325 | + | return gobject.SignalConnect(x.GoPointer(), "layout", cbRefPtr) | |
| 293 | 326 | } | |
| 294 | 327 | ||
| 295 | 328 | // Emitted as the third step of toolkit and application processing | |
| @@ -298,30 +331,46 @@ func (x *FrameClock) ConnectLayout(cb func(FrameClock)) uint32 { | |||
| 298 | 331 | // The frame is repainted. GDK normally handles this internally and | |
| 299 | 332 | // emits [signal@Gdk.Surface::render] signals which are turned into | |
| 300 | 333 | // [signal@Gtk.Widget::snapshot] signals by GTK. | |
| 301 | - | func (x *FrameClock) ConnectPaint(cb func(FrameClock)) uint32 { | |
| 334 | + | func (x *FrameClock) ConnectPaint(cb *func(FrameClock)) uint32 { | |
| 335 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 336 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 337 | + | return gobject.SignalConnect(x.GoPointer(), "paint", cbRefPtr) | |
| 338 | + | } | |
| 339 | + | ||
| 302 | 340 | fcb := func(clsPtr uintptr) { | |
| 303 | 341 | fa := FrameClock{} | |
| 304 | 342 | fa.Ptr = clsPtr | |
| 343 | + | cbFn := *cb | |
| 305 | 344 | ||
| 306 | - | cb(fa) | |
| 345 | + | cbFn(fa) | |
| 307 | 346 | ||
| 308 | 347 | } | |
| 309 | - | return gobject.SignalConnect(x.GoPointer(), "paint", purego.NewCallback(fcb)) | |
| 348 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 349 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 350 | + | return gobject.SignalConnect(x.GoPointer(), "paint", cbRefPtr) | |
| 310 | 351 | } | |
| 311 | 352 | ||
| 312 | 353 | // Emitted after processing of the frame is finished. | |
| 313 | 354 | // | |
| 314 | 355 | // This signal is handled internally by GTK to resume normal | |
| 315 | 356 | // event processing. Applications should not handle this signal. | |
| 316 | - | func (x *FrameClock) ConnectResumeEvents(cb func(FrameClock)) uint32 { | |
| 357 | + | func (x *FrameClock) ConnectResumeEvents(cb *func(FrameClock)) uint32 { | |
| 358 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 359 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 360 | + | return gobject.SignalConnect(x.GoPointer(), "resume-events", cbRefPtr) | |
| 361 | + | } | |
| 362 | + | ||
| 317 | 363 | fcb := func(clsPtr uintptr) { | |
| 318 | 364 | fa := FrameClock{} | |
| 319 | 365 | fa.Ptr = clsPtr | |
| 366 | + | cbFn := *cb | |
| 320 | 367 | ||
| 321 | - | cb(fa) | |
| 368 | + | cbFn(fa) | |
| 322 | 369 | ||
| 323 | 370 | } | |
| 324 | - | return gobject.SignalConnect(x.GoPointer(), "resume-events", purego.NewCallback(fcb)) | |
| 371 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 372 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 373 | + | return gobject.SignalConnect(x.GoPointer(), "resume-events", cbRefPtr) | |
| 325 | 374 | } | |
| 326 | 375 | ||
| 327 | 376 | // Emitted as the first step of toolkit and application processing | |
| @@ -330,15 +379,23 @@ func (x *FrameClock) ConnectResumeEvents(cb func(FrameClock)) uint32 { | |||
| 330 | 379 | // Animations should be updated using [method@Gdk.FrameClock.get_frame_time]. | |
| 331 | 380 | // Applications can connect directly to this signal, or use | |
| 332 | 381 | // [method@Gtk.Widget.add_tick_callback] as a more convenient interface. | |
| 333 | - | func (x *FrameClock) ConnectUpdate(cb func(FrameClock)) uint32 { | |
| 382 | + | func (x *FrameClock) ConnectUpdate(cb *func(FrameClock)) uint32 { | |
| 383 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 384 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 385 | + | return gobject.SignalConnect(x.GoPointer(), "update", cbRefPtr) | |
| 386 | + | } | |
| 387 | + | ||
| 334 | 388 | fcb := func(clsPtr uintptr) { | |
| 335 | 389 | fa := FrameClock{} | |
| 336 | 390 | fa.Ptr = clsPtr | |
| 391 | + | cbFn := *cb | |
| 337 | 392 | ||
| 338 | - | cb(fa) | |
| 393 | + | cbFn(fa) | |
| 339 | 394 | ||
| 340 | 395 | } | |
| 341 | - | return gobject.SignalConnect(x.GoPointer(), "update", purego.NewCallback(fcb)) | |
| 396 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 397 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 398 | + | return gobject.SignalConnect(x.GoPointer(), "update", cbRefPtr) | |
| 342 | 399 | } | |
| 343 | 400 | ||
| 344 | 401 | func init() { | |
M v4/gdk/gdkgltexture.go +4 -4
| @@ -35,10 +35,10 @@ var xNewGLTexture func(uintptr, uint, int, int, uintptr, uintptr) uintptr | |||
| 35 | 35 | // Note that the GL texture must not be modified until @destroy is called, | |
| 36 | 36 | // which will happen when the GdkTexture object is finalized, or due to | |
| 37 | 37 | // an explicit call of [method@Gdk.GLTexture.release]. | |
| 38 | - | func NewGLTexture(ContextVar *GLContext, IdVar uint, WidthVar int, HeightVar int, DestroyVar glib.DestroyNotify, DataVar uintptr) *GLTexture { | |
| 38 | + | func NewGLTexture(ContextVar *GLContext, IdVar uint, WidthVar int, HeightVar int, DestroyVar *glib.DestroyNotify, DataVar uintptr) *GLTexture { | |
| 39 | 39 | var cls *GLTexture | |
| 40 | 40 | ||
| 41 | - | cret := xNewGLTexture(ContextVar.GoPointer(), IdVar, WidthVar, HeightVar, purego.NewCallback(DestroyVar), DataVar) | |
| 41 | + | cret := xNewGLTexture(ContextVar.GoPointer(), IdVar, WidthVar, HeightVar, glib.NewCallback(DestroyVar), DataVar) | |
| 42 | 42 | ||
| 43 | 43 | if cret == 0 { | |
| 44 | 44 | return nil | |
| @@ -276,9 +276,9 @@ func (x *GLTexture) Load(SizeVar int, TypeVar string, CancellableVar *gio.Cancel | |||
| 276 | 276 | // Loads an icon asynchronously. To finish this function, see | |
| 277 | 277 | // g_loadable_icon_load_finish(). For the synchronous, blocking | |
| 278 | 278 | // version of this function, see g_loadable_icon_load(). | |
| 279 | - | func (x *GLTexture) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 279 | + | func (x *GLTexture) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 280 | 280 | ||
| 281 | - | gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 281 | + | gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 282 | 282 | ||
| 283 | 283 | } | |
| 284 | 284 | ||
M v4/gdk/gdkmemorytexture.go +2 -2
| @@ -262,9 +262,9 @@ func (x *MemoryTexture) Load(SizeVar int, TypeVar string, CancellableVar *gio.Ca | |||
| 262 | 262 | // Loads an icon asynchronously. To finish this function, see | |
| 263 | 263 | // g_loadable_icon_load_finish(). For the synchronous, blocking | |
| 264 | 264 | // version of this function, see g_loadable_icon_load(). | |
| 265 | - | func (x *MemoryTexture) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 265 | + | func (x *MemoryTexture) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 266 | 266 | ||
| 267 | - | gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 267 | + | gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 268 | 268 | ||
| 269 | 269 | } | |
| 270 | 270 | ||
M v4/gdk/gdkmonitor.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -195,15 +196,23 @@ func (c *Monitor) SetGoPointer(ptr uintptr) { | |||
| 195 | 196 | } | |
| 196 | 197 | ||
| 197 | 198 | // Emitted when the output represented by @monitor gets disconnected. | |
| 198 | - | func (x *Monitor) ConnectInvalidate(cb func(Monitor)) uint32 { | |
| 199 | + | func (x *Monitor) ConnectInvalidate(cb *func(Monitor)) uint32 { | |
| 200 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 201 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 202 | + | return gobject.SignalConnect(x.GoPointer(), "invalidate", cbRefPtr) | |
| 203 | + | } | |
| 204 | + | ||
| 199 | 205 | fcb := func(clsPtr uintptr) { | |
| 200 | 206 | fa := Monitor{} | |
| 201 | 207 | fa.Ptr = clsPtr | |
| 208 | + | cbFn := *cb | |
| 202 | 209 | ||
| 203 | - | cb(fa) | |
| 210 | + | cbFn(fa) | |
| 204 | 211 | ||
| 205 | 212 | } | |
| 206 | - | return gobject.SignalConnect(x.GoPointer(), "invalidate", purego.NewCallback(fcb)) | |
| 213 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 214 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 215 | + | return gobject.SignalConnect(x.GoPointer(), "invalidate", cbRefPtr) | |
| 207 | 216 | } | |
| 208 | 217 | ||
| 209 | 218 | func init() { | |
M v4/gdk/gdkseat.go +46 -12
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -130,27 +132,43 @@ func (c *Seat) SetGoPointer(ptr uintptr) { | |||
| 130 | 132 | } | |
| 131 | 133 | ||
| 132 | 134 | // Emitted when a new input device is related to this seat. | |
| 133 | - | func (x *Seat) ConnectDeviceAdded(cb func(Seat, uintptr)) uint32 { | |
| 135 | + | func (x *Seat) ConnectDeviceAdded(cb *func(Seat, uintptr)) uint32 { | |
| 136 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 137 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 138 | + | return gobject.SignalConnect(x.GoPointer(), "device-added", cbRefPtr) | |
| 139 | + | } | |
| 140 | + | ||
| 134 | 141 | fcb := func(clsPtr uintptr, DeviceVarp uintptr) { | |
| 135 | 142 | fa := Seat{} | |
| 136 | 143 | fa.Ptr = clsPtr | |
| 144 | + | cbFn := *cb | |
| 137 | 145 | ||
| 138 | - | cb(fa, DeviceVarp) | |
| 146 | + | cbFn(fa, DeviceVarp) | |
| 139 | 147 | ||
| 140 | 148 | } | |
| 141 | - | return gobject.SignalConnect(x.GoPointer(), "device-added", purego.NewCallback(fcb)) | |
| 149 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 150 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 151 | + | return gobject.SignalConnect(x.GoPointer(), "device-added", cbRefPtr) | |
| 142 | 152 | } | |
| 143 | 153 | ||
| 144 | 154 | // Emitted when an input device is removed (e.g. unplugged). | |
| 145 | - | func (x *Seat) ConnectDeviceRemoved(cb func(Seat, uintptr)) uint32 { | |
| 155 | + | func (x *Seat) ConnectDeviceRemoved(cb *func(Seat, uintptr)) uint32 { | |
| 156 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 157 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 158 | + | return gobject.SignalConnect(x.GoPointer(), "device-removed", cbRefPtr) | |
| 159 | + | } | |
| 160 | + | ||
| 146 | 161 | fcb := func(clsPtr uintptr, DeviceVarp uintptr) { | |
| 147 | 162 | fa := Seat{} | |
| 148 | 163 | fa.Ptr = clsPtr | |
| 164 | + | cbFn := *cb | |
| 149 | 165 | ||
| 150 | - | cb(fa, DeviceVarp) | |
| 166 | + | cbFn(fa, DeviceVarp) | |
| 151 | 167 | ||
| 152 | 168 | } | |
| 153 | - | return gobject.SignalConnect(x.GoPointer(), "device-removed", purego.NewCallback(fcb)) | |
| 169 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 170 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 171 | + | return gobject.SignalConnect(x.GoPointer(), "device-removed", cbRefPtr) | |
| 154 | 172 | } | |
| 155 | 173 | ||
| 156 | 174 | // Emitted whenever a new tool is made known to the seat. | |
| @@ -160,27 +178,43 @@ func (x *Seat) ConnectDeviceRemoved(cb func(Seat, uintptr)) uint32 { | |||
| 160 | 178 | // [signal@Gdk.Device::tool-changed] signal accordingly. | |
| 161 | 179 | // | |
| 162 | 180 | // A same tool may be used by several devices. | |
| 163 | - | func (x *Seat) ConnectToolAdded(cb func(Seat, uintptr)) uint32 { | |
| 181 | + | func (x *Seat) ConnectToolAdded(cb *func(Seat, uintptr)) uint32 { | |
| 182 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 183 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 184 | + | return gobject.SignalConnect(x.GoPointer(), "tool-added", cbRefPtr) | |
| 185 | + | } | |
| 186 | + | ||
| 164 | 187 | fcb := func(clsPtr uintptr, ToolVarp uintptr) { | |
| 165 | 188 | fa := Seat{} | |
| 166 | 189 | fa.Ptr = clsPtr | |
| 190 | + | cbFn := *cb | |
| 167 | 191 | ||
| 168 | - | cb(fa, ToolVarp) | |
| 192 | + | cbFn(fa, ToolVarp) | |
| 169 | 193 | ||
| 170 | 194 | } | |
| 171 | - | return gobject.SignalConnect(x.GoPointer(), "tool-added", purego.NewCallback(fcb)) | |
| 195 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 196 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 197 | + | return gobject.SignalConnect(x.GoPointer(), "tool-added", cbRefPtr) | |
| 172 | 198 | } | |
| 173 | 199 | ||
| 174 | 200 | // Emitted whenever a tool is no longer known to this @seat. | |
| 175 | - | func (x *Seat) ConnectToolRemoved(cb func(Seat, uintptr)) uint32 { | |
| 201 | + | func (x *Seat) ConnectToolRemoved(cb *func(Seat, uintptr)) uint32 { | |
| 202 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 203 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 204 | + | return gobject.SignalConnect(x.GoPointer(), "tool-removed", cbRefPtr) | |
| 205 | + | } | |
| 206 | + | ||
| 176 | 207 | fcb := func(clsPtr uintptr, ToolVarp uintptr) { | |
| 177 | 208 | fa := Seat{} | |
| 178 | 209 | fa.Ptr = clsPtr | |
| 210 | + | cbFn := *cb | |
| 179 | 211 | ||
| 180 | - | cb(fa, ToolVarp) | |
| 212 | + | cbFn(fa, ToolVarp) | |
| 181 | 213 | ||
| 182 | 214 | } | |
| 183 | - | return gobject.SignalConnect(x.GoPointer(), "tool-removed", purego.NewCallback(fcb)) | |
| 215 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 216 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 217 | + | return gobject.SignalConnect(x.GoPointer(), "tool-removed", cbRefPtr) | |
| 184 | 218 | } | |
| 185 | 219 | ||
| 186 | 220 | func init() { | |
M v4/gdk/gdksurface.go +55 -15
| @@ -483,27 +483,43 @@ func (c *Surface) SetGoPointer(ptr uintptr) { | |||
| 483 | 483 | } | |
| 484 | 484 | ||
| 485 | 485 | // Emitted when @surface starts being present on the monitor. | |
| 486 | - | func (x *Surface) ConnectEnterMonitor(cb func(Surface, uintptr)) uint32 { | |
| 486 | + | func (x *Surface) ConnectEnterMonitor(cb *func(Surface, uintptr)) uint32 { | |
| 487 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 488 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 489 | + | return gobject.SignalConnect(x.GoPointer(), "enter-monitor", cbRefPtr) | |
| 490 | + | } | |
| 491 | + | ||
| 487 | 492 | fcb := func(clsPtr uintptr, MonitorVarp uintptr) { | |
| 488 | 493 | fa := Surface{} | |
| 489 | 494 | fa.Ptr = clsPtr | |
| 495 | + | cbFn := *cb | |
| 490 | 496 | ||
| 491 | - | cb(fa, MonitorVarp) | |
| 497 | + | cbFn(fa, MonitorVarp) | |
| 492 | 498 | ||
| 493 | 499 | } | |
| 494 | - | return gobject.SignalConnect(x.GoPointer(), "enter-monitor", purego.NewCallback(fcb)) | |
| 500 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 501 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 502 | + | return gobject.SignalConnect(x.GoPointer(), "enter-monitor", cbRefPtr) | |
| 495 | 503 | } | |
| 496 | 504 | ||
| 497 | 505 | // Emitted when GDK receives an input event for @surface. | |
| 498 | - | func (x *Surface) ConnectEvent(cb func(Surface, *Event) bool) uint32 { | |
| 506 | + | func (x *Surface) ConnectEvent(cb *func(Surface, *Event) bool) uint32 { | |
| 507 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 508 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 509 | + | return gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) | |
| 510 | + | } | |
| 511 | + | ||
| 499 | 512 | fcb := func(clsPtr uintptr, EventVarp uintptr) bool { | |
| 500 | 513 | fa := Surface{} | |
| 501 | 514 | fa.Ptr = clsPtr | |
| 515 | + | cbFn := *cb | |
| 502 | 516 | ||
| 503 | - | return cb(fa, EventNewFromInternalPtr(EventVarp)) | |
| 517 | + | return cbFn(fa, EventNewFromInternalPtr(EventVarp)) | |
| 504 | 518 | ||
| 505 | 519 | } | |
| 506 | - | return gobject.SignalConnect(x.GoPointer(), "event", purego.NewCallback(fcb)) | |
| 520 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 521 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 522 | + | return gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) | |
| 507 | 523 | } | |
| 508 | 524 | ||
| 509 | 525 | // Emitted when the size of @surface is changed, or when relayout should | |
| @@ -511,39 +527,63 @@ func (x *Surface) ConnectEvent(cb func(Surface, *Event) bool) uint32 { | |||
| 511 | 527 | // | |
| 512 | 528 | // Surface size is reported in ”application pixels”, not | |
| 513 | 529 | // ”device pixels” (see gdk_surface_get_scale_factor()). | |
| 514 | - | func (x *Surface) ConnectLayout(cb func(Surface, int, int)) uint32 { | |
| 530 | + | func (x *Surface) ConnectLayout(cb *func(Surface, int, int)) uint32 { | |
| 531 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 532 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 533 | + | return gobject.SignalConnect(x.GoPointer(), "layout", cbRefPtr) | |
| 534 | + | } | |
| 535 | + | ||
| 515 | 536 | fcb := func(clsPtr uintptr, WidthVarp int, HeightVarp int) { | |
| 516 | 537 | fa := Surface{} | |
| 517 | 538 | fa.Ptr = clsPtr | |
| 539 | + | cbFn := *cb | |
| 518 | 540 | ||
| 519 | - | cb(fa, WidthVarp, HeightVarp) | |
| 541 | + | cbFn(fa, WidthVarp, HeightVarp) | |
| 520 | 542 | ||
| 521 | 543 | } | |
| 522 | - | return gobject.SignalConnect(x.GoPointer(), "layout", purego.NewCallback(fcb)) | |
| 544 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 545 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 546 | + | return gobject.SignalConnect(x.GoPointer(), "layout", cbRefPtr) | |
| 523 | 547 | } | |
| 524 | 548 | ||
| 525 | 549 | // Emitted when @surface stops being present on the monitor. | |
| 526 | - | func (x *Surface) ConnectLeaveMonitor(cb func(Surface, uintptr)) uint32 { | |
| 550 | + | func (x *Surface) ConnectLeaveMonitor(cb *func(Surface, uintptr)) uint32 { | |
| 551 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 552 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 553 | + | return gobject.SignalConnect(x.GoPointer(), "leave-monitor", cbRefPtr) | |
| 554 | + | } | |
| 555 | + | ||
| 527 | 556 | fcb := func(clsPtr uintptr, MonitorVarp uintptr) { | |
| 528 | 557 | fa := Surface{} | |
| 529 | 558 | fa.Ptr = clsPtr | |
| 559 | + | cbFn := *cb | |
| 530 | 560 | ||
| 531 | - | cb(fa, MonitorVarp) | |
| 561 | + | cbFn(fa, MonitorVarp) | |
| 532 | 562 | ||
| 533 | 563 | } | |
| 534 | - | return gobject.SignalConnect(x.GoPointer(), "leave-monitor", purego.NewCallback(fcb)) | |
| 564 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 565 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 566 | + | return gobject.SignalConnect(x.GoPointer(), "leave-monitor", cbRefPtr) | |
| 535 | 567 | } | |
| 536 | 568 | ||
| 537 | 569 | // Emitted when part of the surface needs to be redrawn. | |
| 538 | - | func (x *Surface) ConnectRender(cb func(Surface, uintptr) bool) uint32 { | |
| 570 | + | func (x *Surface) ConnectRender(cb *func(Surface, uintptr) bool) uint32 { | |
| 571 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 572 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 573 | + | return gobject.SignalConnect(x.GoPointer(), "render", cbRefPtr) | |
| 574 | + | } | |
| 575 | + | ||
| 539 | 576 | fcb := func(clsPtr uintptr, RegionVarp uintptr) bool { | |
| 540 | 577 | fa := Surface{} | |
| 541 | 578 | fa.Ptr = clsPtr | |
| 579 | + | cbFn := *cb | |
| 542 | 580 | ||
| 543 | - | return cb(fa, RegionVarp) | |
| 581 | + | return cbFn(fa, RegionVarp) | |
| 544 | 582 | ||
| 545 | 583 | } | |
| 546 | - | return gobject.SignalConnect(x.GoPointer(), "render", purego.NewCallback(fcb)) | |
| 584 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 585 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 586 | + | return gobject.SignalConnect(x.GoPointer(), "render", cbRefPtr) | |
| 547 | 587 | } | |
| 548 | 588 | ||
| 549 | 589 | func init() { | |
M v4/gdk/gdktexture.go +2 -2
| @@ -529,9 +529,9 @@ func (x *Texture) Load(SizeVar int, TypeVar string, CancellableVar *gio.Cancella | |||
| 529 | 529 | // Loads an icon asynchronously. To finish this function, see | |
| 530 | 530 | // g_loadable_icon_load_finish(). For the synchronous, blocking | |
| 531 | 531 | // version of this function, see g_loadable_icon_load(). | |
| 532 | - | func (x *Texture) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 532 | + | func (x *Texture) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 533 | 533 | ||
| 534 | - | gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 534 | + | gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 535 | 535 | ||
| 536 | 536 | } | |
| 537 | 537 | ||
M v4/gdk/gdkvulkancontext.go +13 -3
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gdk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -39,15 +41,23 @@ func (c *VulkanContext) SetGoPointer(ptr uintptr) { | |||
| 39 | 41 | // | |
| 40 | 42 | // Usually this means that the swapchain had to be recreated, | |
| 41 | 43 | // for example in response to a change of the surface size. | |
| 42 | - | func (x *VulkanContext) ConnectImagesUpdated(cb func(VulkanContext)) uint32 { | |
| 44 | + | func (x *VulkanContext) ConnectImagesUpdated(cb *func(VulkanContext)) uint32 { | |
| 45 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 46 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 47 | + | return gobject.SignalConnect(x.GoPointer(), "images-updated", cbRefPtr) | |
| 48 | + | } | |
| 49 | + | ||
| 43 | 50 | fcb := func(clsPtr uintptr) { | |
| 44 | 51 | fa := VulkanContext{} | |
| 45 | 52 | fa.Ptr = clsPtr | |
| 53 | + | cbFn := *cb | |
| 46 | 54 | ||
| 47 | - | cb(fa) | |
| 55 | + | cbFn(fa) | |
| 48 | 56 | ||
| 49 | 57 | } | |
| 50 | - | return gobject.SignalConnect(x.GoPointer(), "images-updated", purego.NewCallback(fcb)) | |
| 58 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 59 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 60 | + | return gobject.SignalConnect(x.GoPointer(), "images-updated", cbRefPtr) | |
| 51 | 61 | } | |
| 52 | 62 | ||
| 53 | 63 | // Initializes the object implementing the interface. | |
M v4/gdkpixbuf/gdk-pixbuf-animation.go +2 -2
| @@ -313,9 +313,9 @@ var xPixbufAnimationNewFromStreamAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 313 | 313 | // When the operation is finished, `callback` will be called in the main thread. | |
| 314 | 314 | // You can then call gdk_pixbuf_animation_new_from_stream_finish() to get the | |
| 315 | 315 | // result of the operation. | |
| 316 | - | func PixbufAnimationNewFromStreamAsync(StreamVar *gio.InputStream, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 316 | + | func PixbufAnimationNewFromStreamAsync(StreamVar *gio.InputStream, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 317 | 317 | ||
| 318 | - | xPixbufAnimationNewFromStreamAsync(StreamVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 318 | + | xPixbufAnimationNewFromStreamAsync(StreamVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 319 | 319 | ||
| 320 | 320 | } | |
| 321 | 321 | ||
M v4/gdkpixbuf/gdk-pixbuf-loader.go +44 -12
| @@ -309,15 +309,23 @@ func (c *PixbufLoader) SetGoPointer(ptr uintptr) { | |||
| 309 | 309 | // After this signal is emitted, applications can call | |
| 310 | 310 | // gdk_pixbuf_loader_get_pixbuf() to fetch the partially-loaded | |
| 311 | 311 | // pixbuf. | |
| 312 | - | func (x *PixbufLoader) ConnectAreaPrepared(cb func(PixbufLoader)) uint32 { | |
| 312 | + | func (x *PixbufLoader) ConnectAreaPrepared(cb *func(PixbufLoader)) uint32 { | |
| 313 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 314 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 315 | + | return gobject.SignalConnect(x.GoPointer(), "area-prepared", cbRefPtr) | |
| 316 | + | } | |
| 317 | + | ||
| 313 | 318 | fcb := func(clsPtr uintptr) { | |
| 314 | 319 | fa := PixbufLoader{} | |
| 315 | 320 | fa.Ptr = clsPtr | |
| 321 | + | cbFn := *cb | |
| 316 | 322 | ||
| 317 | - | cb(fa) | |
| 323 | + | cbFn(fa) | |
| 318 | 324 | ||
| 319 | 325 | } | |
| 320 | - | return gobject.SignalConnect(x.GoPointer(), "area-prepared", purego.NewCallback(fcb)) | |
| 326 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 327 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 328 | + | return gobject.SignalConnect(x.GoPointer(), "area-prepared", cbRefPtr) | |
| 321 | 329 | } | |
| 322 | 330 | ||
| 323 | 331 | // This signal is emitted when a significant area of the image being | |
| @@ -328,15 +336,23 @@ func (x *PixbufLoader) ConnectAreaPrepared(cb func(PixbufLoader)) uint32 { | |||
| 328 | 336 | // | |
| 329 | 337 | // Applications can use this signal to know when to repaint | |
| 330 | 338 | // areas of an image that is being loaded. | |
| 331 | - | func (x *PixbufLoader) ConnectAreaUpdated(cb func(PixbufLoader, int, int, int, int)) uint32 { | |
| 339 | + | func (x *PixbufLoader) ConnectAreaUpdated(cb *func(PixbufLoader, int, int, int, int)) uint32 { | |
| 340 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 341 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 342 | + | return gobject.SignalConnect(x.GoPointer(), "area-updated", cbRefPtr) | |
| 343 | + | } | |
| 344 | + | ||
| 332 | 345 | fcb := func(clsPtr uintptr, XVarp int, YVarp int, WidthVarp int, HeightVarp int) { | |
| 333 | 346 | fa := PixbufLoader{} | |
| 334 | 347 | fa.Ptr = clsPtr | |
| 348 | + | cbFn := *cb | |
| 335 | 349 | ||
| 336 | - | cb(fa, XVarp, YVarp, WidthVarp, HeightVarp) | |
| 350 | + | cbFn(fa, XVarp, YVarp, WidthVarp, HeightVarp) | |
| 337 | 351 | ||
| 338 | 352 | } | |
| 339 | - | return gobject.SignalConnect(x.GoPointer(), "area-updated", purego.NewCallback(fcb)) | |
| 353 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 354 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 355 | + | return gobject.SignalConnect(x.GoPointer(), "area-updated", cbRefPtr) | |
| 340 | 356 | } | |
| 341 | 357 | ||
| 342 | 358 | // This signal is emitted when gdk_pixbuf_loader_close() is called. | |
| @@ -344,15 +360,23 @@ func (x *PixbufLoader) ConnectAreaUpdated(cb func(PixbufLoader, int, int, int, i | |||
| 344 | 360 | // It can be used by different parts of an application to receive | |
| 345 | 361 | // notification when an image loader is closed by the code that | |
| 346 | 362 | // drives it. | |
| 347 | - | func (x *PixbufLoader) ConnectClosed(cb func(PixbufLoader)) uint32 { | |
| 363 | + | func (x *PixbufLoader) ConnectClosed(cb *func(PixbufLoader)) uint32 { | |
| 364 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 365 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 366 | + | return gobject.SignalConnect(x.GoPointer(), "closed", cbRefPtr) | |
| 367 | + | } | |
| 368 | + | ||
| 348 | 369 | fcb := func(clsPtr uintptr) { | |
| 349 | 370 | fa := PixbufLoader{} | |
| 350 | 371 | fa.Ptr = clsPtr | |
| 372 | + | cbFn := *cb | |
| 351 | 373 | ||
| 352 | - | cb(fa) | |
| 374 | + | cbFn(fa) | |
| 353 | 375 | ||
| 354 | 376 | } | |
| 355 | - | return gobject.SignalConnect(x.GoPointer(), "closed", purego.NewCallback(fcb)) | |
| 377 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 378 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 379 | + | return gobject.SignalConnect(x.GoPointer(), "closed", cbRefPtr) | |
| 356 | 380 | } | |
| 357 | 381 | ||
| 358 | 382 | // This signal is emitted when the pixbuf loader has been fed the | |
| @@ -362,15 +386,23 @@ func (x *PixbufLoader) ConnectClosed(cb func(PixbufLoader)) uint32 { | |||
| 362 | 386 | // Applications can call gdk_pixbuf_loader_set_size() in response | |
| 363 | 387 | // to this signal to set the desired size to which the image | |
| 364 | 388 | // should be scaled. | |
| 365 | - | func (x *PixbufLoader) ConnectSizePrepared(cb func(PixbufLoader, int, int)) uint32 { | |
| 389 | + | func (x *PixbufLoader) ConnectSizePrepared(cb *func(PixbufLoader, int, int)) uint32 { | |
| 390 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 391 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 392 | + | return gobject.SignalConnect(x.GoPointer(), "size-prepared", cbRefPtr) | |
| 393 | + | } | |
| 394 | + | ||
| 366 | 395 | fcb := func(clsPtr uintptr, WidthVarp int, HeightVarp int) { | |
| 367 | 396 | fa := PixbufLoader{} | |
| 368 | 397 | fa.Ptr = clsPtr | |
| 398 | + | cbFn := *cb | |
| 369 | 399 | ||
| 370 | - | cb(fa, WidthVarp, HeightVarp) | |
| 400 | + | cbFn(fa, WidthVarp, HeightVarp) | |
| 371 | 401 | ||
| 372 | 402 | } | |
| 373 | - | return gobject.SignalConnect(x.GoPointer(), "size-prepared", purego.NewCallback(fcb)) | |
| 403 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 404 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 405 | + | return gobject.SignalConnect(x.GoPointer(), "size-prepared", cbRefPtr) | |
| 374 | 406 | } | |
| 375 | 407 | ||
| 376 | 408 | func init() { | |
M v4/gdkpixbuf/gdk-pixbuf.go +18 -18
| @@ -212,10 +212,10 @@ var xNewPixbufFromData func(uintptr, Colorspace, bool, int, int, int, int, uintp | |||
| 212 | 212 | // it is its responsibility to free the pixel array. | |
| 213 | 213 | // | |
| 214 | 214 | // See also: [ctor@GdkPixbuf.Pixbuf.new_from_bytes] | |
| 215 | - | func NewPixbufFromData(DataVar uintptr, ColorspaceVar Colorspace, HasAlphaVar bool, BitsPerSampleVar int, WidthVar int, HeightVar int, RowstrideVar int, DestroyFnVar PixbufDestroyNotify, DestroyFnDataVar uintptr) *Pixbuf { | |
| 215 | + | func NewPixbufFromData(DataVar uintptr, ColorspaceVar Colorspace, HasAlphaVar bool, BitsPerSampleVar int, WidthVar int, HeightVar int, RowstrideVar int, DestroyFnVar *PixbufDestroyNotify, DestroyFnDataVar uintptr) *Pixbuf { | |
| 216 | 216 | var cls *Pixbuf | |
| 217 | 217 | ||
| 218 | - | cret := xNewPixbufFromData(DataVar, ColorspaceVar, HasAlphaVar, BitsPerSampleVar, WidthVar, HeightVar, RowstrideVar, purego.NewCallback(DestroyFnVar), DestroyFnDataVar) | |
| 218 | + | cret := xNewPixbufFromData(DataVar, ColorspaceVar, HasAlphaVar, BitsPerSampleVar, WidthVar, HeightVar, RowstrideVar, glib.NewCallback(DestroyFnVar), DestroyFnDataVar) | |
| 219 | 219 | ||
| 220 | 220 | if cret == 0 { | |
| 221 | 221 | return nil | |
| @@ -1138,9 +1138,9 @@ var xPixbufSaveToCallback func(uintptr, uintptr, uintptr, string, **glib.Error, | |||
| 1138 | 1138 | // function generates. | |
| 1139 | 1139 | // | |
| 1140 | 1140 | // See [method@GdkPixbuf.Pixbuf.save] for more details. | |
| 1141 | - | func (x *Pixbuf) SaveToCallback(SaveFuncVar PixbufSaveFunc, UserDataVar uintptr, TypeVar string, ErrorVar **glib.Error, varArgs ...interface{}) bool { | |
| 1141 | + | func (x *Pixbuf) SaveToCallback(SaveFuncVar *PixbufSaveFunc, UserDataVar uintptr, TypeVar string, ErrorVar **glib.Error, varArgs ...interface{}) bool { | |
| 1142 | 1142 | ||
| 1143 | - | cret := xPixbufSaveToCallback(x.GoPointer(), purego.NewCallback(SaveFuncVar), UserDataVar, TypeVar, ErrorVar, varArgs...) | |
| 1143 | + | cret := xPixbufSaveToCallback(x.GoPointer(), glib.NewCallback(SaveFuncVar), UserDataVar, TypeVar, ErrorVar, varArgs...) | |
| 1144 | 1144 | return cret | |
| 1145 | 1145 | } | |
| 1146 | 1146 | ||
| @@ -1154,10 +1154,10 @@ var xPixbufSaveToCallbackv func(uintptr, uintptr, uintptr, string, []string, []s | |||
| 1154 | 1154 | // If @error is set, `FALSE` will be returned. | |
| 1155 | 1155 | // | |
| 1156 | 1156 | // See [method@GdkPixbuf.Pixbuf.save_to_callback] for more details. | |
| 1157 | - | func (x *Pixbuf) SaveToCallbackv(SaveFuncVar PixbufSaveFunc, UserDataVar uintptr, TypeVar string, OptionKeysVar []string, OptionValuesVar []string) (bool, error) { | |
| 1157 | + | func (x *Pixbuf) SaveToCallbackv(SaveFuncVar *PixbufSaveFunc, UserDataVar uintptr, TypeVar string, OptionKeysVar []string, OptionValuesVar []string) (bool, error) { | |
| 1158 | 1158 | var cerr *glib.Error | |
| 1159 | 1159 | ||
| 1160 | - | cret := xPixbufSaveToCallbackv(x.GoPointer(), purego.NewCallback(SaveFuncVar), UserDataVar, TypeVar, OptionKeysVar, OptionValuesVar, &cerr) | |
| 1160 | + | cret := xPixbufSaveToCallbackv(x.GoPointer(), glib.NewCallback(SaveFuncVar), UserDataVar, TypeVar, OptionKeysVar, OptionValuesVar, &cerr) | |
| 1161 | 1161 | if cerr == nil { | |
| 1162 | 1162 | return cret, nil | |
| 1163 | 1163 | } | |
| @@ -1195,9 +1195,9 @@ var xPixbufSaveToStreamAsync func(uintptr, uintptr, string, uintptr, uintptr, ui | |||
| 1195 | 1195 | // | |
| 1196 | 1196 | // You can then call gdk_pixbuf_save_to_stream_finish() to get the result of | |
| 1197 | 1197 | // the operation. | |
| 1198 | - | func (x *Pixbuf) SaveToStreamAsync(StreamVar *gio.OutputStream, TypeVar string, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr, varArgs ...interface{}) { | |
| 1198 | + | func (x *Pixbuf) SaveToStreamAsync(StreamVar *gio.OutputStream, TypeVar string, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr, varArgs ...interface{}) { | |
| 1199 | 1199 | ||
| 1200 | - | xPixbufSaveToStreamAsync(x.GoPointer(), StreamVar.GoPointer(), TypeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, varArgs...) | |
| 1200 | + | xPixbufSaveToStreamAsync(x.GoPointer(), StreamVar.GoPointer(), TypeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, varArgs...) | |
| 1201 | 1201 | ||
| 1202 | 1202 | } | |
| 1203 | 1203 | ||
| @@ -1231,9 +1231,9 @@ var xPixbufSaveToStreamvAsync func(uintptr, uintptr, string, uintptr, uintptr, u | |||
| 1231 | 1231 | // | |
| 1232 | 1232 | // You can then call gdk_pixbuf_save_to_stream_finish() to get the result of | |
| 1233 | 1233 | // the operation. | |
| 1234 | - | func (x *Pixbuf) SaveToStreamvAsync(StreamVar *gio.OutputStream, TypeVar string, OptionKeysVar uintptr, OptionValuesVar uintptr, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1234 | + | func (x *Pixbuf) SaveToStreamvAsync(StreamVar *gio.OutputStream, TypeVar string, OptionKeysVar uintptr, OptionValuesVar uintptr, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1235 | 1235 | ||
| 1236 | - | xPixbufSaveToStreamvAsync(x.GoPointer(), StreamVar.GoPointer(), TypeVar, OptionKeysVar, OptionValuesVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1236 | + | xPixbufSaveToStreamvAsync(x.GoPointer(), StreamVar.GoPointer(), TypeVar, OptionKeysVar, OptionValuesVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1237 | 1237 | ||
| 1238 | 1238 | } | |
| 1239 | 1239 | ||
| @@ -1403,9 +1403,9 @@ func (x *Pixbuf) Load(SizeVar int, TypeVar string, CancellableVar *gio.Cancellab | |||
| 1403 | 1403 | // Loads an icon asynchronously. To finish this function, see | |
| 1404 | 1404 | // g_loadable_icon_load_finish(). For the synchronous, blocking | |
| 1405 | 1405 | // version of this function, see g_loadable_icon_load(). | |
| 1406 | - | func (x *Pixbuf) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1406 | + | func (x *Pixbuf) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1407 | 1407 | ||
| 1408 | - | gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1408 | + | gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1409 | 1409 | ||
| 1410 | 1410 | } | |
| 1411 | 1411 | ||
| @@ -1461,9 +1461,9 @@ var xPixbufGetFileInfoAsync func(string, uintptr, uintptr, uintptr) | |||
| 1461 | 1461 | // When the operation is finished, @callback will be called in the | |
| 1462 | 1462 | // main thread. You can then call gdk_pixbuf_get_file_info_finish() to | |
| 1463 | 1463 | // get the result of the operation. | |
| 1464 | - | func PixbufGetFileInfoAsync(FilenameVar string, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1464 | + | func PixbufGetFileInfoAsync(FilenameVar string, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1465 | 1465 | ||
| 1466 | - | xPixbufGetFileInfoAsync(FilenameVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1466 | + | xPixbufGetFileInfoAsync(FilenameVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1467 | 1467 | ||
| 1468 | 1468 | } | |
| 1469 | 1469 | ||
| @@ -1528,9 +1528,9 @@ var xPixbufNewFromStreamAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 1528 | 1528 | // When the operation is finished, @callback will be called in the main thread. | |
| 1529 | 1529 | // You can then call gdk_pixbuf_new_from_stream_finish() to get the result of | |
| 1530 | 1530 | // the operation. | |
| 1531 | - | func PixbufNewFromStreamAsync(StreamVar *gio.InputStream, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1531 | + | func PixbufNewFromStreamAsync(StreamVar *gio.InputStream, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1532 | 1532 | ||
| 1533 | - | xPixbufNewFromStreamAsync(StreamVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1533 | + | xPixbufNewFromStreamAsync(StreamVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1534 | 1534 | ||
| 1535 | 1535 | } | |
| 1536 | 1536 | ||
| @@ -1543,9 +1543,9 @@ var xPixbufNewFromStreamAtScaleAsync func(uintptr, int, int, bool, uintptr, uint | |||
| 1543 | 1543 | // | |
| 1544 | 1544 | // When the operation is finished, @callback will be called in the main thread. | |
| 1545 | 1545 | // You can then call gdk_pixbuf_new_from_stream_finish() to get the result of the operation. | |
| 1546 | - | func PixbufNewFromStreamAtScaleAsync(StreamVar *gio.InputStream, WidthVar int, HeightVar int, PreserveAspectRatioVar bool, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1546 | + | func PixbufNewFromStreamAtScaleAsync(StreamVar *gio.InputStream, WidthVar int, HeightVar int, PreserveAspectRatioVar bool, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 1547 | 1547 | ||
| 1548 | - | xPixbufNewFromStreamAtScaleAsync(StreamVar.GoPointer(), WidthVar, HeightVar, PreserveAspectRatioVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1548 | + | xPixbufNewFromStreamAtScaleAsync(StreamVar.GoPointer(), WidthVar, HeightVar, PreserveAspectRatioVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1549 | 1549 | ||
| 1550 | 1550 | } | |
| 1551 | 1551 | ||
M v4/gio/gappinfo.go +38 -14
| @@ -103,7 +103,7 @@ type AppInfo interface { | |||
| 103 | 103 | GetSupportedTypes() []string | |
| 104 | 104 | Launch(FilesVar *glib.List, ContextVar *AppLaunchContext) bool | |
| 105 | 105 | LaunchUris(UrisVar *glib.List, ContextVar *AppLaunchContext) bool | |
| 106 | - | LaunchUrisAsync(UrisVar *glib.List, ContextVar *AppLaunchContext, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 106 | + | LaunchUrisAsync(UrisVar *glib.List, ContextVar *AppLaunchContext, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 107 | 107 | LaunchUrisFinish(ResultVar AsyncResult) bool | |
| 108 | 108 | RemoveSupportsType(ContentTypeVar string) bool | |
| 109 | 109 | SetAsDefaultForExtension(ExtensionVar string) bool | |
| @@ -331,9 +331,9 @@ func (x *AppInfoBase) LaunchUris(UrisVar *glib.List, ContextVar *AppLaunchContex | |||
| 331 | 331 | // waits for activation in case of D-Bus–activated applications and also provides | |
| 332 | 332 | // extended error information for sandboxed applications, see notes for | |
| 333 | 333 | // g_app_info_launch_default_for_uri_async(). | |
| 334 | - | func (x *AppInfoBase) LaunchUrisAsync(UrisVar *glib.List, ContextVar *AppLaunchContext, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 334 | + | func (x *AppInfoBase) LaunchUrisAsync(UrisVar *glib.List, ContextVar *AppLaunchContext, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 335 | 335 | ||
| 336 | - | XGAppInfoLaunchUrisAsync(x.GoPointer(), UrisVar, ContextVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 336 | + | XGAppInfoLaunchUrisAsync(x.GoPointer(), UrisVar, ContextVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 337 | 337 | ||
| 338 | 338 | } | |
| 339 | 339 | ||
| @@ -596,9 +596,9 @@ var xAppInfoLaunchDefaultForUriAsync func(string, uintptr, uintptr, uintptr, uin | |||
| 596 | 596 | // This is also useful if you want to be sure that the D-Bus–activated | |
| 597 | 597 | // applications are really started before termination and if you are interested | |
| 598 | 598 | // in receiving error information from their activation. | |
| 599 | - | func AppInfoLaunchDefaultForUriAsync(UriVar string, ContextVar *AppLaunchContext, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 599 | + | func AppInfoLaunchDefaultForUriAsync(UriVar string, ContextVar *AppLaunchContext, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 600 | 600 | ||
| 601 | - | xAppInfoLaunchDefaultForUriAsync(UriVar, ContextVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 601 | + | xAppInfoLaunchDefaultForUriAsync(UriVar, ContextVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 602 | 602 | ||
| 603 | 603 | } | |
| 604 | 604 | ||
| @@ -736,15 +736,23 @@ func (c *AppLaunchContext) SetGoPointer(ptr uintptr) { | |||
| 736 | 736 | // The #GAppLaunchContext::launch-failed signal is emitted when a #GAppInfo launch | |
| 737 | 737 | // fails. The startup notification id is provided, so that the launcher | |
| 738 | 738 | // can cancel the startup notification. | |
| 739 | - | func (x *AppLaunchContext) ConnectLaunchFailed(cb func(AppLaunchContext, string)) uint32 { | |
| 739 | + | func (x *AppLaunchContext) ConnectLaunchFailed(cb *func(AppLaunchContext, string)) uint32 { | |
| 740 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 741 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 742 | + | return gobject.SignalConnect(x.GoPointer(), "launch-failed", cbRefPtr) | |
| 743 | + | } | |
| 744 | + | ||
| 740 | 745 | fcb := func(clsPtr uintptr, StartupNotifyIdVarp string) { | |
| 741 | 746 | fa := AppLaunchContext{} | |
| 742 | 747 | fa.Ptr = clsPtr | |
| 748 | + | cbFn := *cb | |
| 743 | 749 | ||
| 744 | - | cb(fa, StartupNotifyIdVarp) | |
| 750 | + | cbFn(fa, StartupNotifyIdVarp) | |
| 745 | 751 | ||
| 746 | 752 | } | |
| 747 | - | return gobject.SignalConnect(x.GoPointer(), "launch-failed", purego.NewCallback(fcb)) | |
| 753 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 754 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 755 | + | return gobject.SignalConnect(x.GoPointer(), "launch-failed", cbRefPtr) | |
| 748 | 756 | } | |
| 749 | 757 | ||
| 750 | 758 | // The #GAppLaunchContext::launch-started signal is emitted when a #GAppInfo is | |
| @@ -761,15 +769,23 @@ func (x *AppLaunchContext) ConnectLaunchFailed(cb func(AppLaunchContext, string) | |||
| 761 | 769 | // | |
| 762 | 770 | // It is guaranteed that this signal is followed by either a #GAppLaunchContext::launched or | |
| 763 | 771 | // #GAppLaunchContext::launch-failed signal. | |
| 764 | - | func (x *AppLaunchContext) ConnectLaunchStarted(cb func(AppLaunchContext, uintptr, uintptr)) uint32 { | |
| 772 | + | func (x *AppLaunchContext) ConnectLaunchStarted(cb *func(AppLaunchContext, uintptr, uintptr)) uint32 { | |
| 773 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 774 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 775 | + | return gobject.SignalConnect(x.GoPointer(), "launch-started", cbRefPtr) | |
| 776 | + | } | |
| 777 | + | ||
| 765 | 778 | fcb := func(clsPtr uintptr, InfoVarp uintptr, PlatformDataVarp uintptr) { | |
| 766 | 779 | fa := AppLaunchContext{} | |
| 767 | 780 | fa.Ptr = clsPtr | |
| 781 | + | cbFn := *cb | |
| 768 | 782 | ||
| 769 | - | cb(fa, InfoVarp, PlatformDataVarp) | |
| 783 | + | cbFn(fa, InfoVarp, PlatformDataVarp) | |
| 770 | 784 | ||
| 771 | 785 | } | |
| 772 | - | return gobject.SignalConnect(x.GoPointer(), "launch-started", purego.NewCallback(fcb)) | |
| 786 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 787 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 788 | + | return gobject.SignalConnect(x.GoPointer(), "launch-started", cbRefPtr) | |
| 773 | 789 | } | |
| 774 | 790 | ||
| 775 | 791 | // The #GAppLaunchContext::launched signal is emitted when a #GAppInfo is successfully | |
| @@ -781,15 +797,23 @@ func (x *AppLaunchContext) ConnectLaunchStarted(cb func(AppLaunchContext, uintpt | |||
| 781 | 797 | // Since 2.72 the `pid` may be 0 if the process id wasn't known (for | |
| 782 | 798 | // example if the process was launched via D-Bus). The `pid` may not be | |
| 783 | 799 | // set at all in subsequent releases. | |
| 784 | - | func (x *AppLaunchContext) ConnectLaunched(cb func(AppLaunchContext, uintptr, uintptr)) uint32 { | |
| 800 | + | func (x *AppLaunchContext) ConnectLaunched(cb *func(AppLaunchContext, uintptr, uintptr)) uint32 { | |
| 801 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 802 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 803 | + | return gobject.SignalConnect(x.GoPointer(), "launched", cbRefPtr) | |
| 804 | + | } | |
| 805 | + | ||
| 785 | 806 | fcb := func(clsPtr uintptr, InfoVarp uintptr, PlatformDataVarp uintptr) { | |
| 786 | 807 | fa := AppLaunchContext{} | |
| 787 | 808 | fa.Ptr = clsPtr | |
| 809 | + | cbFn := *cb | |
| 788 | 810 | ||
| 789 | - | cb(fa, InfoVarp, PlatformDataVarp) | |
| 811 | + | cbFn(fa, InfoVarp, PlatformDataVarp) | |
| 790 | 812 | ||
| 791 | 813 | } | |
| 792 | - | return gobject.SignalConnect(x.GoPointer(), "launched", purego.NewCallback(fcb)) | |
| 814 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 815 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 816 | + | return gobject.SignalConnect(x.GoPointer(), "launched", cbRefPtr) | |
| 793 | 817 | } | |
| 794 | 818 | ||
| 795 | 819 | func init() { | |
M v4/gio/gapplication.go +77 -21
| @@ -907,29 +907,45 @@ func (c *Application) SetGoPointer(ptr uintptr) { | |||
| 907 | 907 | ||
| 908 | 908 | // The ::activate signal is emitted on the primary instance when an | |
| 909 | 909 | // activation occurs. See g_application_activate(). | |
| 910 | - | func (x *Application) ConnectActivate(cb func(Application)) uint32 { | |
| 910 | + | func (x *Application) ConnectActivate(cb *func(Application)) uint32 { | |
| 911 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 912 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 913 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 914 | + | } | |
| 915 | + | ||
| 911 | 916 | fcb := func(clsPtr uintptr) { | |
| 912 | 917 | fa := Application{} | |
| 913 | 918 | fa.Ptr = clsPtr | |
| 919 | + | cbFn := *cb | |
| 914 | 920 | ||
| 915 | - | cb(fa) | |
| 921 | + | cbFn(fa) | |
| 916 | 922 | ||
| 917 | 923 | } | |
| 918 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 924 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 925 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 926 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 919 | 927 | } | |
| 920 | 928 | ||
| 921 | 929 | // The ::command-line signal is emitted on the primary instance when | |
| 922 | 930 | // a commandline is not handled locally. See g_application_run() and | |
| 923 | 931 | // the #GApplicationCommandLine documentation for more information. | |
| 924 | - | func (x *Application) ConnectCommandLine(cb func(Application, uintptr) int) uint32 { | |
| 932 | + | func (x *Application) ConnectCommandLine(cb *func(Application, uintptr) int) uint32 { | |
| 933 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 934 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 935 | + | return gobject.SignalConnect(x.GoPointer(), "command-line", cbRefPtr) | |
| 936 | + | } | |
| 937 | + | ||
| 925 | 938 | fcb := func(clsPtr uintptr, CommandLineVarp uintptr) int { | |
| 926 | 939 | fa := Application{} | |
| 927 | 940 | fa.Ptr = clsPtr | |
| 941 | + | cbFn := *cb | |
| 928 | 942 | ||
| 929 | - | return cb(fa, CommandLineVarp) | |
| 943 | + | return cbFn(fa, CommandLineVarp) | |
| 930 | 944 | ||
| 931 | 945 | } | |
| 932 | - | return gobject.SignalConnect(x.GoPointer(), "command-line", purego.NewCallback(fcb)) | |
| 946 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 947 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 948 | + | return gobject.SignalConnect(x.GoPointer(), "command-line", cbRefPtr) | |
| 933 | 949 | } | |
| 934 | 950 | ||
| 935 | 951 | // The ::handle-local-options signal is emitted on the local instance | |
| @@ -973,15 +989,23 @@ func (x *Application) ConnectCommandLine(cb func(Application, uintptr) int) uint | |||
| 973 | 989 | // You can override local_command_line() if you need more powerful | |
| 974 | 990 | // capabilities than what is provided here, but this should not | |
| 975 | 991 | // normally be required. | |
| 976 | - | func (x *Application) ConnectHandleLocalOptions(cb func(Application, uintptr) int) uint32 { | |
| 992 | + | func (x *Application) ConnectHandleLocalOptions(cb *func(Application, uintptr) int) uint32 { | |
| 993 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 994 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 995 | + | return gobject.SignalConnect(x.GoPointer(), "handle-local-options", cbRefPtr) | |
| 996 | + | } | |
| 997 | + | ||
| 977 | 998 | fcb := func(clsPtr uintptr, OptionsVarp uintptr) int { | |
| 978 | 999 | fa := Application{} | |
| 979 | 1000 | fa.Ptr = clsPtr | |
| 1001 | + | cbFn := *cb | |
| 980 | 1002 | ||
| 981 | - | return cb(fa, OptionsVarp) | |
| 1003 | + | return cbFn(fa, OptionsVarp) | |
| 982 | 1004 | ||
| 983 | 1005 | } | |
| 984 | - | return gobject.SignalConnect(x.GoPointer(), "handle-local-options", purego.NewCallback(fcb)) | |
| 1006 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1007 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1008 | + | return gobject.SignalConnect(x.GoPointer(), "handle-local-options", cbRefPtr) | |
| 985 | 1009 | } | |
| 986 | 1010 | ||
| 987 | 1011 | // The ::name-lost signal is emitted only on the registered primary instance | |
| @@ -989,54 +1013,86 @@ func (x *Application) ConnectHandleLocalOptions(cb func(Application, uintptr) in | |||
| 989 | 1013 | // is using the %G_APPLICATION_ALLOW_REPLACEMENT flag. | |
| 990 | 1014 | // | |
| 991 | 1015 | // The default handler for this signal calls g_application_quit(). | |
| 992 | - | func (x *Application) ConnectNameLost(cb func(Application) bool) uint32 { | |
| 1016 | + | func (x *Application) ConnectNameLost(cb *func(Application) bool) uint32 { | |
| 1017 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1018 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1019 | + | return gobject.SignalConnect(x.GoPointer(), "name-lost", cbRefPtr) | |
| 1020 | + | } | |
| 1021 | + | ||
| 993 | 1022 | fcb := func(clsPtr uintptr) bool { | |
| 994 | 1023 | fa := Application{} | |
| 995 | 1024 | fa.Ptr = clsPtr | |
| 1025 | + | cbFn := *cb | |
| 996 | 1026 | ||
| 997 | - | return cb(fa) | |
| 1027 | + | return cbFn(fa) | |
| 998 | 1028 | ||
| 999 | 1029 | } | |
| 1000 | - | return gobject.SignalConnect(x.GoPointer(), "name-lost", purego.NewCallback(fcb)) | |
| 1030 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1031 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1032 | + | return gobject.SignalConnect(x.GoPointer(), "name-lost", cbRefPtr) | |
| 1001 | 1033 | } | |
| 1002 | 1034 | ||
| 1003 | 1035 | // The ::open signal is emitted on the primary instance when there are | |
| 1004 | 1036 | // files to open. See g_application_open() for more information. | |
| 1005 | - | func (x *Application) ConnectOpen(cb func(Application, uintptr, int, string)) uint32 { | |
| 1037 | + | func (x *Application) ConnectOpen(cb *func(Application, uintptr, int, string)) uint32 { | |
| 1038 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1039 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1040 | + | return gobject.SignalConnect(x.GoPointer(), "open", cbRefPtr) | |
| 1041 | + | } | |
| 1042 | + | ||
| 1006 | 1043 | fcb := func(clsPtr uintptr, FilesVarp uintptr, NFilesVarp int, HintVarp string) { | |
| 1007 | 1044 | fa := Application{} | |
| 1008 | 1045 | fa.Ptr = clsPtr | |
| 1046 | + | cbFn := *cb | |
| 1009 | 1047 | ||
| 1010 | - | cb(fa, FilesVarp, NFilesVarp, HintVarp) | |
| 1048 | + | cbFn(fa, FilesVarp, NFilesVarp, HintVarp) | |
| 1011 | 1049 | ||
| 1012 | 1050 | } | |
| 1013 | - | return gobject.SignalConnect(x.GoPointer(), "open", purego.NewCallback(fcb)) | |
| 1051 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1052 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1053 | + | return gobject.SignalConnect(x.GoPointer(), "open", cbRefPtr) | |
| 1014 | 1054 | } | |
| 1015 | 1055 | ||
| 1016 | 1056 | // The ::shutdown signal is emitted only on the registered primary instance | |
| 1017 | 1057 | // immediately after the main loop terminates. | |
| 1018 | - | func (x *Application) ConnectShutdown(cb func(Application)) uint32 { | |
| 1058 | + | func (x *Application) ConnectShutdown(cb *func(Application)) uint32 { | |
| 1059 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1060 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1061 | + | return gobject.SignalConnect(x.GoPointer(), "shutdown", cbRefPtr) | |
| 1062 | + | } | |
| 1063 | + | ||
| 1019 | 1064 | fcb := func(clsPtr uintptr) { | |
| 1020 | 1065 | fa := Application{} | |
| 1021 | 1066 | fa.Ptr = clsPtr | |
| 1067 | + | cbFn := *cb | |
| 1022 | 1068 | ||
| 1023 | - | cb(fa) | |
| 1069 | + | cbFn(fa) | |
| 1024 | 1070 | ||
| 1025 | 1071 | } | |
| 1026 | - | return gobject.SignalConnect(x.GoPointer(), "shutdown", purego.NewCallback(fcb)) | |
| 1072 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1073 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1074 | + | return gobject.SignalConnect(x.GoPointer(), "shutdown", cbRefPtr) | |
| 1027 | 1075 | } | |
| 1028 | 1076 | ||
| 1029 | 1077 | // The ::startup signal is emitted on the primary instance immediately | |
| 1030 | 1078 | // after registration. See g_application_register(). | |
| 1031 | - | func (x *Application) ConnectStartup(cb func(Application)) uint32 { | |
| 1079 | + | func (x *Application) ConnectStartup(cb *func(Application)) uint32 { | |
| 1080 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1081 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1082 | + | return gobject.SignalConnect(x.GoPointer(), "startup", cbRefPtr) | |
| 1083 | + | } | |
| 1084 | + | ||
| 1032 | 1085 | fcb := func(clsPtr uintptr) { | |
| 1033 | 1086 | fa := Application{} | |
| 1034 | 1087 | fa.Ptr = clsPtr | |
| 1088 | + | cbFn := *cb | |
| 1035 | 1089 | ||
| 1036 | - | cb(fa) | |
| 1090 | + | cbFn(fa) | |
| 1037 | 1091 | ||
| 1038 | 1092 | } | |
| 1039 | - | return gobject.SignalConnect(x.GoPointer(), "startup", purego.NewCallback(fcb)) | |
| 1093 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1094 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1095 | + | return gobject.SignalConnect(x.GoPointer(), "startup", cbRefPtr) | |
| 1040 | 1096 | } | |
| 1041 | 1097 | ||
| 1042 | 1098 | // Emits the #GActionGroup::action-added signal on @action_group. | |
M v4/gio/gasyncinitable.go +5 -5
| @@ -131,7 +131,7 @@ func (x *AsyncInitableIface) GoPointer() uintptr { | |||
| 131 | 131 | type AsyncInitable interface { | |
| 132 | 132 | GoPointer() uintptr | |
| 133 | 133 | SetGoPointer(uintptr) | |
| 134 | - | InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 134 | + | InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 135 | 135 | InitFinish(ResVar AsyncResult) bool | |
| 136 | 136 | NewFinish(ResVar AsyncResult) *gobject.Object | |
| 137 | 137 | } | |
| @@ -183,9 +183,9 @@ func (x *AsyncInitableBase) SetGoPointer(ptr uintptr) { | |||
| 183 | 183 | // in a thread, so if you want to support asynchronous initialization via | |
| 184 | 184 | // threads, just implement the #GAsyncInitable interface without overriding | |
| 185 | 185 | // any interface methods. | |
| 186 | - | func (x *AsyncInitableBase) InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 186 | + | func (x *AsyncInitableBase) InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 187 | 187 | ||
| 188 | - | XGAsyncInitableInitAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 188 | + | XGAsyncInitableInitAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 189 | 189 | ||
| 190 | 190 | } | |
| 191 | 191 | ||
| @@ -234,9 +234,9 @@ var xAsyncInitableNewvAsync func([]interface{}, uint, *gobject.Parameter, int, u | |||
| 234 | 234 | // When the initialization is finished, @callback will be called. You can | |
| 235 | 235 | // then call g_async_initable_new_finish() to get the new object and check | |
| 236 | 236 | // for any errors. | |
| 237 | - | func AsyncInitableNewvAsync(ObjectTypeVar []interface{}, NParametersVar uint, ParametersVar *gobject.Parameter, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 237 | + | func AsyncInitableNewvAsync(ObjectTypeVar []interface{}, NParametersVar uint, ParametersVar *gobject.Parameter, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 238 | 238 | ||
| 239 | - | xAsyncInitableNewvAsync(ObjectTypeVar, NParametersVar, ParametersVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 239 | + | xAsyncInitableNewvAsync(ObjectTypeVar, NParametersVar, ParametersVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 240 | 240 | ||
| 241 | 241 | } | |
| 242 | 242 | ||
M v4/gio/gbufferedinputstream.go +2 -2
| @@ -127,9 +127,9 @@ var xBufferedInputStreamFillAsync func(uintptr, int, int, uintptr, uintptr, uint | |||
| 127 | 127 | // | |
| 128 | 128 | // If @count is -1 then the attempted read size is equal to the number | |
| 129 | 129 | // of bytes that are required to fill the buffer. | |
| 130 | - | func (x *BufferedInputStream) FillAsync(CountVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 130 | + | func (x *BufferedInputStream) FillAsync(CountVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 131 | 131 | ||
| 132 | - | xBufferedInputStreamFillAsync(x.GoPointer(), CountVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 132 | + | xBufferedInputStreamFillAsync(x.GoPointer(), CountVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 133 | 133 | ||
| 134 | 134 | } | |
| 135 | 135 | ||
M v4/gio/gcancellable.go +13 -5
| @@ -105,9 +105,9 @@ var xCancellableConnect func(uintptr, uintptr, uintptr, uintptr) uint32 | |||
| 105 | 105 | // @callback is invoked. This lifts a restriction in place for | |
| 106 | 106 | // earlier GLib versions which now makes it easier to write cleanup | |
| 107 | 107 | // code that unconditionally invokes e.g. g_cancellable_cancel(). | |
| 108 | - | func (x *Cancellable) Connect(CallbackVar gobject.Callback, DataVar uintptr, DataDestroyFuncVar glib.DestroyNotify) uint32 { | |
| 108 | + | func (x *Cancellable) Connect(CallbackVar *gobject.Callback, DataVar uintptr, DataDestroyFuncVar *glib.DestroyNotify) uint32 { | |
| 109 | 109 | ||
| 110 | - | cret := xCancellableConnect(x.GoPointer(), purego.NewCallback(CallbackVar), DataVar, purego.NewCallback(DataDestroyFuncVar)) | |
| 110 | + | cret := xCancellableConnect(x.GoPointer(), glib.NewCallback(CallbackVar), DataVar, glib.NewCallback(DataDestroyFuncVar)) | |
| 111 | 111 | return cret | |
| 112 | 112 | } | |
| 113 | 113 | ||
| @@ -344,15 +344,23 @@ func (c *Cancellable) SetGoPointer(ptr uintptr) { | |||
| 344 | 344 | // Note that the cancelled signal is emitted in the thread that | |
| 345 | 345 | // the user cancelled from, which may be the main thread. So, the | |
| 346 | 346 | // cancellable signal should not do something that can block. | |
| 347 | - | func (x *Cancellable) ConnectCancelled(cb func(Cancellable)) uint32 { | |
| 347 | + | func (x *Cancellable) ConnectCancelled(cb *func(Cancellable)) uint32 { | |
| 348 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 349 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 350 | + | return gobject.SignalConnect(x.GoPointer(), "cancelled", cbRefPtr) | |
| 351 | + | } | |
| 352 | + | ||
| 348 | 353 | fcb := func(clsPtr uintptr) { | |
| 349 | 354 | fa := Cancellable{} | |
| 350 | 355 | fa.Ptr = clsPtr | |
| 356 | + | cbFn := *cb | |
| 351 | 357 | ||
| 352 | - | cb(fa) | |
| 358 | + | cbFn(fa) | |
| 353 | 359 | ||
| 354 | 360 | } | |
| 355 | - | return gobject.SignalConnect(x.GoPointer(), "cancelled", purego.NewCallback(fcb)) | |
| 361 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 362 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 363 | + | return gobject.SignalConnect(x.GoPointer(), "cancelled", cbRefPtr) | |
| 356 | 364 | } | |
| 357 | 365 | ||
| 358 | 366 | var xCancellableGetCurrent func() uintptr | |
M v4/gio/gdatainputstream.go +6 -6
| @@ -171,9 +171,9 @@ var xDataInputStreamReadLineAsync func(uintptr, int, uintptr, uintptr, uintptr) | |||
| 171 | 171 | // When the operation is finished, @callback will be called. You | |
| 172 | 172 | // can then call g_data_input_stream_read_line_finish() to get | |
| 173 | 173 | // the result of the operation. | |
| 174 | - | func (x *DataInputStream) ReadLineAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 174 | + | func (x *DataInputStream) ReadLineAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 175 | 175 | ||
| 176 | - | xDataInputStreamReadLineAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 176 | + | xDataInputStreamReadLineAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 177 | 177 | ||
| 178 | 178 | } | |
| 179 | 179 | ||
| @@ -327,9 +327,9 @@ var xDataInputStreamReadUntilAsync func(uintptr, string, int, uintptr, uintptr, | |||
| 327 | 327 | // inconsistent with g_data_input_stream_read_until(). Both functions | |
| 328 | 328 | // will be marked as deprecated in a future release. Use | |
| 329 | 329 | // g_data_input_stream_read_upto_async() instead. | |
| 330 | - | func (x *DataInputStream) ReadUntilAsync(StopCharsVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 330 | + | func (x *DataInputStream) ReadUntilAsync(StopCharsVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 331 | 331 | ||
| 332 | - | xDataInputStreamReadUntilAsync(x.GoPointer(), StopCharsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 332 | + | xDataInputStreamReadUntilAsync(x.GoPointer(), StopCharsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 333 | 333 | ||
| 334 | 334 | } | |
| 335 | 335 | ||
| @@ -389,9 +389,9 @@ var xDataInputStreamReadUptoAsync func(uintptr, string, int, int, uintptr, uintp | |||
| 389 | 389 | // When the operation is finished, @callback will be called. You | |
| 390 | 390 | // can then call g_data_input_stream_read_upto_finish() to get | |
| 391 | 391 | // the result of the operation. | |
| 392 | - | func (x *DataInputStream) ReadUptoAsync(StopCharsVar string, StopCharsLenVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 392 | + | func (x *DataInputStream) ReadUptoAsync(StopCharsVar string, StopCharsLenVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 393 | 393 | ||
| 394 | - | xDataInputStreamReadUptoAsync(x.GoPointer(), StopCharsVar, StopCharsLenVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 394 | + | xDataInputStreamReadUptoAsync(x.GoPointer(), StopCharsVar, StopCharsLenVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 395 | 395 | ||
| 396 | 396 | } | |
| 397 | 397 | ||
M v4/gio/gdbusaddress.go +2 -2
| @@ -54,9 +54,9 @@ var xDbusAddressGetStream func(string, uintptr, uintptr, uintptr) | |||
| 54 | 54 | // | |
| 55 | 55 | // This is an asynchronous failable function. See | |
| 56 | 56 | // g_dbus_address_get_stream_sync() for the synchronous version. | |
| 57 | - | func DbusAddressGetStream(AddressVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 57 | + | func DbusAddressGetStream(AddressVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 58 | 58 | ||
| 59 | - | xDbusAddressGetStream(AddressVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 59 | + | xDbusAddressGetStream(AddressVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 60 | 60 | ||
| 61 | 61 | } | |
| 62 | 62 | ||
M v4/gio/gdbusconnection.go +2 -2
| @@ -209,9 +209,9 @@ var xBusGet func(BusType, uintptr, uintptr, uintptr) | |||
| 209 | 209 | // | |
| 210 | 210 | // This is an asynchronous failable function. See g_bus_get_sync() for | |
| 211 | 211 | // the synchronous version. | |
| 212 | - | func BusGet(BusTypeVar BusType, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 212 | + | func BusGet(BusTypeVar BusType, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 213 | 213 | ||
| 214 | - | xBusGet(BusTypeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 214 | + | xBusGet(BusTypeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 215 | 215 | ||
| 216 | 216 | } | |
| 217 | 217 | ||
M v4/gio/gdbusinterfaceskeleton.go +11 -3
| @@ -235,15 +235,23 @@ func (c *DBusInterfaceSkeleton) SetGoPointer(ptr uintptr) { | |||
| 235 | 235 | // flags set, no dedicated thread is ever used and the call will be | |
| 236 | 236 | // handled in the same thread as the object that @interface belongs | |
| 237 | 237 | // to was exported in. | |
| 238 | - | func (x *DBusInterfaceSkeleton) ConnectGAuthorizeMethod(cb func(DBusInterfaceSkeleton, uintptr) bool) uint32 { | |
| 238 | + | func (x *DBusInterfaceSkeleton) ConnectGAuthorizeMethod(cb *func(DBusInterfaceSkeleton, uintptr) bool) uint32 { | |
| 239 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 240 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 241 | + | return gobject.SignalConnect(x.GoPointer(), "g-authorize-method", cbRefPtr) | |
| 242 | + | } | |
| 243 | + | ||
| 239 | 244 | fcb := func(clsPtr uintptr, InvocationVarp uintptr) bool { | |
| 240 | 245 | fa := DBusInterfaceSkeleton{} | |
| 241 | 246 | fa.Ptr = clsPtr | |
| 247 | + | cbFn := *cb | |
| 242 | 248 | ||
| 243 | - | return cb(fa, InvocationVarp) | |
| 249 | + | return cbFn(fa, InvocationVarp) | |
| 244 | 250 | ||
| 245 | 251 | } | |
| 246 | - | return gobject.SignalConnect(x.GoPointer(), "g-authorize-method", purego.NewCallback(fcb)) | |
| 252 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 253 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 254 | + | return gobject.SignalConnect(x.GoPointer(), "g-authorize-method", cbRefPtr) | |
| 247 | 255 | } | |
| 248 | 256 | ||
| 249 | 257 | // Gets the #GDBusObject that @interface_ belongs to, if any. | |
M v4/gio/gdbusnameowning.go +4 -4
| @@ -68,9 +68,9 @@ var xBusOwnName func(BusType, string, BusNameOwnerFlags, uintptr, uintptr, uintp | |||
| 68 | 68 | // to [own names][gdbus-owning-names] and export objects. | |
| 69 | 69 | // Simply register objects to be exported in @bus_acquired_handler and | |
| 70 | 70 | // unregister the objects (if any) in @name_lost_handler. | |
| 71 | - | func BusOwnName(BusTypeVar BusType, NameVar string, FlagsVar BusNameOwnerFlags, BusAcquiredHandlerVar BusAcquiredCallback, NameAcquiredHandlerVar BusNameAcquiredCallback, NameLostHandlerVar BusNameLostCallback, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) uint { | |
| 71 | + | func BusOwnName(BusTypeVar BusType, NameVar string, FlagsVar BusNameOwnerFlags, BusAcquiredHandlerVar *BusAcquiredCallback, NameAcquiredHandlerVar *BusNameAcquiredCallback, NameLostHandlerVar *BusNameLostCallback, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint { | |
| 72 | 72 | ||
| 73 | - | cret := xBusOwnName(BusTypeVar, NameVar, FlagsVar, purego.NewCallback(BusAcquiredHandlerVar), purego.NewCallback(NameAcquiredHandlerVar), purego.NewCallback(NameLostHandlerVar), UserDataVar, purego.NewCallback(UserDataFreeFuncVar)) | |
| 73 | + | cret := xBusOwnName(BusTypeVar, NameVar, FlagsVar, glib.NewCallback(BusAcquiredHandlerVar), glib.NewCallback(NameAcquiredHandlerVar), glib.NewCallback(NameLostHandlerVar), UserDataVar, glib.NewCallback(UserDataFreeFuncVar)) | |
| 74 | 74 | return cret | |
| 75 | 75 | } | |
| 76 | 76 | ||
| @@ -78,9 +78,9 @@ var xBusOwnNameOnConnection func(uintptr, string, BusNameOwnerFlags, uintptr, ui | |||
| 78 | 78 | ||
| 79 | 79 | // Like g_bus_own_name() but takes a #GDBusConnection instead of a | |
| 80 | 80 | // #GBusType. | |
| 81 | - | func BusOwnNameOnConnection(ConnectionVar *DBusConnection, NameVar string, FlagsVar BusNameOwnerFlags, NameAcquiredHandlerVar BusNameAcquiredCallback, NameLostHandlerVar BusNameLostCallback, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) uint { | |
| 81 | + | func BusOwnNameOnConnection(ConnectionVar *DBusConnection, NameVar string, FlagsVar BusNameOwnerFlags, NameAcquiredHandlerVar *BusNameAcquiredCallback, NameLostHandlerVar *BusNameLostCallback, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint { | |
| 82 | 82 | ||
| 83 | - | cret := xBusOwnNameOnConnection(ConnectionVar.GoPointer(), NameVar, FlagsVar, purego.NewCallback(NameAcquiredHandlerVar), purego.NewCallback(NameLostHandlerVar), UserDataVar, purego.NewCallback(UserDataFreeFuncVar)) | |
| 83 | + | cret := xBusOwnNameOnConnection(ConnectionVar.GoPointer(), NameVar, FlagsVar, glib.NewCallback(NameAcquiredHandlerVar), glib.NewCallback(NameLostHandlerVar), UserDataVar, glib.NewCallback(UserDataFreeFuncVar)) | |
| 84 | 84 | return cret | |
| 85 | 85 | } | |
| 86 | 86 | ||
M v4/gio/gdbusnamewatching.go +4 -4
| @@ -65,9 +65,9 @@ var xBusWatchName func(BusType, string, BusNameWatcherFlags, uintptr, uintptr, u | |||
| 65 | 65 | // Basically, the application should create object proxies in | |
| 66 | 66 | // @name_appeared_handler and destroy them again (if any) in | |
| 67 | 67 | // @name_vanished_handler. | |
| 68 | - | func BusWatchName(BusTypeVar BusType, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedHandlerVar BusNameAppearedCallback, NameVanishedHandlerVar BusNameVanishedCallback, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) uint { | |
| 68 | + | func BusWatchName(BusTypeVar BusType, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedHandlerVar *BusNameAppearedCallback, NameVanishedHandlerVar *BusNameVanishedCallback, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint { | |
| 69 | 69 | ||
| 70 | - | cret := xBusWatchName(BusTypeVar, NameVar, FlagsVar, purego.NewCallback(NameAppearedHandlerVar), purego.NewCallback(NameVanishedHandlerVar), UserDataVar, purego.NewCallback(UserDataFreeFuncVar)) | |
| 70 | + | cret := xBusWatchName(BusTypeVar, NameVar, FlagsVar, glib.NewCallback(NameAppearedHandlerVar), glib.NewCallback(NameVanishedHandlerVar), UserDataVar, glib.NewCallback(UserDataFreeFuncVar)) | |
| 71 | 71 | return cret | |
| 72 | 72 | } | |
| 73 | 73 | ||
| @@ -75,9 +75,9 @@ var xBusWatchNameOnConnection func(uintptr, string, BusNameWatcherFlags, uintptr | |||
| 75 | 75 | ||
| 76 | 76 | // Like g_bus_watch_name() but takes a #GDBusConnection instead of a | |
| 77 | 77 | // #GBusType. | |
| 78 | - | func BusWatchNameOnConnection(ConnectionVar *DBusConnection, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedHandlerVar BusNameAppearedCallback, NameVanishedHandlerVar BusNameVanishedCallback, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) uint { | |
| 78 | + | func BusWatchNameOnConnection(ConnectionVar *DBusConnection, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedHandlerVar *BusNameAppearedCallback, NameVanishedHandlerVar *BusNameVanishedCallback, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint { | |
| 79 | 79 | ||
| 80 | - | cret := xBusWatchNameOnConnection(ConnectionVar.GoPointer(), NameVar, FlagsVar, purego.NewCallback(NameAppearedHandlerVar), purego.NewCallback(NameVanishedHandlerVar), UserDataVar, purego.NewCallback(UserDataFreeFuncVar)) | |
| 80 | + | cret := xBusWatchNameOnConnection(ConnectionVar.GoPointer(), NameVar, FlagsVar, glib.NewCallback(NameAppearedHandlerVar), glib.NewCallback(NameVanishedHandlerVar), UserDataVar, glib.NewCallback(UserDataFreeFuncVar)) | |
| 81 | 81 | return cret | |
| 82 | 82 | } | |
| 83 | 83 | ||
M v4/gio/gdbusobjectmanagerclient.go +32 -16
| @@ -163,11 +163,11 @@ var xNewDBusObjectManagerClientForBusSync func(BusType, DBusObjectManagerClientF | |||
| 163 | 163 | // This is a synchronous failable constructor - the calling thread is | |
| 164 | 164 | // blocked until a reply is received. See g_dbus_object_manager_client_new_for_bus() | |
| 165 | 165 | // for the asynchronous version. | |
| 166 | - | func NewDBusObjectManagerClientForBusSync(BusTypeVar BusType, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar glib.DestroyNotify, CancellableVar *Cancellable) (*DBusObjectManagerClient, error) { | |
| 166 | + | func NewDBusObjectManagerClientForBusSync(BusTypeVar BusType, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar *DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar *glib.DestroyNotify, CancellableVar *Cancellable) (*DBusObjectManagerClient, error) { | |
| 167 | 167 | var cls *DBusObjectManagerClient | |
| 168 | 168 | var cerr *glib.Error | |
| 169 | 169 | ||
| 170 | - | cret := xNewDBusObjectManagerClientForBusSync(BusTypeVar, FlagsVar, NameVar, ObjectPathVar, purego.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, purego.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), &cerr) | |
| 170 | + | cret := xNewDBusObjectManagerClientForBusSync(BusTypeVar, FlagsVar, NameVar, ObjectPathVar, glib.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, glib.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), &cerr) | |
| 171 | 171 | ||
| 172 | 172 | if cret == 0 { | |
| 173 | 173 | return nil, cerr | |
| @@ -188,11 +188,11 @@ var xNewDBusObjectManagerClientSync func(uintptr, DBusObjectManagerClientFlags, | |||
| 188 | 188 | // This is a synchronous failable constructor - the calling thread is | |
| 189 | 189 | // blocked until a reply is received. See g_dbus_object_manager_client_new() | |
| 190 | 190 | // for the asynchronous version. | |
| 191 | - | func NewDBusObjectManagerClientSync(ConnectionVar *DBusConnection, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar glib.DestroyNotify, CancellableVar *Cancellable) (*DBusObjectManagerClient, error) { | |
| 191 | + | func NewDBusObjectManagerClientSync(ConnectionVar *DBusConnection, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar *DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar *glib.DestroyNotify, CancellableVar *Cancellable) (*DBusObjectManagerClient, error) { | |
| 192 | 192 | var cls *DBusObjectManagerClient | |
| 193 | 193 | var cerr *glib.Error | |
| 194 | 194 | ||
| 195 | - | cret := xNewDBusObjectManagerClientSync(ConnectionVar.GoPointer(), FlagsVar, NameVar, ObjectPathVar, purego.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, purego.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), &cerr) | |
| 195 | + | cret := xNewDBusObjectManagerClientSync(ConnectionVar.GoPointer(), FlagsVar, NameVar, ObjectPathVar, glib.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, glib.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), &cerr) | |
| 196 | 196 | ||
| 197 | 197 | if cret == 0 { | |
| 198 | 198 | return nil, cerr | |
| @@ -273,15 +273,23 @@ func (c *DBusObjectManagerClient) SetGoPointer(ptr uintptr) { | |||
| 273 | 273 | // This signal is emitted in the | |
| 274 | 274 | // [thread-default main context][g-main-context-push-thread-default] | |
| 275 | 275 | // that @manager was constructed in. | |
| 276 | - | func (x *DBusObjectManagerClient) ConnectInterfaceProxyPropertiesChanged(cb func(DBusObjectManagerClient, uintptr, uintptr, uintptr, uintptr)) uint32 { | |
| 276 | + | func (x *DBusObjectManagerClient) ConnectInterfaceProxyPropertiesChanged(cb *func(DBusObjectManagerClient, uintptr, uintptr, uintptr, uintptr)) uint32 { | |
| 277 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 278 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 279 | + | return gobject.SignalConnect(x.GoPointer(), "interface-proxy-properties-changed", cbRefPtr) | |
| 280 | + | } | |
| 281 | + | ||
| 277 | 282 | fcb := func(clsPtr uintptr, ObjectProxyVarp uintptr, InterfaceProxyVarp uintptr, ChangedPropertiesVarp uintptr, InvalidatedPropertiesVarp uintptr) { | |
| 278 | 283 | fa := DBusObjectManagerClient{} | |
| 279 | 284 | fa.Ptr = clsPtr | |
| 285 | + | cbFn := *cb | |
| 280 | 286 | ||
| 281 | - | cb(fa, ObjectProxyVarp, InterfaceProxyVarp, ChangedPropertiesVarp, InvalidatedPropertiesVarp) | |
| 287 | + | cbFn(fa, ObjectProxyVarp, InterfaceProxyVarp, ChangedPropertiesVarp, InvalidatedPropertiesVarp) | |
| 282 | 288 | ||
| 283 | 289 | } | |
| 284 | - | return gobject.SignalConnect(x.GoPointer(), "interface-proxy-properties-changed", purego.NewCallback(fcb)) | |
| 290 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 291 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 292 | + | return gobject.SignalConnect(x.GoPointer(), "interface-proxy-properties-changed", cbRefPtr) | |
| 285 | 293 | } | |
| 286 | 294 | ||
| 287 | 295 | // Emitted when a D-Bus signal is received on @interface_proxy. | |
| @@ -292,15 +300,23 @@ func (x *DBusObjectManagerClient) ConnectInterfaceProxyPropertiesChanged(cb func | |||
| 292 | 300 | // This signal is emitted in the | |
| 293 | 301 | // [thread-default main context][g-main-context-push-thread-default] | |
| 294 | 302 | // that @manager was constructed in. | |
| 295 | - | func (x *DBusObjectManagerClient) ConnectInterfaceProxySignal(cb func(DBusObjectManagerClient, uintptr, uintptr, string, string, uintptr)) uint32 { | |
| 303 | + | func (x *DBusObjectManagerClient) ConnectInterfaceProxySignal(cb *func(DBusObjectManagerClient, uintptr, uintptr, string, string, uintptr)) uint32 { | |
| 304 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 305 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 306 | + | return gobject.SignalConnect(x.GoPointer(), "interface-proxy-signal", cbRefPtr) | |
| 307 | + | } | |
| 308 | + | ||
| 296 | 309 | fcb := func(clsPtr uintptr, ObjectProxyVarp uintptr, InterfaceProxyVarp uintptr, SenderNameVarp string, SignalNameVarp string, ParametersVarp uintptr) { | |
| 297 | 310 | fa := DBusObjectManagerClient{} | |
| 298 | 311 | fa.Ptr = clsPtr | |
| 312 | + | cbFn := *cb | |
| 299 | 313 | ||
| 300 | - | cb(fa, ObjectProxyVarp, InterfaceProxyVarp, SenderNameVarp, SignalNameVarp, ParametersVarp) | |
| 314 | + | cbFn(fa, ObjectProxyVarp, InterfaceProxyVarp, SenderNameVarp, SignalNameVarp, ParametersVarp) | |
| 301 | 315 | ||
| 302 | 316 | } | |
| 303 | - | return gobject.SignalConnect(x.GoPointer(), "interface-proxy-signal", purego.NewCallback(fcb)) | |
| 317 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 318 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 319 | + | return gobject.SignalConnect(x.GoPointer(), "interface-proxy-signal", cbRefPtr) | |
| 304 | 320 | } | |
| 305 | 321 | ||
| 306 | 322 | // Starts asynchronous initialization of the object implementing the | |
| @@ -339,9 +355,9 @@ func (x *DBusObjectManagerClient) ConnectInterfaceProxySignal(cb func(DBusObject | |||
| 339 | 355 | // in a thread, so if you want to support asynchronous initialization via | |
| 340 | 356 | // threads, just implement the #GAsyncInitable interface without overriding | |
| 341 | 357 | // any interface methods. | |
| 342 | - | func (x *DBusObjectManagerClient) InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 358 | + | func (x *DBusObjectManagerClient) InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 343 | 359 | ||
| 344 | - | XGAsyncInitableInitAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 360 | + | XGAsyncInitableInitAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 345 | 361 | ||
| 346 | 362 | } | |
| 347 | 363 | ||
| @@ -480,9 +496,9 @@ var xDBusObjectManagerClientNew func(uintptr, DBusObjectManagerClientFlags, stri | |||
| 480 | 496 | // of the thread you are calling this method from. You can | |
| 481 | 497 | // then call g_dbus_object_manager_client_new_finish() to get the result. See | |
| 482 | 498 | // g_dbus_object_manager_client_new_sync() for the synchronous version. | |
| 483 | - | func DBusObjectManagerClientNew(ConnectionVar *DBusConnection, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar glib.DestroyNotify, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 499 | + | func DBusObjectManagerClientNew(ConnectionVar *DBusConnection, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar *DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar *glib.DestroyNotify, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 484 | 500 | ||
| 485 | - | xDBusObjectManagerClientNew(ConnectionVar.GoPointer(), FlagsVar, NameVar, ObjectPathVar, purego.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, purego.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 501 | + | xDBusObjectManagerClientNew(ConnectionVar.GoPointer(), FlagsVar, NameVar, ObjectPathVar, glib.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, glib.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 486 | 502 | ||
| 487 | 503 | } | |
| 488 | 504 | ||
| @@ -497,9 +513,9 @@ var xDBusObjectManagerClientNewForBus func(BusType, DBusObjectManagerClientFlags | |||
| 497 | 513 | // of the thread you are calling this method from. You can | |
| 498 | 514 | // then call g_dbus_object_manager_client_new_for_bus_finish() to get the result. See | |
| 499 | 515 | // g_dbus_object_manager_client_new_for_bus_sync() for the synchronous version. | |
| 500 | - | func DBusObjectManagerClientNewForBus(BusTypeVar BusType, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar glib.DestroyNotify, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 516 | + | func DBusObjectManagerClientNewForBus(BusTypeVar BusType, FlagsVar DBusObjectManagerClientFlags, NameVar string, ObjectPathVar string, GetProxyTypeFuncVar *DBusProxyTypeFunc, GetProxyTypeUserDataVar uintptr, GetProxyTypeDestroyNotifyVar *glib.DestroyNotify, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 501 | 517 | ||
| 502 | - | xDBusObjectManagerClientNewForBus(BusTypeVar, FlagsVar, NameVar, ObjectPathVar, purego.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, purego.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 518 | + | xDBusObjectManagerClientNewForBus(BusTypeVar, FlagsVar, NameVar, ObjectPathVar, glib.NewCallback(GetProxyTypeFuncVar), GetProxyTypeUserDataVar, glib.NewCallback(GetProxyTypeDestroyNotifyVar), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 503 | 519 | ||
| 504 | 520 | } | |
| 505 | 521 | ||
M v4/gio/gdbusobjectskeleton.go +11 -3
| @@ -131,15 +131,23 @@ func (c *DBusObjectSkeleton) SetGoPointer(ptr uintptr) { | |||
| 131 | 131 | // except that it is for the enclosing object. | |
| 132 | 132 | // | |
| 133 | 133 | // The default class handler just returns %TRUE. | |
| 134 | - | func (x *DBusObjectSkeleton) ConnectAuthorizeMethod(cb func(DBusObjectSkeleton, uintptr, uintptr) bool) uint32 { | |
| 134 | + | func (x *DBusObjectSkeleton) ConnectAuthorizeMethod(cb *func(DBusObjectSkeleton, uintptr, uintptr) bool) uint32 { | |
| 135 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 136 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 137 | + | return gobject.SignalConnect(x.GoPointer(), "authorize-method", cbRefPtr) | |
| 138 | + | } | |
| 139 | + | ||
| 135 | 140 | fcb := func(clsPtr uintptr, InterfaceVarp uintptr, InvocationVarp uintptr) bool { | |
| 136 | 141 | fa := DBusObjectSkeleton{} | |
| 137 | 142 | fa.Ptr = clsPtr | |
| 143 | + | cbFn := *cb | |
| 138 | 144 | ||
| 139 | - | return cb(fa, InterfaceVarp, InvocationVarp) | |
| 145 | + | return cbFn(fa, InterfaceVarp, InvocationVarp) | |
| 140 | 146 | ||
| 141 | 147 | } | |
| 142 | - | return gobject.SignalConnect(x.GoPointer(), "authorize-method", purego.NewCallback(fcb)) | |
| 148 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 149 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 150 | + | return gobject.SignalConnect(x.GoPointer(), "authorize-method", cbRefPtr) | |
| 143 | 151 | } | |
| 144 | 152 | ||
| 145 | 153 | // Gets the D-Bus interface with name @interface_name associated with | |
M v4/gio/gdbusproxy.go +32 -16
| @@ -235,9 +235,9 @@ var xDBusProxyCall func(uintptr, string, *glib.Variant, DBusCallFlags, int, uint | |||
| 235 | 235 | // | |
| 236 | 236 | // If @callback is %NULL then the D-Bus method call message will be sent with | |
| 237 | 237 | // the %G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set. | |
| 238 | - | func (x *DBusProxy) Call(MethodNameVar string, ParametersVar *glib.Variant, FlagsVar DBusCallFlags, TimeoutMsecVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 238 | + | func (x *DBusProxy) Call(MethodNameVar string, ParametersVar *glib.Variant, FlagsVar DBusCallFlags, TimeoutMsecVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 239 | 239 | ||
| 240 | - | xDBusProxyCall(x.GoPointer(), MethodNameVar, ParametersVar, FlagsVar, TimeoutMsecVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 240 | + | xDBusProxyCall(x.GoPointer(), MethodNameVar, ParametersVar, FlagsVar, TimeoutMsecVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 241 | 241 | ||
| 242 | 242 | } | |
| 243 | 243 | ||
| @@ -309,9 +309,9 @@ var xDBusProxyCallWithUnixFdList func(uintptr, string, *glib.Variant, DBusCallFl | |||
| 309 | 309 | // Like g_dbus_proxy_call() but also takes a #GUnixFDList object. | |
| 310 | 310 | // | |
| 311 | 311 | // This method is only available on UNIX. | |
| 312 | - | func (x *DBusProxy) CallWithUnixFdList(MethodNameVar string, ParametersVar *glib.Variant, FlagsVar DBusCallFlags, TimeoutMsecVar int, FdListVar *UnixFDList, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 312 | + | func (x *DBusProxy) CallWithUnixFdList(MethodNameVar string, ParametersVar *glib.Variant, FlagsVar DBusCallFlags, TimeoutMsecVar int, FdListVar *UnixFDList, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 313 | 313 | ||
| 314 | - | xDBusProxyCallWithUnixFdList(x.GoPointer(), MethodNameVar, ParametersVar, FlagsVar, TimeoutMsecVar, FdListVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 314 | + | xDBusProxyCallWithUnixFdList(x.GoPointer(), MethodNameVar, ParametersVar, FlagsVar, TimeoutMsecVar, FdListVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 315 | 315 | ||
| 316 | 316 | } | |
| 317 | 317 | ||
| @@ -548,15 +548,23 @@ func (c *DBusProxy) SetGoPointer(ptr uintptr) { | |||
| 548 | 548 | // This signal corresponds to the | |
| 549 | 549 | // `PropertiesChanged` D-Bus signal on the | |
| 550 | 550 | // `org.freedesktop.DBus.Properties` interface. | |
| 551 | - | func (x *DBusProxy) ConnectGPropertiesChanged(cb func(DBusProxy, uintptr, uintptr)) uint32 { | |
| 551 | + | func (x *DBusProxy) ConnectGPropertiesChanged(cb *func(DBusProxy, uintptr, uintptr)) uint32 { | |
| 552 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 553 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 554 | + | return gobject.SignalConnect(x.GoPointer(), "g-properties-changed", cbRefPtr) | |
| 555 | + | } | |
| 556 | + | ||
| 552 | 557 | fcb := func(clsPtr uintptr, ChangedPropertiesVarp uintptr, InvalidatedPropertiesVarp uintptr) { | |
| 553 | 558 | fa := DBusProxy{} | |
| 554 | 559 | fa.Ptr = clsPtr | |
| 560 | + | cbFn := *cb | |
| 555 | 561 | ||
| 556 | - | cb(fa, ChangedPropertiesVarp, InvalidatedPropertiesVarp) | |
| 562 | + | cbFn(fa, ChangedPropertiesVarp, InvalidatedPropertiesVarp) | |
| 557 | 563 | ||
| 558 | 564 | } | |
| 559 | - | return gobject.SignalConnect(x.GoPointer(), "g-properties-changed", purego.NewCallback(fcb)) | |
| 565 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 566 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 567 | + | return gobject.SignalConnect(x.GoPointer(), "g-properties-changed", cbRefPtr) | |
| 560 | 568 | } | |
| 561 | 569 | ||
| 562 | 570 | // Emitted when a signal from the remote object and interface that @proxy is for, has been received. | |
| @@ -564,15 +572,23 @@ func (x *DBusProxy) ConnectGPropertiesChanged(cb func(DBusProxy, uintptr, uintpt | |||
| 564 | 572 | // Since 2.72 this signal supports detailed connections. You can connect to | |
| 565 | 573 | // the detailed signal `g-signal::x` in order to receive callbacks only when | |
| 566 | 574 | // signal `x` is received from the remote object. | |
| 567 | - | func (x *DBusProxy) ConnectGSignal(cb func(DBusProxy, string, string, uintptr)) uint32 { | |
| 575 | + | func (x *DBusProxy) ConnectGSignal(cb *func(DBusProxy, string, string, uintptr)) uint32 { | |
| 576 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 577 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 578 | + | return gobject.SignalConnect(x.GoPointer(), "g-signal", cbRefPtr) | |
| 579 | + | } | |
| 580 | + | ||
| 568 | 581 | fcb := func(clsPtr uintptr, SenderNameVarp string, SignalNameVarp string, ParametersVarp uintptr) { | |
| 569 | 582 | fa := DBusProxy{} | |
| 570 | 583 | fa.Ptr = clsPtr | |
| 584 | + | cbFn := *cb | |
| 571 | 585 | ||
| 572 | - | cb(fa, SenderNameVarp, SignalNameVarp, ParametersVarp) | |
| 586 | + | cbFn(fa, SenderNameVarp, SignalNameVarp, ParametersVarp) | |
| 573 | 587 | ||
| 574 | 588 | } | |
| 575 | - | return gobject.SignalConnect(x.GoPointer(), "g-signal", purego.NewCallback(fcb)) | |
| 589 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 590 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 591 | + | return gobject.SignalConnect(x.GoPointer(), "g-signal", cbRefPtr) | |
| 576 | 592 | } | |
| 577 | 593 | ||
| 578 | 594 | // Starts asynchronous initialization of the object implementing the | |
| @@ -611,9 +627,9 @@ func (x *DBusProxy) ConnectGSignal(cb func(DBusProxy, string, string, uintptr)) | |||
| 611 | 627 | // in a thread, so if you want to support asynchronous initialization via | |
| 612 | 628 | // threads, just implement the #GAsyncInitable interface without overriding | |
| 613 | 629 | // any interface methods. | |
| 614 | - | func (x *DBusProxy) InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 630 | + | func (x *DBusProxy) InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 615 | 631 | ||
| 616 | - | XGAsyncInitableInitAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 632 | + | XGAsyncInitableInitAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 617 | 633 | ||
| 618 | 634 | } | |
| 619 | 635 | ||
| @@ -778,9 +794,9 @@ var xDBusProxyNew func(uintptr, DBusProxyFlags, *DBusInterfaceInfo, string, stri | |||
| 778 | 794 | // See g_dbus_proxy_new_sync() and for a synchronous version of this constructor. | |
| 779 | 795 | // | |
| 780 | 796 | // #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. | |
| 781 | - | func DBusProxyNew(ConnectionVar *DBusConnection, FlagsVar DBusProxyFlags, InfoVar *DBusInterfaceInfo, NameVar string, ObjectPathVar string, InterfaceNameVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 797 | + | func DBusProxyNew(ConnectionVar *DBusConnection, FlagsVar DBusProxyFlags, InfoVar *DBusInterfaceInfo, NameVar string, ObjectPathVar string, InterfaceNameVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 782 | 798 | ||
| 783 | - | xDBusProxyNew(ConnectionVar.GoPointer(), FlagsVar, InfoVar, NameVar, ObjectPathVar, InterfaceNameVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 799 | + | xDBusProxyNew(ConnectionVar.GoPointer(), FlagsVar, InfoVar, NameVar, ObjectPathVar, InterfaceNameVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 784 | 800 | ||
| 785 | 801 | } | |
| 786 | 802 | ||
| @@ -789,9 +805,9 @@ var xDBusProxyNewForBus func(BusType, DBusProxyFlags, *DBusInterfaceInfo, string | |||
| 789 | 805 | // Like g_dbus_proxy_new() but takes a #GBusType instead of a #GDBusConnection. | |
| 790 | 806 | // | |
| 791 | 807 | // #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. | |
| 792 | - | func DBusProxyNewForBus(BusTypeVar BusType, FlagsVar DBusProxyFlags, InfoVar *DBusInterfaceInfo, NameVar string, ObjectPathVar string, InterfaceNameVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 808 | + | func DBusProxyNewForBus(BusTypeVar BusType, FlagsVar DBusProxyFlags, InfoVar *DBusInterfaceInfo, NameVar string, ObjectPathVar string, InterfaceNameVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 793 | 809 | ||
| 794 | - | xDBusProxyNewForBus(BusTypeVar, FlagsVar, InfoVar, NameVar, ObjectPathVar, InterfaceNameVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 810 | + | xDBusProxyNewForBus(BusTypeVar, FlagsVar, InfoVar, NameVar, ObjectPathVar, InterfaceNameVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 795 | 811 | ||
| 796 | 812 | } | |
| 797 | 813 | ||
M v4/gio/gdebugcontrollerdbus.go +11 -3
| @@ -219,15 +219,23 @@ func (c *DebugControllerDBus) SetGoPointer(ptr uintptr) { | |||
| 219 | 219 | // Signal handlers must not modify @invocation, or cause it to return a value. | |
| 220 | 220 | // | |
| 221 | 221 | // The default class handler just returns %TRUE. | |
| 222 | - | func (x *DebugControllerDBus) ConnectAuthorize(cb func(DebugControllerDBus, uintptr) bool) uint32 { | |
| 222 | + | func (x *DebugControllerDBus) ConnectAuthorize(cb *func(DebugControllerDBus, uintptr) bool) uint32 { | |
| 223 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 224 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 225 | + | return gobject.SignalConnect(x.GoPointer(), "authorize", cbRefPtr) | |
| 226 | + | } | |
| 227 | + | ||
| 223 | 228 | fcb := func(clsPtr uintptr, InvocationVarp uintptr) bool { | |
| 224 | 229 | fa := DebugControllerDBus{} | |
| 225 | 230 | fa.Ptr = clsPtr | |
| 231 | + | cbFn := *cb | |
| 226 | 232 | ||
| 227 | - | return cb(fa, InvocationVarp) | |
| 233 | + | return cbFn(fa, InvocationVarp) | |
| 228 | 234 | ||
| 229 | 235 | } | |
| 230 | - | return gobject.SignalConnect(x.GoPointer(), "authorize", purego.NewCallback(fcb)) | |
| 236 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 237 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 238 | + | return gobject.SignalConnect(x.GoPointer(), "authorize", cbRefPtr) | |
| 231 | 239 | } | |
| 232 | 240 | ||
| 233 | 241 | // Get the value of #GDebugController:debug-enabled. | |
M v4/gio/gdesktopappinfo.go +6 -6
| @@ -352,10 +352,10 @@ var xDesktopAppInfoLaunchUrisAsManager func(uintptr, *glib.List, uintptr, glib.S | |||
| 352 | 352 | // If application launching occurs via some other mechanism (eg: D-Bus | |
| 353 | 353 | // activation) then @spawn_flags, @user_setup, @user_setup_data, | |
| 354 | 354 | // @pid_callback and @pid_callback_data are ignored. | |
| 355 | - | func (x *DesktopAppInfo) LaunchUrisAsManager(UrisVar *glib.List, LaunchContextVar *AppLaunchContext, SpawnFlagsVar glib.SpawnFlags, UserSetupVar glib.SpawnChildSetupFunc, UserSetupDataVar uintptr, PidCallbackVar DesktopAppLaunchCallback, PidCallbackDataVar uintptr) (bool, error) { | |
| 355 | + | func (x *DesktopAppInfo) LaunchUrisAsManager(UrisVar *glib.List, LaunchContextVar *AppLaunchContext, SpawnFlagsVar glib.SpawnFlags, UserSetupVar *glib.SpawnChildSetupFunc, UserSetupDataVar uintptr, PidCallbackVar *DesktopAppLaunchCallback, PidCallbackDataVar uintptr) (bool, error) { | |
| 356 | 356 | var cerr *glib.Error | |
| 357 | 357 | ||
| 358 | - | cret := xDesktopAppInfoLaunchUrisAsManager(x.GoPointer(), UrisVar, LaunchContextVar.GoPointer(), SpawnFlagsVar, purego.NewCallback(UserSetupVar), UserSetupDataVar, purego.NewCallback(PidCallbackVar), PidCallbackDataVar, &cerr) | |
| 358 | + | cret := xDesktopAppInfoLaunchUrisAsManager(x.GoPointer(), UrisVar, LaunchContextVar.GoPointer(), SpawnFlagsVar, glib.NewCallback(UserSetupVar), UserSetupDataVar, glib.NewCallback(PidCallbackVar), PidCallbackDataVar, &cerr) | |
| 359 | 359 | if cerr == nil { | |
| 360 | 360 | return cret, nil | |
| 361 | 361 | } | |
| @@ -371,10 +371,10 @@ var xDesktopAppInfoLaunchUrisAsManagerWithFds func(uintptr, *glib.List, uintptr, | |||
| 371 | 371 | // | |
| 372 | 372 | // If application launching occurs via some non-spawn mechanism (e.g. D-Bus | |
| 373 | 373 | // activation) then @stdin_fd, @stdout_fd and @stderr_fd are ignored. | |
| 374 | - | func (x *DesktopAppInfo) LaunchUrisAsManagerWithFds(UrisVar *glib.List, LaunchContextVar *AppLaunchContext, SpawnFlagsVar glib.SpawnFlags, UserSetupVar glib.SpawnChildSetupFunc, UserSetupDataVar uintptr, PidCallbackVar DesktopAppLaunchCallback, PidCallbackDataVar uintptr, StdinFdVar int, StdoutFdVar int, StderrFdVar int) (bool, error) { | |
| 374 | + | func (x *DesktopAppInfo) LaunchUrisAsManagerWithFds(UrisVar *glib.List, LaunchContextVar *AppLaunchContext, SpawnFlagsVar glib.SpawnFlags, UserSetupVar *glib.SpawnChildSetupFunc, UserSetupDataVar uintptr, PidCallbackVar *DesktopAppLaunchCallback, PidCallbackDataVar uintptr, StdinFdVar int, StdoutFdVar int, StderrFdVar int) (bool, error) { | |
| 375 | 375 | var cerr *glib.Error | |
| 376 | 376 | ||
| 377 | - | cret := xDesktopAppInfoLaunchUrisAsManagerWithFds(x.GoPointer(), UrisVar, LaunchContextVar.GoPointer(), SpawnFlagsVar, purego.NewCallback(UserSetupVar), UserSetupDataVar, purego.NewCallback(PidCallbackVar), PidCallbackDataVar, StdinFdVar, StdoutFdVar, StderrFdVar, &cerr) | |
| 377 | + | cret := xDesktopAppInfoLaunchUrisAsManagerWithFds(x.GoPointer(), UrisVar, LaunchContextVar.GoPointer(), SpawnFlagsVar, glib.NewCallback(UserSetupVar), UserSetupDataVar, glib.NewCallback(PidCallbackVar), PidCallbackDataVar, StdinFdVar, StdoutFdVar, StderrFdVar, &cerr) | |
| 378 | 378 | if cerr == nil { | |
| 379 | 379 | return cret, nil | |
| 380 | 380 | } | |
| @@ -609,9 +609,9 @@ func (x *DesktopAppInfo) LaunchUris(UrisVar *glib.List, ContextVar *AppLaunchCon | |||
| 609 | 609 | // waits for activation in case of D-Bus–activated applications and also provides | |
| 610 | 610 | // extended error information for sandboxed applications, see notes for | |
| 611 | 611 | // g_app_info_launch_default_for_uri_async(). | |
| 612 | - | func (x *DesktopAppInfo) LaunchUrisAsync(UrisVar *glib.List, ContextVar *AppLaunchContext, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 612 | + | func (x *DesktopAppInfo) LaunchUrisAsync(UrisVar *glib.List, ContextVar *AppLaunchContext, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 613 | 613 | ||
| 614 | - | XGAppInfoLaunchUrisAsync(x.GoPointer(), UrisVar, ContextVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 614 | + | XGAppInfoLaunchUrisAsync(x.GoPointer(), UrisVar, ContextVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 615 | 615 | ||
| 616 | 616 | } | |
| 617 | 617 | ||
M v4/gio/gdrive.go +15 -15
| @@ -52,9 +52,9 @@ type Drive interface { | |||
| 52 | 52 | CanStart() bool | |
| 53 | 53 | CanStartDegraded() bool | |
| 54 | 54 | CanStop() bool | |
| 55 | - | Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 55 | + | Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 56 | 56 | EjectFinish(ResultVar AsyncResult) bool | |
| 57 | - | EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 57 | + | EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 58 | 58 | EjectWithOperationFinish(ResultVar AsyncResult) bool | |
| 59 | 59 | EnumerateIdentifiers() []string | |
| 60 | 60 | GetIcon() *IconBase | |
| @@ -69,11 +69,11 @@ type Drive interface { | |||
| 69 | 69 | IsMediaCheckAutomatic() bool | |
| 70 | 70 | IsMediaRemovable() bool | |
| 71 | 71 | IsRemovable() bool | |
| 72 | - | PollForMedia(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 72 | + | PollForMedia(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 73 | 73 | PollForMediaFinish(ResultVar AsyncResult) bool | |
| 74 | - | Start(FlagsVar DriveStartFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 74 | + | Start(FlagsVar DriveStartFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 75 | 75 | StartFinish(ResultVar AsyncResult) bool | |
| 76 | - | Stop(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 76 | + | Stop(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 77 | 77 | StopFinish(ResultVar AsyncResult) bool | |
| 78 | 78 | } | |
| 79 | 79 | type DriveBase struct { | |
| @@ -128,9 +128,9 @@ func (x *DriveBase) CanStop() bool { | |||
| 128 | 128 | // When the operation is finished, @callback will be called. | |
| 129 | 129 | // You can then call g_drive_eject_finish() to obtain the | |
| 130 | 130 | // result of the operation. | |
| 131 | - | func (x *DriveBase) Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 131 | + | func (x *DriveBase) Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 132 | 132 | ||
| 133 | - | XGDriveEject(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 133 | + | XGDriveEject(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 134 | 134 | ||
| 135 | 135 | } | |
| 136 | 136 | ||
| @@ -149,9 +149,9 @@ func (x *DriveBase) EjectFinish(ResultVar AsyncResult) (bool, error) { | |||
| 149 | 149 | // Ejects a drive. This is an asynchronous operation, and is | |
| 150 | 150 | // finished by calling g_drive_eject_with_operation_finish() with the @drive | |
| 151 | 151 | // and #GAsyncResult data returned in the @callback. | |
| 152 | - | func (x *DriveBase) EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 152 | + | func (x *DriveBase) EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 153 | 153 | ||
| 154 | - | XGDriveEjectWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 154 | + | XGDriveEjectWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 155 | 155 | ||
| 156 | 156 | } | |
| 157 | 157 | ||
| @@ -288,9 +288,9 @@ func (x *DriveBase) IsRemovable() bool { | |||
| 288 | 288 | // When the operation is finished, @callback will be called. | |
| 289 | 289 | // You can then call g_drive_poll_for_media_finish() to obtain the | |
| 290 | 290 | // result of the operation. | |
| 291 | - | func (x *DriveBase) PollForMedia(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 291 | + | func (x *DriveBase) PollForMedia(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 292 | 292 | ||
| 293 | - | XGDrivePollForMedia(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 293 | + | XGDrivePollForMedia(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 294 | 294 | ||
| 295 | 295 | } | |
| 296 | 296 | ||
| @@ -311,9 +311,9 @@ func (x *DriveBase) PollForMediaFinish(ResultVar AsyncResult) (bool, error) { | |||
| 311 | 311 | // When the operation is finished, @callback will be called. | |
| 312 | 312 | // You can then call g_drive_start_finish() to obtain the | |
| 313 | 313 | // result of the operation. | |
| 314 | - | func (x *DriveBase) Start(FlagsVar DriveStartFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 314 | + | func (x *DriveBase) Start(FlagsVar DriveStartFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 315 | 315 | ||
| 316 | - | XGDriveStart(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 316 | + | XGDriveStart(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 317 | 317 | ||
| 318 | 318 | } | |
| 319 | 319 | ||
| @@ -334,9 +334,9 @@ func (x *DriveBase) StartFinish(ResultVar AsyncResult) (bool, error) { | |||
| 334 | 334 | // When the operation is finished, @callback will be called. | |
| 335 | 335 | // You can then call g_drive_stop_finish() to obtain the | |
| 336 | 336 | // result of the operation. | |
| 337 | - | func (x *DriveBase) Stop(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 337 | + | func (x *DriveBase) Stop(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 338 | 338 | ||
| 339 | - | XGDriveStop(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 339 | + | XGDriveStop(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 340 | 340 | ||
| 341 | 341 | } | |
| 342 | 342 | ||
M v4/gio/gdtlsconnection.go +9 -9
| @@ -42,7 +42,7 @@ type DtlsConnection interface { | |||
| 42 | 42 | GoPointer() uintptr | |
| 43 | 43 | SetGoPointer(uintptr) | |
| 44 | 44 | Close(CancellableVar *Cancellable) bool | |
| 45 | - | CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 45 | + | CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 46 | 46 | CloseFinish(ResultVar AsyncResult) bool | |
| 47 | 47 | EmitAcceptCertificate(PeerCertVar *TlsCertificate, ErrorsVar TlsCertificateFlags) bool | |
| 48 | 48 | GetCertificate() *TlsCertificate | |
| @@ -57,7 +57,7 @@ type DtlsConnection interface { | |||
| 57 | 57 | GetRehandshakeMode() TlsRehandshakeMode | |
| 58 | 58 | GetRequireCloseNotify() bool | |
| 59 | 59 | Handshake(CancellableVar *Cancellable) bool | |
| 60 | - | HandshakeAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 60 | + | HandshakeAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 61 | 61 | HandshakeFinish(ResultVar AsyncResult) bool | |
| 62 | 62 | SetAdvertisedProtocols(ProtocolsVar uintptr) | |
| 63 | 63 | SetCertificate(CertificateVar *TlsCertificate) | |
| @@ -66,7 +66,7 @@ type DtlsConnection interface { | |||
| 66 | 66 | SetRehandshakeMode(ModeVar TlsRehandshakeMode) | |
| 67 | 67 | SetRequireCloseNotify(RequireCloseNotifyVar bool) | |
| 68 | 68 | Shutdown(ShutdownReadVar bool, ShutdownWriteVar bool, CancellableVar *Cancellable) bool | |
| 69 | - | ShutdownAsync(ShutdownReadVar bool, ShutdownWriteVar bool, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 69 | + | ShutdownAsync(ShutdownReadVar bool, ShutdownWriteVar bool, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 70 | 70 | ShutdownFinish(ResultVar AsyncResult) bool | |
| 71 | 71 | } | |
| 72 | 72 | type DtlsConnectionBase struct { | |
| @@ -113,9 +113,9 @@ func (x *DtlsConnectionBase) Close(CancellableVar *Cancellable) (bool, error) { | |||
| 113 | 113 | ||
| 114 | 114 | // Asynchronously close the DTLS connection. See g_dtls_connection_close() for | |
| 115 | 115 | // more information. | |
| 116 | - | func (x *DtlsConnectionBase) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 116 | + | func (x *DtlsConnectionBase) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 117 | 117 | ||
| 118 | - | XGDtlsConnectionCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 118 | + | XGDtlsConnectionCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 119 | 119 | ||
| 120 | 120 | } | |
| 121 | 121 | ||
| @@ -332,9 +332,9 @@ func (x *DtlsConnectionBase) Handshake(CancellableVar *Cancellable) (bool, error | |||
| 332 | 332 | ||
| 333 | 333 | // Asynchronously performs a TLS handshake on @conn. See | |
| 334 | 334 | // g_dtls_connection_handshake() for more information. | |
| 335 | - | func (x *DtlsConnectionBase) HandshakeAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 335 | + | func (x *DtlsConnectionBase) HandshakeAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 336 | 336 | ||
| 337 | - | XGDtlsConnectionHandshakeAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 337 | + | XGDtlsConnectionHandshakeAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 338 | 338 | ||
| 339 | 339 | } | |
| 340 | 340 | ||
| @@ -490,9 +490,9 @@ func (x *DtlsConnectionBase) Shutdown(ShutdownReadVar bool, ShutdownWriteVar boo | |||
| 490 | 490 | ||
| 491 | 491 | // Asynchronously shut down part or all of the DTLS connection. See | |
| 492 | 492 | // g_dtls_connection_shutdown() for more information. | |
| 493 | - | func (x *DtlsConnectionBase) ShutdownAsync(ShutdownReadVar bool, ShutdownWriteVar bool, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 493 | + | func (x *DtlsConnectionBase) ShutdownAsync(ShutdownReadVar bool, ShutdownWriteVar bool, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 494 | 494 | ||
| 495 | - | XGDtlsConnectionShutdownAsync(x.GoPointer(), ShutdownReadVar, ShutdownWriteVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 495 | + | XGDtlsConnectionShutdownAsync(x.GoPointer(), ShutdownReadVar, ShutdownWriteVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 496 | 496 | ||
| 497 | 497 | } | |
| 498 | 498 | ||
M v4/gio/gfile.go +111 -111
| @@ -106,33 +106,33 @@ type File interface { | |||
| 106 | 106 | GoPointer() uintptr | |
| 107 | 107 | SetGoPointer(uintptr) | |
| 108 | 108 | AppendTo(FlagsVar FileCreateFlags, CancellableVar *Cancellable) *FileOutputStream | |
| 109 | - | AppendToAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 109 | + | AppendToAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 110 | 110 | AppendToFinish(ResVar AsyncResult) *FileOutputStream | |
| 111 | 111 | BuildAttributeListForCopy(FlagsVar FileCopyFlags, CancellableVar *Cancellable) string | |
| 112 | - | Copy(DestinationVar File, FlagsVar FileCopyFlags, CancellableVar *Cancellable, ProgressCallbackVar FileProgressCallback, ProgressCallbackDataVar uintptr) bool | |
| 113 | - | CopyAsync(DestinationVar File, FlagsVar FileCopyFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar FileProgressCallback, ProgressCallbackDataVar uintptr, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 112 | + | Copy(DestinationVar File, FlagsVar FileCopyFlags, CancellableVar *Cancellable, ProgressCallbackVar *FileProgressCallback, ProgressCallbackDataVar uintptr) bool | |
| 113 | + | CopyAsync(DestinationVar File, FlagsVar FileCopyFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar *FileProgressCallback, ProgressCallbackDataVar uintptr, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 114 | 114 | CopyAttributes(DestinationVar File, FlagsVar FileCopyFlags, CancellableVar *Cancellable) bool | |
| 115 | 115 | CopyFinish(ResVar AsyncResult) bool | |
| 116 | 116 | Create(FlagsVar FileCreateFlags, CancellableVar *Cancellable) *FileOutputStream | |
| 117 | - | CreateAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 117 | + | CreateAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 118 | 118 | CreateFinish(ResVar AsyncResult) *FileOutputStream | |
| 119 | 119 | CreateReadwrite(FlagsVar FileCreateFlags, CancellableVar *Cancellable) *FileIOStream | |
| 120 | - | CreateReadwriteAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 120 | + | CreateReadwriteAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 121 | 121 | CreateReadwriteFinish(ResVar AsyncResult) *FileIOStream | |
| 122 | 122 | Delete(CancellableVar *Cancellable) bool | |
| 123 | - | DeleteAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 123 | + | DeleteAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 124 | 124 | DeleteFinish(ResultVar AsyncResult) bool | |
| 125 | 125 | Dup() *FileBase | |
| 126 | - | EjectMountable(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 126 | + | EjectMountable(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 127 | 127 | EjectMountableFinish(ResultVar AsyncResult) bool | |
| 128 | - | EjectMountableWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 128 | + | EjectMountableWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 129 | 129 | EjectMountableWithOperationFinish(ResultVar AsyncResult) bool | |
| 130 | 130 | EnumerateChildren(AttributesVar string, FlagsVar FileQueryInfoFlags, CancellableVar *Cancellable) *FileEnumerator | |
| 131 | - | EnumerateChildrenAsync(AttributesVar string, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 131 | + | EnumerateChildrenAsync(AttributesVar string, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 132 | 132 | EnumerateChildrenFinish(ResVar AsyncResult) *FileEnumerator | |
| 133 | 133 | Equal(File2Var File) bool | |
| 134 | 134 | FindEnclosingMount(CancellableVar *Cancellable) *MountBase | |
| 135 | - | FindEnclosingMountAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 135 | + | FindEnclosingMountAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 136 | 136 | FindEnclosingMountFinish(ResVar AsyncResult) *MountBase | |
| 137 | 137 | GetBasename() string | |
| 138 | 138 | GetChild(NameVar string) *FileBase | |
| @@ -149,62 +149,62 @@ type File interface { | |||
| 149 | 149 | Hash() uint | |
| 150 | 150 | IsNative() bool | |
| 151 | 151 | LoadBytes(CancellableVar *Cancellable, EtagOutVar string) *glib.Bytes | |
| 152 | - | LoadBytesAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 152 | + | LoadBytesAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 153 | 153 | LoadBytesFinish(ResultVar AsyncResult, EtagOutVar string) *glib.Bytes | |
| 154 | 154 | LoadContents(CancellableVar *Cancellable, ContentsVar []string, LengthVar uint, EtagOutVar string) bool | |
| 155 | - | LoadContentsAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 155 | + | LoadContentsAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 156 | 156 | LoadContentsFinish(ResVar AsyncResult, ContentsVar []string, LengthVar uint, EtagOutVar string) bool | |
| 157 | - | LoadPartialContentsAsync(CancellableVar *Cancellable, ReadMoreCallbackVar FileReadMoreCallback, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 157 | + | LoadPartialContentsAsync(CancellableVar *Cancellable, ReadMoreCallbackVar *FileReadMoreCallback, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 158 | 158 | LoadPartialContentsFinish(ResVar AsyncResult, ContentsVar []string, LengthVar uint, EtagOutVar string) bool | |
| 159 | 159 | MakeDirectory(CancellableVar *Cancellable) bool | |
| 160 | - | MakeDirectoryAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 160 | + | MakeDirectoryAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 161 | 161 | MakeDirectoryFinish(ResultVar AsyncResult) bool | |
| 162 | 162 | MakeDirectoryWithParents(CancellableVar *Cancellable) bool | |
| 163 | 163 | MakeSymbolicLink(SymlinkValueVar string, CancellableVar *Cancellable) bool | |
| 164 | - | MeasureDiskUsage(FlagsVar FileMeasureFlags, CancellableVar *Cancellable, ProgressCallbackVar FileMeasureProgressCallback, ProgressDataVar uintptr, DiskUsageVar uint64, NumDirsVar uint64, NumFilesVar uint64) bool | |
| 165 | - | MeasureDiskUsageAsync(FlagsVar FileMeasureFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar FileMeasureProgressCallback, ProgressDataVar uintptr, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 164 | + | MeasureDiskUsage(FlagsVar FileMeasureFlags, CancellableVar *Cancellable, ProgressCallbackVar *FileMeasureProgressCallback, ProgressDataVar uintptr, DiskUsageVar uint64, NumDirsVar uint64, NumFilesVar uint64) bool | |
| 165 | + | MeasureDiskUsageAsync(FlagsVar FileMeasureFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar *FileMeasureProgressCallback, ProgressDataVar uintptr, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 166 | 166 | MeasureDiskUsageFinish(ResultVar AsyncResult, DiskUsageVar uint64, NumDirsVar uint64, NumFilesVar uint64) bool | |
| 167 | 167 | Monitor(FlagsVar FileMonitorFlags, CancellableVar *Cancellable) *FileMonitor | |
| 168 | 168 | MonitorDirectory(FlagsVar FileMonitorFlags, CancellableVar *Cancellable) *FileMonitor | |
| 169 | 169 | MonitorFile(FlagsVar FileMonitorFlags, CancellableVar *Cancellable) *FileMonitor | |
| 170 | - | MountEnclosingVolume(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 170 | + | MountEnclosingVolume(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 171 | 171 | MountEnclosingVolumeFinish(ResultVar AsyncResult) bool | |
| 172 | - | MountMountable(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 172 | + | MountMountable(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 173 | 173 | MountMountableFinish(ResultVar AsyncResult) *FileBase | |
| 174 | - | Move(DestinationVar File, FlagsVar FileCopyFlags, CancellableVar *Cancellable, ProgressCallbackVar FileProgressCallback, ProgressCallbackDataVar uintptr) bool | |
| 175 | - | MoveAsync(DestinationVar File, FlagsVar FileCopyFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar FileProgressCallback, ProgressCallbackDataVar uintptr, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 174 | + | Move(DestinationVar File, FlagsVar FileCopyFlags, CancellableVar *Cancellable, ProgressCallbackVar *FileProgressCallback, ProgressCallbackDataVar uintptr) bool | |
| 175 | + | MoveAsync(DestinationVar File, FlagsVar FileCopyFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar *FileProgressCallback, ProgressCallbackDataVar uintptr, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 176 | 176 | MoveFinish(ResultVar AsyncResult) bool | |
| 177 | 177 | OpenReadwrite(CancellableVar *Cancellable) *FileIOStream | |
| 178 | - | OpenReadwriteAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 178 | + | OpenReadwriteAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 179 | 179 | OpenReadwriteFinish(ResVar AsyncResult) *FileIOStream | |
| 180 | 180 | PeekPath() string | |
| 181 | - | PollMountable(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 181 | + | PollMountable(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 182 | 182 | PollMountableFinish(ResultVar AsyncResult) bool | |
| 183 | 183 | QueryDefaultHandler(CancellableVar *Cancellable) *AppInfoBase | |
| 184 | - | QueryDefaultHandlerAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 184 | + | QueryDefaultHandlerAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 185 | 185 | QueryDefaultHandlerFinish(ResultVar AsyncResult) *AppInfoBase | |
| 186 | 186 | QueryExists(CancellableVar *Cancellable) bool | |
| 187 | 187 | QueryFileType(FlagsVar FileQueryInfoFlags, CancellableVar *Cancellable) FileType | |
| 188 | 188 | QueryFilesystemInfo(AttributesVar string, CancellableVar *Cancellable) *FileInfo | |
| 189 | - | QueryFilesystemInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 189 | + | QueryFilesystemInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 190 | 190 | QueryFilesystemInfoFinish(ResVar AsyncResult) *FileInfo | |
| 191 | 191 | QueryInfo(AttributesVar string, FlagsVar FileQueryInfoFlags, CancellableVar *Cancellable) *FileInfo | |
| 192 | - | QueryInfoAsync(AttributesVar string, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 192 | + | QueryInfoAsync(AttributesVar string, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 193 | 193 | QueryInfoFinish(ResVar AsyncResult) *FileInfo | |
| 194 | 194 | QuerySettableAttributes(CancellableVar *Cancellable) *FileAttributeInfoList | |
| 195 | 195 | QueryWritableNamespaces(CancellableVar *Cancellable) *FileAttributeInfoList | |
| 196 | 196 | Read(CancellableVar *Cancellable) *FileInputStream | |
| 197 | - | ReadAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 197 | + | ReadAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 198 | 198 | ReadFinish(ResVar AsyncResult) *FileInputStream | |
| 199 | 199 | Replace(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable) *FileOutputStream | |
| 200 | - | ReplaceAsync(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 200 | + | ReplaceAsync(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 201 | 201 | ReplaceContents(ContentsVar string, LengthVar uint, EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, NewEtagVar string, CancellableVar *Cancellable) bool | |
| 202 | - | ReplaceContentsAsync(ContentsVar string, LengthVar uint, EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 203 | - | ReplaceContentsBytesAsync(ContentsVar *glib.Bytes, EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 202 | + | ReplaceContentsAsync(ContentsVar string, LengthVar uint, EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 203 | + | ReplaceContentsBytesAsync(ContentsVar *glib.Bytes, EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 204 | 204 | ReplaceContentsFinish(ResVar AsyncResult, NewEtagVar string) bool | |
| 205 | 205 | ReplaceFinish(ResVar AsyncResult) *FileOutputStream | |
| 206 | 206 | ReplaceReadwrite(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable) *FileIOStream | |
| 207 | - | ReplaceReadwriteAsync(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 207 | + | ReplaceReadwriteAsync(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 208 | 208 | ReplaceReadwriteFinish(ResVar AsyncResult) *FileIOStream | |
| 209 | 209 | ResolveRelativePath(RelativePathVar string) *FileBase | |
| 210 | 210 | SetAttribute(AttributeVar string, TypeVar FileAttributeType, ValuePVar uintptr, FlagsVar FileQueryInfoFlags, CancellableVar *Cancellable) bool | |
| @@ -214,23 +214,23 @@ type File interface { | |||
| 214 | 214 | SetAttributeString(AttributeVar string, ValueVar string, FlagsVar FileQueryInfoFlags, CancellableVar *Cancellable) bool | |
| 215 | 215 | SetAttributeUint32(AttributeVar string, ValueVar uint32, FlagsVar FileQueryInfoFlags, CancellableVar *Cancellable) bool | |
| 216 | 216 | SetAttributeUint64(AttributeVar string, ValueVar uint64, FlagsVar FileQueryInfoFlags, CancellableVar *Cancellable) bool | |
| 217 | - | SetAttributesAsync(InfoVar *FileInfo, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 217 | + | SetAttributesAsync(InfoVar *FileInfo, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 218 | 218 | SetAttributesFinish(ResultVar AsyncResult, InfoVar **FileInfo) bool | |
| 219 | 219 | SetAttributesFromInfo(InfoVar *FileInfo, FlagsVar FileQueryInfoFlags, CancellableVar *Cancellable) bool | |
| 220 | 220 | SetDisplayName(DisplayNameVar string, CancellableVar *Cancellable) *FileBase | |
| 221 | - | SetDisplayNameAsync(DisplayNameVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 221 | + | SetDisplayNameAsync(DisplayNameVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 222 | 222 | SetDisplayNameFinish(ResVar AsyncResult) *FileBase | |
| 223 | - | StartMountable(FlagsVar DriveStartFlags, StartOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 223 | + | StartMountable(FlagsVar DriveStartFlags, StartOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 224 | 224 | StartMountableFinish(ResultVar AsyncResult) bool | |
| 225 | - | StopMountable(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 225 | + | StopMountable(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 226 | 226 | StopMountableFinish(ResultVar AsyncResult) bool | |
| 227 | 227 | SupportsThreadContexts() bool | |
| 228 | 228 | Trash(CancellableVar *Cancellable) bool | |
| 229 | - | TrashAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 229 | + | TrashAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 230 | 230 | TrashFinish(ResultVar AsyncResult) bool | |
| 231 | - | UnmountMountable(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 231 | + | UnmountMountable(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 232 | 232 | UnmountMountableFinish(ResultVar AsyncResult) bool | |
| 233 | - | UnmountMountableWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 233 | + | UnmountMountableWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 234 | 234 | UnmountMountableWithOperationFinish(ResultVar AsyncResult) bool | |
| 235 | 235 | } | |
| 236 | 236 | type FileBase struct { | |
| @@ -288,9 +288,9 @@ func (x *FileBase) AppendTo(FlagsVar FileCreateFlags, CancellableVar *Cancellabl | |||
| 288 | 288 | // When the operation is finished, @callback will be called. | |
| 289 | 289 | // You can then call g_file_append_to_finish() to get the result | |
| 290 | 290 | // of the operation. | |
| 291 | - | func (x *FileBase) AppendToAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 291 | + | func (x *FileBase) AppendToAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 292 | 292 | ||
| 293 | - | XGFileAppendToAsync(x.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 293 | + | XGFileAppendToAsync(x.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 294 | 294 | ||
| 295 | 295 | } | |
| 296 | 296 | ||
| @@ -374,10 +374,10 @@ func (x *FileBase) BuildAttributeListForCopy(FlagsVar FileCopyFlags, Cancellable | |||
| 374 | 374 | // | |
| 375 | 375 | // If you are interested in copying the #GFile object itself (not the on-disk | |
| 376 | 376 | // file), see g_file_dup(). | |
| 377 | - | func (x *FileBase) Copy(DestinationVar File, FlagsVar FileCopyFlags, CancellableVar *Cancellable, ProgressCallbackVar FileProgressCallback, ProgressCallbackDataVar uintptr) (bool, error) { | |
| 377 | + | func (x *FileBase) Copy(DestinationVar File, FlagsVar FileCopyFlags, CancellableVar *Cancellable, ProgressCallbackVar *FileProgressCallback, ProgressCallbackDataVar uintptr) (bool, error) { | |
| 378 | 378 | var cerr *glib.Error | |
| 379 | 379 | ||
| 380 | - | cret := XGFileCopy(x.GoPointer(), DestinationVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(ProgressCallbackVar), ProgressCallbackDataVar, &cerr) | |
| 380 | + | cret := XGFileCopy(x.GoPointer(), DestinationVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(ProgressCallbackVar), ProgressCallbackDataVar, &cerr) | |
| 381 | 381 | if cerr == nil { | |
| 382 | 382 | return cret, nil | |
| 383 | 383 | } | |
| @@ -395,9 +395,9 @@ func (x *FileBase) Copy(DestinationVar File, FlagsVar FileCopyFlags, Cancellable | |||
| 395 | 395 | // | |
| 396 | 396 | // When the operation is finished, @callback will be called. You can then call | |
| 397 | 397 | // g_file_copy_finish() to get the result of the operation. | |
| 398 | - | func (x *FileBase) CopyAsync(DestinationVar File, FlagsVar FileCopyFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar FileProgressCallback, ProgressCallbackDataVar uintptr, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 398 | + | func (x *FileBase) CopyAsync(DestinationVar File, FlagsVar FileCopyFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar *FileProgressCallback, ProgressCallbackDataVar uintptr, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 399 | 399 | ||
| 400 | - | XGFileCopyAsync(x.GoPointer(), DestinationVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(ProgressCallbackVar), ProgressCallbackDataVar, purego.NewCallback(CallbackVar), UserDataVar) | |
| 400 | + | XGFileCopyAsync(x.GoPointer(), DestinationVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(ProgressCallbackVar), ProgressCallbackDataVar, glib.NewCallback(CallbackVar), UserDataVar) | |
| 401 | 401 | ||
| 402 | 402 | } | |
| 403 | 403 | ||
| @@ -478,9 +478,9 @@ func (x *FileBase) Create(FlagsVar FileCreateFlags, CancellableVar *Cancellable) | |||
| 478 | 478 | // When the operation is finished, @callback will be called. | |
| 479 | 479 | // You can then call g_file_create_finish() to get the result | |
| 480 | 480 | // of the operation. | |
| 481 | - | func (x *FileBase) CreateAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 481 | + | func (x *FileBase) CreateAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 482 | 482 | ||
| 483 | - | XGFileCreateAsync(x.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 483 | + | XGFileCreateAsync(x.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 484 | 484 | ||
| 485 | 485 | } | |
| 486 | 486 | ||
| @@ -554,9 +554,9 @@ func (x *FileBase) CreateReadwrite(FlagsVar FileCreateFlags, CancellableVar *Can | |||
| 554 | 554 | // When the operation is finished, @callback will be called. | |
| 555 | 555 | // You can then call g_file_create_readwrite_finish() to get | |
| 556 | 556 | // the result of the operation. | |
| 557 | - | func (x *FileBase) CreateReadwriteAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 557 | + | func (x *FileBase) CreateReadwriteAsync(FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 558 | 558 | ||
| 559 | - | XGFileCreateReadwriteAsync(x.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 559 | + | XGFileCreateReadwriteAsync(x.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 560 | 560 | ||
| 561 | 561 | } | |
| 562 | 562 | ||
| @@ -617,9 +617,9 @@ func (x *FileBase) Delete(CancellableVar *Cancellable) (bool, error) { | |||
| 617 | 617 | // Asynchronously delete a file. If the @file is a directory, it will | |
| 618 | 618 | // only be deleted if it is empty. This has the same semantics as | |
| 619 | 619 | // g_unlink(). | |
| 620 | - | func (x *FileBase) DeleteAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 620 | + | func (x *FileBase) DeleteAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 621 | 621 | ||
| 622 | - | XGFileDeleteAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 622 | + | XGFileDeleteAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 623 | 623 | ||
| 624 | 624 | } | |
| 625 | 625 | ||
| @@ -666,9 +666,9 @@ func (x *FileBase) Dup() *FileBase { | |||
| 666 | 666 | // If @cancellable is not %NULL, then the operation can be cancelled by | |
| 667 | 667 | // triggering the cancellable object from another thread. If the operation | |
| 668 | 668 | // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. | |
| 669 | - | func (x *FileBase) EjectMountable(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 669 | + | func (x *FileBase) EjectMountable(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 670 | 670 | ||
| 671 | - | XGFileEjectMountable(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 671 | + | XGFileEjectMountable(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 672 | 672 | ||
| 673 | 673 | } | |
| 674 | 674 | ||
| @@ -693,9 +693,9 @@ func (x *FileBase) EjectMountableFinish(ResultVar AsyncResult) (bool, error) { | |||
| 693 | 693 | // If @cancellable is not %NULL, then the operation can be cancelled by | |
| 694 | 694 | // triggering the cancellable object from another thread. If the operation | |
| 695 | 695 | // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. | |
| 696 | - | func (x *FileBase) EjectMountableWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 696 | + | func (x *FileBase) EjectMountableWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 697 | 697 | ||
| 698 | - | XGFileEjectMountableWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 698 | + | XGFileEjectMountableWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 699 | 699 | ||
| 700 | 700 | } | |
| 701 | 701 | ||
| @@ -765,9 +765,9 @@ func (x *FileBase) EnumerateChildren(AttributesVar string, FlagsVar FileQueryInf | |||
| 765 | 765 | // When the operation is finished, @callback will be called. You can | |
| 766 | 766 | // then call g_file_enumerate_children_finish() to get the result of | |
| 767 | 767 | // the operation. | |
| 768 | - | func (x *FileBase) EnumerateChildrenAsync(AttributesVar string, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 768 | + | func (x *FileBase) EnumerateChildrenAsync(AttributesVar string, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 769 | 769 | ||
| 770 | - | XGFileEnumerateChildrenAsync(x.GoPointer(), AttributesVar, FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 770 | + | XGFileEnumerateChildrenAsync(x.GoPointer(), AttributesVar, FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 771 | 771 | ||
| 772 | 772 | } | |
| 773 | 773 | ||
| @@ -839,9 +839,9 @@ func (x *FileBase) FindEnclosingMount(CancellableVar *Cancellable) (*MountBase, | |||
| 839 | 839 | // When the operation is finished, @callback will be called. | |
| 840 | 840 | // You can then call g_file_find_enclosing_mount_finish() to | |
| 841 | 841 | // get the result of the operation. | |
| 842 | - | func (x *FileBase) FindEnclosingMountAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 842 | + | func (x *FileBase) FindEnclosingMountAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 843 | 843 | ||
| 844 | - | XGFileFindEnclosingMountAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 844 | + | XGFileFindEnclosingMountAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 845 | 845 | ||
| 846 | 846 | } | |
| 847 | 847 | ||
| @@ -1111,9 +1111,9 @@ func (x *FileBase) LoadBytes(CancellableVar *Cancellable, EtagOutVar string) (*g | |||
| 1111 | 1111 | // asynchronous operation. | |
| 1112 | 1112 | // | |
| 1113 | 1113 | // See g_file_load_bytes() for more information. | |
| 1114 | - | func (x *FileBase) LoadBytesAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1114 | + | func (x *FileBase) LoadBytesAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1115 | 1115 | ||
| 1116 | - | XGFileLoadBytesAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1116 | + | XGFileLoadBytesAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1117 | 1117 | ||
| 1118 | 1118 | } | |
| 1119 | 1119 | ||
| @@ -1169,9 +1169,9 @@ func (x *FileBase) LoadContents(CancellableVar *Cancellable, ContentsVar []strin | |||
| 1169 | 1169 | // If @cancellable is not %NULL, then the operation can be cancelled by | |
| 1170 | 1170 | // triggering the cancellable object from another thread. If the operation | |
| 1171 | 1171 | // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. | |
| 1172 | - | func (x *FileBase) LoadContentsAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1172 | + | func (x *FileBase) LoadContentsAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1173 | 1173 | ||
| 1174 | - | XGFileLoadContentsAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1174 | + | XGFileLoadContentsAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1175 | 1175 | ||
| 1176 | 1176 | } | |
| 1177 | 1177 | ||
| @@ -1202,9 +1202,9 @@ func (x *FileBase) LoadContentsFinish(ResVar AsyncResult, ContentsVar []string, | |||
| 1202 | 1202 | // If @cancellable is not %NULL, then the operation can be cancelled by | |
| 1203 | 1203 | // triggering the cancellable object from another thread. If the operation | |
| 1204 | 1204 | // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. | |
| 1205 | - | func (x *FileBase) LoadPartialContentsAsync(CancellableVar *Cancellable, ReadMoreCallbackVar FileReadMoreCallback, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1205 | + | func (x *FileBase) LoadPartialContentsAsync(CancellableVar *Cancellable, ReadMoreCallbackVar *FileReadMoreCallback, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1206 | 1206 | ||
| 1207 | - | XGFileLoadPartialContentsAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(ReadMoreCallbackVar), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1207 | + | XGFileLoadPartialContentsAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(ReadMoreCallbackVar), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1208 | 1208 | ||
| 1209 | 1209 | } | |
| 1210 | 1210 | ||
| @@ -1250,9 +1250,9 @@ func (x *FileBase) MakeDirectory(CancellableVar *Cancellable) (bool, error) { | |||
| 1250 | 1250 | } | |
| 1251 | 1251 | ||
| 1252 | 1252 | // Asynchronously creates a directory. | |
| 1253 | - | func (x *FileBase) MakeDirectoryAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1253 | + | func (x *FileBase) MakeDirectoryAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1254 | 1254 | ||
| 1255 | - | XGFileMakeDirectoryAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1255 | + | XGFileMakeDirectoryAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1256 | 1256 | ||
| 1257 | 1257 | } | |
| 1258 | 1258 | ||
| @@ -1328,10 +1328,10 @@ func (x *FileBase) MakeSymbolicLink(SymlinkValueVar string, CancellableVar *Canc | |||
| 1328 | 1328 | // periodic progress updates while scanning. See the documentation for | |
| 1329 | 1329 | // #GFileMeasureProgressCallback for information about when and how the | |
| 1330 | 1330 | // callback will be invoked. | |
| 1331 | - | func (x *FileBase) MeasureDiskUsage(FlagsVar FileMeasureFlags, CancellableVar *Cancellable, ProgressCallbackVar FileMeasureProgressCallback, ProgressDataVar uintptr, DiskUsageVar uint64, NumDirsVar uint64, NumFilesVar uint64) (bool, error) { | |
| 1331 | + | func (x *FileBase) MeasureDiskUsage(FlagsVar FileMeasureFlags, CancellableVar *Cancellable, ProgressCallbackVar *FileMeasureProgressCallback, ProgressDataVar uintptr, DiskUsageVar uint64, NumDirsVar uint64, NumFilesVar uint64) (bool, error) { | |
| 1332 | 1332 | var cerr *glib.Error | |
| 1333 | 1333 | ||
| 1334 | - | cret := XGFileMeasureDiskUsage(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(ProgressCallbackVar), ProgressDataVar, DiskUsageVar, NumDirsVar, NumFilesVar, &cerr) | |
| 1334 | + | cret := XGFileMeasureDiskUsage(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(ProgressCallbackVar), ProgressDataVar, DiskUsageVar, NumDirsVar, NumFilesVar, &cerr) | |
| 1335 | 1335 | if cerr == nil { | |
| 1336 | 1336 | return cret, nil | |
| 1337 | 1337 | } | |
| @@ -1343,9 +1343,9 @@ func (x *FileBase) MeasureDiskUsage(FlagsVar FileMeasureFlags, CancellableVar *C | |||
| 1343 | 1343 | // | |
| 1344 | 1344 | // This is the asynchronous version of g_file_measure_disk_usage(). See | |
| 1345 | 1345 | // there for more information. | |
| 1346 | - | func (x *FileBase) MeasureDiskUsageAsync(FlagsVar FileMeasureFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar FileMeasureProgressCallback, ProgressDataVar uintptr, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1346 | + | func (x *FileBase) MeasureDiskUsageAsync(FlagsVar FileMeasureFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar *FileMeasureProgressCallback, ProgressDataVar uintptr, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1347 | 1347 | ||
| 1348 | - | XGFileMeasureDiskUsageAsync(x.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(ProgressCallbackVar), ProgressDataVar, purego.NewCallback(CallbackVar), UserDataVar) | |
| 1348 | + | XGFileMeasureDiskUsageAsync(x.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(ProgressCallbackVar), ProgressDataVar, glib.NewCallback(CallbackVar), UserDataVar) | |
| 1349 | 1349 | ||
| 1350 | 1350 | } | |
| 1351 | 1351 | ||
| @@ -1459,9 +1459,9 @@ func (x *FileBase) MonitorFile(FlagsVar FileMonitorFlags, CancellableVar *Cancel | |||
| 1459 | 1459 | // If @cancellable is not %NULL, then the operation can be cancelled by | |
| 1460 | 1460 | // triggering the cancellable object from another thread. If the operation | |
| 1461 | 1461 | // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. | |
| 1462 | - | func (x *FileBase) MountEnclosingVolume(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1462 | + | func (x *FileBase) MountEnclosingVolume(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1463 | 1463 | ||
| 1464 | - | XGFileMountEnclosingVolume(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1464 | + | XGFileMountEnclosingVolume(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1465 | 1465 | ||
| 1466 | 1466 | } | |
| 1467 | 1467 | ||
| @@ -1488,9 +1488,9 @@ func (x *FileBase) MountEnclosingVolumeFinish(ResultVar AsyncResult) (bool, erro | |||
| 1488 | 1488 | // When the operation is finished, @callback will be called. | |
| 1489 | 1489 | // You can then call g_file_mount_mountable_finish() to get | |
| 1490 | 1490 | // the result of the operation. | |
| 1491 | - | func (x *FileBase) MountMountable(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1491 | + | func (x *FileBase) MountMountable(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1492 | 1492 | ||
| 1493 | - | XGFileMountMountable(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1493 | + | XGFileMountMountable(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1494 | 1494 | ||
| 1495 | 1495 | } | |
| 1496 | 1496 | ||
| @@ -1549,10 +1549,10 @@ func (x *FileBase) MountMountableFinish(ResultVar AsyncResult) (*FileBase, error | |||
| 1549 | 1549 | // %G_FILE_COPY_OVERWRITE is specified and the target is a file, then | |
| 1550 | 1550 | // the %G_IO_ERROR_WOULD_RECURSE error may be returned (if the native | |
| 1551 | 1551 | // move operation isn't available). | |
| 1552 | - | func (x *FileBase) Move(DestinationVar File, FlagsVar FileCopyFlags, CancellableVar *Cancellable, ProgressCallbackVar FileProgressCallback, ProgressCallbackDataVar uintptr) (bool, error) { | |
| 1552 | + | func (x *FileBase) Move(DestinationVar File, FlagsVar FileCopyFlags, CancellableVar *Cancellable, ProgressCallbackVar *FileProgressCallback, ProgressCallbackDataVar uintptr) (bool, error) { | |
| 1553 | 1553 | var cerr *glib.Error | |
| 1554 | 1554 | ||
| 1555 | - | cret := XGFileMove(x.GoPointer(), DestinationVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(ProgressCallbackVar), ProgressCallbackDataVar, &cerr) | |
| 1555 | + | cret := XGFileMove(x.GoPointer(), DestinationVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(ProgressCallbackVar), ProgressCallbackDataVar, &cerr) | |
| 1556 | 1556 | if cerr == nil { | |
| 1557 | 1557 | return cret, nil | |
| 1558 | 1558 | } | |
| @@ -1569,9 +1569,9 @@ func (x *FileBase) Move(DestinationVar File, FlagsVar FileCopyFlags, Cancellable | |||
| 1569 | 1569 | // | |
| 1570 | 1570 | // When the operation is finished, @callback will be called. You can then call | |
| 1571 | 1571 | // g_file_move_finish() to get the result of the operation. | |
| 1572 | - | func (x *FileBase) MoveAsync(DestinationVar File, FlagsVar FileCopyFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar FileProgressCallback, ProgressCallbackDataVar uintptr, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1572 | + | func (x *FileBase) MoveAsync(DestinationVar File, FlagsVar FileCopyFlags, IoPriorityVar int, CancellableVar *Cancellable, ProgressCallbackVar *FileProgressCallback, ProgressCallbackDataVar uintptr, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1573 | 1573 | ||
| 1574 | - | XGFileMoveAsync(x.GoPointer(), DestinationVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(ProgressCallbackVar), ProgressCallbackDataVar, purego.NewCallback(CallbackVar), UserDataVar) | |
| 1574 | + | XGFileMoveAsync(x.GoPointer(), DestinationVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(ProgressCallbackVar), ProgressCallbackDataVar, glib.NewCallback(CallbackVar), UserDataVar) | |
| 1575 | 1575 | ||
| 1576 | 1576 | } | |
| 1577 | 1577 | ||
| @@ -1630,9 +1630,9 @@ func (x *FileBase) OpenReadwrite(CancellableVar *Cancellable) (*FileIOStream, er | |||
| 1630 | 1630 | // When the operation is finished, @callback will be called. | |
| 1631 | 1631 | // You can then call g_file_open_readwrite_finish() to get | |
| 1632 | 1632 | // the result of the operation. | |
| 1633 | - | func (x *FileBase) OpenReadwriteAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1633 | + | func (x *FileBase) OpenReadwriteAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1634 | 1634 | ||
| 1635 | - | XGFileOpenReadwriteAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1635 | + | XGFileOpenReadwriteAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1636 | 1636 | ||
| 1637 | 1637 | } | |
| 1638 | 1638 | ||
| @@ -1678,9 +1678,9 @@ func (x *FileBase) PeekPath() string { | |||
| 1678 | 1678 | // When the operation is finished, @callback will be called. | |
| 1679 | 1679 | // You can then call g_file_mount_mountable_finish() to get | |
| 1680 | 1680 | // the result of the operation. | |
| 1681 | - | func (x *FileBase) PollMountable(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1681 | + | func (x *FileBase) PollMountable(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1682 | 1682 | ||
| 1683 | - | XGFilePollMountable(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1683 | + | XGFilePollMountable(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1684 | 1684 | ||
| 1685 | 1685 | } | |
| 1686 | 1686 | ||
| @@ -1724,9 +1724,9 @@ func (x *FileBase) QueryDefaultHandler(CancellableVar *Cancellable) (*AppInfoBas | |||
| 1724 | 1724 | } | |
| 1725 | 1725 | ||
| 1726 | 1726 | // Async version of g_file_query_default_handler(). | |
| 1727 | - | func (x *FileBase) QueryDefaultHandlerAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1727 | + | func (x *FileBase) QueryDefaultHandlerAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1728 | 1728 | ||
| 1729 | - | XGFileQueryDefaultHandlerAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1729 | + | XGFileQueryDefaultHandlerAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1730 | 1730 | ||
| 1731 | 1731 | } | |
| 1732 | 1732 | ||
| @@ -1842,9 +1842,9 @@ func (x *FileBase) QueryFilesystemInfo(AttributesVar string, CancellableVar *Can | |||
| 1842 | 1842 | // When the operation is finished, @callback will be called. You can | |
| 1843 | 1843 | // then call g_file_query_info_finish() to get the result of the | |
| 1844 | 1844 | // operation. | |
| 1845 | - | func (x *FileBase) QueryFilesystemInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1845 | + | func (x *FileBase) QueryFilesystemInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1846 | 1846 | ||
| 1847 | - | XGFileQueryFilesystemInfoAsync(x.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1847 | + | XGFileQueryFilesystemInfoAsync(x.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1848 | 1848 | ||
| 1849 | 1849 | } | |
| 1850 | 1850 | ||
| @@ -1925,9 +1925,9 @@ func (x *FileBase) QueryInfo(AttributesVar string, FlagsVar FileQueryInfoFlags, | |||
| 1925 | 1925 | // | |
| 1926 | 1926 | // When the operation is finished, @callback will be called. You can | |
| 1927 | 1927 | // then call g_file_query_info_finish() to get the result of the operation. | |
| 1928 | - | func (x *FileBase) QueryInfoAsync(AttributesVar string, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1928 | + | func (x *FileBase) QueryInfoAsync(AttributesVar string, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1929 | 1929 | ||
| 1930 | - | XGFileQueryInfoAsync(x.GoPointer(), AttributesVar, FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1930 | + | XGFileQueryInfoAsync(x.GoPointer(), AttributesVar, FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1931 | 1931 | ||
| 1932 | 1932 | } | |
| 1933 | 1933 | ||
| @@ -2027,9 +2027,9 @@ func (x *FileBase) Read(CancellableVar *Cancellable) (*FileInputStream, error) { | |||
| 2027 | 2027 | // When the operation is finished, @callback will be called. | |
| 2028 | 2028 | // You can then call g_file_read_finish() to get the result | |
| 2029 | 2029 | // of the operation. | |
| 2030 | - | func (x *FileBase) ReadAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2030 | + | func (x *FileBase) ReadAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2031 | 2031 | ||
| 2032 | - | XGFileReadAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2032 | + | XGFileReadAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2033 | 2033 | ||
| 2034 | 2034 | } | |
| 2035 | 2035 | ||
| @@ -2121,9 +2121,9 @@ func (x *FileBase) Replace(EtagVar string, MakeBackupVar bool, FlagsVar FileCrea | |||
| 2121 | 2121 | // When the operation is finished, @callback will be called. | |
| 2122 | 2122 | // You can then call g_file_replace_finish() to get the result | |
| 2123 | 2123 | // of the operation. | |
| 2124 | - | func (x *FileBase) ReplaceAsync(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2124 | + | func (x *FileBase) ReplaceAsync(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2125 | 2125 | ||
| 2126 | - | XGFileReplaceAsync(x.GoPointer(), EtagVar, MakeBackupVar, FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2126 | + | XGFileReplaceAsync(x.GoPointer(), EtagVar, MakeBackupVar, FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2127 | 2127 | ||
| 2128 | 2128 | } | |
| 2129 | 2129 | ||
| @@ -2173,9 +2173,9 @@ func (x *FileBase) ReplaceContents(ContentsVar string, LengthVar uint, EtagVar s | |||
| 2173 | 2173 | // until @callback is called. See g_file_replace_contents_bytes_async() | |
| 2174 | 2174 | // for a #GBytes version that will automatically hold a reference to the | |
| 2175 | 2175 | // contents (without copying) for the duration of the call. | |
| 2176 | - | func (x *FileBase) ReplaceContentsAsync(ContentsVar string, LengthVar uint, EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2176 | + | func (x *FileBase) ReplaceContentsAsync(ContentsVar string, LengthVar uint, EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2177 | 2177 | ||
| 2178 | - | XGFileReplaceContentsAsync(x.GoPointer(), ContentsVar, LengthVar, EtagVar, MakeBackupVar, FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2178 | + | XGFileReplaceContentsAsync(x.GoPointer(), ContentsVar, LengthVar, EtagVar, MakeBackupVar, FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2179 | 2179 | ||
| 2180 | 2180 | } | |
| 2181 | 2181 | ||
| @@ -2187,9 +2187,9 @@ func (x *FileBase) ReplaceContentsAsync(ContentsVar string, LengthVar uint, Etag | |||
| 2187 | 2187 | // When this operation has completed, @callback will be called with | |
| 2188 | 2188 | // @user_user data, and the operation can be finalized with | |
| 2189 | 2189 | // g_file_replace_contents_finish(). | |
| 2190 | - | func (x *FileBase) ReplaceContentsBytesAsync(ContentsVar *glib.Bytes, EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2190 | + | func (x *FileBase) ReplaceContentsBytesAsync(ContentsVar *glib.Bytes, EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2191 | 2191 | ||
| 2192 | - | XGFileReplaceContentsBytesAsync(x.GoPointer(), ContentsVar, EtagVar, MakeBackupVar, FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2192 | + | XGFileReplaceContentsBytesAsync(x.GoPointer(), ContentsVar, EtagVar, MakeBackupVar, FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2193 | 2193 | ||
| 2194 | 2194 | } | |
| 2195 | 2195 | ||
| @@ -2265,9 +2265,9 @@ func (x *FileBase) ReplaceReadwrite(EtagVar string, MakeBackupVar bool, FlagsVar | |||
| 2265 | 2265 | // When the operation is finished, @callback will be called. | |
| 2266 | 2266 | // You can then call g_file_replace_readwrite_finish() to get | |
| 2267 | 2267 | // the result of the operation. | |
| 2268 | - | func (x *FileBase) ReplaceReadwriteAsync(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2268 | + | func (x *FileBase) ReplaceReadwriteAsync(EtagVar string, MakeBackupVar bool, FlagsVar FileCreateFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2269 | 2269 | ||
| 2270 | - | XGFileReplaceReadwriteAsync(x.GoPointer(), EtagVar, MakeBackupVar, FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2270 | + | XGFileReplaceReadwriteAsync(x.GoPointer(), EtagVar, MakeBackupVar, FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2271 | 2271 | ||
| 2272 | 2272 | } | |
| 2273 | 2273 | ||
| @@ -2440,9 +2440,9 @@ func (x *FileBase) SetAttributeUint64(AttributeVar string, ValueVar uint64, Flag | |||
| 2440 | 2440 | // When the operation is finished, @callback will be called. | |
| 2441 | 2441 | // You can then call g_file_set_attributes_finish() to get | |
| 2442 | 2442 | // the result of the operation. | |
| 2443 | - | func (x *FileBase) SetAttributesAsync(InfoVar *FileInfo, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2443 | + | func (x *FileBase) SetAttributesAsync(InfoVar *FileInfo, FlagsVar FileQueryInfoFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2444 | 2444 | ||
| 2445 | - | XGFileSetAttributesAsync(x.GoPointer(), InfoVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2445 | + | XGFileSetAttributesAsync(x.GoPointer(), InfoVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2446 | 2446 | ||
| 2447 | 2447 | } | |
| 2448 | 2448 | ||
| @@ -2522,9 +2522,9 @@ func (x *FileBase) SetDisplayName(DisplayNameVar string, CancellableVar *Cancell | |||
| 2522 | 2522 | // When the operation is finished, @callback will be called. | |
| 2523 | 2523 | // You can then call g_file_set_display_name_finish() to get | |
| 2524 | 2524 | // the result of the operation. | |
| 2525 | - | func (x *FileBase) SetDisplayNameAsync(DisplayNameVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2525 | + | func (x *FileBase) SetDisplayNameAsync(DisplayNameVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2526 | 2526 | ||
| 2527 | - | XGFileSetDisplayNameAsync(x.GoPointer(), DisplayNameVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2527 | + | XGFileSetDisplayNameAsync(x.GoPointer(), DisplayNameVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2528 | 2528 | ||
| 2529 | 2529 | } | |
| 2530 | 2530 | ||
| @@ -2559,9 +2559,9 @@ func (x *FileBase) SetDisplayNameFinish(ResVar AsyncResult) (*FileBase, error) { | |||
| 2559 | 2559 | // When the operation is finished, @callback will be called. | |
| 2560 | 2560 | // You can then call g_file_mount_mountable_finish() to get | |
| 2561 | 2561 | // the result of the operation. | |
| 2562 | - | func (x *FileBase) StartMountable(FlagsVar DriveStartFlags, StartOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2562 | + | func (x *FileBase) StartMountable(FlagsVar DriveStartFlags, StartOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2563 | 2563 | ||
| 2564 | - | XGFileStartMountable(x.GoPointer(), FlagsVar, StartOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2564 | + | XGFileStartMountable(x.GoPointer(), FlagsVar, StartOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2565 | 2565 | ||
| 2566 | 2566 | } | |
| 2567 | 2567 | ||
| @@ -2589,9 +2589,9 @@ func (x *FileBase) StartMountableFinish(ResultVar AsyncResult) (bool, error) { | |||
| 2589 | 2589 | // When the operation is finished, @callback will be called. | |
| 2590 | 2590 | // You can then call g_file_stop_mountable_finish() to get | |
| 2591 | 2591 | // the result of the operation. | |
| 2592 | - | func (x *FileBase) StopMountable(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2592 | + | func (x *FileBase) StopMountable(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2593 | 2593 | ||
| 2594 | - | XGFileStopMountable(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2594 | + | XGFileStopMountable(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2595 | 2595 | ||
| 2596 | 2596 | } | |
| 2597 | 2597 | ||
| @@ -2642,9 +2642,9 @@ func (x *FileBase) Trash(CancellableVar *Cancellable) (bool, error) { | |||
| 2642 | 2642 | } | |
| 2643 | 2643 | ||
| 2644 | 2644 | // Asynchronously sends @file to the Trash location, if possible. | |
| 2645 | - | func (x *FileBase) TrashAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2645 | + | func (x *FileBase) TrashAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2646 | 2646 | ||
| 2647 | - | XGFileTrashAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2647 | + | XGFileTrashAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2648 | 2648 | ||
| 2649 | 2649 | } | |
| 2650 | 2650 | ||
| @@ -2670,9 +2670,9 @@ func (x *FileBase) TrashFinish(ResultVar AsyncResult) (bool, error) { | |||
| 2670 | 2670 | // When the operation is finished, @callback will be called. | |
| 2671 | 2671 | // You can then call g_file_unmount_mountable_finish() to get | |
| 2672 | 2672 | // the result of the operation. | |
| 2673 | - | func (x *FileBase) UnmountMountable(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2673 | + | func (x *FileBase) UnmountMountable(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2674 | 2674 | ||
| 2675 | - | XGFileUnmountMountable(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2675 | + | XGFileUnmountMountable(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2676 | 2676 | ||
| 2677 | 2677 | } | |
| 2678 | 2678 | ||
| @@ -2700,9 +2700,9 @@ func (x *FileBase) UnmountMountableFinish(ResultVar AsyncResult) (bool, error) { | |||
| 2700 | 2700 | // When the operation is finished, @callback will be called. | |
| 2701 | 2701 | // You can then call g_file_unmount_mountable_finish() to get | |
| 2702 | 2702 | // the result of the operation. | |
| 2703 | - | func (x *FileBase) UnmountMountableWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2703 | + | func (x *FileBase) UnmountMountableWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2704 | 2704 | ||
| 2705 | - | XGFileUnmountMountableWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2705 | + | XGFileUnmountMountableWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2706 | 2706 | ||
| 2707 | 2707 | } | |
| 2708 | 2708 | ||
M v4/gio/gfileenumerator.go +4 -4
| @@ -88,9 +88,9 @@ var xFileEnumeratorCloseAsync func(uintptr, int, uintptr, uintptr, uintptr) | |||
| 88 | 88 | // triggering the cancellable object from another thread. If the operation | |
| 89 | 89 | // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned in | |
| 90 | 90 | // g_file_enumerator_close_finish(). | |
| 91 | - | func (x *FileEnumerator) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 91 | + | func (x *FileEnumerator) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 92 | 92 | ||
| 93 | - | xFileEnumeratorCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 93 | + | xFileEnumeratorCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 94 | 94 | ||
| 95 | 95 | } | |
| 96 | 96 | ||
| @@ -288,9 +288,9 @@ var xFileEnumeratorNextFilesAsync func(uintptr, int, int, uintptr, uintptr, uint | |||
| 288 | 288 | // Any outstanding i/o request with higher priority (lower numerical value) will | |
| 289 | 289 | // be executed before an outstanding request with lower priority. Default | |
| 290 | 290 | // priority is %G_PRIORITY_DEFAULT. | |
| 291 | - | func (x *FileEnumerator) NextFilesAsync(NumFilesVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 291 | + | func (x *FileEnumerator) NextFilesAsync(NumFilesVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 292 | 292 | ||
| 293 | - | xFileEnumeratorNextFilesAsync(x.GoPointer(), NumFilesVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 293 | + | xFileEnumeratorNextFilesAsync(x.GoPointer(), NumFilesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 294 | 294 | ||
| 295 | 295 | } | |
| 296 | 296 | ||
M v4/gio/gfileicon.go +2 -2
| @@ -133,9 +133,9 @@ func (x *FileIcon) Load(SizeVar int, TypeVar string, CancellableVar *Cancellable | |||
| 133 | 133 | // Loads an icon asynchronously. To finish this function, see | |
| 134 | 134 | // g_loadable_icon_load_finish(). For the synchronous, blocking | |
| 135 | 135 | // version of this function, see g_loadable_icon_load(). | |
| 136 | - | func (x *FileIcon) LoadAsync(SizeVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 136 | + | func (x *FileIcon) LoadAsync(SizeVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 137 | 137 | ||
| 138 | - | XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 138 | + | XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 139 | 139 | ||
| 140 | 140 | } | |
| 141 | 141 | ||
M v4/gio/gfileinputstream.go +2 -2
| @@ -81,9 +81,9 @@ var xFileInputStreamQueryInfoAsync func(uintptr, string, int, uintptr, uintptr, | |||
| 81 | 81 | // If @cancellable is not %NULL, then the operation can be cancelled by | |
| 82 | 82 | // triggering the cancellable object from another thread. If the operation | |
| 83 | 83 | // was cancelled, the error %G_IO_ERROR_CANCELLED will be set | |
| 84 | - | func (x *FileInputStream) QueryInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 84 | + | func (x *FileInputStream) QueryInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 85 | 85 | ||
| 86 | - | xFileInputStreamQueryInfoAsync(x.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 86 | + | xFileInputStreamQueryInfoAsync(x.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 87 | 87 | ||
| 88 | 88 | } | |
| 89 | 89 | ||
M v4/gio/gfileiostream.go +2 -2
| @@ -110,9 +110,9 @@ var xFileIOStreamQueryInfoAsync func(uintptr, string, int, uintptr, uintptr, uin | |||
| 110 | 110 | // | |
| 111 | 111 | // For the synchronous version of this function, see | |
| 112 | 112 | // g_file_io_stream_query_info(). | |
| 113 | - | func (x *FileIOStream) QueryInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 113 | + | func (x *FileIOStream) QueryInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 114 | 114 | ||
| 115 | - | xFileIOStreamQueryInfoAsync(x.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 115 | + | xFileIOStreamQueryInfoAsync(x.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 116 | 116 | ||
| 117 | 117 | } | |
| 118 | 118 | ||
M v4/gio/gfilemonitor.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -127,15 +128,23 @@ func (c *FileMonitor) SetGoPointer(ptr uintptr) { | |||
| 127 | 128 | // old path, and @other_file will be set to a #GFile containing the new path. | |
| 128 | 129 | // | |
| 129 | 130 | // In all the other cases, @other_file will be set to #NULL. | |
| 130 | - | func (x *FileMonitor) ConnectChanged(cb func(FileMonitor, uintptr, uintptr, FileMonitorEvent)) uint32 { | |
| 131 | + | func (x *FileMonitor) ConnectChanged(cb *func(FileMonitor, uintptr, uintptr, FileMonitorEvent)) uint32 { | |
| 132 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 133 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 134 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 135 | + | } | |
| 136 | + | ||
| 131 | 137 | fcb := func(clsPtr uintptr, FileVarp uintptr, OtherFileVarp uintptr, EventTypeVarp FileMonitorEvent) { | |
| 132 | 138 | fa := FileMonitor{} | |
| 133 | 139 | fa.Ptr = clsPtr | |
| 140 | + | cbFn := *cb | |
| 134 | 141 | ||
| 135 | - | cb(fa, FileVarp, OtherFileVarp, EventTypeVarp) | |
| 142 | + | cbFn(fa, FileVarp, OtherFileVarp, EventTypeVarp) | |
| 136 | 143 | ||
| 137 | 144 | } | |
| 138 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 145 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 146 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 147 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 139 | 148 | } | |
| 140 | 149 | ||
| 141 | 150 | func init() { | |
M v4/gio/gfilenamecompleter.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -83,15 +84,23 @@ func (c *FilenameCompleter) SetGoPointer(ptr uintptr) { | |||
| 83 | 84 | } | |
| 84 | 85 | ||
| 85 | 86 | // Emitted when the file name completion information comes available. | |
| 86 | - | func (x *FilenameCompleter) ConnectGotCompletionData(cb func(FilenameCompleter)) uint32 { | |
| 87 | + | func (x *FilenameCompleter) ConnectGotCompletionData(cb *func(FilenameCompleter)) uint32 { | |
| 88 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 89 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 90 | + | return gobject.SignalConnect(x.GoPointer(), "got-completion-data", cbRefPtr) | |
| 91 | + | } | |
| 92 | + | ||
| 87 | 93 | fcb := func(clsPtr uintptr) { | |
| 88 | 94 | fa := FilenameCompleter{} | |
| 89 | 95 | fa.Ptr = clsPtr | |
| 96 | + | cbFn := *cb | |
| 90 | 97 | ||
| 91 | - | cb(fa) | |
| 98 | + | cbFn(fa) | |
| 92 | 99 | ||
| 93 | 100 | } | |
| 94 | - | return gobject.SignalConnect(x.GoPointer(), "got-completion-data", purego.NewCallback(fcb)) | |
| 101 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 102 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 103 | + | return gobject.SignalConnect(x.GoPointer(), "got-completion-data", cbRefPtr) | |
| 95 | 104 | } | |
| 96 | 105 | ||
| 97 | 106 | func init() { | |
M v4/gio/gfileoutputstream.go +2 -2
| @@ -104,9 +104,9 @@ var xFileOutputStreamQueryInfoAsync func(uintptr, string, int, uintptr, uintptr, | |||
| 104 | 104 | // | |
| 105 | 105 | // For the synchronous version of this function, see | |
| 106 | 106 | // g_file_output_stream_query_info(). | |
| 107 | - | func (x *FileOutputStream) QueryInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 107 | + | func (x *FileOutputStream) QueryInfoAsync(AttributesVar string, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 108 | 108 | ||
| 109 | - | xFileOutputStreamQueryInfoAsync(x.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 109 | + | xFileOutputStreamQueryInfoAsync(x.GoPointer(), AttributesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 110 | 110 | ||
| 111 | 111 | } | |
| 112 | 112 | ||
M v4/gio/ginputstream.go +10 -10
| @@ -103,9 +103,9 @@ var xInputStreamCloseAsync func(uintptr, int, uintptr, uintptr, uintptr) | |||
| 103 | 103 | // The asynchronous methods have a default fallback that uses threads to implement | |
| 104 | 104 | // asynchronicity, so they are optional for inheriting classes. However, if you | |
| 105 | 105 | // override one you must override all. | |
| 106 | - | func (x *InputStream) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 106 | + | func (x *InputStream) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 107 | 107 | ||
| 108 | - | xInputStreamCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 108 | + | xInputStreamCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 109 | 109 | ||
| 110 | 110 | } | |
| 111 | 111 | ||
| @@ -219,9 +219,9 @@ var xInputStreamReadAllAsync func(uintptr, uintptr, uint, int, uintptr, uintptr, | |||
| 219 | 219 | // Any outstanding I/O request with higher priority (lower numerical | |
| 220 | 220 | // value) will be executed before an outstanding request with lower | |
| 221 | 221 | // priority. Default priority is %G_PRIORITY_DEFAULT. | |
| 222 | - | func (x *InputStream) ReadAllAsync(BufferVar uintptr, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 222 | + | func (x *InputStream) ReadAllAsync(BufferVar uintptr, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 223 | 223 | ||
| 224 | - | xInputStreamReadAllAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 224 | + | xInputStreamReadAllAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 225 | 225 | ||
| 226 | 226 | } | |
| 227 | 227 | ||
| @@ -272,9 +272,9 @@ var xInputStreamReadAsync func(uintptr, uintptr, uint, int, uintptr, uintptr, ui | |||
| 272 | 272 | // The asynchronous methods have a default fallback that uses threads to implement | |
| 273 | 273 | // asynchronicity, so they are optional for inheriting classes. However, if you | |
| 274 | 274 | // override one you must override all. | |
| 275 | - | func (x *InputStream) ReadAsync(BufferVar uintptr, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 275 | + | func (x *InputStream) ReadAsync(BufferVar uintptr, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 276 | 276 | ||
| 277 | - | xInputStreamReadAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 277 | + | xInputStreamReadAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 278 | 278 | ||
| 279 | 279 | } | |
| 280 | 280 | ||
| @@ -336,9 +336,9 @@ var xInputStreamReadBytesAsync func(uintptr, uint, int, uintptr, uintptr, uintpt | |||
| 336 | 336 | // Any outstanding I/O request with higher priority (lower numerical | |
| 337 | 337 | // value) will be executed before an outstanding request with lower | |
| 338 | 338 | // priority. Default priority is %G_PRIORITY_DEFAULT. | |
| 339 | - | func (x *InputStream) ReadBytesAsync(CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 339 | + | func (x *InputStream) ReadBytesAsync(CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 340 | 340 | ||
| 341 | - | xInputStreamReadBytesAsync(x.GoPointer(), CountVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 341 | + | xInputStreamReadBytesAsync(x.GoPointer(), CountVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 342 | 342 | ||
| 343 | 343 | } | |
| 344 | 344 | ||
| @@ -438,9 +438,9 @@ var xInputStreamSkipAsync func(uintptr, uint, int, uintptr, uintptr, uintptr) | |||
| 438 | 438 | // The asynchronous methods have a default fallback that uses threads to | |
| 439 | 439 | // implement asynchronicity, so they are optional for inheriting classes. | |
| 440 | 440 | // However, if you override one, you must override all. | |
| 441 | - | func (x *InputStream) SkipAsync(CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 441 | + | func (x *InputStream) SkipAsync(CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 442 | 442 | ||
| 443 | - | xInputStreamSkipAsync(x.GoPointer(), CountVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 443 | + | xInputStreamSkipAsync(x.GoPointer(), CountVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 444 | 444 | ||
| 445 | 445 | } | |
| 446 | 446 | ||
M v4/gio/gio-2.0.go +115 -57
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gio | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -90,15 +92,23 @@ func (c *AppInfoMonitor) SetGoPointer(ptr uintptr) { | |||
| 90 | 92 | ||
| 91 | 93 | // Signal emitted when the app info database for changes (ie: newly installed | |
| 92 | 94 | // or removed applications). | |
| 93 | - | func (x *AppInfoMonitor) ConnectChanged(cb func(AppInfoMonitor)) uint32 { | |
| 95 | + | func (x *AppInfoMonitor) ConnectChanged(cb *func(AppInfoMonitor)) uint32 { | |
| 96 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 97 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 98 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 99 | + | } | |
| 100 | + | ||
| 94 | 101 | fcb := func(clsPtr uintptr) { | |
| 95 | 102 | fa := AppInfoMonitor{} | |
| 96 | 103 | fa.Ptr = clsPtr | |
| 104 | + | cbFn := *cb | |
| 97 | 105 | ||
| 98 | - | cb(fa) | |
| 106 | + | cbFn(fa) | |
| 99 | 107 | ||
| 100 | 108 | } | |
| 101 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 109 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 110 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 111 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 102 | 112 | } | |
| 103 | 113 | ||
| 104 | 114 | var xAppInfoMonitorGet func() uintptr | |
| @@ -236,9 +246,9 @@ func (x *BytesIcon) Load(SizeVar int, TypeVar string, CancellableVar *Cancellabl | |||
| 236 | 246 | // Loads an icon asynchronously. To finish this function, see | |
| 237 | 247 | // g_loadable_icon_load_finish(). For the synchronous, blocking | |
| 238 | 248 | // version of this function, see g_loadable_icon_load(). | |
| 239 | - | func (x *BytesIcon) LoadAsync(SizeVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 249 | + | func (x *BytesIcon) LoadAsync(SizeVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 240 | 250 | ||
| 241 | - | XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 251 | + | XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 242 | 252 | ||
| 243 | 253 | } | |
| 244 | 254 | ||
| @@ -692,28 +702,44 @@ func (c *DBusAuthObserver) SetGoPointer(ptr uintptr) { | |||
| 692 | 702 | } | |
| 693 | 703 | ||
| 694 | 704 | // Emitted to check if @mechanism is allowed to be used. | |
| 695 | - | func (x *DBusAuthObserver) ConnectAllowMechanism(cb func(DBusAuthObserver, string) bool) uint32 { | |
| 705 | + | func (x *DBusAuthObserver) ConnectAllowMechanism(cb *func(DBusAuthObserver, string) bool) uint32 { | |
| 706 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 707 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 708 | + | return gobject.SignalConnect(x.GoPointer(), "allow-mechanism", cbRefPtr) | |
| 709 | + | } | |
| 710 | + | ||
| 696 | 711 | fcb := func(clsPtr uintptr, MechanismVarp string) bool { | |
| 697 | 712 | fa := DBusAuthObserver{} | |
| 698 | 713 | fa.Ptr = clsPtr | |
| 714 | + | cbFn := *cb | |
| 699 | 715 | ||
| 700 | - | return cb(fa, MechanismVarp) | |
| 716 | + | return cbFn(fa, MechanismVarp) | |
| 701 | 717 | ||
| 702 | 718 | } | |
| 703 | - | return gobject.SignalConnect(x.GoPointer(), "allow-mechanism", purego.NewCallback(fcb)) | |
| 719 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 720 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 721 | + | return gobject.SignalConnect(x.GoPointer(), "allow-mechanism", cbRefPtr) | |
| 704 | 722 | } | |
| 705 | 723 | ||
| 706 | 724 | // Emitted to check if a peer that is successfully authenticated | |
| 707 | 725 | // is authorized. | |
| 708 | - | func (x *DBusAuthObserver) ConnectAuthorizeAuthenticatedPeer(cb func(DBusAuthObserver, uintptr, uintptr) bool) uint32 { | |
| 726 | + | func (x *DBusAuthObserver) ConnectAuthorizeAuthenticatedPeer(cb *func(DBusAuthObserver, uintptr, uintptr) bool) uint32 { | |
| 727 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 728 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 729 | + | return gobject.SignalConnect(x.GoPointer(), "authorize-authenticated-peer", cbRefPtr) | |
| 730 | + | } | |
| 731 | + | ||
| 709 | 732 | fcb := func(clsPtr uintptr, StreamVarp uintptr, CredentialsVarp uintptr) bool { | |
| 710 | 733 | fa := DBusAuthObserver{} | |
| 711 | 734 | fa.Ptr = clsPtr | |
| 735 | + | cbFn := *cb | |
| 712 | 736 | ||
| 713 | - | return cb(fa, StreamVarp, CredentialsVarp) | |
| 737 | + | return cbFn(fa, StreamVarp, CredentialsVarp) | |
| 714 | 738 | ||
| 715 | 739 | } | |
| 716 | - | return gobject.SignalConnect(x.GoPointer(), "authorize-authenticated-peer", purego.NewCallback(fcb)) | |
| 740 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 741 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 742 | + | return gobject.SignalConnect(x.GoPointer(), "authorize-authenticated-peer", cbRefPtr) | |
| 717 | 743 | } | |
| 718 | 744 | ||
| 719 | 745 | // The #GDBusConnection type is used for D-Bus connections to remote | |
| @@ -918,9 +944,9 @@ var xDBusConnectionAddFilter func(uintptr, uintptr, uintptr, uintptr) uint | |||
| 918 | 944 | // needed. (It is not guaranteed to be called synchronously when the | |
| 919 | 945 | // filter is removed, and may be called after @connection has been | |
| 920 | 946 | // destroyed.) | |
| 921 | - | func (x *DBusConnection) AddFilter(FilterFunctionVar DBusMessageFilterFunction, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) uint { | |
| 947 | + | func (x *DBusConnection) AddFilter(FilterFunctionVar *DBusMessageFilterFunction, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint { | |
| 922 | 948 | ||
| 923 | - | cret := xDBusConnectionAddFilter(x.GoPointer(), purego.NewCallback(FilterFunctionVar), UserDataVar, purego.NewCallback(UserDataFreeFuncVar)) | |
| 949 | + | cret := xDBusConnectionAddFilter(x.GoPointer(), glib.NewCallback(FilterFunctionVar), UserDataVar, glib.NewCallback(UserDataFreeFuncVar)) | |
| 924 | 950 | return cret | |
| 925 | 951 | } | |
| 926 | 952 | ||
| @@ -973,9 +999,9 @@ var xDBusConnectionCall func(uintptr, string, string, string, string, *glib.Vari | |||
| 973 | 999 | // | |
| 974 | 1000 | // If @callback is %NULL then the D-Bus method call message will be sent with | |
| 975 | 1001 | // the %G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set. | |
| 976 | - | func (x *DBusConnection) Call(BusNameVar string, ObjectPathVar string, InterfaceNameVar string, MethodNameVar string, ParametersVar *glib.Variant, ReplyTypeVar *glib.VariantType, FlagsVar DBusCallFlags, TimeoutMsecVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1002 | + | func (x *DBusConnection) Call(BusNameVar string, ObjectPathVar string, InterfaceNameVar string, MethodNameVar string, ParametersVar *glib.Variant, ReplyTypeVar *glib.VariantType, FlagsVar DBusCallFlags, TimeoutMsecVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 977 | 1003 | ||
| 978 | - | xDBusConnectionCall(x.GoPointer(), BusNameVar, ObjectPathVar, InterfaceNameVar, MethodNameVar, ParametersVar, ReplyTypeVar, FlagsVar, TimeoutMsecVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1004 | + | xDBusConnectionCall(x.GoPointer(), BusNameVar, ObjectPathVar, InterfaceNameVar, MethodNameVar, ParametersVar, ReplyTypeVar, FlagsVar, TimeoutMsecVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 979 | 1005 | ||
| 980 | 1006 | } | |
| 981 | 1007 | ||
| @@ -1061,9 +1087,9 @@ var xDBusConnectionCallWithUnixFdList func(uintptr, string, string, string, stri | |||
| 1061 | 1087 | // value of type %G_VARIANT_TYPE_HANDLE in the body of the message. | |
| 1062 | 1088 | // | |
| 1063 | 1089 | // This method is only available on UNIX. | |
| 1064 | - | func (x *DBusConnection) CallWithUnixFdList(BusNameVar string, ObjectPathVar string, InterfaceNameVar string, MethodNameVar string, ParametersVar *glib.Variant, ReplyTypeVar *glib.VariantType, FlagsVar DBusCallFlags, TimeoutMsecVar int, FdListVar *UnixFDList, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1090 | + | func (x *DBusConnection) CallWithUnixFdList(BusNameVar string, ObjectPathVar string, InterfaceNameVar string, MethodNameVar string, ParametersVar *glib.Variant, ReplyTypeVar *glib.VariantType, FlagsVar DBusCallFlags, TimeoutMsecVar int, FdListVar *UnixFDList, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1065 | 1091 | ||
| 1066 | - | xDBusConnectionCallWithUnixFdList(x.GoPointer(), BusNameVar, ObjectPathVar, InterfaceNameVar, MethodNameVar, ParametersVar, ReplyTypeVar, FlagsVar, TimeoutMsecVar, FdListVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1092 | + | xDBusConnectionCallWithUnixFdList(x.GoPointer(), BusNameVar, ObjectPathVar, InterfaceNameVar, MethodNameVar, ParametersVar, ReplyTypeVar, FlagsVar, TimeoutMsecVar, FdListVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1067 | 1093 | ||
| 1068 | 1094 | } | |
| 1069 | 1095 | ||
| @@ -1136,9 +1162,9 @@ var xDBusConnectionClose func(uintptr, uintptr, uintptr, uintptr) | |||
| 1136 | 1162 | // then call g_dbus_connection_close_finish() to get the result of the | |
| 1137 | 1163 | // operation. See g_dbus_connection_close_sync() for the synchronous | |
| 1138 | 1164 | // version. | |
| 1139 | - | func (x *DBusConnection) Close(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1165 | + | func (x *DBusConnection) Close(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1140 | 1166 | ||
| 1141 | - | xDBusConnectionClose(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1167 | + | xDBusConnectionClose(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1142 | 1168 | ||
| 1143 | 1169 | } | |
| 1144 | 1170 | ||
| @@ -1268,9 +1294,9 @@ var xDBusConnectionFlush func(uintptr, uintptr, uintptr, uintptr) | |||
| 1268 | 1294 | // then call g_dbus_connection_flush_finish() to get the result of the | |
| 1269 | 1295 | // operation. See g_dbus_connection_flush_sync() for the synchronous | |
| 1270 | 1296 | // version. | |
| 1271 | - | func (x *DBusConnection) Flush(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1297 | + | func (x *DBusConnection) Flush(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1272 | 1298 | ||
| 1273 | - | xDBusConnectionFlush(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1299 | + | xDBusConnectionFlush(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1274 | 1300 | ||
| 1275 | 1301 | } | |
| 1276 | 1302 | ||
| @@ -1463,10 +1489,10 @@ var xDBusConnectionRegisterObject func(uintptr, string, *DBusInterfaceInfo, *DBu | |||
| 1463 | 1489 | // as the object is exported. Also note that @vtable will be copied. | |
| 1464 | 1490 | // | |
| 1465 | 1491 | // See this [server][gdbus-server] for an example of how to use this method. | |
| 1466 | - | func (x *DBusConnection) RegisterObject(ObjectPathVar string, InterfaceInfoVar *DBusInterfaceInfo, VtableVar *DBusInterfaceVTable, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) (uint, error) { | |
| 1492 | + | func (x *DBusConnection) RegisterObject(ObjectPathVar string, InterfaceInfoVar *DBusInterfaceInfo, VtableVar *DBusInterfaceVTable, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) (uint, error) { | |
| 1467 | 1493 | var cerr *glib.Error | |
| 1468 | 1494 | ||
| 1469 | - | cret := xDBusConnectionRegisterObject(x.GoPointer(), ObjectPathVar, InterfaceInfoVar, VtableVar, UserDataVar, purego.NewCallback(UserDataFreeFuncVar), &cerr) | |
| 1495 | + | cret := xDBusConnectionRegisterObject(x.GoPointer(), ObjectPathVar, InterfaceInfoVar, VtableVar, UserDataVar, glib.NewCallback(UserDataFreeFuncVar), &cerr) | |
| 1470 | 1496 | if cerr == nil { | |
| 1471 | 1497 | return cret, nil | |
| 1472 | 1498 | } | |
| @@ -1525,10 +1551,10 @@ var xDBusConnectionRegisterSubtree func(uintptr, string, *DBusSubtreeVTable, DBu | |||
| 1525 | 1551 | // | |
| 1526 | 1552 | // See this [server][gdbus-subtree-server] for an example of how to use | |
| 1527 | 1553 | // this method. | |
| 1528 | - | func (x *DBusConnection) RegisterSubtree(ObjectPathVar string, VtableVar *DBusSubtreeVTable, FlagsVar DBusSubtreeFlags, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) (uint, error) { | |
| 1554 | + | func (x *DBusConnection) RegisterSubtree(ObjectPathVar string, VtableVar *DBusSubtreeVTable, FlagsVar DBusSubtreeFlags, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) (uint, error) { | |
| 1529 | 1555 | var cerr *glib.Error | |
| 1530 | 1556 | ||
| 1531 | - | cret := xDBusConnectionRegisterSubtree(x.GoPointer(), ObjectPathVar, VtableVar, FlagsVar, UserDataVar, purego.NewCallback(UserDataFreeFuncVar), &cerr) | |
| 1557 | + | cret := xDBusConnectionRegisterSubtree(x.GoPointer(), ObjectPathVar, VtableVar, FlagsVar, UserDataVar, glib.NewCallback(UserDataFreeFuncVar), &cerr) | |
| 1532 | 1558 | if cerr == nil { | |
| 1533 | 1559 | return cret, nil | |
| 1534 | 1560 | } | |
| @@ -1617,9 +1643,9 @@ var xDBusConnectionSendMessageWithReply func(uintptr, uintptr, DBusSendMessageFl | |||
| 1617 | 1643 | // See this [server][gdbus-server] and [client][gdbus-unix-fd-client] | |
| 1618 | 1644 | // for an example of how to use this low-level API to send and receive | |
| 1619 | 1645 | // UNIX file descriptors. | |
| 1620 | - | func (x *DBusConnection) SendMessageWithReply(MessageVar *DBusMessage, FlagsVar DBusSendMessageFlags, TimeoutMsecVar int, OutSerialVar uint32, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1646 | + | func (x *DBusConnection) SendMessageWithReply(MessageVar *DBusMessage, FlagsVar DBusSendMessageFlags, TimeoutMsecVar int, OutSerialVar uint32, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1621 | 1647 | ||
| 1622 | - | xDBusConnectionSendMessageWithReply(x.GoPointer(), MessageVar.GoPointer(), FlagsVar, TimeoutMsecVar, OutSerialVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1648 | + | xDBusConnectionSendMessageWithReply(x.GoPointer(), MessageVar.GoPointer(), FlagsVar, TimeoutMsecVar, OutSerialVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1623 | 1649 | ||
| 1624 | 1650 | } | |
| 1625 | 1651 | ||
| @@ -1772,9 +1798,9 @@ var xDBusConnectionSignalSubscribe func(uintptr, string, string, string, string, | |||
| 1772 | 1798 | // to never be zero. | |
| 1773 | 1799 | // | |
| 1774 | 1800 | // This function can never fail. | |
| 1775 | - | func (x *DBusConnection) SignalSubscribe(SenderVar string, InterfaceNameVar string, MemberVar string, ObjectPathVar string, Arg0Var string, FlagsVar DBusSignalFlags, CallbackVar DBusSignalCallback, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) uint { | |
| 1801 | + | func (x *DBusConnection) SignalSubscribe(SenderVar string, InterfaceNameVar string, MemberVar string, ObjectPathVar string, Arg0Var string, FlagsVar DBusSignalFlags, CallbackVar *DBusSignalCallback, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint { | |
| 1776 | 1802 | ||
| 1777 | - | cret := xDBusConnectionSignalSubscribe(x.GoPointer(), SenderVar, InterfaceNameVar, MemberVar, ObjectPathVar, Arg0Var, FlagsVar, purego.NewCallback(CallbackVar), UserDataVar, purego.NewCallback(UserDataFreeFuncVar)) | |
| 1803 | + | cret := xDBusConnectionSignalSubscribe(x.GoPointer(), SenderVar, InterfaceNameVar, MemberVar, ObjectPathVar, Arg0Var, FlagsVar, glib.NewCallback(CallbackVar), UserDataVar, glib.NewCallback(UserDataFreeFuncVar)) | |
| 1778 | 1804 | return cret | |
| 1779 | 1805 | } | |
| 1780 | 1806 | ||
| @@ -1880,15 +1906,23 @@ func (c *DBusConnection) SetGoPointer(ptr uintptr) { | |||
| 1880 | 1906 | // Upon receiving this signal, you should give up your reference to | |
| 1881 | 1907 | // @connection. You are guaranteed that this signal is emitted only | |
| 1882 | 1908 | // once. | |
| 1883 | - | func (x *DBusConnection) ConnectClosed(cb func(DBusConnection, bool, uintptr)) uint32 { | |
| 1909 | + | func (x *DBusConnection) ConnectClosed(cb *func(DBusConnection, bool, uintptr)) uint32 { | |
| 1910 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1911 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1912 | + | return gobject.SignalConnect(x.GoPointer(), "closed", cbRefPtr) | |
| 1913 | + | } | |
| 1914 | + | ||
| 1884 | 1915 | fcb := func(clsPtr uintptr, RemotePeerVanishedVarp bool, ErrorVarp uintptr) { | |
| 1885 | 1916 | fa := DBusConnection{} | |
| 1886 | 1917 | fa.Ptr = clsPtr | |
| 1918 | + | cbFn := *cb | |
| 1887 | 1919 | ||
| 1888 | - | cb(fa, RemotePeerVanishedVarp, ErrorVarp) | |
| 1920 | + | cbFn(fa, RemotePeerVanishedVarp, ErrorVarp) | |
| 1889 | 1921 | ||
| 1890 | 1922 | } | |
| 1891 | - | return gobject.SignalConnect(x.GoPointer(), "closed", purego.NewCallback(fcb)) | |
| 1923 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1924 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1925 | + | return gobject.SignalConnect(x.GoPointer(), "closed", cbRefPtr) | |
| 1892 | 1926 | } | |
| 1893 | 1927 | ||
| 1894 | 1928 | // Starts asynchronous initialization of the object implementing the | |
| @@ -1927,9 +1961,9 @@ func (x *DBusConnection) ConnectClosed(cb func(DBusConnection, bool, uintptr)) u | |||
| 1927 | 1961 | // in a thread, so if you want to support asynchronous initialization via | |
| 1928 | 1962 | // threads, just implement the #GAsyncInitable interface without overriding | |
| 1929 | 1963 | // any interface methods. | |
| 1930 | - | func (x *DBusConnection) InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 1964 | + | func (x *DBusConnection) InitAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 1931 | 1965 | ||
| 1932 | - | XGAsyncInitableInitAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 1966 | + | XGAsyncInitableInitAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 1933 | 1967 | ||
| 1934 | 1968 | } | |
| 1935 | 1969 | ||
| @@ -2037,9 +2071,9 @@ var xDBusConnectionNew func(uintptr, string, DBusConnectionFlags, uintptr, uintp | |||
| 2037 | 2071 | // This is an asynchronous failable constructor. See | |
| 2038 | 2072 | // g_dbus_connection_new_sync() for the synchronous | |
| 2039 | 2073 | // version. | |
| 2040 | - | func DBusConnectionNew(StreamVar *IOStream, GuidVar string, FlagsVar DBusConnectionFlags, ObserverVar *DBusAuthObserver, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2074 | + | func DBusConnectionNew(StreamVar *IOStream, GuidVar string, FlagsVar DBusConnectionFlags, ObserverVar *DBusAuthObserver, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2041 | 2075 | ||
| 2042 | - | xDBusConnectionNew(StreamVar.GoPointer(), GuidVar, FlagsVar, ObserverVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2076 | + | xDBusConnectionNew(StreamVar.GoPointer(), GuidVar, FlagsVar, ObserverVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2043 | 2077 | ||
| 2044 | 2078 | } | |
| 2045 | 2079 | ||
| @@ -2067,9 +2101,9 @@ var xDBusConnectionNewForAddress func(string, DBusConnectionFlags, uintptr, uint | |||
| 2067 | 2101 | // This is an asynchronous failable constructor. See | |
| 2068 | 2102 | // g_dbus_connection_new_for_address_sync() for the synchronous | |
| 2069 | 2103 | // version. | |
| 2070 | - | func DBusConnectionNewForAddress(AddressVar string, FlagsVar DBusConnectionFlags, ObserverVar *DBusAuthObserver, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 2104 | + | func DBusConnectionNewForAddress(AddressVar string, FlagsVar DBusConnectionFlags, ObserverVar *DBusAuthObserver, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 2071 | 2105 | ||
| 2072 | - | xDBusConnectionNewForAddress(AddressVar, FlagsVar, ObserverVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 2106 | + | xDBusConnectionNewForAddress(AddressVar, FlagsVar, ObserverVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 2073 | 2107 | ||
| 2074 | 2108 | } | |
| 2075 | 2109 | ||
| @@ -3230,15 +3264,23 @@ func (c *DBusServer) SetGoPointer(ptr uintptr) { | |||
| 3230 | 3264 | // before incoming messages on @connection are processed. This means | |
| 3231 | 3265 | // that it's suitable to call g_dbus_connection_register_object() or | |
| 3232 | 3266 | // similar from the signal handler. | |
| 3233 | - | func (x *DBusServer) ConnectNewConnection(cb func(DBusServer, uintptr) bool) uint32 { | |
| 3267 | + | func (x *DBusServer) ConnectNewConnection(cb *func(DBusServer, uintptr) bool) uint32 { | |
| 3268 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3269 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3270 | + | return gobject.SignalConnect(x.GoPointer(), "new-connection", cbRefPtr) | |
| 3271 | + | } | |
| 3272 | + | ||
| 3234 | 3273 | fcb := func(clsPtr uintptr, ConnectionVarp uintptr) bool { | |
| 3235 | 3274 | fa := DBusServer{} | |
| 3236 | 3275 | fa.Ptr = clsPtr | |
| 3276 | + | cbFn := *cb | |
| 3237 | 3277 | ||
| 3238 | - | return cb(fa, ConnectionVarp) | |
| 3278 | + | return cbFn(fa, ConnectionVarp) | |
| 3239 | 3279 | ||
| 3240 | 3280 | } | |
| 3241 | - | return gobject.SignalConnect(x.GoPointer(), "new-connection", purego.NewCallback(fcb)) | |
| 3281 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3282 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3283 | + | return gobject.SignalConnect(x.GoPointer(), "new-connection", cbRefPtr) | |
| 3242 | 3284 | } | |
| 3243 | 3285 | ||
| 3244 | 3286 | // Initializes the object implementing the interface. | |
| @@ -4525,15 +4567,23 @@ func (c *SimpleAction) SetGoPointer(ptr uintptr) { | |||
| 4525 | 4567 | // type, the default is to forward them directly to | |
| 4526 | 4568 | // #GSimpleAction::change-state. This should allow almost all users | |
| 4527 | 4569 | // of #GSimpleAction to connect only one handler or the other. | |
| 4528 | - | func (x *SimpleAction) ConnectActivate(cb func(SimpleAction, uintptr)) uint32 { | |
| 4570 | + | func (x *SimpleAction) ConnectActivate(cb *func(SimpleAction, uintptr)) uint32 { | |
| 4571 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 4572 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 4573 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 4574 | + | } | |
| 4575 | + | ||
| 4529 | 4576 | fcb := func(clsPtr uintptr, ParameterVarp uintptr) { | |
| 4530 | 4577 | fa := SimpleAction{} | |
| 4531 | 4578 | fa.Ptr = clsPtr | |
| 4579 | + | cbFn := *cb | |
| 4532 | 4580 | ||
| 4533 | - | cb(fa, ParameterVarp) | |
| 4581 | + | cbFn(fa, ParameterVarp) | |
| 4534 | 4582 | ||
| 4535 | 4583 | } | |
| 4536 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 4584 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 4585 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 4586 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 4537 | 4587 | } | |
| 4538 | 4588 | ||
| 4539 | 4589 | // Indicates that the action just received a request to change its | |
| @@ -4572,15 +4622,23 @@ func (x *SimpleAction) ConnectActivate(cb func(SimpleAction, uintptr)) uint32 { | |||
| 4572 | 4622 | // | |
| 4573 | 4623 | // The handler need not set the state to the requested value. | |
| 4574 | 4624 | // It could set it to any value at all, or take some other action. | |
| 4575 | - | func (x *SimpleAction) ConnectChangeState(cb func(SimpleAction, uintptr)) uint32 { | |
| 4625 | + | func (x *SimpleAction) ConnectChangeState(cb *func(SimpleAction, uintptr)) uint32 { | |
| 4626 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 4627 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 4628 | + | return gobject.SignalConnect(x.GoPointer(), "change-state", cbRefPtr) | |
| 4629 | + | } | |
| 4630 | + | ||
| 4576 | 4631 | fcb := func(clsPtr uintptr, ValueVarp uintptr) { | |
| 4577 | 4632 | fa := SimpleAction{} | |
| 4578 | 4633 | fa.Ptr = clsPtr | |
| 4634 | + | cbFn := *cb | |
| 4579 | 4635 | ||
| 4580 | - | cb(fa, ValueVarp) | |
| 4636 | + | cbFn(fa, ValueVarp) | |
| 4581 | 4637 | ||
| 4582 | 4638 | } | |
| 4583 | - | return gobject.SignalConnect(x.GoPointer(), "change-state", purego.NewCallback(fcb)) | |
| 4639 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 4640 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 4641 | + | return gobject.SignalConnect(x.GoPointer(), "change-state", cbRefPtr) | |
| 4584 | 4642 | } | |
| 4585 | 4643 | ||
| 4586 | 4644 | // Activates the action. | |
| @@ -4952,9 +5010,9 @@ var xSubprocessCommunicateAsync func(uintptr, *glib.Bytes, uintptr, uintptr, uin | |||
| 4952 | 5010 | ||
| 4953 | 5011 | // Asynchronous version of g_subprocess_communicate(). Complete | |
| 4954 | 5012 | // invocation with g_subprocess_communicate_finish(). | |
| 4955 | - | func (x *Subprocess) CommunicateAsync(StdinBufVar *glib.Bytes, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 5013 | + | func (x *Subprocess) CommunicateAsync(StdinBufVar *glib.Bytes, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 4956 | 5014 | ||
| 4957 | - | xSubprocessCommunicateAsync(x.GoPointer(), StdinBufVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 5015 | + | xSubprocessCommunicateAsync(x.GoPointer(), StdinBufVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 4958 | 5016 | ||
| 4959 | 5017 | } | |
| 4960 | 5018 | ||
| @@ -4994,9 +5052,9 @@ var xSubprocessCommunicateUtf8Async func(uintptr, string, uintptr, uintptr, uint | |||
| 4994 | 5052 | ||
| 4995 | 5053 | // Asynchronous version of g_subprocess_communicate_utf8(). Complete | |
| 4996 | 5054 | // invocation with g_subprocess_communicate_utf8_finish(). | |
| 4997 | - | func (x *Subprocess) CommunicateUtf8Async(StdinBufVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 5055 | + | func (x *Subprocess) CommunicateUtf8Async(StdinBufVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 4998 | 5056 | ||
| 4999 | - | xSubprocessCommunicateUtf8Async(x.GoPointer(), StdinBufVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 5057 | + | xSubprocessCommunicateUtf8Async(x.GoPointer(), StdinBufVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 5000 | 5058 | ||
| 5001 | 5059 | } | |
| 5002 | 5060 | ||
| @@ -5240,9 +5298,9 @@ var xSubprocessWaitAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 5240 | 5298 | // Wait for the subprocess to terminate. | |
| 5241 | 5299 | // | |
| 5242 | 5300 | // This is the asynchronous version of g_subprocess_wait(). | |
| 5243 | - | func (x *Subprocess) WaitAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 5301 | + | func (x *Subprocess) WaitAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 5244 | 5302 | ||
| 5245 | - | xSubprocessWaitAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 5303 | + | xSubprocessWaitAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 5246 | 5304 | ||
| 5247 | 5305 | } | |
| 5248 | 5306 | ||
| @@ -5265,9 +5323,9 @@ var xSubprocessWaitCheckAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 5265 | 5323 | // Combines g_subprocess_wait_async() with g_spawn_check_wait_status(). | |
| 5266 | 5324 | // | |
| 5267 | 5325 | // This is the asynchronous version of g_subprocess_wait_check(). | |
| 5268 | - | func (x *Subprocess) WaitCheckAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 5326 | + | func (x *Subprocess) WaitCheckAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 5269 | 5327 | ||
| 5270 | - | xSubprocessWaitCheckAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 5328 | + | xSubprocessWaitCheckAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 5271 | 5329 | ||
| 5272 | 5330 | } | |
| 5273 | 5331 | ||
| @@ -5442,9 +5500,9 @@ var xSubprocessLauncherSetChildSetup func(uintptr, uintptr, uintptr, uintptr) | |||
| 5442 | 5500 | // %NULL can be given as @child_setup to disable the functionality. | |
| 5443 | 5501 | // | |
| 5444 | 5502 | // Child setup functions are only available on UNIX. | |
| 5445 | - | func (x *SubprocessLauncher) SetChildSetup(ChildSetupVar glib.SpawnChildSetupFunc, UserDataVar uintptr, DestroyNotifyVar glib.DestroyNotify) { | |
| 5503 | + | func (x *SubprocessLauncher) SetChildSetup(ChildSetupVar *glib.SpawnChildSetupFunc, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify) { | |
| 5446 | 5504 | ||
| 5447 | - | xSubprocessLauncherSetChildSetup(x.GoPointer(), purego.NewCallback(ChildSetupVar), UserDataVar, purego.NewCallback(DestroyNotifyVar)) | |
| 5505 | + | xSubprocessLauncherSetChildSetup(x.GoPointer(), glib.NewCallback(ChildSetupVar), UserDataVar, glib.NewCallback(DestroyNotifyVar)) | |
| 5448 | 5506 | ||
| 5449 | 5507 | } | |
| 5450 | 5508 | ||
M v4/gio/gioscheduler.go +2 -2
| @@ -29,9 +29,9 @@ var xIoSchedulerPushJob func(uintptr, uintptr, uintptr, int, uintptr) | |||
| 29 | 29 | // If @cancellable is not %NULL, it can be used to cancel the I/O job | |
| 30 | 30 | // by calling g_cancellable_cancel() or by calling | |
| 31 | 31 | // g_io_scheduler_cancel_all_jobs(). | |
| 32 | - | func IoSchedulerPushJob(JobFuncVar IOSchedulerJobFunc, UserDataVar uintptr, NotifyVar glib.DestroyNotify, IoPriorityVar int, CancellableVar *Cancellable) { | |
| 32 | + | func IoSchedulerPushJob(JobFuncVar *IOSchedulerJobFunc, UserDataVar uintptr, NotifyVar *glib.DestroyNotify, IoPriorityVar int, CancellableVar *Cancellable) { | |
| 33 | 33 | ||
| 34 | - | xIoSchedulerPushJob(purego.NewCallback(JobFuncVar), UserDataVar, purego.NewCallback(NotifyVar), IoPriorityVar, CancellableVar.GoPointer()) | |
| 34 | + | xIoSchedulerPushJob(glib.NewCallback(JobFuncVar), UserDataVar, glib.NewCallback(NotifyVar), IoPriorityVar, CancellableVar.GoPointer()) | |
| 35 | 35 | ||
| 36 | 36 | } | |
| 37 | 37 | ||
M v4/gio/giostream.go +4 -4
| @@ -148,9 +148,9 @@ var xIOStreamCloseAsync func(uintptr, int, uintptr, uintptr, uintptr) | |||
| 148 | 148 | // The asynchronous methods have a default fallback that uses threads | |
| 149 | 149 | // to implement asynchronicity, so they are optional for inheriting | |
| 150 | 150 | // classes. However, if you override one you must override all. | |
| 151 | - | func (x *IOStream) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 151 | + | func (x *IOStream) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 152 | 152 | ||
| 153 | - | xIOStreamCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 153 | + | xIOStreamCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 154 | 154 | ||
| 155 | 155 | } | |
| 156 | 156 | ||
| @@ -247,9 +247,9 @@ var xIOStreamSpliceAsync func(uintptr, uintptr, IOStreamSpliceFlags, int, uintpt | |||
| 247 | 247 | // When the operation is finished @callback will be called. | |
| 248 | 248 | // You can then call g_io_stream_splice_finish() to get the | |
| 249 | 249 | // result of the operation. | |
| 250 | - | func (x *IOStream) SpliceAsync(Stream2Var *IOStream, FlagsVar IOStreamSpliceFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 250 | + | func (x *IOStream) SpliceAsync(Stream2Var *IOStream, FlagsVar IOStreamSpliceFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 251 | 251 | ||
| 252 | - | xIOStreamSpliceAsync(x.GoPointer(), Stream2Var.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 252 | + | xIOStreamSpliceAsync(x.GoPointer(), Stream2Var.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 253 | 253 | ||
| 254 | 254 | } | |
| 255 | 255 | ||
M v4/gio/giotypes.go +4 -4
| @@ -335,9 +335,9 @@ var xIOSchedulerJobSendToMainloop func(uintptr, uintptr, uintptr, uintptr) bool | |||
| 335 | 335 | // Used from an I/O job to send a callback to be run in the thread | |
| 336 | 336 | // that the job was started from, waiting for the result (and thus | |
| 337 | 337 | // blocking the I/O job). | |
| 338 | - | func (x *IOSchedulerJob) SendToMainloop(FuncVar glib.SourceFunc, UserDataVar uintptr, NotifyVar glib.DestroyNotify) bool { | |
| 338 | + | func (x *IOSchedulerJob) SendToMainloop(FuncVar *glib.SourceFunc, UserDataVar uintptr, NotifyVar *glib.DestroyNotify) bool { | |
| 339 | 339 | ||
| 340 | - | cret := xIOSchedulerJobSendToMainloop(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar, purego.NewCallback(NotifyVar)) | |
| 340 | + | cret := xIOSchedulerJobSendToMainloop(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar, glib.NewCallback(NotifyVar)) | |
| 341 | 341 | return cret | |
| 342 | 342 | } | |
| 343 | 343 | ||
| @@ -352,9 +352,9 @@ var xIOSchedulerJobSendToMainloopAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 352 | 352 | // on to this function you have to ensure that it is not freed before | |
| 353 | 353 | // @func is called, either by passing %NULL as @notify to | |
| 354 | 354 | // g_io_scheduler_push_job() or by using refcounting for @user_data. | |
| 355 | - | func (x *IOSchedulerJob) SendToMainloopAsync(FuncVar glib.SourceFunc, UserDataVar uintptr, NotifyVar glib.DestroyNotify) { | |
| 355 | + | func (x *IOSchedulerJob) SendToMainloopAsync(FuncVar *glib.SourceFunc, UserDataVar uintptr, NotifyVar *glib.DestroyNotify) { | |
| 356 | 356 | ||
| 357 | - | xIOSchedulerJobSendToMainloopAsync(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar, purego.NewCallback(NotifyVar)) | |
| 357 | + | xIOSchedulerJobSendToMainloopAsync(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar, glib.NewCallback(NotifyVar)) | |
| 358 | 358 | ||
| 359 | 359 | } | |
| 360 | 360 | ||
M v4/gio/gliststore.go +6 -6
| @@ -84,9 +84,9 @@ var xListStoreFindWithEqualFunc func(uintptr, uintptr, uintptr, uint) bool | |||
| 84 | 84 | // comparing them with @compare_func until the first occurrence of @item which | |
| 85 | 85 | // matches. If @item was not found, then @position will not be set, and this | |
| 86 | 86 | // method will return %FALSE. | |
| 87 | - | func (x *ListStore) FindWithEqualFunc(ItemVar *gobject.Object, EqualFuncVar glib.EqualFunc, PositionVar uint) bool { | |
| 87 | + | func (x *ListStore) FindWithEqualFunc(ItemVar *gobject.Object, EqualFuncVar *glib.EqualFunc, PositionVar uint) bool { | |
| 88 | 88 | ||
| 89 | - | cret := xListStoreFindWithEqualFunc(x.GoPointer(), ItemVar.GoPointer(), purego.NewCallback(EqualFuncVar), PositionVar) | |
| 89 | + | cret := xListStoreFindWithEqualFunc(x.GoPointer(), ItemVar.GoPointer(), glib.NewCallback(EqualFuncVar), PositionVar) | |
| 90 | 90 | return cret | |
| 91 | 91 | } | |
| 92 | 92 | ||
| @@ -116,9 +116,9 @@ var xListStoreInsertSorted func(uintptr, uintptr, uintptr, uintptr) uint | |||
| 116 | 116 | // inserting items by way of this function. | |
| 117 | 117 | // | |
| 118 | 118 | // This function takes a ref on @item. | |
| 119 | - | func (x *ListStore) InsertSorted(ItemVar *gobject.Object, CompareFuncVar glib.CompareDataFunc, UserDataVar uintptr) uint { | |
| 119 | + | func (x *ListStore) InsertSorted(ItemVar *gobject.Object, CompareFuncVar *glib.CompareDataFunc, UserDataVar uintptr) uint { | |
| 120 | 120 | ||
| 121 | - | cret := xListStoreInsertSorted(x.GoPointer(), ItemVar.GoPointer(), purego.NewCallback(CompareFuncVar), UserDataVar) | |
| 121 | + | cret := xListStoreInsertSorted(x.GoPointer(), ItemVar.GoPointer(), glib.NewCallback(CompareFuncVar), UserDataVar) | |
| 122 | 122 | return cret | |
| 123 | 123 | } | |
| 124 | 124 | ||
| @@ -147,9 +147,9 @@ func (x *ListStore) RemoveAll() { | |||
| 147 | 147 | var xListStoreSort func(uintptr, uintptr, uintptr) | |
| 148 | 148 | ||
| 149 | 149 | // Sort the items in @store according to @compare_func. | |
| 150 | - | func (x *ListStore) Sort(CompareFuncVar glib.CompareDataFunc, UserDataVar uintptr) { | |
| 150 | + | func (x *ListStore) Sort(CompareFuncVar *glib.CompareDataFunc, UserDataVar uintptr) { | |
| 151 | 151 | ||
| 152 | - | xListStoreSort(x.GoPointer(), purego.NewCallback(CompareFuncVar), UserDataVar) | |
| 152 | + | xListStoreSort(x.GoPointer(), glib.NewCallback(CompareFuncVar), UserDataVar) | |
| 153 | 153 | ||
| 154 | 154 | } | |
| 155 | 155 | ||
M v4/gio/gloadableicon.go +3 -3
| @@ -24,7 +24,7 @@ type LoadableIcon interface { | |||
| 24 | 24 | GoPointer() uintptr | |
| 25 | 25 | SetGoPointer(uintptr) | |
| 26 | 26 | Load(SizeVar int, TypeVar string, CancellableVar *Cancellable) *InputStream | |
| 27 | - | LoadAsync(SizeVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 27 | + | LoadAsync(SizeVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 28 | 28 | LoadFinish(ResVar AsyncResult, TypeVar string) *InputStream | |
| 29 | 29 | } | |
| 30 | 30 | type LoadableIconBase struct { | |
| @@ -62,9 +62,9 @@ func (x *LoadableIconBase) Load(SizeVar int, TypeVar string, CancellableVar *Can | |||
| 62 | 62 | // Loads an icon asynchronously. To finish this function, see | |
| 63 | 63 | // g_loadable_icon_load_finish(). For the synchronous, blocking | |
| 64 | 64 | // version of this function, see g_loadable_icon_load(). | |
| 65 | - | func (x *LoadableIconBase) LoadAsync(SizeVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 65 | + | func (x *LoadableIconBase) LoadAsync(SizeVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 66 | 66 | ||
| 67 | - | XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 67 | + | XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 68 | 68 | ||
| 69 | 69 | } | |
| 70 | 70 | ||
M v4/gio/gmemoryinputstream.go +4 -4
| @@ -74,10 +74,10 @@ func NewMemoryInputStreamFromBytes(BytesVar *glib.Bytes) *MemoryInputStream { | |||
| 74 | 74 | var xNewMemoryInputStreamFromData func(uintptr, int, uintptr) uintptr | |
| 75 | 75 | ||
| 76 | 76 | // Creates a new #GMemoryInputStream with data in memory of a given size. | |
| 77 | - | func NewMemoryInputStreamFromData(DataVar uintptr, LenVar int, DestroyVar glib.DestroyNotify) *MemoryInputStream { | |
| 77 | + | func NewMemoryInputStreamFromData(DataVar uintptr, LenVar int, DestroyVar *glib.DestroyNotify) *MemoryInputStream { | |
| 78 | 78 | var cls *MemoryInputStream | |
| 79 | 79 | ||
| 80 | - | cret := xNewMemoryInputStreamFromData(DataVar, LenVar, purego.NewCallback(DestroyVar)) | |
| 80 | + | cret := xNewMemoryInputStreamFromData(DataVar, LenVar, glib.NewCallback(DestroyVar)) | |
| 81 | 81 | ||
| 82 | 82 | if cret == 0 { | |
| 83 | 83 | return nil | |
| @@ -99,9 +99,9 @@ func (x *MemoryInputStream) AddBytes(BytesVar *glib.Bytes) { | |||
| 99 | 99 | var xMemoryInputStreamAddData func(uintptr, uintptr, int, uintptr) | |
| 100 | 100 | ||
| 101 | 101 | // Appends @data to data that can be read from the input stream | |
| 102 | - | func (x *MemoryInputStream) AddData(DataVar uintptr, LenVar int, DestroyVar glib.DestroyNotify) { | |
| 102 | + | func (x *MemoryInputStream) AddData(DataVar uintptr, LenVar int, DestroyVar *glib.DestroyNotify) { | |
| 103 | 103 | ||
| 104 | - | xMemoryInputStreamAddData(x.GoPointer(), DataVar, LenVar, purego.NewCallback(DestroyVar)) | |
| 104 | + | xMemoryInputStreamAddData(x.GoPointer(), DataVar, LenVar, glib.NewCallback(DestroyVar)) | |
| 105 | 105 | ||
| 106 | 106 | } | |
| 107 | 107 | ||
M v4/gio/gmemoryoutputstream.go +2 -2
| @@ -88,10 +88,10 @@ var xNewMemoryOutputStream func(uintptr, uint, uintptr, uintptr) uintptr | |||
| 88 | 88 | // data = malloc (200); | |
| 89 | 89 | // stream3 = g_memory_output_stream_new (data, 200, NULL, free); | |
| 90 | 90 | // ]| | |
| 91 | - | func NewMemoryOutputStream(DataVar uintptr, SizeVar uint, ReallocFunctionVar ReallocFunc, DestroyFunctionVar glib.DestroyNotify) *MemoryOutputStream { | |
| 91 | + | func NewMemoryOutputStream(DataVar uintptr, SizeVar uint, ReallocFunctionVar *ReallocFunc, DestroyFunctionVar *glib.DestroyNotify) *MemoryOutputStream { | |
| 92 | 92 | var cls *MemoryOutputStream | |
| 93 | 93 | ||
| 94 | - | cret := xNewMemoryOutputStream(DataVar, SizeVar, purego.NewCallback(ReallocFunctionVar), purego.NewCallback(DestroyFunctionVar)) | |
| 94 | + | cret := xNewMemoryOutputStream(DataVar, SizeVar, glib.NewCallback(ReallocFunctionVar), glib.NewCallback(DestroyFunctionVar)) | |
| 95 | 95 | ||
| 96 | 96 | if cret == 0 { | |
| 97 | 97 | return nil | |
M v4/gio/gmenumodel.go +11 -3
| @@ -559,15 +559,23 @@ func (c *MenuModel) SetGoPointer(ptr uintptr) { | |||
| 559 | 559 | // Signal handlers may query the model (particularly the added items) | |
| 560 | 560 | // and expect to see the results of the modification that is being | |
| 561 | 561 | // reported. The signal is emitted after the modification. | |
| 562 | - | func (x *MenuModel) ConnectItemsChanged(cb func(MenuModel, int, int, int)) uint32 { | |
| 562 | + | func (x *MenuModel) ConnectItemsChanged(cb *func(MenuModel, int, int, int)) uint32 { | |
| 563 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 564 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 565 | + | return gobject.SignalConnect(x.GoPointer(), "items-changed", cbRefPtr) | |
| 566 | + | } | |
| 567 | + | ||
| 563 | 568 | fcb := func(clsPtr uintptr, PositionVarp int, RemovedVarp int, AddedVarp int) { | |
| 564 | 569 | fa := MenuModel{} | |
| 565 | 570 | fa.Ptr = clsPtr | |
| 571 | + | cbFn := *cb | |
| 566 | 572 | ||
| 567 | - | cb(fa, PositionVarp, RemovedVarp, AddedVarp) | |
| 573 | + | cbFn(fa, PositionVarp, RemovedVarp, AddedVarp) | |
| 568 | 574 | ||
| 569 | 575 | } | |
| 570 | - | return gobject.SignalConnect(x.GoPointer(), "items-changed", purego.NewCallback(fcb)) | |
| 576 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 577 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 578 | + | return gobject.SignalConnect(x.GoPointer(), "items-changed", cbRefPtr) | |
| 571 | 579 | } | |
| 572 | 580 | ||
| 573 | 581 | func init() { | |
M v4/gio/gmount.go +18 -18
| @@ -42,9 +42,9 @@ type Mount interface { | |||
| 42 | 42 | SetGoPointer(uintptr) | |
| 43 | 43 | CanEject() bool | |
| 44 | 44 | CanUnmount() bool | |
| 45 | - | Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 45 | + | Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 46 | 46 | EjectFinish(ResultVar AsyncResult) bool | |
| 47 | - | EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 47 | + | EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 48 | 48 | EjectWithOperationFinish(ResultVar AsyncResult) bool | |
| 49 | 49 | GetDefaultLocation() *FileBase | |
| 50 | 50 | GetDrive() *DriveBase | |
| @@ -55,16 +55,16 @@ type Mount interface { | |||
| 55 | 55 | GetSymbolicIcon() *IconBase | |
| 56 | 56 | GetUuid() string | |
| 57 | 57 | GetVolume() *VolumeBase | |
| 58 | - | GuessContentType(ForceRescanVar bool, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 58 | + | GuessContentType(ForceRescanVar bool, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 59 | 59 | GuessContentTypeFinish(ResultVar AsyncResult) uintptr | |
| 60 | 60 | GuessContentTypeSync(ForceRescanVar bool, CancellableVar *Cancellable) uintptr | |
| 61 | 61 | IsShadowed() bool | |
| 62 | - | Remount(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 62 | + | Remount(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 63 | 63 | RemountFinish(ResultVar AsyncResult) bool | |
| 64 | 64 | Shadow() | |
| 65 | - | Unmount(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 65 | + | Unmount(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 66 | 66 | UnmountFinish(ResultVar AsyncResult) bool | |
| 67 | - | UnmountWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 67 | + | UnmountWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 68 | 68 | UnmountWithOperationFinish(ResultVar AsyncResult) bool | |
| 69 | 69 | Unshadow() | |
| 70 | 70 | } | |
| @@ -97,9 +97,9 @@ func (x *MountBase) CanUnmount() bool { | |||
| 97 | 97 | // Ejects a mount. This is an asynchronous operation, and is | |
| 98 | 98 | // finished by calling g_mount_eject_finish() with the @mount | |
| 99 | 99 | // and #GAsyncResult data returned in the @callback. | |
| 100 | - | func (x *MountBase) Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 100 | + | func (x *MountBase) Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 101 | 101 | ||
| 102 | - | XGMountEject(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 102 | + | XGMountEject(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 103 | 103 | ||
| 104 | 104 | } | |
| 105 | 105 | ||
| @@ -119,9 +119,9 @@ func (x *MountBase) EjectFinish(ResultVar AsyncResult) (bool, error) { | |||
| 119 | 119 | // Ejects a mount. This is an asynchronous operation, and is | |
| 120 | 120 | // finished by calling g_mount_eject_with_operation_finish() with the @mount | |
| 121 | 121 | // and #GAsyncResult data returned in the @callback. | |
| 122 | - | func (x *MountBase) EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 122 | + | func (x *MountBase) EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 123 | 123 | ||
| 124 | - | XGMountEjectWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 124 | + | XGMountEjectWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 125 | 125 | ||
| 126 | 126 | } | |
| 127 | 127 | ||
| @@ -262,9 +262,9 @@ func (x *MountBase) GetVolume() *VolumeBase { | |||
| 262 | 262 | // g_mount_guess_content_type_sync() for the synchronous version), and | |
| 263 | 263 | // is finished by calling g_mount_guess_content_type_finish() with the | |
| 264 | 264 | // @mount and #GAsyncResult data returned in the @callback. | |
| 265 | - | func (x *MountBase) GuessContentType(ForceRescanVar bool, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 265 | + | func (x *MountBase) GuessContentType(ForceRescanVar bool, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 266 | 266 | ||
| 267 | - | XGMountGuessContentType(x.GoPointer(), ForceRescanVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 267 | + | XGMountGuessContentType(x.GoPointer(), ForceRescanVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 268 | 268 | ||
| 269 | 269 | } | |
| 270 | 270 | ||
| @@ -342,9 +342,9 @@ func (x *MountBase) IsShadowed() bool { | |||
| 342 | 342 | // take affect. While this is semantically equivalent with unmounting | |
| 343 | 343 | // and then remounting not all backends might need to actually be | |
| 344 | 344 | // unmounted. | |
| 345 | - | func (x *MountBase) Remount(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 345 | + | func (x *MountBase) Remount(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 346 | 346 | ||
| 347 | - | XGMountRemount(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 347 | + | XGMountRemount(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 348 | 348 | ||
| 349 | 349 | } | |
| 350 | 350 | ||
| @@ -374,9 +374,9 @@ func (x *MountBase) Shadow() { | |||
| 374 | 374 | // Unmounts a mount. This is an asynchronous operation, and is | |
| 375 | 375 | // finished by calling g_mount_unmount_finish() with the @mount | |
| 376 | 376 | // and #GAsyncResult data returned in the @callback. | |
| 377 | - | func (x *MountBase) Unmount(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 377 | + | func (x *MountBase) Unmount(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 378 | 378 | ||
| 379 | - | XGMountUnmount(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 379 | + | XGMountUnmount(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 380 | 380 | ||
| 381 | 381 | } | |
| 382 | 382 | ||
| @@ -396,9 +396,9 @@ func (x *MountBase) UnmountFinish(ResultVar AsyncResult) (bool, error) { | |||
| 396 | 396 | // Unmounts a mount. This is an asynchronous operation, and is | |
| 397 | 397 | // finished by calling g_mount_unmount_with_operation_finish() with the @mount | |
| 398 | 398 | // and #GAsyncResult data returned in the @callback. | |
| 399 | - | func (x *MountBase) UnmountWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 399 | + | func (x *MountBase) UnmountWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 400 | 400 | ||
| 401 | - | XGMountUnmountWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 401 | + | XGMountUnmountWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 402 | 402 | ||
| 403 | 403 | } | |
| 404 | 404 | ||
M v4/gio/gmountoperation.go +67 -18
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -258,15 +259,23 @@ func (c *MountOperation) SetGoPointer(ptr uintptr) { | |||
| 258 | 259 | // | |
| 259 | 260 | // Implementations of GMountOperation should handle this signal | |
| 260 | 261 | // by dismissing open password dialogs. | |
| 261 | - | func (x *MountOperation) ConnectAborted(cb func(MountOperation)) uint32 { | |
| 262 | + | func (x *MountOperation) ConnectAborted(cb *func(MountOperation)) uint32 { | |
| 263 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 264 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 265 | + | return gobject.SignalConnect(x.GoPointer(), "aborted", cbRefPtr) | |
| 266 | + | } | |
| 267 | + | ||
| 262 | 268 | fcb := func(clsPtr uintptr) { | |
| 263 | 269 | fa := MountOperation{} | |
| 264 | 270 | fa.Ptr = clsPtr | |
| 271 | + | cbFn := *cb | |
| 265 | 272 | ||
| 266 | - | cb(fa) | |
| 273 | + | cbFn(fa) | |
| 267 | 274 | ||
| 268 | 275 | } | |
| 269 | - | return gobject.SignalConnect(x.GoPointer(), "aborted", purego.NewCallback(fcb)) | |
| 276 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 277 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 278 | + | return gobject.SignalConnect(x.GoPointer(), "aborted", cbRefPtr) | |
| 270 | 279 | } | |
| 271 | 280 | ||
| 272 | 281 | // Emitted when a mount operation asks the user for a password. | |
| @@ -274,15 +283,23 @@ func (x *MountOperation) ConnectAborted(cb func(MountOperation)) uint32 { | |||
| 274 | 283 | // If the message contains a line break, the first line should be | |
| 275 | 284 | // presented as a heading. For example, it may be used as the | |
| 276 | 285 | // primary text in a #GtkMessageDialog. | |
| 277 | - | func (x *MountOperation) ConnectAskPassword(cb func(MountOperation, string, string, string, AskPasswordFlags)) uint32 { | |
| 286 | + | func (x *MountOperation) ConnectAskPassword(cb *func(MountOperation, string, string, string, AskPasswordFlags)) uint32 { | |
| 287 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 288 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 289 | + | return gobject.SignalConnect(x.GoPointer(), "ask-password", cbRefPtr) | |
| 290 | + | } | |
| 291 | + | ||
| 278 | 292 | fcb := func(clsPtr uintptr, MessageVarp string, DefaultUserVarp string, DefaultDomainVarp string, FlagsVarp AskPasswordFlags) { | |
| 279 | 293 | fa := MountOperation{} | |
| 280 | 294 | fa.Ptr = clsPtr | |
| 295 | + | cbFn := *cb | |
| 281 | 296 | ||
| 282 | - | cb(fa, MessageVarp, DefaultUserVarp, DefaultDomainVarp, FlagsVarp) | |
| 297 | + | cbFn(fa, MessageVarp, DefaultUserVarp, DefaultDomainVarp, FlagsVarp) | |
| 283 | 298 | ||
| 284 | 299 | } | |
| 285 | - | return gobject.SignalConnect(x.GoPointer(), "ask-password", purego.NewCallback(fcb)) | |
| 300 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 301 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 302 | + | return gobject.SignalConnect(x.GoPointer(), "ask-password", cbRefPtr) | |
| 286 | 303 | } | |
| 287 | 304 | ||
| 288 | 305 | // Emitted when asking the user a question and gives a list of | |
| @@ -291,27 +308,43 @@ func (x *MountOperation) ConnectAskPassword(cb func(MountOperation, string, stri | |||
| 291 | 308 | // If the message contains a line break, the first line should be | |
| 292 | 309 | // presented as a heading. For example, it may be used as the | |
| 293 | 310 | // primary text in a #GtkMessageDialog. | |
| 294 | - | func (x *MountOperation) ConnectAskQuestion(cb func(MountOperation, string, uintptr)) uint32 { | |
| 311 | + | func (x *MountOperation) ConnectAskQuestion(cb *func(MountOperation, string, uintptr)) uint32 { | |
| 312 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 313 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 314 | + | return gobject.SignalConnect(x.GoPointer(), "ask-question", cbRefPtr) | |
| 315 | + | } | |
| 316 | + | ||
| 295 | 317 | fcb := func(clsPtr uintptr, MessageVarp string, ChoicesVarp uintptr) { | |
| 296 | 318 | fa := MountOperation{} | |
| 297 | 319 | fa.Ptr = clsPtr | |
| 320 | + | cbFn := *cb | |
| 298 | 321 | ||
| 299 | - | cb(fa, MessageVarp, ChoicesVarp) | |
| 322 | + | cbFn(fa, MessageVarp, ChoicesVarp) | |
| 300 | 323 | ||
| 301 | 324 | } | |
| 302 | - | return gobject.SignalConnect(x.GoPointer(), "ask-question", purego.NewCallback(fcb)) | |
| 325 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 326 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 327 | + | return gobject.SignalConnect(x.GoPointer(), "ask-question", cbRefPtr) | |
| 303 | 328 | } | |
| 304 | 329 | ||
| 305 | 330 | // Emitted when the user has replied to the mount operation. | |
| 306 | - | func (x *MountOperation) ConnectReply(cb func(MountOperation, MountOperationResult)) uint32 { | |
| 331 | + | func (x *MountOperation) ConnectReply(cb *func(MountOperation, MountOperationResult)) uint32 { | |
| 332 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 333 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 334 | + | return gobject.SignalConnect(x.GoPointer(), "reply", cbRefPtr) | |
| 335 | + | } | |
| 336 | + | ||
| 307 | 337 | fcb := func(clsPtr uintptr, ResultVarp MountOperationResult) { | |
| 308 | 338 | fa := MountOperation{} | |
| 309 | 339 | fa.Ptr = clsPtr | |
| 340 | + | cbFn := *cb | |
| 310 | 341 | ||
| 311 | - | cb(fa, ResultVarp) | |
| 342 | + | cbFn(fa, ResultVarp) | |
| 312 | 343 | ||
| 313 | 344 | } | |
| 314 | - | return gobject.SignalConnect(x.GoPointer(), "reply", purego.NewCallback(fcb)) | |
| 345 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 346 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 347 | + | return gobject.SignalConnect(x.GoPointer(), "reply", cbRefPtr) | |
| 315 | 348 | } | |
| 316 | 349 | ||
| 317 | 350 | // Emitted when one or more processes are blocking an operation | |
| @@ -326,15 +359,23 @@ func (x *MountOperation) ConnectReply(cb func(MountOperation, MountOperationResu | |||
| 326 | 359 | // If the message contains a line break, the first line should be | |
| 327 | 360 | // presented as a heading. For example, it may be used as the | |
| 328 | 361 | // primary text in a #GtkMessageDialog. | |
| 329 | - | func (x *MountOperation) ConnectShowProcesses(cb func(MountOperation, string, uintptr, uintptr)) uint32 { | |
| 362 | + | func (x *MountOperation) ConnectShowProcesses(cb *func(MountOperation, string, uintptr, uintptr)) uint32 { | |
| 363 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 364 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 365 | + | return gobject.SignalConnect(x.GoPointer(), "show-processes", cbRefPtr) | |
| 366 | + | } | |
| 367 | + | ||
| 330 | 368 | fcb := func(clsPtr uintptr, MessageVarp string, ProcessesVarp uintptr, ChoicesVarp uintptr) { | |
| 331 | 369 | fa := MountOperation{} | |
| 332 | 370 | fa.Ptr = clsPtr | |
| 371 | + | cbFn := *cb | |
| 333 | 372 | ||
| 334 | - | cb(fa, MessageVarp, ProcessesVarp, ChoicesVarp) | |
| 373 | + | cbFn(fa, MessageVarp, ProcessesVarp, ChoicesVarp) | |
| 335 | 374 | ||
| 336 | 375 | } | |
| 337 | - | return gobject.SignalConnect(x.GoPointer(), "show-processes", purego.NewCallback(fcb)) | |
| 376 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 377 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 378 | + | return gobject.SignalConnect(x.GoPointer(), "show-processes", cbRefPtr) | |
| 338 | 379 | } | |
| 339 | 380 | ||
| 340 | 381 | // Emitted when an unmount operation has been busy for more than some time | |
| @@ -353,15 +394,23 @@ func (x *MountOperation) ConnectShowProcesses(cb func(MountOperation, string, ui | |||
| 353 | 394 | // If the message contains a line break, the first line should be | |
| 354 | 395 | // presented as a heading. For example, it may be used as the | |
| 355 | 396 | // primary text in a #GtkMessageDialog. | |
| 356 | - | func (x *MountOperation) ConnectShowUnmountProgress(cb func(MountOperation, string, int64, int64)) uint32 { | |
| 397 | + | func (x *MountOperation) ConnectShowUnmountProgress(cb *func(MountOperation, string, int64, int64)) uint32 { | |
| 398 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 399 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 400 | + | return gobject.SignalConnect(x.GoPointer(), "show-unmount-progress", cbRefPtr) | |
| 401 | + | } | |
| 402 | + | ||
| 357 | 403 | fcb := func(clsPtr uintptr, MessageVarp string, TimeLeftVarp int64, BytesLeftVarp int64) { | |
| 358 | 404 | fa := MountOperation{} | |
| 359 | 405 | fa.Ptr = clsPtr | |
| 406 | + | cbFn := *cb | |
| 360 | 407 | ||
| 361 | - | cb(fa, MessageVarp, TimeLeftVarp, BytesLeftVarp) | |
| 408 | + | cbFn(fa, MessageVarp, TimeLeftVarp, BytesLeftVarp) | |
| 362 | 409 | ||
| 363 | 410 | } | |
| 364 | - | return gobject.SignalConnect(x.GoPointer(), "show-unmount-progress", purego.NewCallback(fcb)) | |
| 411 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 412 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 413 | + | return gobject.SignalConnect(x.GoPointer(), "show-unmount-progress", cbRefPtr) | |
| 365 | 414 | } | |
| 366 | 415 | ||
| 367 | 416 | func init() { | |
M v4/gio/gnetworkmonitor.go +3 -3
| @@ -29,7 +29,7 @@ type NetworkMonitor interface { | |||
| 29 | 29 | GoPointer() uintptr | |
| 30 | 30 | SetGoPointer(uintptr) | |
| 31 | 31 | CanReach(ConnectableVar SocketConnectable, CancellableVar *Cancellable) bool | |
| 32 | - | CanReachAsync(ConnectableVar SocketConnectable, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 32 | + | CanReachAsync(ConnectableVar SocketConnectable, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 33 | 33 | CanReachFinish(ResultVar AsyncResult) bool | |
| 34 | 34 | GetConnectivity() NetworkConnectivity | |
| 35 | 35 | GetNetworkAvailable() bool | |
| @@ -84,9 +84,9 @@ func (x *NetworkMonitorBase) CanReach(ConnectableVar SocketConnectable, Cancella | |||
| 84 | 84 | // When the operation is finished, @callback will be called. | |
| 85 | 85 | // You can then call g_network_monitor_can_reach_finish() | |
| 86 | 86 | // to get the result of the operation. | |
| 87 | - | func (x *NetworkMonitorBase) CanReachAsync(ConnectableVar SocketConnectable, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 87 | + | func (x *NetworkMonitorBase) CanReachAsync(ConnectableVar SocketConnectable, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 88 | 88 | ||
| 89 | - | XGNetworkMonitorCanReachAsync(x.GoPointer(), ConnectableVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 89 | + | XGNetworkMonitorCanReachAsync(x.GoPointer(), ConnectableVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 90 | 90 | ||
| 91 | 91 | } | |
| 92 | 92 | ||
M v4/gio/goutputstream.go +16 -16
| @@ -109,9 +109,9 @@ var xOutputStreamCloseAsync func(uintptr, int, uintptr, uintptr, uintptr) | |||
| 109 | 109 | // The asynchronous methods have a default fallback that uses threads | |
| 110 | 110 | // to implement asynchronicity, so they are optional for inheriting | |
| 111 | 111 | // classes. However, if you override one you must override all. | |
| 112 | - | func (x *OutputStream) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 112 | + | func (x *OutputStream) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 113 | 113 | ||
| 114 | - | xOutputStreamCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 114 | + | xOutputStreamCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 115 | 115 | ||
| 116 | 116 | } | |
| 117 | 117 | ||
| @@ -160,9 +160,9 @@ var xOutputStreamFlushAsync func(uintptr, int, uintptr, uintptr, uintptr) | |||
| 160 | 160 | // When the operation is finished @callback will be | |
| 161 | 161 | // called. You can then call g_output_stream_flush_finish() to get the | |
| 162 | 162 | // result of the operation. | |
| 163 | - | func (x *OutputStream) FlushAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 163 | + | func (x *OutputStream) FlushAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 164 | 164 | ||
| 165 | - | xOutputStreamFlushAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 165 | + | xOutputStreamFlushAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 166 | 166 | ||
| 167 | 167 | } | |
| 168 | 168 | ||
| @@ -269,9 +269,9 @@ var xOutputStreamSpliceAsync func(uintptr, uintptr, OutputStreamSpliceFlags, int | |||
| 269 | 269 | // | |
| 270 | 270 | // For the synchronous, blocking version of this function, see | |
| 271 | 271 | // g_output_stream_splice(). | |
| 272 | - | func (x *OutputStream) SpliceAsync(SourceVar *InputStream, FlagsVar OutputStreamSpliceFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 272 | + | func (x *OutputStream) SpliceAsync(SourceVar *InputStream, FlagsVar OutputStreamSpliceFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 273 | 273 | ||
| 274 | - | xOutputStreamSpliceAsync(x.GoPointer(), SourceVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 274 | + | xOutputStreamSpliceAsync(x.GoPointer(), SourceVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 275 | 275 | ||
| 276 | 276 | } | |
| 277 | 277 | ||
| @@ -391,9 +391,9 @@ var xOutputStreamWriteAllAsync func(uintptr, uintptr, uint, int, uintptr, uintpt | |||
| 391 | 391 | // | |
| 392 | 392 | // Note that no copy of @buffer will be made, so it must stay valid | |
| 393 | 393 | // until @callback is called. | |
| 394 | - | func (x *OutputStream) WriteAllAsync(BufferVar uintptr, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 394 | + | func (x *OutputStream) WriteAllAsync(BufferVar uintptr, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 395 | 395 | ||
| 396 | - | xOutputStreamWriteAllAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 396 | + | xOutputStreamWriteAllAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 397 | 397 | ||
| 398 | 398 | } | |
| 399 | 399 | ||
| @@ -457,9 +457,9 @@ var xOutputStreamWriteAsync func(uintptr, uintptr, uint, int, uintptr, uintptr, | |||
| 457 | 457 | // until @callback is called. See g_output_stream_write_bytes_async() | |
| 458 | 458 | // for a #GBytes version that will automatically hold a reference to | |
| 459 | 459 | // the contents (without copying) for the duration of the call. | |
| 460 | - | func (x *OutputStream) WriteAsync(BufferVar uintptr, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 460 | + | func (x *OutputStream) WriteAsync(BufferVar uintptr, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 461 | 461 | ||
| 462 | - | xOutputStreamWriteAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 462 | + | xOutputStreamWriteAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 463 | 463 | ||
| 464 | 464 | } | |
| 465 | 465 | ||
| @@ -502,9 +502,9 @@ var xOutputStreamWriteBytesAsync func(uintptr, *glib.Bytes, int, uintptr, uintpt | |||
| 502 | 502 | // | |
| 503 | 503 | // For the synchronous, blocking version of this function, see | |
| 504 | 504 | // g_output_stream_write_bytes(). | |
| 505 | - | func (x *OutputStream) WriteBytesAsync(BytesVar *glib.Bytes, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 505 | + | func (x *OutputStream) WriteBytesAsync(BytesVar *glib.Bytes, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 506 | 506 | ||
| 507 | - | xOutputStreamWriteBytesAsync(x.GoPointer(), BytesVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 507 | + | xOutputStreamWriteBytesAsync(x.GoPointer(), BytesVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 508 | 508 | ||
| 509 | 509 | } | |
| 510 | 510 | ||
| @@ -625,9 +625,9 @@ var xOutputStreamWritevAllAsync func(uintptr, uintptr, uint, int, uintptr, uintp | |||
| 625 | 625 | // Note that no copy of @vectors will be made, so it must stay valid | |
| 626 | 626 | // until @callback is called. The content of the individual elements | |
| 627 | 627 | // of @vectors might be changed by this function. | |
| 628 | - | func (x *OutputStream) WritevAllAsync(VectorsVar uintptr, NVectorsVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 628 | + | func (x *OutputStream) WritevAllAsync(VectorsVar uintptr, NVectorsVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 629 | 629 | ||
| 630 | - | xOutputStreamWritevAllAsync(x.GoPointer(), VectorsVar, NVectorsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 630 | + | xOutputStreamWritevAllAsync(x.GoPointer(), VectorsVar, NVectorsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 631 | 631 | ||
| 632 | 632 | } | |
| 633 | 633 | ||
| @@ -686,9 +686,9 @@ var xOutputStreamWritevAsync func(uintptr, uintptr, uint, int, uintptr, uintptr, | |||
| 686 | 686 | // | |
| 687 | 687 | // Note that no copy of @vectors will be made, so it must stay valid | |
| 688 | 688 | // until @callback is called. | |
| 689 | - | func (x *OutputStream) WritevAsync(VectorsVar uintptr, NVectorsVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 689 | + | func (x *OutputStream) WritevAsync(VectorsVar uintptr, NVectorsVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 690 | 690 | ||
| 691 | - | xOutputStreamWritevAsync(x.GoPointer(), VectorsVar, NVectorsVar, IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 691 | + | xOutputStreamWritevAsync(x.GoPointer(), VectorsVar, NVectorsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 692 | 692 | ||
| 693 | 693 | } | |
| 694 | 694 | ||
M v4/gio/gpermission.go +4 -4
| @@ -86,9 +86,9 @@ var xPermissionAcquireAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 86 | 86 | // | |
| 87 | 87 | // This is the first half of the asynchronous version of | |
| 88 | 88 | // g_permission_acquire(). | |
| 89 | - | func (x *Permission) AcquireAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 89 | + | func (x *Permission) AcquireAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 90 | 90 | ||
| 91 | - | xPermissionAcquireAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 91 | + | xPermissionAcquireAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 92 | 92 | ||
| 93 | 93 | } | |
| 94 | 94 | ||
| @@ -190,9 +190,9 @@ var xPermissionReleaseAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 190 | 190 | // | |
| 191 | 191 | // This is the first half of the asynchronous version of | |
| 192 | 192 | // g_permission_release(). | |
| 193 | - | func (x *Permission) ReleaseAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 193 | + | func (x *Permission) ReleaseAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 194 | 194 | ||
| 195 | - | xPermissionReleaseAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 195 | + | xPermissionReleaseAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 196 | 196 | ||
| 197 | 197 | } | |
| 198 | 198 | ||
M v4/gio/gproxy.go +3 -3
| @@ -28,7 +28,7 @@ type Proxy interface { | |||
| 28 | 28 | GoPointer() uintptr | |
| 29 | 29 | SetGoPointer(uintptr) | |
| 30 | 30 | Connect(ConnectionVar *IOStream, ProxyAddressVar *ProxyAddress, CancellableVar *Cancellable) *IOStream | |
| 31 | - | ConnectAsync(ConnectionVar *IOStream, ProxyAddressVar *ProxyAddress, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 31 | + | ConnectAsync(ConnectionVar *IOStream, ProxyAddressVar *ProxyAddress, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 32 | 32 | ConnectFinish(ResultVar AsyncResult) *IOStream | |
| 33 | 33 | SupportsHostname() bool | |
| 34 | 34 | } | |
| @@ -67,9 +67,9 @@ func (x *ProxyBase) Connect(ConnectionVar *IOStream, ProxyAddressVar *ProxyAddre | |||
| 67 | 67 | } | |
| 68 | 68 | ||
| 69 | 69 | // Asynchronous version of g_proxy_connect(). | |
| 70 | - | func (x *ProxyBase) ConnectAsync(ConnectionVar *IOStream, ProxyAddressVar *ProxyAddress, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 70 | + | func (x *ProxyBase) ConnectAsync(ConnectionVar *IOStream, ProxyAddressVar *ProxyAddress, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 71 | 71 | ||
| 72 | - | XGProxyConnectAsync(x.GoPointer(), ConnectionVar.GoPointer(), ProxyAddressVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 72 | + | XGProxyConnectAsync(x.GoPointer(), ConnectionVar.GoPointer(), ProxyAddressVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 73 | 73 | ||
| 74 | 74 | } | |
| 75 | 75 | ||
M v4/gio/gproxyresolver.go +3 -3
| @@ -31,7 +31,7 @@ type ProxyResolver interface { | |||
| 31 | 31 | SetGoPointer(uintptr) | |
| 32 | 32 | IsSupported() bool | |
| 33 | 33 | Lookup(UriVar string, CancellableVar *Cancellable) uintptr | |
| 34 | - | LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 34 | + | LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 35 | 35 | LookupFinish(ResultVar AsyncResult) uintptr | |
| 36 | 36 | } | |
| 37 | 37 | type ProxyResolverBase struct { | |
| @@ -83,9 +83,9 @@ func (x *ProxyResolverBase) Lookup(UriVar string, CancellableVar *Cancellable) ( | |||
| 83 | 83 | ||
| 84 | 84 | // Asynchronous lookup of proxy. See g_proxy_resolver_lookup() for more | |
| 85 | 85 | // details. | |
| 86 | - | func (x *ProxyResolverBase) LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 86 | + | func (x *ProxyResolverBase) LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 87 | 87 | ||
| 88 | - | XGProxyResolverLookupAsync(x.GoPointer(), UriVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 88 | + | XGProxyResolverLookupAsync(x.GoPointer(), UriVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 89 | 89 | ||
| 90 | 90 | } | |
| 91 | 91 | ||
M v4/gio/gresolver.go +21 -13
| @@ -83,9 +83,9 @@ var xResolverLookupByAddressAsync func(uintptr, uintptr, uintptr, uintptr, uintp | |||
| 83 | 83 | // Begins asynchronously reverse-resolving @address to determine its | |
| 84 | 84 | // associated hostname, and eventually calls @callback, which must | |
| 85 | 85 | // call g_resolver_lookup_by_address_finish() to get the final result. | |
| 86 | - | func (x *Resolver) LookupByAddressAsync(AddressVar *InetAddress, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 86 | + | func (x *Resolver) LookupByAddressAsync(AddressVar *InetAddress, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 87 | 87 | ||
| 88 | - | xResolverLookupByAddressAsync(x.GoPointer(), AddressVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 88 | + | xResolverLookupByAddressAsync(x.GoPointer(), AddressVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 89 | 89 | ||
| 90 | 90 | } | |
| 91 | 91 | ||
| @@ -150,9 +150,9 @@ var xResolverLookupByNameAsync func(uintptr, string, uintptr, uintptr, uintptr) | |||
| 150 | 150 | // associated IP address(es), and eventually calls @callback, which | |
| 151 | 151 | // must call g_resolver_lookup_by_name_finish() to get the result. | |
| 152 | 152 | // See g_resolver_lookup_by_name() for more details. | |
| 153 | - | func (x *Resolver) LookupByNameAsync(HostnameVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 153 | + | func (x *Resolver) LookupByNameAsync(HostnameVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 154 | 154 | ||
| 155 | - | xResolverLookupByNameAsync(x.GoPointer(), HostnameVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 155 | + | xResolverLookupByNameAsync(x.GoPointer(), HostnameVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 156 | 156 | ||
| 157 | 157 | } | |
| 158 | 158 | ||
| @@ -197,9 +197,9 @@ var xResolverLookupByNameWithFlagsAsync func(uintptr, string, ResolverNameLookup | |||
| 197 | 197 | // associated IP address(es), and eventually calls @callback, which | |
| 198 | 198 | // must call g_resolver_lookup_by_name_with_flags_finish() to get the result. | |
| 199 | 199 | // See g_resolver_lookup_by_name() for more details. | |
| 200 | - | func (x *Resolver) LookupByNameWithFlagsAsync(HostnameVar string, FlagsVar ResolverNameLookupFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 200 | + | func (x *Resolver) LookupByNameWithFlagsAsync(HostnameVar string, FlagsVar ResolverNameLookupFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 201 | 201 | ||
| 202 | - | xResolverLookupByNameWithFlagsAsync(x.GoPointer(), HostnameVar, FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 202 | + | xResolverLookupByNameWithFlagsAsync(x.GoPointer(), HostnameVar, FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 203 | 203 | ||
| 204 | 204 | } | |
| 205 | 205 | ||
| @@ -251,9 +251,9 @@ var xResolverLookupRecordsAsync func(uintptr, string, ResolverRecordType, uintpt | |||
| 251 | 251 | // @rrname, and eventually calls @callback, which must call | |
| 252 | 252 | // g_resolver_lookup_records_finish() to get the final result. See | |
| 253 | 253 | // g_resolver_lookup_records() for more details. | |
| 254 | - | func (x *Resolver) LookupRecordsAsync(RrnameVar string, RecordTypeVar ResolverRecordType, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 254 | + | func (x *Resolver) LookupRecordsAsync(RrnameVar string, RecordTypeVar ResolverRecordType, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 255 | 255 | ||
| 256 | - | xResolverLookupRecordsAsync(x.GoPointer(), RrnameVar, RecordTypeVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 256 | + | xResolverLookupRecordsAsync(x.GoPointer(), RrnameVar, RecordTypeVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 257 | 257 | ||
| 258 | 258 | } | |
| 259 | 259 | ||
| @@ -319,9 +319,9 @@ var xResolverLookupServiceAsync func(uintptr, string, string, string, uintptr, u | |||
| 319 | 319 | // @callback, which must call g_resolver_lookup_service_finish() to | |
| 320 | 320 | // get the final result. See g_resolver_lookup_service() for more | |
| 321 | 321 | // details. | |
| 322 | - | func (x *Resolver) LookupServiceAsync(ServiceVar string, ProtocolVar string, DomainVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 322 | + | func (x *Resolver) LookupServiceAsync(ServiceVar string, ProtocolVar string, DomainVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 323 | 323 | ||
| 324 | - | xResolverLookupServiceAsync(x.GoPointer(), ServiceVar, ProtocolVar, DomainVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 324 | + | xResolverLookupServiceAsync(x.GoPointer(), ServiceVar, ProtocolVar, DomainVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 325 | 325 | ||
| 326 | 326 | } | |
| 327 | 327 | ||
| @@ -371,15 +371,23 @@ func (c *Resolver) SetGoPointer(ptr uintptr) { | |||
| 371 | 371 | ||
| 372 | 372 | // Emitted when the resolver notices that the system resolver | |
| 373 | 373 | // configuration has changed. | |
| 374 | - | func (x *Resolver) ConnectReload(cb func(Resolver)) uint32 { | |
| 374 | + | func (x *Resolver) ConnectReload(cb *func(Resolver)) uint32 { | |
| 375 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 376 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 377 | + | return gobject.SignalConnect(x.GoPointer(), "reload", cbRefPtr) | |
| 378 | + | } | |
| 379 | + | ||
| 375 | 380 | fcb := func(clsPtr uintptr) { | |
| 376 | 381 | fa := Resolver{} | |
| 377 | 382 | fa.Ptr = clsPtr | |
| 383 | + | cbFn := *cb | |
| 378 | 384 | ||
| 379 | - | cb(fa) | |
| 385 | + | cbFn(fa) | |
| 380 | 386 | ||
| 381 | 387 | } | |
| 382 | - | return gobject.SignalConnect(x.GoPointer(), "reload", purego.NewCallback(fcb)) | |
| 388 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 389 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 390 | + | return gobject.SignalConnect(x.GoPointer(), "reload", cbRefPtr) | |
| 383 | 391 | } | |
| 384 | 392 | ||
| 385 | 393 | var xResolverFreeAddresses func(*glib.List) | |
M v4/gio/gsettings.go +48 -16
| @@ -569,9 +569,9 @@ var xSettingsBindWithMapping func(uintptr, string, uintptr, string, SettingsBind | |||
| 569 | 569 | // and that you can have only one binding per object property. | |
| 570 | 570 | // If you bind the same property twice on the same object, the second | |
| 571 | 571 | // binding overrides the first one. | |
| 572 | - | func (x *Settings) BindWithMapping(KeyVar string, ObjectVar *gobject.Object, PropertyVar string, FlagsVar SettingsBindFlags, GetMappingVar SettingsBindGetMapping, SetMappingVar SettingsBindSetMapping, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 572 | + | func (x *Settings) BindWithMapping(KeyVar string, ObjectVar *gobject.Object, PropertyVar string, FlagsVar SettingsBindFlags, GetMappingVar *SettingsBindGetMapping, SetMappingVar *SettingsBindSetMapping, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 573 | 573 | ||
| 574 | - | xSettingsBindWithMapping(x.GoPointer(), KeyVar, ObjectVar.GoPointer(), PropertyVar, FlagsVar, purego.NewCallback(GetMappingVar), purego.NewCallback(SetMappingVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 574 | + | xSettingsBindWithMapping(x.GoPointer(), KeyVar, ObjectVar.GoPointer(), PropertyVar, FlagsVar, glib.NewCallback(GetMappingVar), glib.NewCallback(SetMappingVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 575 | 575 | ||
| 576 | 576 | } | |
| 577 | 577 | ||
| @@ -844,9 +844,9 @@ var xSettingsGetMapped func(uintptr, string, uintptr, uintptr) uintptr | |||
| 844 | 844 | // to each invocation of @mapping. The final value of that #gpointer is | |
| 845 | 845 | // what is returned by this function. %NULL is valid; it is returned | |
| 846 | 846 | // just as any other value would be. | |
| 847 | - | func (x *Settings) GetMapped(KeyVar string, MappingVar SettingsGetMapping, UserDataVar uintptr) uintptr { | |
| 847 | + | func (x *Settings) GetMapped(KeyVar string, MappingVar *SettingsGetMapping, UserDataVar uintptr) uintptr { | |
| 848 | 848 | ||
| 849 | - | cret := xSettingsGetMapped(x.GoPointer(), KeyVar, purego.NewCallback(MappingVar), UserDataVar) | |
| 849 | + | cret := xSettingsGetMapped(x.GoPointer(), KeyVar, glib.NewCallback(MappingVar), UserDataVar) | |
| 850 | 850 | return cret | |
| 851 | 851 | } | |
| 852 | 852 | ||
| @@ -1240,15 +1240,23 @@ func (c *Settings) SetGoPointer(ptr uintptr) { | |||
| 1240 | 1240 | // The default handler for this signal invokes the "changed" signal | |
| 1241 | 1241 | // for each affected key. If any other connected handler returns | |
| 1242 | 1242 | // %TRUE then this default functionality will be suppressed. | |
| 1243 | - | func (x *Settings) ConnectChangeEvent(cb func(Settings, uintptr, int) bool) uint32 { | |
| 1243 | + | func (x *Settings) ConnectChangeEvent(cb *func(Settings, uintptr, int) bool) uint32 { | |
| 1244 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1245 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1246 | + | return gobject.SignalConnect(x.GoPointer(), "change-event", cbRefPtr) | |
| 1247 | + | } | |
| 1248 | + | ||
| 1244 | 1249 | fcb := func(clsPtr uintptr, KeysVarp uintptr, NKeysVarp int) bool { | |
| 1245 | 1250 | fa := Settings{} | |
| 1246 | 1251 | fa.Ptr = clsPtr | |
| 1252 | + | cbFn := *cb | |
| 1247 | 1253 | ||
| 1248 | - | return cb(fa, KeysVarp, NKeysVarp) | |
| 1254 | + | return cbFn(fa, KeysVarp, NKeysVarp) | |
| 1249 | 1255 | ||
| 1250 | 1256 | } | |
| 1251 | - | return gobject.SignalConnect(x.GoPointer(), "change-event", purego.NewCallback(fcb)) | |
| 1257 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1258 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1259 | + | return gobject.SignalConnect(x.GoPointer(), "change-event", cbRefPtr) | |
| 1252 | 1260 | } | |
| 1253 | 1261 | ||
| 1254 | 1262 | // The "changed" signal is emitted when a key has potentially changed. | |
| @@ -1261,15 +1269,23 @@ func (x *Settings) ConnectChangeEvent(cb func(Settings, uintptr, int) bool) uint | |||
| 1261 | 1269 | // | |
| 1262 | 1270 | // Note that @settings only emits this signal if you have read @key at | |
| 1263 | 1271 | // least once while a signal handler was already connected for @key. | |
| 1264 | - | func (x *Settings) ConnectChanged(cb func(Settings, string)) uint32 { | |
| 1272 | + | func (x *Settings) ConnectChanged(cb *func(Settings, string)) uint32 { | |
| 1273 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1274 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1275 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 1276 | + | } | |
| 1277 | + | ||
| 1265 | 1278 | fcb := func(clsPtr uintptr, KeyVarp string) { | |
| 1266 | 1279 | fa := Settings{} | |
| 1267 | 1280 | fa.Ptr = clsPtr | |
| 1281 | + | cbFn := *cb | |
| 1268 | 1282 | ||
| 1269 | - | cb(fa, KeyVarp) | |
| 1283 | + | cbFn(fa, KeyVarp) | |
| 1270 | 1284 | ||
| 1271 | 1285 | } | |
| 1272 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 1286 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1287 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1288 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 1273 | 1289 | } | |
| 1274 | 1290 | ||
| 1275 | 1291 | // The "writable-change-event" signal is emitted once per writability | |
| @@ -1290,15 +1306,23 @@ func (x *Settings) ConnectChanged(cb func(Settings, string)) uint32 { | |||
| 1290 | 1306 | // example, a new mandatory setting is introduced). If any other | |
| 1291 | 1307 | // connected handler returns %TRUE then this default functionality | |
| 1292 | 1308 | // will be suppressed. | |
| 1293 | - | func (x *Settings) ConnectWritableChangeEvent(cb func(Settings, uint) bool) uint32 { | |
| 1309 | + | func (x *Settings) ConnectWritableChangeEvent(cb *func(Settings, uint) bool) uint32 { | |
| 1310 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1311 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1312 | + | return gobject.SignalConnect(x.GoPointer(), "writable-change-event", cbRefPtr) | |
| 1313 | + | } | |
| 1314 | + | ||
| 1294 | 1315 | fcb := func(clsPtr uintptr, KeyVarp uint) bool { | |
| 1295 | 1316 | fa := Settings{} | |
| 1296 | 1317 | fa.Ptr = clsPtr | |
| 1318 | + | cbFn := *cb | |
| 1297 | 1319 | ||
| 1298 | - | return cb(fa, KeyVarp) | |
| 1320 | + | return cbFn(fa, KeyVarp) | |
| 1299 | 1321 | ||
| 1300 | 1322 | } | |
| 1301 | - | return gobject.SignalConnect(x.GoPointer(), "writable-change-event", purego.NewCallback(fcb)) | |
| 1323 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1324 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1325 | + | return gobject.SignalConnect(x.GoPointer(), "writable-change-event", cbRefPtr) | |
| 1302 | 1326 | } | |
| 1303 | 1327 | ||
| 1304 | 1328 | // The "writable-changed" signal is emitted when the writability of a | |
| @@ -1308,15 +1332,23 @@ func (x *Settings) ConnectWritableChangeEvent(cb func(Settings, uint) bool) uint | |||
| 1308 | 1332 | // This signal supports detailed connections. You can connect to the | |
| 1309 | 1333 | // detailed signal "writable-changed::x" in order to only receive | |
| 1310 | 1334 | // callbacks when the writability of "x" changes. | |
| 1311 | - | func (x *Settings) ConnectWritableChanged(cb func(Settings, string)) uint32 { | |
| 1335 | + | func (x *Settings) ConnectWritableChanged(cb *func(Settings, string)) uint32 { | |
| 1336 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1337 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1338 | + | return gobject.SignalConnect(x.GoPointer(), "writable-changed", cbRefPtr) | |
| 1339 | + | } | |
| 1340 | + | ||
| 1312 | 1341 | fcb := func(clsPtr uintptr, KeyVarp string) { | |
| 1313 | 1342 | fa := Settings{} | |
| 1314 | 1343 | fa.Ptr = clsPtr | |
| 1344 | + | cbFn := *cb | |
| 1315 | 1345 | ||
| 1316 | - | cb(fa, KeyVarp) | |
| 1346 | + | cbFn(fa, KeyVarp) | |
| 1317 | 1347 | ||
| 1318 | 1348 | } | |
| 1319 | - | return gobject.SignalConnect(x.GoPointer(), "writable-changed", purego.NewCallback(fcb)) | |
| 1349 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1350 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1351 | + | return gobject.SignalConnect(x.GoPointer(), "writable-changed", cbRefPtr) | |
| 1320 | 1352 | } | |
| 1321 | 1353 | ||
| 1322 | 1354 | var xSettingsListRelocatableSchemas func() uintptr | |
M v4/gio/gsimpleasyncresult.go +18 -18
| @@ -22,9 +22,9 @@ var xSimpleAsyncReportErrorInIdle func(uintptr, uintptr, uintptr, glib.Quark, in | |||
| 22 | 22 | // Reports an error in an asynchronous function in an idle function by | |
| 23 | 23 | // directly setting the contents of the #GAsyncResult with the given error | |
| 24 | 24 | // information. | |
| 25 | - | func SimpleAsyncReportErrorInIdle(ObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, UserDataVar uintptr, DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) { | |
| 25 | + | func SimpleAsyncReportErrorInIdle(ObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) { | |
| 26 | 26 | ||
| 27 | - | xSimpleAsyncReportErrorInIdle(ObjectVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, DomainVar, CodeVar, FormatVar, varArgs...) | |
| 27 | + | xSimpleAsyncReportErrorInIdle(ObjectVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, DomainVar, CodeVar, FormatVar, varArgs...) | |
| 28 | 28 | ||
| 29 | 29 | } | |
| 30 | 30 | ||
| @@ -33,9 +33,9 @@ var xSimpleAsyncReportGerrorInIdle func(uintptr, uintptr, uintptr, *glib.Error) | |||
| 33 | 33 | // Reports an error in an idle function. Similar to | |
| 34 | 34 | // g_simple_async_report_error_in_idle(), but takes a #GError rather | |
| 35 | 35 | // than building a new one. | |
| 36 | - | func SimpleAsyncReportGerrorInIdle(ObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) { | |
| 36 | + | func SimpleAsyncReportGerrorInIdle(ObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) { | |
| 37 | 37 | ||
| 38 | - | xSimpleAsyncReportGerrorInIdle(ObjectVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, ErrorVar) | |
| 38 | + | xSimpleAsyncReportGerrorInIdle(ObjectVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, ErrorVar) | |
| 39 | 39 | ||
| 40 | 40 | } | |
| 41 | 41 | ||
| @@ -44,9 +44,9 @@ var xSimpleAsyncReportTakeGerrorInIdle func(uintptr, uintptr, uintptr, *glib.Err | |||
| 44 | 44 | // Reports an error in an idle function. Similar to | |
| 45 | 45 | // g_simple_async_report_gerror_in_idle(), but takes over the caller's | |
| 46 | 46 | // ownership of @error, so the caller does not have to free it any more. | |
| 47 | - | func SimpleAsyncReportTakeGerrorInIdle(ObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) { | |
| 47 | + | func SimpleAsyncReportTakeGerrorInIdle(ObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) { | |
| 48 | 48 | ||
| 49 | - | xSimpleAsyncReportTakeGerrorInIdle(ObjectVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, ErrorVar) | |
| 49 | + | xSimpleAsyncReportTakeGerrorInIdle(ObjectVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, ErrorVar) | |
| 50 | 50 | ||
| 51 | 51 | } | |
| 52 | 52 | ||
| @@ -244,10 +244,10 @@ var xNewSimpleAsyncResult func(uintptr, uintptr, uintptr, uintptr) uintptr | |||
| 244 | 244 | // probably should) then you should provide the user's cancellable to | |
| 245 | 245 | // g_simple_async_result_set_check_cancellable() immediately after | |
| 246 | 246 | // this function returns. | |
| 247 | - | func NewSimpleAsyncResult(SourceObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, UserDataVar uintptr, SourceTagVar uintptr) *SimpleAsyncResult { | |
| 247 | + | func NewSimpleAsyncResult(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, SourceTagVar uintptr) *SimpleAsyncResult { | |
| 248 | 248 | var cls *SimpleAsyncResult | |
| 249 | 249 | ||
| 250 | - | cret := xNewSimpleAsyncResult(SourceObjectVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, SourceTagVar) | |
| 250 | + | cret := xNewSimpleAsyncResult(SourceObjectVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, SourceTagVar) | |
| 251 | 251 | ||
| 252 | 252 | if cret == 0 { | |
| 253 | 253 | return nil | |
| @@ -260,10 +260,10 @@ func NewSimpleAsyncResult(SourceObjectVar *gobject.Object, CallbackVar AsyncRead | |||
| 260 | 260 | var xNewSimpleAsyncResultError func(uintptr, uintptr, uintptr, glib.Quark, int, string, ...interface{}) uintptr | |
| 261 | 261 | ||
| 262 | 262 | // Creates a new #GSimpleAsyncResult with a set error. | |
| 263 | - | func NewSimpleAsyncResultError(SourceObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, UserDataVar uintptr, DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) *SimpleAsyncResult { | |
| 263 | + | func NewSimpleAsyncResultError(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) *SimpleAsyncResult { | |
| 264 | 264 | var cls *SimpleAsyncResult | |
| 265 | 265 | ||
| 266 | - | cret := xNewSimpleAsyncResultError(SourceObjectVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, DomainVar, CodeVar, FormatVar, varArgs...) | |
| 266 | + | cret := xNewSimpleAsyncResultError(SourceObjectVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, DomainVar, CodeVar, FormatVar, varArgs...) | |
| 267 | 267 | ||
| 268 | 268 | if cret == 0 { | |
| 269 | 269 | return nil | |
| @@ -276,10 +276,10 @@ func NewSimpleAsyncResultError(SourceObjectVar *gobject.Object, CallbackVar Asyn | |||
| 276 | 276 | var xNewSimpleAsyncResultFromError func(uintptr, uintptr, uintptr, *glib.Error) uintptr | |
| 277 | 277 | ||
| 278 | 278 | // Creates a #GSimpleAsyncResult from an error condition. | |
| 279 | - | func NewSimpleAsyncResultFromError(SourceObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) *SimpleAsyncResult { | |
| 279 | + | func NewSimpleAsyncResultFromError(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) *SimpleAsyncResult { | |
| 280 | 280 | var cls *SimpleAsyncResult | |
| 281 | 281 | ||
| 282 | - | cret := xNewSimpleAsyncResultFromError(SourceObjectVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, ErrorVar) | |
| 282 | + | cret := xNewSimpleAsyncResultFromError(SourceObjectVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, ErrorVar) | |
| 283 | 283 | ||
| 284 | 284 | if cret == 0 { | |
| 285 | 285 | return nil | |
| @@ -293,10 +293,10 @@ var xNewSimpleAsyncResultTakeError func(uintptr, uintptr, uintptr, *glib.Error) | |||
| 293 | 293 | ||
| 294 | 294 | // Creates a #GSimpleAsyncResult from an error condition, and takes over the | |
| 295 | 295 | // caller's ownership of @error, so the caller does not need to free it anymore. | |
| 296 | - | func NewSimpleAsyncResultTakeError(SourceObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) *SimpleAsyncResult { | |
| 296 | + | func NewSimpleAsyncResultTakeError(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, UserDataVar uintptr, ErrorVar *glib.Error) *SimpleAsyncResult { | |
| 297 | 297 | var cls *SimpleAsyncResult | |
| 298 | 298 | ||
| 299 | - | cret := xNewSimpleAsyncResultTakeError(SourceObjectVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, ErrorVar) | |
| 299 | + | cret := xNewSimpleAsyncResultTakeError(SourceObjectVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, ErrorVar) | |
| 300 | 300 | ||
| 301 | 301 | if cret == 0 { | |
| 302 | 302 | return nil | |
| @@ -399,9 +399,9 @@ var xSimpleAsyncResultRunInThread func(uintptr, uintptr, int, uintptr) | |||
| 399 | 399 | // | |
| 400 | 400 | // Calling this function takes a reference to @simple for as long as | |
| 401 | 401 | // is needed to run the job and report its completion. | |
| 402 | - | func (x *SimpleAsyncResult) RunInThread(FuncVar SimpleAsyncThreadFunc, IoPriorityVar int, CancellableVar *Cancellable) { | |
| 402 | + | func (x *SimpleAsyncResult) RunInThread(FuncVar *SimpleAsyncThreadFunc, IoPriorityVar int, CancellableVar *Cancellable) { | |
| 403 | 403 | ||
| 404 | - | xSimpleAsyncResultRunInThread(x.GoPointer(), purego.NewCallback(FuncVar), IoPriorityVar, CancellableVar.GoPointer()) | |
| 404 | + | xSimpleAsyncResultRunInThread(x.GoPointer(), glib.NewCallback(FuncVar), IoPriorityVar, CancellableVar.GoPointer()) | |
| 405 | 405 | ||
| 406 | 406 | } | |
| 407 | 407 | ||
| @@ -481,9 +481,9 @@ func (x *SimpleAsyncResult) SetOpResGboolean(OpResVar bool) { | |||
| 481 | 481 | var xSimpleAsyncResultSetOpResGpointer func(uintptr, uintptr, uintptr) | |
| 482 | 482 | ||
| 483 | 483 | // Sets the operation result within the asynchronous result to a pointer. | |
| 484 | - | func (x *SimpleAsyncResult) SetOpResGpointer(OpResVar uintptr, DestroyOpResVar glib.DestroyNotify) { | |
| 484 | + | func (x *SimpleAsyncResult) SetOpResGpointer(OpResVar uintptr, DestroyOpResVar *glib.DestroyNotify) { | |
| 485 | 485 | ||
| 486 | - | xSimpleAsyncResultSetOpResGpointer(x.GoPointer(), OpResVar, purego.NewCallback(DestroyOpResVar)) | |
| 486 | + | xSimpleAsyncResultSetOpResGpointer(x.GoPointer(), OpResVar, glib.NewCallback(DestroyOpResVar)) | |
| 487 | 487 | ||
| 488 | 488 | } | |
| 489 | 489 | ||
M v4/gio/gsimpleproxyresolver.go +2 -2
| @@ -131,9 +131,9 @@ func (x *SimpleProxyResolver) Lookup(UriVar string, CancellableVar *Cancellable) | |||
| 131 | 131 | ||
| 132 | 132 | // Asynchronous lookup of proxy. See g_proxy_resolver_lookup() for more | |
| 133 | 133 | // details. | |
| 134 | - | func (x *SimpleProxyResolver) LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 134 | + | func (x *SimpleProxyResolver) LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 135 | 135 | ||
| 136 | - | XGProxyResolverLookupAsync(x.GoPointer(), UriVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 136 | + | XGProxyResolverLookupAsync(x.GoPointer(), UriVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 137 | 137 | ||
| 138 | 138 | } | |
| 139 | 139 | ||
M v4/gio/gsocketaddressenumerator.go +2 -2
| @@ -83,9 +83,9 @@ var xSocketAddressEnumeratorNextAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 83 | 83 | // g_socket_address_enumerator_next_finish() to get the result. | |
| 84 | 84 | // | |
| 85 | 85 | // It is an error to call this multiple times before the previous callback has finished. | |
| 86 | - | func (x *SocketAddressEnumerator) NextAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 86 | + | func (x *SocketAddressEnumerator) NextAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 87 | 87 | ||
| 88 | - | xSocketAddressEnumeratorNextAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 88 | + | xSocketAddressEnumeratorNextAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 89 | 89 | ||
| 90 | 90 | } | |
| 91 | 91 | ||
M v4/gio/gsocketclient.go +19 -11
| @@ -145,9 +145,9 @@ var xSocketClientConnectAsync func(uintptr, uintptr, uintptr, uintptr, uintptr) | |||
| 145 | 145 | // When the operation is finished @callback will be | |
| 146 | 146 | // called. You can then call g_socket_client_connect_finish() to get | |
| 147 | 147 | // the result of the operation. | |
| 148 | - | func (x *SocketClient) ConnectAsync(ConnectableVar SocketConnectable, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 148 | + | func (x *SocketClient) ConnectAsync(ConnectableVar SocketConnectable, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 149 | 149 | ||
| 150 | - | xSocketClientConnectAsync(x.GoPointer(), ConnectableVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 150 | + | xSocketClientConnectAsync(x.GoPointer(), ConnectableVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 151 | 151 | ||
| 152 | 152 | } | |
| 153 | 153 | ||
| @@ -229,9 +229,9 @@ var xSocketClientConnectToHostAsync func(uintptr, string, uint16, uintptr, uintp | |||
| 229 | 229 | // When the operation is finished @callback will be | |
| 230 | 230 | // called. You can then call g_socket_client_connect_to_host_finish() to get | |
| 231 | 231 | // the result of the operation. | |
| 232 | - | func (x *SocketClient) ConnectToHostAsync(HostAndPortVar string, DefaultPortVar uint16, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 232 | + | func (x *SocketClient) ConnectToHostAsync(HostAndPortVar string, DefaultPortVar uint16, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 233 | 233 | ||
| 234 | - | xSocketClientConnectToHostAsync(x.GoPointer(), HostAndPortVar, DefaultPortVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 234 | + | xSocketClientConnectToHostAsync(x.GoPointer(), HostAndPortVar, DefaultPortVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 235 | 235 | ||
| 236 | 236 | } | |
| 237 | 237 | ||
| @@ -294,9 +294,9 @@ var xSocketClientConnectToServiceAsync func(uintptr, string, string, uintptr, ui | |||
| 294 | 294 | ||
| 295 | 295 | // This is the asynchronous version of | |
| 296 | 296 | // g_socket_client_connect_to_service(). | |
| 297 | - | func (x *SocketClient) ConnectToServiceAsync(DomainVar string, ServiceVar string, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 297 | + | func (x *SocketClient) ConnectToServiceAsync(DomainVar string, ServiceVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 298 | 298 | ||
| 299 | - | xSocketClientConnectToServiceAsync(x.GoPointer(), DomainVar, ServiceVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 299 | + | xSocketClientConnectToServiceAsync(x.GoPointer(), DomainVar, ServiceVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 300 | 300 | ||
| 301 | 301 | } | |
| 302 | 302 | ||
| @@ -369,9 +369,9 @@ var xSocketClientConnectToUriAsync func(uintptr, string, uint16, uintptr, uintpt | |||
| 369 | 369 | // When the operation is finished @callback will be | |
| 370 | 370 | // called. You can then call g_socket_client_connect_to_uri_finish() to get | |
| 371 | 371 | // the result of the operation. | |
| 372 | - | func (x *SocketClient) ConnectToUriAsync(UriVar string, DefaultPortVar uint16, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 372 | + | func (x *SocketClient) ConnectToUriAsync(UriVar string, DefaultPortVar uint16, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 373 | 373 | ||
| 374 | - | xSocketClientConnectToUriAsync(x.GoPointer(), UriVar, DefaultPortVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 374 | + | xSocketClientConnectToUriAsync(x.GoPointer(), UriVar, DefaultPortVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 375 | 375 | ||
| 376 | 376 | } | |
| 377 | 377 | ||
| @@ -710,15 +710,23 @@ func (c *SocketClient) SetGoPointer(ptr uintptr) { | |||
| 710 | 710 | // | |
| 711 | 711 | // Note that there may be additional #GSocketClientEvent values in | |
| 712 | 712 | // the future; unrecognized @event values should be ignored. | |
| 713 | - | func (x *SocketClient) ConnectEvent(cb func(SocketClient, SocketClientEvent, uintptr, uintptr)) uint32 { | |
| 713 | + | func (x *SocketClient) ConnectEvent(cb *func(SocketClient, SocketClientEvent, uintptr, uintptr)) uint32 { | |
| 714 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 715 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 716 | + | return gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) | |
| 717 | + | } | |
| 718 | + | ||
| 714 | 719 | fcb := func(clsPtr uintptr, EventVarp SocketClientEvent, ConnectableVarp uintptr, ConnectionVarp uintptr) { | |
| 715 | 720 | fa := SocketClient{} | |
| 716 | 721 | fa.Ptr = clsPtr | |
| 722 | + | cbFn := *cb | |
| 717 | 723 | ||
| 718 | - | cb(fa, EventVarp, ConnectableVarp, ConnectionVarp) | |
| 724 | + | cbFn(fa, EventVarp, ConnectableVarp, ConnectionVarp) | |
| 719 | 725 | ||
| 720 | 726 | } | |
| 721 | - | return gobject.SignalConnect(x.GoPointer(), "event", purego.NewCallback(fcb)) | |
| 727 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 728 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 729 | + | return gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) | |
| 722 | 730 | } | |
| 723 | 731 | ||
| 724 | 732 | func init() { | |
M v4/gio/gsocketconnection.go +2 -2
| @@ -73,9 +73,9 @@ var xSocketConnectionConnectAsync func(uintptr, uintptr, uintptr, uintptr, uintp | |||
| 73 | 73 | // socket if it is currently set. | |
| 74 | 74 | // | |
| 75 | 75 | // Use g_socket_connection_connect_finish() to retrieve the result. | |
| 76 | - | func (x *SocketConnection) ConnectAsync(AddressVar *SocketAddress, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 76 | + | func (x *SocketConnection) ConnectAsync(AddressVar *SocketAddress, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 77 | 77 | ||
| 78 | - | xSocketConnectionConnectAsync(x.GoPointer(), AddressVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 78 | + | xSocketConnectionConnectAsync(x.GoPointer(), AddressVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 79 | 79 | ||
| 80 | 80 | } | |
| 81 | 81 | ||
M v4/gio/gsocketlistener.go +15 -7
| @@ -106,9 +106,9 @@ var xSocketListenerAcceptAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 106 | 106 | // When the operation is finished @callback will be | |
| 107 | 107 | // called. You can then call g_socket_listener_accept_finish() | |
| 108 | 108 | // to get the result of the operation. | |
| 109 | - | func (x *SocketListener) AcceptAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 109 | + | func (x *SocketListener) AcceptAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 110 | 110 | ||
| 111 | - | xSocketListenerAcceptAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 111 | + | xSocketListenerAcceptAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 112 | 112 | ||
| 113 | 113 | } | |
| 114 | 114 | ||
| @@ -174,9 +174,9 @@ var xSocketListenerAcceptSocketAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 174 | 174 | // When the operation is finished @callback will be | |
| 175 | 175 | // called. You can then call g_socket_listener_accept_socket_finish() | |
| 176 | 176 | // to get the result of the operation. | |
| 177 | - | func (x *SocketListener) AcceptSocketAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 177 | + | func (x *SocketListener) AcceptSocketAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 178 | 178 | ||
| 179 | - | xSocketListenerAcceptSocketAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 179 | + | xSocketListenerAcceptSocketAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 180 | 180 | ||
| 181 | 181 | } | |
| 182 | 182 | ||
| @@ -345,15 +345,23 @@ func (c *SocketListener) SetGoPointer(ptr uintptr) { | |||
| 345 | 345 | // Note that when @listener is used to listen on both IPv4 and | |
| 346 | 346 | // IPv6, a separate set of signals will be emitted for each, and | |
| 347 | 347 | // the order they happen in is undefined. | |
| 348 | - | func (x *SocketListener) ConnectEvent(cb func(SocketListener, SocketListenerEvent, uintptr)) uint32 { | |
| 348 | + | func (x *SocketListener) ConnectEvent(cb *func(SocketListener, SocketListenerEvent, uintptr)) uint32 { | |
| 349 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 350 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 351 | + | return gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) | |
| 352 | + | } | |
| 353 | + | ||
| 349 | 354 | fcb := func(clsPtr uintptr, EventVarp SocketListenerEvent, SocketVarp uintptr) { | |
| 350 | 355 | fa := SocketListener{} | |
| 351 | 356 | fa.Ptr = clsPtr | |
| 357 | + | cbFn := *cb | |
| 352 | 358 | ||
| 353 | - | cb(fa, EventVarp, SocketVarp) | |
| 359 | + | cbFn(fa, EventVarp, SocketVarp) | |
| 354 | 360 | ||
| 355 | 361 | } | |
| 356 | - | return gobject.SignalConnect(x.GoPointer(), "event", purego.NewCallback(fcb)) | |
| 362 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 363 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 364 | + | return gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) | |
| 357 | 365 | } | |
| 358 | 366 | ||
| 359 | 367 | func init() { | |
M v4/gio/gsocketservice.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -148,15 +149,23 @@ func (c *SocketService) SetGoPointer(ptr uintptr) { | |||
| 148 | 149 | // | |
| 149 | 150 | // @connection will be unreffed once the signal handler returns, | |
| 150 | 151 | // so you need to ref it yourself if you are planning to use it. | |
| 151 | - | func (x *SocketService) ConnectIncoming(cb func(SocketService, uintptr, uintptr) bool) uint32 { | |
| 152 | + | func (x *SocketService) ConnectIncoming(cb *func(SocketService, uintptr, uintptr) bool) uint32 { | |
| 153 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 154 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 155 | + | return gobject.SignalConnect(x.GoPointer(), "incoming", cbRefPtr) | |
| 156 | + | } | |
| 157 | + | ||
| 152 | 158 | fcb := func(clsPtr uintptr, ConnectionVarp uintptr, SourceObjectVarp uintptr) bool { | |
| 153 | 159 | fa := SocketService{} | |
| 154 | 160 | fa.Ptr = clsPtr | |
| 161 | + | cbFn := *cb | |
| 155 | 162 | ||
| 156 | - | return cb(fa, ConnectionVarp, SourceObjectVarp) | |
| 163 | + | return cbFn(fa, ConnectionVarp, SourceObjectVarp) | |
| 157 | 164 | ||
| 158 | 165 | } | |
| 159 | - | return gobject.SignalConnect(x.GoPointer(), "incoming", purego.NewCallback(fcb)) | |
| 166 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 167 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 168 | + | return gobject.SignalConnect(x.GoPointer(), "incoming", cbRefPtr) | |
| 160 | 169 | } | |
| 161 | 170 | ||
| 162 | 171 | func init() { | |
M v4/gio/gtask.go +16 -16
| @@ -569,10 +569,10 @@ var xNewTask func(uintptr, uintptr, uintptr, uintptr) uintptr | |||
| 569 | 569 | // other objects that the task depends on have been destroyed. If you | |
| 570 | 570 | // do not want this behavior, you can use | |
| 571 | 571 | // g_task_set_check_cancellable() to change it. | |
| 572 | - | func NewTask(SourceObjectVar *gobject.Object, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, CallbackDataVar uintptr) *Task { | |
| 572 | + | func NewTask(SourceObjectVar *gobject.Object, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, CallbackDataVar uintptr) *Task { | |
| 573 | 573 | var cls *Task | |
| 574 | 574 | ||
| 575 | - | cret := xNewTask(SourceObjectVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), CallbackDataVar) | |
| 575 | + | cret := xNewTask(SourceObjectVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), CallbackDataVar) | |
| 576 | 576 | ||
| 577 | 577 | if cret == 0 { | |
| 578 | 578 | return nil | |
| @@ -593,9 +593,9 @@ var xTaskAttachSource func(uintptr, *glib.Source, uintptr) | |||
| 593 | 593 | // g_task_set_name()), if one has been set. | |
| 594 | 594 | // | |
| 595 | 595 | // This takes a reference on @task until @source is destroyed. | |
| 596 | - | func (x *Task) AttachSource(SourceVar *glib.Source, CallbackVar glib.SourceFunc) { | |
| 596 | + | func (x *Task) AttachSource(SourceVar *glib.Source, CallbackVar *glib.SourceFunc) { | |
| 597 | 597 | ||
| 598 | - | xTaskAttachSource(x.GoPointer(), SourceVar, purego.NewCallback(CallbackVar)) | |
| 598 | + | xTaskAttachSource(x.GoPointer(), SourceVar, glib.NewCallback(CallbackVar)) | |
| 599 | 599 | ||
| 600 | 600 | } | |
| 601 | 601 | ||
| @@ -896,9 +896,9 @@ var xTaskReturnPointer func(uintptr, uintptr, uintptr) | |||
| 896 | 896 | // g_task_return_pointer(), you cannot assume that @result is still | |
| 897 | 897 | // valid after calling this, unless you are still holding another | |
| 898 | 898 | // reference on it. | |
| 899 | - | func (x *Task) ReturnPointer(ResultVar uintptr, ResultDestroyVar glib.DestroyNotify) { | |
| 899 | + | func (x *Task) ReturnPointer(ResultVar uintptr, ResultDestroyVar *glib.DestroyNotify) { | |
| 900 | 900 | ||
| 901 | - | xTaskReturnPointer(x.GoPointer(), ResultVar, purego.NewCallback(ResultDestroyVar)) | |
| 901 | + | xTaskReturnPointer(x.GoPointer(), ResultVar, glib.NewCallback(ResultDestroyVar)) | |
| 902 | 902 | ||
| 903 | 903 | } | |
| 904 | 904 | ||
| @@ -932,9 +932,9 @@ var xTaskRunInThread func(uintptr, uintptr) | |||
| 932 | 932 | // do this. If you have a very large number of tasks to run (several tens of | |
| 933 | 933 | // tasks), but don't want them to all run at once, you should only queue a | |
| 934 | 934 | // limited number of them (around ten) at a time. | |
| 935 | - | func (x *Task) RunInThread(TaskFuncVar TaskThreadFunc) { | |
| 935 | + | func (x *Task) RunInThread(TaskFuncVar *TaskThreadFunc) { | |
| 936 | 936 | ||
| 937 | - | xTaskRunInThread(x.GoPointer(), purego.NewCallback(TaskFuncVar)) | |
| 937 | + | xTaskRunInThread(x.GoPointer(), glib.NewCallback(TaskFuncVar)) | |
| 938 | 938 | ||
| 939 | 939 | } | |
| 940 | 940 | ||
| @@ -956,9 +956,9 @@ var xTaskRunInThreadSync func(uintptr, uintptr) | |||
| 956 | 956 | // always do this. If you have a very large number of tasks to run, | |
| 957 | 957 | // but don't want them to all run at once, you should only queue a | |
| 958 | 958 | // limited number of them at a time. | |
| 959 | - | func (x *Task) RunInThreadSync(TaskFuncVar TaskThreadFunc) { | |
| 959 | + | func (x *Task) RunInThreadSync(TaskFuncVar *TaskThreadFunc) { | |
| 960 | 960 | ||
| 961 | - | xTaskRunInThreadSync(x.GoPointer(), purego.NewCallback(TaskFuncVar)) | |
| 961 | + | xTaskRunInThreadSync(x.GoPointer(), glib.NewCallback(TaskFuncVar)) | |
| 962 | 962 | ||
| 963 | 963 | } | |
| 964 | 964 | ||
| @@ -1076,9 +1076,9 @@ func (x *Task) SetSourceTag(SourceTagVar uintptr) { | |||
| 1076 | 1076 | var xTaskSetTaskData func(uintptr, uintptr, uintptr) | |
| 1077 | 1077 | ||
| 1078 | 1078 | // Sets @task's task data (freeing the existing task data, if any). | |
| 1079 | - | func (x *Task) SetTaskData(TaskDataVar uintptr, TaskDataDestroyVar glib.DestroyNotify) { | |
| 1079 | + | func (x *Task) SetTaskData(TaskDataVar uintptr, TaskDataDestroyVar *glib.DestroyNotify) { | |
| 1080 | 1080 | ||
| 1081 | - | xTaskSetTaskData(x.GoPointer(), TaskDataVar, purego.NewCallback(TaskDataDestroyVar)) | |
| 1081 | + | xTaskSetTaskData(x.GoPointer(), TaskDataVar, glib.NewCallback(TaskDataDestroyVar)) | |
| 1082 | 1082 | ||
| 1083 | 1083 | } | |
| 1084 | 1084 | ||
| @@ -1147,9 +1147,9 @@ var xTaskReportError func(uintptr, uintptr, uintptr, uintptr, *glib.Error) | |||
| 1147 | 1147 | // wrapper method, and deal with it appropriately if so. | |
| 1148 | 1148 | // | |
| 1149 | 1149 | // See also g_task_report_new_error(). | |
| 1150 | - | func TaskReportError(SourceObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, CallbackDataVar uintptr, SourceTagVar uintptr, ErrorVar *glib.Error) { | |
| 1150 | + | func TaskReportError(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, CallbackDataVar uintptr, SourceTagVar uintptr, ErrorVar *glib.Error) { | |
| 1151 | 1151 | ||
| 1152 | - | xTaskReportError(SourceObjectVar.GoPointer(), purego.NewCallback(CallbackVar), CallbackDataVar, SourceTagVar, ErrorVar) | |
| 1152 | + | xTaskReportError(SourceObjectVar.GoPointer(), glib.NewCallback(CallbackVar), CallbackDataVar, SourceTagVar, ErrorVar) | |
| 1153 | 1153 | ||
| 1154 | 1154 | } | |
| 1155 | 1155 | ||
| @@ -1164,9 +1164,9 @@ var xTaskReportNewError func(uintptr, uintptr, uintptr, uintptr, glib.Quark, int | |||
| 1164 | 1164 | // appropriately if so. | |
| 1165 | 1165 | // | |
| 1166 | 1166 | // See also g_task_report_error(). | |
| 1167 | - | func TaskReportNewError(SourceObjectVar *gobject.Object, CallbackVar AsyncReadyCallback, CallbackDataVar uintptr, SourceTagVar uintptr, DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) { | |
| 1167 | + | func TaskReportNewError(SourceObjectVar *gobject.Object, CallbackVar *AsyncReadyCallback, CallbackDataVar uintptr, SourceTagVar uintptr, DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) { | |
| 1168 | 1168 | ||
| 1169 | - | xTaskReportNewError(SourceObjectVar.GoPointer(), purego.NewCallback(CallbackVar), CallbackDataVar, SourceTagVar, DomainVar, CodeVar, FormatVar, varArgs...) | |
| 1169 | + | xTaskReportNewError(SourceObjectVar.GoPointer(), glib.NewCallback(CallbackVar), CallbackDataVar, SourceTagVar, DomainVar, CodeVar, FormatVar, varArgs...) | |
| 1170 | 1170 | ||
| 1171 | 1171 | } | |
| 1172 | 1172 | ||
M v4/gio/gthreadedsocketservice.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -78,15 +79,23 @@ func (c *ThreadedSocketService) SetGoPointer(ptr uintptr) { | |||
| 78 | 79 | // incoming connection. This thread is dedicated to handling | |
| 79 | 80 | // @connection and may perform blocking IO. The signal handler need | |
| 80 | 81 | // not return until the connection is closed. | |
| 81 | - | func (x *ThreadedSocketService) ConnectRun(cb func(ThreadedSocketService, uintptr, uintptr) bool) uint32 { | |
| 82 | + | func (x *ThreadedSocketService) ConnectRun(cb *func(ThreadedSocketService, uintptr, uintptr) bool) uint32 { | |
| 83 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 84 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 85 | + | return gobject.SignalConnect(x.GoPointer(), "run", cbRefPtr) | |
| 86 | + | } | |
| 87 | + | ||
| 82 | 88 | fcb := func(clsPtr uintptr, ConnectionVarp uintptr, SourceObjectVarp uintptr) bool { | |
| 83 | 89 | fa := ThreadedSocketService{} | |
| 84 | 90 | fa.Ptr = clsPtr | |
| 91 | + | cbFn := *cb | |
| 85 | 92 | ||
| 86 | - | return cb(fa, ConnectionVarp, SourceObjectVarp) | |
| 93 | + | return cbFn(fa, ConnectionVarp, SourceObjectVarp) | |
| 87 | 94 | ||
| 88 | 95 | } | |
| 89 | - | return gobject.SignalConnect(x.GoPointer(), "run", purego.NewCallback(fcb)) | |
| 96 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 97 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 98 | + | return gobject.SignalConnect(x.GoPointer(), "run", cbRefPtr) | |
| 90 | 99 | } | |
| 91 | 100 | ||
| 92 | 101 | func init() { | |
M v4/gio/gtlsconnection.go +13 -5
| @@ -289,9 +289,9 @@ var xTlsConnectionHandshakeAsync func(uintptr, int, uintptr, uintptr, uintptr) | |||
| 289 | 289 | ||
| 290 | 290 | // Asynchronously performs a TLS handshake on @conn. See | |
| 291 | 291 | // g_tls_connection_handshake() for more information. | |
| 292 | - | func (x *TlsConnection) HandshakeAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 292 | + | func (x *TlsConnection) HandshakeAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 293 | 293 | ||
| 294 | - | xTlsConnectionHandshakeAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 294 | + | xTlsConnectionHandshakeAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 295 | 295 | ||
| 296 | 296 | } | |
| 297 | 297 | ||
| @@ -499,15 +499,23 @@ func (c *TlsConnection) SetGoPointer(ptr uintptr) { | |||
| 499 | 499 | // If you are doing I/O in another thread, you do not | |
| 500 | 500 | // need to worry about this, and can simply block in the signal | |
| 501 | 501 | // handler until the UI thread returns an answer. | |
| 502 | - | func (x *TlsConnection) ConnectAcceptCertificate(cb func(TlsConnection, uintptr, TlsCertificateFlags) bool) uint32 { | |
| 502 | + | func (x *TlsConnection) ConnectAcceptCertificate(cb *func(TlsConnection, uintptr, TlsCertificateFlags) bool) uint32 { | |
| 503 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 504 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 505 | + | return gobject.SignalConnect(x.GoPointer(), "accept-certificate", cbRefPtr) | |
| 506 | + | } | |
| 507 | + | ||
| 503 | 508 | fcb := func(clsPtr uintptr, PeerCertVarp uintptr, ErrorsVarp TlsCertificateFlags) bool { | |
| 504 | 509 | fa := TlsConnection{} | |
| 505 | 510 | fa.Ptr = clsPtr | |
| 511 | + | cbFn := *cb | |
| 506 | 512 | ||
| 507 | - | return cb(fa, PeerCertVarp, ErrorsVarp) | |
| 513 | + | return cbFn(fa, PeerCertVarp, ErrorsVarp) | |
| 508 | 514 | ||
| 509 | 515 | } | |
| 510 | - | return gobject.SignalConnect(x.GoPointer(), "accept-certificate", purego.NewCallback(fcb)) | |
| 516 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 517 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 518 | + | return gobject.SignalConnect(x.GoPointer(), "accept-certificate", cbRefPtr) | |
| 511 | 519 | } | |
| 512 | 520 | ||
| 513 | 521 | func init() { | |
M v4/gio/gtlsdatabase.go +8 -8
| @@ -110,9 +110,9 @@ var xTlsDatabaseLookupCertificateForHandleAsync func(uintptr, string, uintptr, T | |||
| 110 | 110 | ||
| 111 | 111 | // Asynchronously look up a certificate by its handle in the database. See | |
| 112 | 112 | // g_tls_database_lookup_certificate_for_handle() for more information. | |
| 113 | - | func (x *TlsDatabase) LookupCertificateForHandleAsync(HandleVar string, InteractionVar *TlsInteraction, FlagsVar TlsDatabaseLookupFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 113 | + | func (x *TlsDatabase) LookupCertificateForHandleAsync(HandleVar string, InteractionVar *TlsInteraction, FlagsVar TlsDatabaseLookupFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 114 | 114 | ||
| 115 | - | xTlsDatabaseLookupCertificateForHandleAsync(x.GoPointer(), HandleVar, InteractionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 115 | + | xTlsDatabaseLookupCertificateForHandleAsync(x.GoPointer(), HandleVar, InteractionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 116 | 116 | ||
| 117 | 117 | } | |
| 118 | 118 | ||
| @@ -185,9 +185,9 @@ var xTlsDatabaseLookupCertificateIssuerAsync func(uintptr, uintptr, uintptr, Tls | |||
| 185 | 185 | ||
| 186 | 186 | // Asynchronously look up the issuer of @certificate in the database. See | |
| 187 | 187 | // g_tls_database_lookup_certificate_issuer() for more information. | |
| 188 | - | func (x *TlsDatabase) LookupCertificateIssuerAsync(CertificateVar *TlsCertificate, InteractionVar *TlsInteraction, FlagsVar TlsDatabaseLookupFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 188 | + | func (x *TlsDatabase) LookupCertificateIssuerAsync(CertificateVar *TlsCertificate, InteractionVar *TlsInteraction, FlagsVar TlsDatabaseLookupFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 189 | 189 | ||
| 190 | - | xTlsDatabaseLookupCertificateIssuerAsync(x.GoPointer(), CertificateVar.GoPointer(), InteractionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 190 | + | xTlsDatabaseLookupCertificateIssuerAsync(x.GoPointer(), CertificateVar.GoPointer(), InteractionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 191 | 191 | ||
| 192 | 192 | } | |
| 193 | 193 | ||
| @@ -238,9 +238,9 @@ var xTlsDatabaseLookupCertificatesIssuedByAsync func(uintptr, uintptr, uintptr, | |||
| 238 | 238 | // The database may choose to hold a reference to the issuer byte array for the duration | |
| 239 | 239 | // of of this asynchronous operation. The byte array should not be modified during | |
| 240 | 240 | // this time. | |
| 241 | - | func (x *TlsDatabase) LookupCertificatesIssuedByAsync(IssuerRawDnVar uintptr, InteractionVar *TlsInteraction, FlagsVar TlsDatabaseLookupFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 241 | + | func (x *TlsDatabase) LookupCertificatesIssuedByAsync(IssuerRawDnVar uintptr, InteractionVar *TlsInteraction, FlagsVar TlsDatabaseLookupFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 242 | 242 | ||
| 243 | - | xTlsDatabaseLookupCertificatesIssuedByAsync(x.GoPointer(), IssuerRawDnVar, InteractionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 243 | + | xTlsDatabaseLookupCertificatesIssuedByAsync(x.GoPointer(), IssuerRawDnVar, InteractionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 244 | 244 | ||
| 245 | 245 | } | |
| 246 | 246 | ||
| @@ -337,9 +337,9 @@ var xTlsDatabaseVerifyChainAsync func(uintptr, uintptr, string, uintptr, uintptr | |||
| 337 | 337 | // Asynchronously determines the validity of a certificate chain after | |
| 338 | 338 | // looking up and adding any missing certificates to the chain. See | |
| 339 | 339 | // g_tls_database_verify_chain() for more information. | |
| 340 | - | func (x *TlsDatabase) VerifyChainAsync(ChainVar *TlsCertificate, PurposeVar string, IdentityVar SocketConnectable, InteractionVar *TlsInteraction, FlagsVar TlsDatabaseVerifyFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 340 | + | func (x *TlsDatabase) VerifyChainAsync(ChainVar *TlsCertificate, PurposeVar string, IdentityVar SocketConnectable, InteractionVar *TlsInteraction, FlagsVar TlsDatabaseVerifyFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 341 | 341 | ||
| 342 | - | xTlsDatabaseVerifyChainAsync(x.GoPointer(), ChainVar.GoPointer(), PurposeVar, IdentityVar.GoPointer(), InteractionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 342 | + | xTlsDatabaseVerifyChainAsync(x.GoPointer(), ChainVar.GoPointer(), PurposeVar, IdentityVar.GoPointer(), InteractionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 343 | 343 | ||
| 344 | 344 | } | |
| 345 | 345 | ||
M v4/gio/gtlsinteraction.go +4 -4
| @@ -114,9 +114,9 @@ var xTlsInteractionAskPasswordAsync func(uintptr, uintptr, uintptr, uintptr, uin | |||
| 114 | 114 | // not support immediate cancellation. | |
| 115 | 115 | // | |
| 116 | 116 | // Certain implementations may not support immediate cancellation. | |
| 117 | - | func (x *TlsInteraction) AskPasswordAsync(PasswordVar *TlsPassword, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 117 | + | func (x *TlsInteraction) AskPasswordAsync(PasswordVar *TlsPassword, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 118 | 118 | ||
| 119 | - | xTlsInteractionAskPasswordAsync(x.GoPointer(), PasswordVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 119 | + | xTlsInteractionAskPasswordAsync(x.GoPointer(), PasswordVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 120 | 120 | ||
| 121 | 121 | } | |
| 122 | 122 | ||
| @@ -246,9 +246,9 @@ var xTlsInteractionRequestCertificateAsync func(uintptr, uintptr, TlsCertificate | |||
| 246 | 246 | // also choose to provide a certificate from elsewhere. @callback will be called | |
| 247 | 247 | // when the operation completes. Alternatively the user may abort this certificate | |
| 248 | 248 | // request, which will usually abort the TLS connection. | |
| 249 | - | func (x *TlsInteraction) RequestCertificateAsync(ConnectionVar *TlsConnection, FlagsVar TlsCertificateRequestFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 249 | + | func (x *TlsInteraction) RequestCertificateAsync(ConnectionVar *TlsConnection, FlagsVar TlsCertificateRequestFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 250 | 250 | ||
| 251 | - | xTlsInteractionRequestCertificateAsync(x.GoPointer(), ConnectionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 251 | + | xTlsInteractionRequestCertificateAsync(x.GoPointer(), ConnectionVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 252 | 252 | ||
| 253 | 253 | } | |
| 254 | 254 | ||
M v4/gio/gtlspassword.go +2 -2
| @@ -141,9 +141,9 @@ var xTlsPasswordSetValueFull func(uintptr, uintptr, int, uintptr) | |||
| 141 | 141 | // @length if using a nul-terminated password, and @length will be | |
| 142 | 142 | // calculated automatically. (Note that the terminating nul is not | |
| 143 | 143 | // considered part of the password in this case.) | |
| 144 | - | func (x *TlsPassword) SetValueFull(ValueVar uintptr, LengthVar int, DestroyVar glib.DestroyNotify) { | |
| 144 | + | func (x *TlsPassword) SetValueFull(ValueVar uintptr, LengthVar int, DestroyVar *glib.DestroyNotify) { | |
| 145 | 145 | ||
| 146 | - | xTlsPasswordSetValueFull(x.GoPointer(), ValueVar, LengthVar, purego.NewCallback(DestroyVar)) | |
| 146 | + | xTlsPasswordSetValueFull(x.GoPointer(), ValueVar, LengthVar, glib.NewCallback(DestroyVar)) | |
| 147 | 147 | ||
| 148 | 148 | } | |
| 149 | 149 | ||
M v4/gio/gunixconnection.go +4 -4
| @@ -93,9 +93,9 @@ var xUnixConnectionReceiveCredentialsAsync func(uintptr, uintptr, uintptr, uintp | |||
| 93 | 93 | // | |
| 94 | 94 | // When the operation is finished, @callback will be called. You can then call | |
| 95 | 95 | // g_unix_connection_receive_credentials_finish() to get the result of the operation. | |
| 96 | - | func (x *UnixConnection) ReceiveCredentialsAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 96 | + | func (x *UnixConnection) ReceiveCredentialsAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 97 | 97 | ||
| 98 | - | xUnixConnectionReceiveCredentialsAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 98 | + | xUnixConnectionReceiveCredentialsAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 99 | 99 | ||
| 100 | 100 | } | |
| 101 | 101 | ||
| @@ -182,9 +182,9 @@ var xUnixConnectionSendCredentialsAsync func(uintptr, uintptr, uintptr, uintptr) | |||
| 182 | 182 | // | |
| 183 | 183 | // When the operation is finished, @callback will be called. You can then call | |
| 184 | 184 | // g_unix_connection_send_credentials_finish() to get the result of the operation. | |
| 185 | - | func (x *UnixConnection) SendCredentialsAsync(CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 185 | + | func (x *UnixConnection) SendCredentialsAsync(CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 186 | 186 | ||
| 187 | - | xUnixConnectionSendCredentialsAsync(x.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 187 | + | xUnixConnectionSendCredentialsAsync(x.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 188 | 188 | ||
| 189 | 189 | } | |
| 190 | 190 | ||
M v4/gio/gunixmounts.go +22 -6
| @@ -525,27 +525,43 @@ func (c *UnixMountMonitor) SetGoPointer(ptr uintptr) { | |||
| 525 | 525 | } | |
| 526 | 526 | ||
| 527 | 527 | // Emitted when the unix mount points have changed. | |
| 528 | - | func (x *UnixMountMonitor) ConnectMountpointsChanged(cb func(UnixMountMonitor)) uint32 { | |
| 528 | + | func (x *UnixMountMonitor) ConnectMountpointsChanged(cb *func(UnixMountMonitor)) uint32 { | |
| 529 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 530 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 531 | + | return gobject.SignalConnect(x.GoPointer(), "mountpoints-changed", cbRefPtr) | |
| 532 | + | } | |
| 533 | + | ||
| 529 | 534 | fcb := func(clsPtr uintptr) { | |
| 530 | 535 | fa := UnixMountMonitor{} | |
| 531 | 536 | fa.Ptr = clsPtr | |
| 537 | + | cbFn := *cb | |
| 532 | 538 | ||
| 533 | - | cb(fa) | |
| 539 | + | cbFn(fa) | |
| 534 | 540 | ||
| 535 | 541 | } | |
| 536 | - | return gobject.SignalConnect(x.GoPointer(), "mountpoints-changed", purego.NewCallback(fcb)) | |
| 542 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 543 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 544 | + | return gobject.SignalConnect(x.GoPointer(), "mountpoints-changed", cbRefPtr) | |
| 537 | 545 | } | |
| 538 | 546 | ||
| 539 | 547 | // Emitted when the unix mounts have changed. | |
| 540 | - | func (x *UnixMountMonitor) ConnectMountsChanged(cb func(UnixMountMonitor)) uint32 { | |
| 548 | + | func (x *UnixMountMonitor) ConnectMountsChanged(cb *func(UnixMountMonitor)) uint32 { | |
| 549 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 550 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 551 | + | return gobject.SignalConnect(x.GoPointer(), "mounts-changed", cbRefPtr) | |
| 552 | + | } | |
| 553 | + | ||
| 541 | 554 | fcb := func(clsPtr uintptr) { | |
| 542 | 555 | fa := UnixMountMonitor{} | |
| 543 | 556 | fa.Ptr = clsPtr | |
| 557 | + | cbFn := *cb | |
| 544 | 558 | ||
| 545 | - | cb(fa) | |
| 559 | + | cbFn(fa) | |
| 546 | 560 | ||
| 547 | 561 | } | |
| 548 | - | return gobject.SignalConnect(x.GoPointer(), "mounts-changed", purego.NewCallback(fcb)) | |
| 562 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 563 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 564 | + | return gobject.SignalConnect(x.GoPointer(), "mounts-changed", cbRefPtr) | |
| 549 | 565 | } | |
| 550 | 566 | ||
| 551 | 567 | var xUnixMountMonitorGet func() uintptr | |
M v4/gio/gvfs.go +2 -2
| @@ -137,9 +137,9 @@ var xVfsRegisterUriScheme func(uintptr, string, uintptr, uintptr, uintptr, uintp | |||
| 137 | 137 | // | |
| 138 | 138 | // It's an error to call this function twice with the same scheme. To unregister | |
| 139 | 139 | // a custom URI scheme, use g_vfs_unregister_uri_scheme(). | |
| 140 | - | func (x *Vfs) RegisterUriScheme(SchemeVar string, UriFuncVar VfsFileLookupFunc, UriDataVar uintptr, UriDestroyVar glib.DestroyNotify, ParseNameFuncVar VfsFileLookupFunc, ParseNameDataVar uintptr, ParseNameDestroyVar glib.DestroyNotify) bool { | |
| 140 | + | func (x *Vfs) RegisterUriScheme(SchemeVar string, UriFuncVar *VfsFileLookupFunc, UriDataVar uintptr, UriDestroyVar *glib.DestroyNotify, ParseNameFuncVar *VfsFileLookupFunc, ParseNameDataVar uintptr, ParseNameDestroyVar *glib.DestroyNotify) bool { | |
| 141 | 141 | ||
| 142 | - | cret := xVfsRegisterUriScheme(x.GoPointer(), SchemeVar, purego.NewCallback(UriFuncVar), UriDataVar, purego.NewCallback(UriDestroyVar), purego.NewCallback(ParseNameFuncVar), ParseNameDataVar, purego.NewCallback(ParseNameDestroyVar)) | |
| 142 | + | cret := xVfsRegisterUriScheme(x.GoPointer(), SchemeVar, glib.NewCallback(UriFuncVar), UriDataVar, glib.NewCallback(UriDestroyVar), glib.NewCallback(ParseNameFuncVar), ParseNameDataVar, glib.NewCallback(ParseNameDestroyVar)) | |
| 143 | 143 | return cret | |
| 144 | 144 | } | |
| 145 | 145 | ||
M v4/gio/gvolume.go +9 -9
| @@ -63,9 +63,9 @@ type Volume interface { | |||
| 63 | 63 | SetGoPointer(uintptr) | |
| 64 | 64 | CanEject() bool | |
| 65 | 65 | CanMount() bool | |
| 66 | - | Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 66 | + | Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 67 | 67 | EjectFinish(ResultVar AsyncResult) bool | |
| 68 | - | EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 68 | + | EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 69 | 69 | EjectWithOperationFinish(ResultVar AsyncResult) bool | |
| 70 | 70 | EnumerateIdentifiers() []string | |
| 71 | 71 | GetActivationRoot() *FileBase | |
| @@ -77,7 +77,7 @@ type Volume interface { | |||
| 77 | 77 | GetSortKey() string | |
| 78 | 78 | GetSymbolicIcon() *IconBase | |
| 79 | 79 | GetUuid() string | |
| 80 | - | Mount(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) | |
| 80 | + | Mount(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) | |
| 81 | 81 | MountFinish(ResultVar AsyncResult) bool | |
| 82 | 82 | ShouldAutomount() bool | |
| 83 | 83 | } | |
| @@ -110,9 +110,9 @@ func (x *VolumeBase) CanMount() bool { | |||
| 110 | 110 | // Ejects a volume. This is an asynchronous operation, and is | |
| 111 | 111 | // finished by calling g_volume_eject_finish() with the @volume | |
| 112 | 112 | // and #GAsyncResult returned in the @callback. | |
| 113 | - | func (x *VolumeBase) Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 113 | + | func (x *VolumeBase) Eject(FlagsVar MountUnmountFlags, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 114 | 114 | ||
| 115 | - | XGVolumeEject(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 115 | + | XGVolumeEject(x.GoPointer(), FlagsVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 116 | 116 | ||
| 117 | 117 | } | |
| 118 | 118 | ||
| @@ -132,9 +132,9 @@ func (x *VolumeBase) EjectFinish(ResultVar AsyncResult) (bool, error) { | |||
| 132 | 132 | // Ejects a volume. This is an asynchronous operation, and is | |
| 133 | 133 | // finished by calling g_volume_eject_with_operation_finish() with the @volume | |
| 134 | 134 | // and #GAsyncResult data returned in the @callback. | |
| 135 | - | func (x *VolumeBase) EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 135 | + | func (x *VolumeBase) EjectWithOperation(FlagsVar MountUnmountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 136 | 136 | ||
| 137 | - | XGVolumeEjectWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 137 | + | XGVolumeEjectWithOperation(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 138 | 138 | ||
| 139 | 139 | } | |
| 140 | 140 | ||
| @@ -294,9 +294,9 @@ func (x *VolumeBase) GetUuid() string { | |||
| 294 | 294 | // Mounts a volume. This is an asynchronous operation, and is | |
| 295 | 295 | // finished by calling g_volume_mount_finish() with the @volume | |
| 296 | 296 | // and #GAsyncResult returned in the @callback. | |
| 297 | - | func (x *VolumeBase) Mount(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar AsyncReadyCallback, UserDataVar uintptr) { | |
| 297 | + | func (x *VolumeBase) Mount(FlagsVar MountMountFlags, MountOperationVar *MountOperation, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { | |
| 298 | 298 | ||
| 299 | - | XGVolumeMount(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 299 | + | XGVolumeMount(x.GoPointer(), FlagsVar, MountOperationVar.GoPointer(), CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 300 | 300 | ||
| 301 | 301 | } | |
| 302 | 302 | ||
M v4/gio/gvolumemonitor.go +132 -36
| @@ -122,150 +122,246 @@ func (c *VolumeMonitor) SetGoPointer(ptr uintptr) { | |||
| 122 | 122 | } | |
| 123 | 123 | ||
| 124 | 124 | // Emitted when a drive changes. | |
| 125 | - | func (x *VolumeMonitor) ConnectDriveChanged(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 125 | + | func (x *VolumeMonitor) ConnectDriveChanged(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 126 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 127 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 128 | + | return gobject.SignalConnect(x.GoPointer(), "drive-changed", cbRefPtr) | |
| 129 | + | } | |
| 130 | + | ||
| 126 | 131 | fcb := func(clsPtr uintptr, DriveVarp uintptr) { | |
| 127 | 132 | fa := VolumeMonitor{} | |
| 128 | 133 | fa.Ptr = clsPtr | |
| 134 | + | cbFn := *cb | |
| 129 | 135 | ||
| 130 | - | cb(fa, DriveVarp) | |
| 136 | + | cbFn(fa, DriveVarp) | |
| 131 | 137 | ||
| 132 | 138 | } | |
| 133 | - | return gobject.SignalConnect(x.GoPointer(), "drive-changed", purego.NewCallback(fcb)) | |
| 139 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 140 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 141 | + | return gobject.SignalConnect(x.GoPointer(), "drive-changed", cbRefPtr) | |
| 134 | 142 | } | |
| 135 | 143 | ||
| 136 | 144 | // Emitted when a drive is connected to the system. | |
| 137 | - | func (x *VolumeMonitor) ConnectDriveConnected(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 145 | + | func (x *VolumeMonitor) ConnectDriveConnected(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 146 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 147 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 148 | + | return gobject.SignalConnect(x.GoPointer(), "drive-connected", cbRefPtr) | |
| 149 | + | } | |
| 150 | + | ||
| 138 | 151 | fcb := func(clsPtr uintptr, DriveVarp uintptr) { | |
| 139 | 152 | fa := VolumeMonitor{} | |
| 140 | 153 | fa.Ptr = clsPtr | |
| 154 | + | cbFn := *cb | |
| 141 | 155 | ||
| 142 | - | cb(fa, DriveVarp) | |
| 156 | + | cbFn(fa, DriveVarp) | |
| 143 | 157 | ||
| 144 | 158 | } | |
| 145 | - | return gobject.SignalConnect(x.GoPointer(), "drive-connected", purego.NewCallback(fcb)) | |
| 159 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 160 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 161 | + | return gobject.SignalConnect(x.GoPointer(), "drive-connected", cbRefPtr) | |
| 146 | 162 | } | |
| 147 | 163 | ||
| 148 | 164 | // Emitted when a drive is disconnected from the system. | |
| 149 | - | func (x *VolumeMonitor) ConnectDriveDisconnected(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 165 | + | func (x *VolumeMonitor) ConnectDriveDisconnected(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 166 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 167 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 168 | + | return gobject.SignalConnect(x.GoPointer(), "drive-disconnected", cbRefPtr) | |
| 169 | + | } | |
| 170 | + | ||
| 150 | 171 | fcb := func(clsPtr uintptr, DriveVarp uintptr) { | |
| 151 | 172 | fa := VolumeMonitor{} | |
| 152 | 173 | fa.Ptr = clsPtr | |
| 174 | + | cbFn := *cb | |
| 153 | 175 | ||
| 154 | - | cb(fa, DriveVarp) | |
| 176 | + | cbFn(fa, DriveVarp) | |
| 155 | 177 | ||
| 156 | 178 | } | |
| 157 | - | return gobject.SignalConnect(x.GoPointer(), "drive-disconnected", purego.NewCallback(fcb)) | |
| 179 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 180 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 181 | + | return gobject.SignalConnect(x.GoPointer(), "drive-disconnected", cbRefPtr) | |
| 158 | 182 | } | |
| 159 | 183 | ||
| 160 | 184 | // Emitted when the eject button is pressed on @drive. | |
| 161 | - | func (x *VolumeMonitor) ConnectDriveEjectButton(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 185 | + | func (x *VolumeMonitor) ConnectDriveEjectButton(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 186 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 187 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 188 | + | return gobject.SignalConnect(x.GoPointer(), "drive-eject-button", cbRefPtr) | |
| 189 | + | } | |
| 190 | + | ||
| 162 | 191 | fcb := func(clsPtr uintptr, DriveVarp uintptr) { | |
| 163 | 192 | fa := VolumeMonitor{} | |
| 164 | 193 | fa.Ptr = clsPtr | |
| 194 | + | cbFn := *cb | |
| 165 | 195 | ||
| 166 | - | cb(fa, DriveVarp) | |
| 196 | + | cbFn(fa, DriveVarp) | |
| 167 | 197 | ||
| 168 | 198 | } | |
| 169 | - | return gobject.SignalConnect(x.GoPointer(), "drive-eject-button", purego.NewCallback(fcb)) | |
| 199 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 200 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 201 | + | return gobject.SignalConnect(x.GoPointer(), "drive-eject-button", cbRefPtr) | |
| 170 | 202 | } | |
| 171 | 203 | ||
| 172 | 204 | // Emitted when the stop button is pressed on @drive. | |
| 173 | - | func (x *VolumeMonitor) ConnectDriveStopButton(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 205 | + | func (x *VolumeMonitor) ConnectDriveStopButton(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 206 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 207 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 208 | + | return gobject.SignalConnect(x.GoPointer(), "drive-stop-button", cbRefPtr) | |
| 209 | + | } | |
| 210 | + | ||
| 174 | 211 | fcb := func(clsPtr uintptr, DriveVarp uintptr) { | |
| 175 | 212 | fa := VolumeMonitor{} | |
| 176 | 213 | fa.Ptr = clsPtr | |
| 214 | + | cbFn := *cb | |
| 177 | 215 | ||
| 178 | - | cb(fa, DriveVarp) | |
| 216 | + | cbFn(fa, DriveVarp) | |
| 179 | 217 | ||
| 180 | 218 | } | |
| 181 | - | return gobject.SignalConnect(x.GoPointer(), "drive-stop-button", purego.NewCallback(fcb)) | |
| 219 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 220 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 221 | + | return gobject.SignalConnect(x.GoPointer(), "drive-stop-button", cbRefPtr) | |
| 182 | 222 | } | |
| 183 | 223 | ||
| 184 | 224 | // Emitted when a mount is added. | |
| 185 | - | func (x *VolumeMonitor) ConnectMountAdded(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 225 | + | func (x *VolumeMonitor) ConnectMountAdded(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 226 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 227 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 228 | + | return gobject.SignalConnect(x.GoPointer(), "mount-added", cbRefPtr) | |
| 229 | + | } | |
| 230 | + | ||
| 186 | 231 | fcb := func(clsPtr uintptr, MountVarp uintptr) { | |
| 187 | 232 | fa := VolumeMonitor{} | |
| 188 | 233 | fa.Ptr = clsPtr | |
| 234 | + | cbFn := *cb | |
| 189 | 235 | ||
| 190 | - | cb(fa, MountVarp) | |
| 236 | + | cbFn(fa, MountVarp) | |
| 191 | 237 | ||
| 192 | 238 | } | |
| 193 | - | return gobject.SignalConnect(x.GoPointer(), "mount-added", purego.NewCallback(fcb)) | |
| 239 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 240 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 241 | + | return gobject.SignalConnect(x.GoPointer(), "mount-added", cbRefPtr) | |
| 194 | 242 | } | |
| 195 | 243 | ||
| 196 | 244 | // Emitted when a mount changes. | |
| 197 | - | func (x *VolumeMonitor) ConnectMountChanged(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 245 | + | func (x *VolumeMonitor) ConnectMountChanged(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 246 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 247 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 248 | + | return gobject.SignalConnect(x.GoPointer(), "mount-changed", cbRefPtr) | |
| 249 | + | } | |
| 250 | + | ||
| 198 | 251 | fcb := func(clsPtr uintptr, MountVarp uintptr) { | |
| 199 | 252 | fa := VolumeMonitor{} | |
| 200 | 253 | fa.Ptr = clsPtr | |
| 254 | + | cbFn := *cb | |
| 201 | 255 | ||
| 202 | - | cb(fa, MountVarp) | |
| 256 | + | cbFn(fa, MountVarp) | |
| 203 | 257 | ||
| 204 | 258 | } | |
| 205 | - | return gobject.SignalConnect(x.GoPointer(), "mount-changed", purego.NewCallback(fcb)) | |
| 259 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 260 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 261 | + | return gobject.SignalConnect(x.GoPointer(), "mount-changed", cbRefPtr) | |
| 206 | 262 | } | |
| 207 | 263 | ||
| 208 | 264 | // May be emitted when a mount is about to be removed. | |
| 209 | 265 | // | |
| 210 | 266 | // This signal depends on the backend and is only emitted if | |
| 211 | 267 | // GIO was used to unmount. | |
| 212 | - | func (x *VolumeMonitor) ConnectMountPreUnmount(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 268 | + | func (x *VolumeMonitor) ConnectMountPreUnmount(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 269 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 270 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 271 | + | return gobject.SignalConnect(x.GoPointer(), "mount-pre-unmount", cbRefPtr) | |
| 272 | + | } | |
| 273 | + | ||
| 213 | 274 | fcb := func(clsPtr uintptr, MountVarp uintptr) { | |
| 214 | 275 | fa := VolumeMonitor{} | |
| 215 | 276 | fa.Ptr = clsPtr | |
| 277 | + | cbFn := *cb | |
| 216 | 278 | ||
| 217 | - | cb(fa, MountVarp) | |
| 279 | + | cbFn(fa, MountVarp) | |
| 218 | 280 | ||
| 219 | 281 | } | |
| 220 | - | return gobject.SignalConnect(x.GoPointer(), "mount-pre-unmount", purego.NewCallback(fcb)) | |
| 282 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 283 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 284 | + | return gobject.SignalConnect(x.GoPointer(), "mount-pre-unmount", cbRefPtr) | |
| 221 | 285 | } | |
| 222 | 286 | ||
| 223 | 287 | // Emitted when a mount is removed. | |
| 224 | - | func (x *VolumeMonitor) ConnectMountRemoved(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 288 | + | func (x *VolumeMonitor) ConnectMountRemoved(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 289 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 290 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 291 | + | return gobject.SignalConnect(x.GoPointer(), "mount-removed", cbRefPtr) | |
| 292 | + | } | |
| 293 | + | ||
| 225 | 294 | fcb := func(clsPtr uintptr, MountVarp uintptr) { | |
| 226 | 295 | fa := VolumeMonitor{} | |
| 227 | 296 | fa.Ptr = clsPtr | |
| 297 | + | cbFn := *cb | |
| 228 | 298 | ||
| 229 | - | cb(fa, MountVarp) | |
| 299 | + | cbFn(fa, MountVarp) | |
| 230 | 300 | ||
| 231 | 301 | } | |
| 232 | - | return gobject.SignalConnect(x.GoPointer(), "mount-removed", purego.NewCallback(fcb)) | |
| 302 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 303 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 304 | + | return gobject.SignalConnect(x.GoPointer(), "mount-removed", cbRefPtr) | |
| 233 | 305 | } | |
| 234 | 306 | ||
| 235 | 307 | // Emitted when a mountable volume is added to the system. | |
| 236 | - | func (x *VolumeMonitor) ConnectVolumeAdded(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 308 | + | func (x *VolumeMonitor) ConnectVolumeAdded(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 309 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 310 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 311 | + | return gobject.SignalConnect(x.GoPointer(), "volume-added", cbRefPtr) | |
| 312 | + | } | |
| 313 | + | ||
| 237 | 314 | fcb := func(clsPtr uintptr, VolumeVarp uintptr) { | |
| 238 | 315 | fa := VolumeMonitor{} | |
| 239 | 316 | fa.Ptr = clsPtr | |
| 317 | + | cbFn := *cb | |
| 240 | 318 | ||
| 241 | - | cb(fa, VolumeVarp) | |
| 319 | + | cbFn(fa, VolumeVarp) | |
| 242 | 320 | ||
| 243 | 321 | } | |
| 244 | - | return gobject.SignalConnect(x.GoPointer(), "volume-added", purego.NewCallback(fcb)) | |
| 322 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 323 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 324 | + | return gobject.SignalConnect(x.GoPointer(), "volume-added", cbRefPtr) | |
| 245 | 325 | } | |
| 246 | 326 | ||
| 247 | 327 | // Emitted when mountable volume is changed. | |
| 248 | - | func (x *VolumeMonitor) ConnectVolumeChanged(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 328 | + | func (x *VolumeMonitor) ConnectVolumeChanged(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 329 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 330 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 331 | + | return gobject.SignalConnect(x.GoPointer(), "volume-changed", cbRefPtr) | |
| 332 | + | } | |
| 333 | + | ||
| 249 | 334 | fcb := func(clsPtr uintptr, VolumeVarp uintptr) { | |
| 250 | 335 | fa := VolumeMonitor{} | |
| 251 | 336 | fa.Ptr = clsPtr | |
| 337 | + | cbFn := *cb | |
| 252 | 338 | ||
| 253 | - | cb(fa, VolumeVarp) | |
| 339 | + | cbFn(fa, VolumeVarp) | |
| 254 | 340 | ||
| 255 | 341 | } | |
| 256 | - | return gobject.SignalConnect(x.GoPointer(), "volume-changed", purego.NewCallback(fcb)) | |
| 342 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 343 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 344 | + | return gobject.SignalConnect(x.GoPointer(), "volume-changed", cbRefPtr) | |
| 257 | 345 | } | |
| 258 | 346 | ||
| 259 | 347 | // Emitted when a mountable volume is removed from the system. | |
| 260 | - | func (x *VolumeMonitor) ConnectVolumeRemoved(cb func(VolumeMonitor, uintptr)) uint32 { | |
| 348 | + | func (x *VolumeMonitor) ConnectVolumeRemoved(cb *func(VolumeMonitor, uintptr)) uint32 { | |
| 349 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 350 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 351 | + | return gobject.SignalConnect(x.GoPointer(), "volume-removed", cbRefPtr) | |
| 352 | + | } | |
| 353 | + | ||
| 261 | 354 | fcb := func(clsPtr uintptr, VolumeVarp uintptr) { | |
| 262 | 355 | fa := VolumeMonitor{} | |
| 263 | 356 | fa.Ptr = clsPtr | |
| 357 | + | cbFn := *cb | |
| 264 | 358 | ||
| 265 | - | cb(fa, VolumeVarp) | |
| 359 | + | cbFn(fa, VolumeVarp) | |
| 266 | 360 | ||
| 267 | 361 | } | |
| 268 | - | return gobject.SignalConnect(x.GoPointer(), "volume-removed", purego.NewCallback(fcb)) | |
| 362 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 363 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 364 | + | return gobject.SignalConnect(x.GoPointer(), "volume-removed", cbRefPtr) | |
| 269 | 365 | } | |
| 270 | 366 | ||
| 271 | 367 | var xVolumeMonitorAdoptOrphanMount func(uintptr) uintptr | |
M v4/glib/garray.go +4 -4
| @@ -115,9 +115,9 @@ var xNewBytesWithFreeFunc func(uintptr, uint, uintptr, uintptr) *Bytes | |||
| 115 | 115 | // been called to indicate that the bytes is no longer in use. | |
| 116 | 116 | // | |
| 117 | 117 | // @data may be %NULL if @size is 0. | |
| 118 | - | func NewBytesWithFreeFunc(DataVar uintptr, SizeVar uint, FreeFuncVar DestroyNotify, UserDataVar uintptr) *Bytes { | |
| 118 | + | func NewBytesWithFreeFunc(DataVar uintptr, SizeVar uint, FreeFuncVar *DestroyNotify, UserDataVar uintptr) *Bytes { | |
| 119 | 119 | ||
| 120 | - | cret := xNewBytesWithFreeFunc(DataVar, SizeVar, purego.NewCallback(FreeFuncVar), UserDataVar) | |
| 120 | + | cret := xNewBytesWithFreeFunc(DataVar, SizeVar, NewCallback(FreeFuncVar), UserDataVar) | |
| 121 | 121 | return cret | |
| 122 | 122 | } | |
| 123 | 123 | ||
| @@ -400,9 +400,9 @@ var xPtrArrayFindWithEqualFunc func(uintptr, uintptr, uintptr, uint) bool | |||
| 400 | 400 | // @equal_func is called with the element from the array as its first parameter, | |
| 401 | 401 | // and @needle as its second parameter. If @equal_func is %NULL, pointer | |
| 402 | 402 | // equality is used. | |
| 403 | - | func PtrArrayFindWithEqualFunc(HaystackVar uintptr, NeedleVar uintptr, EqualFuncVar EqualFunc, IndexVar uint) bool { | |
| 403 | + | func PtrArrayFindWithEqualFunc(HaystackVar uintptr, NeedleVar uintptr, EqualFuncVar *EqualFunc, IndexVar uint) bool { | |
| 404 | 404 | ||
| 405 | - | cret := xPtrArrayFindWithEqualFunc(HaystackVar, NeedleVar, purego.NewCallback(EqualFuncVar), IndexVar) | |
| 405 | + | cret := xPtrArrayFindWithEqualFunc(HaystackVar, NeedleVar, NewCallback(EqualFuncVar), IndexVar) | |
| 406 | 406 | return cret | |
| 407 | 407 | } | |
| 408 | 408 | ||
M v4/glib/gasyncqueue.go +8 -8
| @@ -138,9 +138,9 @@ var xAsyncQueuePushSorted func(uintptr, uintptr, uintptr, uintptr) | |||
| 138 | 138 | // it when it is finished. | |
| 139 | 139 | // | |
| 140 | 140 | // For an example of @func see g_async_queue_sort(). | |
| 141 | - | func (x *AsyncQueue) PushSorted(DataVar uintptr, FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 141 | + | func (x *AsyncQueue) PushSorted(DataVar uintptr, FuncVar *CompareDataFunc, UserDataVar uintptr) { | |
| 142 | 142 | ||
| 143 | - | xAsyncQueuePushSorted(x.GoPointer(), DataVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 143 | + | xAsyncQueuePushSorted(x.GoPointer(), DataVar, NewCallback(FuncVar), UserDataVar) | |
| 144 | 144 | ||
| 145 | 145 | } | |
| 146 | 146 | ||
| @@ -161,9 +161,9 @@ var xAsyncQueuePushSortedUnlocked func(uintptr, uintptr, uintptr, uintptr) | |||
| 161 | 161 | // This function must be called while holding the @queue's lock. | |
| 162 | 162 | // | |
| 163 | 163 | // For an example of @func see g_async_queue_sort(). | |
| 164 | - | func (x *AsyncQueue) PushSortedUnlocked(DataVar uintptr, FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 164 | + | func (x *AsyncQueue) PushSortedUnlocked(DataVar uintptr, FuncVar *CompareDataFunc, UserDataVar uintptr) { | |
| 165 | 165 | ||
| 166 | - | xAsyncQueuePushSortedUnlocked(x.GoPointer(), DataVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 166 | + | xAsyncQueuePushSortedUnlocked(x.GoPointer(), DataVar, NewCallback(FuncVar), UserDataVar) | |
| 167 | 167 | ||
| 168 | 168 | } | |
| 169 | 169 | ||
| @@ -243,9 +243,9 @@ var xAsyncQueueSort func(uintptr, uintptr, uintptr) | |||
| 243 | 243 | // return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1); | |
| 244 | 244 | // | |
| 245 | 245 | // ]| | |
| 246 | - | func (x *AsyncQueue) Sort(FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 246 | + | func (x *AsyncQueue) Sort(FuncVar *CompareDataFunc, UserDataVar uintptr) { | |
| 247 | 247 | ||
| 248 | - | xAsyncQueueSort(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 248 | + | xAsyncQueueSort(x.GoPointer(), NewCallback(FuncVar), UserDataVar) | |
| 249 | 249 | ||
| 250 | 250 | } | |
| 251 | 251 | ||
| @@ -260,9 +260,9 @@ var xAsyncQueueSortUnlocked func(uintptr, uintptr, uintptr) | |||
| 260 | 260 | // element. | |
| 261 | 261 | // | |
| 262 | 262 | // This function must be called while holding the @queue's lock. | |
| 263 | - | func (x *AsyncQueue) SortUnlocked(FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 263 | + | func (x *AsyncQueue) SortUnlocked(FuncVar *CompareDataFunc, UserDataVar uintptr) { | |
| 264 | 264 | ||
| 265 | - | xAsyncQueueSortUnlocked(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 265 | + | xAsyncQueueSortUnlocked(x.GoPointer(), NewCallback(FuncVar), UserDataVar) | |
| 266 | 266 | ||
| 267 | 267 | } | |
| 268 | 268 | ||
M v4/glib/gdataset.go +12 -12
| @@ -59,9 +59,9 @@ var xDatalistForeach func(**Data, uintptr, uintptr) | |||
| 59 | 59 | // @func can make changes to @datalist, but the iteration will not | |
| 60 | 60 | // reflect changes made during the g_datalist_foreach() call, other | |
| 61 | 61 | // than skipping over elements that are removed. | |
| 62 | - | func DatalistForeach(DatalistVar **Data, FuncVar DataForeachFunc, UserDataVar uintptr) { | |
| 62 | + | func DatalistForeach(DatalistVar **Data, FuncVar *DataForeachFunc, UserDataVar uintptr) { | |
| 63 | 63 | ||
| 64 | - | xDatalistForeach(DatalistVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 64 | + | xDatalistForeach(DatalistVar, NewCallback(FuncVar), UserDataVar) | |
| 65 | 65 | ||
| 66 | 66 | } | |
| 67 | 67 | ||
| @@ -100,9 +100,9 @@ var xDatalistIdDupData func(**Data, Quark, uintptr, uintptr) uintptr | |||
| 100 | 100 | // | |
| 101 | 101 | // This function can be useful to avoid races when multiple | |
| 102 | 102 | // threads are using the same datalist and the same key. | |
| 103 | - | func DatalistIdDupData(DatalistVar **Data, KeyIdVar Quark, DupFuncVar DuplicateFunc, UserDataVar uintptr) uintptr { | |
| 103 | + | func DatalistIdDupData(DatalistVar **Data, KeyIdVar Quark, DupFuncVar *DuplicateFunc, UserDataVar uintptr) uintptr { | |
| 104 | 104 | ||
| 105 | - | cret := xDatalistIdDupData(DatalistVar, KeyIdVar, purego.NewCallback(DupFuncVar), UserDataVar) | |
| 105 | + | cret := xDatalistIdDupData(DatalistVar, KeyIdVar, NewCallback(DupFuncVar), UserDataVar) | |
| 106 | 106 | return cret | |
| 107 | 107 | } | |
| 108 | 108 | ||
| @@ -140,9 +140,9 @@ var xDatalistIdReplaceData func(**Data, Quark, uintptr, uintptr, uintptr, uintpt | |||
| 140 | 140 | // Its up to the caller to free this as they wish, which may | |
| 141 | 141 | // or may not include using @old_destroy as sometimes replacement | |
| 142 | 142 | // should not destroy the object in the normal way. | |
| 143 | - | func DatalistIdReplaceData(DatalistVar **Data, KeyIdVar Quark, OldvalVar uintptr, NewvalVar uintptr, DestroyVar DestroyNotify, OldDestroyVar DestroyNotify) bool { | |
| 143 | + | func DatalistIdReplaceData(DatalistVar **Data, KeyIdVar Quark, OldvalVar uintptr, NewvalVar uintptr, DestroyVar *DestroyNotify, OldDestroyVar *DestroyNotify) bool { | |
| 144 | 144 | ||
| 145 | - | cret := xDatalistIdReplaceData(DatalistVar, KeyIdVar, OldvalVar, NewvalVar, purego.NewCallback(DestroyVar), purego.NewCallback(OldDestroyVar)) | |
| 145 | + | cret := xDatalistIdReplaceData(DatalistVar, KeyIdVar, OldvalVar, NewvalVar, NewCallback(DestroyVar), NewCallback(OldDestroyVar)) | |
| 146 | 146 | return cret | |
| 147 | 147 | } | |
| 148 | 148 | ||
| @@ -152,9 +152,9 @@ var xDatalistIdSetDataFull func(**Data, Quark, uintptr, uintptr) | |||
| 152 | 152 | // function to be called when the element is removed from the datalist. | |
| 153 | 153 | // Any previous data with the same key is removed, and its destroy | |
| 154 | 154 | // function is called. | |
| 155 | - | func DatalistIdSetDataFull(DatalistVar **Data, KeyIdVar Quark, DataVar uintptr, DestroyFuncVar DestroyNotify) { | |
| 155 | + | func DatalistIdSetDataFull(DatalistVar **Data, KeyIdVar Quark, DataVar uintptr, DestroyFuncVar *DestroyNotify) { | |
| 156 | 156 | ||
| 157 | - | xDatalistIdSetDataFull(DatalistVar, KeyIdVar, DataVar, purego.NewCallback(DestroyFuncVar)) | |
| 157 | + | xDatalistIdSetDataFull(DatalistVar, KeyIdVar, DataVar, NewCallback(DestroyFuncVar)) | |
| 158 | 158 | ||
| 159 | 159 | } | |
| 160 | 160 | ||
| @@ -211,9 +211,9 @@ var xDatasetForeach func(uintptr, uintptr, uintptr) | |||
| 211 | 211 | // @func can make changes to the dataset, but the iteration will not | |
| 212 | 212 | // reflect changes made during the g_dataset_foreach() call, other | |
| 213 | 213 | // than skipping over elements that are removed. | |
| 214 | - | func DatasetForeach(DatasetLocationVar uintptr, FuncVar DataForeachFunc, UserDataVar uintptr) { | |
| 214 | + | func DatasetForeach(DatasetLocationVar uintptr, FuncVar *DataForeachFunc, UserDataVar uintptr) { | |
| 215 | 215 | ||
| 216 | - | xDatasetForeach(DatasetLocationVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 216 | + | xDatasetForeach(DatasetLocationVar, NewCallback(FuncVar), UserDataVar) | |
| 217 | 217 | ||
| 218 | 218 | } | |
| 219 | 219 | ||
| @@ -242,9 +242,9 @@ var xDatasetIdSetDataFull func(uintptr, Quark, uintptr, uintptr) | |||
| 242 | 242 | // the function to call when the data element is destroyed. Any | |
| 243 | 243 | // previous data with the same key is removed, and its destroy function | |
| 244 | 244 | // is called. | |
| 245 | - | func DatasetIdSetDataFull(DatasetLocationVar uintptr, KeyIdVar Quark, DataVar uintptr, DestroyFuncVar DestroyNotify) { | |
| 245 | + | func DatasetIdSetDataFull(DatasetLocationVar uintptr, KeyIdVar Quark, DataVar uintptr, DestroyFuncVar *DestroyNotify) { | |
| 246 | 246 | ||
| 247 | - | xDatasetIdSetDataFull(DatasetLocationVar, KeyIdVar, DataVar, purego.NewCallback(DestroyFuncVar)) | |
| 247 | + | xDatasetIdSetDataFull(DatasetLocationVar, KeyIdVar, DataVar, NewCallback(DestroyFuncVar)) | |
| 248 | 248 | ||
| 249 | 249 | } | |
| 250 | 250 | ||
M v4/glib/ghook.go +4 -4
| @@ -128,9 +128,9 @@ func (x *HookList) InvokeCheck(MayRecurseVar bool) { | |||
| 128 | 128 | var xHookListMarshal func(uintptr, bool, uintptr, uintptr) | |
| 129 | 129 | ||
| 130 | 130 | // Calls a function on each valid #GHook. | |
| 131 | - | func (x *HookList) Marshal(MayRecurseVar bool, MarshallerVar HookMarshaller, MarshalDataVar uintptr) { | |
| 131 | + | func (x *HookList) Marshal(MayRecurseVar bool, MarshallerVar *HookMarshaller, MarshalDataVar uintptr) { | |
| 132 | 132 | ||
| 133 | - | xHookListMarshal(x.GoPointer(), MayRecurseVar, purego.NewCallback(MarshallerVar), MarshalDataVar) | |
| 133 | + | xHookListMarshal(x.GoPointer(), MayRecurseVar, NewCallback(MarshallerVar), MarshalDataVar) | |
| 134 | 134 | ||
| 135 | 135 | } | |
| 136 | 136 | ||
| @@ -138,9 +138,9 @@ var xHookListMarshalCheck func(uintptr, bool, uintptr, uintptr) | |||
| 138 | 138 | ||
| 139 | 139 | // Calls a function on each valid #GHook and destroys it if the | |
| 140 | 140 | // function returns %FALSE. | |
| 141 | - | func (x *HookList) MarshalCheck(MayRecurseVar bool, MarshallerVar HookCheckMarshaller, MarshalDataVar uintptr) { | |
| 141 | + | func (x *HookList) MarshalCheck(MayRecurseVar bool, MarshallerVar *HookCheckMarshaller, MarshalDataVar uintptr) { | |
| 142 | 142 | ||
| 143 | - | xHookListMarshalCheck(x.GoPointer(), MayRecurseVar, purego.NewCallback(MarshallerVar), MarshalDataVar) | |
| 143 | + | xHookListMarshalCheck(x.GoPointer(), MayRecurseVar, NewCallback(MarshallerVar), MarshalDataVar) | |
| 144 | 144 | ||
| 145 | 145 | } | |
| 146 | 146 | ||
M v4/glib/giochannel.go +4 -4
| @@ -670,9 +670,9 @@ var xIoAddWatch func(*IOChannel, IOCondition, uintptr, uintptr) uint | |||
| 670 | 670 | ||
| 671 | 671 | // Adds the #GIOChannel into the default main loop context | |
| 672 | 672 | // with the default priority. | |
| 673 | - | func IoAddWatch(ChannelVar *IOChannel, ConditionVar IOCondition, FuncVar IOFunc, UserDataVar uintptr) uint { | |
| 673 | + | func IoAddWatch(ChannelVar *IOChannel, ConditionVar IOCondition, FuncVar *IOFunc, UserDataVar uintptr) uint { | |
| 674 | 674 | ||
| 675 | - | cret := xIoAddWatch(ChannelVar, ConditionVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 675 | + | cret := xIoAddWatch(ChannelVar, ConditionVar, NewCallback(FuncVar), UserDataVar) | |
| 676 | 676 | return cret | |
| 677 | 677 | } | |
| 678 | 678 | ||
| @@ -684,9 +684,9 @@ var xIoAddWatchFull func(*IOChannel, int, IOCondition, uintptr, uintptr, uintptr | |||
| 684 | 684 | // This internally creates a main loop source using g_io_create_watch() | |
| 685 | 685 | // and attaches it to the main loop context with g_source_attach(). | |
| 686 | 686 | // You can do these steps manually if you need greater control. | |
| 687 | - | func IoAddWatchFull(ChannelVar *IOChannel, PriorityVar int, ConditionVar IOCondition, FuncVar IOFunc, UserDataVar uintptr, NotifyVar DestroyNotify) uint { | |
| 687 | + | func IoAddWatchFull(ChannelVar *IOChannel, PriorityVar int, ConditionVar IOCondition, FuncVar *IOFunc, UserDataVar uintptr, NotifyVar *DestroyNotify) uint { | |
| 688 | 688 | ||
| 689 | - | cret := xIoAddWatchFull(ChannelVar, PriorityVar, ConditionVar, purego.NewCallback(FuncVar), UserDataVar, purego.NewCallback(NotifyVar)) | |
| 689 | + | cret := xIoAddWatchFull(ChannelVar, PriorityVar, ConditionVar, NewCallback(FuncVar), UserDataVar, NewCallback(NotifyVar)) | |
| 690 | 690 | return cret | |
| 691 | 691 | } | |
| 692 | 692 | ||
M v4/glib/glib-unix.go +8 -8
| @@ -25,9 +25,9 @@ var xUnixFdAdd func(int, IOCondition, uintptr, uintptr) uint | |||
| 25 | 25 | // to cancel the watch at any time that it exists. | |
| 26 | 26 | // | |
| 27 | 27 | // The source will never close the fd -- you must do it yourself. | |
| 28 | - | func UnixFdAdd(FdVar int, ConditionVar IOCondition, FunctionVar UnixFDSourceFunc, UserDataVar uintptr) uint { | |
| 28 | + | func UnixFdAdd(FdVar int, ConditionVar IOCondition, FunctionVar *UnixFDSourceFunc, UserDataVar uintptr) uint { | |
| 29 | 29 | ||
| 30 | - | cret := xUnixFdAdd(FdVar, ConditionVar, purego.NewCallback(FunctionVar), UserDataVar) | |
| 30 | + | cret := xUnixFdAdd(FdVar, ConditionVar, NewCallback(FunctionVar), UserDataVar) | |
| 31 | 31 | return cret | |
| 32 | 32 | } | |
| 33 | 33 | ||
| @@ -39,9 +39,9 @@ var xUnixFdAddFull func(int, int, IOCondition, uintptr, uintptr, uintptr) uint | |||
| 39 | 39 | // This is the same as g_unix_fd_add(), except that it allows you to | |
| 40 | 40 | // specify a non-default priority and a provide a #GDestroyNotify for | |
| 41 | 41 | // @user_data. | |
| 42 | - | func UnixFdAddFull(PriorityVar int, FdVar int, ConditionVar IOCondition, FunctionVar UnixFDSourceFunc, UserDataVar uintptr, NotifyVar DestroyNotify) uint { | |
| 42 | + | func UnixFdAddFull(PriorityVar int, FdVar int, ConditionVar IOCondition, FunctionVar *UnixFDSourceFunc, UserDataVar uintptr, NotifyVar *DestroyNotify) uint { | |
| 43 | 43 | ||
| 44 | - | cret := xUnixFdAddFull(PriorityVar, FdVar, ConditionVar, purego.NewCallback(FunctionVar), UserDataVar, purego.NewCallback(NotifyVar)) | |
| 44 | + | cret := xUnixFdAddFull(PriorityVar, FdVar, ConditionVar, NewCallback(FunctionVar), UserDataVar, NewCallback(NotifyVar)) | |
| 45 | 45 | return cret | |
| 46 | 46 | } | |
| 47 | 47 | ||
| @@ -123,9 +123,9 @@ var xUnixSignalAdd func(int, uintptr, uintptr) uint | |||
| 123 | 123 | // A convenience function for g_unix_signal_source_new(), which | |
| 124 | 124 | // attaches to the default #GMainContext. You can remove the watch | |
| 125 | 125 | // using g_source_remove(). | |
| 126 | - | func UnixSignalAdd(SignumVar int, HandlerVar SourceFunc, UserDataVar uintptr) uint { | |
| 126 | + | func UnixSignalAdd(SignumVar int, HandlerVar *SourceFunc, UserDataVar uintptr) uint { | |
| 127 | 127 | ||
| 128 | - | cret := xUnixSignalAdd(SignumVar, purego.NewCallback(HandlerVar), UserDataVar) | |
| 128 | + | cret := xUnixSignalAdd(SignumVar, NewCallback(HandlerVar), UserDataVar) | |
| 129 | 129 | return cret | |
| 130 | 130 | } | |
| 131 | 131 | ||
| @@ -134,9 +134,9 @@ var xUnixSignalAddFull func(int, int, uintptr, uintptr, uintptr) uint | |||
| 134 | 134 | // A convenience function for g_unix_signal_source_new(), which | |
| 135 | 135 | // attaches to the default #GMainContext. You can remove the watch | |
| 136 | 136 | // using g_source_remove(). | |
| 137 | - | func UnixSignalAddFull(PriorityVar int, SignumVar int, HandlerVar SourceFunc, UserDataVar uintptr, NotifyVar DestroyNotify) uint { | |
| 137 | + | func UnixSignalAddFull(PriorityVar int, SignumVar int, HandlerVar *SourceFunc, UserDataVar uintptr, NotifyVar *DestroyNotify) uint { | |
| 138 | 138 | ||
| 139 | - | cret := xUnixSignalAddFull(PriorityVar, SignumVar, purego.NewCallback(HandlerVar), UserDataVar, purego.NewCallback(NotifyVar)) | |
| 139 | + | cret := xUnixSignalAddFull(PriorityVar, SignumVar, NewCallback(HandlerVar), UserDataVar, NewCallback(NotifyVar)) | |
| 140 | 140 | return cret | |
| 141 | 141 | } | |
| 142 | 142 | ||
M v4/glib/glist.go +2 -2
| @@ -26,9 +26,9 @@ var xClearList func(**List, uintptr) | |||
| 26 | 26 | // Clears a pointer to a #GList, freeing it and, optionally, freeing its elements using @destroy. | |
| 27 | 27 | // | |
| 28 | 28 | // @list_ptr must be a valid pointer. If @list_ptr points to a null #GList, this does nothing. | |
| 29 | - | func ClearList(ListPtrVar **List, DestroyVar DestroyNotify) { | |
| 29 | + | func ClearList(ListPtrVar **List, DestroyVar *DestroyNotify) { | |
| 30 | 30 | ||
| 31 | - | xClearList(ListPtrVar, purego.NewCallback(DestroyVar)) | |
| 31 | + | xClearList(ListPtrVar, NewCallback(DestroyVar)) | |
| 32 | 32 | ||
| 33 | 33 | } | |
| 34 | 34 | ||
M v4/glib/gmain.go +28 -28
| @@ -196,9 +196,9 @@ var xMainContextInvoke func(uintptr, uintptr, uintptr) | |||
| 196 | 196 | // Note that, as with normal idle functions, @function should probably | |
| 197 | 197 | // return %FALSE. If it returns %TRUE, it will be continuously run in a | |
| 198 | 198 | // loop (and may prevent this call from returning). | |
| 199 | - | func (x *MainContext) Invoke(FunctionVar SourceFunc, DataVar uintptr) { | |
| 199 | + | func (x *MainContext) Invoke(FunctionVar *SourceFunc, DataVar uintptr) { | |
| 200 | 200 | ||
| 201 | - | xMainContextInvoke(x.GoPointer(), purego.NewCallback(FunctionVar), DataVar) | |
| 201 | + | xMainContextInvoke(x.GoPointer(), NewCallback(FunctionVar), DataVar) | |
| 202 | 202 | ||
| 203 | 203 | } | |
| 204 | 204 | ||
| @@ -213,9 +213,9 @@ var xMainContextInvokeFull func(uintptr, int, uintptr, uintptr, uintptr) | |||
| 213 | 213 | // | |
| 214 | 214 | // @notify should not assume that it is called from any particular | |
| 215 | 215 | // thread or with any particular context acquired. | |
| 216 | - | func (x *MainContext) InvokeFull(PriorityVar int, FunctionVar SourceFunc, DataVar uintptr, NotifyVar DestroyNotify) { | |
| 216 | + | func (x *MainContext) InvokeFull(PriorityVar int, FunctionVar *SourceFunc, DataVar uintptr, NotifyVar *DestroyNotify) { | |
| 217 | 217 | ||
| 218 | - | xMainContextInvokeFull(x.GoPointer(), PriorityVar, purego.NewCallback(FunctionVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 218 | + | xMainContextInvokeFull(x.GoPointer(), PriorityVar, NewCallback(FunctionVar), DataVar, NewCallback(NotifyVar)) | |
| 219 | 219 | ||
| 220 | 220 | } | |
| 221 | 221 | ||
| @@ -384,9 +384,9 @@ var xMainContextSetPollFunc func(uintptr, uintptr) | |||
| 384 | 384 | // | |
| 385 | 385 | // This function could possibly be used to integrate the GLib event | |
| 386 | 386 | // loop with an external event loop. | |
| 387 | - | func (x *MainContext) SetPollFunc(FuncVar PollFunc) { | |
| 387 | + | func (x *MainContext) SetPollFunc(FuncVar *PollFunc) { | |
| 388 | 388 | ||
| 389 | - | xMainContextSetPollFunc(x.GoPointer(), purego.NewCallback(FuncVar)) | |
| 389 | + | xMainContextSetPollFunc(x.GoPointer(), NewCallback(FuncVar)) | |
| 390 | 390 | ||
| 391 | 391 | } | |
| 392 | 392 | ||
| @@ -988,9 +988,9 @@ var xSourceSetCallback func(uintptr, uintptr, uintptr, uintptr) | |||
| 988 | 988 | // | |
| 989 | 989 | // Note that g_source_destroy() for a currently attached source has the effect | |
| 990 | 990 | // of also unsetting the callback. | |
| 991 | - | func (x *Source) SetCallback(FuncVar SourceFunc, DataVar uintptr, NotifyVar DestroyNotify) { | |
| 991 | + | func (x *Source) SetCallback(FuncVar *SourceFunc, DataVar uintptr, NotifyVar *DestroyNotify) { | |
| 992 | 992 | ||
| 993 | - | xSourceSetCallback(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 993 | + | xSourceSetCallback(x.GoPointer(), NewCallback(FuncVar), DataVar, NewCallback(NotifyVar)) | |
| 994 | 994 | ||
| 995 | 995 | } | |
| 996 | 996 | ||
| @@ -1042,9 +1042,9 @@ var xSourceSetDisposeFunction func(uintptr, uintptr) | |||
| 1042 | 1042 | // @source is already partially freed and not valid anymore. | |
| 1043 | 1043 | // | |
| 1044 | 1044 | // This should only ever be called from #GSource implementations. | |
| 1045 | - | func (x *Source) SetDisposeFunction(DisposeVar SourceDisposeFunc) { | |
| 1045 | + | func (x *Source) SetDisposeFunction(DisposeVar *SourceDisposeFunc) { | |
| 1046 | 1046 | ||
| 1047 | - | xSourceSetDisposeFunction(x.GoPointer(), purego.NewCallback(DisposeVar)) | |
| 1047 | + | xSourceSetDisposeFunction(x.GoPointer(), NewCallback(DisposeVar)) | |
| 1048 | 1048 | ||
| 1049 | 1049 | } | |
| 1050 | 1050 | ||
| @@ -1273,9 +1273,9 @@ var xChildWatchAdd func(Pid, uintptr, uintptr) uint | |||
| 1273 | 1273 | // g_child_watch_source_new() and attaches it to the main loop context | |
| 1274 | 1274 | // using g_source_attach(). You can do these steps manually if you | |
| 1275 | 1275 | // need greater control. | |
| 1276 | - | func ChildWatchAdd(PidVar Pid, FunctionVar ChildWatchFunc, DataVar uintptr) uint { | |
| 1276 | + | func ChildWatchAdd(PidVar Pid, FunctionVar *ChildWatchFunc, DataVar uintptr) uint { | |
| 1277 | 1277 | ||
| 1278 | - | cret := xChildWatchAdd(PidVar, purego.NewCallback(FunctionVar), DataVar) | |
| 1278 | + | cret := xChildWatchAdd(PidVar, NewCallback(FunctionVar), DataVar) | |
| 1279 | 1279 | return cret | |
| 1280 | 1280 | } | |
| 1281 | 1281 | ||
| @@ -1305,9 +1305,9 @@ var xChildWatchAddFull func(int, Pid, uintptr, uintptr, uintptr) uint | |||
| 1305 | 1305 | // g_child_watch_source_new() and attaches it to the main loop context | |
| 1306 | 1306 | // using g_source_attach(). You can do these steps manually if you | |
| 1307 | 1307 | // need greater control. | |
| 1308 | - | func ChildWatchAddFull(PriorityVar int, PidVar Pid, FunctionVar ChildWatchFunc, DataVar uintptr, NotifyVar DestroyNotify) uint { | |
| 1308 | + | func ChildWatchAddFull(PriorityVar int, PidVar Pid, FunctionVar *ChildWatchFunc, DataVar uintptr, NotifyVar *DestroyNotify) uint { | |
| 1309 | 1309 | ||
| 1310 | - | cret := xChildWatchAddFull(PriorityVar, PidVar, purego.NewCallback(FunctionVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 1310 | + | cret := xChildWatchAddFull(PriorityVar, PidVar, NewCallback(FunctionVar), DataVar, NewCallback(NotifyVar)) | |
| 1311 | 1311 | return cret | |
| 1312 | 1312 | } | |
| 1313 | 1313 | ||
| @@ -1363,9 +1363,9 @@ var xClearHandleId func(uint, uintptr) | |||
| 1363 | 1363 | // | |
| 1364 | 1364 | // A macro is also included that allows this function to be used without | |
| 1365 | 1365 | // pointer casts. | |
| 1366 | - | func ClearHandleId(TagPtrVar uint, ClearFuncVar ClearHandleFunc) { | |
| 1366 | + | func ClearHandleId(TagPtrVar uint, ClearFuncVar *ClearHandleFunc) { | |
| 1367 | 1367 | ||
| 1368 | - | xClearHandleId(TagPtrVar, purego.NewCallback(ClearFuncVar)) | |
| 1368 | + | xClearHandleId(TagPtrVar, NewCallback(ClearFuncVar)) | |
| 1369 | 1369 | ||
| 1370 | 1370 | } | |
| 1371 | 1371 | ||
| @@ -1431,9 +1431,9 @@ var xIdleAdd func(uintptr, uintptr) uint | |||
| 1431 | 1431 | // the callback will be invoked in whichever thread is running that main | |
| 1432 | 1432 | // context. You can do these steps manually if you need greater control or to | |
| 1433 | 1433 | // use a custom main context. | |
| 1434 | - | func IdleAdd(FunctionVar SourceFunc, DataVar uintptr) uint { | |
| 1434 | + | func IdleAdd(FunctionVar *SourceFunc, DataVar uintptr) uint { | |
| 1435 | 1435 | ||
| 1436 | - | cret := xIdleAdd(purego.NewCallback(FunctionVar), DataVar) | |
| 1436 | + | cret := xIdleAdd(NewCallback(FunctionVar), DataVar) | |
| 1437 | 1437 | return cret | |
| 1438 | 1438 | } | |
| 1439 | 1439 | ||
| @@ -1453,9 +1453,9 @@ var xIdleAddFull func(int, uintptr, uintptr, uintptr) uint | |||
| 1453 | 1453 | // the callback will be invoked in whichever thread is running that main | |
| 1454 | 1454 | // context. You can do these steps manually if you need greater control or to | |
| 1455 | 1455 | // use a custom main context. | |
| 1456 | - | func IdleAddFull(PriorityVar int, FunctionVar SourceFunc, DataVar uintptr, NotifyVar DestroyNotify) uint { | |
| 1456 | + | func IdleAddFull(PriorityVar int, FunctionVar *SourceFunc, DataVar uintptr, NotifyVar *DestroyNotify) uint { | |
| 1457 | 1457 | ||
| 1458 | - | cret := xIdleAddFull(PriorityVar, purego.NewCallback(FunctionVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 1458 | + | cret := xIdleAddFull(PriorityVar, NewCallback(FunctionVar), DataVar, NewCallback(NotifyVar)) | |
| 1459 | 1459 | return cret | |
| 1460 | 1460 | } | |
| 1461 | 1461 | ||
| @@ -1762,9 +1762,9 @@ var xTimeoutAdd func(uint, uintptr, uintptr) uint | |||
| 1762 | 1762 | // | |
| 1763 | 1763 | // The interval given is in terms of monotonic time, not wall clock | |
| 1764 | 1764 | // time. See g_get_monotonic_time(). | |
| 1765 | - | func TimeoutAdd(IntervalVar uint, FunctionVar SourceFunc, DataVar uintptr) uint { | |
| 1765 | + | func TimeoutAdd(IntervalVar uint, FunctionVar *SourceFunc, DataVar uintptr) uint { | |
| 1766 | 1766 | ||
| 1767 | - | cret := xTimeoutAdd(IntervalVar, purego.NewCallback(FunctionVar), DataVar) | |
| 1767 | + | cret := xTimeoutAdd(IntervalVar, NewCallback(FunctionVar), DataVar) | |
| 1768 | 1768 | return cret | |
| 1769 | 1769 | } | |
| 1770 | 1770 | ||
| @@ -1794,9 +1794,9 @@ var xTimeoutAddFull func(int, uint, uintptr, uintptr, uintptr) uint | |||
| 1794 | 1794 | // | |
| 1795 | 1795 | // The interval given is in terms of monotonic time, not wall clock time. | |
| 1796 | 1796 | // See g_get_monotonic_time(). | |
| 1797 | - | func TimeoutAddFull(PriorityVar int, IntervalVar uint, FunctionVar SourceFunc, DataVar uintptr, NotifyVar DestroyNotify) uint { | |
| 1797 | + | func TimeoutAddFull(PriorityVar int, IntervalVar uint, FunctionVar *SourceFunc, DataVar uintptr, NotifyVar *DestroyNotify) uint { | |
| 1798 | 1798 | ||
| 1799 | - | cret := xTimeoutAddFull(PriorityVar, IntervalVar, purego.NewCallback(FunctionVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 1799 | + | cret := xTimeoutAddFull(PriorityVar, IntervalVar, NewCallback(FunctionVar), DataVar, NewCallback(NotifyVar)) | |
| 1800 | 1800 | return cret | |
| 1801 | 1801 | } | |
| 1802 | 1802 | ||
| @@ -1825,9 +1825,9 @@ var xTimeoutAddSeconds func(uint, uintptr, uintptr) uint | |||
| 1825 | 1825 | // | |
| 1826 | 1826 | // The interval given is in terms of monotonic time, not wall clock | |
| 1827 | 1827 | // time. See g_get_monotonic_time(). | |
| 1828 | - | func TimeoutAddSeconds(IntervalVar uint, FunctionVar SourceFunc, DataVar uintptr) uint { | |
| 1828 | + | func TimeoutAddSeconds(IntervalVar uint, FunctionVar *SourceFunc, DataVar uintptr) uint { | |
| 1829 | 1829 | ||
| 1830 | - | cret := xTimeoutAddSeconds(IntervalVar, purego.NewCallback(FunctionVar), DataVar) | |
| 1830 | + | cret := xTimeoutAddSeconds(IntervalVar, NewCallback(FunctionVar), DataVar) | |
| 1831 | 1831 | return cret | |
| 1832 | 1832 | } | |
| 1833 | 1833 | ||
| @@ -1872,9 +1872,9 @@ var xTimeoutAddSecondsFull func(int, uint, uintptr, uintptr, uintptr) uint | |||
| 1872 | 1872 | // | |
| 1873 | 1873 | // The interval given is in terms of monotonic time, not wall clock | |
| 1874 | 1874 | // time. See g_get_monotonic_time(). | |
| 1875 | - | func TimeoutAddSecondsFull(PriorityVar int, IntervalVar uint, FunctionVar SourceFunc, DataVar uintptr, NotifyVar DestroyNotify) uint { | |
| 1875 | + | func TimeoutAddSecondsFull(PriorityVar int, IntervalVar uint, FunctionVar *SourceFunc, DataVar uintptr, NotifyVar *DestroyNotify) uint { | |
| 1876 | 1876 | ||
| 1877 | - | cret := xTimeoutAddSecondsFull(PriorityVar, IntervalVar, purego.NewCallback(FunctionVar), DataVar, purego.NewCallback(NotifyVar)) | |
| 1877 | + | cret := xTimeoutAddSecondsFull(PriorityVar, IntervalVar, NewCallback(FunctionVar), DataVar, NewCallback(NotifyVar)) | |
| 1878 | 1878 | return cret | |
| 1879 | 1879 | } | |
| 1880 | 1880 | ||
M v4/glib/gmarkup.go +2 -2
| @@ -27,9 +27,9 @@ var xNewMarkupParseContext func(*MarkupParser, MarkupParseFlags, uintptr, uintpt | |||
| 27 | 27 | // a context, as long as no errors occur; once an error occurs, | |
| 28 | 28 | // the parse context can't continue to parse text (you have to | |
| 29 | 29 | // free it and create a new parse context). | |
| 30 | - | func NewMarkupParseContext(ParserVar *MarkupParser, FlagsVar MarkupParseFlags, UserDataVar uintptr, UserDataDnotifyVar DestroyNotify) *MarkupParseContext { | |
| 30 | + | func NewMarkupParseContext(ParserVar *MarkupParser, FlagsVar MarkupParseFlags, UserDataVar uintptr, UserDataDnotifyVar *DestroyNotify) *MarkupParseContext { | |
| 31 | 31 | ||
| 32 | - | cret := xNewMarkupParseContext(ParserVar, FlagsVar, UserDataVar, purego.NewCallback(UserDataDnotifyVar)) | |
| 32 | + | cret := xNewMarkupParseContext(ParserVar, FlagsVar, UserDataVar, NewCallback(UserDataDnotifyVar)) | |
| 33 | 33 | return cret | |
| 34 | 34 | } | |
| 35 | 35 | ||
M v4/glib/gmem.go +2 -2
| @@ -70,9 +70,9 @@ var xClearPointer func(uintptr, uintptr) | |||
| 70 | 70 | // compatible with being called as `GDestroyNotify` using the standard calling | |
| 71 | 71 | // convention for the platform that GLib was compiled for; otherwise the program | |
| 72 | 72 | // will experience undefined behaviour. | |
| 73 | - | func ClearPointer(PpVar uintptr, DestroyVar DestroyNotify) { | |
| 73 | + | func ClearPointer(PpVar uintptr, DestroyVar *DestroyNotify) { | |
| 74 | 74 | ||
| 75 | - | xClearPointer(PpVar, purego.NewCallback(DestroyVar)) | |
| 75 | + | xClearPointer(PpVar, NewCallback(DestroyVar)) | |
| 76 | 76 | ||
| 77 | 77 | } | |
| 78 | 78 | ||
M v4/glib/gmessages.go +12 -12
| @@ -283,9 +283,9 @@ var xLogSetDefaultHandler func(uintptr, uintptr) uintptr | |||
| 283 | 283 | // | |
| 284 | 284 | // This has no effect if structured logging is enabled; see | |
| 285 | 285 | // [Using Structured Logging][using-structured-logging]. | |
| 286 | - | func LogSetDefaultHandler(LogFuncVar LogFunc, UserDataVar uintptr) uintptr { | |
| 286 | + | func LogSetDefaultHandler(LogFuncVar *LogFunc, UserDataVar uintptr) uintptr { | |
| 287 | 287 | ||
| 288 | - | cret := xLogSetDefaultHandler(purego.NewCallback(LogFuncVar), UserDataVar) | |
| 288 | + | cret := xLogSetDefaultHandler(NewCallback(LogFuncVar), UserDataVar) | |
| 289 | 289 | return cret | |
| 290 | 290 | } | |
| 291 | 291 | ||
| @@ -352,9 +352,9 @@ var xLogSetHandler func(string, LogLevelFlags, uintptr, uintptr) uint | |||
| 352 | 352 | // | G_LOG_FLAG_RECURSION, my_log_handler, NULL); | |
| 353 | 353 | // | |
| 354 | 354 | // ]| | |
| 355 | - | func LogSetHandler(LogDomainVar string, LogLevelsVar LogLevelFlags, LogFuncVar LogFunc, UserDataVar uintptr) uint { | |
| 355 | + | func LogSetHandler(LogDomainVar string, LogLevelsVar LogLevelFlags, LogFuncVar *LogFunc, UserDataVar uintptr) uint { | |
| 356 | 356 | ||
| 357 | - | cret := xLogSetHandler(LogDomainVar, LogLevelsVar, purego.NewCallback(LogFuncVar), UserDataVar) | |
| 357 | + | cret := xLogSetHandler(LogDomainVar, LogLevelsVar, NewCallback(LogFuncVar), UserDataVar) | |
| 358 | 358 | return cret | |
| 359 | 359 | } | |
| 360 | 360 | ||
| @@ -364,9 +364,9 @@ var xLogSetHandlerFull func(string, LogLevelFlags, uintptr, uintptr, uintptr) ui | |||
| 364 | 364 | // | |
| 365 | 365 | // This has no effect if structured logging is enabled; see | |
| 366 | 366 | // [Using Structured Logging][using-structured-logging]. | |
| 367 | - | func LogSetHandlerFull(LogDomainVar string, LogLevelsVar LogLevelFlags, LogFuncVar LogFunc, UserDataVar uintptr, DestroyVar DestroyNotify) uint { | |
| 367 | + | func LogSetHandlerFull(LogDomainVar string, LogLevelsVar LogLevelFlags, LogFuncVar *LogFunc, UserDataVar uintptr, DestroyVar *DestroyNotify) uint { | |
| 368 | 368 | ||
| 369 | - | cret := xLogSetHandlerFull(LogDomainVar, LogLevelsVar, purego.NewCallback(LogFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 369 | + | cret := xLogSetHandlerFull(LogDomainVar, LogLevelsVar, NewCallback(LogFuncVar), UserDataVar, NewCallback(DestroyVar)) | |
| 370 | 370 | return cret | |
| 371 | 371 | } | |
| 372 | 372 | ||
| @@ -381,9 +381,9 @@ var xLogSetWriterFunc func(uintptr, uintptr, uintptr) | |||
| 381 | 381 | // log messages are formatted and outputted. | |
| 382 | 382 | // | |
| 383 | 383 | // There can only be one writer function. It is an error to set more than one. | |
| 384 | - | func LogSetWriterFunc(FuncVar LogWriterFunc, UserDataVar uintptr, UserDataFreeVar DestroyNotify) { | |
| 384 | + | func LogSetWriterFunc(FuncVar *LogWriterFunc, UserDataVar uintptr, UserDataFreeVar *DestroyNotify) { | |
| 385 | 385 | ||
| 386 | - | xLogSetWriterFunc(purego.NewCallback(FuncVar), UserDataVar, purego.NewCallback(UserDataFreeVar)) | |
| 386 | + | xLogSetWriterFunc(NewCallback(FuncVar), UserDataVar, NewCallback(UserDataFreeVar)) | |
| 387 | 387 | ||
| 388 | 388 | } | |
| 389 | 389 | ||
| @@ -784,9 +784,9 @@ var xSetPrintHandler func(uintptr) uintptr | |||
| 784 | 784 | // the message to stdout. By providing your own handler | |
| 785 | 785 | // you can redirect the output, to a GTK+ widget or a | |
| 786 | 786 | // log file for example. | |
| 787 | - | func SetPrintHandler(FuncVar PrintFunc) uintptr { | |
| 787 | + | func SetPrintHandler(FuncVar *PrintFunc) uintptr { | |
| 788 | 788 | ||
| 789 | - | cret := xSetPrintHandler(purego.NewCallback(FuncVar)) | |
| 789 | + | cret := xSetPrintHandler(NewCallback(FuncVar)) | |
| 790 | 790 | return cret | |
| 791 | 791 | } | |
| 792 | 792 | ||
| @@ -799,9 +799,9 @@ var xSetPrinterrHandler func(uintptr) uintptr | |||
| 799 | 799 | // message to stderr. By providing your own handler you can | |
| 800 | 800 | // redirect the output, to a GTK+ widget or a log file for | |
| 801 | 801 | // example. | |
| 802 | - | func SetPrinterrHandler(FuncVar PrintFunc) uintptr { | |
| 802 | + | func SetPrinterrHandler(FuncVar *PrintFunc) uintptr { | |
| 803 | 803 | ||
| 804 | - | cret := xSetPrinterrHandler(purego.NewCallback(FuncVar)) | |
| 804 | + | cret := xSetPrinterrHandler(NewCallback(FuncVar)) | |
| 805 | 805 | return cret | |
| 806 | 806 | } | |
| 807 | 807 | ||
M v4/glib/gnode.go +6 -6
| @@ -62,9 +62,9 @@ var xNodeChildrenForeach func(uintptr, TraverseFlags, uintptr, uintptr) | |||
| 62 | 62 | // Calls a function for each of the children of a #GNode. Note that it | |
| 63 | 63 | // doesn't descend beneath the child nodes. @func must not do anything | |
| 64 | 64 | // that would modify the structure of the tree. | |
| 65 | - | func (x *Node) ChildrenForeach(FlagsVar TraverseFlags, FuncVar NodeForeachFunc, DataVar uintptr) { | |
| 65 | + | func (x *Node) ChildrenForeach(FlagsVar TraverseFlags, FuncVar *NodeForeachFunc, DataVar uintptr) { | |
| 66 | 66 | ||
| 67 | - | xNodeChildrenForeach(x.GoPointer(), FlagsVar, purego.NewCallback(FuncVar), DataVar) | |
| 67 | + | xNodeChildrenForeach(x.GoPointer(), FlagsVar, NewCallback(FuncVar), DataVar) | |
| 68 | 68 | ||
| 69 | 69 | } | |
| 70 | 70 | ||
| @@ -81,9 +81,9 @@ func (x *Node) Copy() *Node { | |||
| 81 | 81 | var xNodeCopyDeep func(uintptr, uintptr, uintptr) *Node | |
| 82 | 82 | ||
| 83 | 83 | // Recursively copies a #GNode and its data. | |
| 84 | - | func (x *Node) CopyDeep(CopyFuncVar CopyFunc, DataVar uintptr) *Node { | |
| 84 | + | func (x *Node) CopyDeep(CopyFuncVar *CopyFunc, DataVar uintptr) *Node { | |
| 85 | 85 | ||
| 86 | - | cret := xNodeCopyDeep(x.GoPointer(), purego.NewCallback(CopyFuncVar), DataVar) | |
| 86 | + | cret := xNodeCopyDeep(x.GoPointer(), NewCallback(CopyFuncVar), DataVar) | |
| 87 | 87 | return cret | |
| 88 | 88 | } | |
| 89 | 89 | ||
| @@ -270,9 +270,9 @@ var xNodeTraverse func(uintptr, TraverseType, TraverseFlags, int, uintptr, uintp | |||
| 270 | 270 | // It calls the given function for each node visited. | |
| 271 | 271 | // The traversal can be halted at any point by returning %TRUE from @func. | |
| 272 | 272 | // @func must not do anything that would modify the structure of the tree. | |
| 273 | - | func (x *Node) Traverse(OrderVar TraverseType, FlagsVar TraverseFlags, MaxDepthVar int, FuncVar NodeTraverseFunc, DataVar uintptr) { | |
| 273 | + | func (x *Node) Traverse(OrderVar TraverseType, FlagsVar TraverseFlags, MaxDepthVar int, FuncVar *NodeTraverseFunc, DataVar uintptr) { | |
| 274 | 274 | ||
| 275 | - | xNodeTraverse(x.GoPointer(), OrderVar, FlagsVar, MaxDepthVar, purego.NewCallback(FuncVar), DataVar) | |
| 275 | + | xNodeTraverse(x.GoPointer(), OrderVar, FlagsVar, MaxDepthVar, NewCallback(FuncVar), DataVar) | |
| 276 | 276 | ||
| 277 | 277 | } | |
| 278 | 278 | ||
M v4/glib/goption.go +10 -10
| @@ -309,9 +309,9 @@ var xOptionContextSetTranslateFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 309 | 309 | // | |
| 310 | 310 | // If you are using gettext(), you only need to set the translation | |
| 311 | 311 | // domain, see g_option_context_set_translation_domain(). | |
| 312 | - | func (x *OptionContext) SetTranslateFunc(FuncVar TranslateFunc, DataVar uintptr, DestroyNotifyVar DestroyNotify) { | |
| 312 | + | func (x *OptionContext) SetTranslateFunc(FuncVar *TranslateFunc, DataVar uintptr, DestroyNotifyVar *DestroyNotify) { | |
| 313 | 313 | ||
| 314 | - | xOptionContextSetTranslateFunc(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyNotifyVar)) | |
| 314 | + | xOptionContextSetTranslateFunc(x.GoPointer(), NewCallback(FuncVar), DataVar, NewCallback(DestroyNotifyVar)) | |
| 315 | 315 | ||
| 316 | 316 | } | |
| 317 | 317 | ||
| @@ -365,9 +365,9 @@ func (x *OptionGroup) GoPointer() uintptr { | |||
| 365 | 365 | var xNewOptionGroup func(string, string, string, uintptr, uintptr) *OptionGroup | |
| 366 | 366 | ||
| 367 | 367 | // Creates a new #GOptionGroup. | |
| 368 | - | func NewOptionGroup(NameVar string, DescriptionVar string, HelpDescriptionVar string, UserDataVar uintptr, DestroyVar DestroyNotify) *OptionGroup { | |
| 368 | + | func NewOptionGroup(NameVar string, DescriptionVar string, HelpDescriptionVar string, UserDataVar uintptr, DestroyVar *DestroyNotify) *OptionGroup { | |
| 369 | 369 | ||
| 370 | - | cret := xNewOptionGroup(NameVar, DescriptionVar, HelpDescriptionVar, UserDataVar, purego.NewCallback(DestroyVar)) | |
| 370 | + | cret := xNewOptionGroup(NameVar, DescriptionVar, HelpDescriptionVar, UserDataVar, NewCallback(DestroyVar)) | |
| 371 | 371 | return cret | |
| 372 | 372 | } | |
| 373 | 373 | ||
| @@ -406,9 +406,9 @@ var xOptionGroupSetErrorHook func(uintptr, uintptr) | |||
| 406 | 406 | // | |
| 407 | 407 | // Note that the user data to be passed to @error_func can be | |
| 408 | 408 | // specified when constructing the group with g_option_group_new(). | |
| 409 | - | func (x *OptionGroup) SetErrorHook(ErrorFuncVar OptionErrorFunc) { | |
| 409 | + | func (x *OptionGroup) SetErrorHook(ErrorFuncVar *OptionErrorFunc) { | |
| 410 | 410 | ||
| 411 | - | xOptionGroupSetErrorHook(x.GoPointer(), purego.NewCallback(ErrorFuncVar)) | |
| 411 | + | xOptionGroupSetErrorHook(x.GoPointer(), NewCallback(ErrorFuncVar)) | |
| 412 | 412 | ||
| 413 | 413 | } | |
| 414 | 414 | ||
| @@ -421,9 +421,9 @@ var xOptionGroupSetParseHooks func(uintptr, uintptr, uintptr) | |||
| 421 | 421 | // Note that the user data to be passed to @pre_parse_func and | |
| 422 | 422 | // @post_parse_func can be specified when constructing the group | |
| 423 | 423 | // with g_option_group_new(). | |
| 424 | - | func (x *OptionGroup) SetParseHooks(PreParseFuncVar OptionParseFunc, PostParseFuncVar OptionParseFunc) { | |
| 424 | + | func (x *OptionGroup) SetParseHooks(PreParseFuncVar *OptionParseFunc, PostParseFuncVar *OptionParseFunc) { | |
| 425 | 425 | ||
| 426 | - | xOptionGroupSetParseHooks(x.GoPointer(), purego.NewCallback(PreParseFuncVar), purego.NewCallback(PostParseFuncVar)) | |
| 426 | + | xOptionGroupSetParseHooks(x.GoPointer(), NewCallback(PreParseFuncVar), NewCallback(PostParseFuncVar)) | |
| 427 | 427 | ||
| 428 | 428 | } | |
| 429 | 429 | ||
| @@ -435,9 +435,9 @@ var xOptionGroupSetTranslateFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 435 | 435 | // | |
| 436 | 436 | // If you are using gettext(), you only need to set the translation | |
| 437 | 437 | // domain, see g_option_group_set_translation_domain(). | |
| 438 | - | func (x *OptionGroup) SetTranslateFunc(FuncVar TranslateFunc, DataVar uintptr, DestroyNotifyVar DestroyNotify) { | |
| 438 | + | func (x *OptionGroup) SetTranslateFunc(FuncVar *TranslateFunc, DataVar uintptr, DestroyNotifyVar *DestroyNotify) { | |
| 439 | 439 | ||
| 440 | - | xOptionGroupSetTranslateFunc(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyNotifyVar)) | |
| 440 | + | xOptionGroupSetTranslateFunc(x.GoPointer(), NewCallback(FuncVar), DataVar, NewCallback(DestroyNotifyVar)) | |
| 441 | 441 | ||
| 442 | 442 | } | |
| 443 | 443 | ||
M v4/glib/gqsort.go +2 -2
| @@ -12,9 +12,9 @@ var xQsortWithData func(uintptr, int, uint, uintptr, uintptr) | |||
| 12 | 12 | // the comparison routine accepts a user data argument. | |
| 13 | 13 | // | |
| 14 | 14 | // This is guaranteed to be a stable sort since version 2.32. | |
| 15 | - | func QsortWithData(PbaseVar uintptr, TotalElemsVar int, SizeVar uint, CompareFuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 15 | + | func QsortWithData(PbaseVar uintptr, TotalElemsVar int, SizeVar uint, CompareFuncVar *CompareDataFunc, UserDataVar uintptr) { | |
| 16 | 16 | ||
| 17 | - | xQsortWithData(PbaseVar, TotalElemsVar, SizeVar, purego.NewCallback(CompareFuncVar), UserDataVar) | |
| 17 | + | xQsortWithData(PbaseVar, TotalElemsVar, SizeVar, NewCallback(CompareFuncVar), UserDataVar) | |
| 18 | 18 | ||
| 19 | 19 | } | |
| 20 | 20 | ||
M v4/glib/gqueue.go +12 -12
| @@ -36,9 +36,9 @@ var xQueueClearFull func(uintptr, uintptr) | |||
| 36 | 36 | ||
| 37 | 37 | // Convenience method, which frees all the memory used by a #GQueue, | |
| 38 | 38 | // and calls the provided @free_func on each item in the #GQueue. | |
| 39 | - | func (x *Queue) ClearFull(FreeFuncVar DestroyNotify) { | |
| 39 | + | func (x *Queue) ClearFull(FreeFuncVar *DestroyNotify) { | |
| 40 | 40 | ||
| 41 | - | xQueueClearFull(x.GoPointer(), purego.NewCallback(FreeFuncVar)) | |
| 41 | + | xQueueClearFull(x.GoPointer(), NewCallback(FreeFuncVar)) | |
| 42 | 42 | ||
| 43 | 43 | } | |
| 44 | 44 | ||
| @@ -80,9 +80,9 @@ var xQueueFindCustom func(uintptr, uintptr, uintptr) *List | |||
| 80 | 80 | // which should return 0 when the desired element is found. The function | |
| 81 | 81 | // takes two gconstpointer arguments, the #GQueue element's data as the | |
| 82 | 82 | // first argument and the given user data as the second argument. | |
| 83 | - | func (x *Queue) FindCustom(DataVar uintptr, FuncVar CompareFunc) *List { | |
| 83 | + | func (x *Queue) FindCustom(DataVar uintptr, FuncVar *CompareFunc) *List { | |
| 84 | 84 | ||
| 85 | - | cret := xQueueFindCustom(x.GoPointer(), DataVar, purego.NewCallback(FuncVar)) | |
| 85 | + | cret := xQueueFindCustom(x.GoPointer(), DataVar, NewCallback(FuncVar)) | |
| 86 | 86 | return cret | |
| 87 | 87 | } | |
| 88 | 88 | ||
| @@ -93,9 +93,9 @@ var xQueueForeach func(uintptr, uintptr, uintptr) | |||
| 93 | 93 | // | |
| 94 | 94 | // It is safe for @func to remove the element from @queue, but it must | |
| 95 | 95 | // not modify any part of the queue after that element. | |
| 96 | - | func (x *Queue) Foreach(FuncVar Func, UserDataVar uintptr) { | |
| 96 | + | func (x *Queue) Foreach(FuncVar *Func, UserDataVar uintptr) { | |
| 97 | 97 | ||
| 98 | - | xQueueForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 98 | + | xQueueForeach(x.GoPointer(), NewCallback(FuncVar), UserDataVar) | |
| 99 | 99 | ||
| 100 | 100 | } | |
| 101 | 101 | ||
| @@ -120,9 +120,9 @@ var xQueueFreeFull func(uintptr, uintptr) | |||
| 120 | 120 | // | |
| 121 | 121 | // @free_func should not modify the queue (eg, by removing the freed | |
| 122 | 122 | // element from it). | |
| 123 | - | func (x *Queue) FreeFull(FreeFuncVar DestroyNotify) { | |
| 123 | + | func (x *Queue) FreeFull(FreeFuncVar *DestroyNotify) { | |
| 124 | 124 | ||
| 125 | - | xQueueFreeFull(x.GoPointer(), purego.NewCallback(FreeFuncVar)) | |
| 125 | + | xQueueFreeFull(x.GoPointer(), NewCallback(FreeFuncVar)) | |
| 126 | 126 | ||
| 127 | 127 | } | |
| 128 | 128 | ||
| @@ -205,9 +205,9 @@ func (x *Queue) InsertBeforeLink(SiblingVar *List, LinkVar *List) { | |||
| 205 | 205 | var xQueueInsertSorted func(uintptr, uintptr, uintptr, uintptr) | |
| 206 | 206 | ||
| 207 | 207 | // Inserts @data into @queue using @func to determine the new position. | |
| 208 | - | func (x *Queue) InsertSorted(DataVar uintptr, FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 208 | + | func (x *Queue) InsertSorted(DataVar uintptr, FuncVar *CompareDataFunc, UserDataVar uintptr) { | |
| 209 | 209 | ||
| 210 | - | xQueueInsertSorted(x.GoPointer(), DataVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 210 | + | xQueueInsertSorted(x.GoPointer(), DataVar, NewCallback(FuncVar), UserDataVar) | |
| 211 | 211 | ||
| 212 | 212 | } | |
| 213 | 213 | ||
| @@ -421,9 +421,9 @@ func (x *Queue) Reverse() { | |||
| 421 | 421 | var xQueueSort func(uintptr, uintptr, uintptr) | |
| 422 | 422 | ||
| 423 | 423 | // Sorts @queue using @compare_func. | |
| 424 | - | func (x *Queue) Sort(CompareFuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 424 | + | func (x *Queue) Sort(CompareFuncVar *CompareDataFunc, UserDataVar uintptr) { | |
| 425 | 425 | ||
| 426 | - | xQueueSort(x.GoPointer(), purego.NewCallback(CompareFuncVar), UserDataVar) | |
| 426 | + | xQueueSort(x.GoPointer(), NewCallback(CompareFuncVar), UserDataVar) | |
| 427 | 427 | ||
| 428 | 428 | } | |
| 429 | 429 | ||
M v4/glib/grcbox.go +4 -4
| @@ -88,9 +88,9 @@ var xAtomicRcBoxReleaseFull func(uintptr, uintptr) | |||
| 88 | 88 | // If the reference was the last one, it will call @clear_func | |
| 89 | 89 | // to clear the contents of @mem_block, and then will free the | |
| 90 | 90 | // resources allocated for @mem_block. | |
| 91 | - | func AtomicRcBoxReleaseFull(MemBlockVar uintptr, ClearFuncVar DestroyNotify) { | |
| 91 | + | func AtomicRcBoxReleaseFull(MemBlockVar uintptr, ClearFuncVar *DestroyNotify) { | |
| 92 | 92 | ||
| 93 | - | xAtomicRcBoxReleaseFull(MemBlockVar, purego.NewCallback(ClearFuncVar)) | |
| 93 | + | xAtomicRcBoxReleaseFull(MemBlockVar, NewCallback(ClearFuncVar)) | |
| 94 | 94 | ||
| 95 | 95 | } | |
| 96 | 96 | ||
| @@ -176,9 +176,9 @@ var xRcBoxReleaseFull func(uintptr, uintptr) | |||
| 176 | 176 | // If the reference was the last one, it will call @clear_func | |
| 177 | 177 | // to clear the contents of @mem_block, and then will free the | |
| 178 | 178 | // resources allocated for @mem_block. | |
| 179 | - | func RcBoxReleaseFull(MemBlockVar uintptr, ClearFuncVar DestroyNotify) { | |
| 179 | + | func RcBoxReleaseFull(MemBlockVar uintptr, ClearFuncVar *DestroyNotify) { | |
| 180 | 180 | ||
| 181 | - | xRcBoxReleaseFull(MemBlockVar, purego.NewCallback(ClearFuncVar)) | |
| 181 | + | xRcBoxReleaseFull(MemBlockVar, NewCallback(ClearFuncVar)) | |
| 182 | 182 | ||
| 183 | 183 | } | |
| 184 | 184 | ||
M v4/glib/gregex.go +2 -2
| @@ -741,10 +741,10 @@ var xRegexReplaceEval func(uintptr, uintptr, int, int, RegexMatchFlags, uintptr, | |||
| 741 | 741 | // | |
| 742 | 742 | // ... | |
| 743 | 743 | // ]| | |
| 744 | - | func (x *Regex) ReplaceEval(StringVar uintptr, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, EvalVar RegexEvalCallback, UserDataVar uintptr) (string, error) { | |
| 744 | + | func (x *Regex) ReplaceEval(StringVar uintptr, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, EvalVar *RegexEvalCallback, UserDataVar uintptr) (string, error) { | |
| 745 | 745 | var cerr *Error | |
| 746 | 746 | ||
| 747 | - | cret := xRegexReplaceEval(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, purego.NewCallback(EvalVar), UserDataVar, &cerr) | |
| 747 | + | cret := xRegexReplaceEval(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, NewCallback(EvalVar), UserDataVar, &cerr) | |
| 748 | 748 | if cerr == nil { | |
| 749 | 749 | return cret, nil | |
| 750 | 750 | } | |
M v4/glib/gscanner.go +2 -2
| @@ -218,9 +218,9 @@ var xScannerScopeForeachSymbol func(uintptr, uint, uintptr, uintptr) | |||
| 218 | 218 | // in the given scope of the #GScanner. The function is passed | |
| 219 | 219 | // the symbol and value of each pair, and the given @user_data | |
| 220 | 220 | // parameter. | |
| 221 | - | func (x *Scanner) ScopeForeachSymbol(ScopeIdVar uint, FuncVar HFunc, UserDataVar uintptr) { | |
| 221 | + | func (x *Scanner) ScopeForeachSymbol(ScopeIdVar uint, FuncVar *HFunc, UserDataVar uintptr) { | |
| 222 | 222 | ||
| 223 | - | xScannerScopeForeachSymbol(x.GoPointer(), ScopeIdVar, purego.NewCallback(FuncVar), UserDataVar) | |
| 223 | + | xScannerScopeForeachSymbol(x.GoPointer(), ScopeIdVar, NewCallback(FuncVar), UserDataVar) | |
| 224 | 224 | ||
| 225 | 225 | } | |
| 226 | 226 | ||
M v4/glib/gsequence.go +18 -18
| @@ -35,9 +35,9 @@ var xSequenceForeach func(uintptr, uintptr, uintptr) | |||
| 35 | 35 | ||
| 36 | 36 | // Calls @func for each item in the sequence passing @user_data | |
| 37 | 37 | // to the function. @func must not modify the sequence itself. | |
| 38 | - | func (x *Sequence) Foreach(FuncVar Func, UserDataVar uintptr) { | |
| 38 | + | func (x *Sequence) Foreach(FuncVar *Func, UserDataVar uintptr) { | |
| 39 | 39 | ||
| 40 | - | xSequenceForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 40 | + | xSequenceForeach(x.GoPointer(), NewCallback(FuncVar), UserDataVar) | |
| 41 | 41 | ||
| 42 | 42 | } | |
| 43 | 43 | ||
| @@ -105,9 +105,9 @@ var xSequenceInsertSorted func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |||
| 105 | 105 | // Note that when adding a large amount of data to a #GSequence, | |
| 106 | 106 | // it is more efficient to do unsorted insertions and then call | |
| 107 | 107 | // g_sequence_sort() or g_sequence_sort_iter(). | |
| 108 | - | func (x *Sequence) InsertSorted(DataVar uintptr, CmpFuncVar CompareDataFunc, CmpDataVar uintptr) *SequenceIter { | |
| 108 | + | func (x *Sequence) InsertSorted(DataVar uintptr, CmpFuncVar *CompareDataFunc, CmpDataVar uintptr) *SequenceIter { | |
| 109 | 109 | ||
| 110 | - | cret := xSequenceInsertSorted(x.GoPointer(), DataVar, purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 110 | + | cret := xSequenceInsertSorted(x.GoPointer(), DataVar, NewCallback(CmpFuncVar), CmpDataVar) | |
| 111 | 111 | return cret | |
| 112 | 112 | } | |
| 113 | 113 | ||
| @@ -125,9 +125,9 @@ var xSequenceInsertSortedIter func(uintptr, uintptr, uintptr, uintptr) *Sequence | |||
| 125 | 125 | // Note that when adding a large amount of data to a #GSequence, | |
| 126 | 126 | // it is more efficient to do unsorted insertions and then call | |
| 127 | 127 | // g_sequence_sort() or g_sequence_sort_iter(). | |
| 128 | - | func (x *Sequence) InsertSortedIter(DataVar uintptr, IterCmpVar SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter { | |
| 128 | + | func (x *Sequence) InsertSortedIter(DataVar uintptr, IterCmpVar *SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter { | |
| 129 | 129 | ||
| 130 | - | cret := xSequenceInsertSortedIter(x.GoPointer(), DataVar, purego.NewCallback(IterCmpVar), CmpDataVar) | |
| 130 | + | cret := xSequenceInsertSortedIter(x.GoPointer(), DataVar, NewCallback(IterCmpVar), CmpDataVar) | |
| 131 | 131 | return cret | |
| 132 | 132 | } | |
| 133 | 133 | ||
| @@ -159,9 +159,9 @@ var xSequenceLookup func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |||
| 159 | 159 | // | |
| 160 | 160 | // This function will fail if the data contained in the sequence is | |
| 161 | 161 | // unsorted. | |
| 162 | - | func (x *Sequence) Lookup(DataVar uintptr, CmpFuncVar CompareDataFunc, CmpDataVar uintptr) *SequenceIter { | |
| 162 | + | func (x *Sequence) Lookup(DataVar uintptr, CmpFuncVar *CompareDataFunc, CmpDataVar uintptr) *SequenceIter { | |
| 163 | 163 | ||
| 164 | - | cret := xSequenceLookup(x.GoPointer(), DataVar, purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 164 | + | cret := xSequenceLookup(x.GoPointer(), DataVar, NewCallback(CmpFuncVar), CmpDataVar) | |
| 165 | 165 | return cret | |
| 166 | 166 | } | |
| 167 | 167 | ||
| @@ -177,9 +177,9 @@ var xSequenceLookupIter func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |||
| 177 | 177 | // | |
| 178 | 178 | // This function will fail if the data contained in the sequence is | |
| 179 | 179 | // unsorted. | |
| 180 | - | func (x *Sequence) LookupIter(DataVar uintptr, IterCmpVar SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter { | |
| 180 | + | func (x *Sequence) LookupIter(DataVar uintptr, IterCmpVar *SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter { | |
| 181 | 181 | ||
| 182 | - | cret := xSequenceLookupIter(x.GoPointer(), DataVar, purego.NewCallback(IterCmpVar), CmpDataVar) | |
| 182 | + | cret := xSequenceLookupIter(x.GoPointer(), DataVar, NewCallback(IterCmpVar), CmpDataVar) | |
| 183 | 183 | return cret | |
| 184 | 184 | } | |
| 185 | 185 | ||
| @@ -207,9 +207,9 @@ var xSequenceSearch func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |||
| 207 | 207 | // | |
| 208 | 208 | // This function will fail if the data contained in the sequence is | |
| 209 | 209 | // unsorted. | |
| 210 | - | func (x *Sequence) Search(DataVar uintptr, CmpFuncVar CompareDataFunc, CmpDataVar uintptr) *SequenceIter { | |
| 210 | + | func (x *Sequence) Search(DataVar uintptr, CmpFuncVar *CompareDataFunc, CmpDataVar uintptr) *SequenceIter { | |
| 211 | 211 | ||
| 212 | - | cret := xSequenceSearch(x.GoPointer(), DataVar, purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 212 | + | cret := xSequenceSearch(x.GoPointer(), DataVar, NewCallback(CmpFuncVar), CmpDataVar) | |
| 213 | 213 | return cret | |
| 214 | 214 | } | |
| 215 | 215 | ||
| @@ -228,9 +228,9 @@ var xSequenceSearchIter func(uintptr, uintptr, uintptr, uintptr) *SequenceIter | |||
| 228 | 228 | // | |
| 229 | 229 | // This function will fail if the data contained in the sequence is | |
| 230 | 230 | // unsorted. | |
| 231 | - | func (x *Sequence) SearchIter(DataVar uintptr, IterCmpVar SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter { | |
| 231 | + | func (x *Sequence) SearchIter(DataVar uintptr, IterCmpVar *SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter { | |
| 232 | 232 | ||
| 233 | - | cret := xSequenceSearchIter(x.GoPointer(), DataVar, purego.NewCallback(IterCmpVar), CmpDataVar) | |
| 233 | + | cret := xSequenceSearchIter(x.GoPointer(), DataVar, NewCallback(IterCmpVar), CmpDataVar) | |
| 234 | 234 | return cret | |
| 235 | 235 | } | |
| 236 | 236 | ||
| @@ -242,9 +242,9 @@ var xSequenceSort func(uintptr, uintptr, uintptr) | |||
| 242 | 242 | // return 0 if they are equal, a negative value if the | |
| 243 | 243 | // first comes before the second, and a positive value | |
| 244 | 244 | // if the second comes before the first. | |
| 245 | - | func (x *Sequence) Sort(CmpFuncVar CompareDataFunc, CmpDataVar uintptr) { | |
| 245 | + | func (x *Sequence) Sort(CmpFuncVar *CompareDataFunc, CmpDataVar uintptr) { | |
| 246 | 246 | ||
| 247 | - | xSequenceSort(x.GoPointer(), purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 247 | + | xSequenceSort(x.GoPointer(), NewCallback(CmpFuncVar), CmpDataVar) | |
| 248 | 248 | ||
| 249 | 249 | } | |
| 250 | 250 | ||
| @@ -257,9 +257,9 @@ var xSequenceSortIter func(uintptr, uintptr, uintptr) | |||
| 257 | 257 | // return 0 if the iterators are equal, a negative value if the first | |
| 258 | 258 | // iterator comes before the second, and a positive value if the second | |
| 259 | 259 | // iterator comes before the first. | |
| 260 | - | func (x *Sequence) SortIter(CmpFuncVar SequenceIterCompareFunc, CmpDataVar uintptr) { | |
| 260 | + | func (x *Sequence) SortIter(CmpFuncVar *SequenceIterCompareFunc, CmpDataVar uintptr) { | |
| 261 | 261 | ||
| 262 | - | xSequenceSortIter(x.GoPointer(), purego.NewCallback(CmpFuncVar), CmpDataVar) | |
| 262 | + | xSequenceSortIter(x.GoPointer(), NewCallback(CmpFuncVar), CmpDataVar) | |
| 263 | 263 | ||
| 264 | 264 | } | |
| 265 | 265 | ||
M v4/glib/gslist.go +2 -2
| @@ -25,9 +25,9 @@ var xClearSlist func(**SList, uintptr) | |||
| 25 | 25 | // Clears a pointer to a #GSList, freeing it and, optionally, freeing its elements using @destroy. | |
| 26 | 26 | // | |
| 27 | 27 | // @slist_ptr must be a valid pointer. If @slist_ptr points to a null #GSList, this does nothing. | |
| 28 | - | func ClearSlist(SlistPtrVar **SList, DestroyVar DestroyNotify) { | |
| 28 | + | func ClearSlist(SlistPtrVar **SList, DestroyVar *DestroyNotify) { | |
| 29 | 29 | ||
| 30 | - | xClearSlist(SlistPtrVar, purego.NewCallback(DestroyVar)) | |
| 30 | + | xClearSlist(SlistPtrVar, NewCallback(DestroyVar)) | |
| 31 | 31 | ||
| 32 | 32 | } | |
| 33 | 33 | ||
M v4/glib/gspawn.go +10 -10
| @@ -146,10 +146,10 @@ var xSpawnAsync func(string, uintptr, uintptr, SpawnFlags, uintptr, uintptr, *Pi | |||
| 146 | 146 | // Note that the returned @child_pid on Windows is a handle to the child | |
| 147 | 147 | // process and not its identifier. Process handles and process identifiers | |
| 148 | 148 | // are different concepts on Windows. | |
| 149 | - | func SpawnAsync(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar SpawnChildSetupFunc, UserDataVar uintptr, ChildPidVar *Pid) (bool, error) { | |
| 149 | + | func SpawnAsync(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar *SpawnChildSetupFunc, UserDataVar uintptr, ChildPidVar *Pid) (bool, error) { | |
| 150 | 150 | var cerr *Error | |
| 151 | 151 | ||
| 152 | - | cret := xSpawnAsync(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, purego.NewCallback(ChildSetupVar), UserDataVar, ChildPidVar, &cerr) | |
| 152 | + | cret := xSpawnAsync(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, NewCallback(ChildSetupVar), UserDataVar, ChildPidVar, &cerr) | |
| 153 | 153 | if cerr == nil { | |
| 154 | 154 | return cret, nil | |
| 155 | 155 | } | |
| @@ -163,10 +163,10 @@ var xSpawnAsyncWithFds func(string, uintptr, uintptr, SpawnFlags, uintptr, uintp | |||
| 163 | 163 | // | |
| 164 | 164 | // Identical to g_spawn_async_with_pipes_and_fds() but with `n_fds` set to zero, | |
| 165 | 165 | // so no FD assignments are used. | |
| 166 | - | func SpawnAsyncWithFds(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar SpawnChildSetupFunc, UserDataVar uintptr, ChildPidVar *Pid, StdinFdVar int, StdoutFdVar int, StderrFdVar int) (bool, error) { | |
| 166 | + | func SpawnAsyncWithFds(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar *SpawnChildSetupFunc, UserDataVar uintptr, ChildPidVar *Pid, StdinFdVar int, StdoutFdVar int, StderrFdVar int) (bool, error) { | |
| 167 | 167 | var cerr *Error | |
| 168 | 168 | ||
| 169 | - | cret := xSpawnAsyncWithFds(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, purego.NewCallback(ChildSetupVar), UserDataVar, ChildPidVar, StdinFdVar, StdoutFdVar, StderrFdVar, &cerr) | |
| 169 | + | cret := xSpawnAsyncWithFds(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, NewCallback(ChildSetupVar), UserDataVar, ChildPidVar, StdinFdVar, StdoutFdVar, StderrFdVar, &cerr) | |
| 170 | 170 | if cerr == nil { | |
| 171 | 171 | return cret, nil | |
| 172 | 172 | } | |
| @@ -178,10 +178,10 @@ var xSpawnAsyncWithPipes func(string, uintptr, uintptr, SpawnFlags, uintptr, uin | |||
| 178 | 178 | ||
| 179 | 179 | // Identical to g_spawn_async_with_pipes_and_fds() but with `n_fds` set to zero, | |
| 180 | 180 | // so no FD assignments are used. | |
| 181 | - | func SpawnAsyncWithPipes(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar SpawnChildSetupFunc, UserDataVar uintptr, ChildPidVar *Pid, StandardInputVar int, StandardOutputVar int, StandardErrorVar int) (bool, error) { | |
| 181 | + | func SpawnAsyncWithPipes(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar *SpawnChildSetupFunc, UserDataVar uintptr, ChildPidVar *Pid, StandardInputVar int, StandardOutputVar int, StandardErrorVar int) (bool, error) { | |
| 182 | 182 | var cerr *Error | |
| 183 | 183 | ||
| 184 | - | cret := xSpawnAsyncWithPipes(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, purego.NewCallback(ChildSetupVar), UserDataVar, ChildPidVar, StandardInputVar, StandardOutputVar, StandardErrorVar, &cerr) | |
| 184 | + | cret := xSpawnAsyncWithPipes(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, NewCallback(ChildSetupVar), UserDataVar, ChildPidVar, StandardInputVar, StandardOutputVar, StandardErrorVar, &cerr) | |
| 185 | 185 | if cerr == nil { | |
| 186 | 186 | return cret, nil | |
| 187 | 187 | } | |
| @@ -379,10 +379,10 @@ var xSpawnAsyncWithPipesAndFds func(string, uintptr, uintptr, SpawnFlags, uintpt | |||
| 379 | 379 | // graphical application too, then to ensure that the spawned program opens its | |
| 380 | 380 | // windows on the right screen, you may want to use #GdkAppLaunchContext, | |
| 381 | 381 | // #GAppLaunchContext, or set the `DISPLAY` environment variable. | |
| 382 | - | func SpawnAsyncWithPipesAndFds(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar SpawnChildSetupFunc, UserDataVar uintptr, StdinFdVar int, StdoutFdVar int, StderrFdVar int, SourceFdsVar uintptr, TargetFdsVar uintptr, NFdsVar uint, ChildPidOutVar *Pid, StdinPipeOutVar int, StdoutPipeOutVar int, StderrPipeOutVar int) (bool, error) { | |
| 382 | + | func SpawnAsyncWithPipesAndFds(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar *SpawnChildSetupFunc, UserDataVar uintptr, StdinFdVar int, StdoutFdVar int, StderrFdVar int, SourceFdsVar uintptr, TargetFdsVar uintptr, NFdsVar uint, ChildPidOutVar *Pid, StdinPipeOutVar int, StdoutPipeOutVar int, StderrPipeOutVar int) (bool, error) { | |
| 383 | 383 | var cerr *Error | |
| 384 | 384 | ||
| 385 | - | cret := xSpawnAsyncWithPipesAndFds(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, purego.NewCallback(ChildSetupVar), UserDataVar, StdinFdVar, StdoutFdVar, StderrFdVar, SourceFdsVar, TargetFdsVar, NFdsVar, ChildPidOutVar, StdinPipeOutVar, StdoutPipeOutVar, StderrPipeOutVar, &cerr) | |
| 385 | + | cret := xSpawnAsyncWithPipesAndFds(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, NewCallback(ChildSetupVar), UserDataVar, StdinFdVar, StdoutFdVar, StderrFdVar, SourceFdsVar, TargetFdsVar, NFdsVar, ChildPidOutVar, StdinPipeOutVar, StdoutPipeOutVar, StderrPipeOutVar, &cerr) | |
| 386 | 386 | if cerr == nil { | |
| 387 | 387 | return cret, nil | |
| 388 | 388 | } | |
| @@ -565,10 +565,10 @@ var xSpawnSync func(string, uintptr, uintptr, SpawnFlags, uintptr, uintptr, uint | |||
| 565 | 565 | // This function calls g_spawn_async_with_pipes() internally; see that | |
| 566 | 566 | // function for full details on the other parameters and details on | |
| 567 | 567 | // how these functions work on Windows. | |
| 568 | - | func SpawnSync(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar SpawnChildSetupFunc, UserDataVar uintptr, StandardOutputVar uintptr, StandardErrorVar uintptr, WaitStatusVar int) (bool, error) { | |
| 568 | + | func SpawnSync(WorkingDirectoryVar string, ArgvVar uintptr, EnvpVar uintptr, FlagsVar SpawnFlags, ChildSetupVar *SpawnChildSetupFunc, UserDataVar uintptr, StandardOutputVar uintptr, StandardErrorVar uintptr, WaitStatusVar int) (bool, error) { | |
| 569 | 569 | var cerr *Error | |
| 570 | 570 | ||
| 571 | - | cret := xSpawnSync(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, purego.NewCallback(ChildSetupVar), UserDataVar, StandardOutputVar, StandardErrorVar, WaitStatusVar, &cerr) | |
| 571 | + | cret := xSpawnSync(WorkingDirectoryVar, ArgvVar, EnvpVar, FlagsVar, NewCallback(ChildSetupVar), UserDataVar, StandardOutputVar, StandardErrorVar, WaitStatusVar, &cerr) | |
| 572 | 572 | if cerr == nil { | |
| 573 | 573 | return cret, nil | |
| 574 | 574 | } | |
M v4/glib/gtestutils.go +14 -14
| @@ -377,9 +377,9 @@ var xTestAddDataFunc func(string, uintptr, uintptr) | |||
| 377 | 377 | // No component of @testpath may start with a dot (`.`) if the | |
| 378 | 378 | // %G_TEST_OPTION_ISOLATE_DIRS option is being used; and it is recommended to | |
| 379 | 379 | // do so even if it isn’t. | |
| 380 | - | func TestAddDataFunc(TestpathVar string, TestDataVar uintptr, TestFuncVar TestDataFunc) { | |
| 380 | + | func TestAddDataFunc(TestpathVar string, TestDataVar uintptr, TestFuncVar *TestDataFunc) { | |
| 381 | 381 | ||
| 382 | - | xTestAddDataFunc(TestpathVar, TestDataVar, purego.NewCallback(TestFuncVar)) | |
| 382 | + | xTestAddDataFunc(TestpathVar, TestDataVar, NewCallback(TestFuncVar)) | |
| 383 | 383 | ||
| 384 | 384 | } | |
| 385 | 385 | ||
| @@ -387,9 +387,9 @@ var xTestAddDataFuncFull func(string, uintptr, uintptr, uintptr) | |||
| 387 | 387 | ||
| 388 | 388 | // Create a new test case, as with g_test_add_data_func(), but freeing | |
| 389 | 389 | // @test_data after the test run is complete. | |
| 390 | - | func TestAddDataFuncFull(TestpathVar string, TestDataVar uintptr, TestFuncVar TestDataFunc, DataFreeFuncVar DestroyNotify) { | |
| 390 | + | func TestAddDataFuncFull(TestpathVar string, TestDataVar uintptr, TestFuncVar *TestDataFunc, DataFreeFuncVar *DestroyNotify) { | |
| 391 | 391 | ||
| 392 | - | xTestAddDataFuncFull(TestpathVar, TestDataVar, purego.NewCallback(TestFuncVar), purego.NewCallback(DataFreeFuncVar)) | |
| 392 | + | xTestAddDataFuncFull(TestpathVar, TestDataVar, NewCallback(TestFuncVar), NewCallback(DataFreeFuncVar)) | |
| 393 | 393 | ||
| 394 | 394 | } | |
| 395 | 395 | ||
| @@ -407,17 +407,17 @@ var xTestAddFunc func(string, uintptr) | |||
| 407 | 407 | // No component of @testpath may start with a dot (`.`) if the | |
| 408 | 408 | // %G_TEST_OPTION_ISOLATE_DIRS option is being used; and it is recommended to | |
| 409 | 409 | // do so even if it isn’t. | |
| 410 | - | func TestAddFunc(TestpathVar string, TestFuncVar TestFunc) { | |
| 410 | + | func TestAddFunc(TestpathVar string, TestFuncVar *TestFunc) { | |
| 411 | 411 | ||
| 412 | - | xTestAddFunc(TestpathVar, purego.NewCallback(TestFuncVar)) | |
| 412 | + | xTestAddFunc(TestpathVar, NewCallback(TestFuncVar)) | |
| 413 | 413 | ||
| 414 | 414 | } | |
| 415 | 415 | ||
| 416 | 416 | var xTestAddVtable func(string, uint, uintptr, uintptr, uintptr, uintptr) | |
| 417 | 417 | ||
| 418 | - | func TestAddVtable(TestpathVar string, DataSizeVar uint, TestDataVar uintptr, DataSetupVar TestFixtureFunc, DataTestVar TestFixtureFunc, DataTeardownVar TestFixtureFunc) { | |
| 418 | + | func TestAddVtable(TestpathVar string, DataSizeVar uint, TestDataVar uintptr, DataSetupVar *TestFixtureFunc, DataTestVar *TestFixtureFunc, DataTeardownVar *TestFixtureFunc) { | |
| 419 | 419 | ||
| 420 | - | xTestAddVtable(TestpathVar, DataSizeVar, TestDataVar, purego.NewCallback(DataSetupVar), purego.NewCallback(DataTestVar), purego.NewCallback(DataTeardownVar)) | |
| 420 | + | xTestAddVtable(TestpathVar, DataSizeVar, TestDataVar, NewCallback(DataSetupVar), NewCallback(DataTestVar), NewCallback(DataTeardownVar)) | |
| 421 | 421 | ||
| 422 | 422 | } | |
| 423 | 423 | ||
| @@ -518,9 +518,9 @@ var xTestCreateCase func(string, uint, uintptr, uintptr, uintptr, uintptr) *Test | |||
| 518 | 518 | // multiple tests. In this cases, g_test_create_case() will be | |
| 519 | 519 | // called with the same type of fixture (the @data_size argument), but varying | |
| 520 | 520 | // @test_name and @data_test arguments. | |
| 521 | - | func TestCreateCase(TestNameVar string, DataSizeVar uint, TestDataVar uintptr, DataSetupVar TestFixtureFunc, DataTestVar TestFixtureFunc, DataTeardownVar TestFixtureFunc) *TestCase { | |
| 521 | + | func TestCreateCase(TestNameVar string, DataSizeVar uint, TestDataVar uintptr, DataSetupVar *TestFixtureFunc, DataTestVar *TestFixtureFunc, DataTeardownVar *TestFixtureFunc) *TestCase { | |
| 522 | 522 | ||
| 523 | - | cret := xTestCreateCase(TestNameVar, DataSizeVar, TestDataVar, purego.NewCallback(DataSetupVar), purego.NewCallback(DataTestVar), purego.NewCallback(DataTeardownVar)) | |
| 523 | + | cret := xTestCreateCase(TestNameVar, DataSizeVar, TestDataVar, NewCallback(DataSetupVar), NewCallback(DataTestVar), NewCallback(DataTeardownVar)) | |
| 524 | 524 | return cret | |
| 525 | 525 | } | |
| 526 | 526 | ||
| @@ -798,9 +798,9 @@ var xTestLogSetFatalHandler func(uintptr, uintptr) | |||
| 798 | 798 | // behaviour for specific log messages, programs must install a custom log | |
| 799 | 799 | // writer function using g_log_set_writer_func().See | |
| 800 | 800 | // [Using Structured Logging][using-structured-logging]. | |
| 801 | - | func TestLogSetFatalHandler(LogFuncVar TestLogFatalFunc, UserDataVar uintptr) { | |
| 801 | + | func TestLogSetFatalHandler(LogFuncVar *TestLogFatalFunc, UserDataVar uintptr) { | |
| 802 | 802 | ||
| 803 | - | xTestLogSetFatalHandler(purego.NewCallback(LogFuncVar), UserDataVar) | |
| 803 | + | xTestLogSetFatalHandler(NewCallback(LogFuncVar), UserDataVar) | |
| 804 | 804 | ||
| 805 | 805 | } | |
| 806 | 806 | ||
| @@ -855,9 +855,9 @@ var xTestQueueDestroy func(uintptr, uintptr) | |||
| 855 | 855 | // Resources are released in reverse queue order, that means enqueueing | |
| 856 | 856 | // callback A before callback B will cause B() to be called before | |
| 857 | 857 | // A() during teardown. | |
| 858 | - | func TestQueueDestroy(DestroyFuncVar DestroyNotify, DestroyDataVar uintptr) { | |
| 858 | + | func TestQueueDestroy(DestroyFuncVar *DestroyNotify, DestroyDataVar uintptr) { | |
| 859 | 859 | ||
| 860 | - | xTestQueueDestroy(purego.NewCallback(DestroyFuncVar), DestroyDataVar) | |
| 860 | + | xTestQueueDestroy(NewCallback(DestroyFuncVar), DestroyDataVar) | |
| 861 | 861 | ||
| 862 | 862 | } | |
| 863 | 863 | ||
M v4/glib/gthread.go +6 -6
| @@ -242,9 +242,9 @@ func (x *Once) GoPointer() uintptr { | |||
| 242 | 242 | ||
| 243 | 243 | var xOnceImpl func(uintptr, uintptr, uintptr) uintptr | |
| 244 | 244 | ||
| 245 | - | func (x *Once) Impl(FuncVar ThreadFunc, ArgVar uintptr) uintptr { | |
| 245 | + | func (x *Once) Impl(FuncVar *ThreadFunc, ArgVar uintptr) uintptr { | |
| 246 | 246 | ||
| 247 | - | cret := xOnceImpl(x.GoPointer(), purego.NewCallback(FuncVar), ArgVar) | |
| 247 | + | cret := xOnceImpl(x.GoPointer(), NewCallback(FuncVar), ArgVar) | |
| 248 | 248 | return cret | |
| 249 | 249 | } | |
| 250 | 250 | ||
| @@ -689,9 +689,9 @@ var xNewThread func(string, uintptr, uintptr) *Thread | |||
| 689 | 689 | // inheriting the thread priority but were spawned with the default priority. | |
| 690 | 690 | // Starting with GLib 2.64 the behaviour is now consistent between Windows and | |
| 691 | 691 | // POSIX and all threads inherit their parent thread's priority. | |
| 692 | - | func NewThread(NameVar string, FuncVar ThreadFunc, DataVar uintptr) *Thread { | |
| 692 | + | func NewThread(NameVar string, FuncVar *ThreadFunc, DataVar uintptr) *Thread { | |
| 693 | 693 | ||
| 694 | - | cret := xNewThread(NameVar, purego.NewCallback(FuncVar), DataVar) | |
| 694 | + | cret := xNewThread(NameVar, NewCallback(FuncVar), DataVar) | |
| 695 | 695 | return cret | |
| 696 | 696 | } | |
| 697 | 697 | ||
| @@ -702,10 +702,10 @@ var xThreadTryNew func(string, uintptr, uintptr, **Error) *Thread | |||
| 702 | 702 | // | |
| 703 | 703 | // If a thread can not be created (due to resource limits), | |
| 704 | 704 | // @error is set and %NULL is returned. | |
| 705 | - | func ThreadTryNew(NameVar string, FuncVar ThreadFunc, DataVar uintptr) (*Thread, error) { | |
| 705 | + | func ThreadTryNew(NameVar string, FuncVar *ThreadFunc, DataVar uintptr) (*Thread, error) { | |
| 706 | 706 | var cerr *Error | |
| 707 | 707 | ||
| 708 | - | cret := xThreadTryNew(NameVar, purego.NewCallback(FuncVar), DataVar, &cerr) | |
| 708 | + | cret := xThreadTryNew(NameVar, NewCallback(FuncVar), DataVar, &cerr) | |
| 709 | 709 | if cerr == nil { | |
| 710 | 710 | return cret, nil | |
| 711 | 711 | } | |
M v4/glib/gthreadpool.go +2 -2
| @@ -144,9 +144,9 @@ var xThreadPoolSetSortFunction func(uintptr, uintptr, uintptr) | |||
| 144 | 144 | // scheduled by the operating system and are executed at random. It | |
| 145 | 145 | // cannot be assumed that threads are executed in the order they are | |
| 146 | 146 | // created. | |
| 147 | - | func (x *ThreadPool) SetSortFunction(FuncVar CompareDataFunc, UserDataVar uintptr) { | |
| 147 | + | func (x *ThreadPool) SetSortFunction(FuncVar *CompareDataFunc, UserDataVar uintptr) { | |
| 148 | 148 | ||
| 149 | - | xThreadPoolSetSortFunction(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 149 | + | xThreadPoolSetSortFunction(x.GoPointer(), NewCallback(FuncVar), UserDataVar) | |
| 150 | 150 | ||
| 151 | 151 | } | |
| 152 | 152 | ||
M v4/glib/gtree.go +16 -16
| @@ -33,9 +33,9 @@ func (x *Tree) GoPointer() uintptr { | |||
| 33 | 33 | var xNewTree func(uintptr) *Tree | |
| 34 | 34 | ||
| 35 | 35 | // Creates a new #GTree. | |
| 36 | - | func NewTree(KeyCompareFuncVar CompareFunc) *Tree { | |
| 36 | + | func NewTree(KeyCompareFuncVar *CompareFunc) *Tree { | |
| 37 | 37 | ||
| 38 | - | cret := xNewTree(purego.NewCallback(KeyCompareFuncVar)) | |
| 38 | + | cret := xNewTree(NewCallback(KeyCompareFuncVar)) | |
| 39 | 39 | return cret | |
| 40 | 40 | } | |
| 41 | 41 | ||
| @@ -44,9 +44,9 @@ var xNewTreeFull func(uintptr, uintptr, uintptr, uintptr) *Tree | |||
| 44 | 44 | // Creates a new #GTree like g_tree_new() and allows to specify functions | |
| 45 | 45 | // to free the memory allocated for the key and value that get called when | |
| 46 | 46 | // removing the entry from the #GTree. | |
| 47 | - | func NewTreeFull(KeyCompareFuncVar CompareDataFunc, KeyCompareDataVar uintptr, KeyDestroyFuncVar DestroyNotify, ValueDestroyFuncVar DestroyNotify) *Tree { | |
| 47 | + | func NewTreeFull(KeyCompareFuncVar *CompareDataFunc, KeyCompareDataVar uintptr, KeyDestroyFuncVar *DestroyNotify, ValueDestroyFuncVar *DestroyNotify) *Tree { | |
| 48 | 48 | ||
| 49 | - | cret := xNewTreeFull(purego.NewCallback(KeyCompareFuncVar), KeyCompareDataVar, purego.NewCallback(KeyDestroyFuncVar), purego.NewCallback(ValueDestroyFuncVar)) | |
| 49 | + | cret := xNewTreeFull(NewCallback(KeyCompareFuncVar), KeyCompareDataVar, NewCallback(KeyDestroyFuncVar), NewCallback(ValueDestroyFuncVar)) | |
| 50 | 50 | return cret | |
| 51 | 51 | } | |
| 52 | 52 | ||
| @@ -54,9 +54,9 @@ var xNewTreeWithData func(uintptr, uintptr) *Tree | |||
| 54 | 54 | ||
| 55 | 55 | // Creates a new #GTree with a comparison function that accepts user data. | |
| 56 | 56 | // See g_tree_new() for more details. | |
| 57 | - | func NewTreeWithData(KeyCompareFuncVar CompareDataFunc, KeyCompareDataVar uintptr) *Tree { | |
| 57 | + | func NewTreeWithData(KeyCompareFuncVar *CompareDataFunc, KeyCompareDataVar uintptr) *Tree { | |
| 58 | 58 | ||
| 59 | - | cret := xNewTreeWithData(purego.NewCallback(KeyCompareFuncVar), KeyCompareDataVar) | |
| 59 | + | cret := xNewTreeWithData(NewCallback(KeyCompareFuncVar), KeyCompareDataVar) | |
| 60 | 60 | return cret | |
| 61 | 61 | } | |
| 62 | 62 | ||
| @@ -84,9 +84,9 @@ var xTreeForeach func(uintptr, uintptr, uintptr) | |||
| 84 | 84 | // add/remove items). To remove all items matching a predicate, you need | |
| 85 | 85 | // to add each item to a list in your #GTraverseFunc as you walk over | |
| 86 | 86 | // the tree, then walk the list and remove each item. | |
| 87 | - | func (x *Tree) Foreach(FuncVar TraverseFunc, UserDataVar uintptr) { | |
| 87 | + | func (x *Tree) Foreach(FuncVar *TraverseFunc, UserDataVar uintptr) { | |
| 88 | 88 | ||
| 89 | - | xTreeForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 89 | + | xTreeForeach(x.GoPointer(), NewCallback(FuncVar), UserDataVar) | |
| 90 | 90 | ||
| 91 | 91 | } | |
| 92 | 92 | ||
| @@ -100,9 +100,9 @@ var xTreeForeachNode func(uintptr, uintptr, uintptr) | |||
| 100 | 100 | // add/remove items). To remove all items matching a predicate, you need | |
| 101 | 101 | // to add each item to a list in your #GTraverseFunc as you walk over | |
| 102 | 102 | // the tree, then walk the list and remove each item. | |
| 103 | - | func (x *Tree) ForeachNode(FuncVar TraverseNodeFunc, UserDataVar uintptr) { | |
| 103 | + | func (x *Tree) ForeachNode(FuncVar *TraverseNodeFunc, UserDataVar uintptr) { | |
| 104 | 104 | ||
| 105 | - | xTreeForeachNode(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 105 | + | xTreeForeachNode(x.GoPointer(), NewCallback(FuncVar), UserDataVar) | |
| 106 | 106 | ||
| 107 | 107 | } | |
| 108 | 108 | ||
| @@ -306,9 +306,9 @@ var xTreeSearch func(uintptr, uintptr, uintptr) uintptr | |||
| 306 | 306 | // will proceed among the key/value pairs that have a smaller key; if | |
| 307 | 307 | // @search_func returns 1, searching will proceed among the key/value | |
| 308 | 308 | // pairs that have a larger key. | |
| 309 | - | func (x *Tree) Search(SearchFuncVar CompareFunc, UserDataVar uintptr) uintptr { | |
| 309 | + | func (x *Tree) Search(SearchFuncVar *CompareFunc, UserDataVar uintptr) uintptr { | |
| 310 | 310 | ||
| 311 | - | cret := xTreeSearch(x.GoPointer(), purego.NewCallback(SearchFuncVar), UserDataVar) | |
| 311 | + | cret := xTreeSearch(x.GoPointer(), NewCallback(SearchFuncVar), UserDataVar) | |
| 312 | 312 | return cret | |
| 313 | 313 | } | |
| 314 | 314 | ||
| @@ -323,9 +323,9 @@ var xTreeSearchNode func(uintptr, uintptr, uintptr) *TreeNode | |||
| 323 | 323 | // will proceed among the key/value pairs that have a smaller key; if | |
| 324 | 324 | // @search_func returns 1, searching will proceed among the key/value | |
| 325 | 325 | // pairs that have a larger key. | |
| 326 | - | func (x *Tree) SearchNode(SearchFuncVar CompareFunc, UserDataVar uintptr) *TreeNode { | |
| 326 | + | func (x *Tree) SearchNode(SearchFuncVar *CompareFunc, UserDataVar uintptr) *TreeNode { | |
| 327 | 327 | ||
| 328 | - | cret := xTreeSearchNode(x.GoPointer(), purego.NewCallback(SearchFuncVar), UserDataVar) | |
| 328 | + | cret := xTreeSearchNode(x.GoPointer(), NewCallback(SearchFuncVar), UserDataVar) | |
| 329 | 329 | return cret | |
| 330 | 330 | } | |
| 331 | 331 | ||
| @@ -344,9 +344,9 @@ func (x *Tree) Steal(KeyVar uintptr) bool { | |||
| 344 | 344 | var xTreeTraverse func(uintptr, uintptr, TraverseType, uintptr) | |
| 345 | 345 | ||
| 346 | 346 | // Calls the given function for each node in the #GTree. | |
| 347 | - | func (x *Tree) Traverse(TraverseFuncVar TraverseFunc, TraverseTypeVar TraverseType, UserDataVar uintptr) { | |
| 347 | + | func (x *Tree) Traverse(TraverseFuncVar *TraverseFunc, TraverseTypeVar TraverseType, UserDataVar uintptr) { | |
| 348 | 348 | ||
| 349 | - | xTreeTraverse(x.GoPointer(), purego.NewCallback(TraverseFuncVar), TraverseTypeVar, UserDataVar) | |
| 349 | + | xTreeTraverse(x.GoPointer(), NewCallback(TraverseFuncVar), TraverseTypeVar, UserDataVar) | |
| 350 | 350 | ||
| 351 | 351 | } | |
| 352 | 352 | ||
M v4/glib/gutils.go +2 -2
| @@ -108,9 +108,9 @@ var xAtexit func(uintptr) | |||
| 108 | 108 | // As can be seen from the above, for portability it's best to avoid | |
| 109 | 109 | // calling g_atexit() (or atexit()) except in the main executable of a | |
| 110 | 110 | // program. | |
| 111 | - | func Atexit(FuncVar VoidFunc) { | |
| 111 | + | func Atexit(FuncVar *VoidFunc) { | |
| 112 | 112 | ||
| 113 | - | xAtexit(purego.NewCallback(FuncVar)) | |
| 113 | + | xAtexit(NewCallback(FuncVar)) | |
| 114 | 114 | ||
| 115 | 115 | } | |
| 116 | 116 | ||
M v4/glib/gvariant.go +2 -2
| @@ -455,9 +455,9 @@ var xNewVariantFromData func(*VariantType, uintptr, uint, bool, uintptr, uintptr | |||
| 455 | 455 | // @type being loaded. Otherwise this function will internally create a copy of | |
| 456 | 456 | // the memory (since GLib 2.60) or (in older versions) fail and exit the | |
| 457 | 457 | // process. | |
| 458 | - | func NewVariantFromData(TypeVar *VariantType, DataVar uintptr, SizeVar uint, TrustedVar bool, NotifyVar DestroyNotify, UserDataVar uintptr) *Variant { | |
| 458 | + | func NewVariantFromData(TypeVar *VariantType, DataVar uintptr, SizeVar uint, TrustedVar bool, NotifyVar *DestroyNotify, UserDataVar uintptr) *Variant { | |
| 459 | 459 | ||
| 460 | - | cret := xNewVariantFromData(TypeVar, DataVar, SizeVar, TrustedVar, purego.NewCallback(NotifyVar), UserDataVar) | |
| 460 | + | cret := xNewVariantFromData(TypeVar, DataVar, SizeVar, TrustedVar, NewCallback(NotifyVar), UserDataVar) | |
| 461 | 461 | return cret | |
| 462 | 462 | } | |
| 463 | 463 | ||
M v4/glib/more.go +40 -0
| @@ -2,10 +2,50 @@ package glib | |||
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | 4 | "fmt" | |
| 5 | + | "sync" | |
| 5 | 6 | ||
| 7 | + | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | ) | |
| 8 | 10 | ||
| 11 | + | var callbacks = struct { | |
| 12 | + | sync.RWMutex | |
| 13 | + | refs map[uintptr]uintptr | |
| 14 | + | }{ | |
| 15 | + | refs: make(map[uintptr]uintptr), | |
| 16 | + | } | |
| 17 | + | ||
| 18 | + | // GetCallback retrives a callback reference by value. | |
| 19 | + | // Users should not need to call this. | |
| 20 | + | func GetCallback(cbPtr uintptr) (uintptr, bool) { | |
| 21 | + | callbacks.RLock() | |
| 22 | + | defer callbacks.RUnlock() | |
| 23 | + | refPtr, ok := callbacks.refs[cbPtr] | |
| 24 | + | return refPtr, ok | |
| 25 | + | } | |
| 26 | + | ||
| 27 | + | // SaveCallback saves a reference to the callback value. | |
| 28 | + | // Users should not need to call this. | |
| 29 | + | func SaveCallback(cbPtr uintptr, refPtr uintptr) { | |
| 30 | + | callbacks.Lock() | |
| 31 | + | callbacks.refs[cbPtr] = refPtr | |
| 32 | + | callbacks.Unlock() | |
| 33 | + | } | |
| 34 | + | ||
| 35 | + | // UnrefCallbackValue unreferences the provided callback by reflect.value to free a purego slot | |
| 36 | + | // | |
| 37 | + | // NOTE: Windows does not support unreferencing callbacks, so on that platform this operation is | |
| 38 | + | // a NOOP, callback memory is never freed, and there is a limit on maximum total callbacks. | |
| 39 | + | // See the purego documentation for further details. | |
| 40 | + | func UnrefCallback(fnPtr interface{}) error { | |
| 41 | + | return unrefCallback(fnPtr) | |
| 42 | + | } | |
| 43 | + | ||
| 44 | + | // NewCallback is an alias to purego.NewCallback | |
| 45 | + | func NewCallback(fnPtr interface{}) uintptr { | |
| 46 | + | return purego.NewCallbackFnPtr(fnPtr) | |
| 47 | + | } | |
| 48 | + | ||
| 9 | 49 | func (e *Error) Error() string { | |
| 10 | 50 | return fmt.Sprintf("Gtk reported an error with message: '%s', domain: '%v' and code: '%v'", e.MessageGo(), e.Domain, e.Code) | |
| 11 | 51 | } | |
A v4/glib/more_other.go +8 -0
| @@ -0,0 +1,8 @@ | |||
| 1 | + | //go:build !windows && !darwin && !freebsd && (!linux || (!amd64 && !arm64)) | |
| 2 | + | ||
| 3 | + | package glib | |
| 4 | + | ||
| 5 | + | // unrefCallback on unsupported on other platforms | |
| 6 | + | func unrefCallback(_ interface{}) error { | |
| 7 | + | panic("glib.UnrefCallback is unsupported on this platform") | |
| 8 | + | } | |
A v4/glib/more_sysv.go +31 -0
| @@ -0,0 +1,31 @@ | |||
| 1 | + | //go:build darwin || freebsd || (linux && (amd64 || arm64)) | |
| 2 | + | ||
| 3 | + | package glib | |
| 4 | + | ||
| 5 | + | import ( | |
| 6 | + | "fmt" | |
| 7 | + | "reflect" | |
| 8 | + | ||
| 9 | + | "github.com/jwijenbergh/purego" | |
| 10 | + | ) | |
| 11 | + | ||
| 12 | + | func unrefCallback(fnPtr interface{}) error { | |
| 13 | + | val := reflect.ValueOf(fnPtr) | |
| 14 | + | if val.IsNil() { | |
| 15 | + | return fmt.Errorf("function pointer must not be nil") | |
| 16 | + | } | |
| 17 | + | if val.Kind() != reflect.Ptr || val.Elem().Kind() != reflect.Func { | |
| 18 | + | return fmt.Errorf("type must be a function pointer") | |
| 19 | + | } | |
| 20 | + | cbPtr := reflect.ValueOf(fnPtr).Pointer() | |
| 21 | + | refPtr, ok := GetCallback(cbPtr) | |
| 22 | + | if !ok { | |
| 23 | + | return purego.UnrefCallbackFnPtr(fnPtr) | |
| 24 | + | } | |
| 25 | + | defer func() { | |
| 26 | + | callbacks.Lock() | |
| 27 | + | delete(callbacks.refs, cbPtr) | |
| 28 | + | callbacks.Unlock() | |
| 29 | + | }() | |
| 30 | + | return purego.UnrefCallback(refPtr) | |
| 31 | + | } | |
A v4/glib/more_windows.go +6 -0
| @@ -0,0 +1,6 @@ | |||
| 1 | + | package glib | |
| 2 | + | ||
| 3 | + | // unrefCallback on Windows is a NOOP. | |
| 4 | + | func unrefCallback(_ interface{}) error { | |
| 5 | + | return nil | |
| 6 | + | } | |
M v4/gobject/gboxed.go +3 -2
| @@ -4,6 +4,7 @@ package gobject | |||
| 4 | 4 | import ( | |
| 5 | 5 | "github.com/jwijenbergh/purego" | |
| 6 | 6 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 8 | ) | |
| 8 | 9 | ||
| 9 | 10 | // This function is provided by the user and should produce a copy | |
| @@ -43,9 +44,9 @@ var xBoxedTypeRegisterStatic func(string, uintptr, uintptr) []interface{} | |||
| 43 | 44 | // For the general case, it is recommended to use G_DEFINE_BOXED_TYPE() | |
| 44 | 45 | // instead of calling g_boxed_type_register_static() directly. The macro | |
| 45 | 46 | // will create the appropriate `*_get_type()` function for the boxed type. | |
| 46 | - | func BoxedTypeRegisterStatic(NameVar string, BoxedCopyVar BoxedCopyFunc, BoxedFreeVar BoxedFreeFunc) []interface{} { | |
| 47 | + | func BoxedTypeRegisterStatic(NameVar string, BoxedCopyVar *BoxedCopyFunc, BoxedFreeVar *BoxedFreeFunc) []interface{} { | |
| 47 | 48 | ||
| 48 | - | cret := xBoxedTypeRegisterStatic(NameVar, purego.NewCallback(BoxedCopyVar), purego.NewCallback(BoxedFreeVar)) | |
| 49 | + | cret := xBoxedTypeRegisterStatic(NameVar, glib.NewCallback(BoxedCopyVar), glib.NewCallback(BoxedFreeVar)) | |
| 49 | 50 | return cret | |
| 50 | 51 | } | |
| 51 | 52 | ||
M v4/gobject/gclosure.go +19 -18
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | ) | |
| 10 | 11 | ||
| 11 | 12 | // The type used for callback functions in structure definitions and function | |
| @@ -186,9 +187,9 @@ var xClosureAddFinalizeNotifier func(uintptr, uintptr, uintptr) | |||
| 186 | 187 | // unspecified order. If a single call to g_closure_unref() results in | |
| 187 | 188 | // the closure being both invalidated and finalized, then the invalidate | |
| 188 | 189 | // notifiers will be run before the finalize notifiers. | |
| 189 | - | func (x *Closure) AddFinalizeNotifier(NotifyDataVar uintptr, NotifyFuncVar ClosureNotify) { | |
| 190 | + | func (x *Closure) AddFinalizeNotifier(NotifyDataVar uintptr, NotifyFuncVar *ClosureNotify) { | |
| 190 | 191 | ||
| 191 | - | xClosureAddFinalizeNotifier(x.GoPointer(), NotifyDataVar, purego.NewCallback(NotifyFuncVar)) | |
| 192 | + | xClosureAddFinalizeNotifier(x.GoPointer(), NotifyDataVar, glib.NewCallback(NotifyFuncVar)) | |
| 192 | 193 | ||
| 193 | 194 | } | |
| 194 | 195 | ||
| @@ -199,9 +200,9 @@ var xClosureAddInvalidateNotifier func(uintptr, uintptr, uintptr) | |||
| 199 | 200 | // | |
| 200 | 201 | // Invalidation notifiers are invoked before finalization notifiers, | |
| 201 | 202 | // in an unspecified order. | |
| 202 | - | func (x *Closure) AddInvalidateNotifier(NotifyDataVar uintptr, NotifyFuncVar ClosureNotify) { | |
| 203 | + | func (x *Closure) AddInvalidateNotifier(NotifyDataVar uintptr, NotifyFuncVar *ClosureNotify) { | |
| 203 | 204 | ||
| 204 | - | xClosureAddInvalidateNotifier(x.GoPointer(), NotifyDataVar, purego.NewCallback(NotifyFuncVar)) | |
| 205 | + | xClosureAddInvalidateNotifier(x.GoPointer(), NotifyDataVar, glib.NewCallback(NotifyFuncVar)) | |
| 205 | 206 | ||
| 206 | 207 | } | |
| 207 | 208 | ||
| @@ -213,9 +214,9 @@ var xClosureAddMarshalGuards func(uintptr, uintptr, uintptr, uintptr, uintptr) | |||
| 213 | 214 | // This is typically used to protect the extra arguments for the | |
| 214 | 215 | // duration of the callback. See g_object_watch_closure() for an | |
| 215 | 216 | // example of marshal guards. | |
| 216 | - | func (x *Closure) AddMarshalGuards(PreMarshalDataVar uintptr, PreMarshalNotifyVar ClosureNotify, PostMarshalDataVar uintptr, PostMarshalNotifyVar ClosureNotify) { | |
| 217 | + | func (x *Closure) AddMarshalGuards(PreMarshalDataVar uintptr, PreMarshalNotifyVar *ClosureNotify, PostMarshalDataVar uintptr, PostMarshalNotifyVar *ClosureNotify) { | |
| 217 | 218 | ||
| 218 | - | xClosureAddMarshalGuards(x.GoPointer(), PreMarshalDataVar, purego.NewCallback(PreMarshalNotifyVar), PostMarshalDataVar, purego.NewCallback(PostMarshalNotifyVar)) | |
| 219 | + | xClosureAddMarshalGuards(x.GoPointer(), PreMarshalDataVar, glib.NewCallback(PreMarshalNotifyVar), PostMarshalDataVar, glib.NewCallback(PostMarshalNotifyVar)) | |
| 219 | 220 | ||
| 220 | 221 | } | |
| 221 | 222 | ||
| @@ -266,9 +267,9 @@ var xClosureRemoveFinalizeNotifier func(uintptr, uintptr, uintptr) | |||
| 266 | 267 | // Removes a finalization notifier. | |
| 267 | 268 | // | |
| 268 | 269 | // Notice that notifiers are automatically removed after they are run. | |
| 269 | - | func (x *Closure) RemoveFinalizeNotifier(NotifyDataVar uintptr, NotifyFuncVar ClosureNotify) { | |
| 270 | + | func (x *Closure) RemoveFinalizeNotifier(NotifyDataVar uintptr, NotifyFuncVar *ClosureNotify) { | |
| 270 | 271 | ||
| 271 | - | xClosureRemoveFinalizeNotifier(x.GoPointer(), NotifyDataVar, purego.NewCallback(NotifyFuncVar)) | |
| 272 | + | xClosureRemoveFinalizeNotifier(x.GoPointer(), NotifyDataVar, glib.NewCallback(NotifyFuncVar)) | |
| 272 | 273 | ||
| 273 | 274 | } | |
| 274 | 275 | ||
| @@ -277,9 +278,9 @@ var xClosureRemoveInvalidateNotifier func(uintptr, uintptr, uintptr) | |||
| 277 | 278 | // Removes an invalidation notifier. | |
| 278 | 279 | // | |
| 279 | 280 | // Notice that notifiers are automatically removed after they are run. | |
| 280 | - | func (x *Closure) RemoveInvalidateNotifier(NotifyDataVar uintptr, NotifyFuncVar ClosureNotify) { | |
| 281 | + | func (x *Closure) RemoveInvalidateNotifier(NotifyDataVar uintptr, NotifyFuncVar *ClosureNotify) { | |
| 281 | 282 | ||
| 282 | - | xClosureRemoveInvalidateNotifier(x.GoPointer(), NotifyDataVar, purego.NewCallback(NotifyFuncVar)) | |
| 283 | + | xClosureRemoveInvalidateNotifier(x.GoPointer(), NotifyDataVar, glib.NewCallback(NotifyFuncVar)) | |
| 283 | 284 | ||
| 284 | 285 | } | |
| 285 | 286 | ||
| @@ -295,9 +296,9 @@ var xClosureSetMarshal func(uintptr, uintptr) | |||
| 295 | 296 | // @closure->callback. | |
| 296 | 297 | // | |
| 297 | 298 | // See also: g_closure_set_meta_marshal() | |
| 298 | - | func (x *Closure) SetMarshal(MarshalVar ClosureMarshal) { | |
| 299 | + | func (x *Closure) SetMarshal(MarshalVar *ClosureMarshal) { | |
| 299 | 300 | ||
| 300 | - | xClosureSetMarshal(x.GoPointer(), purego.NewCallback(MarshalVar)) | |
| 301 | + | xClosureSetMarshal(x.GoPointer(), glib.NewCallback(MarshalVar)) | |
| 301 | 302 | ||
| 302 | 303 | } | |
| 303 | 304 | ||
| @@ -320,9 +321,9 @@ var xClosureSetMetaMarshal func(uintptr, uintptr, uintptr) | |||
| 320 | 321 | // fixed offset in the class structure. The meta marshaller retrieves | |
| 321 | 322 | // the right callback and passes it to the marshaller as the | |
| 322 | 323 | // @marshal_data argument. | |
| 323 | - | func (x *Closure) SetMetaMarshal(MarshalDataVar uintptr, MetaMarshalVar ClosureMarshal) { | |
| 324 | + | func (x *Closure) SetMetaMarshal(MarshalDataVar uintptr, MetaMarshalVar *ClosureMarshal) { | |
| 324 | 325 | ||
| 325 | - | xClosureSetMetaMarshal(x.GoPointer(), MarshalDataVar, purego.NewCallback(MetaMarshalVar)) | |
| 326 | + | xClosureSetMetaMarshal(x.GoPointer(), MarshalDataVar, glib.NewCallback(MetaMarshalVar)) | |
| 326 | 327 | ||
| 327 | 328 | } | |
| 328 | 329 | ||
| @@ -425,9 +426,9 @@ var xCclosureNew func(uintptr, uintptr, uintptr) *Closure | |||
| 425 | 426 | // the last parameter. | |
| 426 | 427 | // | |
| 427 | 428 | // @destroy_data will be called as a finalize notifier on the #GClosure. | |
| 428 | - | func CclosureNew(CallbackFuncVar Callback, UserDataVar uintptr, DestroyDataVar ClosureNotify) *Closure { | |
| 429 | + | func CclosureNew(CallbackFuncVar *Callback, UserDataVar uintptr, DestroyDataVar *ClosureNotify) *Closure { | |
| 429 | 430 | ||
| 430 | - | cret := xCclosureNew(purego.NewCallback(CallbackFuncVar), UserDataVar, purego.NewCallback(DestroyDataVar)) | |
| 431 | + | cret := xCclosureNew(glib.NewCallback(CallbackFuncVar), UserDataVar, glib.NewCallback(DestroyDataVar)) | |
| 431 | 432 | return cret | |
| 432 | 433 | } | |
| 433 | 434 | ||
| @@ -437,9 +438,9 @@ var xCclosureNewSwap func(uintptr, uintptr, uintptr) *Closure | |||
| 437 | 438 | // the first parameter. | |
| 438 | 439 | // | |
| 439 | 440 | // @destroy_data will be called as a finalize notifier on the #GClosure. | |
| 440 | - | func CclosureNewSwap(CallbackFuncVar Callback, UserDataVar uintptr, DestroyDataVar ClosureNotify) *Closure { | |
| 441 | + | func CclosureNewSwap(CallbackFuncVar *Callback, UserDataVar uintptr, DestroyDataVar *ClosureNotify) *Closure { | |
| 441 | 442 | ||
| 442 | - | cret := xCclosureNewSwap(purego.NewCallback(CallbackFuncVar), UserDataVar, purego.NewCallback(DestroyDataVar)) | |
| 443 | + | cret := xCclosureNewSwap(glib.NewCallback(CallbackFuncVar), UserDataVar, glib.NewCallback(DestroyDataVar)) | |
| 443 | 444 | return cret | |
| 444 | 445 | } | |
| 445 | 446 | ||
M v4/gobject/gobject-2.0.go +36 -18
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gobject | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -413,9 +415,9 @@ var xBindingGroupBindFull func(uintptr, string, uintptr, string, BindingFlags, u | |||
| 413 | 415 | // %G_BINDING_SYNC_CREATE is automatically specified. | |
| 414 | 416 | // | |
| 415 | 417 | // See g_object_bind_property_full() for more information. | |
| 416 | - | func (x *BindingGroup) BindFull(SourcePropertyVar string, TargetVar *Object, TargetPropertyVar string, FlagsVar BindingFlags, TransformToVar BindingTransformFunc, TransformFromVar BindingTransformFunc, UserDataVar uintptr, UserDataDestroyVar glib.DestroyNotify) { | |
| 418 | + | func (x *BindingGroup) BindFull(SourcePropertyVar string, TargetVar *Object, TargetPropertyVar string, FlagsVar BindingFlags, TransformToVar *BindingTransformFunc, TransformFromVar *BindingTransformFunc, UserDataVar uintptr, UserDataDestroyVar *glib.DestroyNotify) { | |
| 417 | 419 | ||
| 418 | - | xBindingGroupBindFull(x.GoPointer(), SourcePropertyVar, TargetVar.GoPointer(), TargetPropertyVar, FlagsVar, purego.NewCallback(TransformToVar), purego.NewCallback(TransformFromVar), UserDataVar, purego.NewCallback(UserDataDestroyVar)) | |
| 420 | + | xBindingGroupBindFull(x.GoPointer(), SourcePropertyVar, TargetVar.GoPointer(), TargetPropertyVar, FlagsVar, glib.NewCallback(TransformToVar), glib.NewCallback(TransformFromVar), UserDataVar, glib.NewCallback(UserDataDestroyVar)) | |
| 419 | 421 | ||
| 420 | 422 | } | |
| 421 | 423 | ||
| @@ -538,9 +540,9 @@ var xSignalGroupConnect func(uintptr, string, uintptr, uintptr) | |||
| 538 | 540 | // on the target instance of @self. | |
| 539 | 541 | // | |
| 540 | 542 | // You cannot connect a signal handler after #GSignalGroup:target has been set. | |
| 541 | - | func (x *SignalGroup) Connect(DetailedSignalVar string, CHandlerVar Callback, DataVar uintptr) { | |
| 543 | + | func (x *SignalGroup) Connect(DetailedSignalVar string, CHandlerVar *Callback, DataVar uintptr) { | |
| 542 | 544 | ||
| 543 | - | xSignalGroupConnect(x.GoPointer(), DetailedSignalVar, purego.NewCallback(CHandlerVar), DataVar) | |
| 545 | + | xSignalGroupConnect(x.GoPointer(), DetailedSignalVar, glib.NewCallback(CHandlerVar), DataVar) | |
| 544 | 546 | ||
| 545 | 547 | } | |
| 546 | 548 | ||
| @@ -552,9 +554,9 @@ var xSignalGroupConnectAfter func(uintptr, string, uintptr, uintptr) | |||
| 552 | 554 | // The @c_handler will be called after the default handler of the signal. | |
| 553 | 555 | // | |
| 554 | 556 | // You cannot connect a signal handler after #GSignalGroup:target has been set. | |
| 555 | - | func (x *SignalGroup) ConnectAfter(DetailedSignalVar string, CHandlerVar Callback, DataVar uintptr) { | |
| 557 | + | func (x *SignalGroup) ConnectAfter(DetailedSignalVar string, CHandlerVar *Callback, DataVar uintptr) { | |
| 556 | 558 | ||
| 557 | - | xSignalGroupConnectAfter(x.GoPointer(), DetailedSignalVar, purego.NewCallback(CHandlerVar), DataVar) | |
| 559 | + | xSignalGroupConnectAfter(x.GoPointer(), DetailedSignalVar, glib.NewCallback(CHandlerVar), DataVar) | |
| 558 | 560 | ||
| 559 | 561 | } | |
| 560 | 562 | ||
| @@ -564,9 +566,9 @@ var xSignalGroupConnectData func(uintptr, string, uintptr, uintptr, uintptr, Con | |||
| 564 | 566 | // on the target instance of @self. | |
| 565 | 567 | // | |
| 566 | 568 | // You cannot connect a signal handler after #GSignalGroup:target has been set. | |
| 567 | - | func (x *SignalGroup) ConnectData(DetailedSignalVar string, CHandlerVar Callback, DataVar uintptr, NotifyVar ClosureNotify, FlagsVar ConnectFlags) { | |
| 569 | + | func (x *SignalGroup) ConnectData(DetailedSignalVar string, CHandlerVar *Callback, DataVar uintptr, NotifyVar *ClosureNotify, FlagsVar ConnectFlags) { | |
| 568 | 570 | ||
| 569 | - | xSignalGroupConnectData(x.GoPointer(), DetailedSignalVar, purego.NewCallback(CHandlerVar), DataVar, purego.NewCallback(NotifyVar), FlagsVar) | |
| 571 | + | xSignalGroupConnectData(x.GoPointer(), DetailedSignalVar, glib.NewCallback(CHandlerVar), DataVar, glib.NewCallback(NotifyVar), FlagsVar) | |
| 570 | 572 | ||
| 571 | 573 | } | |
| 572 | 574 | ||
| @@ -579,9 +581,9 @@ var xSignalGroupConnectObject func(uintptr, string, uintptr, uintptr, ConnectFla | |||
| 579 | 581 | // the signal handler will automatically be removed. | |
| 580 | 582 | // | |
| 581 | 583 | // You cannot connect a signal handler after #GSignalGroup:target has been set. | |
| 582 | - | func (x *SignalGroup) ConnectObject(DetailedSignalVar string, CHandlerVar Callback, ObjectVar uintptr, FlagsVar ConnectFlags) { | |
| 584 | + | func (x *SignalGroup) ConnectObject(DetailedSignalVar string, CHandlerVar *Callback, ObjectVar uintptr, FlagsVar ConnectFlags) { | |
| 583 | 585 | ||
| 584 | - | xSignalGroupConnectObject(x.GoPointer(), DetailedSignalVar, purego.NewCallback(CHandlerVar), ObjectVar, FlagsVar) | |
| 586 | + | xSignalGroupConnectObject(x.GoPointer(), DetailedSignalVar, glib.NewCallback(CHandlerVar), ObjectVar, FlagsVar) | |
| 585 | 587 | ||
| 586 | 588 | } | |
| 587 | 589 | ||
| @@ -594,9 +596,9 @@ var xSignalGroupConnectSwapped func(uintptr, string, uintptr, uintptr) | |||
| 594 | 596 | // will be swapped when calling @c_handler. | |
| 595 | 597 | // | |
| 596 | 598 | // You cannot connect a signal handler after #GSignalGroup:target has been set. | |
| 597 | - | func (x *SignalGroup) ConnectSwapped(DetailedSignalVar string, CHandlerVar Callback, DataVar uintptr) { | |
| 599 | + | func (x *SignalGroup) ConnectSwapped(DetailedSignalVar string, CHandlerVar *Callback, DataVar uintptr) { | |
| 598 | 600 | ||
| 599 | - | xSignalGroupConnectSwapped(x.GoPointer(), DetailedSignalVar, purego.NewCallback(CHandlerVar), DataVar) | |
| 601 | + | xSignalGroupConnectSwapped(x.GoPointer(), DetailedSignalVar, glib.NewCallback(CHandlerVar), DataVar) | |
| 600 | 602 | ||
| 601 | 603 | } | |
| 602 | 604 | ||
| @@ -654,15 +656,23 @@ func (c *SignalGroup) SetGoPointer(ptr uintptr) { | |||
| 654 | 656 | // other than %NULL. It is similar to #GObject::notify on `target` except it | |
| 655 | 657 | // will not emit when #GSignalGroup:target is %NULL and also allows for | |
| 656 | 658 | // receiving the #GObject without a data-race. | |
| 657 | - | func (x *SignalGroup) ConnectBind(cb func(SignalGroup, uintptr)) uint32 { | |
| 659 | + | func (x *SignalGroup) ConnectBind(cb *func(SignalGroup, uintptr)) uint32 { | |
| 660 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 661 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 662 | + | return SignalConnect(x.GoPointer(), "bind", cbRefPtr) | |
| 663 | + | } | |
| 664 | + | ||
| 658 | 665 | fcb := func(clsPtr uintptr, InstanceVarp uintptr) { | |
| 659 | 666 | fa := SignalGroup{} | |
| 660 | 667 | fa.Ptr = clsPtr | |
| 668 | + | cbFn := *cb | |
| 661 | 669 | ||
| 662 | - | cb(fa, InstanceVarp) | |
| 670 | + | cbFn(fa, InstanceVarp) | |
| 663 | 671 | ||
| 664 | 672 | } | |
| 665 | - | return SignalConnect(x.GoPointer(), "bind", purego.NewCallback(fcb)) | |
| 673 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 674 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 675 | + | return SignalConnect(x.GoPointer(), "bind", cbRefPtr) | |
| 666 | 676 | } | |
| 667 | 677 | ||
| 668 | 678 | // This signal is emitted when the target instance of @self is set to a | |
| @@ -670,15 +680,23 @@ func (x *SignalGroup) ConnectBind(cb func(SignalGroup, uintptr)) uint32 { | |||
| 670 | 680 | // | |
| 671 | 681 | // This signal will only be emitted if the previous target of @self is | |
| 672 | 682 | // non-%NULL. | |
| 673 | - | func (x *SignalGroup) ConnectUnbind(cb func(SignalGroup)) uint32 { | |
| 683 | + | func (x *SignalGroup) ConnectUnbind(cb *func(SignalGroup)) uint32 { | |
| 684 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 685 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 686 | + | return SignalConnect(x.GoPointer(), "unbind", cbRefPtr) | |
| 687 | + | } | |
| 688 | + | ||
| 674 | 689 | fcb := func(clsPtr uintptr) { | |
| 675 | 690 | fa := SignalGroup{} | |
| 676 | 691 | fa.Ptr = clsPtr | |
| 692 | + | cbFn := *cb | |
| 677 | 693 | ||
| 678 | - | cb(fa) | |
| 694 | + | cbFn(fa) | |
| 679 | 695 | ||
| 680 | 696 | } | |
| 681 | - | return SignalConnect(x.GoPointer(), "unbind", purego.NewCallback(fcb)) | |
| 697 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 698 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 699 | + | return SignalConnect(x.GoPointer(), "unbind", cbRefPtr) | |
| 682 | 700 | } | |
| 683 | 701 | ||
| 684 | 702 | func init() { | |
M v4/gobject/gobject.go +39 -31
| @@ -354,9 +354,9 @@ var xCclosureNewObject func(uintptr, uintptr) *Closure | |||
| 354 | 354 | // closure. This function is useful when you have a callback closely | |
| 355 | 355 | // associated with a #GObject, and want the callback to no longer run | |
| 356 | 356 | // after the object is is freed. | |
| 357 | - | func CclosureNewObject(CallbackFuncVar Callback, ObjectVar *Object) *Closure { | |
| 357 | + | func CclosureNewObject(CallbackFuncVar *Callback, ObjectVar *Object) *Closure { | |
| 358 | 358 | ||
| 359 | - | cret := xCclosureNewObject(purego.NewCallback(CallbackFuncVar), ObjectVar.GoPointer()) | |
| 359 | + | cret := xCclosureNewObject(glib.NewCallback(CallbackFuncVar), ObjectVar.GoPointer()) | |
| 360 | 360 | return cret | |
| 361 | 361 | } | |
| 362 | 362 | ||
| @@ -367,9 +367,9 @@ var xCclosureNewObjectSwap func(uintptr, uintptr) *Closure | |||
| 367 | 367 | // closure. This function is useful when you have a callback closely | |
| 368 | 368 | // associated with a #GObject, and want the callback to no longer run | |
| 369 | 369 | // after the object is is freed. | |
| 370 | - | func CclosureNewObjectSwap(CallbackFuncVar Callback, ObjectVar *Object) *Closure { | |
| 370 | + | func CclosureNewObjectSwap(CallbackFuncVar *Callback, ObjectVar *Object) *Closure { | |
| 371 | 371 | ||
| 372 | - | cret := xCclosureNewObjectSwap(purego.NewCallback(CallbackFuncVar), ObjectVar.GoPointer()) | |
| 372 | + | cret := xCclosureNewObjectSwap(glib.NewCallback(CallbackFuncVar), ObjectVar.GoPointer()) | |
| 373 | 373 | return cret | |
| 374 | 374 | } | |
| 375 | 375 | ||
| @@ -401,9 +401,9 @@ var xSignalConnectObject func(*TypeInstance, string, uintptr, uintptr, ConnectFl | |||
| 401 | 401 | // disconnected. Note that this is not currently threadsafe (ie: | |
| 402 | 402 | // emitting a signal while @gobject is being destroyed in another thread | |
| 403 | 403 | // is not safe). | |
| 404 | - | func SignalConnectObject(InstanceVar *TypeInstance, DetailedSignalVar string, CHandlerVar Callback, GobjectVar *Object, ConnectFlagsVar ConnectFlags) uint32 { | |
| 404 | + | func SignalConnectObject(InstanceVar *TypeInstance, DetailedSignalVar string, CHandlerVar *Callback, GobjectVar *Object, ConnectFlagsVar ConnectFlags) uint32 { | |
| 405 | 405 | ||
| 406 | - | cret := xSignalConnectObject(InstanceVar, DetailedSignalVar, purego.NewCallback(CHandlerVar), GobjectVar.GoPointer(), ConnectFlagsVar) | |
| 406 | + | cret := xSignalConnectObject(InstanceVar, DetailedSignalVar, glib.NewCallback(CHandlerVar), GobjectVar.GoPointer(), ConnectFlagsVar) | |
| 407 | 407 | return cret | |
| 408 | 408 | } | |
| 409 | 409 | ||
| @@ -581,9 +581,9 @@ var xObjectAddToggleRef func(uintptr, uintptr, uintptr) | |||
| 581 | 581 | // of them will ever be notified until all but one are removed. For | |
| 582 | 582 | // this reason, you should only ever use a toggle reference if there | |
| 583 | 583 | // is important state in the proxy object. | |
| 584 | - | func (x *Object) AddToggleRef(NotifyVar ToggleNotify, DataVar uintptr) { | |
| 584 | + | func (x *Object) AddToggleRef(NotifyVar *ToggleNotify, DataVar uintptr) { | |
| 585 | 585 | ||
| 586 | - | xObjectAddToggleRef(x.GoPointer(), purego.NewCallback(NotifyVar), DataVar) | |
| 586 | + | xObjectAddToggleRef(x.GoPointer(), glib.NewCallback(NotifyVar), DataVar) | |
| 587 | 587 | ||
| 588 | 588 | } | |
| 589 | 589 | ||
| @@ -680,10 +680,10 @@ var xObjectBindPropertyFull func(uintptr, string, uintptr, string, BindingFlags, | |||
| 680 | 680 | // be called once, when the binding is removed. If you need different data | |
| 681 | 681 | // for each transformation function, please use | |
| 682 | 682 | // g_object_bind_property_with_closures() instead. | |
| 683 | - | func (x *Object) BindPropertyFull(SourcePropertyVar string, TargetVar *Object, TargetPropertyVar string, FlagsVar BindingFlags, TransformToVar BindingTransformFunc, TransformFromVar BindingTransformFunc, UserDataVar uintptr, NotifyVar glib.DestroyNotify) *Binding { | |
| 683 | + | func (x *Object) BindPropertyFull(SourcePropertyVar string, TargetVar *Object, TargetPropertyVar string, FlagsVar BindingFlags, TransformToVar *BindingTransformFunc, TransformFromVar *BindingTransformFunc, UserDataVar uintptr, NotifyVar *glib.DestroyNotify) *Binding { | |
| 684 | 684 | var cls *Binding | |
| 685 | 685 | ||
| 686 | - | cret := xObjectBindPropertyFull(x.GoPointer(), SourcePropertyVar, TargetVar.GoPointer(), TargetPropertyVar, FlagsVar, purego.NewCallback(TransformToVar), purego.NewCallback(TransformFromVar), UserDataVar, purego.NewCallback(NotifyVar)) | |
| 686 | + | cret := xObjectBindPropertyFull(x.GoPointer(), SourcePropertyVar, TargetVar.GoPointer(), TargetPropertyVar, FlagsVar, glib.NewCallback(TransformToVar), glib.NewCallback(TransformFromVar), UserDataVar, glib.NewCallback(NotifyVar)) | |
| 687 | 687 | ||
| 688 | 688 | if cret == 0 { | |
| 689 | 689 | return nil | |
| @@ -788,9 +788,9 @@ var xObjectDupData func(uintptr, string, uintptr, uintptr) uintptr | |||
| 788 | 788 | // This function can be useful to avoid races when multiple | |
| 789 | 789 | // threads are using object data on the same key on the same | |
| 790 | 790 | // object. | |
| 791 | - | func (x *Object) DupData(KeyVar string, DupFuncVar glib.DuplicateFunc, UserDataVar uintptr) uintptr { | |
| 791 | + | func (x *Object) DupData(KeyVar string, DupFuncVar *glib.DuplicateFunc, UserDataVar uintptr) uintptr { | |
| 792 | 792 | ||
| 793 | - | cret := xObjectDupData(x.GoPointer(), KeyVar, purego.NewCallback(DupFuncVar), UserDataVar) | |
| 793 | + | cret := xObjectDupData(x.GoPointer(), KeyVar, glib.NewCallback(DupFuncVar), UserDataVar) | |
| 794 | 794 | return cret | |
| 795 | 795 | } | |
| 796 | 796 | ||
| @@ -810,9 +810,9 @@ var xObjectDupQdata func(uintptr, glib.Quark, uintptr, uintptr) uintptr | |||
| 810 | 810 | // This function can be useful to avoid races when multiple | |
| 811 | 811 | // threads are using object data on the same key on the same | |
| 812 | 812 | // object. | |
| 813 | - | func (x *Object) DupQdata(QuarkVar glib.Quark, DupFuncVar glib.DuplicateFunc, UserDataVar uintptr) uintptr { | |
| 813 | + | func (x *Object) DupQdata(QuarkVar glib.Quark, DupFuncVar *glib.DuplicateFunc, UserDataVar uintptr) uintptr { | |
| 814 | 814 | ||
| 815 | - | cret := xObjectDupQdata(x.GoPointer(), QuarkVar, purego.NewCallback(DupFuncVar), UserDataVar) | |
| 815 | + | cret := xObjectDupQdata(x.GoPointer(), QuarkVar, glib.NewCallback(DupFuncVar), UserDataVar) | |
| 816 | 816 | return cret | |
| 817 | 817 | } | |
| 818 | 818 | ||
| @@ -1081,9 +1081,9 @@ var xObjectRemoveToggleRef func(uintptr, uintptr, uintptr) | |||
| 1081 | 1081 | ||
| 1082 | 1082 | // Removes a reference added with g_object_add_toggle_ref(). The | |
| 1083 | 1083 | // reference count of the object is decreased by one. | |
| 1084 | - | func (x *Object) RemoveToggleRef(NotifyVar ToggleNotify, DataVar uintptr) { | |
| 1084 | + | func (x *Object) RemoveToggleRef(NotifyVar *ToggleNotify, DataVar uintptr) { | |
| 1085 | 1085 | ||
| 1086 | - | xObjectRemoveToggleRef(x.GoPointer(), purego.NewCallback(NotifyVar), DataVar) | |
| 1086 | + | xObjectRemoveToggleRef(x.GoPointer(), glib.NewCallback(NotifyVar), DataVar) | |
| 1087 | 1087 | ||
| 1088 | 1088 | } | |
| 1089 | 1089 | ||
| @@ -1116,9 +1116,9 @@ var xObjectReplaceData func(uintptr, string, uintptr, uintptr, uintptr, uintptr) | |||
| 1116 | 1116 | // | |
| 1117 | 1117 | // See g_object_set_data() for guidance on using a small, bounded set of values | |
| 1118 | 1118 | // for @key. | |
| 1119 | - | func (x *Object) ReplaceData(KeyVar string, OldvalVar uintptr, NewvalVar uintptr, DestroyVar glib.DestroyNotify, OldDestroyVar glib.DestroyNotify) bool { | |
| 1119 | + | func (x *Object) ReplaceData(KeyVar string, OldvalVar uintptr, NewvalVar uintptr, DestroyVar *glib.DestroyNotify, OldDestroyVar *glib.DestroyNotify) bool { | |
| 1120 | 1120 | ||
| 1121 | - | cret := xObjectReplaceData(x.GoPointer(), KeyVar, OldvalVar, NewvalVar, purego.NewCallback(DestroyVar), purego.NewCallback(OldDestroyVar)) | |
| 1121 | + | cret := xObjectReplaceData(x.GoPointer(), KeyVar, OldvalVar, NewvalVar, glib.NewCallback(DestroyVar), glib.NewCallback(OldDestroyVar)) | |
| 1122 | 1122 | return cret | |
| 1123 | 1123 | } | |
| 1124 | 1124 | ||
| @@ -1137,9 +1137,9 @@ var xObjectReplaceQdata func(uintptr, glib.Quark, uintptr, uintptr, uintptr, uin | |||
| 1137 | 1137 | // It’s up to the caller to free this as needed, which may | |
| 1138 | 1138 | // or may not include using @old_destroy as sometimes replacement | |
| 1139 | 1139 | // should not destroy the object in the normal way. | |
| 1140 | - | func (x *Object) ReplaceQdata(QuarkVar glib.Quark, OldvalVar uintptr, NewvalVar uintptr, DestroyVar glib.DestroyNotify, OldDestroyVar glib.DestroyNotify) bool { | |
| 1140 | + | func (x *Object) ReplaceQdata(QuarkVar glib.Quark, OldvalVar uintptr, NewvalVar uintptr, DestroyVar *glib.DestroyNotify, OldDestroyVar *glib.DestroyNotify) bool { | |
| 1141 | 1141 | ||
| 1142 | - | cret := xObjectReplaceQdata(x.GoPointer(), QuarkVar, OldvalVar, NewvalVar, purego.NewCallback(DestroyVar), purego.NewCallback(OldDestroyVar)) | |
| 1142 | + | cret := xObjectReplaceQdata(x.GoPointer(), QuarkVar, OldvalVar, NewvalVar, glib.NewCallback(DestroyVar), glib.NewCallback(OldDestroyVar)) | |
| 1143 | 1143 | return cret | |
| 1144 | 1144 | } | |
| 1145 | 1145 | ||
| @@ -1198,9 +1198,9 @@ var xObjectSetDataFull func(uintptr, string, uintptr, uintptr) | |||
| 1198 | 1198 | // to a different value or when the object is destroyed. | |
| 1199 | 1199 | // | |
| 1200 | 1200 | // Note that the @destroy callback is not called if @data is %NULL. | |
| 1201 | - | func (x *Object) SetDataFull(KeyVar string, DataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 1201 | + | func (x *Object) SetDataFull(KeyVar string, DataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 1202 | 1202 | ||
| 1203 | - | xObjectSetDataFull(x.GoPointer(), KeyVar, DataVar, purego.NewCallback(DestroyVar)) | |
| 1203 | + | xObjectSetDataFull(x.GoPointer(), KeyVar, DataVar, glib.NewCallback(DestroyVar)) | |
| 1204 | 1204 | ||
| 1205 | 1205 | } | |
| 1206 | 1206 | ||
| @@ -1236,9 +1236,9 @@ var xObjectSetQdataFull func(uintptr, glib.Quark, uintptr, uintptr) | |||
| 1236 | 1236 | // called with @data as argument when the @object is finalized, or | |
| 1237 | 1237 | // the data is being overwritten by a call to g_object_set_qdata() | |
| 1238 | 1238 | // with the same @quark. | |
| 1239 | - | func (x *Object) SetQdataFull(QuarkVar glib.Quark, DataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 1239 | + | func (x *Object) SetQdataFull(QuarkVar glib.Quark, DataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 1240 | 1240 | ||
| 1241 | - | xObjectSetQdataFull(x.GoPointer(), QuarkVar, DataVar, purego.NewCallback(DestroyVar)) | |
| 1241 | + | xObjectSetQdataFull(x.GoPointer(), QuarkVar, DataVar, glib.NewCallback(DestroyVar)) | |
| 1242 | 1242 | ||
| 1243 | 1243 | } | |
| 1244 | 1244 | ||
| @@ -1432,18 +1432,18 @@ var xObjectWeakRef func(uintptr, uintptr, uintptr) | |||
| 1432 | 1432 | // thread-safe: they cannot safely be used in one thread if the | |
| 1433 | 1433 | // object's last g_object_unref() might happen in another thread. | |
| 1434 | 1434 | // Use #GWeakRef if thread-safety is required. | |
| 1435 | - | func (x *Object) WeakRef(NotifyVar WeakNotify, DataVar uintptr) { | |
| 1435 | + | func (x *Object) WeakRef(NotifyVar *WeakNotify, DataVar uintptr) { | |
| 1436 | 1436 | ||
| 1437 | - | xObjectWeakRef(x.GoPointer(), purego.NewCallback(NotifyVar), DataVar) | |
| 1437 | + | xObjectWeakRef(x.GoPointer(), glib.NewCallback(NotifyVar), DataVar) | |
| 1438 | 1438 | ||
| 1439 | 1439 | } | |
| 1440 | 1440 | ||
| 1441 | 1441 | var xObjectWeakUnref func(uintptr, uintptr, uintptr) | |
| 1442 | 1442 | ||
| 1443 | 1443 | // Removes a weak reference callback to an object. | |
| 1444 | - | func (x *Object) WeakUnref(NotifyVar WeakNotify, DataVar uintptr) { | |
| 1444 | + | func (x *Object) WeakUnref(NotifyVar *WeakNotify, DataVar uintptr) { | |
| 1445 | 1445 | ||
| 1446 | - | xObjectWeakUnref(x.GoPointer(), purego.NewCallback(NotifyVar), DataVar) | |
| 1446 | + | xObjectWeakUnref(x.GoPointer(), glib.NewCallback(NotifyVar), DataVar) | |
| 1447 | 1447 | ||
| 1448 | 1448 | } | |
| 1449 | 1449 | ||
| @@ -1482,15 +1482,23 @@ func (c *Object) SetGoPointer(ptr uintptr) { | |||
| 1482 | 1482 | // It is important to note that you must use | |
| 1483 | 1483 | // [canonical parameter names][canonical-parameter-names] as | |
| 1484 | 1484 | // detail strings for the notify signal. | |
| 1485 | - | func (x *Object) ConnectNotify(cb func(Object, uintptr)) uint32 { | |
| 1485 | + | func (x *Object) ConnectNotify(cb *func(Object, uintptr)) uint32 { | |
| 1486 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1487 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1488 | + | return SignalConnect(x.GoPointer(), "notify", cbRefPtr) | |
| 1489 | + | } | |
| 1490 | + | ||
| 1486 | 1491 | fcb := func(clsPtr uintptr, PspecVarp uintptr) { | |
| 1487 | 1492 | fa := Object{} | |
| 1488 | 1493 | fa.Ptr = clsPtr | |
| 1494 | + | cbFn := *cb | |
| 1489 | 1495 | ||
| 1490 | - | cb(fa, PspecVarp) | |
| 1496 | + | cbFn(fa, PspecVarp) | |
| 1491 | 1497 | ||
| 1492 | 1498 | } | |
| 1493 | - | return SignalConnect(x.GoPointer(), "notify", purego.NewCallback(fcb)) | |
| 1499 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1500 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1501 | + | return SignalConnect(x.GoPointer(), "notify", cbRefPtr) | |
| 1494 | 1502 | } | |
| 1495 | 1503 | ||
| 1496 | 1504 | var xObjectCompatControl func(uint, uintptr) uint | |
M v4/gobject/gparam.go +2 -2
| @@ -415,9 +415,9 @@ var xParamSpecSetQdataFull func(uintptr, glib.Quark, uintptr, uintptr) | |||
| 415 | 415 | // specified which is called with @data as argument when the @pspec is | |
| 416 | 416 | // finalized, or the data is being overwritten by a call to | |
| 417 | 417 | // g_param_spec_set_qdata() with the same @quark. | |
| 418 | - | func (x *ParamSpec) SetQdataFull(QuarkVar glib.Quark, DataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 418 | + | func (x *ParamSpec) SetQdataFull(QuarkVar glib.Quark, DataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 419 | 419 | ||
| 420 | - | xParamSpecSetQdataFull(x.GoPointer(), QuarkVar, DataVar, purego.NewCallback(DestroyVar)) | |
| 420 | + | xParamSpecSetQdataFull(x.GoPointer(), QuarkVar, DataVar, glib.NewCallback(DestroyVar)) | |
| 421 | 421 | ||
| 422 | 422 | } | |
| 423 | 423 | ||
M v4/gobject/gsignal.go +14 -14
| @@ -214,9 +214,9 @@ var xSignalAddEmissionHook func(uint, glib.Quark, uintptr, uintptr, uintptr) uin | |||
| 214 | 214 | // Adds an emission hook for a signal, which will get called for any emission | |
| 215 | 215 | // of that signal, independent of the instance. This is possible only | |
| 216 | 216 | // for signals which don't have %G_SIGNAL_NO_HOOKS flag set. | |
| 217 | - | func SignalAddEmissionHook(SignalIdVar uint, DetailVar glib.Quark, HookFuncVar SignalEmissionHook, HookDataVar uintptr, DataDestroyVar glib.DestroyNotify) uint32 { | |
| 217 | + | func SignalAddEmissionHook(SignalIdVar uint, DetailVar glib.Quark, HookFuncVar *SignalEmissionHook, HookDataVar uintptr, DataDestroyVar *glib.DestroyNotify) uint32 { | |
| 218 | 218 | ||
| 219 | - | cret := xSignalAddEmissionHook(SignalIdVar, DetailVar, purego.NewCallback(HookFuncVar), HookDataVar, purego.NewCallback(DataDestroyVar)) | |
| 219 | + | cret := xSignalAddEmissionHook(SignalIdVar, DetailVar, glib.NewCallback(HookFuncVar), HookDataVar, glib.NewCallback(DataDestroyVar)) | |
| 220 | 220 | return cret | |
| 221 | 221 | } | |
| 222 | 222 | ||
| @@ -269,9 +269,9 @@ var xSignalConnectData func(uintptr, string, uintptr, uintptr, uintptr, ConnectF | |||
| 269 | 269 | // which will be called when the signal handler is disconnected and no longer | |
| 270 | 270 | // used. Specify @connect_flags if you need `..._after()` or | |
| 271 | 271 | // `..._swapped()` variants of this function. | |
| 272 | - | func SignalConnectData(InstanceVar *Object, DetailedSignalVar string, CHandlerVar Callback, DataVar uintptr, DestroyDataVar ClosureNotify, ConnectFlagsVar ConnectFlags) uint32 { | |
| 272 | + | func SignalConnectData(InstanceVar *Object, DetailedSignalVar string, CHandlerVar *Callback, DataVar uintptr, DestroyDataVar *ClosureNotify, ConnectFlagsVar ConnectFlags) uint32 { | |
| 273 | 273 | ||
| 274 | - | cret := xSignalConnectData(InstanceVar.GoPointer(), DetailedSignalVar, purego.NewCallback(CHandlerVar), DataVar, purego.NewCallback(DestroyDataVar), ConnectFlagsVar) | |
| 274 | + | cret := xSignalConnectData(InstanceVar.GoPointer(), DetailedSignalVar, glib.NewCallback(CHandlerVar), DataVar, glib.NewCallback(DestroyDataVar), ConnectFlagsVar) | |
| 275 | 275 | return cret | |
| 276 | 276 | } | |
| 277 | 277 | ||
| @@ -572,9 +572,9 @@ var xSignalNew func(string, []interface{}, SignalFlags, uint, uintptr, uintptr, | |||
| 572 | 572 | // If @c_marshaller is non-%NULL, you need to also specify a va_marshaller | |
| 573 | 573 | // using g_signal_set_va_marshaller() or the generic va_marshaller will | |
| 574 | 574 | // be used. | |
| 575 | - | func SignalNew(SignalNameVar string, ItypeVar []interface{}, SignalFlagsVar SignalFlags, ClassOffsetVar uint, AccumulatorVar SignalAccumulator, AccuDataVar uintptr, CMarshallerVar SignalCMarshaller, ReturnTypeVar []interface{}, NParamsVar uint, varArgs ...interface{}) uint { | |
| 575 | + | func SignalNew(SignalNameVar string, ItypeVar []interface{}, SignalFlagsVar SignalFlags, ClassOffsetVar uint, AccumulatorVar *SignalAccumulator, AccuDataVar uintptr, CMarshallerVar SignalCMarshaller, ReturnTypeVar []interface{}, NParamsVar uint, varArgs ...interface{}) uint { | |
| 576 | 576 | ||
| 577 | - | cret := xSignalNew(SignalNameVar, ItypeVar, SignalFlagsVar, ClassOffsetVar, purego.NewCallback(AccumulatorVar), AccuDataVar, CMarshallerVar, ReturnTypeVar, NParamsVar, varArgs...) | |
| 577 | + | cret := xSignalNew(SignalNameVar, ItypeVar, SignalFlagsVar, ClassOffsetVar, glib.NewCallback(AccumulatorVar), AccuDataVar, CMarshallerVar, ReturnTypeVar, NParamsVar, varArgs...) | |
| 578 | 578 | return cret | |
| 579 | 579 | } | |
| 580 | 580 | ||
| @@ -596,9 +596,9 @@ var xSignalNewClassHandler func(string, []interface{}, SignalFlags, uintptr, uin | |||
| 596 | 596 | // | |
| 597 | 597 | // If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as | |
| 598 | 598 | // the marshaller for this signal. | |
| 599 | - | func SignalNewClassHandler(SignalNameVar string, ItypeVar []interface{}, SignalFlagsVar SignalFlags, ClassHandlerVar Callback, AccumulatorVar SignalAccumulator, AccuDataVar uintptr, CMarshallerVar SignalCMarshaller, ReturnTypeVar []interface{}, NParamsVar uint, varArgs ...interface{}) uint { | |
| 599 | + | func SignalNewClassHandler(SignalNameVar string, ItypeVar []interface{}, SignalFlagsVar SignalFlags, ClassHandlerVar *Callback, AccumulatorVar *SignalAccumulator, AccuDataVar uintptr, CMarshallerVar SignalCMarshaller, ReturnTypeVar []interface{}, NParamsVar uint, varArgs ...interface{}) uint { | |
| 600 | 600 | ||
| 601 | - | cret := xSignalNewClassHandler(SignalNameVar, ItypeVar, SignalFlagsVar, purego.NewCallback(ClassHandlerVar), purego.NewCallback(AccumulatorVar), AccuDataVar, CMarshallerVar, ReturnTypeVar, NParamsVar, varArgs...) | |
| 601 | + | cret := xSignalNewClassHandler(SignalNameVar, ItypeVar, SignalFlagsVar, glib.NewCallback(ClassHandlerVar), glib.NewCallback(AccumulatorVar), AccuDataVar, CMarshallerVar, ReturnTypeVar, NParamsVar, varArgs...) | |
| 602 | 602 | return cret | |
| 603 | 603 | } | |
| 604 | 604 | ||
| @@ -610,9 +610,9 @@ var xSignalNewValist func(string, []interface{}, SignalFlags, *Closure, uintptr, | |||
| 610 | 610 | // | |
| 611 | 611 | // If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as | |
| 612 | 612 | // the marshaller for this signal. | |
| 613 | - | func SignalNewValist(SignalNameVar string, ItypeVar []interface{}, SignalFlagsVar SignalFlags, ClassClosureVar *Closure, AccumulatorVar SignalAccumulator, AccuDataVar uintptr, CMarshallerVar SignalCMarshaller, ReturnTypeVar []interface{}, NParamsVar uint, ArgsVar []interface{}) uint { | |
| 613 | + | func SignalNewValist(SignalNameVar string, ItypeVar []interface{}, SignalFlagsVar SignalFlags, ClassClosureVar *Closure, AccumulatorVar *SignalAccumulator, AccuDataVar uintptr, CMarshallerVar SignalCMarshaller, ReturnTypeVar []interface{}, NParamsVar uint, ArgsVar []interface{}) uint { | |
| 614 | 614 | ||
| 615 | - | cret := xSignalNewValist(SignalNameVar, ItypeVar, SignalFlagsVar, ClassClosureVar, purego.NewCallback(AccumulatorVar), AccuDataVar, CMarshallerVar, ReturnTypeVar, NParamsVar, ArgsVar) | |
| 615 | + | cret := xSignalNewValist(SignalNameVar, ItypeVar, SignalFlagsVar, ClassClosureVar, glib.NewCallback(AccumulatorVar), AccuDataVar, CMarshallerVar, ReturnTypeVar, NParamsVar, ArgsVar) | |
| 616 | 616 | return cret | |
| 617 | 617 | } | |
| 618 | 618 | ||
| @@ -624,9 +624,9 @@ var xSignalNewv func(string, []interface{}, SignalFlags, *Closure, uintptr, uint | |||
| 624 | 624 | // | |
| 625 | 625 | // If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as | |
| 626 | 626 | // the marshaller for this signal. | |
| 627 | - | func SignalNewv(SignalNameVar string, ItypeVar []interface{}, SignalFlagsVar SignalFlags, ClassClosureVar *Closure, AccumulatorVar SignalAccumulator, AccuDataVar uintptr, CMarshallerVar SignalCMarshaller, ReturnTypeVar []interface{}, NParamsVar uint, ParamTypesVar uintptr) uint { | |
| 627 | + | func SignalNewv(SignalNameVar string, ItypeVar []interface{}, SignalFlagsVar SignalFlags, ClassClosureVar *Closure, AccumulatorVar *SignalAccumulator, AccuDataVar uintptr, CMarshallerVar SignalCMarshaller, ReturnTypeVar []interface{}, NParamsVar uint, ParamTypesVar uintptr) uint { | |
| 628 | 628 | ||
| 629 | - | cret := xSignalNewv(SignalNameVar, ItypeVar, SignalFlagsVar, ClassClosureVar, purego.NewCallback(AccumulatorVar), AccuDataVar, CMarshallerVar, ReturnTypeVar, NParamsVar, ParamTypesVar) | |
| 629 | + | cret := xSignalNewv(SignalNameVar, ItypeVar, SignalFlagsVar, ClassClosureVar, glib.NewCallback(AccumulatorVar), AccuDataVar, CMarshallerVar, ReturnTypeVar, NParamsVar, ParamTypesVar) | |
| 630 | 630 | return cret | |
| 631 | 631 | } | |
| 632 | 632 | ||
| @@ -655,9 +655,9 @@ var xSignalOverrideClassHandler func(string, []interface{}, uintptr) | |||
| 655 | 655 | // See g_signal_chain_from_overridden() and | |
| 656 | 656 | // g_signal_chain_from_overridden_handler() for how to chain up to the | |
| 657 | 657 | // parent class closure from inside the overridden one. | |
| 658 | - | func SignalOverrideClassHandler(SignalNameVar string, InstanceTypeVar []interface{}, ClassHandlerVar Callback) { | |
| 658 | + | func SignalOverrideClassHandler(SignalNameVar string, InstanceTypeVar []interface{}, ClassHandlerVar *Callback) { | |
| 659 | 659 | ||
| 660 | - | xSignalOverrideClassHandler(SignalNameVar, InstanceTypeVar, purego.NewCallback(ClassHandlerVar)) | |
| 660 | + | xSignalOverrideClassHandler(SignalNameVar, InstanceTypeVar, glib.NewCallback(ClassHandlerVar)) | |
| 661 | 661 | ||
| 662 | 662 | } | |
| 663 | 663 | ||
M v4/gobject/gtype.go +10 -10
| @@ -571,9 +571,9 @@ var xTypeAddClassCacheFunc func(uintptr, uintptr) | |||
| 571 | 571 | // passed in to figure whether they actually want to cache the class of this | |
| 572 | 572 | // type, since all classes are routed through the same #GTypeClassCacheFunc | |
| 573 | 573 | // chain. | |
| 574 | - | func TypeAddClassCacheFunc(CacheDataVar uintptr, CacheFuncVar TypeClassCacheFunc) { | |
| 574 | + | func TypeAddClassCacheFunc(CacheDataVar uintptr, CacheFuncVar *TypeClassCacheFunc) { | |
| 575 | 575 | ||
| 576 | - | xTypeAddClassCacheFunc(CacheDataVar, purego.NewCallback(CacheFuncVar)) | |
| 576 | + | xTypeAddClassCacheFunc(CacheDataVar, glib.NewCallback(CacheFuncVar)) | |
| 577 | 577 | ||
| 578 | 578 | } | |
| 579 | 579 | ||
| @@ -614,9 +614,9 @@ var xTypeAddInterfaceCheck func(uintptr, uintptr) | |||
| 614 | 614 | // implementation of #GObject uses this facility to check that an | |
| 615 | 615 | // object implements all of the properties that are defined on its | |
| 616 | 616 | // interfaces. | |
| 617 | - | func TypeAddInterfaceCheck(CheckDataVar uintptr, CheckFuncVar TypeInterfaceCheckFunc) { | |
| 617 | + | func TypeAddInterfaceCheck(CheckDataVar uintptr, CheckFuncVar *TypeInterfaceCheckFunc) { | |
| 618 | 618 | ||
| 619 | - | xTypeAddInterfaceCheck(CheckDataVar, purego.NewCallback(CheckFuncVar)) | |
| 619 | + | xTypeAddInterfaceCheck(CheckDataVar, glib.NewCallback(CheckFuncVar)) | |
| 620 | 620 | ||
| 621 | 621 | } | |
| 622 | 622 | ||
| @@ -1202,9 +1202,9 @@ var xTypeRegisterStaticSimple func([]interface{}, string, uint, uintptr, uint, u | |||
| 1202 | 1202 | // @parent_type. The value of @flags determines the nature (e.g. | |
| 1203 | 1203 | // abstract or not) of the type. It works by filling a #GTypeInfo | |
| 1204 | 1204 | // struct and calling g_type_register_static(). | |
| 1205 | - | func TypeRegisterStaticSimple(ParentTypeVar []interface{}, TypeNameVar string, ClassSizeVar uint, ClassInitVar ClassInitFunc, InstanceSizeVar uint, InstanceInitVar InstanceInitFunc, FlagsVar TypeFlags) []interface{} { | |
| 1205 | + | func TypeRegisterStaticSimple(ParentTypeVar []interface{}, TypeNameVar string, ClassSizeVar uint, ClassInitVar *ClassInitFunc, InstanceSizeVar uint, InstanceInitVar *InstanceInitFunc, FlagsVar TypeFlags) []interface{} { | |
| 1206 | 1206 | ||
| 1207 | - | cret := xTypeRegisterStaticSimple(ParentTypeVar, TypeNameVar, ClassSizeVar, purego.NewCallback(ClassInitVar), InstanceSizeVar, purego.NewCallback(InstanceInitVar), FlagsVar) | |
| 1207 | + | cret := xTypeRegisterStaticSimple(ParentTypeVar, TypeNameVar, ClassSizeVar, glib.NewCallback(ClassInitVar), InstanceSizeVar, glib.NewCallback(InstanceInitVar), FlagsVar) | |
| 1208 | 1208 | return cret | |
| 1209 | 1209 | } | |
| 1210 | 1210 | ||
| @@ -1213,9 +1213,9 @@ var xTypeRemoveClassCacheFunc func(uintptr, uintptr) | |||
| 1213 | 1213 | // Removes a previously installed #GTypeClassCacheFunc. The cache | |
| 1214 | 1214 | // maintained by @cache_func has to be empty when calling | |
| 1215 | 1215 | // g_type_remove_class_cache_func() to avoid leaks. | |
| 1216 | - | func TypeRemoveClassCacheFunc(CacheDataVar uintptr, CacheFuncVar TypeClassCacheFunc) { | |
| 1216 | + | func TypeRemoveClassCacheFunc(CacheDataVar uintptr, CacheFuncVar *TypeClassCacheFunc) { | |
| 1217 | 1217 | ||
| 1218 | - | xTypeRemoveClassCacheFunc(CacheDataVar, purego.NewCallback(CacheFuncVar)) | |
| 1218 | + | xTypeRemoveClassCacheFunc(CacheDataVar, glib.NewCallback(CacheFuncVar)) | |
| 1219 | 1219 | ||
| 1220 | 1220 | } | |
| 1221 | 1221 | ||
| @@ -1223,9 +1223,9 @@ var xTypeRemoveInterfaceCheck func(uintptr, uintptr) | |||
| 1223 | 1223 | ||
| 1224 | 1224 | // Removes an interface check function added with | |
| 1225 | 1225 | // g_type_add_interface_check(). | |
| 1226 | - | func TypeRemoveInterfaceCheck(CheckDataVar uintptr, CheckFuncVar TypeInterfaceCheckFunc) { | |
| 1226 | + | func TypeRemoveInterfaceCheck(CheckDataVar uintptr, CheckFuncVar *TypeInterfaceCheckFunc) { | |
| 1227 | 1227 | ||
| 1228 | - | xTypeRemoveInterfaceCheck(CheckDataVar, purego.NewCallback(CheckFuncVar)) | |
| 1228 | + | xTypeRemoveInterfaceCheck(CheckDataVar, glib.NewCallback(CheckFuncVar)) | |
| 1229 | 1229 | ||
| 1230 | 1230 | } | |
| 1231 | 1231 | ||
M v4/gobject/gvalue.go +2 -2
| @@ -765,9 +765,9 @@ var xValueRegisterTransformFunc func([]interface{}, []interface{}, uintptr) | |||
| 765 | 765 | // Registers a value transformation function for use in g_value_transform(). | |
| 766 | 766 | // A previously registered transformation function for @src_type and @dest_type | |
| 767 | 767 | // will be replaced. | |
| 768 | - | func ValueRegisterTransformFunc(SrcTypeVar []interface{}, DestTypeVar []interface{}, TransformFuncVar ValueTransform) { | |
| 768 | + | func ValueRegisterTransformFunc(SrcTypeVar []interface{}, DestTypeVar []interface{}, TransformFuncVar *ValueTransform) { | |
| 769 | 769 | ||
| 770 | - | xValueRegisterTransformFunc(SrcTypeVar, DestTypeVar, purego.NewCallback(TransformFuncVar)) | |
| 770 | + | xValueRegisterTransformFunc(SrcTypeVar, DestTypeVar, glib.NewCallback(TransformFuncVar)) | |
| 771 | 771 | ||
| 772 | 772 | } | |
| 773 | 773 | ||
M v4/gobject/gvaluearray.go +4 -4
| @@ -107,9 +107,9 @@ var xValueArraySort func(uintptr, uintptr) *ValueArray | |||
| 107 | 107 | // | |
| 108 | 108 | // The current implementation uses the same sorting algorithm as standard | |
| 109 | 109 | // C qsort() function. | |
| 110 | - | func (x *ValueArray) Sort(CompareFuncVar glib.CompareFunc) *ValueArray { | |
| 110 | + | func (x *ValueArray) Sort(CompareFuncVar *glib.CompareFunc) *ValueArray { | |
| 111 | 111 | ||
| 112 | - | cret := xValueArraySort(x.GoPointer(), purego.NewCallback(CompareFuncVar)) | |
| 112 | + | cret := xValueArraySort(x.GoPointer(), glib.NewCallback(CompareFuncVar)) | |
| 113 | 113 | return cret | |
| 114 | 114 | } | |
| 115 | 115 | ||
| @@ -120,9 +120,9 @@ var xValueArraySortWithData func(uintptr, uintptr, uintptr) *ValueArray | |||
| 120 | 120 | // | |
| 121 | 121 | // The current implementation uses the same sorting algorithm as standard | |
| 122 | 122 | // C qsort() function. | |
| 123 | - | func (x *ValueArray) SortWithData(CompareFuncVar glib.CompareDataFunc, UserDataVar uintptr) *ValueArray { | |
| 123 | + | func (x *ValueArray) SortWithData(CompareFuncVar *glib.CompareDataFunc, UserDataVar uintptr) *ValueArray { | |
| 124 | 124 | ||
| 125 | - | cret := xValueArraySortWithData(x.GoPointer(), purego.NewCallback(CompareFuncVar), UserDataVar) | |
| 125 | + | cret := xValueArraySortWithData(x.GoPointer(), glib.NewCallback(CompareFuncVar), UserDataVar) | |
| 126 | 126 | return cret | |
| 127 | 127 | } | |
| 128 | 128 | ||
M v4/gobject/more.go +3 -8
| @@ -3,7 +3,7 @@ package gobject | |||
| 3 | 3 | import ( | |
| 4 | 4 | "reflect" | |
| 5 | 5 | ||
| 6 | - | "github.com/jwijenbergh/purego" | |
| 6 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 7 | ) | |
| 8 | 8 | ||
| 9 | 9 | type Ptr interface { | |
| @@ -36,19 +36,14 @@ func (o Object) Cast(v Ptr) { | |||
| 36 | 36 | v.SetGoPointer(o.GoPointer()) | |
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | - | func (o Object) ConnectSignal(signal string, cb func()) uint32 { | |
| 40 | - | return SignalConnect(o.GoPointer(), signal, purego.NewCallback(cb)) | |
| 39 | + | func (o Object) ConnectSignal(signal string, cb *func()) uint32 { | |
| 40 | + | return SignalConnect(o.GoPointer(), signal, glib.NewCallback(cb)) | |
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | 43 | func (o Object) DisconnectSignal(handler uint32) { | |
| 44 | 44 | SignalHandlerDisconnect(&o, handler) | |
| 45 | 45 | } | |
| 46 | 46 | ||
| 47 | - | // NewCallback is an alias to purego.NewCallback | |
| 48 | - | func NewCallback(fn interface{}) uintptr { | |
| 49 | - | return purego.NewCallback(fn) | |
| 50 | - | } | |
| 51 | - | ||
| 52 | 47 | // types | |
| 53 | 48 | const ( | |
| 54 | 49 | TypeInvalidVal Type = 0 | |
M v4/gsk/gskrendernode.go +2 -2
| @@ -252,10 +252,10 @@ var xRenderNodeDeserialize func(*glib.Bytes, uintptr, uintptr) uintptr | |||
| 252 | 252 | // Loads data previously created via [method@Gsk.RenderNode.serialize]. | |
| 253 | 253 | // | |
| 254 | 254 | // For a discussion of the supported format, see that function. | |
| 255 | - | func RenderNodeDeserialize(BytesVar *glib.Bytes, ErrorFuncVar ParseErrorFunc, UserDataVar uintptr) *RenderNode { | |
| 255 | + | func RenderNodeDeserialize(BytesVar *glib.Bytes, ErrorFuncVar *ParseErrorFunc, UserDataVar uintptr) *RenderNode { | |
| 256 | 256 | var cls *RenderNode | |
| 257 | 257 | ||
| 258 | - | cret := xRenderNodeDeserialize(BytesVar, purego.NewCallback(ErrorFuncVar), UserDataVar) | |
| 258 | + | cret := xRenderNodeDeserialize(BytesVar, glib.NewCallback(ErrorFuncVar), UserDataVar) | |
| 259 | 259 | ||
| 260 | 260 | if cret == 0 { | |
| 261 | 261 | return nil | |
M v4/gtk/gtkaboutdialog.go +14 -3
| @@ -2,9 +2,12 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 12 | "github.com/jwijenbergh/puregotk/v4/gsk" | |
| 10 | 13 | ) | |
| @@ -508,15 +511,23 @@ func (c *AboutDialog) SetGoPointer(ptr uintptr) { | |||
| 508 | 511 | // | |
| 509 | 512 | // Applications may connect to it to override the default behaviour, | |
| 510 | 513 | // which is to call [func@Gtk.show_uri]. | |
| 511 | - | func (x *AboutDialog) ConnectActivateLink(cb func(AboutDialog, string) bool) uint32 { | |
| 514 | + | func (x *AboutDialog) ConnectActivateLink(cb *func(AboutDialog, string) bool) uint32 { | |
| 515 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 516 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 517 | + | return gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr) | |
| 518 | + | } | |
| 519 | + | ||
| 512 | 520 | fcb := func(clsPtr uintptr, UriVarp string) bool { | |
| 513 | 521 | fa := AboutDialog{} | |
| 514 | 522 | fa.Ptr = clsPtr | |
| 523 | + | cbFn := *cb | |
| 515 | 524 | ||
| 516 | - | return cb(fa, UriVarp) | |
| 525 | + | return cbFn(fa, UriVarp) | |
| 517 | 526 | ||
| 518 | 527 | } | |
| 519 | - | return gobject.SignalConnect(x.GoPointer(), "activate-link", purego.NewCallback(fcb)) | |
| 528 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 529 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 530 | + | return gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr) | |
| 520 | 531 | } | |
| 521 | 532 | ||
| 522 | 533 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkadjustment.go +23 -6
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -256,27 +257,43 @@ func (c *Adjustment) SetGoPointer(ptr uintptr) { | |||
| 256 | 257 | // | |
| 257 | 258 | // Note that the [property@Gtk.Adjustment:value] property is | |
| 258 | 259 | // covered by the [signal@Gtk.Adjustment::value-changed] signal. | |
| 259 | - | func (x *Adjustment) ConnectChanged(cb func(Adjustment)) uint32 { | |
| 260 | + | func (x *Adjustment) ConnectChanged(cb *func(Adjustment)) uint32 { | |
| 261 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 262 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 263 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 264 | + | } | |
| 265 | + | ||
| 260 | 266 | fcb := func(clsPtr uintptr) { | |
| 261 | 267 | fa := Adjustment{} | |
| 262 | 268 | fa.Ptr = clsPtr | |
| 269 | + | cbFn := *cb | |
| 263 | 270 | ||
| 264 | - | cb(fa) | |
| 271 | + | cbFn(fa) | |
| 265 | 272 | ||
| 266 | 273 | } | |
| 267 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 274 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 275 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 276 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 268 | 277 | } | |
| 269 | 278 | ||
| 270 | 279 | // Emitted when the value has been changed. | |
| 271 | - | func (x *Adjustment) ConnectValueChanged(cb func(Adjustment)) uint32 { | |
| 280 | + | func (x *Adjustment) ConnectValueChanged(cb *func(Adjustment)) uint32 { | |
| 281 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 282 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 283 | + | return gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr) | |
| 284 | + | } | |
| 285 | + | ||
| 272 | 286 | fcb := func(clsPtr uintptr) { | |
| 273 | 287 | fa := Adjustment{} | |
| 274 | 288 | fa.Ptr = clsPtr | |
| 289 | + | cbFn := *cb | |
| 275 | 290 | ||
| 276 | - | cb(fa) | |
| 291 | + | cbFn(fa) | |
| 277 | 292 | ||
| 278 | 293 | } | |
| 279 | - | return gobject.SignalConnect(x.GoPointer(), "value-changed", purego.NewCallback(fcb)) | |
| 294 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 295 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 296 | + | return gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr) | |
| 280 | 297 | } | |
| 281 | 298 | ||
| 282 | 299 | func init() { | |
M v4/gtk/gtkappchooserbutton.go +36 -9
| @@ -2,9 +2,12 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 12 | ) | |
| 10 | 13 | ||
| @@ -194,42 +197,66 @@ func (c *AppChooserButton) SetGoPointer(ptr uintptr) { | |||
| 194 | 197 | // | |
| 195 | 198 | // The `::activate` signal on `GtkAppChooserButton` is an action signal and | |
| 196 | 199 | // emitting it causes the button to pop up its dialog. | |
| 197 | - | func (x *AppChooserButton) ConnectActivate(cb func(AppChooserButton)) uint32 { | |
| 200 | + | func (x *AppChooserButton) ConnectActivate(cb *func(AppChooserButton)) uint32 { | |
| 201 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 202 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 203 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 204 | + | } | |
| 205 | + | ||
| 198 | 206 | fcb := func(clsPtr uintptr) { | |
| 199 | 207 | fa := AppChooserButton{} | |
| 200 | 208 | fa.Ptr = clsPtr | |
| 209 | + | cbFn := *cb | |
| 201 | 210 | ||
| 202 | - | cb(fa) | |
| 211 | + | cbFn(fa) | |
| 203 | 212 | ||
| 204 | 213 | } | |
| 205 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 214 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 215 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 216 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 206 | 217 | } | |
| 207 | 218 | ||
| 208 | 219 | // Emitted when the active application changes. | |
| 209 | - | func (x *AppChooserButton) ConnectChanged(cb func(AppChooserButton)) uint32 { | |
| 220 | + | func (x *AppChooserButton) ConnectChanged(cb *func(AppChooserButton)) uint32 { | |
| 221 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 222 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 223 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 224 | + | } | |
| 225 | + | ||
| 210 | 226 | fcb := func(clsPtr uintptr) { | |
| 211 | 227 | fa := AppChooserButton{} | |
| 212 | 228 | fa.Ptr = clsPtr | |
| 229 | + | cbFn := *cb | |
| 213 | 230 | ||
| 214 | - | cb(fa) | |
| 231 | + | cbFn(fa) | |
| 215 | 232 | ||
| 216 | 233 | } | |
| 217 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 234 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 235 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 236 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 218 | 237 | } | |
| 219 | 238 | ||
| 220 | 239 | // Emitted when a custom item is activated. | |
| 221 | 240 | // | |
| 222 | 241 | // Use [method@Gtk.AppChooserButton.append_custom_item], | |
| 223 | 242 | // to add custom items. | |
| 224 | - | func (x *AppChooserButton) ConnectCustomItemActivated(cb func(AppChooserButton, string)) uint32 { | |
| 243 | + | func (x *AppChooserButton) ConnectCustomItemActivated(cb *func(AppChooserButton, string)) uint32 { | |
| 244 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 245 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 246 | + | return gobject.SignalConnect(x.GoPointer(), "custom-item-activated", cbRefPtr) | |
| 247 | + | } | |
| 248 | + | ||
| 225 | 249 | fcb := func(clsPtr uintptr, ItemNameVarp string) { | |
| 226 | 250 | fa := AppChooserButton{} | |
| 227 | 251 | fa.Ptr = clsPtr | |
| 252 | + | cbFn := *cb | |
| 228 | 253 | ||
| 229 | - | cb(fa, ItemNameVarp) | |
| 254 | + | cbFn(fa, ItemNameVarp) | |
| 230 | 255 | ||
| 231 | 256 | } | |
| 232 | - | return gobject.SignalConnect(x.GoPointer(), "custom-item-activated", purego.NewCallback(fcb)) | |
| 257 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 258 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 259 | + | return gobject.SignalConnect(x.GoPointer(), "custom-item-activated", cbRefPtr) | |
| 233 | 260 | } | |
| 234 | 261 | ||
| 235 | 262 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkappchooserwidget.go +25 -6
| @@ -2,9 +2,12 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 12 | ) | |
| 10 | 13 | ||
| @@ -192,27 +195,43 @@ func (c *AppChooserWidget) SetGoPointer(ptr uintptr) { | |||
| 192 | 195 | // This usually happens when the user double clicks an item, or an item | |
| 193 | 196 | // is selected and the user presses one of the keys Space, Shift+Space, | |
| 194 | 197 | // Return or Enter. | |
| 195 | - | func (x *AppChooserWidget) ConnectApplicationActivated(cb func(AppChooserWidget, uintptr)) uint32 { | |
| 198 | + | func (x *AppChooserWidget) ConnectApplicationActivated(cb *func(AppChooserWidget, uintptr)) uint32 { | |
| 199 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 200 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 201 | + | return gobject.SignalConnect(x.GoPointer(), "application-activated", cbRefPtr) | |
| 202 | + | } | |
| 203 | + | ||
| 196 | 204 | fcb := func(clsPtr uintptr, ApplicationVarp uintptr) { | |
| 197 | 205 | fa := AppChooserWidget{} | |
| 198 | 206 | fa.Ptr = clsPtr | |
| 207 | + | cbFn := *cb | |
| 199 | 208 | ||
| 200 | - | cb(fa, ApplicationVarp) | |
| 209 | + | cbFn(fa, ApplicationVarp) | |
| 201 | 210 | ||
| 202 | 211 | } | |
| 203 | - | return gobject.SignalConnect(x.GoPointer(), "application-activated", purego.NewCallback(fcb)) | |
| 212 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 213 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 214 | + | return gobject.SignalConnect(x.GoPointer(), "application-activated", cbRefPtr) | |
| 204 | 215 | } | |
| 205 | 216 | ||
| 206 | 217 | // Emitted when an application item is selected from the widget's list. | |
| 207 | - | func (x *AppChooserWidget) ConnectApplicationSelected(cb func(AppChooserWidget, uintptr)) uint32 { | |
| 218 | + | func (x *AppChooserWidget) ConnectApplicationSelected(cb *func(AppChooserWidget, uintptr)) uint32 { | |
| 219 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 220 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 221 | + | return gobject.SignalConnect(x.GoPointer(), "application-selected", cbRefPtr) | |
| 222 | + | } | |
| 223 | + | ||
| 208 | 224 | fcb := func(clsPtr uintptr, ApplicationVarp uintptr) { | |
| 209 | 225 | fa := AppChooserWidget{} | |
| 210 | 226 | fa.Ptr = clsPtr | |
| 227 | + | cbFn := *cb | |
| 211 | 228 | ||
| 212 | - | cb(fa, ApplicationVarp) | |
| 229 | + | cbFn(fa, ApplicationVarp) | |
| 213 | 230 | ||
| 214 | 231 | } | |
| 215 | - | return gobject.SignalConnect(x.GoPointer(), "application-selected", purego.NewCallback(fcb)) | |
| 232 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 233 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 234 | + | return gobject.SignalConnect(x.GoPointer(), "application-selected", cbRefPtr) | |
| 216 | 235 | } | |
| 217 | 236 | ||
| 218 | 237 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkapplication.go +33 -9
| @@ -432,43 +432,67 @@ func (c *Application) SetGoPointer(ptr uintptr) { | |||
| 432 | 432 | // is `TRUE`. Applications can connect to this signal and call | |
| 433 | 433 | // [method@Gtk.Application.inhibit] with `GTK_APPLICATION_INHIBIT_LOGOUT` | |
| 434 | 434 | // to delay the end of the session until state has been saved. | |
| 435 | - | func (x *Application) ConnectQueryEnd(cb func(Application)) uint32 { | |
| 435 | + | func (x *Application) ConnectQueryEnd(cb *func(Application)) uint32 { | |
| 436 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 437 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 438 | + | return gobject.SignalConnect(x.GoPointer(), "query-end", cbRefPtr) | |
| 439 | + | } | |
| 440 | + | ||
| 436 | 441 | fcb := func(clsPtr uintptr) { | |
| 437 | 442 | fa := Application{} | |
| 438 | 443 | fa.Ptr = clsPtr | |
| 444 | + | cbFn := *cb | |
| 439 | 445 | ||
| 440 | - | cb(fa) | |
| 446 | + | cbFn(fa) | |
| 441 | 447 | ||
| 442 | 448 | } | |
| 443 | - | return gobject.SignalConnect(x.GoPointer(), "query-end", purego.NewCallback(fcb)) | |
| 449 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 450 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 451 | + | return gobject.SignalConnect(x.GoPointer(), "query-end", cbRefPtr) | |
| 444 | 452 | } | |
| 445 | 453 | ||
| 446 | 454 | // Emitted when a [class@Gtk.Window] is added to `application` through | |
| 447 | 455 | // [method@Gtk.Application.add_window]. | |
| 448 | - | func (x *Application) ConnectWindowAdded(cb func(Application, uintptr)) uint32 { | |
| 456 | + | func (x *Application) ConnectWindowAdded(cb *func(Application, uintptr)) uint32 { | |
| 457 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 458 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 459 | + | return gobject.SignalConnect(x.GoPointer(), "window-added", cbRefPtr) | |
| 460 | + | } | |
| 461 | + | ||
| 449 | 462 | fcb := func(clsPtr uintptr, WindowVarp uintptr) { | |
| 450 | 463 | fa := Application{} | |
| 451 | 464 | fa.Ptr = clsPtr | |
| 465 | + | cbFn := *cb | |
| 452 | 466 | ||
| 453 | - | cb(fa, WindowVarp) | |
| 467 | + | cbFn(fa, WindowVarp) | |
| 454 | 468 | ||
| 455 | 469 | } | |
| 456 | - | return gobject.SignalConnect(x.GoPointer(), "window-added", purego.NewCallback(fcb)) | |
| 470 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 471 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 472 | + | return gobject.SignalConnect(x.GoPointer(), "window-added", cbRefPtr) | |
| 457 | 473 | } | |
| 458 | 474 | ||
| 459 | 475 | // Emitted when a [class@Gtk.Window] is removed from `application`. | |
| 460 | 476 | // | |
| 461 | 477 | // This can happen as a side-effect of the window being destroyed | |
| 462 | 478 | // or explicitly through [method@Gtk.Application.remove_window]. | |
| 463 | - | func (x *Application) ConnectWindowRemoved(cb func(Application, uintptr)) uint32 { | |
| 479 | + | func (x *Application) ConnectWindowRemoved(cb *func(Application, uintptr)) uint32 { | |
| 480 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 481 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 482 | + | return gobject.SignalConnect(x.GoPointer(), "window-removed", cbRefPtr) | |
| 483 | + | } | |
| 484 | + | ||
| 464 | 485 | fcb := func(clsPtr uintptr, WindowVarp uintptr) { | |
| 465 | 486 | fa := Application{} | |
| 466 | 487 | fa.Ptr = clsPtr | |
| 488 | + | cbFn := *cb | |
| 467 | 489 | ||
| 468 | - | cb(fa, WindowVarp) | |
| 490 | + | cbFn(fa, WindowVarp) | |
| 469 | 491 | ||
| 470 | 492 | } | |
| 471 | - | return gobject.SignalConnect(x.GoPointer(), "window-removed", purego.NewCallback(fcb)) | |
| 493 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 494 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 495 | + | return gobject.SignalConnect(x.GoPointer(), "window-removed", cbRefPtr) | |
| 472 | 496 | } | |
| 473 | 497 | ||
| 474 | 498 | // Emits the #GActionGroup::action-added signal on @action_group. | |
M v4/gtk/gtkassistant.go +59 -17
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -338,9 +340,9 @@ var xAssistantSetForwardPageFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 338 | 340 | // Setting @page_func to %NULL will make the assistant to | |
| 339 | 341 | // use the default forward function, which just goes to the | |
| 340 | 342 | // next visible page. | |
| 341 | - | func (x *Assistant) SetForwardPageFunc(PageFuncVar AssistantPageFunc, DataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 343 | + | func (x *Assistant) SetForwardPageFunc(PageFuncVar *AssistantPageFunc, DataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 342 | 344 | ||
| 343 | - | xAssistantSetForwardPageFunc(x.GoPointer(), purego.NewCallback(PageFuncVar), DataVar, purego.NewCallback(DestroyVar)) | |
| 345 | + | xAssistantSetForwardPageFunc(x.GoPointer(), glib.NewCallback(PageFuncVar), DataVar, glib.NewCallback(DestroyVar)) | |
| 344 | 346 | ||
| 345 | 347 | } | |
| 346 | 348 | ||
| @@ -415,53 +417,85 @@ func (c *Assistant) SetGoPointer(ptr uintptr) { | |||
| 415 | 417 | // %GTK_ASSISTANT_PAGE_PROGRESS after the confirmation page and handle | |
| 416 | 418 | // this operation within the [signal@Gtk.Assistant::prepare] signal of | |
| 417 | 419 | // the progress page. | |
| 418 | - | func (x *Assistant) ConnectApply(cb func(Assistant)) uint32 { | |
| 420 | + | func (x *Assistant) ConnectApply(cb *func(Assistant)) uint32 { | |
| 421 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 422 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 423 | + | return gobject.SignalConnect(x.GoPointer(), "apply", cbRefPtr) | |
| 424 | + | } | |
| 425 | + | ||
| 419 | 426 | fcb := func(clsPtr uintptr) { | |
| 420 | 427 | fa := Assistant{} | |
| 421 | 428 | fa.Ptr = clsPtr | |
| 429 | + | cbFn := *cb | |
| 422 | 430 | ||
| 423 | - | cb(fa) | |
| 431 | + | cbFn(fa) | |
| 424 | 432 | ||
| 425 | 433 | } | |
| 426 | - | return gobject.SignalConnect(x.GoPointer(), "apply", purego.NewCallback(fcb)) | |
| 434 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 435 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 436 | + | return gobject.SignalConnect(x.GoPointer(), "apply", cbRefPtr) | |
| 427 | 437 | } | |
| 428 | 438 | ||
| 429 | 439 | // Emitted when then the cancel button is clicked. | |
| 430 | - | func (x *Assistant) ConnectCancel(cb func(Assistant)) uint32 { | |
| 440 | + | func (x *Assistant) ConnectCancel(cb *func(Assistant)) uint32 { | |
| 441 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 442 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 443 | + | return gobject.SignalConnect(x.GoPointer(), "cancel", cbRefPtr) | |
| 444 | + | } | |
| 445 | + | ||
| 431 | 446 | fcb := func(clsPtr uintptr) { | |
| 432 | 447 | fa := Assistant{} | |
| 433 | 448 | fa.Ptr = clsPtr | |
| 449 | + | cbFn := *cb | |
| 434 | 450 | ||
| 435 | - | cb(fa) | |
| 451 | + | cbFn(fa) | |
| 436 | 452 | ||
| 437 | 453 | } | |
| 438 | - | return gobject.SignalConnect(x.GoPointer(), "cancel", purego.NewCallback(fcb)) | |
| 454 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 455 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 456 | + | return gobject.SignalConnect(x.GoPointer(), "cancel", cbRefPtr) | |
| 439 | 457 | } | |
| 440 | 458 | ||
| 441 | 459 | // Emitted either when the close button of a summary page is clicked, | |
| 442 | 460 | // or when the apply button in the last page in the flow (of type | |
| 443 | 461 | // %GTK_ASSISTANT_PAGE_CONFIRM) is clicked. | |
| 444 | - | func (x *Assistant) ConnectClose(cb func(Assistant)) uint32 { | |
| 462 | + | func (x *Assistant) ConnectClose(cb *func(Assistant)) uint32 { | |
| 463 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 464 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 465 | + | return gobject.SignalConnect(x.GoPointer(), "close", cbRefPtr) | |
| 466 | + | } | |
| 467 | + | ||
| 445 | 468 | fcb := func(clsPtr uintptr) { | |
| 446 | 469 | fa := Assistant{} | |
| 447 | 470 | fa.Ptr = clsPtr | |
| 471 | + | cbFn := *cb | |
| 448 | 472 | ||
| 449 | - | cb(fa) | |
| 473 | + | cbFn(fa) | |
| 450 | 474 | ||
| 451 | 475 | } | |
| 452 | - | return gobject.SignalConnect(x.GoPointer(), "close", purego.NewCallback(fcb)) | |
| 476 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 477 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 478 | + | return gobject.SignalConnect(x.GoPointer(), "close", cbRefPtr) | |
| 453 | 479 | } | |
| 454 | 480 | ||
| 455 | 481 | // The action signal for the Escape binding. | |
| 456 | - | func (x *Assistant) ConnectEscape(cb func(Assistant)) uint32 { | |
| 482 | + | func (x *Assistant) ConnectEscape(cb *func(Assistant)) uint32 { | |
| 483 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 484 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 485 | + | return gobject.SignalConnect(x.GoPointer(), "escape", cbRefPtr) | |
| 486 | + | } | |
| 487 | + | ||
| 457 | 488 | fcb := func(clsPtr uintptr) { | |
| 458 | 489 | fa := Assistant{} | |
| 459 | 490 | fa.Ptr = clsPtr | |
| 491 | + | cbFn := *cb | |
| 460 | 492 | ||
| 461 | - | cb(fa) | |
| 493 | + | cbFn(fa) | |
| 462 | 494 | ||
| 463 | 495 | } | |
| 464 | - | return gobject.SignalConnect(x.GoPointer(), "escape", purego.NewCallback(fcb)) | |
| 496 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 497 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 498 | + | return gobject.SignalConnect(x.GoPointer(), "escape", cbRefPtr) | |
| 465 | 499 | } | |
| 466 | 500 | ||
| 467 | 501 | // Emitted when a new page is set as the assistant's current page, | |
| @@ -469,15 +503,23 @@ func (x *Assistant) ConnectEscape(cb func(Assistant)) uint32 { | |||
| 469 | 503 | // | |
| 470 | 504 | // A handler for this signal can do any preparations which are | |
| 471 | 505 | // necessary before showing @page. | |
| 472 | - | func (x *Assistant) ConnectPrepare(cb func(Assistant, uintptr)) uint32 { | |
| 506 | + | func (x *Assistant) ConnectPrepare(cb *func(Assistant, uintptr)) uint32 { | |
| 507 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 508 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 509 | + | return gobject.SignalConnect(x.GoPointer(), "prepare", cbRefPtr) | |
| 510 | + | } | |
| 511 | + | ||
| 473 | 512 | fcb := func(clsPtr uintptr, PageVarp uintptr) { | |
| 474 | 513 | fa := Assistant{} | |
| 475 | 514 | fa.Ptr = clsPtr | |
| 515 | + | cbFn := *cb | |
| 476 | 516 | ||
| 477 | - | cb(fa, PageVarp) | |
| 517 | + | cbFn(fa, PageVarp) | |
| 478 | 518 | ||
| 479 | 519 | } | |
| 480 | - | return gobject.SignalConnect(x.GoPointer(), "prepare", purego.NewCallback(fcb)) | |
| 520 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 521 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 522 | + | return gobject.SignalConnect(x.GoPointer(), "prepare", cbRefPtr) | |
| 481 | 523 | } | |
| 482 | 524 | ||
| 483 | 525 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkatcontext.go +12 -3
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -89,15 +90,23 @@ func (c *ATContext) SetGoPointer(ptr uintptr) { | |||
| 89 | 90 | ||
| 90 | 91 | // Emitted when the attributes of the accessible for the | |
| 91 | 92 | // `GtkATContext` instance change. | |
| 92 | - | func (x *ATContext) ConnectStateChange(cb func(ATContext)) uint32 { | |
| 93 | + | func (x *ATContext) ConnectStateChange(cb *func(ATContext)) uint32 { | |
| 94 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 95 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 96 | + | return gobject.SignalConnect(x.GoPointer(), "state-change", cbRefPtr) | |
| 97 | + | } | |
| 98 | + | ||
| 93 | 99 | fcb := func(clsPtr uintptr) { | |
| 94 | 100 | fa := ATContext{} | |
| 95 | 101 | fa.Ptr = clsPtr | |
| 102 | + | cbFn := *cb | |
| 96 | 103 | ||
| 97 | - | cb(fa) | |
| 104 | + | cbFn(fa) | |
| 98 | 105 | ||
| 99 | 106 | } | |
| 100 | - | return gobject.SignalConnect(x.GoPointer(), "state-change", purego.NewCallback(fcb)) | |
| 107 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 108 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 109 | + | return gobject.SignalConnect(x.GoPointer(), "state-change", cbRefPtr) | |
| 101 | 110 | } | |
| 102 | 111 | ||
| 103 | 112 | func init() { | |
M v4/gtk/gtkbuilderscope.go +5 -4
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -129,9 +130,9 @@ var xBuilderCScopeAddCallbackSymbol func(uintptr, string, uintptr) | |||
| 129 | 130 | // are added. Using this method allows for better encapsulation as it | |
| 130 | 131 | // does not require that callback symbols be declared in the global | |
| 131 | 132 | // namespace. | |
| 132 | - | func (x *BuilderCScope) AddCallbackSymbol(CallbackNameVar string, CallbackSymbolVar gobject.Callback) { | |
| 133 | + | func (x *BuilderCScope) AddCallbackSymbol(CallbackNameVar string, CallbackSymbolVar *gobject.Callback) { | |
| 133 | 134 | ||
| 134 | - | xBuilderCScopeAddCallbackSymbol(x.GoPointer(), CallbackNameVar, purego.NewCallback(CallbackSymbolVar)) | |
| 135 | + | xBuilderCScopeAddCallbackSymbol(x.GoPointer(), CallbackNameVar, glib.NewCallback(CallbackSymbolVar)) | |
| 135 | 136 | ||
| 136 | 137 | } | |
| 137 | 138 | ||
| @@ -141,9 +142,9 @@ var xBuilderCScopeAddCallbackSymbols func(uintptr, string, uintptr, ...interface | |||
| 141 | 142 | // | |
| 142 | 143 | // This is equivalent to calling [method@Gtk.BuilderCScope.add_callback_symbol] | |
| 143 | 144 | // for each symbol. | |
| 144 | - | func (x *BuilderCScope) AddCallbackSymbols(FirstCallbackNameVar string, FirstCallbackSymbolVar gobject.Callback, varArgs ...interface{}) { | |
| 145 | + | func (x *BuilderCScope) AddCallbackSymbols(FirstCallbackNameVar string, FirstCallbackSymbolVar *gobject.Callback, varArgs ...interface{}) { | |
| 145 | 146 | ||
| 146 | - | xBuilderCScopeAddCallbackSymbols(x.GoPointer(), FirstCallbackNameVar, purego.NewCallback(FirstCallbackSymbolVar), varArgs...) | |
| 147 | + | xBuilderCScopeAddCallbackSymbols(x.GoPointer(), FirstCallbackNameVar, glib.NewCallback(FirstCallbackSymbolVar), varArgs...) | |
| 147 | 148 | ||
| 148 | 149 | } | |
| 149 | 150 | ||
M v4/gtk/gtkbutton.go +22 -6
| @@ -282,27 +282,43 @@ func (c *Button) SetGoPointer(ptr uintptr) { | |||
| 282 | 282 | // | |
| 283 | 283 | // This is an action signal. Applications should never connect | |
| 284 | 284 | // to this signal, but use the [signal@Gtk.Button::clicked] signal. | |
| 285 | - | func (x *Button) ConnectActivate(cb func(Button)) uint32 { | |
| 285 | + | func (x *Button) ConnectActivate(cb *func(Button)) uint32 { | |
| 286 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 287 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 288 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 289 | + | } | |
| 290 | + | ||
| 286 | 291 | fcb := func(clsPtr uintptr) { | |
| 287 | 292 | fa := Button{} | |
| 288 | 293 | fa.Ptr = clsPtr | |
| 294 | + | cbFn := *cb | |
| 289 | 295 | ||
| 290 | - | cb(fa) | |
| 296 | + | cbFn(fa) | |
| 291 | 297 | ||
| 292 | 298 | } | |
| 293 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 299 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 300 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 301 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 294 | 302 | } | |
| 295 | 303 | ||
| 296 | 304 | // Emitted when the button has been activated (pressed and released). | |
| 297 | - | func (x *Button) ConnectClicked(cb func(Button)) uint32 { | |
| 305 | + | func (x *Button) ConnectClicked(cb *func(Button)) uint32 { | |
| 306 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 307 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 308 | + | return gobject.SignalConnect(x.GoPointer(), "clicked", cbRefPtr) | |
| 309 | + | } | |
| 310 | + | ||
| 298 | 311 | fcb := func(clsPtr uintptr) { | |
| 299 | 312 | fa := Button{} | |
| 300 | 313 | fa.Ptr = clsPtr | |
| 314 | + | cbFn := *cb | |
| 301 | 315 | ||
| 302 | - | cb(fa) | |
| 316 | + | cbFn(fa) | |
| 303 | 317 | ||
| 304 | 318 | } | |
| 305 | - | return gobject.SignalConnect(x.GoPointer(), "clicked", purego.NewCallback(fcb)) | |
| 319 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 320 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 321 | + | return gobject.SignalConnect(x.GoPointer(), "clicked", cbRefPtr) | |
| 306 | 322 | } | |
| 307 | 323 | ||
| 308 | 324 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkcalendar.go +57 -15
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -220,63 +222,103 @@ func (c *Calendar) SetGoPointer(ptr uintptr) { | |||
| 220 | 222 | } | |
| 221 | 223 | ||
| 222 | 224 | // Emitted when the user selects a day. | |
| 223 | - | func (x *Calendar) ConnectDaySelected(cb func(Calendar)) uint32 { | |
| 225 | + | func (x *Calendar) ConnectDaySelected(cb *func(Calendar)) uint32 { | |
| 226 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 227 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 228 | + | return gobject.SignalConnect(x.GoPointer(), "day-selected", cbRefPtr) | |
| 229 | + | } | |
| 230 | + | ||
| 224 | 231 | fcb := func(clsPtr uintptr) { | |
| 225 | 232 | fa := Calendar{} | |
| 226 | 233 | fa.Ptr = clsPtr | |
| 234 | + | cbFn := *cb | |
| 227 | 235 | ||
| 228 | - | cb(fa) | |
| 236 | + | cbFn(fa) | |
| 229 | 237 | ||
| 230 | 238 | } | |
| 231 | - | return gobject.SignalConnect(x.GoPointer(), "day-selected", purego.NewCallback(fcb)) | |
| 239 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 240 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 241 | + | return gobject.SignalConnect(x.GoPointer(), "day-selected", cbRefPtr) | |
| 232 | 242 | } | |
| 233 | 243 | ||
| 234 | 244 | // Emitted when the user switched to the next month. | |
| 235 | - | func (x *Calendar) ConnectNextMonth(cb func(Calendar)) uint32 { | |
| 245 | + | func (x *Calendar) ConnectNextMonth(cb *func(Calendar)) uint32 { | |
| 246 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 247 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 248 | + | return gobject.SignalConnect(x.GoPointer(), "next-month", cbRefPtr) | |
| 249 | + | } | |
| 250 | + | ||
| 236 | 251 | fcb := func(clsPtr uintptr) { | |
| 237 | 252 | fa := Calendar{} | |
| 238 | 253 | fa.Ptr = clsPtr | |
| 254 | + | cbFn := *cb | |
| 239 | 255 | ||
| 240 | - | cb(fa) | |
| 256 | + | cbFn(fa) | |
| 241 | 257 | ||
| 242 | 258 | } | |
| 243 | - | return gobject.SignalConnect(x.GoPointer(), "next-month", purego.NewCallback(fcb)) | |
| 259 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 260 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 261 | + | return gobject.SignalConnect(x.GoPointer(), "next-month", cbRefPtr) | |
| 244 | 262 | } | |
| 245 | 263 | ||
| 246 | 264 | // Emitted when user switched to the next year. | |
| 247 | - | func (x *Calendar) ConnectNextYear(cb func(Calendar)) uint32 { | |
| 265 | + | func (x *Calendar) ConnectNextYear(cb *func(Calendar)) uint32 { | |
| 266 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 267 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 268 | + | return gobject.SignalConnect(x.GoPointer(), "next-year", cbRefPtr) | |
| 269 | + | } | |
| 270 | + | ||
| 248 | 271 | fcb := func(clsPtr uintptr) { | |
| 249 | 272 | fa := Calendar{} | |
| 250 | 273 | fa.Ptr = clsPtr | |
| 274 | + | cbFn := *cb | |
| 251 | 275 | ||
| 252 | - | cb(fa) | |
| 276 | + | cbFn(fa) | |
| 253 | 277 | ||
| 254 | 278 | } | |
| 255 | - | return gobject.SignalConnect(x.GoPointer(), "next-year", purego.NewCallback(fcb)) | |
| 279 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 280 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 281 | + | return gobject.SignalConnect(x.GoPointer(), "next-year", cbRefPtr) | |
| 256 | 282 | } | |
| 257 | 283 | ||
| 258 | 284 | // Emitted when the user switched to the previous month. | |
| 259 | - | func (x *Calendar) ConnectPrevMonth(cb func(Calendar)) uint32 { | |
| 285 | + | func (x *Calendar) ConnectPrevMonth(cb *func(Calendar)) uint32 { | |
| 286 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 287 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 288 | + | return gobject.SignalConnect(x.GoPointer(), "prev-month", cbRefPtr) | |
| 289 | + | } | |
| 290 | + | ||
| 260 | 291 | fcb := func(clsPtr uintptr) { | |
| 261 | 292 | fa := Calendar{} | |
| 262 | 293 | fa.Ptr = clsPtr | |
| 294 | + | cbFn := *cb | |
| 263 | 295 | ||
| 264 | - | cb(fa) | |
| 296 | + | cbFn(fa) | |
| 265 | 297 | ||
| 266 | 298 | } | |
| 267 | - | return gobject.SignalConnect(x.GoPointer(), "prev-month", purego.NewCallback(fcb)) | |
| 299 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 300 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 301 | + | return gobject.SignalConnect(x.GoPointer(), "prev-month", cbRefPtr) | |
| 268 | 302 | } | |
| 269 | 303 | ||
| 270 | 304 | // Emitted when user switched to the previous year. | |
| 271 | - | func (x *Calendar) ConnectPrevYear(cb func(Calendar)) uint32 { | |
| 305 | + | func (x *Calendar) ConnectPrevYear(cb *func(Calendar)) uint32 { | |
| 306 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 307 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 308 | + | return gobject.SignalConnect(x.GoPointer(), "prev-year", cbRefPtr) | |
| 309 | + | } | |
| 310 | + | ||
| 272 | 311 | fcb := func(clsPtr uintptr) { | |
| 273 | 312 | fa := Calendar{} | |
| 274 | 313 | fa.Ptr = clsPtr | |
| 314 | + | cbFn := *cb | |
| 275 | 315 | ||
| 276 | - | cb(fa) | |
| 316 | + | cbFn(fa) | |
| 277 | 317 | ||
| 278 | 318 | } | |
| 279 | - | return gobject.SignalConnect(x.GoPointer(), "prev-year", purego.NewCallback(fcb)) | |
| 319 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 320 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 321 | + | return gobject.SignalConnect(x.GoPointer(), "prev-year", cbRefPtr) | |
| 280 | 322 | } | |
| 281 | 323 | ||
| 282 | 324 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkcellarea.go +50 -18
| @@ -624,9 +624,9 @@ func (x *CellArea) Focus(DirectionVar DirectionType) bool { | |||
| 624 | 624 | var xCellAreaForeach func(uintptr, uintptr, uintptr) | |
| 625 | 625 | ||
| 626 | 626 | // Calls @callback for every `GtkCellRenderer` in @area. | |
| 627 | - | func (x *CellArea) Foreach(CallbackVar CellCallback, CallbackDataVar uintptr) { | |
| 627 | + | func (x *CellArea) Foreach(CallbackVar *CellCallback, CallbackDataVar uintptr) { | |
| 628 | 628 | ||
| 629 | - | xCellAreaForeach(x.GoPointer(), purego.NewCallback(CallbackVar), CallbackDataVar) | |
| 629 | + | xCellAreaForeach(x.GoPointer(), glib.NewCallback(CallbackVar), CallbackDataVar) | |
| 630 | 630 | ||
| 631 | 631 | } | |
| 632 | 632 | ||
| @@ -634,9 +634,9 @@ var xCellAreaForeachAlloc func(uintptr, uintptr, uintptr, *gdk.Rectangle, *gdk.R | |||
| 634 | 634 | ||
| 635 | 635 | // Calls @callback for every `GtkCellRenderer` in @area with the | |
| 636 | 636 | // allocated rectangle inside @cell_area. | |
| 637 | - | func (x *CellArea) ForeachAlloc(ContextVar *CellAreaContext, WidgetVar *Widget, CellAreaVar *gdk.Rectangle, BackgroundAreaVar *gdk.Rectangle, CallbackVar CellAllocCallback, CallbackDataVar uintptr) { | |
| 637 | + | func (x *CellArea) ForeachAlloc(ContextVar *CellAreaContext, WidgetVar *Widget, CellAreaVar *gdk.Rectangle, BackgroundAreaVar *gdk.Rectangle, CallbackVar *CellAllocCallback, CallbackDataVar uintptr) { | |
| 638 | 638 | ||
| 639 | - | xCellAreaForeachAlloc(x.GoPointer(), ContextVar.GoPointer(), WidgetVar.GoPointer(), CellAreaVar, BackgroundAreaVar, purego.NewCallback(CallbackVar), CallbackDataVar) | |
| 639 | + | xCellAreaForeachAlloc(x.GoPointer(), ContextVar.GoPointer(), WidgetVar.GoPointer(), CellAreaVar, BackgroundAreaVar, glib.NewCallback(CallbackVar), CallbackDataVar) | |
| 640 | 640 | ||
| 641 | 641 | } | |
| 642 | 642 | ||
| @@ -972,27 +972,43 @@ func (c *CellArea) SetGoPointer(ptr uintptr) { | |||
| 972 | 972 | ||
| 973 | 973 | // Indicates that editing has started on @renderer and that @editable | |
| 974 | 974 | // should be added to the owning cell-layouting widget at @cell_area. | |
| 975 | - | func (x *CellArea) ConnectAddEditable(cb func(CellArea, uintptr, uintptr, uintptr, string)) uint32 { | |
| 975 | + | func (x *CellArea) ConnectAddEditable(cb *func(CellArea, uintptr, uintptr, uintptr, string)) uint32 { | |
| 976 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 977 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 978 | + | return gobject.SignalConnect(x.GoPointer(), "add-editable", cbRefPtr) | |
| 979 | + | } | |
| 980 | + | ||
| 976 | 981 | fcb := func(clsPtr uintptr, RendererVarp uintptr, EditableVarp uintptr, CellAreaVarp uintptr, PathVarp string) { | |
| 977 | 982 | fa := CellArea{} | |
| 978 | 983 | fa.Ptr = clsPtr | |
| 984 | + | cbFn := *cb | |
| 979 | 985 | ||
| 980 | - | cb(fa, RendererVarp, EditableVarp, CellAreaVarp, PathVarp) | |
| 986 | + | cbFn(fa, RendererVarp, EditableVarp, CellAreaVarp, PathVarp) | |
| 981 | 987 | ||
| 982 | 988 | } | |
| 983 | - | return gobject.SignalConnect(x.GoPointer(), "add-editable", purego.NewCallback(fcb)) | |
| 989 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 990 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 991 | + | return gobject.SignalConnect(x.GoPointer(), "add-editable", cbRefPtr) | |
| 984 | 992 | } | |
| 985 | 993 | ||
| 986 | 994 | // This signal is emitted whenever applying attributes to @area from @model | |
| 987 | - | func (x *CellArea) ConnectApplyAttributes(cb func(CellArea, uintptr, uintptr, bool, bool)) uint32 { | |
| 995 | + | func (x *CellArea) ConnectApplyAttributes(cb *func(CellArea, uintptr, uintptr, bool, bool)) uint32 { | |
| 996 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 997 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 998 | + | return gobject.SignalConnect(x.GoPointer(), "apply-attributes", cbRefPtr) | |
| 999 | + | } | |
| 1000 | + | ||
| 988 | 1001 | fcb := func(clsPtr uintptr, ModelVarp uintptr, IterVarp uintptr, IsExpanderVarp bool, IsExpandedVarp bool) { | |
| 989 | 1002 | fa := CellArea{} | |
| 990 | 1003 | fa.Ptr = clsPtr | |
| 1004 | + | cbFn := *cb | |
| 991 | 1005 | ||
| 992 | - | cb(fa, ModelVarp, IterVarp, IsExpanderVarp, IsExpandedVarp) | |
| 1006 | + | cbFn(fa, ModelVarp, IterVarp, IsExpanderVarp, IsExpandedVarp) | |
| 993 | 1007 | ||
| 994 | 1008 | } | |
| 995 | - | return gobject.SignalConnect(x.GoPointer(), "apply-attributes", purego.NewCallback(fcb)) | |
| 1009 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1010 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1011 | + | return gobject.SignalConnect(x.GoPointer(), "apply-attributes", cbRefPtr) | |
| 996 | 1012 | } | |
| 997 | 1013 | ||
| 998 | 1014 | // Indicates that focus changed on this @area. This signal | |
| @@ -1003,28 +1019,44 @@ func (x *CellArea) ConnectApplyAttributes(cb func(CellArea, uintptr, uintptr, bo | |||
| 1003 | 1019 | // currently focused renderer did not change, this is | |
| 1004 | 1020 | // because focus may change to the same renderer in the | |
| 1005 | 1021 | // same cell area for a different row of data. | |
| 1006 | - | func (x *CellArea) ConnectFocusChanged(cb func(CellArea, uintptr, string)) uint32 { | |
| 1022 | + | func (x *CellArea) ConnectFocusChanged(cb *func(CellArea, uintptr, string)) uint32 { | |
| 1023 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1024 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1025 | + | return gobject.SignalConnect(x.GoPointer(), "focus-changed", cbRefPtr) | |
| 1026 | + | } | |
| 1027 | + | ||
| 1007 | 1028 | fcb := func(clsPtr uintptr, RendererVarp uintptr, PathVarp string) { | |
| 1008 | 1029 | fa := CellArea{} | |
| 1009 | 1030 | fa.Ptr = clsPtr | |
| 1031 | + | cbFn := *cb | |
| 1010 | 1032 | ||
| 1011 | - | cb(fa, RendererVarp, PathVarp) | |
| 1033 | + | cbFn(fa, RendererVarp, PathVarp) | |
| 1012 | 1034 | ||
| 1013 | 1035 | } | |
| 1014 | - | return gobject.SignalConnect(x.GoPointer(), "focus-changed", purego.NewCallback(fcb)) | |
| 1036 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1037 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1038 | + | return gobject.SignalConnect(x.GoPointer(), "focus-changed", cbRefPtr) | |
| 1015 | 1039 | } | |
| 1016 | 1040 | ||
| 1017 | 1041 | // Indicates that editing finished on @renderer and that @editable | |
| 1018 | 1042 | // should be removed from the owning cell-layouting widget. | |
| 1019 | - | func (x *CellArea) ConnectRemoveEditable(cb func(CellArea, uintptr, uintptr)) uint32 { | |
| 1043 | + | func (x *CellArea) ConnectRemoveEditable(cb *func(CellArea, uintptr, uintptr)) uint32 { | |
| 1044 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1045 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1046 | + | return gobject.SignalConnect(x.GoPointer(), "remove-editable", cbRefPtr) | |
| 1047 | + | } | |
| 1048 | + | ||
| 1020 | 1049 | fcb := func(clsPtr uintptr, RendererVarp uintptr, EditableVarp uintptr) { | |
| 1021 | 1050 | fa := CellArea{} | |
| 1022 | 1051 | fa.Ptr = clsPtr | |
| 1052 | + | cbFn := *cb | |
| 1023 | 1053 | ||
| 1024 | - | cb(fa, RendererVarp, EditableVarp) | |
| 1054 | + | cbFn(fa, RendererVarp, EditableVarp) | |
| 1025 | 1055 | ||
| 1026 | 1056 | } | |
| 1027 | - | return gobject.SignalConnect(x.GoPointer(), "remove-editable", purego.NewCallback(fcb)) | |
| 1057 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1058 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1059 | + | return gobject.SignalConnect(x.GoPointer(), "remove-editable", cbRefPtr) | |
| 1028 | 1060 | } | |
| 1029 | 1061 | ||
| 1030 | 1062 | // Gets the ID of the @buildable object. | |
| @@ -1143,9 +1175,9 @@ func (x *CellArea) SetAttributes(CellVar *CellRenderer, varArgs ...interface{}) | |||
| 1143 | 1175 | // cell renderer(s) as appropriate. | |
| 1144 | 1176 | // | |
| 1145 | 1177 | // @func may be %NULL to remove a previously set function. | |
| 1146 | - | func (x *CellArea) SetCellDataFunc(CellVar *CellRenderer, FuncVar CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 1178 | + | func (x *CellArea) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 1147 | 1179 | ||
| 1148 | - | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(DestroyVar)) | |
| 1180 | + | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) | |
| 1149 | 1181 | ||
| 1150 | 1182 | } | |
| 1151 | 1183 | ||
M v4/gtk/gtkcellareabox.go +2 -2
| @@ -198,9 +198,9 @@ func (x *CellAreaBox) SetAttributes(CellVar *CellRenderer, varArgs ...interface{ | |||
| 198 | 198 | // cell renderer(s) as appropriate. | |
| 199 | 199 | // | |
| 200 | 200 | // @func may be %NULL to remove a previously set function. | |
| 201 | - | func (x *CellAreaBox) SetCellDataFunc(CellVar *CellRenderer, FuncVar CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 201 | + | func (x *CellAreaBox) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 202 | 202 | ||
| 203 | - | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(DestroyVar)) | |
| 203 | + | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) | |
| 204 | 204 | ||
| 205 | 205 | } | |
| 206 | 206 | ||
M v4/gtk/gtkcelllayout.go +3 -3
| @@ -151,7 +151,7 @@ type CellLayout interface { | |||
| 151 | 151 | PackStart(CellVar *CellRenderer, ExpandVar bool) | |
| 152 | 152 | Reorder(CellVar *CellRenderer, PositionVar int) | |
| 153 | 153 | SetAttributes(CellVar *CellRenderer, varArgs ...interface{}) | |
| 154 | - | SetCellDataFunc(CellVar *CellRenderer, FuncVar CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) | |
| 154 | + | SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) | |
| 155 | 155 | } | |
| 156 | 156 | type CellLayoutBase struct { | |
| 157 | 157 | Ptr uintptr | |
| @@ -271,9 +271,9 @@ func (x *CellLayoutBase) SetAttributes(CellVar *CellRenderer, varArgs ...interfa | |||
| 271 | 271 | // cell renderer(s) as appropriate. | |
| 272 | 272 | // | |
| 273 | 273 | // @func may be %NULL to remove a previously set function. | |
| 274 | - | func (x *CellLayoutBase) SetCellDataFunc(CellVar *CellRenderer, FuncVar CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 274 | + | func (x *CellLayoutBase) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 275 | 275 | ||
| 276 | - | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(DestroyVar)) | |
| 276 | + | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) | |
| 277 | 277 | ||
| 278 | 278 | } | |
| 279 | 279 | ||
M v4/gtk/gtkcellrenderer.go +23 -6
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -405,15 +406,23 @@ func (c *CellRenderer) SetGoPointer(ptr uintptr) { | |||
| 405 | 406 | // editing when the user presses Escape. | |
| 406 | 407 | // | |
| 407 | 408 | // See also: gtk_cell_renderer_stop_editing(). | |
| 408 | - | func (x *CellRenderer) ConnectEditingCanceled(cb func(CellRenderer)) uint32 { | |
| 409 | + | func (x *CellRenderer) ConnectEditingCanceled(cb *func(CellRenderer)) uint32 { | |
| 410 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 411 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 412 | + | return gobject.SignalConnect(x.GoPointer(), "editing-canceled", cbRefPtr) | |
| 413 | + | } | |
| 414 | + | ||
| 409 | 415 | fcb := func(clsPtr uintptr) { | |
| 410 | 416 | fa := CellRenderer{} | |
| 411 | 417 | fa.Ptr = clsPtr | |
| 418 | + | cbFn := *cb | |
| 412 | 419 | ||
| 413 | - | cb(fa) | |
| 420 | + | cbFn(fa) | |
| 414 | 421 | ||
| 415 | 422 | } | |
| 416 | - | return gobject.SignalConnect(x.GoPointer(), "editing-canceled", purego.NewCallback(fcb)) | |
| 423 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 424 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 425 | + | return gobject.SignalConnect(x.GoPointer(), "editing-canceled", cbRefPtr) | |
| 417 | 426 | } | |
| 418 | 427 | ||
| 419 | 428 | // This signal gets emitted when a cell starts to be edited. | |
| @@ -448,15 +457,23 @@ func (x *CellRenderer) ConnectEditingCanceled(cb func(CellRenderer)) uint32 { | |||
| 448 | 457 | // } | |
| 449 | 458 | // | |
| 450 | 459 | // ]| | |
| 451 | - | func (x *CellRenderer) ConnectEditingStarted(cb func(CellRenderer, uintptr, string)) uint32 { | |
| 460 | + | func (x *CellRenderer) ConnectEditingStarted(cb *func(CellRenderer, uintptr, string)) uint32 { | |
| 461 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 462 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 463 | + | return gobject.SignalConnect(x.GoPointer(), "editing-started", cbRefPtr) | |
| 464 | + | } | |
| 465 | + | ||
| 452 | 466 | fcb := func(clsPtr uintptr, EditableVarp uintptr, PathVarp string) { | |
| 453 | 467 | fa := CellRenderer{} | |
| 454 | 468 | fa.Ptr = clsPtr | |
| 469 | + | cbFn := *cb | |
| 455 | 470 | ||
| 456 | - | cb(fa, EditableVarp, PathVarp) | |
| 471 | + | cbFn(fa, EditableVarp, PathVarp) | |
| 457 | 472 | ||
| 458 | 473 | } | |
| 459 | - | return gobject.SignalConnect(x.GoPointer(), "editing-started", purego.NewCallback(fcb)) | |
| 474 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 475 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 476 | + | return gobject.SignalConnect(x.GoPointer(), "editing-started", cbRefPtr) | |
| 460 | 477 | } | |
| 461 | 478 | ||
| 462 | 479 | func init() { | |
M v4/gtk/gtkcellrendereraccel.go +25 -6
| @@ -2,9 +2,12 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 12 | ) | |
| 10 | 13 | ||
| @@ -60,27 +63,43 @@ func (c *CellRendererAccel) SetGoPointer(ptr uintptr) { | |||
| 60 | 63 | } | |
| 61 | 64 | ||
| 62 | 65 | // Gets emitted when the user has removed the accelerator. | |
| 63 | - | func (x *CellRendererAccel) ConnectAccelCleared(cb func(CellRendererAccel, string)) uint32 { | |
| 66 | + | func (x *CellRendererAccel) ConnectAccelCleared(cb *func(CellRendererAccel, string)) uint32 { | |
| 67 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 68 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 69 | + | return gobject.SignalConnect(x.GoPointer(), "accel-cleared", cbRefPtr) | |
| 70 | + | } | |
| 71 | + | ||
| 64 | 72 | fcb := func(clsPtr uintptr, PathStringVarp string) { | |
| 65 | 73 | fa := CellRendererAccel{} | |
| 66 | 74 | fa.Ptr = clsPtr | |
| 75 | + | cbFn := *cb | |
| 67 | 76 | ||
| 68 | - | cb(fa, PathStringVarp) | |
| 77 | + | cbFn(fa, PathStringVarp) | |
| 69 | 78 | ||
| 70 | 79 | } | |
| 71 | - | return gobject.SignalConnect(x.GoPointer(), "accel-cleared", purego.NewCallback(fcb)) | |
| 80 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 81 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 82 | + | return gobject.SignalConnect(x.GoPointer(), "accel-cleared", cbRefPtr) | |
| 72 | 83 | } | |
| 73 | 84 | ||
| 74 | 85 | // Gets emitted when the user has selected a new accelerator. | |
| 75 | - | func (x *CellRendererAccel) ConnectAccelEdited(cb func(CellRendererAccel, string, uint, gdk.ModifierType, uint)) uint32 { | |
| 86 | + | func (x *CellRendererAccel) ConnectAccelEdited(cb *func(CellRendererAccel, string, uint, gdk.ModifierType, uint)) uint32 { | |
| 87 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 88 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 89 | + | return gobject.SignalConnect(x.GoPointer(), "accel-edited", cbRefPtr) | |
| 90 | + | } | |
| 91 | + | ||
| 76 | 92 | fcb := func(clsPtr uintptr, PathStringVarp string, AccelKeyVarp uint, AccelModsVarp gdk.ModifierType, HardwareKeycodeVarp uint) { | |
| 77 | 93 | fa := CellRendererAccel{} | |
| 78 | 94 | fa.Ptr = clsPtr | |
| 95 | + | cbFn := *cb | |
| 79 | 96 | ||
| 80 | - | cb(fa, PathStringVarp, AccelKeyVarp, AccelModsVarp, HardwareKeycodeVarp) | |
| 97 | + | cbFn(fa, PathStringVarp, AccelKeyVarp, AccelModsVarp, HardwareKeycodeVarp) | |
| 81 | 98 | ||
| 82 | 99 | } | |
| 83 | - | return gobject.SignalConnect(x.GoPointer(), "accel-edited", purego.NewCallback(fcb)) | |
| 100 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 101 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 102 | + | return gobject.SignalConnect(x.GoPointer(), "accel-edited", cbRefPtr) | |
| 84 | 103 | } | |
| 85 | 104 | ||
| 86 | 105 | func init() { | |
M v4/gtk/gtkcellrenderercombo.go +14 -3
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -71,15 +74,23 @@ func (c *CellRendererCombo) SetGoPointer(ptr uintptr) { | |||
| 71 | 74 | // the tree view will immediately cease the editing operating. This | |
| 72 | 75 | // means that you most probably want to refrain from changing the model | |
| 73 | 76 | // until the combo cell renderer emits the edited or editing_canceled signal. | |
| 74 | - | func (x *CellRendererCombo) ConnectChanged(cb func(CellRendererCombo, string, uintptr)) uint32 { | |
| 77 | + | func (x *CellRendererCombo) ConnectChanged(cb *func(CellRendererCombo, string, uintptr)) uint32 { | |
| 78 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 79 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 80 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 81 | + | } | |
| 82 | + | ||
| 75 | 83 | fcb := func(clsPtr uintptr, PathStringVarp string, NewIterVarp uintptr) { | |
| 76 | 84 | fa := CellRendererCombo{} | |
| 77 | 85 | fa.Ptr = clsPtr | |
| 86 | + | cbFn := *cb | |
| 78 | 87 | ||
| 79 | - | cb(fa, PathStringVarp, NewIterVarp) | |
| 88 | + | cbFn(fa, PathStringVarp, NewIterVarp) | |
| 80 | 89 | ||
| 81 | 90 | } | |
| 82 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 91 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 92 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 93 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 83 | 94 | } | |
| 84 | 95 | ||
| 85 | 96 | func init() { | |
M v4/gtk/gtkcellrenderertext.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -87,15 +88,23 @@ func (c *CellRendererText) SetGoPointer(ptr uintptr) { | |||
| 87 | 88 | // | |
| 88 | 89 | // It is the responsibility of the application to update the model | |
| 89 | 90 | // and store @new_text at the position indicated by @path. | |
| 90 | - | func (x *CellRendererText) ConnectEdited(cb func(CellRendererText, string, string)) uint32 { | |
| 91 | + | func (x *CellRendererText) ConnectEdited(cb *func(CellRendererText, string, string)) uint32 { | |
| 92 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 93 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 94 | + | return gobject.SignalConnect(x.GoPointer(), "edited", cbRefPtr) | |
| 95 | + | } | |
| 96 | + | ||
| 91 | 97 | fcb := func(clsPtr uintptr, PathVarp string, NewTextVarp string) { | |
| 92 | 98 | fa := CellRendererText{} | |
| 93 | 99 | fa.Ptr = clsPtr | |
| 100 | + | cbFn := *cb | |
| 94 | 101 | ||
| 95 | - | cb(fa, PathVarp, NewTextVarp) | |
| 102 | + | cbFn(fa, PathVarp, NewTextVarp) | |
| 96 | 103 | ||
| 97 | 104 | } | |
| 98 | - | return gobject.SignalConnect(x.GoPointer(), "edited", purego.NewCallback(fcb)) | |
| 105 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 106 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 107 | + | return gobject.SignalConnect(x.GoPointer(), "edited", cbRefPtr) | |
| 99 | 108 | } | |
| 100 | 109 | ||
| 101 | 110 | func init() { | |
M v4/gtk/gtkcellrenderertoggle.go +14 -3
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -121,15 +124,23 @@ func (c *CellRendererToggle) SetGoPointer(ptr uintptr) { | |||
| 121 | 124 | // It is the responsibility of the application to update the model | |
| 122 | 125 | // with the correct value to store at @path. Often this is simply the | |
| 123 | 126 | // opposite of the value currently stored at @path. | |
| 124 | - | func (x *CellRendererToggle) ConnectToggled(cb func(CellRendererToggle, string)) uint32 { | |
| 127 | + | func (x *CellRendererToggle) ConnectToggled(cb *func(CellRendererToggle, string)) uint32 { | |
| 128 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 129 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 130 | + | return gobject.SignalConnect(x.GoPointer(), "toggled", cbRefPtr) | |
| 131 | + | } | |
| 132 | + | ||
| 125 | 133 | fcb := func(clsPtr uintptr, PathVarp string) { | |
| 126 | 134 | fa := CellRendererToggle{} | |
| 127 | 135 | fa.Ptr = clsPtr | |
| 136 | + | cbFn := *cb | |
| 128 | 137 | ||
| 129 | - | cb(fa, PathVarp) | |
| 138 | + | cbFn(fa, PathVarp) | |
| 130 | 139 | ||
| 131 | 140 | } | |
| 132 | - | return gobject.SignalConnect(x.GoPointer(), "toggled", purego.NewCallback(fcb)) | |
| 141 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 142 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 143 | + | return gobject.SignalConnect(x.GoPointer(), "toggled", cbRefPtr) | |
| 133 | 144 | } | |
| 134 | 145 | ||
| 135 | 146 | func init() { | |
M v4/gtk/gtkcellview.go +2 -2
| @@ -489,9 +489,9 @@ func (x *CellView) SetAttributes(CellVar *CellRenderer, varArgs ...interface{}) | |||
| 489 | 489 | // cell renderer(s) as appropriate. | |
| 490 | 490 | // | |
| 491 | 491 | // @func may be %NULL to remove a previously set function. | |
| 492 | - | func (x *CellView) SetCellDataFunc(CellVar *CellRenderer, FuncVar CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 492 | + | func (x *CellView) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 493 | 493 | ||
| 494 | - | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(DestroyVar)) | |
| 494 | + | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) | |
| 495 | 495 | ||
| 496 | 496 | } | |
| 497 | 497 | ||
M v4/gtk/gtkcheckbutton.go +22 -6
| @@ -286,28 +286,44 @@ func (c *CheckButton) SetGoPointer(ptr uintptr) { | |||
| 286 | 286 | // | |
| 287 | 287 | // Applications should never connect to this signal, but use the | |
| 288 | 288 | // [signal@Gtk.CheckButton::toggled] signal. | |
| 289 | - | func (x *CheckButton) ConnectActivate(cb func(CheckButton)) uint32 { | |
| 289 | + | func (x *CheckButton) ConnectActivate(cb *func(CheckButton)) uint32 { | |
| 290 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 291 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 292 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 293 | + | } | |
| 294 | + | ||
| 290 | 295 | fcb := func(clsPtr uintptr) { | |
| 291 | 296 | fa := CheckButton{} | |
| 292 | 297 | fa.Ptr = clsPtr | |
| 298 | + | cbFn := *cb | |
| 293 | 299 | ||
| 294 | - | cb(fa) | |
| 300 | + | cbFn(fa) | |
| 295 | 301 | ||
| 296 | 302 | } | |
| 297 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 303 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 304 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 305 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 298 | 306 | } | |
| 299 | 307 | ||
| 300 | 308 | // Emitted when the buttons's [property@Gtk.CheckButton:active] | |
| 301 | 309 | // property changes. | |
| 302 | - | func (x *CheckButton) ConnectToggled(cb func(CheckButton)) uint32 { | |
| 310 | + | func (x *CheckButton) ConnectToggled(cb *func(CheckButton)) uint32 { | |
| 311 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 312 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 313 | + | return gobject.SignalConnect(x.GoPointer(), "toggled", cbRefPtr) | |
| 314 | + | } | |
| 315 | + | ||
| 303 | 316 | fcb := func(clsPtr uintptr) { | |
| 304 | 317 | fa := CheckButton{} | |
| 305 | 318 | fa.Ptr = clsPtr | |
| 319 | + | cbFn := *cb | |
| 306 | 320 | ||
| 307 | - | cb(fa) | |
| 321 | + | cbFn(fa) | |
| 308 | 322 | ||
| 309 | 323 | } | |
| 310 | - | return gobject.SignalConnect(x.GoPointer(), "toggled", purego.NewCallback(fcb)) | |
| 324 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 325 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 326 | + | return gobject.SignalConnect(x.GoPointer(), "toggled", cbRefPtr) | |
| 311 | 327 | } | |
| 312 | 328 | ||
| 313 | 329 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkcolorbutton.go +25 -6
| @@ -2,9 +2,12 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 12 | ) | |
| 10 | 13 | ||
| @@ -126,15 +129,23 @@ func (c *ColorButton) SetGoPointer(ptr uintptr) { | |||
| 126 | 129 | // | |
| 127 | 130 | // The `::activate` signal on `GtkMenuButton` is an action signal and | |
| 128 | 131 | // emitting it causes the button to pop up its dialog. | |
| 129 | - | func (x *ColorButton) ConnectActivate(cb func(ColorButton)) uint32 { | |
| 132 | + | func (x *ColorButton) ConnectActivate(cb *func(ColorButton)) uint32 { | |
| 133 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 134 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 135 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 136 | + | } | |
| 137 | + | ||
| 130 | 138 | fcb := func(clsPtr uintptr) { | |
| 131 | 139 | fa := ColorButton{} | |
| 132 | 140 | fa.Ptr = clsPtr | |
| 141 | + | cbFn := *cb | |
| 133 | 142 | ||
| 134 | - | cb(fa) | |
| 143 | + | cbFn(fa) | |
| 135 | 144 | ||
| 136 | 145 | } | |
| 137 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 146 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 147 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 148 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 138 | 149 | } | |
| 139 | 150 | ||
| 140 | 151 | // Emitted when the user selects a color. | |
| @@ -145,15 +156,23 @@ func (x *ColorButton) ConnectActivate(cb func(ColorButton)) uint32 { | |||
| 145 | 156 | // Note that this signal is only emitted when the user changes the color. | |
| 146 | 157 | // If you need to react to programmatic color changes as well, use | |
| 147 | 158 | // the notify::rgba signal. | |
| 148 | - | func (x *ColorButton) ConnectColorSet(cb func(ColorButton)) uint32 { | |
| 159 | + | func (x *ColorButton) ConnectColorSet(cb *func(ColorButton)) uint32 { | |
| 160 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 161 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 162 | + | return gobject.SignalConnect(x.GoPointer(), "color-set", cbRefPtr) | |
| 163 | + | } | |
| 164 | + | ||
| 149 | 165 | fcb := func(clsPtr uintptr) { | |
| 150 | 166 | fa := ColorButton{} | |
| 151 | 167 | fa.Ptr = clsPtr | |
| 168 | + | cbFn := *cb | |
| 152 | 169 | ||
| 153 | - | cb(fa) | |
| 170 | + | cbFn(fa) | |
| 154 | 171 | ||
| 155 | 172 | } | |
| 156 | - | return gobject.SignalConnect(x.GoPointer(), "color-set", purego.NewCallback(fcb)) | |
| 173 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 174 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 175 | + | return gobject.SignalConnect(x.GoPointer(), "color-set", cbRefPtr) | |
| 157 | 176 | } | |
| 158 | 177 | ||
| 159 | 178 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkcolumnview.go +12 -3
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -355,15 +356,23 @@ func (c *ColumnView) SetGoPointer(ptr uintptr) { | |||
| 355 | 356 | // This allows for a convenient way to handle activation in a columnview. | |
| 356 | 357 | // See [method@Gtk.ListItem.set_activatable] for details on how to use this | |
| 357 | 358 | // signal. | |
| 358 | - | func (x *ColumnView) ConnectActivate(cb func(ColumnView, uint)) uint32 { | |
| 359 | + | func (x *ColumnView) ConnectActivate(cb *func(ColumnView, uint)) uint32 { | |
| 360 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 361 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 362 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 363 | + | } | |
| 364 | + | ||
| 359 | 365 | fcb := func(clsPtr uintptr, PositionVarp uint) { | |
| 360 | 366 | fa := ColumnView{} | |
| 361 | 367 | fa.Ptr = clsPtr | |
| 368 | + | cbFn := *cb | |
| 362 | 369 | ||
| 363 | - | cb(fa, PositionVarp) | |
| 370 | + | cbFn(fa, PositionVarp) | |
| 364 | 371 | ||
| 365 | 372 | } | |
| 366 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 373 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 374 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 375 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 367 | 376 | } | |
| 368 | 377 | ||
| 369 | 378 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkcombobox.go +70 -22
| @@ -465,9 +465,9 @@ var xComboBoxSetRowSeparatorFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 465 | 465 | // | |
| 466 | 466 | // If the row separator function is %NULL, no separators are drawn. | |
| 467 | 467 | // This is the default value. | |
| 468 | - | func (x *ComboBox) SetRowSeparatorFunc(FuncVar TreeViewRowSeparatorFunc, DataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 468 | + | func (x *ComboBox) SetRowSeparatorFunc(FuncVar *TreeViewRowSeparatorFunc, DataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 469 | 469 | ||
| 470 | - | xComboBoxSetRowSeparatorFunc(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyVar)) | |
| 470 | + | xComboBoxSetRowSeparatorFunc(x.GoPointer(), glib.NewCallback(FuncVar), DataVar, glib.NewCallback(DestroyVar)) | |
| 471 | 471 | ||
| 472 | 472 | } | |
| 473 | 473 | ||
| @@ -483,15 +483,23 @@ func (c *ComboBox) SetGoPointer(ptr uintptr) { | |||
| 483 | 483 | // | |
| 484 | 484 | // The `::activate` signal on `GtkComboBox` is an action signal and | |
| 485 | 485 | // emitting it causes the combo box to pop up its dropdown. | |
| 486 | - | func (x *ComboBox) ConnectActivate(cb func(ComboBox)) uint32 { | |
| 486 | + | func (x *ComboBox) ConnectActivate(cb *func(ComboBox)) uint32 { | |
| 487 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 488 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 489 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 490 | + | } | |
| 491 | + | ||
| 487 | 492 | fcb := func(clsPtr uintptr) { | |
| 488 | 493 | fa := ComboBox{} | |
| 489 | 494 | fa.Ptr = clsPtr | |
| 495 | + | cbFn := *cb | |
| 490 | 496 | ||
| 491 | - | cb(fa) | |
| 497 | + | cbFn(fa) | |
| 492 | 498 | ||
| 493 | 499 | } | |
| 494 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 500 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 501 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 502 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 495 | 503 | } | |
| 496 | 504 | ||
| 497 | 505 | // Emitted when the active item is changed. | |
| @@ -499,15 +507,23 @@ func (x *ComboBox) ConnectActivate(cb func(ComboBox)) uint32 { | |||
| 499 | 507 | // The can be due to the user selecting a different item from the list, | |
| 500 | 508 | // or due to a call to [method@Gtk.ComboBox.set_active_iter]. It will | |
| 501 | 509 | // also be emitted while typing into the entry of a combo box with an entry. | |
| 502 | - | func (x *ComboBox) ConnectChanged(cb func(ComboBox)) uint32 { | |
| 510 | + | func (x *ComboBox) ConnectChanged(cb *func(ComboBox)) uint32 { | |
| 511 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 512 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 513 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 514 | + | } | |
| 515 | + | ||
| 503 | 516 | fcb := func(clsPtr uintptr) { | |
| 504 | 517 | fa := ComboBox{} | |
| 505 | 518 | fa.Ptr = clsPtr | |
| 519 | + | cbFn := *cb | |
| 506 | 520 | ||
| 507 | - | cb(fa) | |
| 521 | + | cbFn(fa) | |
| 508 | 522 | ||
| 509 | 523 | } | |
| 510 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 524 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 525 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 526 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 511 | 527 | } | |
| 512 | 528 | ||
| 513 | 529 | // Emitted to allow changing how the text in a combo box's entry is displayed. | |
| @@ -544,29 +560,45 @@ func (x *ComboBox) ConnectChanged(cb func(ComboBox)) uint32 { | |||
| 544 | 560 | // } | |
| 545 | 561 | // | |
| 546 | 562 | // ``` | |
| 547 | - | func (x *ComboBox) ConnectFormatEntryText(cb func(ComboBox, string) string) uint32 { | |
| 563 | + | func (x *ComboBox) ConnectFormatEntryText(cb *func(ComboBox, string) string) uint32 { | |
| 564 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 565 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 566 | + | return gobject.SignalConnect(x.GoPointer(), "format-entry-text", cbRefPtr) | |
| 567 | + | } | |
| 568 | + | ||
| 548 | 569 | fcb := func(clsPtr uintptr, PathVarp string) string { | |
| 549 | 570 | fa := ComboBox{} | |
| 550 | 571 | fa.Ptr = clsPtr | |
| 572 | + | cbFn := *cb | |
| 551 | 573 | ||
| 552 | - | return cb(fa, PathVarp) | |
| 574 | + | return cbFn(fa, PathVarp) | |
| 553 | 575 | ||
| 554 | 576 | } | |
| 555 | - | return gobject.SignalConnect(x.GoPointer(), "format-entry-text", purego.NewCallback(fcb)) | |
| 577 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 578 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 579 | + | return gobject.SignalConnect(x.GoPointer(), "format-entry-text", cbRefPtr) | |
| 556 | 580 | } | |
| 557 | 581 | ||
| 558 | 582 | // Emitted to move the active selection. | |
| 559 | 583 | // | |
| 560 | 584 | // This is an [keybinding signal](class.SignalAction.html). | |
| 561 | - | func (x *ComboBox) ConnectMoveActive(cb func(ComboBox, ScrollType)) uint32 { | |
| 585 | + | func (x *ComboBox) ConnectMoveActive(cb *func(ComboBox, ScrollType)) uint32 { | |
| 586 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 587 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 588 | + | return gobject.SignalConnect(x.GoPointer(), "move-active", cbRefPtr) | |
| 589 | + | } | |
| 590 | + | ||
| 562 | 591 | fcb := func(clsPtr uintptr, ScrollTypeVarp ScrollType) { | |
| 563 | 592 | fa := ComboBox{} | |
| 564 | 593 | fa.Ptr = clsPtr | |
| 594 | + | cbFn := *cb | |
| 565 | 595 | ||
| 566 | - | cb(fa, ScrollTypeVarp) | |
| 596 | + | cbFn(fa, ScrollTypeVarp) | |
| 567 | 597 | ||
| 568 | 598 | } | |
| 569 | - | return gobject.SignalConnect(x.GoPointer(), "move-active", purego.NewCallback(fcb)) | |
| 599 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 600 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 601 | + | return gobject.SignalConnect(x.GoPointer(), "move-active", cbRefPtr) | |
| 570 | 602 | } | |
| 571 | 603 | ||
| 572 | 604 | // Emitted to popdown the combo box list. | |
| @@ -574,15 +606,23 @@ func (x *ComboBox) ConnectMoveActive(cb func(ComboBox, ScrollType)) uint32 { | |||
| 574 | 606 | // This is an [keybinding signal](class.SignalAction.html). | |
| 575 | 607 | // | |
| 576 | 608 | // The default bindings for this signal are Alt+Up and Escape. | |
| 577 | - | func (x *ComboBox) ConnectPopdown(cb func(ComboBox) bool) uint32 { | |
| 609 | + | func (x *ComboBox) ConnectPopdown(cb *func(ComboBox) bool) uint32 { | |
| 610 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 611 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 612 | + | return gobject.SignalConnect(x.GoPointer(), "popdown", cbRefPtr) | |
| 613 | + | } | |
| 614 | + | ||
| 578 | 615 | fcb := func(clsPtr uintptr) bool { | |
| 579 | 616 | fa := ComboBox{} | |
| 580 | 617 | fa.Ptr = clsPtr | |
| 618 | + | cbFn := *cb | |
| 581 | 619 | ||
| 582 | - | return cb(fa) | |
| 620 | + | return cbFn(fa) | |
| 583 | 621 | ||
| 584 | 622 | } | |
| 585 | - | return gobject.SignalConnect(x.GoPointer(), "popdown", purego.NewCallback(fcb)) | |
| 623 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 624 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 625 | + | return gobject.SignalConnect(x.GoPointer(), "popdown", cbRefPtr) | |
| 586 | 626 | } | |
| 587 | 627 | ||
| 588 | 628 | // Emitted to popup the combo box list. | |
| @@ -590,15 +630,23 @@ func (x *ComboBox) ConnectPopdown(cb func(ComboBox) bool) uint32 { | |||
| 590 | 630 | // This is an [keybinding signal](class.SignalAction.html). | |
| 591 | 631 | // | |
| 592 | 632 | // The default binding for this signal is Alt+Down. | |
| 593 | - | func (x *ComboBox) ConnectPopup(cb func(ComboBox)) uint32 { | |
| 633 | + | func (x *ComboBox) ConnectPopup(cb *func(ComboBox)) uint32 { | |
| 634 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 635 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 636 | + | return gobject.SignalConnect(x.GoPointer(), "popup", cbRefPtr) | |
| 637 | + | } | |
| 638 | + | ||
| 594 | 639 | fcb := func(clsPtr uintptr) { | |
| 595 | 640 | fa := ComboBox{} | |
| 596 | 641 | fa.Ptr = clsPtr | |
| 642 | + | cbFn := *cb | |
| 597 | 643 | ||
| 598 | - | cb(fa) | |
| 644 | + | cbFn(fa) | |
| 599 | 645 | ||
| 600 | 646 | } | |
| 601 | - | return gobject.SignalConnect(x.GoPointer(), "popup", purego.NewCallback(fcb)) | |
| 647 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 648 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 649 | + | return gobject.SignalConnect(x.GoPointer(), "popup", cbRefPtr) | |
| 602 | 650 | } | |
| 603 | 651 | ||
| 604 | 652 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
| @@ -880,9 +928,9 @@ func (x *ComboBox) SetAttributes(CellVar *CellRenderer, varArgs ...interface{}) | |||
| 880 | 928 | // cell renderer(s) as appropriate. | |
| 881 | 929 | // | |
| 882 | 930 | // @func may be %NULL to remove a previously set function. | |
| 883 | - | func (x *ComboBox) SetCellDataFunc(CellVar *CellRenderer, FuncVar CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 931 | + | func (x *ComboBox) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 884 | 932 | ||
| 885 | - | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(DestroyVar)) | |
| 933 | + | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) | |
| 886 | 934 | ||
| 887 | 935 | } | |
| 888 | 936 | ||
M v4/gtk/gtkcomboboxtext.go +2 -2
| @@ -511,9 +511,9 @@ func (x *ComboBoxText) SetAttributes(CellVar *CellRenderer, varArgs ...interface | |||
| 511 | 511 | // cell renderer(s) as appropriate. | |
| 512 | 512 | // | |
| 513 | 513 | // @func may be %NULL to remove a previously set function. | |
| 514 | - | func (x *ComboBoxText) SetCellDataFunc(CellVar *CellRenderer, FuncVar CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 514 | + | func (x *ComboBoxText) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 515 | 515 | ||
| 516 | - | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(DestroyVar)) | |
| 516 | + | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) | |
| 517 | 517 | ||
| 518 | 518 | } | |
| 519 | 519 | ||
M v4/gtk/gtkcssprovider.go +12 -3
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -173,15 +174,23 @@ func (c *CssProvider) SetGoPointer(ptr uintptr) { | |||
| 173 | 174 | // Note that this signal may be emitted at any time as the css provider | |
| 174 | 175 | // may opt to defer parsing parts or all of the input to a later time | |
| 175 | 176 | // than when a loading function was called. | |
| 176 | - | func (x *CssProvider) ConnectParsingError(cb func(CssProvider, uintptr, uintptr)) uint32 { | |
| 177 | + | func (x *CssProvider) ConnectParsingError(cb *func(CssProvider, uintptr, uintptr)) uint32 { | |
| 178 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 179 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 180 | + | return gobject.SignalConnect(x.GoPointer(), "parsing-error", cbRefPtr) | |
| 181 | + | } | |
| 182 | + | ||
| 177 | 183 | fcb := func(clsPtr uintptr, SectionVarp uintptr, ErrorVarp uintptr) { | |
| 178 | 184 | fa := CssProvider{} | |
| 179 | 185 | fa.Ptr = clsPtr | |
| 186 | + | cbFn := *cb | |
| 180 | 187 | ||
| 181 | - | cb(fa, SectionVarp, ErrorVarp) | |
| 188 | + | cbFn(fa, SectionVarp, ErrorVarp) | |
| 182 | 189 | ||
| 183 | 190 | } | |
| 184 | - | return gobject.SignalConnect(x.GoPointer(), "parsing-error", purego.NewCallback(fcb)) | |
| 191 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 192 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 193 | + | return gobject.SignalConnect(x.GoPointer(), "parsing-error", cbRefPtr) | |
| 185 | 194 | } | |
| 186 | 195 | ||
| 187 | 196 | func init() { | |
M v4/gtk/gtkcustomfilter.go +4 -4
| @@ -43,10 +43,10 @@ var xNewCustomFilter func(uintptr, uintptr, uintptr) uintptr | |||
| 43 | 43 | // | |
| 44 | 44 | // If the filter func changes its filtering behavior, | |
| 45 | 45 | // gtk_filter_changed() needs to be called. | |
| 46 | - | func NewCustomFilter(MatchFuncVar CustomFilterFunc, UserDataVar uintptr, UserDestroyVar glib.DestroyNotify) *CustomFilter { | |
| 46 | + | func NewCustomFilter(MatchFuncVar *CustomFilterFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) *CustomFilter { | |
| 47 | 47 | var cls *CustomFilter | |
| 48 | 48 | ||
| 49 | - | cret := xNewCustomFilter(purego.NewCallback(MatchFuncVar), UserDataVar, purego.NewCallback(UserDestroyVar)) | |
| 49 | + | cret := xNewCustomFilter(glib.NewCallback(MatchFuncVar), UserDataVar, glib.NewCallback(UserDestroyVar)) | |
| 50 | 50 | ||
| 51 | 51 | if cret == 0 { | |
| 52 | 52 | return nil | |
| @@ -67,9 +67,9 @@ var xCustomFilterSetFilterFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 67 | 67 | // | |
| 68 | 68 | // If a previous function was set, its @user_destroy will be | |
| 69 | 69 | // called now. | |
| 70 | - | func (x *CustomFilter) SetFilterFunc(MatchFuncVar CustomFilterFunc, UserDataVar uintptr, UserDestroyVar glib.DestroyNotify) { | |
| 70 | + | func (x *CustomFilter) SetFilterFunc(MatchFuncVar *CustomFilterFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) { | |
| 71 | 71 | ||
| 72 | - | xCustomFilterSetFilterFunc(x.GoPointer(), purego.NewCallback(MatchFuncVar), UserDataVar, purego.NewCallback(UserDestroyVar)) | |
| 72 | + | xCustomFilterSetFilterFunc(x.GoPointer(), glib.NewCallback(MatchFuncVar), UserDataVar, glib.NewCallback(UserDestroyVar)) | |
| 73 | 73 | ||
| 74 | 74 | } | |
| 75 | 75 | ||
M v4/gtk/gtkcustomlayout.go +3 -2
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | ) | |
| 10 | 11 | ||
| 11 | 12 | // A function to be used by `GtkCustomLayout` to allocate a widget. | |
| @@ -48,10 +49,10 @@ var xNewCustomLayout func(uintptr, uintptr, uintptr) uintptr | |||
| 48 | 49 | // Legacy layout managers map to the old `GtkWidget` size negotiation | |
| 49 | 50 | // virtual functions, and are meant to be used during the transition | |
| 50 | 51 | // from layout containers to layout manager delegates. | |
| 51 | - | func NewCustomLayout(RequestModeVar CustomRequestModeFunc, MeasureVar CustomMeasureFunc, AllocateVar CustomAllocateFunc) *CustomLayout { | |
| 52 | + | func NewCustomLayout(RequestModeVar *CustomRequestModeFunc, MeasureVar *CustomMeasureFunc, AllocateVar *CustomAllocateFunc) *CustomLayout { | |
| 52 | 53 | var cls *CustomLayout | |
| 53 | 54 | ||
| 54 | - | cret := xNewCustomLayout(purego.NewCallback(RequestModeVar), purego.NewCallback(MeasureVar), purego.NewCallback(AllocateVar)) | |
| 55 | + | cret := xNewCustomLayout(glib.NewCallback(RequestModeVar), glib.NewCallback(MeasureVar), glib.NewCallback(AllocateVar)) | |
| 55 | 56 | ||
| 56 | 57 | if cret == 0 { | |
| 57 | 58 | return nil | |
M v4/gtk/gtkcustomsorter.go +4 -4
| @@ -35,10 +35,10 @@ var xNewCustomSorter func(uintptr, uintptr, uintptr) uintptr | |||
| 35 | 35 | // @sort_func to compare items. | |
| 36 | 36 | // | |
| 37 | 37 | // If @sort_func is %NULL, all items are considered equal. | |
| 38 | - | func NewCustomSorter(SortFuncVar glib.CompareDataFunc, UserDataVar uintptr, UserDestroyVar glib.DestroyNotify) *CustomSorter { | |
| 38 | + | func NewCustomSorter(SortFuncVar *glib.CompareDataFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) *CustomSorter { | |
| 39 | 39 | var cls *CustomSorter | |
| 40 | 40 | ||
| 41 | - | cret := xNewCustomSorter(purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(UserDestroyVar)) | |
| 41 | + | cret := xNewCustomSorter(glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(UserDestroyVar)) | |
| 42 | 42 | ||
| 43 | 43 | if cret == 0 { | |
| 44 | 44 | return nil | |
| @@ -59,9 +59,9 @@ var xCustomSorterSetSortFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 59 | 59 | // | |
| 60 | 60 | // If a previous function was set, its @user_destroy will be | |
| 61 | 61 | // called now. | |
| 62 | - | func (x *CustomSorter) SetSortFunc(SortFuncVar glib.CompareDataFunc, UserDataVar uintptr, UserDestroyVar glib.DestroyNotify) { | |
| 62 | + | func (x *CustomSorter) SetSortFunc(SortFuncVar *glib.CompareDataFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) { | |
| 63 | 63 | ||
| 64 | - | xCustomSorterSetSortFunc(x.GoPointer(), purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(UserDestroyVar)) | |
| 64 | + | xCustomSorterSetSortFunc(x.GoPointer(), glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(UserDestroyVar)) | |
| 65 | 65 | ||
| 66 | 66 | } | |
| 67 | 67 | ||
M v4/gtk/gtkdialog.go +23 -6
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gsk" | |
| 12 | 13 | ) | |
| @@ -440,15 +441,23 @@ func (c *Dialog) SetGoPointer(ptr uintptr) { | |||
| 440 | 441 | // This is a [keybinding signal](class.SignalAction.html). | |
| 441 | 442 | // | |
| 442 | 443 | // The default binding for this signal is the Escape key. | |
| 443 | - | func (x *Dialog) ConnectClose(cb func(Dialog)) uint32 { | |
| 444 | + | func (x *Dialog) ConnectClose(cb *func(Dialog)) uint32 { | |
| 445 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 446 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 447 | + | return gobject.SignalConnect(x.GoPointer(), "close", cbRefPtr) | |
| 448 | + | } | |
| 449 | + | ||
| 444 | 450 | fcb := func(clsPtr uintptr) { | |
| 445 | 451 | fa := Dialog{} | |
| 446 | 452 | fa.Ptr = clsPtr | |
| 453 | + | cbFn := *cb | |
| 447 | 454 | ||
| 448 | - | cb(fa) | |
| 455 | + | cbFn(fa) | |
| 449 | 456 | ||
| 450 | 457 | } | |
| 451 | - | return gobject.SignalConnect(x.GoPointer(), "close", purego.NewCallback(fcb)) | |
| 458 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 459 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 460 | + | return gobject.SignalConnect(x.GoPointer(), "close", cbRefPtr) | |
| 452 | 461 | } | |
| 453 | 462 | ||
| 454 | 463 | // Emitted when an action widget is clicked. | |
| @@ -457,15 +466,23 @@ func (x *Dialog) ConnectClose(cb func(Dialog)) uint32 { | |||
| 457 | 466 | // delete event, and when [method@Gtk.Dialog.response] is called. | |
| 458 | 467 | // On a delete event, the response ID is %GTK_RESPONSE_DELETE_EVENT. | |
| 459 | 468 | // Otherwise, it depends on which action widget was clicked. | |
| 460 | - | func (x *Dialog) ConnectResponse(cb func(Dialog, int)) uint32 { | |
| 469 | + | func (x *Dialog) ConnectResponse(cb *func(Dialog, int)) uint32 { | |
| 470 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 471 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 472 | + | return gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr) | |
| 473 | + | } | |
| 474 | + | ||
| 461 | 475 | fcb := func(clsPtr uintptr, ResponseIdVarp int) { | |
| 462 | 476 | fa := Dialog{} | |
| 463 | 477 | fa.Ptr = clsPtr | |
| 478 | + | cbFn := *cb | |
| 464 | 479 | ||
| 465 | - | cb(fa, ResponseIdVarp) | |
| 480 | + | cbFn(fa, ResponseIdVarp) | |
| 466 | 481 | ||
| 467 | 482 | } | |
| 468 | - | return gobject.SignalConnect(x.GoPointer(), "response", purego.NewCallback(fcb)) | |
| 483 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 484 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 485 | + | return gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr) | |
| 469 | 486 | } | |
| 470 | 487 | ||
| 471 | 488 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkdragsource.go +45 -12
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -244,15 +245,23 @@ func (c *DragSource) SetGoPointer(ptr uintptr) { | |||
| 244 | 245 | // | |
| 245 | 246 | // It can be used to e.g. set a custom drag icon with | |
| 246 | 247 | // [method@Gtk.DragSource.set_icon]. | |
| 247 | - | func (x *DragSource) ConnectDragBegin(cb func(DragSource, uintptr)) uint32 { | |
| 248 | + | func (x *DragSource) ConnectDragBegin(cb *func(DragSource, uintptr)) uint32 { | |
| 249 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 250 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 251 | + | return gobject.SignalConnect(x.GoPointer(), "drag-begin", cbRefPtr) | |
| 252 | + | } | |
| 253 | + | ||
| 248 | 254 | fcb := func(clsPtr uintptr, DragVarp uintptr) { | |
| 249 | 255 | fa := DragSource{} | |
| 250 | 256 | fa.Ptr = clsPtr | |
| 257 | + | cbFn := *cb | |
| 251 | 258 | ||
| 252 | - | cb(fa, DragVarp) | |
| 259 | + | cbFn(fa, DragVarp) | |
| 253 | 260 | ||
| 254 | 261 | } | |
| 255 | - | return gobject.SignalConnect(x.GoPointer(), "drag-begin", purego.NewCallback(fcb)) | |
| 262 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 263 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 264 | + | return gobject.SignalConnect(x.GoPointer(), "drag-begin", cbRefPtr) | |
| 256 | 265 | } | |
| 257 | 266 | ||
| 258 | 267 | // Emitted on the drag source when a drag has failed. | |
| @@ -260,15 +269,23 @@ func (x *DragSource) ConnectDragBegin(cb func(DragSource, uintptr)) uint32 { | |||
| 260 | 269 | // The signal handler may handle a failed drag operation based on | |
| 261 | 270 | // the type of error. It should return %TRUE if the failure has been handled | |
| 262 | 271 | // and the default "drag operation failed" animation should not be shown. | |
| 263 | - | func (x *DragSource) ConnectDragCancel(cb func(DragSource, uintptr, gdk.DragCancelReason) bool) uint32 { | |
| 272 | + | func (x *DragSource) ConnectDragCancel(cb *func(DragSource, uintptr, gdk.DragCancelReason) bool) uint32 { | |
| 273 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 274 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 275 | + | return gobject.SignalConnect(x.GoPointer(), "drag-cancel", cbRefPtr) | |
| 276 | + | } | |
| 277 | + | ||
| 264 | 278 | fcb := func(clsPtr uintptr, DragVarp uintptr, ReasonVarp gdk.DragCancelReason) bool { | |
| 265 | 279 | fa := DragSource{} | |
| 266 | 280 | fa.Ptr = clsPtr | |
| 281 | + | cbFn := *cb | |
| 267 | 282 | ||
| 268 | - | return cb(fa, DragVarp, ReasonVarp) | |
| 283 | + | return cbFn(fa, DragVarp, ReasonVarp) | |
| 269 | 284 | ||
| 270 | 285 | } | |
| 271 | - | return gobject.SignalConnect(x.GoPointer(), "drag-cancel", purego.NewCallback(fcb)) | |
| 286 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 287 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 288 | + | return gobject.SignalConnect(x.GoPointer(), "drag-cancel", cbRefPtr) | |
| 272 | 289 | } | |
| 273 | 290 | ||
| 274 | 291 | // Emitted on the drag source when a drag is finished. | |
| @@ -276,15 +293,23 @@ func (x *DragSource) ConnectDragCancel(cb func(DragSource, uintptr, gdk.DragCanc | |||
| 276 | 293 | // A typical reason to connect to this signal is to undo | |
| 277 | 294 | // things done in [signal@Gtk.DragSource::prepare] or | |
| 278 | 295 | // [signal@Gtk.DragSource::drag-begin] handlers. | |
| 279 | - | func (x *DragSource) ConnectDragEnd(cb func(DragSource, uintptr, bool)) uint32 { | |
| 296 | + | func (x *DragSource) ConnectDragEnd(cb *func(DragSource, uintptr, bool)) uint32 { | |
| 297 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 298 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 299 | + | return gobject.SignalConnect(x.GoPointer(), "drag-end", cbRefPtr) | |
| 300 | + | } | |
| 301 | + | ||
| 280 | 302 | fcb := func(clsPtr uintptr, DragVarp uintptr, DeleteDataVarp bool) { | |
| 281 | 303 | fa := DragSource{} | |
| 282 | 304 | fa.Ptr = clsPtr | |
| 305 | + | cbFn := *cb | |
| 283 | 306 | ||
| 284 | - | cb(fa, DragVarp, DeleteDataVarp) | |
| 307 | + | cbFn(fa, DragVarp, DeleteDataVarp) | |
| 285 | 308 | ||
| 286 | 309 | } | |
| 287 | - | return gobject.SignalConnect(x.GoPointer(), "drag-end", purego.NewCallback(fcb)) | |
| 310 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 311 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 312 | + | return gobject.SignalConnect(x.GoPointer(), "drag-end", cbRefPtr) | |
| 288 | 313 | } | |
| 289 | 314 | ||
| 290 | 315 | // Emitted when a drag is about to be initiated. | |
| @@ -293,16 +318,24 @@ func (x *DragSource) ConnectDragEnd(cb func(DragSource, uintptr, bool)) uint32 { | |||
| 293 | 318 | // to start. The default handler for this signal returns the value of | |
| 294 | 319 | // the [property@Gtk.DragSource:content] property, so if you set up that | |
| 295 | 320 | // property ahead of time, you don't need to connect to this signal. | |
| 296 | - | func (x *DragSource) ConnectPrepare(cb func(DragSource, float64, float64) gdk.ContentProvider) uint32 { | |
| 321 | + | func (x *DragSource) ConnectPrepare(cb *func(DragSource, float64, float64) gdk.ContentProvider) uint32 { | |
| 322 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 323 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 324 | + | return gobject.SignalConnect(x.GoPointer(), "prepare", cbRefPtr) | |
| 325 | + | } | |
| 326 | + | ||
| 297 | 327 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) uintptr { | |
| 298 | 328 | fa := DragSource{} | |
| 299 | 329 | fa.Ptr = clsPtr | |
| 330 | + | cbFn := *cb | |
| 300 | 331 | ||
| 301 | - | PrepareCls := cb(fa, XVarp, YVarp) | |
| 332 | + | PrepareCls := cbFn(fa, XVarp, YVarp) | |
| 302 | 333 | return PrepareCls.Ptr | |
| 303 | 334 | ||
| 304 | 335 | } | |
| 305 | - | return gobject.SignalConnect(x.GoPointer(), "prepare", purego.NewCallback(fcb)) | |
| 336 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 337 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 338 | + | return gobject.SignalConnect(x.GoPointer(), "prepare", cbRefPtr) | |
| 306 | 339 | } | |
| 307 | 340 | ||
| 308 | 341 | func init() { | |
M v4/gtk/gtkdrawingarea.go +13 -5
| @@ -205,9 +205,9 @@ var xDrawingAreaSetDrawFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 205 | 205 | // | |
| 206 | 206 | // If what you are drawing does change, call [method@Gtk.Widget.queue_draw] | |
| 207 | 207 | // on the drawing area. This will cause a redraw and will call @draw_func again. | |
| 208 | - | func (x *DrawingArea) SetDrawFunc(DrawFuncVar DrawingAreaDrawFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 208 | + | func (x *DrawingArea) SetDrawFunc(DrawFuncVar *DrawingAreaDrawFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 209 | 209 | ||
| 210 | - | xDrawingAreaSetDrawFunc(x.GoPointer(), purego.NewCallback(DrawFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 210 | + | xDrawingAreaSetDrawFunc(x.GoPointer(), glib.NewCallback(DrawFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 211 | 211 | ||
| 212 | 212 | } | |
| 213 | 213 | ||
| @@ -224,15 +224,23 @@ func (c *DrawingArea) SetGoPointer(ptr uintptr) { | |||
| 224 | 224 | // | |
| 225 | 225 | // This is useful in order to keep state up to date with the widget size, | |
| 226 | 226 | // like for instance a backing surface. | |
| 227 | - | func (x *DrawingArea) ConnectResize(cb func(DrawingArea, int, int)) uint32 { | |
| 227 | + | func (x *DrawingArea) ConnectResize(cb *func(DrawingArea, int, int)) uint32 { | |
| 228 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 229 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 230 | + | return gobject.SignalConnect(x.GoPointer(), "resize", cbRefPtr) | |
| 231 | + | } | |
| 232 | + | ||
| 228 | 233 | fcb := func(clsPtr uintptr, WidthVarp int, HeightVarp int) { | |
| 229 | 234 | fa := DrawingArea{} | |
| 230 | 235 | fa.Ptr = clsPtr | |
| 236 | + | cbFn := *cb | |
| 231 | 237 | ||
| 232 | - | cb(fa, WidthVarp, HeightVarp) | |
| 238 | + | cbFn(fa, WidthVarp, HeightVarp) | |
| 233 | 239 | ||
| 234 | 240 | } | |
| 235 | - | return gobject.SignalConnect(x.GoPointer(), "resize", purego.NewCallback(fcb)) | |
| 241 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 242 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 243 | + | return gobject.SignalConnect(x.GoPointer(), "resize", cbRefPtr) | |
| 236 | 244 | } | |
| 237 | 245 | ||
| 238 | 246 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkdropcontrollermotion.go +34 -9
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -99,39 +100,63 @@ func (c *DropControllerMotion) SetGoPointer(ptr uintptr) { | |||
| 99 | 100 | } | |
| 100 | 101 | ||
| 101 | 102 | // Signals that the pointer has entered the widget. | |
| 102 | - | func (x *DropControllerMotion) ConnectEnter(cb func(DropControllerMotion, float64, float64)) uint32 { | |
| 103 | + | func (x *DropControllerMotion) ConnectEnter(cb *func(DropControllerMotion, float64, float64)) uint32 { | |
| 104 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 105 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 106 | + | return gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) | |
| 107 | + | } | |
| 108 | + | ||
| 103 | 109 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) { | |
| 104 | 110 | fa := DropControllerMotion{} | |
| 105 | 111 | fa.Ptr = clsPtr | |
| 112 | + | cbFn := *cb | |
| 106 | 113 | ||
| 107 | - | cb(fa, XVarp, YVarp) | |
| 114 | + | cbFn(fa, XVarp, YVarp) | |
| 108 | 115 | ||
| 109 | 116 | } | |
| 110 | - | return gobject.SignalConnect(x.GoPointer(), "enter", purego.NewCallback(fcb)) | |
| 117 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 118 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 119 | + | return gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) | |
| 111 | 120 | } | |
| 112 | 121 | ||
| 113 | 122 | // Signals that the pointer has left the widget. | |
| 114 | - | func (x *DropControllerMotion) ConnectLeave(cb func(DropControllerMotion)) uint32 { | |
| 123 | + | func (x *DropControllerMotion) ConnectLeave(cb *func(DropControllerMotion)) uint32 { | |
| 124 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 125 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 126 | + | return gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) | |
| 127 | + | } | |
| 128 | + | ||
| 115 | 129 | fcb := func(clsPtr uintptr) { | |
| 116 | 130 | fa := DropControllerMotion{} | |
| 117 | 131 | fa.Ptr = clsPtr | |
| 132 | + | cbFn := *cb | |
| 118 | 133 | ||
| 119 | - | cb(fa) | |
| 134 | + | cbFn(fa) | |
| 120 | 135 | ||
| 121 | 136 | } | |
| 122 | - | return gobject.SignalConnect(x.GoPointer(), "leave", purego.NewCallback(fcb)) | |
| 137 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 138 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 139 | + | return gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) | |
| 123 | 140 | } | |
| 124 | 141 | ||
| 125 | 142 | // Emitted when the pointer moves inside the widget. | |
| 126 | - | func (x *DropControllerMotion) ConnectMotion(cb func(DropControllerMotion, float64, float64)) uint32 { | |
| 143 | + | func (x *DropControllerMotion) ConnectMotion(cb *func(DropControllerMotion, float64, float64)) uint32 { | |
| 144 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 145 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 146 | + | return gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr) | |
| 147 | + | } | |
| 148 | + | ||
| 127 | 149 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) { | |
| 128 | 150 | fa := DropControllerMotion{} | |
| 129 | 151 | fa.Ptr = clsPtr | |
| 152 | + | cbFn := *cb | |
| 130 | 153 | ||
| 131 | - | cb(fa, XVarp, YVarp) | |
| 154 | + | cbFn(fa, XVarp, YVarp) | |
| 132 | 155 | ||
| 133 | 156 | } | |
| 134 | - | return gobject.SignalConnect(x.GoPointer(), "motion", purego.NewCallback(fcb)) | |
| 157 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 158 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 159 | + | return gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr) | |
| 135 | 160 | } | |
| 136 | 161 | ||
| 137 | 162 | func init() { | |
M v4/gtk/gtkdropdown.go +12 -3
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -310,15 +311,23 @@ func (c *DropDown) SetGoPointer(ptr uintptr) { | |||
| 310 | 311 | // | |
| 311 | 312 | // The `::activate` signal on `GtkDropDown` is an action signal and | |
| 312 | 313 | // emitting it causes the drop down to pop up its dropdown. | |
| 313 | - | func (x *DropDown) ConnectActivate(cb func(DropDown)) uint32 { | |
| 314 | + | func (x *DropDown) ConnectActivate(cb *func(DropDown)) uint32 { | |
| 315 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 316 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 317 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 318 | + | } | |
| 319 | + | ||
| 314 | 320 | fcb := func(clsPtr uintptr) { | |
| 315 | 321 | fa := DropDown{} | |
| 316 | 322 | fa.Ptr = clsPtr | |
| 323 | + | cbFn := *cb | |
| 317 | 324 | ||
| 318 | - | cb(fa) | |
| 325 | + | cbFn(fa) | |
| 319 | 326 | ||
| 320 | 327 | } | |
| 321 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 328 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 329 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 330 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 322 | 331 | } | |
| 323 | 332 | ||
| 324 | 333 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkdroptarget.go +56 -15
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -276,15 +277,23 @@ func (c *DropTarget) SetGoPointer(ptr uintptr) { | |||
| 276 | 277 | // [property@Gtk.DropTarget:preload] property should be set and the value | |
| 277 | 278 | // should be inspected via the ::notify:value signal, calling | |
| 278 | 279 | // [method@Gtk.DropTarget.reject] if required. | |
| 279 | - | func (x *DropTarget) ConnectAccept(cb func(DropTarget, uintptr) bool) uint32 { | |
| 280 | + | func (x *DropTarget) ConnectAccept(cb *func(DropTarget, uintptr) bool) uint32 { | |
| 281 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 282 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 283 | + | return gobject.SignalConnect(x.GoPointer(), "accept", cbRefPtr) | |
| 284 | + | } | |
| 285 | + | ||
| 280 | 286 | fcb := func(clsPtr uintptr, DropVarp uintptr) bool { | |
| 281 | 287 | fa := DropTarget{} | |
| 282 | 288 | fa.Ptr = clsPtr | |
| 289 | + | cbFn := *cb | |
| 283 | 290 | ||
| 284 | - | return cb(fa, DropVarp) | |
| 291 | + | return cbFn(fa, DropVarp) | |
| 285 | 292 | ||
| 286 | 293 | } | |
| 287 | - | return gobject.SignalConnect(x.GoPointer(), "accept", purego.NewCallback(fcb)) | |
| 294 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 295 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 296 | + | return gobject.SignalConnect(x.GoPointer(), "accept", cbRefPtr) | |
| 288 | 297 | } | |
| 289 | 298 | ||
| 290 | 299 | // Emitted on the drop site when the user drops the data onto the widget. | |
| @@ -296,56 +305,88 @@ func (x *DropTarget) ConnectAccept(cb func(DropTarget, uintptr) bool) uint32 { | |||
| 296 | 305 | // Otherwise, the handler returns %TRUE. In this case, this handler will | |
| 297 | 306 | // accept the drop. The handler is responsible for using the given @value | |
| 298 | 307 | // and performing the drop operation. | |
| 299 | - | func (x *DropTarget) ConnectDrop(cb func(DropTarget, uintptr, float64, float64) bool) uint32 { | |
| 308 | + | func (x *DropTarget) ConnectDrop(cb *func(DropTarget, uintptr, float64, float64) bool) uint32 { | |
| 309 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 310 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 311 | + | return gobject.SignalConnect(x.GoPointer(), "drop", cbRefPtr) | |
| 312 | + | } | |
| 313 | + | ||
| 300 | 314 | fcb := func(clsPtr uintptr, ValueVarp uintptr, XVarp float64, YVarp float64) bool { | |
| 301 | 315 | fa := DropTarget{} | |
| 302 | 316 | fa.Ptr = clsPtr | |
| 317 | + | cbFn := *cb | |
| 303 | 318 | ||
| 304 | - | return cb(fa, ValueVarp, XVarp, YVarp) | |
| 319 | + | return cbFn(fa, ValueVarp, XVarp, YVarp) | |
| 305 | 320 | ||
| 306 | 321 | } | |
| 307 | - | return gobject.SignalConnect(x.GoPointer(), "drop", purego.NewCallback(fcb)) | |
| 322 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 323 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 324 | + | return gobject.SignalConnect(x.GoPointer(), "drop", cbRefPtr) | |
| 308 | 325 | } | |
| 309 | 326 | ||
| 310 | 327 | // Emitted on the drop site when the pointer enters the widget. | |
| 311 | 328 | // | |
| 312 | 329 | // It can be used to set up custom highlighting. | |
| 313 | - | func (x *DropTarget) ConnectEnter(cb func(DropTarget, float64, float64) gdk.DragAction) uint32 { | |
| 330 | + | func (x *DropTarget) ConnectEnter(cb *func(DropTarget, float64, float64) gdk.DragAction) uint32 { | |
| 331 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 332 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 333 | + | return gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) | |
| 334 | + | } | |
| 335 | + | ||
| 314 | 336 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) gdk.DragAction { | |
| 315 | 337 | fa := DropTarget{} | |
| 316 | 338 | fa.Ptr = clsPtr | |
| 339 | + | cbFn := *cb | |
| 317 | 340 | ||
| 318 | - | return cb(fa, XVarp, YVarp) | |
| 341 | + | return cbFn(fa, XVarp, YVarp) | |
| 319 | 342 | ||
| 320 | 343 | } | |
| 321 | - | return gobject.SignalConnect(x.GoPointer(), "enter", purego.NewCallback(fcb)) | |
| 344 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 345 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 346 | + | return gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) | |
| 322 | 347 | } | |
| 323 | 348 | ||
| 324 | 349 | // Emitted on the drop site when the pointer leaves the widget. | |
| 325 | 350 | // | |
| 326 | 351 | // Its main purpose it to undo things done in | |
| 327 | 352 | // [signal@Gtk.DropTarget::enter]. | |
| 328 | - | func (x *DropTarget) ConnectLeave(cb func(DropTarget)) uint32 { | |
| 353 | + | func (x *DropTarget) ConnectLeave(cb *func(DropTarget)) uint32 { | |
| 354 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 355 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 356 | + | return gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) | |
| 357 | + | } | |
| 358 | + | ||
| 329 | 359 | fcb := func(clsPtr uintptr) { | |
| 330 | 360 | fa := DropTarget{} | |
| 331 | 361 | fa.Ptr = clsPtr | |
| 362 | + | cbFn := *cb | |
| 332 | 363 | ||
| 333 | - | cb(fa) | |
| 364 | + | cbFn(fa) | |
| 334 | 365 | ||
| 335 | 366 | } | |
| 336 | - | return gobject.SignalConnect(x.GoPointer(), "leave", purego.NewCallback(fcb)) | |
| 367 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 368 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 369 | + | return gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) | |
| 337 | 370 | } | |
| 338 | 371 | ||
| 339 | 372 | // Emitted while the pointer is moving over the drop target. | |
| 340 | - | func (x *DropTarget) ConnectMotion(cb func(DropTarget, float64, float64) gdk.DragAction) uint32 { | |
| 373 | + | func (x *DropTarget) ConnectMotion(cb *func(DropTarget, float64, float64) gdk.DragAction) uint32 { | |
| 374 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 375 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 376 | + | return gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr) | |
| 377 | + | } | |
| 378 | + | ||
| 341 | 379 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) gdk.DragAction { | |
| 342 | 380 | fa := DropTarget{} | |
| 343 | 381 | fa.Ptr = clsPtr | |
| 382 | + | cbFn := *cb | |
| 344 | 383 | ||
| 345 | - | return cb(fa, XVarp, YVarp) | |
| 384 | + | return cbFn(fa, XVarp, YVarp) | |
| 346 | 385 | ||
| 347 | 386 | } | |
| 348 | - | return gobject.SignalConnect(x.GoPointer(), "motion", purego.NewCallback(fcb)) | |
| 387 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 388 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 389 | + | return gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr) | |
| 349 | 390 | } | |
| 350 | 391 | ||
| 351 | 392 | func init() { | |
M v4/gtk/gtkdroptargetasync.go +56 -15
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -151,56 +152,88 @@ func (c *DropTargetAsync) SetGoPointer(ptr uintptr) { | |||
| 151 | 152 | // further processing, such as inspecting the data, this function should | |
| 152 | 153 | // return %TRUE and proceed as is @drop was accepted and if it decides to | |
| 153 | 154 | // reject the drop later, it should call [method@Gtk.DropTargetAsync.reject_drop]. | |
| 154 | - | func (x *DropTargetAsync) ConnectAccept(cb func(DropTargetAsync, uintptr) bool) uint32 { | |
| 155 | + | func (x *DropTargetAsync) ConnectAccept(cb *func(DropTargetAsync, uintptr) bool) uint32 { | |
| 156 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 157 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 158 | + | return gobject.SignalConnect(x.GoPointer(), "accept", cbRefPtr) | |
| 159 | + | } | |
| 160 | + | ||
| 155 | 161 | fcb := func(clsPtr uintptr, DropVarp uintptr) bool { | |
| 156 | 162 | fa := DropTargetAsync{} | |
| 157 | 163 | fa.Ptr = clsPtr | |
| 164 | + | cbFn := *cb | |
| 158 | 165 | ||
| 159 | - | return cb(fa, DropVarp) | |
| 166 | + | return cbFn(fa, DropVarp) | |
| 160 | 167 | ||
| 161 | 168 | } | |
| 162 | - | return gobject.SignalConnect(x.GoPointer(), "accept", purego.NewCallback(fcb)) | |
| 169 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 170 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 171 | + | return gobject.SignalConnect(x.GoPointer(), "accept", cbRefPtr) | |
| 163 | 172 | } | |
| 164 | 173 | ||
| 165 | 174 | // Emitted on the drop site when the pointer enters the widget. | |
| 166 | 175 | // | |
| 167 | 176 | // It can be used to set up custom highlighting. | |
| 168 | - | func (x *DropTargetAsync) ConnectDragEnter(cb func(DropTargetAsync, uintptr, float64, float64) gdk.DragAction) uint32 { | |
| 177 | + | func (x *DropTargetAsync) ConnectDragEnter(cb *func(DropTargetAsync, uintptr, float64, float64) gdk.DragAction) uint32 { | |
| 178 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 179 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 180 | + | return gobject.SignalConnect(x.GoPointer(), "drag-enter", cbRefPtr) | |
| 181 | + | } | |
| 182 | + | ||
| 169 | 183 | fcb := func(clsPtr uintptr, DropVarp uintptr, XVarp float64, YVarp float64) gdk.DragAction { | |
| 170 | 184 | fa := DropTargetAsync{} | |
| 171 | 185 | fa.Ptr = clsPtr | |
| 186 | + | cbFn := *cb | |
| 172 | 187 | ||
| 173 | - | return cb(fa, DropVarp, XVarp, YVarp) | |
| 188 | + | return cbFn(fa, DropVarp, XVarp, YVarp) | |
| 174 | 189 | ||
| 175 | 190 | } | |
| 176 | - | return gobject.SignalConnect(x.GoPointer(), "drag-enter", purego.NewCallback(fcb)) | |
| 191 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 192 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 193 | + | return gobject.SignalConnect(x.GoPointer(), "drag-enter", cbRefPtr) | |
| 177 | 194 | } | |
| 178 | 195 | ||
| 179 | 196 | // Emitted on the drop site when the pointer leaves the widget. | |
| 180 | 197 | // | |
| 181 | 198 | // Its main purpose it to undo things done in | |
| 182 | 199 | // `GtkDropTargetAsync`::drag-enter. | |
| 183 | - | func (x *DropTargetAsync) ConnectDragLeave(cb func(DropTargetAsync, uintptr)) uint32 { | |
| 200 | + | func (x *DropTargetAsync) ConnectDragLeave(cb *func(DropTargetAsync, uintptr)) uint32 { | |
| 201 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 202 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 203 | + | return gobject.SignalConnect(x.GoPointer(), "drag-leave", cbRefPtr) | |
| 204 | + | } | |
| 205 | + | ||
| 184 | 206 | fcb := func(clsPtr uintptr, DropVarp uintptr) { | |
| 185 | 207 | fa := DropTargetAsync{} | |
| 186 | 208 | fa.Ptr = clsPtr | |
| 209 | + | cbFn := *cb | |
| 187 | 210 | ||
| 188 | - | cb(fa, DropVarp) | |
| 211 | + | cbFn(fa, DropVarp) | |
| 189 | 212 | ||
| 190 | 213 | } | |
| 191 | - | return gobject.SignalConnect(x.GoPointer(), "drag-leave", purego.NewCallback(fcb)) | |
| 214 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 215 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 216 | + | return gobject.SignalConnect(x.GoPointer(), "drag-leave", cbRefPtr) | |
| 192 | 217 | } | |
| 193 | 218 | ||
| 194 | 219 | // Emitted while the pointer is moving over the drop target. | |
| 195 | - | func (x *DropTargetAsync) ConnectDragMotion(cb func(DropTargetAsync, uintptr, float64, float64) gdk.DragAction) uint32 { | |
| 220 | + | func (x *DropTargetAsync) ConnectDragMotion(cb *func(DropTargetAsync, uintptr, float64, float64) gdk.DragAction) uint32 { | |
| 221 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 222 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 223 | + | return gobject.SignalConnect(x.GoPointer(), "drag-motion", cbRefPtr) | |
| 224 | + | } | |
| 225 | + | ||
| 196 | 226 | fcb := func(clsPtr uintptr, DropVarp uintptr, XVarp float64, YVarp float64) gdk.DragAction { | |
| 197 | 227 | fa := DropTargetAsync{} | |
| 198 | 228 | fa.Ptr = clsPtr | |
| 229 | + | cbFn := *cb | |
| 199 | 230 | ||
| 200 | - | return cb(fa, DropVarp, XVarp, YVarp) | |
| 231 | + | return cbFn(fa, DropVarp, XVarp, YVarp) | |
| 201 | 232 | ||
| 202 | 233 | } | |
| 203 | - | return gobject.SignalConnect(x.GoPointer(), "drag-motion", purego.NewCallback(fcb)) | |
| 234 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 235 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 236 | + | return gobject.SignalConnect(x.GoPointer(), "drag-motion", cbRefPtr) | |
| 204 | 237 | } | |
| 205 | 238 | ||
| 206 | 239 | // Emitted on the drop site when the user drops the data onto the widget. | |
| @@ -217,15 +250,23 @@ func (x *DropTargetAsync) ConnectDragMotion(cb func(DropTargetAsync, uintptr, fl | |||
| 217 | 250 | // To receive the data, use one of the read functions provided by | |
| 218 | 251 | // [class@Gdk.Drop] such as [method@Gdk.Drop.read_async] or | |
| 219 | 252 | // [method@Gdk.Drop.read_value_async]. | |
| 220 | - | func (x *DropTargetAsync) ConnectDrop(cb func(DropTargetAsync, uintptr, float64, float64) bool) uint32 { | |
| 253 | + | func (x *DropTargetAsync) ConnectDrop(cb *func(DropTargetAsync, uintptr, float64, float64) bool) uint32 { | |
| 254 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 255 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 256 | + | return gobject.SignalConnect(x.GoPointer(), "drop", cbRefPtr) | |
| 257 | + | } | |
| 258 | + | ||
| 221 | 259 | fcb := func(clsPtr uintptr, DropVarp uintptr, XVarp float64, YVarp float64) bool { | |
| 222 | 260 | fa := DropTargetAsync{} | |
| 223 | 261 | fa.Ptr = clsPtr | |
| 262 | + | cbFn := *cb | |
| 224 | 263 | ||
| 225 | - | return cb(fa, DropVarp, XVarp, YVarp) | |
| 264 | + | return cbFn(fa, DropVarp, XVarp, YVarp) | |
| 226 | 265 | ||
| 227 | 266 | } | |
| 228 | - | return gobject.SignalConnect(x.GoPointer(), "drop", purego.NewCallback(fcb)) | |
| 267 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 268 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 269 | + | return gobject.SignalConnect(x.GoPointer(), "drop", cbRefPtr) | |
| 229 | 270 | } | |
| 230 | 271 | ||
| 231 | 272 | func init() { | |
M v4/gtk/gtkemojichooser.go +12 -3
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gsk" | |
| 12 | 13 | ) | |
| @@ -84,15 +85,23 @@ func (c *EmojiChooser) SetGoPointer(ptr uintptr) { | |||
| 84 | 85 | } | |
| 85 | 86 | ||
| 86 | 87 | // Emitted when the user selects an Emoji. | |
| 87 | - | func (x *EmojiChooser) ConnectEmojiPicked(cb func(EmojiChooser, string)) uint32 { | |
| 88 | + | func (x *EmojiChooser) ConnectEmojiPicked(cb *func(EmojiChooser, string)) uint32 { | |
| 89 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 90 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 91 | + | return gobject.SignalConnect(x.GoPointer(), "emoji-picked", cbRefPtr) | |
| 92 | + | } | |
| 93 | + | ||
| 88 | 94 | fcb := func(clsPtr uintptr, TextVarp string) { | |
| 89 | 95 | fa := EmojiChooser{} | |
| 90 | 96 | fa.Ptr = clsPtr | |
| 97 | + | cbFn := *cb | |
| 91 | 98 | ||
| 92 | - | cb(fa, TextVarp) | |
| 99 | + | cbFn(fa, TextVarp) | |
| 93 | 100 | ||
| 94 | 101 | } | |
| 95 | - | return gobject.SignalConnect(x.GoPointer(), "emoji-picked", purego.NewCallback(fcb)) | |
| 102 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 103 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 104 | + | return gobject.SignalConnect(x.GoPointer(), "emoji-picked", cbRefPtr) | |
| 96 | 105 | } | |
| 97 | 106 | ||
| 98 | 107 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkentry.go +34 -9
| @@ -8,6 +8,7 @@ import ( | |||
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | 10 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 11 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 12 | 13 | "github.com/jwijenbergh/puregotk/v4/pango" | |
| 13 | 14 | ) | |
| @@ -916,40 +917,64 @@ func (c *Entry) SetGoPointer(ptr uintptr) { | |||
| 916 | 917 | // Emitted when the entry is activated. | |
| 917 | 918 | // | |
| 918 | 919 | // The keybindings for this signal are all forms of the Enter key. | |
| 919 | - | func (x *Entry) ConnectActivate(cb func(Entry)) uint32 { | |
| 920 | + | func (x *Entry) ConnectActivate(cb *func(Entry)) uint32 { | |
| 921 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 922 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 923 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 924 | + | } | |
| 925 | + | ||
| 920 | 926 | fcb := func(clsPtr uintptr) { | |
| 921 | 927 | fa := Entry{} | |
| 922 | 928 | fa.Ptr = clsPtr | |
| 929 | + | cbFn := *cb | |
| 923 | 930 | ||
| 924 | - | cb(fa) | |
| 931 | + | cbFn(fa) | |
| 925 | 932 | ||
| 926 | 933 | } | |
| 927 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 934 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 935 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 936 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 928 | 937 | } | |
| 929 | 938 | ||
| 930 | 939 | // Emitted when an activatable icon is clicked. | |
| 931 | - | func (x *Entry) ConnectIconPress(cb func(Entry, EntryIconPosition)) uint32 { | |
| 940 | + | func (x *Entry) ConnectIconPress(cb *func(Entry, EntryIconPosition)) uint32 { | |
| 941 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 942 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 943 | + | return gobject.SignalConnect(x.GoPointer(), "icon-press", cbRefPtr) | |
| 944 | + | } | |
| 945 | + | ||
| 932 | 946 | fcb := func(clsPtr uintptr, IconPosVarp EntryIconPosition) { | |
| 933 | 947 | fa := Entry{} | |
| 934 | 948 | fa.Ptr = clsPtr | |
| 949 | + | cbFn := *cb | |
| 935 | 950 | ||
| 936 | - | cb(fa, IconPosVarp) | |
| 951 | + | cbFn(fa, IconPosVarp) | |
| 937 | 952 | ||
| 938 | 953 | } | |
| 939 | - | return gobject.SignalConnect(x.GoPointer(), "icon-press", purego.NewCallback(fcb)) | |
| 954 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 955 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 956 | + | return gobject.SignalConnect(x.GoPointer(), "icon-press", cbRefPtr) | |
| 940 | 957 | } | |
| 941 | 958 | ||
| 942 | 959 | // Emitted on the button release from a mouse click | |
| 943 | 960 | // over an activatable icon. | |
| 944 | - | func (x *Entry) ConnectIconRelease(cb func(Entry, EntryIconPosition)) uint32 { | |
| 961 | + | func (x *Entry) ConnectIconRelease(cb *func(Entry, EntryIconPosition)) uint32 { | |
| 962 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 963 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 964 | + | return gobject.SignalConnect(x.GoPointer(), "icon-release", cbRefPtr) | |
| 965 | + | } | |
| 966 | + | ||
| 945 | 967 | fcb := func(clsPtr uintptr, IconPosVarp EntryIconPosition) { | |
| 946 | 968 | fa := Entry{} | |
| 947 | 969 | fa.Ptr = clsPtr | |
| 970 | + | cbFn := *cb | |
| 948 | 971 | ||
| 949 | - | cb(fa, IconPosVarp) | |
| 972 | + | cbFn(fa, IconPosVarp) | |
| 950 | 973 | ||
| 951 | 974 | } | |
| 952 | - | return gobject.SignalConnect(x.GoPointer(), "icon-release", purego.NewCallback(fcb)) | |
| 975 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 976 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 977 | + | return gobject.SignalConnect(x.GoPointer(), "icon-release", cbRefPtr) | |
| 953 | 978 | } | |
| 954 | 979 | ||
| 955 | 980 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkentrybuffer.go +23 -6
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -189,27 +190,43 @@ func (c *EntryBuffer) SetGoPointer(ptr uintptr) { | |||
| 189 | 190 | // | |
| 190 | 191 | // If you want access to the text after the text has been modified, | |
| 191 | 192 | // use %G_CONNECT_AFTER. | |
| 192 | - | func (x *EntryBuffer) ConnectDeletedText(cb func(EntryBuffer, uint, uint)) uint32 { | |
| 193 | + | func (x *EntryBuffer) ConnectDeletedText(cb *func(EntryBuffer, uint, uint)) uint32 { | |
| 194 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 195 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 196 | + | return gobject.SignalConnect(x.GoPointer(), "deleted-text", cbRefPtr) | |
| 197 | + | } | |
| 198 | + | ||
| 193 | 199 | fcb := func(clsPtr uintptr, PositionVarp uint, NCharsVarp uint) { | |
| 194 | 200 | fa := EntryBuffer{} | |
| 195 | 201 | fa.Ptr = clsPtr | |
| 202 | + | cbFn := *cb | |
| 196 | 203 | ||
| 197 | - | cb(fa, PositionVarp, NCharsVarp) | |
| 204 | + | cbFn(fa, PositionVarp, NCharsVarp) | |
| 198 | 205 | ||
| 199 | 206 | } | |
| 200 | - | return gobject.SignalConnect(x.GoPointer(), "deleted-text", purego.NewCallback(fcb)) | |
| 207 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 208 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 209 | + | return gobject.SignalConnect(x.GoPointer(), "deleted-text", cbRefPtr) | |
| 201 | 210 | } | |
| 202 | 211 | ||
| 203 | 212 | // This signal is emitted after text is inserted into the buffer. | |
| 204 | - | func (x *EntryBuffer) ConnectInsertedText(cb func(EntryBuffer, uint, string, uint)) uint32 { | |
| 213 | + | func (x *EntryBuffer) ConnectInsertedText(cb *func(EntryBuffer, uint, string, uint)) uint32 { | |
| 214 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 215 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 216 | + | return gobject.SignalConnect(x.GoPointer(), "inserted-text", cbRefPtr) | |
| 217 | + | } | |
| 218 | + | ||
| 205 | 219 | fcb := func(clsPtr uintptr, PositionVarp uint, CharsVarp string, NCharsVarp uint) { | |
| 206 | 220 | fa := EntryBuffer{} | |
| 207 | 221 | fa.Ptr = clsPtr | |
| 222 | + | cbFn := *cb | |
| 208 | 223 | ||
| 209 | - | cb(fa, PositionVarp, CharsVarp, NCharsVarp) | |
| 224 | + | cbFn(fa, PositionVarp, CharsVarp, NCharsVarp) | |
| 210 | 225 | ||
| 211 | 226 | } | |
| 212 | - | return gobject.SignalConnect(x.GoPointer(), "inserted-text", purego.NewCallback(fcb)) | |
| 227 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 228 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 229 | + | return gobject.SignalConnect(x.GoPointer(), "inserted-text", cbRefPtr) | |
| 213 | 230 | } | |
| 214 | 231 | ||
| 215 | 232 | func init() { | |
M v4/gtk/gtkentrycompletion.go +50 -16
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -274,9 +276,9 @@ var xEntryCompletionSetMatchFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 274 | 276 | // | |
| 275 | 277 | // The match function is used to determine if a row should or | |
| 276 | 278 | // should not be in the completion list. | |
| 277 | - | func (x *EntryCompletion) SetMatchFunc(FuncVar EntryCompletionMatchFunc, FuncDataVar uintptr, FuncNotifyVar glib.DestroyNotify) { | |
| 279 | + | func (x *EntryCompletion) SetMatchFunc(FuncVar *EntryCompletionMatchFunc, FuncDataVar uintptr, FuncNotifyVar *glib.DestroyNotify) { | |
| 278 | 280 | ||
| 279 | - | xEntryCompletionSetMatchFunc(x.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(FuncNotifyVar)) | |
| 281 | + | xEntryCompletionSetMatchFunc(x.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(FuncNotifyVar)) | |
| 280 | 282 | ||
| 281 | 283 | } | |
| 282 | 284 | ||
| @@ -374,15 +376,23 @@ func (c *EntryCompletion) SetGoPointer(ptr uintptr) { | |||
| 374 | 376 | // | |
| 375 | 377 | // Note that @model is the model that was passed to | |
| 376 | 378 | // [method@Gtk.EntryCompletion.set_model]. | |
| 377 | - | func (x *EntryCompletion) ConnectCursorOnMatch(cb func(EntryCompletion, uintptr, uintptr) bool) uint32 { | |
| 379 | + | func (x *EntryCompletion) ConnectCursorOnMatch(cb *func(EntryCompletion, uintptr, uintptr) bool) uint32 { | |
| 380 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 381 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 382 | + | return gobject.SignalConnect(x.GoPointer(), "cursor-on-match", cbRefPtr) | |
| 383 | + | } | |
| 384 | + | ||
| 378 | 385 | fcb := func(clsPtr uintptr, ModelVarp uintptr, IterVarp uintptr) bool { | |
| 379 | 386 | fa := EntryCompletion{} | |
| 380 | 387 | fa.Ptr = clsPtr | |
| 388 | + | cbFn := *cb | |
| 381 | 389 | ||
| 382 | - | return cb(fa, ModelVarp, IterVarp) | |
| 390 | + | return cbFn(fa, ModelVarp, IterVarp) | |
| 383 | 391 | ||
| 384 | 392 | } | |
| 385 | - | return gobject.SignalConnect(x.GoPointer(), "cursor-on-match", purego.NewCallback(fcb)) | |
| 393 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 394 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 395 | + | return gobject.SignalConnect(x.GoPointer(), "cursor-on-match", cbRefPtr) | |
| 386 | 396 | } | |
| 387 | 397 | ||
| 388 | 398 | // Emitted when the inline autocompletion is triggered. | |
| @@ -394,15 +404,23 @@ func (x *EntryCompletion) ConnectCursorOnMatch(cb func(EntryCompletion, uintptr, | |||
| 394 | 404 | // smaller part of the @prefix into the entry - e.g. the entry used in | |
| 395 | 405 | // the `GtkFileChooser` inserts only the part of the prefix up to the | |
| 396 | 406 | // next '/'. | |
| 397 | - | func (x *EntryCompletion) ConnectInsertPrefix(cb func(EntryCompletion, string) bool) uint32 { | |
| 407 | + | func (x *EntryCompletion) ConnectInsertPrefix(cb *func(EntryCompletion, string) bool) uint32 { | |
| 408 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 409 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 410 | + | return gobject.SignalConnect(x.GoPointer(), "insert-prefix", cbRefPtr) | |
| 411 | + | } | |
| 412 | + | ||
| 398 | 413 | fcb := func(clsPtr uintptr, PrefixVarp string) bool { | |
| 399 | 414 | fa := EntryCompletion{} | |
| 400 | 415 | fa.Ptr = clsPtr | |
| 416 | + | cbFn := *cb | |
| 401 | 417 | ||
| 402 | - | return cb(fa, PrefixVarp) | |
| 418 | + | return cbFn(fa, PrefixVarp) | |
| 403 | 419 | ||
| 404 | 420 | } | |
| 405 | - | return gobject.SignalConnect(x.GoPointer(), "insert-prefix", purego.NewCallback(fcb)) | |
| 421 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 422 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 423 | + | return gobject.SignalConnect(x.GoPointer(), "insert-prefix", cbRefPtr) | |
| 406 | 424 | } | |
| 407 | 425 | ||
| 408 | 426 | // Emitted when a match from the list is selected. | |
| @@ -413,30 +431,46 @@ func (x *EntryCompletion) ConnectInsertPrefix(cb func(EntryCompletion, string) b | |||
| 413 | 431 | // | |
| 414 | 432 | // Note that @model is the model that was passed to | |
| 415 | 433 | // [method@Gtk.EntryCompletion.set_model]. | |
| 416 | - | func (x *EntryCompletion) ConnectMatchSelected(cb func(EntryCompletion, uintptr, uintptr) bool) uint32 { | |
| 434 | + | func (x *EntryCompletion) ConnectMatchSelected(cb *func(EntryCompletion, uintptr, uintptr) bool) uint32 { | |
| 435 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 436 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 437 | + | return gobject.SignalConnect(x.GoPointer(), "match-selected", cbRefPtr) | |
| 438 | + | } | |
| 439 | + | ||
| 417 | 440 | fcb := func(clsPtr uintptr, ModelVarp uintptr, IterVarp uintptr) bool { | |
| 418 | 441 | fa := EntryCompletion{} | |
| 419 | 442 | fa.Ptr = clsPtr | |
| 443 | + | cbFn := *cb | |
| 420 | 444 | ||
| 421 | - | return cb(fa, ModelVarp, IterVarp) | |
| 445 | + | return cbFn(fa, ModelVarp, IterVarp) | |
| 422 | 446 | ||
| 423 | 447 | } | |
| 424 | - | return gobject.SignalConnect(x.GoPointer(), "match-selected", purego.NewCallback(fcb)) | |
| 448 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 449 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 450 | + | return gobject.SignalConnect(x.GoPointer(), "match-selected", cbRefPtr) | |
| 425 | 451 | } | |
| 426 | 452 | ||
| 427 | 453 | // Emitted when the filter model has zero | |
| 428 | 454 | // number of rows in completion_complete method. | |
| 429 | 455 | // | |
| 430 | 456 | // In other words when `GtkEntryCompletion` is out of suggestions. | |
| 431 | - | func (x *EntryCompletion) ConnectNoMatches(cb func(EntryCompletion)) uint32 { | |
| 457 | + | func (x *EntryCompletion) ConnectNoMatches(cb *func(EntryCompletion)) uint32 { | |
| 458 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 459 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 460 | + | return gobject.SignalConnect(x.GoPointer(), "no-matches", cbRefPtr) | |
| 461 | + | } | |
| 462 | + | ||
| 432 | 463 | fcb := func(clsPtr uintptr) { | |
| 433 | 464 | fa := EntryCompletion{} | |
| 434 | 465 | fa.Ptr = clsPtr | |
| 466 | + | cbFn := *cb | |
| 435 | 467 | ||
| 436 | - | cb(fa) | |
| 468 | + | cbFn(fa) | |
| 437 | 469 | ||
| 438 | 470 | } | |
| 439 | - | return gobject.SignalConnect(x.GoPointer(), "no-matches", purego.NewCallback(fcb)) | |
| 471 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 472 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 473 | + | return gobject.SignalConnect(x.GoPointer(), "no-matches", cbRefPtr) | |
| 440 | 474 | } | |
| 441 | 475 | ||
| 442 | 476 | // Gets the ID of the @buildable object. | |
| @@ -555,9 +589,9 @@ func (x *EntryCompletion) SetAttributes(CellVar *CellRenderer, varArgs ...interf | |||
| 555 | 589 | // cell renderer(s) as appropriate. | |
| 556 | 590 | // | |
| 557 | 591 | // @func may be %NULL to remove a previously set function. | |
| 558 | - | func (x *EntryCompletion) SetCellDataFunc(CellVar *CellRenderer, FuncVar CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 592 | + | func (x *EntryCompletion) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 559 | 593 | ||
| 560 | - | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(DestroyVar)) | |
| 594 | + | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) | |
| 561 | 595 | ||
| 562 | 596 | } | |
| 563 | 597 | ||
M v4/gtk/gtkeventcontrollerfocus.go +23 -6
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -87,15 +88,23 @@ func (c *EventControllerFocus) SetGoPointer(ptr uintptr) { | |||
| 87 | 88 | // in these cases, you can monitor the | |
| 88 | 89 | // [property@Gtk.EventControllerFocus:is-focus] | |
| 89 | 90 | // property for changes. | |
| 90 | - | func (x *EventControllerFocus) ConnectEnter(cb func(EventControllerFocus)) uint32 { | |
| 91 | + | func (x *EventControllerFocus) ConnectEnter(cb *func(EventControllerFocus)) uint32 { | |
| 92 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 93 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 94 | + | return gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) | |
| 95 | + | } | |
| 96 | + | ||
| 91 | 97 | fcb := func(clsPtr uintptr) { | |
| 92 | 98 | fa := EventControllerFocus{} | |
| 93 | 99 | fa.Ptr = clsPtr | |
| 100 | + | cbFn := *cb | |
| 94 | 101 | ||
| 95 | - | cb(fa) | |
| 102 | + | cbFn(fa) | |
| 96 | 103 | ||
| 97 | 104 | } | |
| 98 | - | return gobject.SignalConnect(x.GoPointer(), "enter", purego.NewCallback(fcb)) | |
| 105 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 106 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 107 | + | return gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) | |
| 99 | 108 | } | |
| 100 | 109 | ||
| 101 | 110 | // Emitted whenever the focus leaves the widget hierarchy | |
| @@ -107,15 +116,23 @@ func (x *EventControllerFocus) ConnectEnter(cb func(EventControllerFocus)) uint3 | |||
| 107 | 116 | // to a descendent). If you are interested in these cases, you | |
| 108 | 117 | // can monitor the [property@Gtk.EventControllerFocus:is-focus] | |
| 109 | 118 | // property for changes. | |
| 110 | - | func (x *EventControllerFocus) ConnectLeave(cb func(EventControllerFocus)) uint32 { | |
| 119 | + | func (x *EventControllerFocus) ConnectLeave(cb *func(EventControllerFocus)) uint32 { | |
| 120 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 121 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 122 | + | return gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) | |
| 123 | + | } | |
| 124 | + | ||
| 111 | 125 | fcb := func(clsPtr uintptr) { | |
| 112 | 126 | fa := EventControllerFocus{} | |
| 113 | 127 | fa.Ptr = clsPtr | |
| 128 | + | cbFn := *cb | |
| 114 | 129 | ||
| 115 | - | cb(fa) | |
| 130 | + | cbFn(fa) | |
| 116 | 131 | ||
| 117 | 132 | } | |
| 118 | - | return gobject.SignalConnect(x.GoPointer(), "leave", purego.NewCallback(fcb)) | |
| 133 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 134 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 135 | + | return gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) | |
| 119 | 136 | } | |
| 120 | 137 | ||
| 121 | 138 | func init() { | |
M v4/gtk/gtkeventcontrollerkey.go +45 -12
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -109,51 +110,83 @@ func (c *EventControllerKey) SetGoPointer(ptr uintptr) { | |||
| 109 | 110 | // | |
| 110 | 111 | // See [method@Gtk.EventControllerKey.set_im_context] and | |
| 111 | 112 | // [method@Gtk.IMContext.filter_keypress]. | |
| 112 | - | func (x *EventControllerKey) ConnectImUpdate(cb func(EventControllerKey)) uint32 { | |
| 113 | + | func (x *EventControllerKey) ConnectImUpdate(cb *func(EventControllerKey)) uint32 { | |
| 114 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 115 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 116 | + | return gobject.SignalConnect(x.GoPointer(), "im-update", cbRefPtr) | |
| 117 | + | } | |
| 118 | + | ||
| 113 | 119 | fcb := func(clsPtr uintptr) { | |
| 114 | 120 | fa := EventControllerKey{} | |
| 115 | 121 | fa.Ptr = clsPtr | |
| 122 | + | cbFn := *cb | |
| 116 | 123 | ||
| 117 | - | cb(fa) | |
| 124 | + | cbFn(fa) | |
| 118 | 125 | ||
| 119 | 126 | } | |
| 120 | - | return gobject.SignalConnect(x.GoPointer(), "im-update", purego.NewCallback(fcb)) | |
| 127 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 128 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 129 | + | return gobject.SignalConnect(x.GoPointer(), "im-update", cbRefPtr) | |
| 121 | 130 | } | |
| 122 | 131 | ||
| 123 | 132 | // Emitted whenever a key is pressed. | |
| 124 | - | func (x *EventControllerKey) ConnectKeyPressed(cb func(EventControllerKey, uint, uint, gdk.ModifierType) bool) uint32 { | |
| 133 | + | func (x *EventControllerKey) ConnectKeyPressed(cb *func(EventControllerKey, uint, uint, gdk.ModifierType) bool) uint32 { | |
| 134 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 135 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 136 | + | return gobject.SignalConnect(x.GoPointer(), "key-pressed", cbRefPtr) | |
| 137 | + | } | |
| 138 | + | ||
| 125 | 139 | fcb := func(clsPtr uintptr, KeyvalVarp uint, KeycodeVarp uint, StateVarp gdk.ModifierType) bool { | |
| 126 | 140 | fa := EventControllerKey{} | |
| 127 | 141 | fa.Ptr = clsPtr | |
| 142 | + | cbFn := *cb | |
| 128 | 143 | ||
| 129 | - | return cb(fa, KeyvalVarp, KeycodeVarp, StateVarp) | |
| 144 | + | return cbFn(fa, KeyvalVarp, KeycodeVarp, StateVarp) | |
| 130 | 145 | ||
| 131 | 146 | } | |
| 132 | - | return gobject.SignalConnect(x.GoPointer(), "key-pressed", purego.NewCallback(fcb)) | |
| 147 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 148 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 149 | + | return gobject.SignalConnect(x.GoPointer(), "key-pressed", cbRefPtr) | |
| 133 | 150 | } | |
| 134 | 151 | ||
| 135 | 152 | // Emitted whenever a key is released. | |
| 136 | - | func (x *EventControllerKey) ConnectKeyReleased(cb func(EventControllerKey, uint, uint, gdk.ModifierType)) uint32 { | |
| 153 | + | func (x *EventControllerKey) ConnectKeyReleased(cb *func(EventControllerKey, uint, uint, gdk.ModifierType)) uint32 { | |
| 154 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 155 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 156 | + | return gobject.SignalConnect(x.GoPointer(), "key-released", cbRefPtr) | |
| 157 | + | } | |
| 158 | + | ||
| 137 | 159 | fcb := func(clsPtr uintptr, KeyvalVarp uint, KeycodeVarp uint, StateVarp gdk.ModifierType) { | |
| 138 | 160 | fa := EventControllerKey{} | |
| 139 | 161 | fa.Ptr = clsPtr | |
| 162 | + | cbFn := *cb | |
| 140 | 163 | ||
| 141 | - | cb(fa, KeyvalVarp, KeycodeVarp, StateVarp) | |
| 164 | + | cbFn(fa, KeyvalVarp, KeycodeVarp, StateVarp) | |
| 142 | 165 | ||
| 143 | 166 | } | |
| 144 | - | return gobject.SignalConnect(x.GoPointer(), "key-released", purego.NewCallback(fcb)) | |
| 167 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 168 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 169 | + | return gobject.SignalConnect(x.GoPointer(), "key-released", cbRefPtr) | |
| 145 | 170 | } | |
| 146 | 171 | ||
| 147 | 172 | // Emitted whenever the state of modifier keys and pointer buttons change. | |
| 148 | - | func (x *EventControllerKey) ConnectModifiers(cb func(EventControllerKey, gdk.ModifierType) bool) uint32 { | |
| 173 | + | func (x *EventControllerKey) ConnectModifiers(cb *func(EventControllerKey, gdk.ModifierType) bool) uint32 { | |
| 174 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 175 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 176 | + | return gobject.SignalConnect(x.GoPointer(), "modifiers", cbRefPtr) | |
| 177 | + | } | |
| 178 | + | ||
| 149 | 179 | fcb := func(clsPtr uintptr, KeyvalVarp gdk.ModifierType) bool { | |
| 150 | 180 | fa := EventControllerKey{} | |
| 151 | 181 | fa.Ptr = clsPtr | |
| 182 | + | cbFn := *cb | |
| 152 | 183 | ||
| 153 | - | return cb(fa, KeyvalVarp) | |
| 184 | + | return cbFn(fa, KeyvalVarp) | |
| 154 | 185 | ||
| 155 | 186 | } | |
| 156 | - | return gobject.SignalConnect(x.GoPointer(), "modifiers", purego.NewCallback(fcb)) | |
| 187 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 188 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 189 | + | return gobject.SignalConnect(x.GoPointer(), "modifiers", cbRefPtr) | |
| 157 | 190 | } | |
| 158 | 191 | ||
| 159 | 192 | func init() { | |
M v4/gtk/gtkeventcontrollerlegacy.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -56,15 +57,23 @@ func (c *EventControllerLegacy) SetGoPointer(ptr uintptr) { | |||
| 56 | 57 | } | |
| 57 | 58 | ||
| 58 | 59 | // Emitted for each GDK event delivered to @controller. | |
| 59 | - | func (x *EventControllerLegacy) ConnectEvent(cb func(EventControllerLegacy, uintptr) bool) uint32 { | |
| 60 | + | func (x *EventControllerLegacy) ConnectEvent(cb *func(EventControllerLegacy, uintptr) bool) uint32 { | |
| 61 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 62 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 63 | + | return gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) | |
| 64 | + | } | |
| 65 | + | ||
| 60 | 66 | fcb := func(clsPtr uintptr, EventVarp uintptr) bool { | |
| 61 | 67 | fa := EventControllerLegacy{} | |
| 62 | 68 | fa.Ptr = clsPtr | |
| 69 | + | cbFn := *cb | |
| 63 | 70 | ||
| 64 | - | return cb(fa, EventVarp) | |
| 71 | + | return cbFn(fa, EventVarp) | |
| 65 | 72 | ||
| 66 | 73 | } | |
| 67 | - | return gobject.SignalConnect(x.GoPointer(), "event", purego.NewCallback(fcb)) | |
| 74 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 75 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 76 | + | return gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) | |
| 68 | 77 | } | |
| 69 | 78 | ||
| 70 | 79 | func init() { | |
M v4/gtk/gtkeventcontrollermotion.go +34 -9
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -78,39 +79,63 @@ func (c *EventControllerMotion) SetGoPointer(ptr uintptr) { | |||
| 78 | 79 | } | |
| 79 | 80 | ||
| 80 | 81 | // Signals that the pointer has entered the widget. | |
| 81 | - | func (x *EventControllerMotion) ConnectEnter(cb func(EventControllerMotion, float64, float64)) uint32 { | |
| 82 | + | func (x *EventControllerMotion) ConnectEnter(cb *func(EventControllerMotion, float64, float64)) uint32 { | |
| 83 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 84 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 85 | + | return gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) | |
| 86 | + | } | |
| 87 | + | ||
| 82 | 88 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) { | |
| 83 | 89 | fa := EventControllerMotion{} | |
| 84 | 90 | fa.Ptr = clsPtr | |
| 91 | + | cbFn := *cb | |
| 85 | 92 | ||
| 86 | - | cb(fa, XVarp, YVarp) | |
| 93 | + | cbFn(fa, XVarp, YVarp) | |
| 87 | 94 | ||
| 88 | 95 | } | |
| 89 | - | return gobject.SignalConnect(x.GoPointer(), "enter", purego.NewCallback(fcb)) | |
| 96 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 97 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 98 | + | return gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) | |
| 90 | 99 | } | |
| 91 | 100 | ||
| 92 | 101 | // Signals that the pointer has left the widget. | |
| 93 | - | func (x *EventControllerMotion) ConnectLeave(cb func(EventControllerMotion)) uint32 { | |
| 102 | + | func (x *EventControllerMotion) ConnectLeave(cb *func(EventControllerMotion)) uint32 { | |
| 103 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 104 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 105 | + | return gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) | |
| 106 | + | } | |
| 107 | + | ||
| 94 | 108 | fcb := func(clsPtr uintptr) { | |
| 95 | 109 | fa := EventControllerMotion{} | |
| 96 | 110 | fa.Ptr = clsPtr | |
| 111 | + | cbFn := *cb | |
| 97 | 112 | ||
| 98 | - | cb(fa) | |
| 113 | + | cbFn(fa) | |
| 99 | 114 | ||
| 100 | 115 | } | |
| 101 | - | return gobject.SignalConnect(x.GoPointer(), "leave", purego.NewCallback(fcb)) | |
| 116 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 117 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 118 | + | return gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) | |
| 102 | 119 | } | |
| 103 | 120 | ||
| 104 | 121 | // Emitted when the pointer moves inside the widget. | |
| 105 | - | func (x *EventControllerMotion) ConnectMotion(cb func(EventControllerMotion, float64, float64)) uint32 { | |
| 122 | + | func (x *EventControllerMotion) ConnectMotion(cb *func(EventControllerMotion, float64, float64)) uint32 { | |
| 123 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 124 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 125 | + | return gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr) | |
| 126 | + | } | |
| 127 | + | ||
| 106 | 128 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) { | |
| 107 | 129 | fa := EventControllerMotion{} | |
| 108 | 130 | fa.Ptr = clsPtr | |
| 131 | + | cbFn := *cb | |
| 109 | 132 | ||
| 110 | - | cb(fa, XVarp, YVarp) | |
| 133 | + | cbFn(fa, XVarp, YVarp) | |
| 111 | 134 | ||
| 112 | 135 | } | |
| 113 | - | return gobject.SignalConnect(x.GoPointer(), "motion", purego.NewCallback(fcb)) | |
| 136 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 137 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 138 | + | return gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr) | |
| 114 | 139 | } | |
| 115 | 140 | ||
| 116 | 141 | func init() { | |
M v4/gtk/gtkeventcontrollerscroll.go +45 -12
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -141,15 +142,23 @@ func (c *EventControllerScroll) SetGoPointer(ptr uintptr) { | |||
| 141 | 142 | // @vel_x and @vel_y express the initial velocity that was | |
| 142 | 143 | // imprinted by the scroll events. @vel_x and @vel_y are expressed in | |
| 143 | 144 | // pixels/ms. | |
| 144 | - | func (x *EventControllerScroll) ConnectDecelerate(cb func(EventControllerScroll, float64, float64)) uint32 { | |
| 145 | + | func (x *EventControllerScroll) ConnectDecelerate(cb *func(EventControllerScroll, float64, float64)) uint32 { | |
| 146 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 147 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 148 | + | return gobject.SignalConnect(x.GoPointer(), "decelerate", cbRefPtr) | |
| 149 | + | } | |
| 150 | + | ||
| 145 | 151 | fcb := func(clsPtr uintptr, VelXVarp float64, VelYVarp float64) { | |
| 146 | 152 | fa := EventControllerScroll{} | |
| 147 | 153 | fa.Ptr = clsPtr | |
| 154 | + | cbFn := *cb | |
| 148 | 155 | ||
| 149 | - | cb(fa, VelXVarp, VelYVarp) | |
| 156 | + | cbFn(fa, VelXVarp, VelYVarp) | |
| 150 | 157 | ||
| 151 | 158 | } | |
| 152 | - | return gobject.SignalConnect(x.GoPointer(), "decelerate", purego.NewCallback(fcb)) | |
| 159 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 160 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 161 | + | return gobject.SignalConnect(x.GoPointer(), "decelerate", cbRefPtr) | |
| 153 | 162 | } | |
| 154 | 163 | ||
| 155 | 164 | // Signals that the widget should scroll by the | |
| @@ -157,43 +166,67 @@ func (x *EventControllerScroll) ConnectDecelerate(cb func(EventControllerScroll, | |||
| 157 | 166 | // | |
| 158 | 167 | // For the representation unit of the deltas, see | |
| 159 | 168 | // [method@Gtk.EventControllerScroll.get_unit]. | |
| 160 | - | func (x *EventControllerScroll) ConnectScroll(cb func(EventControllerScroll, float64, float64) bool) uint32 { | |
| 169 | + | func (x *EventControllerScroll) ConnectScroll(cb *func(EventControllerScroll, float64, float64) bool) uint32 { | |
| 170 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 171 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 172 | + | return gobject.SignalConnect(x.GoPointer(), "scroll", cbRefPtr) | |
| 173 | + | } | |
| 174 | + | ||
| 161 | 175 | fcb := func(clsPtr uintptr, DxVarp float64, DyVarp float64) bool { | |
| 162 | 176 | fa := EventControllerScroll{} | |
| 163 | 177 | fa.Ptr = clsPtr | |
| 178 | + | cbFn := *cb | |
| 164 | 179 | ||
| 165 | - | return cb(fa, DxVarp, DyVarp) | |
| 180 | + | return cbFn(fa, DxVarp, DyVarp) | |
| 166 | 181 | ||
| 167 | 182 | } | |
| 168 | - | return gobject.SignalConnect(x.GoPointer(), "scroll", purego.NewCallback(fcb)) | |
| 183 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 184 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 185 | + | return gobject.SignalConnect(x.GoPointer(), "scroll", cbRefPtr) | |
| 169 | 186 | } | |
| 170 | 187 | ||
| 171 | 188 | // Signals that a new scrolling operation has begun. | |
| 172 | 189 | // | |
| 173 | 190 | // It will only be emitted on devices capable of it. | |
| 174 | - | func (x *EventControllerScroll) ConnectScrollBegin(cb func(EventControllerScroll)) uint32 { | |
| 191 | + | func (x *EventControllerScroll) ConnectScrollBegin(cb *func(EventControllerScroll)) uint32 { | |
| 192 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 193 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 194 | + | return gobject.SignalConnect(x.GoPointer(), "scroll-begin", cbRefPtr) | |
| 195 | + | } | |
| 196 | + | ||
| 175 | 197 | fcb := func(clsPtr uintptr) { | |
| 176 | 198 | fa := EventControllerScroll{} | |
| 177 | 199 | fa.Ptr = clsPtr | |
| 200 | + | cbFn := *cb | |
| 178 | 201 | ||
| 179 | - | cb(fa) | |
| 202 | + | cbFn(fa) | |
| 180 | 203 | ||
| 181 | 204 | } | |
| 182 | - | return gobject.SignalConnect(x.GoPointer(), "scroll-begin", purego.NewCallback(fcb)) | |
| 205 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 206 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 207 | + | return gobject.SignalConnect(x.GoPointer(), "scroll-begin", cbRefPtr) | |
| 183 | 208 | } | |
| 184 | 209 | ||
| 185 | 210 | // Signals that a scrolling operation has finished. | |
| 186 | 211 | // | |
| 187 | 212 | // It will only be emitted on devices capable of it. | |
| 188 | - | func (x *EventControllerScroll) ConnectScrollEnd(cb func(EventControllerScroll)) uint32 { | |
| 213 | + | func (x *EventControllerScroll) ConnectScrollEnd(cb *func(EventControllerScroll)) uint32 { | |
| 214 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 215 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 216 | + | return gobject.SignalConnect(x.GoPointer(), "scroll-end", cbRefPtr) | |
| 217 | + | } | |
| 218 | + | ||
| 189 | 219 | fcb := func(clsPtr uintptr) { | |
| 190 | 220 | fa := EventControllerScroll{} | |
| 191 | 221 | fa.Ptr = clsPtr | |
| 222 | + | cbFn := *cb | |
| 192 | 223 | ||
| 193 | - | cb(fa) | |
| 224 | + | cbFn(fa) | |
| 194 | 225 | ||
| 195 | 226 | } | |
| 196 | - | return gobject.SignalConnect(x.GoPointer(), "scroll-end", purego.NewCallback(fcb)) | |
| 227 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 228 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 229 | + | return gobject.SignalConnect(x.GoPointer(), "scroll-end", cbRefPtr) | |
| 197 | 230 | } | |
| 198 | 231 | ||
| 199 | 232 | func init() { | |
M v4/gtk/gtkexpander.go +14 -3
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -326,15 +329,23 @@ func (c *Expander) SetGoPointer(ptr uintptr) { | |||
| 326 | 329 | } | |
| 327 | 330 | ||
| 328 | 331 | // Activates the `GtkExpander`. | |
| 329 | - | func (x *Expander) ConnectActivate(cb func(Expander)) uint32 { | |
| 332 | + | func (x *Expander) ConnectActivate(cb *func(Expander)) uint32 { | |
| 333 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 334 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 335 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 336 | + | } | |
| 337 | + | ||
| 330 | 338 | fcb := func(clsPtr uintptr) { | |
| 331 | 339 | fa := Expander{} | |
| 332 | 340 | fa.Ptr = clsPtr | |
| 341 | + | cbFn := *cb | |
| 333 | 342 | ||
| 334 | - | cb(fa) | |
| 343 | + | cbFn(fa) | |
| 335 | 344 | ||
| 336 | 345 | } | |
| 337 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 346 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 347 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 348 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 338 | 349 | } | |
| 339 | 350 | ||
| 340 | 351 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkexpression.go +4 -4
| @@ -163,10 +163,10 @@ var xNewCClosureExpression func([]interface{}, uintptr, uint, uintptr, uintptr, | |||
| 163 | 163 | // This function is a variant of [ctor@Gtk.ClosureExpression.new] that | |
| 164 | 164 | // creates a `GClosure` by calling g_cclosure_new() with the given | |
| 165 | 165 | // `callback_func`, `user_data` and `user_destroy`. | |
| 166 | - | func NewCClosureExpression(ValueTypeVar []interface{}, MarshalVar gobject.ClosureMarshal, NParamsVar uint, ParamsVar uintptr, CallbackFuncVar gobject.Callback, UserDataVar uintptr, UserDestroyVar gobject.ClosureNotify) *CClosureExpression { | |
| 166 | + | func NewCClosureExpression(ValueTypeVar []interface{}, MarshalVar *gobject.ClosureMarshal, NParamsVar uint, ParamsVar uintptr, CallbackFuncVar *gobject.Callback, UserDataVar uintptr, UserDestroyVar *gobject.ClosureNotify) *CClosureExpression { | |
| 167 | 167 | var cls *CClosureExpression | |
| 168 | 168 | ||
| 169 | - | cret := xNewCClosureExpression(ValueTypeVar, purego.NewCallback(MarshalVar), NParamsVar, ParamsVar, purego.NewCallback(CallbackFuncVar), UserDataVar, purego.NewCallback(UserDestroyVar)) | |
| 169 | + | cret := xNewCClosureExpression(ValueTypeVar, glib.NewCallback(MarshalVar), NParamsVar, ParamsVar, glib.NewCallback(CallbackFuncVar), UserDataVar, glib.NewCallback(UserDestroyVar)) | |
| 170 | 170 | ||
| 171 | 171 | if cret == 0 { | |
| 172 | 172 | return nil | |
| @@ -538,9 +538,9 @@ var xExpressionWatch func(uintptr, uintptr, uintptr, uintptr, uintptr) *Expressi | |||
| 538 | 538 | // GTK cannot guarantee that the evaluation did indeed change when the @notify | |
| 539 | 539 | // gets invoked, but it guarantees the opposite: When it did in fact change, | |
| 540 | 540 | // the @notify will be invoked. | |
| 541 | - | func (x *Expression) Watch(ThisVar *gobject.Object, NotifyVar ExpressionNotify, UserDataVar uintptr, UserDestroyVar glib.DestroyNotify) *ExpressionWatch { | |
| 541 | + | func (x *Expression) Watch(ThisVar *gobject.Object, NotifyVar *ExpressionNotify, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) *ExpressionWatch { | |
| 542 | 542 | ||
| 543 | - | cret := xExpressionWatch(x.GoPointer(), ThisVar.GoPointer(), purego.NewCallback(NotifyVar), UserDataVar, purego.NewCallback(UserDestroyVar)) | |
| 543 | + | cret := xExpressionWatch(x.GoPointer(), ThisVar.GoPointer(), glib.NewCallback(NotifyVar), UserDataVar, glib.NewCallback(UserDestroyVar)) | |
| 544 | 544 | return cret | |
| 545 | 545 | } | |
| 546 | 546 | ||
M v4/gtk/gtkfilechooserwidget.go +134 -36
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -65,15 +67,23 @@ func (c *FileChooserWidget) SetGoPointer(ptr uintptr) { | |||
| 65 | 67 | // folder in the file list. | |
| 66 | 68 | // | |
| 67 | 69 | // The default binding for this signal is <kbd>Alt</kbd>-<kbd>D</kbd>. | |
| 68 | - | func (x *FileChooserWidget) ConnectDesktopFolder(cb func(FileChooserWidget)) uint32 { | |
| 70 | + | func (x *FileChooserWidget) ConnectDesktopFolder(cb *func(FileChooserWidget)) uint32 { | |
| 71 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 72 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 73 | + | return gobject.SignalConnect(x.GoPointer(), "desktop-folder", cbRefPtr) | |
| 74 | + | } | |
| 75 | + | ||
| 69 | 76 | fcb := func(clsPtr uintptr) { | |
| 70 | 77 | fa := FileChooserWidget{} | |
| 71 | 78 | fa.Ptr = clsPtr | |
| 79 | + | cbFn := *cb | |
| 72 | 80 | ||
| 73 | - | cb(fa) | |
| 81 | + | cbFn(fa) | |
| 74 | 82 | ||
| 75 | 83 | } | |
| 76 | - | return gobject.SignalConnect(x.GoPointer(), "desktop-folder", purego.NewCallback(fcb)) | |
| 84 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 85 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 86 | + | return gobject.SignalConnect(x.GoPointer(), "desktop-folder", cbRefPtr) | |
| 77 | 87 | } | |
| 78 | 88 | ||
| 79 | 89 | // Emitted when the user asks for it. | |
| @@ -88,15 +98,23 @@ func (x *FileChooserWidget) ConnectDesktopFolder(cb func(FileChooserWidget)) uin | |||
| 88 | 98 | // switch to the "baz" subfolder. | |
| 89 | 99 | // | |
| 90 | 100 | // The default binding for this signal is <kbd>Alt</kbd>-<kbd>Down</kbd>. | |
| 91 | - | func (x *FileChooserWidget) ConnectDownFolder(cb func(FileChooserWidget)) uint32 { | |
| 101 | + | func (x *FileChooserWidget) ConnectDownFolder(cb *func(FileChooserWidget)) uint32 { | |
| 102 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 103 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 104 | + | return gobject.SignalConnect(x.GoPointer(), "down-folder", cbRefPtr) | |
| 105 | + | } | |
| 106 | + | ||
| 92 | 107 | fcb := func(clsPtr uintptr) { | |
| 93 | 108 | fa := FileChooserWidget{} | |
| 94 | 109 | fa.Ptr = clsPtr | |
| 110 | + | cbFn := *cb | |
| 95 | 111 | ||
| 96 | - | cb(fa) | |
| 112 | + | cbFn(fa) | |
| 97 | 113 | ||
| 98 | 114 | } | |
| 99 | - | return gobject.SignalConnect(x.GoPointer(), "down-folder", purego.NewCallback(fcb)) | |
| 115 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 116 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 117 | + | return gobject.SignalConnect(x.GoPointer(), "down-folder", cbRefPtr) | |
| 100 | 118 | } | |
| 101 | 119 | ||
| 102 | 120 | // Emitted when the user asks for it. | |
| @@ -107,15 +125,23 @@ func (x *FileChooserWidget) ConnectDownFolder(cb func(FileChooserWidget)) uint32 | |||
| 107 | 125 | // folder in the file list. | |
| 108 | 126 | // | |
| 109 | 127 | // The default binding for this signal is <kbd>Alt</kbd>-<kbd>Home</kbd>. | |
| 110 | - | func (x *FileChooserWidget) ConnectHomeFolder(cb func(FileChooserWidget)) uint32 { | |
| 128 | + | func (x *FileChooserWidget) ConnectHomeFolder(cb *func(FileChooserWidget)) uint32 { | |
| 129 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 130 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 131 | + | return gobject.SignalConnect(x.GoPointer(), "home-folder", cbRefPtr) | |
| 132 | + | } | |
| 133 | + | ||
| 111 | 134 | fcb := func(clsPtr uintptr) { | |
| 112 | 135 | fa := FileChooserWidget{} | |
| 113 | 136 | fa.Ptr = clsPtr | |
| 137 | + | cbFn := *cb | |
| 114 | 138 | ||
| 115 | - | cb(fa) | |
| 139 | + | cbFn(fa) | |
| 116 | 140 | ||
| 117 | 141 | } | |
| 118 | - | return gobject.SignalConnect(x.GoPointer(), "home-folder", purego.NewCallback(fcb)) | |
| 142 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 143 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 144 | + | return gobject.SignalConnect(x.GoPointer(), "home-folder", cbRefPtr) | |
| 119 | 145 | } | |
| 120 | 146 | ||
| 121 | 147 | // Emitted when the user asks for it. | |
| @@ -131,15 +157,23 @@ func (x *FileChooserWidget) ConnectHomeFolder(cb func(FileChooserWidget)) uint32 | |||
| 131 | 157 | // type `/` and immediately type a path name. On Unix systems, this is | |
| 132 | 158 | // bound to <kbd>~</kbd> (tilde) with a @path string of "~" itself for | |
| 133 | 159 | // access to home directories. | |
| 134 | - | func (x *FileChooserWidget) ConnectLocationPopup(cb func(FileChooserWidget, string)) uint32 { | |
| 160 | + | func (x *FileChooserWidget) ConnectLocationPopup(cb *func(FileChooserWidget, string)) uint32 { | |
| 161 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 162 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 163 | + | return gobject.SignalConnect(x.GoPointer(), "location-popup", cbRefPtr) | |
| 164 | + | } | |
| 165 | + | ||
| 135 | 166 | fcb := func(clsPtr uintptr, PathVarp string) { | |
| 136 | 167 | fa := FileChooserWidget{} | |
| 137 | 168 | fa.Ptr = clsPtr | |
| 169 | + | cbFn := *cb | |
| 138 | 170 | ||
| 139 | - | cb(fa, PathVarp) | |
| 171 | + | cbFn(fa, PathVarp) | |
| 140 | 172 | ||
| 141 | 173 | } | |
| 142 | - | return gobject.SignalConnect(x.GoPointer(), "location-popup", purego.NewCallback(fcb)) | |
| 174 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 175 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 176 | + | return gobject.SignalConnect(x.GoPointer(), "location-popup", cbRefPtr) | |
| 143 | 177 | } | |
| 144 | 178 | ||
| 145 | 179 | // Emitted when the user asks for it. | |
| @@ -150,15 +184,23 @@ func (x *FileChooserWidget) ConnectLocationPopup(cb func(FileChooserWidget, stri | |||
| 150 | 184 | // when the user pastes into a `GtkFileChooserWidget`. | |
| 151 | 185 | // | |
| 152 | 186 | // The default binding for this signal is <kbd>Control</kbd>-<kbd>V</kbd>. | |
| 153 | - | func (x *FileChooserWidget) ConnectLocationPopupOnPaste(cb func(FileChooserWidget)) uint32 { | |
| 187 | + | func (x *FileChooserWidget) ConnectLocationPopupOnPaste(cb *func(FileChooserWidget)) uint32 { | |
| 188 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 189 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 190 | + | return gobject.SignalConnect(x.GoPointer(), "location-popup-on-paste", cbRefPtr) | |
| 191 | + | } | |
| 192 | + | ||
| 154 | 193 | fcb := func(clsPtr uintptr) { | |
| 155 | 194 | fa := FileChooserWidget{} | |
| 156 | 195 | fa.Ptr = clsPtr | |
| 196 | + | cbFn := *cb | |
| 157 | 197 | ||
| 158 | - | cb(fa) | |
| 198 | + | cbFn(fa) | |
| 159 | 199 | ||
| 160 | 200 | } | |
| 161 | - | return gobject.SignalConnect(x.GoPointer(), "location-popup-on-paste", purego.NewCallback(fcb)) | |
| 201 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 202 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 203 | + | return gobject.SignalConnect(x.GoPointer(), "location-popup-on-paste", cbRefPtr) | |
| 162 | 204 | } | |
| 163 | 205 | ||
| 164 | 206 | // Emitted when the user asks for it. | |
| @@ -170,15 +212,23 @@ func (x *FileChooserWidget) ConnectLocationPopupOnPaste(cb func(FileChooserWidge | |||
| 170 | 212 | // he wishes to select. | |
| 171 | 213 | // | |
| 172 | 214 | // The default binding for this signal is <kbd>Control</kbd>-<kbd>L</kbd>. | |
| 173 | - | func (x *FileChooserWidget) ConnectLocationTogglePopup(cb func(FileChooserWidget)) uint32 { | |
| 215 | + | func (x *FileChooserWidget) ConnectLocationTogglePopup(cb *func(FileChooserWidget)) uint32 { | |
| 216 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 217 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 218 | + | return gobject.SignalConnect(x.GoPointer(), "location-toggle-popup", cbRefPtr) | |
| 219 | + | } | |
| 220 | + | ||
| 174 | 221 | fcb := func(clsPtr uintptr) { | |
| 175 | 222 | fa := FileChooserWidget{} | |
| 176 | 223 | fa.Ptr = clsPtr | |
| 224 | + | cbFn := *cb | |
| 177 | 225 | ||
| 178 | - | cb(fa) | |
| 226 | + | cbFn(fa) | |
| 179 | 227 | ||
| 180 | 228 | } | |
| 181 | - | return gobject.SignalConnect(x.GoPointer(), "location-toggle-popup", purego.NewCallback(fcb)) | |
| 229 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 230 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 231 | + | return gobject.SignalConnect(x.GoPointer(), "location-toggle-popup", cbRefPtr) | |
| 182 | 232 | } | |
| 183 | 233 | ||
| 184 | 234 | // Emitted when the user asks for it. | |
| @@ -188,15 +238,23 @@ func (x *FileChooserWidget) ConnectLocationTogglePopup(cb func(FileChooserWidget | |||
| 188 | 238 | // This is used to move the focus to the places sidebar. | |
| 189 | 239 | // | |
| 190 | 240 | // The default binding for this signal is <kbd>Alt</kbd>-<kbd>P</kbd>. | |
| 191 | - | func (x *FileChooserWidget) ConnectPlacesShortcut(cb func(FileChooserWidget)) uint32 { | |
| 241 | + | func (x *FileChooserWidget) ConnectPlacesShortcut(cb *func(FileChooserWidget)) uint32 { | |
| 242 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 243 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 244 | + | return gobject.SignalConnect(x.GoPointer(), "places-shortcut", cbRefPtr) | |
| 245 | + | } | |
| 246 | + | ||
| 192 | 247 | fcb := func(clsPtr uintptr) { | |
| 193 | 248 | fa := FileChooserWidget{} | |
| 194 | 249 | fa.Ptr = clsPtr | |
| 250 | + | cbFn := *cb | |
| 195 | 251 | ||
| 196 | - | cb(fa) | |
| 252 | + | cbFn(fa) | |
| 197 | 253 | ||
| 198 | 254 | } | |
| 199 | - | return gobject.SignalConnect(x.GoPointer(), "places-shortcut", purego.NewCallback(fcb)) | |
| 255 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 256 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 257 | + | return gobject.SignalConnect(x.GoPointer(), "places-shortcut", cbRefPtr) | |
| 200 | 258 | } | |
| 201 | 259 | ||
| 202 | 260 | // Emitted when the user asks for it. | |
| @@ -213,15 +271,23 @@ func (x *FileChooserWidget) ConnectPlacesShortcut(cb func(FileChooserWidget)) ui | |||
| 213 | 271 | // Note that in the default binding, that <kbd>Alt</kbd>-<kbd>1</kbd> is | |
| 214 | 272 | // actually defined to switch to the bookmark at index 0, and so on | |
| 215 | 273 | // successively. | |
| 216 | - | func (x *FileChooserWidget) ConnectQuickBookmark(cb func(FileChooserWidget, int)) uint32 { | |
| 274 | + | func (x *FileChooserWidget) ConnectQuickBookmark(cb *func(FileChooserWidget, int)) uint32 { | |
| 275 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 276 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 277 | + | return gobject.SignalConnect(x.GoPointer(), "quick-bookmark", cbRefPtr) | |
| 278 | + | } | |
| 279 | + | ||
| 217 | 280 | fcb := func(clsPtr uintptr, BookmarkIndexVarp int) { | |
| 218 | 281 | fa := FileChooserWidget{} | |
| 219 | 282 | fa.Ptr = clsPtr | |
| 283 | + | cbFn := *cb | |
| 220 | 284 | ||
| 221 | - | cb(fa, BookmarkIndexVarp) | |
| 285 | + | cbFn(fa, BookmarkIndexVarp) | |
| 222 | 286 | ||
| 223 | 287 | } | |
| 224 | - | return gobject.SignalConnect(x.GoPointer(), "quick-bookmark", purego.NewCallback(fcb)) | |
| 288 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 289 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 290 | + | return gobject.SignalConnect(x.GoPointer(), "quick-bookmark", cbRefPtr) | |
| 225 | 291 | } | |
| 226 | 292 | ||
| 227 | 293 | // Emitted when the user asks for it. | |
| @@ -231,15 +297,23 @@ func (x *FileChooserWidget) ConnectQuickBookmark(cb func(FileChooserWidget, int) | |||
| 231 | 297 | // This is used to make the file chooser show the Recent location. | |
| 232 | 298 | // | |
| 233 | 299 | // The default binding for this signal is <kbd>Alt</kbd>-<kbd>R</kbd>. | |
| 234 | - | func (x *FileChooserWidget) ConnectRecentShortcut(cb func(FileChooserWidget)) uint32 { | |
| 300 | + | func (x *FileChooserWidget) ConnectRecentShortcut(cb *func(FileChooserWidget)) uint32 { | |
| 301 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 302 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 303 | + | return gobject.SignalConnect(x.GoPointer(), "recent-shortcut", cbRefPtr) | |
| 304 | + | } | |
| 305 | + | ||
| 235 | 306 | fcb := func(clsPtr uintptr) { | |
| 236 | 307 | fa := FileChooserWidget{} | |
| 237 | 308 | fa.Ptr = clsPtr | |
| 309 | + | cbFn := *cb | |
| 238 | 310 | ||
| 239 | - | cb(fa) | |
| 311 | + | cbFn(fa) | |
| 240 | 312 | ||
| 241 | 313 | } | |
| 242 | - | return gobject.SignalConnect(x.GoPointer(), "recent-shortcut", purego.NewCallback(fcb)) | |
| 314 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 315 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 316 | + | return gobject.SignalConnect(x.GoPointer(), "recent-shortcut", cbRefPtr) | |
| 243 | 317 | } | |
| 244 | 318 | ||
| 245 | 319 | // Emitted when the user asks for it. | |
| @@ -249,15 +323,23 @@ func (x *FileChooserWidget) ConnectRecentShortcut(cb func(FileChooserWidget)) ui | |||
| 249 | 323 | // This is used to make the file chooser show the search entry. | |
| 250 | 324 | // | |
| 251 | 325 | // The default binding for this signal is <kbd>Alt</kbd>-<kbd>S</kbd>. | |
| 252 | - | func (x *FileChooserWidget) ConnectSearchShortcut(cb func(FileChooserWidget)) uint32 { | |
| 326 | + | func (x *FileChooserWidget) ConnectSearchShortcut(cb *func(FileChooserWidget)) uint32 { | |
| 327 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 328 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 329 | + | return gobject.SignalConnect(x.GoPointer(), "search-shortcut", cbRefPtr) | |
| 330 | + | } | |
| 331 | + | ||
| 253 | 332 | fcb := func(clsPtr uintptr) { | |
| 254 | 333 | fa := FileChooserWidget{} | |
| 255 | 334 | fa.Ptr = clsPtr | |
| 335 | + | cbFn := *cb | |
| 256 | 336 | ||
| 257 | - | cb(fa) | |
| 337 | + | cbFn(fa) | |
| 258 | 338 | ||
| 259 | 339 | } | |
| 260 | - | return gobject.SignalConnect(x.GoPointer(), "search-shortcut", purego.NewCallback(fcb)) | |
| 340 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 341 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 342 | + | return gobject.SignalConnect(x.GoPointer(), "search-shortcut", cbRefPtr) | |
| 261 | 343 | } | |
| 262 | 344 | ||
| 263 | 345 | // Emitted when the user asks for it. | |
| @@ -267,15 +349,23 @@ func (x *FileChooserWidget) ConnectSearchShortcut(cb func(FileChooserWidget)) ui | |||
| 267 | 349 | // This is used to make the file chooser display hidden files. | |
| 268 | 350 | // | |
| 269 | 351 | // The default binding for this signal is <kbd>Control</kbd>-<kbd>H</kbd>. | |
| 270 | - | func (x *FileChooserWidget) ConnectShowHidden(cb func(FileChooserWidget)) uint32 { | |
| 352 | + | func (x *FileChooserWidget) ConnectShowHidden(cb *func(FileChooserWidget)) uint32 { | |
| 353 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 354 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 355 | + | return gobject.SignalConnect(x.GoPointer(), "show-hidden", cbRefPtr) | |
| 356 | + | } | |
| 357 | + | ||
| 271 | 358 | fcb := func(clsPtr uintptr) { | |
| 272 | 359 | fa := FileChooserWidget{} | |
| 273 | 360 | fa.Ptr = clsPtr | |
| 361 | + | cbFn := *cb | |
| 274 | 362 | ||
| 275 | - | cb(fa) | |
| 363 | + | cbFn(fa) | |
| 276 | 364 | ||
| 277 | 365 | } | |
| 278 | - | return gobject.SignalConnect(x.GoPointer(), "show-hidden", purego.NewCallback(fcb)) | |
| 366 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 367 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 368 | + | return gobject.SignalConnect(x.GoPointer(), "show-hidden", cbRefPtr) | |
| 279 | 369 | } | |
| 280 | 370 | ||
| 281 | 371 | // Emitted when the user asks for it. | |
| @@ -286,15 +376,23 @@ func (x *FileChooserWidget) ConnectShowHidden(cb func(FileChooserWidget)) uint32 | |||
| 286 | 376 | // of the current folder in the file hierarchy. | |
| 287 | 377 | // | |
| 288 | 378 | // The default binding for this signal is <kbd>Alt</kbd>-<kbd>Up</kbd>. | |
| 289 | - | func (x *FileChooserWidget) ConnectUpFolder(cb func(FileChooserWidget)) uint32 { | |
| 379 | + | func (x *FileChooserWidget) ConnectUpFolder(cb *func(FileChooserWidget)) uint32 { | |
| 380 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 381 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 382 | + | return gobject.SignalConnect(x.GoPointer(), "up-folder", cbRefPtr) | |
| 383 | + | } | |
| 384 | + | ||
| 290 | 385 | fcb := func(clsPtr uintptr) { | |
| 291 | 386 | fa := FileChooserWidget{} | |
| 292 | 387 | fa.Ptr = clsPtr | |
| 388 | + | cbFn := *cb | |
| 293 | 389 | ||
| 294 | - | cb(fa) | |
| 390 | + | cbFn(fa) | |
| 295 | 391 | ||
| 296 | 392 | } | |
| 297 | - | return gobject.SignalConnect(x.GoPointer(), "up-folder", purego.NewCallback(fcb)) | |
| 393 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 394 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 395 | + | return gobject.SignalConnect(x.GoPointer(), "up-folder", cbRefPtr) | |
| 298 | 396 | } | |
| 299 | 397 | ||
| 300 | 398 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkfilter.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -152,15 +153,23 @@ func (c *Filter) SetGoPointer(ptr uintptr) { | |||
| 152 | 153 | // Depending on the @change parameter, not all items need | |
| 153 | 154 | // to be checked, but only some. Refer to the [enum@Gtk.FilterChange] | |
| 154 | 155 | // documentation for details. | |
| 155 | - | func (x *Filter) ConnectChanged(cb func(Filter, FilterChange)) uint32 { | |
| 156 | + | func (x *Filter) ConnectChanged(cb *func(Filter, FilterChange)) uint32 { | |
| 157 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 158 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 159 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 160 | + | } | |
| 161 | + | ||
| 156 | 162 | fcb := func(clsPtr uintptr, ChangeVarp FilterChange) { | |
| 157 | 163 | fa := Filter{} | |
| 158 | 164 | fa.Ptr = clsPtr | |
| 165 | + | cbFn := *cb | |
| 159 | 166 | ||
| 160 | - | cb(fa, ChangeVarp) | |
| 167 | + | cbFn(fa, ChangeVarp) | |
| 161 | 168 | ||
| 162 | 169 | } | |
| 163 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 170 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 171 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 172 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 164 | 173 | } | |
| 165 | 174 | ||
| 166 | 175 | func init() { | |
M v4/gtk/gtkflowbox.go +96 -32
| @@ -145,9 +145,9 @@ var xFlowBoxBindModel func(uintptr, uintptr, uintptr, uintptr, uintptr) | |||
| 145 | 145 | // Note that using a model is incompatible with the filtering and sorting | |
| 146 | 146 | // functionality in `GtkFlowBox`. When using a model, filtering and sorting | |
| 147 | 147 | // should be implemented by the model. | |
| 148 | - | func (x *FlowBox) BindModel(ModelVar gio.ListModel, CreateWidgetFuncVar FlowBoxCreateWidgetFunc, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) { | |
| 148 | + | func (x *FlowBox) BindModel(ModelVar gio.ListModel, CreateWidgetFuncVar *FlowBoxCreateWidgetFunc, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) { | |
| 149 | 149 | ||
| 150 | - | xFlowBoxBindModel(x.GoPointer(), ModelVar.GoPointer(), purego.NewCallback(CreateWidgetFuncVar), UserDataVar, purego.NewCallback(UserDataFreeFuncVar)) | |
| 150 | + | xFlowBoxBindModel(x.GoPointer(), ModelVar.GoPointer(), glib.NewCallback(CreateWidgetFuncVar), UserDataVar, glib.NewCallback(UserDataFreeFuncVar)) | |
| 151 | 151 | ||
| 152 | 152 | } | |
| 153 | 153 | ||
| @@ -350,9 +350,9 @@ var xFlowBoxSelectedForeach func(uintptr, uintptr, uintptr) | |||
| 350 | 350 | // | |
| 351 | 351 | // Note that the selection cannot be modified from within | |
| 352 | 352 | // this function. | |
| 353 | - | func (x *FlowBox) SelectedForeach(FuncVar FlowBoxForeachFunc, DataVar uintptr) { | |
| 353 | + | func (x *FlowBox) SelectedForeach(FuncVar *FlowBoxForeachFunc, DataVar uintptr) { | |
| 354 | 354 | ||
| 355 | - | xFlowBoxSelectedForeach(x.GoPointer(), purego.NewCallback(FuncVar), DataVar) | |
| 355 | + | xFlowBoxSelectedForeach(x.GoPointer(), glib.NewCallback(FuncVar), DataVar) | |
| 356 | 356 | ||
| 357 | 357 | } | |
| 358 | 358 | ||
| @@ -390,9 +390,9 @@ var xFlowBoxSetFilterFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 390 | 390 | // | |
| 391 | 391 | // Note that using a filter function is incompatible with using a model | |
| 392 | 392 | // (see [method@Gtk.FlowBox.bind_model]). | |
| 393 | - | func (x *FlowBox) SetFilterFunc(FilterFuncVar FlowBoxFilterFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 393 | + | func (x *FlowBox) SetFilterFunc(FilterFuncVar *FlowBoxFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 394 | 394 | ||
| 395 | - | xFlowBoxSetFilterFunc(x.GoPointer(), purego.NewCallback(FilterFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 395 | + | xFlowBoxSetFilterFunc(x.GoPointer(), glib.NewCallback(FilterFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 396 | 396 | ||
| 397 | 397 | } | |
| 398 | 398 | ||
| @@ -480,9 +480,9 @@ var xFlowBoxSetSortFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 480 | 480 | // | |
| 481 | 481 | // Note that using a sort function is incompatible with using a model | |
| 482 | 482 | // (see [method@Gtk.FlowBox.bind_model]). | |
| 483 | - | func (x *FlowBox) SetSortFunc(SortFuncVar FlowBoxSortFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 483 | + | func (x *FlowBox) SetSortFunc(SortFuncVar *FlowBoxSortFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 484 | 484 | ||
| 485 | - | xFlowBoxSetSortFunc(x.GoPointer(), purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 485 | + | xFlowBoxSetSortFunc(x.GoPointer(), glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 486 | 486 | ||
| 487 | 487 | } | |
| 488 | 488 | ||
| @@ -536,27 +536,43 @@ func (c *FlowBox) SetGoPointer(ptr uintptr) { | |||
| 536 | 536 | // Emitted when the user activates the @box. | |
| 537 | 537 | // | |
| 538 | 538 | // This is a [keybinding signal](class.SignalAction.html). | |
| 539 | - | func (x *FlowBox) ConnectActivateCursorChild(cb func(FlowBox)) uint32 { | |
| 539 | + | func (x *FlowBox) ConnectActivateCursorChild(cb *func(FlowBox)) uint32 { | |
| 540 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 541 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 542 | + | return gobject.SignalConnect(x.GoPointer(), "activate-cursor-child", cbRefPtr) | |
| 543 | + | } | |
| 544 | + | ||
| 540 | 545 | fcb := func(clsPtr uintptr) { | |
| 541 | 546 | fa := FlowBox{} | |
| 542 | 547 | fa.Ptr = clsPtr | |
| 548 | + | cbFn := *cb | |
| 543 | 549 | ||
| 544 | - | cb(fa) | |
| 550 | + | cbFn(fa) | |
| 545 | 551 | ||
| 546 | 552 | } | |
| 547 | - | return gobject.SignalConnect(x.GoPointer(), "activate-cursor-child", purego.NewCallback(fcb)) | |
| 553 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 554 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 555 | + | return gobject.SignalConnect(x.GoPointer(), "activate-cursor-child", cbRefPtr) | |
| 548 | 556 | } | |
| 549 | 557 | ||
| 550 | 558 | // Emitted when a child has been activated by the user. | |
| 551 | - | func (x *FlowBox) ConnectChildActivated(cb func(FlowBox, uintptr)) uint32 { | |
| 559 | + | func (x *FlowBox) ConnectChildActivated(cb *func(FlowBox, uintptr)) uint32 { | |
| 560 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 561 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 562 | + | return gobject.SignalConnect(x.GoPointer(), "child-activated", cbRefPtr) | |
| 563 | + | } | |
| 564 | + | ||
| 552 | 565 | fcb := func(clsPtr uintptr, ChildVarp uintptr) { | |
| 553 | 566 | fa := FlowBox{} | |
| 554 | 567 | fa.Ptr = clsPtr | |
| 568 | + | cbFn := *cb | |
| 555 | 569 | ||
| 556 | - | cb(fa, ChildVarp) | |
| 570 | + | cbFn(fa, ChildVarp) | |
| 557 | 571 | ||
| 558 | 572 | } | |
| 559 | - | return gobject.SignalConnect(x.GoPointer(), "child-activated", purego.NewCallback(fcb)) | |
| 573 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 574 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 575 | + | return gobject.SignalConnect(x.GoPointer(), "child-activated", cbRefPtr) | |
| 560 | 576 | } | |
| 561 | 577 | ||
| 562 | 578 | // Emitted when the user initiates a cursor movement. | |
| @@ -575,15 +591,23 @@ func (x *FlowBox) ConnectChildActivated(cb func(FlowBox, uintptr)) uint32 { | |||
| 575 | 591 | // move by individual children | |
| 576 | 592 | // - <kbd>Home</kbd>, <kbd>End</kbd> move to the ends of the box | |
| 577 | 593 | // - <kbd>PgUp</kbd>, <kbd>PgDn</kbd> move vertically by pages | |
| 578 | - | func (x *FlowBox) ConnectMoveCursor(cb func(FlowBox, MovementStep, int, bool, bool) bool) uint32 { | |
| 594 | + | func (x *FlowBox) ConnectMoveCursor(cb *func(FlowBox, MovementStep, int, bool, bool) bool) uint32 { | |
| 595 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 596 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 597 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 598 | + | } | |
| 599 | + | ||
| 579 | 600 | fcb := func(clsPtr uintptr, StepVarp MovementStep, CountVarp int, ExtendVarp bool, ModifyVarp bool) bool { | |
| 580 | 601 | fa := FlowBox{} | |
| 581 | 602 | fa.Ptr = clsPtr | |
| 603 | + | cbFn := *cb | |
| 582 | 604 | ||
| 583 | - | return cb(fa, StepVarp, CountVarp, ExtendVarp, ModifyVarp) | |
| 605 | + | return cbFn(fa, StepVarp, CountVarp, ExtendVarp, ModifyVarp) | |
| 584 | 606 | ||
| 585 | 607 | } | |
| 586 | - | return gobject.SignalConnect(x.GoPointer(), "move-cursor", purego.NewCallback(fcb)) | |
| 608 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 609 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 610 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 587 | 611 | } | |
| 588 | 612 | ||
| 589 | 613 | // Emitted to select all children of the box, | |
| @@ -592,15 +616,23 @@ func (x *FlowBox) ConnectMoveCursor(cb func(FlowBox, MovementStep, int, bool, bo | |||
| 592 | 616 | // This is a [keybinding signal](class.SignalAction.html). | |
| 593 | 617 | // | |
| 594 | 618 | // The default bindings for this signal is <kbd>Ctrl</kbd>-<kbd>a</kbd>. | |
| 595 | - | func (x *FlowBox) ConnectSelectAll(cb func(FlowBox)) uint32 { | |
| 619 | + | func (x *FlowBox) ConnectSelectAll(cb *func(FlowBox)) uint32 { | |
| 620 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 621 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 622 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 623 | + | } | |
| 624 | + | ||
| 596 | 625 | fcb := func(clsPtr uintptr) { | |
| 597 | 626 | fa := FlowBox{} | |
| 598 | 627 | fa.Ptr = clsPtr | |
| 628 | + | cbFn := *cb | |
| 599 | 629 | ||
| 600 | - | cb(fa) | |
| 630 | + | cbFn(fa) | |
| 601 | 631 | ||
| 602 | 632 | } | |
| 603 | - | return gobject.SignalConnect(x.GoPointer(), "select-all", purego.NewCallback(fcb)) | |
| 633 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 634 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 635 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 604 | 636 | } | |
| 605 | 637 | ||
| 606 | 638 | // Emitted when the set of selected children changes. | |
| @@ -608,15 +640,23 @@ func (x *FlowBox) ConnectSelectAll(cb func(FlowBox)) uint32 { | |||
| 608 | 640 | // Use [method@Gtk.FlowBox.selected_foreach] or | |
| 609 | 641 | // [method@Gtk.FlowBox.get_selected_children] to obtain the | |
| 610 | 642 | // selected children. | |
| 611 | - | func (x *FlowBox) ConnectSelectedChildrenChanged(cb func(FlowBox)) uint32 { | |
| 643 | + | func (x *FlowBox) ConnectSelectedChildrenChanged(cb *func(FlowBox)) uint32 { | |
| 644 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 645 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 646 | + | return gobject.SignalConnect(x.GoPointer(), "selected-children-changed", cbRefPtr) | |
| 647 | + | } | |
| 648 | + | ||
| 612 | 649 | fcb := func(clsPtr uintptr) { | |
| 613 | 650 | fa := FlowBox{} | |
| 614 | 651 | fa.Ptr = clsPtr | |
| 652 | + | cbFn := *cb | |
| 615 | 653 | ||
| 616 | - | cb(fa) | |
| 654 | + | cbFn(fa) | |
| 617 | 655 | ||
| 618 | 656 | } | |
| 619 | - | return gobject.SignalConnect(x.GoPointer(), "selected-children-changed", purego.NewCallback(fcb)) | |
| 657 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 658 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 659 | + | return gobject.SignalConnect(x.GoPointer(), "selected-children-changed", cbRefPtr) | |
| 620 | 660 | } | |
| 621 | 661 | ||
| 622 | 662 | // Emitted to toggle the selection of the child that has the focus. | |
| @@ -624,15 +664,23 @@ func (x *FlowBox) ConnectSelectedChildrenChanged(cb func(FlowBox)) uint32 { | |||
| 624 | 664 | // This is a [keybinding signal](class.SignalAction.html). | |
| 625 | 665 | // | |
| 626 | 666 | // The default binding for this signal is <kbd>Ctrl</kbd>-<kbd>Space</kbd>. | |
| 627 | - | func (x *FlowBox) ConnectToggleCursorChild(cb func(FlowBox)) uint32 { | |
| 667 | + | func (x *FlowBox) ConnectToggleCursorChild(cb *func(FlowBox)) uint32 { | |
| 668 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 669 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 670 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-child", cbRefPtr) | |
| 671 | + | } | |
| 672 | + | ||
| 628 | 673 | fcb := func(clsPtr uintptr) { | |
| 629 | 674 | fa := FlowBox{} | |
| 630 | 675 | fa.Ptr = clsPtr | |
| 676 | + | cbFn := *cb | |
| 631 | 677 | ||
| 632 | - | cb(fa) | |
| 678 | + | cbFn(fa) | |
| 633 | 679 | ||
| 634 | 680 | } | |
| 635 | - | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-child", purego.NewCallback(fcb)) | |
| 681 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 682 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 683 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-child", cbRefPtr) | |
| 636 | 684 | } | |
| 637 | 685 | ||
| 638 | 686 | // Emitted to unselect all children of the box, | |
| @@ -641,15 +689,23 @@ func (x *FlowBox) ConnectToggleCursorChild(cb func(FlowBox)) uint32 { | |||
| 641 | 689 | // This is a [keybinding signal](class.SignalAction.html). | |
| 642 | 690 | // | |
| 643 | 691 | // The default bindings for this signal is <kbd>Ctrl</kbd>-<kbd>Shift</kbd>-<kbd>a</kbd>. | |
| 644 | - | func (x *FlowBox) ConnectUnselectAll(cb func(FlowBox)) uint32 { | |
| 692 | + | func (x *FlowBox) ConnectUnselectAll(cb *func(FlowBox)) uint32 { | |
| 693 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 694 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 695 | + | return gobject.SignalConnect(x.GoPointer(), "unselect-all", cbRefPtr) | |
| 696 | + | } | |
| 697 | + | ||
| 645 | 698 | fcb := func(clsPtr uintptr) { | |
| 646 | 699 | fa := FlowBox{} | |
| 647 | 700 | fa.Ptr = clsPtr | |
| 701 | + | cbFn := *cb | |
| 648 | 702 | ||
| 649 | - | cb(fa) | |
| 703 | + | cbFn(fa) | |
| 650 | 704 | ||
| 651 | 705 | } | |
| 652 | - | return gobject.SignalConnect(x.GoPointer(), "unselect-all", purego.NewCallback(fcb)) | |
| 706 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 707 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 708 | + | return gobject.SignalConnect(x.GoPointer(), "unselect-all", cbRefPtr) | |
| 653 | 709 | } | |
| 654 | 710 | ||
| 655 | 711 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
| @@ -928,15 +984,23 @@ func (c *FlowBoxChild) SetGoPointer(ptr uintptr) { | |||
| 928 | 984 | // but it can be used by applications for their own purposes. | |
| 929 | 985 | // | |
| 930 | 986 | // The default bindings are <kbd>Space</kbd> and <kbd>Enter</kbd>. | |
| 931 | - | func (x *FlowBoxChild) ConnectActivate(cb func(FlowBoxChild)) uint32 { | |
| 987 | + | func (x *FlowBoxChild) ConnectActivate(cb *func(FlowBoxChild)) uint32 { | |
| 988 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 989 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 990 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 991 | + | } | |
| 992 | + | ||
| 932 | 993 | fcb := func(clsPtr uintptr) { | |
| 933 | 994 | fa := FlowBoxChild{} | |
| 934 | 995 | fa.Ptr = clsPtr | |
| 996 | + | cbFn := *cb | |
| 935 | 997 | ||
| 936 | - | cb(fa) | |
| 998 | + | cbFn(fa) | |
| 937 | 999 | ||
| 938 | 1000 | } | |
| 939 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 1001 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1002 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1003 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 940 | 1004 | } | |
| 941 | 1005 | ||
| 942 | 1006 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkfontbutton.go +26 -8
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -158,15 +160,23 @@ func (c *FontButton) SetGoPointer(ptr uintptr) { | |||
| 158 | 160 | // | |
| 159 | 161 | // The `::activate` signal on `GtkFontButton` is an action signal and | |
| 160 | 162 | // emitting it causes the button to present its dialog. | |
| 161 | - | func (x *FontButton) ConnectActivate(cb func(FontButton)) uint32 { | |
| 163 | + | func (x *FontButton) ConnectActivate(cb *func(FontButton)) uint32 { | |
| 164 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 165 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 166 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 167 | + | } | |
| 168 | + | ||
| 162 | 169 | fcb := func(clsPtr uintptr) { | |
| 163 | 170 | fa := FontButton{} | |
| 164 | 171 | fa.Ptr = clsPtr | |
| 172 | + | cbFn := *cb | |
| 165 | 173 | ||
| 166 | - | cb(fa) | |
| 174 | + | cbFn(fa) | |
| 167 | 175 | ||
| 168 | 176 | } | |
| 169 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 177 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 178 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 179 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 170 | 180 | } | |
| 171 | 181 | ||
| 172 | 182 | // Emitted when the user selects a font. | |
| @@ -177,15 +187,23 @@ func (x *FontButton) ConnectActivate(cb func(FontButton)) uint32 { | |||
| 177 | 187 | // Note that this signal is only emitted when the user changes the font. | |
| 178 | 188 | // If you need to react to programmatic font changes as well, use | |
| 179 | 189 | // the notify::font signal. | |
| 180 | - | func (x *FontButton) ConnectFontSet(cb func(FontButton)) uint32 { | |
| 190 | + | func (x *FontButton) ConnectFontSet(cb *func(FontButton)) uint32 { | |
| 191 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 192 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 193 | + | return gobject.SignalConnect(x.GoPointer(), "font-set", cbRefPtr) | |
| 194 | + | } | |
| 195 | + | ||
| 181 | 196 | fcb := func(clsPtr uintptr) { | |
| 182 | 197 | fa := FontButton{} | |
| 183 | 198 | fa.Ptr = clsPtr | |
| 199 | + | cbFn := *cb | |
| 184 | 200 | ||
| 185 | - | cb(fa) | |
| 201 | + | cbFn(fa) | |
| 186 | 202 | ||
| 187 | 203 | } | |
| 188 | - | return gobject.SignalConnect(x.GoPointer(), "font-set", purego.NewCallback(fcb)) | |
| 204 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 205 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 206 | + | return gobject.SignalConnect(x.GoPointer(), "font-set", cbRefPtr) | |
| 189 | 207 | } | |
| 190 | 208 | ||
| 191 | 209 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
| @@ -463,9 +481,9 @@ func (x *FontButton) GetShowPreviewEntry() bool { | |||
| 463 | 481 | ||
| 464 | 482 | // Adds a filter function that decides which fonts to display | |
| 465 | 483 | // in the font chooser. | |
| 466 | - | func (x *FontButton) SetFilterFunc(FilterVar FontFilterFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 484 | + | func (x *FontButton) SetFilterFunc(FilterVar *FontFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 467 | 485 | ||
| 468 | - | XGtkFontChooserSetFilterFunc(x.GoPointer(), purego.NewCallback(FilterVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 486 | + | XGtkFontChooserSetFilterFunc(x.GoPointer(), glib.NewCallback(FilterVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 469 | 487 | ||
| 470 | 488 | } | |
| 471 | 489 | ||
M v4/gtk/gtkfontchooser.go +3 -3
| @@ -47,7 +47,7 @@ type FontChooser interface { | |||
| 47 | 47 | GetLevel() FontChooserLevel | |
| 48 | 48 | GetPreviewText() string | |
| 49 | 49 | GetShowPreviewEntry() bool | |
| 50 | - | SetFilterFunc(FilterVar FontFilterFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) | |
| 50 | + | SetFilterFunc(FilterVar *FontFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) | |
| 51 | 51 | SetFont(FontnameVar string) | |
| 52 | 52 | SetFontDesc(FontDescVar *pango.FontDescription) | |
| 53 | 53 | SetFontMap(FontmapVar *pango.FontMap) | |
| @@ -200,9 +200,9 @@ func (x *FontChooserBase) GetShowPreviewEntry() bool { | |||
| 200 | 200 | ||
| 201 | 201 | // Adds a filter function that decides which fonts to display | |
| 202 | 202 | // in the font chooser. | |
| 203 | - | func (x *FontChooserBase) SetFilterFunc(FilterVar FontFilterFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 203 | + | func (x *FontChooserBase) SetFilterFunc(FilterVar *FontFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 204 | 204 | ||
| 205 | - | XGtkFontChooserSetFilterFunc(x.GoPointer(), purego.NewCallback(FilterVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 205 | + | XGtkFontChooserSetFilterFunc(x.GoPointer(), glib.NewCallback(FilterVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 206 | 206 | ||
| 207 | 207 | } | |
| 208 | 208 | ||
M v4/gtk/gtkfontchooserdialog.go +2 -2
| @@ -335,9 +335,9 @@ func (x *FontChooserDialog) GetShowPreviewEntry() bool { | |||
| 335 | 335 | ||
| 336 | 336 | // Adds a filter function that decides which fonts to display | |
| 337 | 337 | // in the font chooser. | |
| 338 | - | func (x *FontChooserDialog) SetFilterFunc(FilterVar FontFilterFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 338 | + | func (x *FontChooserDialog) SetFilterFunc(FilterVar *FontFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 339 | 339 | ||
| 340 | - | XGtkFontChooserSetFilterFunc(x.GoPointer(), purego.NewCallback(FilterVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 340 | + | XGtkFontChooserSetFilterFunc(x.GoPointer(), glib.NewCallback(FilterVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 341 | 341 | ||
| 342 | 342 | } | |
| 343 | 343 | ||
M v4/gtk/gtkfontchooserwidget.go +2 -2
| @@ -336,9 +336,9 @@ func (x *FontChooserWidget) GetShowPreviewEntry() bool { | |||
| 336 | 336 | ||
| 337 | 337 | // Adds a filter function that decides which fonts to display | |
| 338 | 338 | // in the font chooser. | |
| 339 | - | func (x *FontChooserWidget) SetFilterFunc(FilterVar FontFilterFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 339 | + | func (x *FontChooserWidget) SetFilterFunc(FilterVar *FontFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 340 | 340 | ||
| 341 | - | XGtkFontChooserSetFilterFunc(x.GoPointer(), purego.NewCallback(FilterVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 341 | + | XGtkFontChooserSetFilterFunc(x.GoPointer(), glib.NewCallback(FilterVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 342 | 342 | ||
| 343 | 343 | } | |
| 344 | 344 | ||
M v4/gtk/gtkgesture.go +55 -15
| @@ -402,15 +402,23 @@ func (c *Gesture) SetGoPointer(ptr uintptr) { | |||
| 402 | 402 | // (eg. a third touch on a 2-touches gesture) is lifted, in that | |
| 403 | 403 | // situation @sequence won't pertain to the current set of active | |
| 404 | 404 | // touches, so don't rely on this being true. | |
| 405 | - | func (x *Gesture) ConnectBegin(cb func(Gesture, uintptr)) uint32 { | |
| 405 | + | func (x *Gesture) ConnectBegin(cb *func(Gesture, uintptr)) uint32 { | |
| 406 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 407 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 408 | + | return gobject.SignalConnect(x.GoPointer(), "begin", cbRefPtr) | |
| 409 | + | } | |
| 410 | + | ||
| 406 | 411 | fcb := func(clsPtr uintptr, SequenceVarp uintptr) { | |
| 407 | 412 | fa := Gesture{} | |
| 408 | 413 | fa.Ptr = clsPtr | |
| 414 | + | cbFn := *cb | |
| 409 | 415 | ||
| 410 | - | cb(fa, SequenceVarp) | |
| 416 | + | cbFn(fa, SequenceVarp) | |
| 411 | 417 | ||
| 412 | 418 | } | |
| 413 | - | return gobject.SignalConnect(x.GoPointer(), "begin", purego.NewCallback(fcb)) | |
| 419 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 420 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 421 | + | return gobject.SignalConnect(x.GoPointer(), "begin", cbRefPtr) | |
| 414 | 422 | } | |
| 415 | 423 | ||
| 416 | 424 | // Emitted whenever a sequence is cancelled. | |
| @@ -423,15 +431,23 @@ func (x *Gesture) ConnectBegin(cb func(Gesture, uintptr)) uint32 { | |||
| 423 | 431 | // | |
| 424 | 432 | // @gesture must forget everything about @sequence as in | |
| 425 | 433 | // response to this signal. | |
| 426 | - | func (x *Gesture) ConnectCancel(cb func(Gesture, uintptr)) uint32 { | |
| 434 | + | func (x *Gesture) ConnectCancel(cb *func(Gesture, uintptr)) uint32 { | |
| 435 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 436 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 437 | + | return gobject.SignalConnect(x.GoPointer(), "cancel", cbRefPtr) | |
| 438 | + | } | |
| 439 | + | ||
| 427 | 440 | fcb := func(clsPtr uintptr, SequenceVarp uintptr) { | |
| 428 | 441 | fa := Gesture{} | |
| 429 | 442 | fa.Ptr = clsPtr | |
| 443 | + | cbFn := *cb | |
| 430 | 444 | ||
| 431 | - | cb(fa, SequenceVarp) | |
| 445 | + | cbFn(fa, SequenceVarp) | |
| 432 | 446 | ||
| 433 | 447 | } | |
| 434 | - | return gobject.SignalConnect(x.GoPointer(), "cancel", purego.NewCallback(fcb)) | |
| 448 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 449 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 450 | + | return gobject.SignalConnect(x.GoPointer(), "cancel", cbRefPtr) | |
| 435 | 451 | } | |
| 436 | 452 | ||
| 437 | 453 | // Emitted when @gesture either stopped recognizing the event | |
| @@ -443,44 +459,68 @@ func (x *Gesture) ConnectCancel(cb func(Gesture, uintptr)) uint32 { | |||
| 443 | 459 | // pressed touch sequence that exceeds [property@Gtk.Gesture:n-points]). | |
| 444 | 460 | // This situation may be detected by checking through | |
| 445 | 461 | // [method@Gtk.Gesture.handles_sequence]. | |
| 446 | - | func (x *Gesture) ConnectEnd(cb func(Gesture, uintptr)) uint32 { | |
| 462 | + | func (x *Gesture) ConnectEnd(cb *func(Gesture, uintptr)) uint32 { | |
| 463 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 464 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 465 | + | return gobject.SignalConnect(x.GoPointer(), "end", cbRefPtr) | |
| 466 | + | } | |
| 467 | + | ||
| 447 | 468 | fcb := func(clsPtr uintptr, SequenceVarp uintptr) { | |
| 448 | 469 | fa := Gesture{} | |
| 449 | 470 | fa.Ptr = clsPtr | |
| 471 | + | cbFn := *cb | |
| 450 | 472 | ||
| 451 | - | cb(fa, SequenceVarp) | |
| 473 | + | cbFn(fa, SequenceVarp) | |
| 452 | 474 | ||
| 453 | 475 | } | |
| 454 | - | return gobject.SignalConnect(x.GoPointer(), "end", purego.NewCallback(fcb)) | |
| 476 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 477 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 478 | + | return gobject.SignalConnect(x.GoPointer(), "end", cbRefPtr) | |
| 455 | 479 | } | |
| 456 | 480 | ||
| 457 | 481 | // Emitted whenever a sequence state changes. | |
| 458 | 482 | // | |
| 459 | 483 | // See [method@Gtk.Gesture.set_sequence_state] to know | |
| 460 | 484 | // more about the expectable sequence lifetimes. | |
| 461 | - | func (x *Gesture) ConnectSequenceStateChanged(cb func(Gesture, uintptr, EventSequenceState)) uint32 { | |
| 485 | + | func (x *Gesture) ConnectSequenceStateChanged(cb *func(Gesture, uintptr, EventSequenceState)) uint32 { | |
| 486 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 487 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 488 | + | return gobject.SignalConnect(x.GoPointer(), "sequence-state-changed", cbRefPtr) | |
| 489 | + | } | |
| 490 | + | ||
| 462 | 491 | fcb := func(clsPtr uintptr, SequenceVarp uintptr, StateVarp EventSequenceState) { | |
| 463 | 492 | fa := Gesture{} | |
| 464 | 493 | fa.Ptr = clsPtr | |
| 494 | + | cbFn := *cb | |
| 465 | 495 | ||
| 466 | - | cb(fa, SequenceVarp, StateVarp) | |
| 496 | + | cbFn(fa, SequenceVarp, StateVarp) | |
| 467 | 497 | ||
| 468 | 498 | } | |
| 469 | - | return gobject.SignalConnect(x.GoPointer(), "sequence-state-changed", purego.NewCallback(fcb)) | |
| 499 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 500 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 501 | + | return gobject.SignalConnect(x.GoPointer(), "sequence-state-changed", cbRefPtr) | |
| 470 | 502 | } | |
| 471 | 503 | ||
| 472 | 504 | // Emitted whenever an event is handled while the gesture is recognized. | |
| 473 | 505 | // | |
| 474 | 506 | // @sequence is guaranteed to pertain to the set of active touches. | |
| 475 | - | func (x *Gesture) ConnectUpdate(cb func(Gesture, uintptr)) uint32 { | |
| 507 | + | func (x *Gesture) ConnectUpdate(cb *func(Gesture, uintptr)) uint32 { | |
| 508 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 509 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 510 | + | return gobject.SignalConnect(x.GoPointer(), "update", cbRefPtr) | |
| 511 | + | } | |
| 512 | + | ||
| 476 | 513 | fcb := func(clsPtr uintptr, SequenceVarp uintptr) { | |
| 477 | 514 | fa := Gesture{} | |
| 478 | 515 | fa.Ptr = clsPtr | |
| 516 | + | cbFn := *cb | |
| 479 | 517 | ||
| 480 | - | cb(fa, SequenceVarp) | |
| 518 | + | cbFn(fa, SequenceVarp) | |
| 481 | 519 | ||
| 482 | 520 | } | |
| 483 | - | return gobject.SignalConnect(x.GoPointer(), "update", purego.NewCallback(fcb)) | |
| 521 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 522 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 523 | + | return gobject.SignalConnect(x.GoPointer(), "update", cbRefPtr) | |
| 484 | 524 | } | |
| 485 | 525 | ||
| 486 | 526 | func init() { | |
M v4/gtk/gtkgestureclick.go +45 -12
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -59,15 +60,23 @@ func (c *GestureClick) SetGoPointer(ptr uintptr) { | |||
| 59 | 60 | } | |
| 60 | 61 | ||
| 61 | 62 | // Emitted whenever a button or touch press happens. | |
| 62 | - | func (x *GestureClick) ConnectPressed(cb func(GestureClick, int, float64, float64)) uint32 { | |
| 63 | + | func (x *GestureClick) ConnectPressed(cb *func(GestureClick, int, float64, float64)) uint32 { | |
| 64 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 65 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 66 | + | return gobject.SignalConnect(x.GoPointer(), "pressed", cbRefPtr) | |
| 67 | + | } | |
| 68 | + | ||
| 63 | 69 | fcb := func(clsPtr uintptr, NPressVarp int, XVarp float64, YVarp float64) { | |
| 64 | 70 | fa := GestureClick{} | |
| 65 | 71 | fa.Ptr = clsPtr | |
| 72 | + | cbFn := *cb | |
| 66 | 73 | ||
| 67 | - | cb(fa, NPressVarp, XVarp, YVarp) | |
| 74 | + | cbFn(fa, NPressVarp, XVarp, YVarp) | |
| 68 | 75 | ||
| 69 | 76 | } | |
| 70 | - | return gobject.SignalConnect(x.GoPointer(), "pressed", purego.NewCallback(fcb)) | |
| 77 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 78 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 79 | + | return gobject.SignalConnect(x.GoPointer(), "pressed", cbRefPtr) | |
| 71 | 80 | } | |
| 72 | 81 | ||
| 73 | 82 | // Emitted when a button or touch is released. | |
| @@ -76,27 +85,43 @@ func (x *GestureClick) ConnectPressed(cb func(GestureClick, int, float64, float6 | |||
| 76 | 85 | // this event, note that [signal@Gtk.GestureClick::stopped] may | |
| 77 | 86 | // have been emitted between the press and its release, @n_press | |
| 78 | 87 | // will only start over at the next press. | |
| 79 | - | func (x *GestureClick) ConnectReleased(cb func(GestureClick, int, float64, float64)) uint32 { | |
| 88 | + | func (x *GestureClick) ConnectReleased(cb *func(GestureClick, int, float64, float64)) uint32 { | |
| 89 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 90 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 91 | + | return gobject.SignalConnect(x.GoPointer(), "released", cbRefPtr) | |
| 92 | + | } | |
| 93 | + | ||
| 80 | 94 | fcb := func(clsPtr uintptr, NPressVarp int, XVarp float64, YVarp float64) { | |
| 81 | 95 | fa := GestureClick{} | |
| 82 | 96 | fa.Ptr = clsPtr | |
| 97 | + | cbFn := *cb | |
| 83 | 98 | ||
| 84 | - | cb(fa, NPressVarp, XVarp, YVarp) | |
| 99 | + | cbFn(fa, NPressVarp, XVarp, YVarp) | |
| 85 | 100 | ||
| 86 | 101 | } | |
| 87 | - | return gobject.SignalConnect(x.GoPointer(), "released", purego.NewCallback(fcb)) | |
| 102 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 103 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 104 | + | return gobject.SignalConnect(x.GoPointer(), "released", cbRefPtr) | |
| 88 | 105 | } | |
| 89 | 106 | ||
| 90 | 107 | // Emitted whenever any time/distance threshold has been exceeded. | |
| 91 | - | func (x *GestureClick) ConnectStopped(cb func(GestureClick)) uint32 { | |
| 108 | + | func (x *GestureClick) ConnectStopped(cb *func(GestureClick)) uint32 { | |
| 109 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 110 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 111 | + | return gobject.SignalConnect(x.GoPointer(), "stopped", cbRefPtr) | |
| 112 | + | } | |
| 113 | + | ||
| 92 | 114 | fcb := func(clsPtr uintptr) { | |
| 93 | 115 | fa := GestureClick{} | |
| 94 | 116 | fa.Ptr = clsPtr | |
| 117 | + | cbFn := *cb | |
| 95 | 118 | ||
| 96 | - | cb(fa) | |
| 119 | + | cbFn(fa) | |
| 97 | 120 | ||
| 98 | 121 | } | |
| 99 | - | return gobject.SignalConnect(x.GoPointer(), "stopped", purego.NewCallback(fcb)) | |
| 122 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 123 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 124 | + | return gobject.SignalConnect(x.GoPointer(), "stopped", cbRefPtr) | |
| 100 | 125 | } | |
| 101 | 126 | ||
| 102 | 127 | // Emitted whenever the gesture receives a release | |
| @@ -105,15 +130,23 @@ func (x *GestureClick) ConnectStopped(cb func(GestureClick)) uint32 { | |||
| 105 | 130 | // Due to implicit grabs, this can only happen on situations | |
| 106 | 131 | // where input is grabbed elsewhere mid-press or the pressed | |
| 107 | 132 | // widget voluntarily relinquishes its implicit grab. | |
| 108 | - | func (x *GestureClick) ConnectUnpairedRelease(cb func(GestureClick, float64, float64, uint, uintptr)) uint32 { | |
| 133 | + | func (x *GestureClick) ConnectUnpairedRelease(cb *func(GestureClick, float64, float64, uint, uintptr)) uint32 { | |
| 134 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 135 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 136 | + | return gobject.SignalConnect(x.GoPointer(), "unpaired-release", cbRefPtr) | |
| 137 | + | } | |
| 138 | + | ||
| 109 | 139 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64, ButtonVarp uint, SequenceVarp uintptr) { | |
| 110 | 140 | fa := GestureClick{} | |
| 111 | 141 | fa.Ptr = clsPtr | |
| 142 | + | cbFn := *cb | |
| 112 | 143 | ||
| 113 | - | cb(fa, XVarp, YVarp, ButtonVarp, SequenceVarp) | |
| 144 | + | cbFn(fa, XVarp, YVarp, ButtonVarp, SequenceVarp) | |
| 114 | 145 | ||
| 115 | 146 | } | |
| 116 | - | return gobject.SignalConnect(x.GoPointer(), "unpaired-release", purego.NewCallback(fcb)) | |
| 147 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 148 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 149 | + | return gobject.SignalConnect(x.GoPointer(), "unpaired-release", cbRefPtr) | |
| 117 | 150 | } | |
| 118 | 151 | ||
| 119 | 152 | func init() { | |
M v4/gtk/gtkgesturedrag.go +34 -9
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -86,39 +87,63 @@ func (c *GestureDrag) SetGoPointer(ptr uintptr) { | |||
| 86 | 87 | } | |
| 87 | 88 | ||
| 88 | 89 | // Emitted whenever dragging starts. | |
| 89 | - | func (x *GestureDrag) ConnectDragBegin(cb func(GestureDrag, float64, float64)) uint32 { | |
| 90 | + | func (x *GestureDrag) ConnectDragBegin(cb *func(GestureDrag, float64, float64)) uint32 { | |
| 91 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 92 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 93 | + | return gobject.SignalConnect(x.GoPointer(), "drag-begin", cbRefPtr) | |
| 94 | + | } | |
| 95 | + | ||
| 90 | 96 | fcb := func(clsPtr uintptr, StartXVarp float64, StartYVarp float64) { | |
| 91 | 97 | fa := GestureDrag{} | |
| 92 | 98 | fa.Ptr = clsPtr | |
| 99 | + | cbFn := *cb | |
| 93 | 100 | ||
| 94 | - | cb(fa, StartXVarp, StartYVarp) | |
| 101 | + | cbFn(fa, StartXVarp, StartYVarp) | |
| 95 | 102 | ||
| 96 | 103 | } | |
| 97 | - | return gobject.SignalConnect(x.GoPointer(), "drag-begin", purego.NewCallback(fcb)) | |
| 104 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 105 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 106 | + | return gobject.SignalConnect(x.GoPointer(), "drag-begin", cbRefPtr) | |
| 98 | 107 | } | |
| 99 | 108 | ||
| 100 | 109 | // Emitted whenever the dragging is finished. | |
| 101 | - | func (x *GestureDrag) ConnectDragEnd(cb func(GestureDrag, float64, float64)) uint32 { | |
| 110 | + | func (x *GestureDrag) ConnectDragEnd(cb *func(GestureDrag, float64, float64)) uint32 { | |
| 111 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 112 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 113 | + | return gobject.SignalConnect(x.GoPointer(), "drag-end", cbRefPtr) | |
| 114 | + | } | |
| 115 | + | ||
| 102 | 116 | fcb := func(clsPtr uintptr, OffsetXVarp float64, OffsetYVarp float64) { | |
| 103 | 117 | fa := GestureDrag{} | |
| 104 | 118 | fa.Ptr = clsPtr | |
| 119 | + | cbFn := *cb | |
| 105 | 120 | ||
| 106 | - | cb(fa, OffsetXVarp, OffsetYVarp) | |
| 121 | + | cbFn(fa, OffsetXVarp, OffsetYVarp) | |
| 107 | 122 | ||
| 108 | 123 | } | |
| 109 | - | return gobject.SignalConnect(x.GoPointer(), "drag-end", purego.NewCallback(fcb)) | |
| 124 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 125 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 126 | + | return gobject.SignalConnect(x.GoPointer(), "drag-end", cbRefPtr) | |
| 110 | 127 | } | |
| 111 | 128 | ||
| 112 | 129 | // Emitted whenever the dragging point moves. | |
| 113 | - | func (x *GestureDrag) ConnectDragUpdate(cb func(GestureDrag, float64, float64)) uint32 { | |
| 130 | + | func (x *GestureDrag) ConnectDragUpdate(cb *func(GestureDrag, float64, float64)) uint32 { | |
| 131 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 132 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 133 | + | return gobject.SignalConnect(x.GoPointer(), "drag-update", cbRefPtr) | |
| 134 | + | } | |
| 135 | + | ||
| 114 | 136 | fcb := func(clsPtr uintptr, OffsetXVarp float64, OffsetYVarp float64) { | |
| 115 | 137 | fa := GestureDrag{} | |
| 116 | 138 | fa.Ptr = clsPtr | |
| 139 | + | cbFn := *cb | |
| 117 | 140 | ||
| 118 | - | cb(fa, OffsetXVarp, OffsetYVarp) | |
| 141 | + | cbFn(fa, OffsetXVarp, OffsetYVarp) | |
| 119 | 142 | ||
| 120 | 143 | } | |
| 121 | - | return gobject.SignalConnect(x.GoPointer(), "drag-update", purego.NewCallback(fcb)) | |
| 144 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 145 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 146 | + | return gobject.SignalConnect(x.GoPointer(), "drag-update", cbRefPtr) | |
| 122 | 147 | } | |
| 123 | 148 | ||
| 124 | 149 | func init() { | |
M v4/gtk/gtkgesturelongpress.go +23 -6
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -88,28 +89,44 @@ func (c *GestureLongPress) SetGoPointer(ptr uintptr) { | |||
| 88 | 89 | ||
| 89 | 90 | // Emitted whenever a press moved too far, or was released | |
| 90 | 91 | // before [signal@Gtk.GestureLongPress::pressed] happened. | |
| 91 | - | func (x *GestureLongPress) ConnectCancelled(cb func(GestureLongPress)) uint32 { | |
| 92 | + | func (x *GestureLongPress) ConnectCancelled(cb *func(GestureLongPress)) uint32 { | |
| 93 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 94 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 95 | + | return gobject.SignalConnect(x.GoPointer(), "cancelled", cbRefPtr) | |
| 96 | + | } | |
| 97 | + | ||
| 92 | 98 | fcb := func(clsPtr uintptr) { | |
| 93 | 99 | fa := GestureLongPress{} | |
| 94 | 100 | fa.Ptr = clsPtr | |
| 101 | + | cbFn := *cb | |
| 95 | 102 | ||
| 96 | - | cb(fa) | |
| 103 | + | cbFn(fa) | |
| 97 | 104 | ||
| 98 | 105 | } | |
| 99 | - | return gobject.SignalConnect(x.GoPointer(), "cancelled", purego.NewCallback(fcb)) | |
| 106 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 107 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 108 | + | return gobject.SignalConnect(x.GoPointer(), "cancelled", cbRefPtr) | |
| 100 | 109 | } | |
| 101 | 110 | ||
| 102 | 111 | // Emitted whenever a press goes unmoved/unreleased longer than | |
| 103 | 112 | // what the GTK defaults tell. | |
| 104 | - | func (x *GestureLongPress) ConnectPressed(cb func(GestureLongPress, float64, float64)) uint32 { | |
| 113 | + | func (x *GestureLongPress) ConnectPressed(cb *func(GestureLongPress, float64, float64)) uint32 { | |
| 114 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 115 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 116 | + | return gobject.SignalConnect(x.GoPointer(), "pressed", cbRefPtr) | |
| 117 | + | } | |
| 118 | + | ||
| 105 | 119 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) { | |
| 106 | 120 | fa := GestureLongPress{} | |
| 107 | 121 | fa.Ptr = clsPtr | |
| 122 | + | cbFn := *cb | |
| 108 | 123 | ||
| 109 | - | cb(fa, XVarp, YVarp) | |
| 124 | + | cbFn(fa, XVarp, YVarp) | |
| 110 | 125 | ||
| 111 | 126 | } | |
| 112 | - | return gobject.SignalConnect(x.GoPointer(), "pressed", purego.NewCallback(fcb)) | |
| 127 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 128 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 129 | + | return gobject.SignalConnect(x.GoPointer(), "pressed", cbRefPtr) | |
| 113 | 130 | } | |
| 114 | 131 | ||
| 115 | 132 | func init() { | |
M v4/gtk/gtkgesturepan.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -83,15 +84,23 @@ func (c *GesturePan) SetGoPointer(ptr uintptr) { | |||
| 83 | 84 | } | |
| 84 | 85 | ||
| 85 | 86 | // Emitted once a panning gesture along the expected axis is detected. | |
| 86 | - | func (x *GesturePan) ConnectPan(cb func(GesturePan, PanDirection, float64)) uint32 { | |
| 87 | + | func (x *GesturePan) ConnectPan(cb *func(GesturePan, PanDirection, float64)) uint32 { | |
| 88 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 89 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 90 | + | return gobject.SignalConnect(x.GoPointer(), "pan", cbRefPtr) | |
| 91 | + | } | |
| 92 | + | ||
| 87 | 93 | fcb := func(clsPtr uintptr, DirectionVarp PanDirection, OffsetVarp float64) { | |
| 88 | 94 | fa := GesturePan{} | |
| 89 | 95 | fa.Ptr = clsPtr | |
| 96 | + | cbFn := *cb | |
| 90 | 97 | ||
| 91 | - | cb(fa, DirectionVarp, OffsetVarp) | |
| 98 | + | cbFn(fa, DirectionVarp, OffsetVarp) | |
| 92 | 99 | ||
| 93 | 100 | } | |
| 94 | - | return gobject.SignalConnect(x.GoPointer(), "pan", purego.NewCallback(fcb)) | |
| 101 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 102 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 103 | + | return gobject.SignalConnect(x.GoPointer(), "pan", cbRefPtr) | |
| 95 | 104 | } | |
| 96 | 105 | ||
| 97 | 106 | func init() { | |
M v4/gtk/gtkgesturerotate.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -69,15 +70,23 @@ func (c *GestureRotate) SetGoPointer(ptr uintptr) { | |||
| 69 | 70 | } | |
| 70 | 71 | ||
| 71 | 72 | // Emitted when the angle between both tracked points changes. | |
| 72 | - | func (x *GestureRotate) ConnectAngleChanged(cb func(GestureRotate, float64, float64)) uint32 { | |
| 73 | + | func (x *GestureRotate) ConnectAngleChanged(cb *func(GestureRotate, float64, float64)) uint32 { | |
| 74 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 75 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 76 | + | return gobject.SignalConnect(x.GoPointer(), "angle-changed", cbRefPtr) | |
| 77 | + | } | |
| 78 | + | ||
| 73 | 79 | fcb := func(clsPtr uintptr, AngleVarp float64, AngleDeltaVarp float64) { | |
| 74 | 80 | fa := GestureRotate{} | |
| 75 | 81 | fa.Ptr = clsPtr | |
| 82 | + | cbFn := *cb | |
| 76 | 83 | ||
| 77 | - | cb(fa, AngleVarp, AngleDeltaVarp) | |
| 84 | + | cbFn(fa, AngleVarp, AngleDeltaVarp) | |
| 78 | 85 | ||
| 79 | 86 | } | |
| 80 | - | return gobject.SignalConnect(x.GoPointer(), "angle-changed", purego.NewCallback(fcb)) | |
| 87 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 88 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 89 | + | return gobject.SignalConnect(x.GoPointer(), "angle-changed", cbRefPtr) | |
| 81 | 90 | } | |
| 82 | 91 | ||
| 83 | 92 | func init() { | |
M v4/gtk/gtkgesturestylus.go +45 -12
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -127,51 +128,83 @@ func (c *GestureStylus) SetGoPointer(ptr uintptr) { | |||
| 127 | 128 | } | |
| 128 | 129 | ||
| 129 | 130 | // Emitted when the stylus touches the device. | |
| 130 | - | func (x *GestureStylus) ConnectDown(cb func(GestureStylus, float64, float64)) uint32 { | |
| 131 | + | func (x *GestureStylus) ConnectDown(cb *func(GestureStylus, float64, float64)) uint32 { | |
| 132 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 133 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 134 | + | return gobject.SignalConnect(x.GoPointer(), "down", cbRefPtr) | |
| 135 | + | } | |
| 136 | + | ||
| 131 | 137 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) { | |
| 132 | 138 | fa := GestureStylus{} | |
| 133 | 139 | fa.Ptr = clsPtr | |
| 140 | + | cbFn := *cb | |
| 134 | 141 | ||
| 135 | - | cb(fa, XVarp, YVarp) | |
| 142 | + | cbFn(fa, XVarp, YVarp) | |
| 136 | 143 | ||
| 137 | 144 | } | |
| 138 | - | return gobject.SignalConnect(x.GoPointer(), "down", purego.NewCallback(fcb)) | |
| 145 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 146 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 147 | + | return gobject.SignalConnect(x.GoPointer(), "down", cbRefPtr) | |
| 139 | 148 | } | |
| 140 | 149 | ||
| 141 | 150 | // Emitted when the stylus moves while touching the device. | |
| 142 | - | func (x *GestureStylus) ConnectMotion(cb func(GestureStylus, float64, float64)) uint32 { | |
| 151 | + | func (x *GestureStylus) ConnectMotion(cb *func(GestureStylus, float64, float64)) uint32 { | |
| 152 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 153 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 154 | + | return gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr) | |
| 155 | + | } | |
| 156 | + | ||
| 143 | 157 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) { | |
| 144 | 158 | fa := GestureStylus{} | |
| 145 | 159 | fa.Ptr = clsPtr | |
| 160 | + | cbFn := *cb | |
| 146 | 161 | ||
| 147 | - | cb(fa, XVarp, YVarp) | |
| 162 | + | cbFn(fa, XVarp, YVarp) | |
| 148 | 163 | ||
| 149 | 164 | } | |
| 150 | - | return gobject.SignalConnect(x.GoPointer(), "motion", purego.NewCallback(fcb)) | |
| 165 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 166 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 167 | + | return gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr) | |
| 151 | 168 | } | |
| 152 | 169 | ||
| 153 | 170 | // Emitted when the stylus is in proximity of the device. | |
| 154 | - | func (x *GestureStylus) ConnectProximity(cb func(GestureStylus, float64, float64)) uint32 { | |
| 171 | + | func (x *GestureStylus) ConnectProximity(cb *func(GestureStylus, float64, float64)) uint32 { | |
| 172 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 173 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 174 | + | return gobject.SignalConnect(x.GoPointer(), "proximity", cbRefPtr) | |
| 175 | + | } | |
| 176 | + | ||
| 155 | 177 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) { | |
| 156 | 178 | fa := GestureStylus{} | |
| 157 | 179 | fa.Ptr = clsPtr | |
| 180 | + | cbFn := *cb | |
| 158 | 181 | ||
| 159 | - | cb(fa, XVarp, YVarp) | |
| 182 | + | cbFn(fa, XVarp, YVarp) | |
| 160 | 183 | ||
| 161 | 184 | } | |
| 162 | - | return gobject.SignalConnect(x.GoPointer(), "proximity", purego.NewCallback(fcb)) | |
| 185 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 186 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 187 | + | return gobject.SignalConnect(x.GoPointer(), "proximity", cbRefPtr) | |
| 163 | 188 | } | |
| 164 | 189 | ||
| 165 | 190 | // Emitted when the stylus no longer touches the device. | |
| 166 | - | func (x *GestureStylus) ConnectUp(cb func(GestureStylus, float64, float64)) uint32 { | |
| 191 | + | func (x *GestureStylus) ConnectUp(cb *func(GestureStylus, float64, float64)) uint32 { | |
| 192 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 193 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 194 | + | return gobject.SignalConnect(x.GoPointer(), "up", cbRefPtr) | |
| 195 | + | } | |
| 196 | + | ||
| 167 | 197 | fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) { | |
| 168 | 198 | fa := GestureStylus{} | |
| 169 | 199 | fa.Ptr = clsPtr | |
| 200 | + | cbFn := *cb | |
| 170 | 201 | ||
| 171 | - | cb(fa, XVarp, YVarp) | |
| 202 | + | cbFn(fa, XVarp, YVarp) | |
| 172 | 203 | ||
| 173 | 204 | } | |
| 174 | - | return gobject.SignalConnect(x.GoPointer(), "up", purego.NewCallback(fcb)) | |
| 205 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 206 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 207 | + | return gobject.SignalConnect(x.GoPointer(), "up", cbRefPtr) | |
| 175 | 208 | } | |
| 176 | 209 | ||
| 177 | 210 | func init() { | |
M v4/gtk/gtkgestureswipe.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -78,15 +79,23 @@ func (c *GestureSwipe) SetGoPointer(ptr uintptr) { | |||
| 78 | 79 | // Emitted when the recognized gesture is finished. | |
| 79 | 80 | // | |
| 80 | 81 | // Velocity and direction are a product of previously recorded events. | |
| 81 | - | func (x *GestureSwipe) ConnectSwipe(cb func(GestureSwipe, float64, float64)) uint32 { | |
| 82 | + | func (x *GestureSwipe) ConnectSwipe(cb *func(GestureSwipe, float64, float64)) uint32 { | |
| 83 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 84 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 85 | + | return gobject.SignalConnect(x.GoPointer(), "swipe", cbRefPtr) | |
| 86 | + | } | |
| 87 | + | ||
| 82 | 88 | fcb := func(clsPtr uintptr, VelocityXVarp float64, VelocityYVarp float64) { | |
| 83 | 89 | fa := GestureSwipe{} | |
| 84 | 90 | fa.Ptr = clsPtr | |
| 91 | + | cbFn := *cb | |
| 85 | 92 | ||
| 86 | - | cb(fa, VelocityXVarp, VelocityYVarp) | |
| 93 | + | cbFn(fa, VelocityXVarp, VelocityYVarp) | |
| 87 | 94 | ||
| 88 | 95 | } | |
| 89 | - | return gobject.SignalConnect(x.GoPointer(), "swipe", purego.NewCallback(fcb)) | |
| 96 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 97 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 98 | + | return gobject.SignalConnect(x.GoPointer(), "swipe", cbRefPtr) | |
| 90 | 99 | } | |
| 91 | 100 | ||
| 92 | 101 | func init() { | |
M v4/gtk/gtkgesturezoom.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -71,15 +72,23 @@ func (c *GestureZoom) SetGoPointer(ptr uintptr) { | |||
| 71 | 72 | } | |
| 72 | 73 | ||
| 73 | 74 | // Emitted whenever the distance between both tracked sequences changes. | |
| 74 | - | func (x *GestureZoom) ConnectScaleChanged(cb func(GestureZoom, float64)) uint32 { | |
| 75 | + | func (x *GestureZoom) ConnectScaleChanged(cb *func(GestureZoom, float64)) uint32 { | |
| 76 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 77 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 78 | + | return gobject.SignalConnect(x.GoPointer(), "scale-changed", cbRefPtr) | |
| 79 | + | } | |
| 80 | + | ||
| 75 | 81 | fcb := func(clsPtr uintptr, ScaleVarp float64) { | |
| 76 | 82 | fa := GestureZoom{} | |
| 77 | 83 | fa.Ptr = clsPtr | |
| 84 | + | cbFn := *cb | |
| 78 | 85 | ||
| 79 | - | cb(fa, ScaleVarp) | |
| 86 | + | cbFn(fa, ScaleVarp) | |
| 80 | 87 | ||
| 81 | 88 | } | |
| 82 | - | return gobject.SignalConnect(x.GoPointer(), "scale-changed", purego.NewCallback(fcb)) | |
| 89 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 90 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 91 | + | return gobject.SignalConnect(x.GoPointer(), "scale-changed", cbRefPtr) | |
| 83 | 92 | } | |
| 84 | 93 | ||
| 85 | 94 | func init() { | |
M v4/gtk/gtkglarea.go +33 -9
| @@ -378,31 +378,47 @@ func (c *GLArea) SetGoPointer(ptr uintptr) { | |||
| 378 | 378 | // If context creation fails then the signal handler can use | |
| 379 | 379 | // [method@Gtk.GLArea.set_error] to register a more detailed error | |
| 380 | 380 | // of how the construction failed. | |
| 381 | - | func (x *GLArea) ConnectCreateContext(cb func(GLArea) gdk.GLContext) uint32 { | |
| 381 | + | func (x *GLArea) ConnectCreateContext(cb *func(GLArea) gdk.GLContext) uint32 { | |
| 382 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 383 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 384 | + | return gobject.SignalConnect(x.GoPointer(), "create-context", cbRefPtr) | |
| 385 | + | } | |
| 386 | + | ||
| 382 | 387 | fcb := func(clsPtr uintptr) uintptr { | |
| 383 | 388 | fa := GLArea{} | |
| 384 | 389 | fa.Ptr = clsPtr | |
| 390 | + | cbFn := *cb | |
| 385 | 391 | ||
| 386 | - | CreateContextCls := cb(fa) | |
| 392 | + | CreateContextCls := cbFn(fa) | |
| 387 | 393 | return CreateContextCls.Ptr | |
| 388 | 394 | ||
| 389 | 395 | } | |
| 390 | - | return gobject.SignalConnect(x.GoPointer(), "create-context", purego.NewCallback(fcb)) | |
| 396 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 397 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 398 | + | return gobject.SignalConnect(x.GoPointer(), "create-context", cbRefPtr) | |
| 391 | 399 | } | |
| 392 | 400 | ||
| 393 | 401 | // Emitted every time the contents of the `GtkGLArea` should be redrawn. | |
| 394 | 402 | // | |
| 395 | 403 | // The @context is bound to the @area prior to emitting this function, | |
| 396 | 404 | // and the buffers are painted to the window once the emission terminates. | |
| 397 | - | func (x *GLArea) ConnectRender(cb func(GLArea, uintptr) bool) uint32 { | |
| 405 | + | func (x *GLArea) ConnectRender(cb *func(GLArea, uintptr) bool) uint32 { | |
| 406 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 407 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 408 | + | return gobject.SignalConnect(x.GoPointer(), "render", cbRefPtr) | |
| 409 | + | } | |
| 410 | + | ||
| 398 | 411 | fcb := func(clsPtr uintptr, ContextVarp uintptr) bool { | |
| 399 | 412 | fa := GLArea{} | |
| 400 | 413 | fa.Ptr = clsPtr | |
| 414 | + | cbFn := *cb | |
| 401 | 415 | ||
| 402 | - | return cb(fa, ContextVarp) | |
| 416 | + | return cbFn(fa, ContextVarp) | |
| 403 | 417 | ||
| 404 | 418 | } | |
| 405 | - | return gobject.SignalConnect(x.GoPointer(), "render", purego.NewCallback(fcb)) | |
| 419 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 420 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 421 | + | return gobject.SignalConnect(x.GoPointer(), "render", cbRefPtr) | |
| 406 | 422 | } | |
| 407 | 423 | ||
| 408 | 424 | // Emitted once when the widget is realized, and then each time the widget | |
| @@ -416,15 +432,23 @@ func (x *GLArea) ConnectRender(cb func(GLArea, uintptr) bool) uint32 { | |||
| 416 | 432 | // is emitted. | |
| 417 | 433 | // | |
| 418 | 434 | // The default handler sets up the GL viewport. | |
| 419 | - | func (x *GLArea) ConnectResize(cb func(GLArea, int, int)) uint32 { | |
| 435 | + | func (x *GLArea) ConnectResize(cb *func(GLArea, int, int)) uint32 { | |
| 436 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 437 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 438 | + | return gobject.SignalConnect(x.GoPointer(), "resize", cbRefPtr) | |
| 439 | + | } | |
| 440 | + | ||
| 420 | 441 | fcb := func(clsPtr uintptr, WidthVarp int, HeightVarp int) { | |
| 421 | 442 | fa := GLArea{} | |
| 422 | 443 | fa.Ptr = clsPtr | |
| 444 | + | cbFn := *cb | |
| 423 | 445 | ||
| 424 | - | cb(fa, WidthVarp, HeightVarp) | |
| 446 | + | cbFn(fa, WidthVarp, HeightVarp) | |
| 425 | 447 | ||
| 426 | 448 | } | |
| 427 | - | return gobject.SignalConnect(x.GoPointer(), "resize", purego.NewCallback(fcb)) | |
| 449 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 450 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 451 | + | return gobject.SignalConnect(x.GoPointer(), "resize", cbRefPtr) | |
| 428 | 452 | } | |
| 429 | 453 | ||
| 430 | 454 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkgridview.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -240,15 +241,23 @@ func (c *GridView) SetGoPointer(ptr uintptr) { | |||
| 240 | 241 | // This allows for a convenient way to handle activation in a gridview. | |
| 241 | 242 | // See [property@Gtk.ListItem:activatable] for details on how to use | |
| 242 | 243 | // this signal. | |
| 243 | - | func (x *GridView) ConnectActivate(cb func(GridView, uint)) uint32 { | |
| 244 | + | func (x *GridView) ConnectActivate(cb *func(GridView, uint)) uint32 { | |
| 245 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 246 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 247 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 248 | + | } | |
| 249 | + | ||
| 244 | 250 | fcb := func(clsPtr uintptr, PositionVarp uint) { | |
| 245 | 251 | fa := GridView{} | |
| 246 | 252 | fa.Ptr = clsPtr | |
| 253 | + | cbFn := *cb | |
| 247 | 254 | ||
| 248 | - | cb(fa, PositionVarp) | |
| 255 | + | cbFn(fa, PositionVarp) | |
| 249 | 256 | ||
| 250 | 257 | } | |
| 251 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 258 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 259 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 260 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 252 | 261 | } | |
| 253 | 262 | ||
| 254 | 263 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkicontheme.go +14 -3
| @@ -2,10 +2,13 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 8 | 10 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 11 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 12 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 13 | ) | |
| 11 | 14 | ||
| @@ -581,15 +584,23 @@ func (c *IconTheme) SetGoPointer(ptr uintptr) { | |||
| 581 | 584 | // This can happen becuase current icon theme is switched or | |
| 582 | 585 | // because GTK detects that a change has occurred in the | |
| 583 | 586 | // contents of the current icon theme. | |
| 584 | - | func (x *IconTheme) ConnectChanged(cb func(IconTheme)) uint32 { | |
| 587 | + | func (x *IconTheme) ConnectChanged(cb *func(IconTheme)) uint32 { | |
| 588 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 589 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 590 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 591 | + | } | |
| 592 | + | ||
| 585 | 593 | fcb := func(clsPtr uintptr) { | |
| 586 | 594 | fa := IconTheme{} | |
| 587 | 595 | fa.Ptr = clsPtr | |
| 596 | + | cbFn := *cb | |
| 588 | 597 | ||
| 589 | - | cb(fa) | |
| 598 | + | cbFn(fa) | |
| 590 | 599 | ||
| 591 | 600 | } | |
| 592 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 601 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 602 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 603 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 593 | 604 | } | |
| 594 | 605 | ||
| 595 | 606 | var xIconThemeGetForDisplay func(uintptr) uintptr | |
M v4/gtk/gtkiconview.go +94 -28
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| @@ -511,9 +513,9 @@ var xIconViewSelectedForeach func(uintptr, uintptr, uintptr) | |||
| 511 | 513 | ||
| 512 | 514 | // Calls a function for each selected icon. Note that the model or | |
| 513 | 515 | // selection cannot be modified from within this function. | |
| 514 | - | func (x *IconView) SelectedForeach(FuncVar IconViewForeachFunc, DataVar uintptr) { | |
| 516 | + | func (x *IconView) SelectedForeach(FuncVar *IconViewForeachFunc, DataVar uintptr) { | |
| 515 | 517 | ||
| 516 | - | xIconViewSelectedForeach(x.GoPointer(), purego.NewCallback(FuncVar), DataVar) | |
| 518 | + | xIconViewSelectedForeach(x.GoPointer(), glib.NewCallback(FuncVar), DataVar) | |
| 517 | 519 | ||
| 518 | 520 | } | |
| 519 | 521 | ||
| @@ -807,15 +809,23 @@ func (c *IconView) SetGoPointer(ptr uintptr) { | |||
| 807 | 809 | // programmatically. | |
| 808 | 810 | // | |
| 809 | 811 | // The default bindings for this signal are Space, Return and Enter. | |
| 810 | - | func (x *IconView) ConnectActivateCursorItem(cb func(IconView) bool) uint32 { | |
| 812 | + | func (x *IconView) ConnectActivateCursorItem(cb *func(IconView) bool) uint32 { | |
| 813 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 814 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 815 | + | return gobject.SignalConnect(x.GoPointer(), "activate-cursor-item", cbRefPtr) | |
| 816 | + | } | |
| 817 | + | ||
| 811 | 818 | fcb := func(clsPtr uintptr) bool { | |
| 812 | 819 | fa := IconView{} | |
| 813 | 820 | fa.Ptr = clsPtr | |
| 821 | + | cbFn := *cb | |
| 814 | 822 | ||
| 815 | - | return cb(fa) | |
| 823 | + | return cbFn(fa) | |
| 816 | 824 | ||
| 817 | 825 | } | |
| 818 | - | return gobject.SignalConnect(x.GoPointer(), "activate-cursor-item", purego.NewCallback(fcb)) | |
| 826 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 827 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 828 | + | return gobject.SignalConnect(x.GoPointer(), "activate-cursor-item", cbRefPtr) | |
| 819 | 829 | } | |
| 820 | 830 | ||
| 821 | 831 | // The ::item-activated signal is emitted when the method | |
| @@ -825,15 +835,23 @@ func (x *IconView) ConnectActivateCursorItem(cb func(IconView) bool) uint32 { | |||
| 825 | 835 | // "activate-on-single-click" property set to %TRUE. It is also | |
| 826 | 836 | // emitted when a non-editable item is selected and one of the keys: | |
| 827 | 837 | // Space, Return or Enter is pressed. | |
| 828 | - | func (x *IconView) ConnectItemActivated(cb func(IconView, uintptr)) uint32 { | |
| 838 | + | func (x *IconView) ConnectItemActivated(cb *func(IconView, uintptr)) uint32 { | |
| 839 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 840 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 841 | + | return gobject.SignalConnect(x.GoPointer(), "item-activated", cbRefPtr) | |
| 842 | + | } | |
| 843 | + | ||
| 829 | 844 | fcb := func(clsPtr uintptr, PathVarp uintptr) { | |
| 830 | 845 | fa := IconView{} | |
| 831 | 846 | fa.Ptr = clsPtr | |
| 847 | + | cbFn := *cb | |
| 832 | 848 | ||
| 833 | - | cb(fa, PathVarp) | |
| 849 | + | cbFn(fa, PathVarp) | |
| 834 | 850 | ||
| 835 | 851 | } | |
| 836 | - | return gobject.SignalConnect(x.GoPointer(), "item-activated", purego.NewCallback(fcb)) | |
| 852 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 853 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 854 | + | return gobject.SignalConnect(x.GoPointer(), "item-activated", cbRefPtr) | |
| 837 | 855 | } | |
| 838 | 856 | ||
| 839 | 857 | // The ::move-cursor signal is a | |
| @@ -850,15 +868,23 @@ func (x *IconView) ConnectItemActivated(cb func(IconView, uintptr)) uint32 { | |||
| 850 | 868 | // - PageUp/PageDown which move by "pages" | |
| 851 | 869 | // All of these will extend the selection when combined with | |
| 852 | 870 | // the Shift modifier. | |
| 853 | - | func (x *IconView) ConnectMoveCursor(cb func(IconView, MovementStep, int, bool, bool) bool) uint32 { | |
| 871 | + | func (x *IconView) ConnectMoveCursor(cb *func(IconView, MovementStep, int, bool, bool) bool) uint32 { | |
| 872 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 873 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 874 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 875 | + | } | |
| 876 | + | ||
| 854 | 877 | fcb := func(clsPtr uintptr, StepVarp MovementStep, CountVarp int, ExtendVarp bool, ModifyVarp bool) bool { | |
| 855 | 878 | fa := IconView{} | |
| 856 | 879 | fa.Ptr = clsPtr | |
| 880 | + | cbFn := *cb | |
| 857 | 881 | ||
| 858 | - | return cb(fa, StepVarp, CountVarp, ExtendVarp, ModifyVarp) | |
| 882 | + | return cbFn(fa, StepVarp, CountVarp, ExtendVarp, ModifyVarp) | |
| 859 | 883 | ||
| 860 | 884 | } | |
| 861 | - | return gobject.SignalConnect(x.GoPointer(), "move-cursor", purego.NewCallback(fcb)) | |
| 885 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 886 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 887 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 862 | 888 | } | |
| 863 | 889 | ||
| 864 | 890 | // A [keybinding signal][class@Gtk.SignalAction] | |
| @@ -869,15 +895,23 @@ func (x *IconView) ConnectMoveCursor(cb func(IconView, MovementStep, int, bool, | |||
| 869 | 895 | // programmatically. | |
| 870 | 896 | // | |
| 871 | 897 | // The default binding for this signal is Ctrl-a. | |
| 872 | - | func (x *IconView) ConnectSelectAll(cb func(IconView)) uint32 { | |
| 898 | + | func (x *IconView) ConnectSelectAll(cb *func(IconView)) uint32 { | |
| 899 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 900 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 901 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 902 | + | } | |
| 903 | + | ||
| 873 | 904 | fcb := func(clsPtr uintptr) { | |
| 874 | 905 | fa := IconView{} | |
| 875 | 906 | fa.Ptr = clsPtr | |
| 907 | + | cbFn := *cb | |
| 876 | 908 | ||
| 877 | - | cb(fa) | |
| 909 | + | cbFn(fa) | |
| 878 | 910 | ||
| 879 | 911 | } | |
| 880 | - | return gobject.SignalConnect(x.GoPointer(), "select-all", purego.NewCallback(fcb)) | |
| 912 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 913 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 914 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 881 | 915 | } | |
| 882 | 916 | ||
| 883 | 917 | // A [keybinding signal][class@Gtk.SignalAction] | |
| @@ -889,28 +923,44 @@ func (x *IconView) ConnectSelectAll(cb func(IconView)) uint32 { | |||
| 889 | 923 | // programmatically. | |
| 890 | 924 | // | |
| 891 | 925 | // There is no default binding for this signal. | |
| 892 | - | func (x *IconView) ConnectSelectCursorItem(cb func(IconView)) uint32 { | |
| 926 | + | func (x *IconView) ConnectSelectCursorItem(cb *func(IconView)) uint32 { | |
| 927 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 928 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 929 | + | return gobject.SignalConnect(x.GoPointer(), "select-cursor-item", cbRefPtr) | |
| 930 | + | } | |
| 931 | + | ||
| 893 | 932 | fcb := func(clsPtr uintptr) { | |
| 894 | 933 | fa := IconView{} | |
| 895 | 934 | fa.Ptr = clsPtr | |
| 935 | + | cbFn := *cb | |
| 896 | 936 | ||
| 897 | - | cb(fa) | |
| 937 | + | cbFn(fa) | |
| 898 | 938 | ||
| 899 | 939 | } | |
| 900 | - | return gobject.SignalConnect(x.GoPointer(), "select-cursor-item", purego.NewCallback(fcb)) | |
| 940 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 941 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 942 | + | return gobject.SignalConnect(x.GoPointer(), "select-cursor-item", cbRefPtr) | |
| 901 | 943 | } | |
| 902 | 944 | ||
| 903 | 945 | // The ::selection-changed signal is emitted when the selection | |
| 904 | 946 | // (i.e. the set of selected items) changes. | |
| 905 | - | func (x *IconView) ConnectSelectionChanged(cb func(IconView)) uint32 { | |
| 947 | + | func (x *IconView) ConnectSelectionChanged(cb *func(IconView)) uint32 { | |
| 948 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 949 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 950 | + | return gobject.SignalConnect(x.GoPointer(), "selection-changed", cbRefPtr) | |
| 951 | + | } | |
| 952 | + | ||
| 906 | 953 | fcb := func(clsPtr uintptr) { | |
| 907 | 954 | fa := IconView{} | |
| 908 | 955 | fa.Ptr = clsPtr | |
| 956 | + | cbFn := *cb | |
| 909 | 957 | ||
| 910 | - | cb(fa) | |
| 958 | + | cbFn(fa) | |
| 911 | 959 | ||
| 912 | 960 | } | |
| 913 | - | return gobject.SignalConnect(x.GoPointer(), "selection-changed", purego.NewCallback(fcb)) | |
| 961 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 962 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 963 | + | return gobject.SignalConnect(x.GoPointer(), "selection-changed", cbRefPtr) | |
| 914 | 964 | } | |
| 915 | 965 | ||
| 916 | 966 | // A [keybinding signal][class@Gtk.SignalAction] | |
| @@ -923,15 +973,23 @@ func (x *IconView) ConnectSelectionChanged(cb func(IconView)) uint32 { | |||
| 923 | 973 | // programmatically. | |
| 924 | 974 | // | |
| 925 | 975 | // There is no default binding for this signal is Ctrl-Space. | |
| 926 | - | func (x *IconView) ConnectToggleCursorItem(cb func(IconView)) uint32 { | |
| 976 | + | func (x *IconView) ConnectToggleCursorItem(cb *func(IconView)) uint32 { | |
| 977 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 978 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 979 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-item", cbRefPtr) | |
| 980 | + | } | |
| 981 | + | ||
| 927 | 982 | fcb := func(clsPtr uintptr) { | |
| 928 | 983 | fa := IconView{} | |
| 929 | 984 | fa.Ptr = clsPtr | |
| 985 | + | cbFn := *cb | |
| 930 | 986 | ||
| 931 | - | cb(fa) | |
| 987 | + | cbFn(fa) | |
| 932 | 988 | ||
| 933 | 989 | } | |
| 934 | - | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-item", purego.NewCallback(fcb)) | |
| 990 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 991 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 992 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-item", cbRefPtr) | |
| 935 | 993 | } | |
| 936 | 994 | ||
| 937 | 995 | // A [keybinding signal][class@Gtk.SignalAction] | |
| @@ -942,15 +1000,23 @@ func (x *IconView) ConnectToggleCursorItem(cb func(IconView)) uint32 { | |||
| 942 | 1000 | // programmatically. | |
| 943 | 1001 | // | |
| 944 | 1002 | // The default binding for this signal is Ctrl-Shift-a. | |
| 945 | - | func (x *IconView) ConnectUnselectAll(cb func(IconView)) uint32 { | |
| 1003 | + | func (x *IconView) ConnectUnselectAll(cb *func(IconView)) uint32 { | |
| 1004 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1005 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1006 | + | return gobject.SignalConnect(x.GoPointer(), "unselect-all", cbRefPtr) | |
| 1007 | + | } | |
| 1008 | + | ||
| 946 | 1009 | fcb := func(clsPtr uintptr) { | |
| 947 | 1010 | fa := IconView{} | |
| 948 | 1011 | fa.Ptr = clsPtr | |
| 1012 | + | cbFn := *cb | |
| 949 | 1013 | ||
| 950 | - | cb(fa) | |
| 1014 | + | cbFn(fa) | |
| 951 | 1015 | ||
| 952 | 1016 | } | |
| 953 | - | return gobject.SignalConnect(x.GoPointer(), "unselect-all", purego.NewCallback(fcb)) | |
| 1017 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1018 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1019 | + | return gobject.SignalConnect(x.GoPointer(), "unselect-all", cbRefPtr) | |
| 954 | 1020 | } | |
| 955 | 1021 | ||
| 956 | 1022 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
| @@ -1202,9 +1268,9 @@ func (x *IconView) SetAttributes(CellVar *CellRenderer, varArgs ...interface{}) | |||
| 1202 | 1268 | // cell renderer(s) as appropriate. | |
| 1203 | 1269 | // | |
| 1204 | 1270 | // @func may be %NULL to remove a previously set function. | |
| 1205 | - | func (x *IconView) SetCellDataFunc(CellVar *CellRenderer, FuncVar CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 1271 | + | func (x *IconView) SetCellDataFunc(CellVar *CellRenderer, FuncVar *CellLayoutDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 1206 | 1272 | ||
| 1207 | - | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(DestroyVar)) | |
| 1273 | + | XGtkCellLayoutSetCellDataFunc(x.GoPointer(), CellVar.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) | |
| 1208 | 1274 | ||
| 1209 | 1275 | } | |
| 1210 | 1276 | ||
M v4/gtk/gtkimcontext.go +67 -18
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/pango" | |
| 12 | 13 | ) | |
| @@ -284,28 +285,44 @@ func (c *IMContext) SetGoPointer(ptr uintptr) { | |||
| 284 | 285 | // | |
| 285 | 286 | // This can be a single character immediately after a key press or | |
| 286 | 287 | // the final result of preediting. | |
| 287 | - | func (x *IMContext) ConnectCommit(cb func(IMContext, string)) uint32 { | |
| 288 | + | func (x *IMContext) ConnectCommit(cb *func(IMContext, string)) uint32 { | |
| 289 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 290 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 291 | + | return gobject.SignalConnect(x.GoPointer(), "commit", cbRefPtr) | |
| 292 | + | } | |
| 293 | + | ||
| 288 | 294 | fcb := func(clsPtr uintptr, StrVarp string) { | |
| 289 | 295 | fa := IMContext{} | |
| 290 | 296 | fa.Ptr = clsPtr | |
| 297 | + | cbFn := *cb | |
| 291 | 298 | ||
| 292 | - | cb(fa, StrVarp) | |
| 299 | + | cbFn(fa, StrVarp) | |
| 293 | 300 | ||
| 294 | 301 | } | |
| 295 | - | return gobject.SignalConnect(x.GoPointer(), "commit", purego.NewCallback(fcb)) | |
| 302 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 303 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 304 | + | return gobject.SignalConnect(x.GoPointer(), "commit", cbRefPtr) | |
| 296 | 305 | } | |
| 297 | 306 | ||
| 298 | 307 | // The ::delete-surrounding signal is emitted when the input method | |
| 299 | 308 | // needs to delete all or part of the context surrounding the cursor. | |
| 300 | - | func (x *IMContext) ConnectDeleteSurrounding(cb func(IMContext, int, int) bool) uint32 { | |
| 309 | + | func (x *IMContext) ConnectDeleteSurrounding(cb *func(IMContext, int, int) bool) uint32 { | |
| 310 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 311 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 312 | + | return gobject.SignalConnect(x.GoPointer(), "delete-surrounding", cbRefPtr) | |
| 313 | + | } | |
| 314 | + | ||
| 301 | 315 | fcb := func(clsPtr uintptr, OffsetVarp int, NCharsVarp int) bool { | |
| 302 | 316 | fa := IMContext{} | |
| 303 | 317 | fa.Ptr = clsPtr | |
| 318 | + | cbFn := *cb | |
| 304 | 319 | ||
| 305 | - | return cb(fa, OffsetVarp, NCharsVarp) | |
| 320 | + | return cbFn(fa, OffsetVarp, NCharsVarp) | |
| 306 | 321 | ||
| 307 | 322 | } | |
| 308 | - | return gobject.SignalConnect(x.GoPointer(), "delete-surrounding", purego.NewCallback(fcb)) | |
| 323 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 324 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 325 | + | return gobject.SignalConnect(x.GoPointer(), "delete-surrounding", cbRefPtr) | |
| 309 | 326 | } | |
| 310 | 327 | ||
| 311 | 328 | // The ::preedit-changed signal is emitted whenever the preedit sequence | |
| @@ -313,41 +330,65 @@ func (x *IMContext) ConnectDeleteSurrounding(cb func(IMContext, int, int) bool) | |||
| 313 | 330 | // | |
| 314 | 331 | // It is also emitted at the end of a preedit sequence, in which case | |
| 315 | 332 | // [method@Gtk.IMContext.get_preedit_string] returns the empty string. | |
| 316 | - | func (x *IMContext) ConnectPreeditChanged(cb func(IMContext)) uint32 { | |
| 333 | + | func (x *IMContext) ConnectPreeditChanged(cb *func(IMContext)) uint32 { | |
| 334 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 335 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 336 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-changed", cbRefPtr) | |
| 337 | + | } | |
| 338 | + | ||
| 317 | 339 | fcb := func(clsPtr uintptr) { | |
| 318 | 340 | fa := IMContext{} | |
| 319 | 341 | fa.Ptr = clsPtr | |
| 342 | + | cbFn := *cb | |
| 320 | 343 | ||
| 321 | - | cb(fa) | |
| 344 | + | cbFn(fa) | |
| 322 | 345 | ||
| 323 | 346 | } | |
| 324 | - | return gobject.SignalConnect(x.GoPointer(), "preedit-changed", purego.NewCallback(fcb)) | |
| 347 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 348 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 349 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-changed", cbRefPtr) | |
| 325 | 350 | } | |
| 326 | 351 | ||
| 327 | 352 | // The ::preedit-end signal is emitted when a preediting sequence | |
| 328 | 353 | // has been completed or canceled. | |
| 329 | - | func (x *IMContext) ConnectPreeditEnd(cb func(IMContext)) uint32 { | |
| 354 | + | func (x *IMContext) ConnectPreeditEnd(cb *func(IMContext)) uint32 { | |
| 355 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 356 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 357 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-end", cbRefPtr) | |
| 358 | + | } | |
| 359 | + | ||
| 330 | 360 | fcb := func(clsPtr uintptr) { | |
| 331 | 361 | fa := IMContext{} | |
| 332 | 362 | fa.Ptr = clsPtr | |
| 363 | + | cbFn := *cb | |
| 333 | 364 | ||
| 334 | - | cb(fa) | |
| 365 | + | cbFn(fa) | |
| 335 | 366 | ||
| 336 | 367 | } | |
| 337 | - | return gobject.SignalConnect(x.GoPointer(), "preedit-end", purego.NewCallback(fcb)) | |
| 368 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 369 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 370 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-end", cbRefPtr) | |
| 338 | 371 | } | |
| 339 | 372 | ||
| 340 | 373 | // The ::preedit-start signal is emitted when a new preediting sequence | |
| 341 | 374 | // starts. | |
| 342 | - | func (x *IMContext) ConnectPreeditStart(cb func(IMContext)) uint32 { | |
| 375 | + | func (x *IMContext) ConnectPreeditStart(cb *func(IMContext)) uint32 { | |
| 376 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 377 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 378 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-start", cbRefPtr) | |
| 379 | + | } | |
| 380 | + | ||
| 343 | 381 | fcb := func(clsPtr uintptr) { | |
| 344 | 382 | fa := IMContext{} | |
| 345 | 383 | fa.Ptr = clsPtr | |
| 384 | + | cbFn := *cb | |
| 346 | 385 | ||
| 347 | - | cb(fa) | |
| 386 | + | cbFn(fa) | |
| 348 | 387 | ||
| 349 | 388 | } | |
| 350 | - | return gobject.SignalConnect(x.GoPointer(), "preedit-start", purego.NewCallback(fcb)) | |
| 389 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 390 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 391 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-start", cbRefPtr) | |
| 351 | 392 | } | |
| 352 | 393 | ||
| 353 | 394 | // The ::retrieve-surrounding signal is emitted when the input method | |
| @@ -355,15 +396,23 @@ func (x *IMContext) ConnectPreeditStart(cb func(IMContext)) uint32 { | |||
| 355 | 396 | // | |
| 356 | 397 | // The callback should set the input method surrounding context by | |
| 357 | 398 | // calling the [method@Gtk.IMContext.set_surrounding] method. | |
| 358 | - | func (x *IMContext) ConnectRetrieveSurrounding(cb func(IMContext) bool) uint32 { | |
| 399 | + | func (x *IMContext) ConnectRetrieveSurrounding(cb *func(IMContext) bool) uint32 { | |
| 400 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 401 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 402 | + | return gobject.SignalConnect(x.GoPointer(), "retrieve-surrounding", cbRefPtr) | |
| 403 | + | } | |
| 404 | + | ||
| 359 | 405 | fcb := func(clsPtr uintptr) bool { | |
| 360 | 406 | fa := IMContext{} | |
| 361 | 407 | fa.Ptr = clsPtr | |
| 408 | + | cbFn := *cb | |
| 362 | 409 | ||
| 363 | - | return cb(fa) | |
| 410 | + | return cbFn(fa) | |
| 364 | 411 | ||
| 365 | 412 | } | |
| 366 | - | return gobject.SignalConnect(x.GoPointer(), "retrieve-surrounding", purego.NewCallback(fcb)) | |
| 413 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 414 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 415 | + | return gobject.SignalConnect(x.GoPointer(), "retrieve-surrounding", cbRefPtr) | |
| 367 | 416 | } | |
| 368 | 417 | ||
| 369 | 418 | func init() { | |
M v4/gtk/gtkinfobar.go +25 -6
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -331,15 +334,23 @@ func (c *InfoBar) SetGoPointer(ptr uintptr) { | |||
| 331 | 334 | // The ::close signal is a [keybinding signal](class.SignalAction.html). | |
| 332 | 335 | // | |
| 333 | 336 | // The default binding for this signal is the Escape key. | |
| 334 | - | func (x *InfoBar) ConnectClose(cb func(InfoBar)) uint32 { | |
| 337 | + | func (x *InfoBar) ConnectClose(cb *func(InfoBar)) uint32 { | |
| 338 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 339 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 340 | + | return gobject.SignalConnect(x.GoPointer(), "close", cbRefPtr) | |
| 341 | + | } | |
| 342 | + | ||
| 335 | 343 | fcb := func(clsPtr uintptr) { | |
| 336 | 344 | fa := InfoBar{} | |
| 337 | 345 | fa.Ptr = clsPtr | |
| 346 | + | cbFn := *cb | |
| 338 | 347 | ||
| 339 | - | cb(fa) | |
| 348 | + | cbFn(fa) | |
| 340 | 349 | ||
| 341 | 350 | } | |
| 342 | - | return gobject.SignalConnect(x.GoPointer(), "close", purego.NewCallback(fcb)) | |
| 351 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 352 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 353 | + | return gobject.SignalConnect(x.GoPointer(), "close", cbRefPtr) | |
| 343 | 354 | } | |
| 344 | 355 | ||
| 345 | 356 | // Emitted when an action widget is clicked. | |
| @@ -347,15 +358,23 @@ func (x *InfoBar) ConnectClose(cb func(InfoBar)) uint32 { | |||
| 347 | 358 | // The signal is also emitted when the application programmer | |
| 348 | 359 | // calls [method@Gtk.InfoBar.response]. The @response_id depends | |
| 349 | 360 | // on which action widget was clicked. | |
| 350 | - | func (x *InfoBar) ConnectResponse(cb func(InfoBar, int)) uint32 { | |
| 361 | + | func (x *InfoBar) ConnectResponse(cb *func(InfoBar, int)) uint32 { | |
| 362 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 363 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 364 | + | return gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr) | |
| 365 | + | } | |
| 366 | + | ||
| 351 | 367 | fcb := func(clsPtr uintptr, ResponseIdVarp int) { | |
| 352 | 368 | fa := InfoBar{} | |
| 353 | 369 | fa.Ptr = clsPtr | |
| 370 | + | cbFn := *cb | |
| 354 | 371 | ||
| 355 | - | cb(fa, ResponseIdVarp) | |
| 372 | + | cbFn(fa, ResponseIdVarp) | |
| 356 | 373 | ||
| 357 | 374 | } | |
| 358 | - | return gobject.SignalConnect(x.GoPointer(), "response", purego.NewCallback(fcb)) | |
| 375 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 376 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 377 | + | return gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr) | |
| 359 | 378 | } | |
| 360 | 379 | ||
| 361 | 380 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtklabel.go +47 -12
| @@ -2,9 +2,12 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 12 | "github.com/jwijenbergh/puregotk/v4/pango" | |
| 10 | 13 | ) | |
| @@ -925,30 +928,46 @@ func (c *Label) SetGoPointer(ptr uintptr) { | |||
| 925 | 928 | // if they need to control activation of URIs programmatically. | |
| 926 | 929 | // | |
| 927 | 930 | // The default bindings for this signal are all forms of the Enter key. | |
| 928 | - | func (x *Label) ConnectActivateCurrentLink(cb func(Label)) uint32 { | |
| 931 | + | func (x *Label) ConnectActivateCurrentLink(cb *func(Label)) uint32 { | |
| 932 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 933 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 934 | + | return gobject.SignalConnect(x.GoPointer(), "activate-current-link", cbRefPtr) | |
| 935 | + | } | |
| 936 | + | ||
| 929 | 937 | fcb := func(clsPtr uintptr) { | |
| 930 | 938 | fa := Label{} | |
| 931 | 939 | fa.Ptr = clsPtr | |
| 940 | + | cbFn := *cb | |
| 932 | 941 | ||
| 933 | - | cb(fa) | |
| 942 | + | cbFn(fa) | |
| 934 | 943 | ||
| 935 | 944 | } | |
| 936 | - | return gobject.SignalConnect(x.GoPointer(), "activate-current-link", purego.NewCallback(fcb)) | |
| 945 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 946 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 947 | + | return gobject.SignalConnect(x.GoPointer(), "activate-current-link", cbRefPtr) | |
| 937 | 948 | } | |
| 938 | 949 | ||
| 939 | 950 | // Gets emitted to activate a URI. | |
| 940 | 951 | // | |
| 941 | 952 | // Applications may connect to it to override the default behaviour, | |
| 942 | 953 | // which is to call gtk_show_uri(). | |
| 943 | - | func (x *Label) ConnectActivateLink(cb func(Label, string) bool) uint32 { | |
| 954 | + | func (x *Label) ConnectActivateLink(cb *func(Label, string) bool) uint32 { | |
| 955 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 956 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 957 | + | return gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr) | |
| 958 | + | } | |
| 959 | + | ||
| 944 | 960 | fcb := func(clsPtr uintptr, UriVarp string) bool { | |
| 945 | 961 | fa := Label{} | |
| 946 | 962 | fa.Ptr = clsPtr | |
| 963 | + | cbFn := *cb | |
| 947 | 964 | ||
| 948 | - | return cb(fa, UriVarp) | |
| 965 | + | return cbFn(fa, UriVarp) | |
| 949 | 966 | ||
| 950 | 967 | } | |
| 951 | - | return gobject.SignalConnect(x.GoPointer(), "activate-link", purego.NewCallback(fcb)) | |
| 968 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 969 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 970 | + | return gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr) | |
| 952 | 971 | } | |
| 953 | 972 | ||
| 954 | 973 | // Gets emitted to copy the slection to the clipboard. | |
| @@ -956,15 +975,23 @@ func (x *Label) ConnectActivateLink(cb func(Label, string) bool) uint32 { | |||
| 956 | 975 | // The ::copy-clipboard signal is a [keybinding signal](class.SignalAction.html). | |
| 957 | 976 | // | |
| 958 | 977 | // The default binding for this signal is Ctrl-c. | |
| 959 | - | func (x *Label) ConnectCopyClipboard(cb func(Label)) uint32 { | |
| 978 | + | func (x *Label) ConnectCopyClipboard(cb *func(Label)) uint32 { | |
| 979 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 980 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 981 | + | return gobject.SignalConnect(x.GoPointer(), "copy-clipboard", cbRefPtr) | |
| 982 | + | } | |
| 983 | + | ||
| 960 | 984 | fcb := func(clsPtr uintptr) { | |
| 961 | 985 | fa := Label{} | |
| 962 | 986 | fa.Ptr = clsPtr | |
| 987 | + | cbFn := *cb | |
| 963 | 988 | ||
| 964 | - | cb(fa) | |
| 989 | + | cbFn(fa) | |
| 965 | 990 | ||
| 966 | 991 | } | |
| 967 | - | return gobject.SignalConnect(x.GoPointer(), "copy-clipboard", purego.NewCallback(fcb)) | |
| 992 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 993 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 994 | + | return gobject.SignalConnect(x.GoPointer(), "copy-clipboard", cbRefPtr) | |
| 968 | 995 | } | |
| 969 | 996 | ||
| 970 | 997 | // Gets emitted when the user initiates a cursor movement. | |
| @@ -984,15 +1011,23 @@ func (x *Label) ConnectCopyClipboard(cb func(Label)) uint32 { | |||
| 984 | 1011 | // - Arrow keys move by individual characters/lines | |
| 985 | 1012 | // - Ctrl-arrow key combinations move by words/paragraphs | |
| 986 | 1013 | // - Home/End keys move to the ends of the buffer | |
| 987 | - | func (x *Label) ConnectMoveCursor(cb func(Label, MovementStep, int, bool)) uint32 { | |
| 1014 | + | func (x *Label) ConnectMoveCursor(cb *func(Label, MovementStep, int, bool)) uint32 { | |
| 1015 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1016 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1017 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 1018 | + | } | |
| 1019 | + | ||
| 988 | 1020 | fcb := func(clsPtr uintptr, StepVarp MovementStep, CountVarp int, ExtendSelectionVarp bool) { | |
| 989 | 1021 | fa := Label{} | |
| 990 | 1022 | fa.Ptr = clsPtr | |
| 1023 | + | cbFn := *cb | |
| 991 | 1024 | ||
| 992 | - | cb(fa, StepVarp, CountVarp, ExtendSelectionVarp) | |
| 1025 | + | cbFn(fa, StepVarp, CountVarp, ExtendSelectionVarp) | |
| 993 | 1026 | ||
| 994 | 1027 | } | |
| 995 | - | return gobject.SignalConnect(x.GoPointer(), "move-cursor", purego.NewCallback(fcb)) | |
| 1028 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1029 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1030 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 996 | 1031 | } | |
| 997 | 1032 | ||
| 998 | 1033 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtklevelbar.go +14 -3
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -311,15 +314,23 @@ func (c *LevelBar) SetGoPointer(ptr uintptr) { | |||
| 311 | 314 | // The signal supports detailed connections; you can connect to the | |
| 312 | 315 | // detailed signal "changed::x" in order to only receive callbacks when | |
| 313 | 316 | // the value of offset "x" changes. | |
| 314 | - | func (x *LevelBar) ConnectOffsetChanged(cb func(LevelBar, string)) uint32 { | |
| 317 | + | func (x *LevelBar) ConnectOffsetChanged(cb *func(LevelBar, string)) uint32 { | |
| 318 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 319 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 320 | + | return gobject.SignalConnect(x.GoPointer(), "offset-changed", cbRefPtr) | |
| 321 | + | } | |
| 322 | + | ||
| 315 | 323 | fcb := func(clsPtr uintptr, NameVarp string) { | |
| 316 | 324 | fa := LevelBar{} | |
| 317 | 325 | fa.Ptr = clsPtr | |
| 326 | + | cbFn := *cb | |
| 318 | 327 | ||
| 319 | - | cb(fa, NameVarp) | |
| 328 | + | cbFn(fa, NameVarp) | |
| 320 | 329 | ||
| 321 | 330 | } | |
| 322 | - | return gobject.SignalConnect(x.GoPointer(), "offset-changed", purego.NewCallback(fcb)) | |
| 331 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 332 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 333 | + | return gobject.SignalConnect(x.GoPointer(), "offset-changed", cbRefPtr) | |
| 323 | 334 | } | |
| 324 | 335 | ||
| 325 | 336 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtklinkbutton.go +13 -3
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -139,15 +141,23 @@ func (c *LinkButton) SetGoPointer(ptr uintptr) { | |||
| 139 | 141 | // To override the default behavior, you can connect to the | |
| 140 | 142 | // ::activate-link signal and stop the propagation of the signal | |
| 141 | 143 | // by returning %TRUE from your handler. | |
| 142 | - | func (x *LinkButton) ConnectActivateLink(cb func(LinkButton) bool) uint32 { | |
| 144 | + | func (x *LinkButton) ConnectActivateLink(cb *func(LinkButton) bool) uint32 { | |
| 145 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 146 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 147 | + | return gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr) | |
| 148 | + | } | |
| 149 | + | ||
| 143 | 150 | fcb := func(clsPtr uintptr) bool { | |
| 144 | 151 | fa := LinkButton{} | |
| 145 | 152 | fa.Ptr = clsPtr | |
| 153 | + | cbFn := *cb | |
| 146 | 154 | ||
| 147 | - | return cb(fa) | |
| 155 | + | return cbFn(fa) | |
| 148 | 156 | ||
| 149 | 157 | } | |
| 150 | - | return gobject.SignalConnect(x.GoPointer(), "activate-link", purego.NewCallback(fcb)) | |
| 158 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 159 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 160 | + | return gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr) | |
| 151 | 161 | } | |
| 152 | 162 | ||
| 153 | 163 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtklistbox.go +109 -37
| @@ -153,9 +153,9 @@ var xListBoxBindModel func(uintptr, uintptr, uintptr, uintptr, uintptr) | |||
| 153 | 153 | // Note that using a model is incompatible with the filtering and sorting | |
| 154 | 154 | // functionality in `GtkListBox`. When using a model, filtering and sorting | |
| 155 | 155 | // should be implemented by the model. | |
| 156 | - | func (x *ListBox) BindModel(ModelVar gio.ListModel, CreateWidgetFuncVar ListBoxCreateWidgetFunc, UserDataVar uintptr, UserDataFreeFuncVar glib.DestroyNotify) { | |
| 156 | + | func (x *ListBox) BindModel(ModelVar gio.ListModel, CreateWidgetFuncVar *ListBoxCreateWidgetFunc, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) { | |
| 157 | 157 | ||
| 158 | - | xListBoxBindModel(x.GoPointer(), ModelVar.GoPointer(), purego.NewCallback(CreateWidgetFuncVar), UserDataVar, purego.NewCallback(UserDataFreeFuncVar)) | |
| 158 | + | xListBoxBindModel(x.GoPointer(), ModelVar.GoPointer(), glib.NewCallback(CreateWidgetFuncVar), UserDataVar, glib.NewCallback(UserDataFreeFuncVar)) | |
| 159 | 159 | ||
| 160 | 160 | } | |
| 161 | 161 | ||
| @@ -399,9 +399,9 @@ var xListBoxSelectedForeach func(uintptr, uintptr, uintptr) | |||
| 399 | 399 | // Calls a function for each selected child. | |
| 400 | 400 | // | |
| 401 | 401 | // Note that the selection cannot be modified from within this function. | |
| 402 | - | func (x *ListBox) SelectedForeach(FuncVar ListBoxForeachFunc, DataVar uintptr) { | |
| 402 | + | func (x *ListBox) SelectedForeach(FuncVar *ListBoxForeachFunc, DataVar uintptr) { | |
| 403 | 403 | ||
| 404 | - | xListBoxSelectedForeach(x.GoPointer(), purego.NewCallback(FuncVar), DataVar) | |
| 404 | + | xListBoxSelectedForeach(x.GoPointer(), glib.NewCallback(FuncVar), DataVar) | |
| 405 | 405 | ||
| 406 | 406 | } | |
| 407 | 407 | ||
| @@ -448,9 +448,9 @@ var xListBoxSetFilterFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 448 | 448 | // | |
| 449 | 449 | // Note that using a filter function is incompatible with using a model | |
| 450 | 450 | // (see [method@Gtk.ListBox.bind_model]). | |
| 451 | - | func (x *ListBox) SetFilterFunc(FilterFuncVar ListBoxFilterFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 451 | + | func (x *ListBox) SetFilterFunc(FilterFuncVar *ListBoxFilterFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 452 | 452 | ||
| 453 | - | xListBoxSetFilterFunc(x.GoPointer(), purego.NewCallback(FilterFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 453 | + | xListBoxSetFilterFunc(x.GoPointer(), glib.NewCallback(FilterFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 454 | 454 | ||
| 455 | 455 | } | |
| 456 | 456 | ||
| @@ -481,9 +481,9 @@ var xListBoxSetHeaderFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 481 | 481 | // by [method@Gtk.ListBoxRow.changed] on the previous row, or when the previous | |
| 482 | 482 | // row becomes a different row). It is also called for all rows when | |
| 483 | 483 | // [method@Gtk.ListBox.invalidate_headers] is called. | |
| 484 | - | func (x *ListBox) SetHeaderFunc(UpdateHeaderVar ListBoxUpdateHeaderFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 484 | + | func (x *ListBox) SetHeaderFunc(UpdateHeaderVar *ListBoxUpdateHeaderFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 485 | 485 | ||
| 486 | - | xListBoxSetHeaderFunc(x.GoPointer(), purego.NewCallback(UpdateHeaderVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 486 | + | xListBoxSetHeaderFunc(x.GoPointer(), glib.NewCallback(UpdateHeaderVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 487 | 487 | ||
| 488 | 488 | } | |
| 489 | 489 | ||
| @@ -530,9 +530,9 @@ var xListBoxSetSortFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 530 | 530 | // | |
| 531 | 531 | // Note that using a sort function is incompatible with using a model | |
| 532 | 532 | // (see [method@Gtk.ListBox.bind_model]). | |
| 533 | - | func (x *ListBox) SetSortFunc(SortFuncVar ListBoxSortFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 533 | + | func (x *ListBox) SetSortFunc(SortFuncVar *ListBoxSortFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 534 | 534 | ||
| 535 | - | xListBoxSetSortFunc(x.GoPointer(), purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 535 | + | xListBoxSetSortFunc(x.GoPointer(), glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 536 | 536 | ||
| 537 | 537 | } | |
| 538 | 538 | ||
| @@ -562,38 +562,62 @@ func (c *ListBox) SetGoPointer(ptr uintptr) { | |||
| 562 | 562 | c.Ptr = ptr | |
| 563 | 563 | } | |
| 564 | 564 | ||
| 565 | - | func (x *ListBox) ConnectActivateCursorRow(cb func(ListBox)) uint32 { | |
| 565 | + | func (x *ListBox) ConnectActivateCursorRow(cb *func(ListBox)) uint32 { | |
| 566 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 567 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 568 | + | return gobject.SignalConnect(x.GoPointer(), "activate-cursor-row", cbRefPtr) | |
| 569 | + | } | |
| 570 | + | ||
| 566 | 571 | fcb := func(clsPtr uintptr) { | |
| 567 | 572 | fa := ListBox{} | |
| 568 | 573 | fa.Ptr = clsPtr | |
| 574 | + | cbFn := *cb | |
| 569 | 575 | ||
| 570 | - | cb(fa) | |
| 576 | + | cbFn(fa) | |
| 571 | 577 | ||
| 572 | 578 | } | |
| 573 | - | return gobject.SignalConnect(x.GoPointer(), "activate-cursor-row", purego.NewCallback(fcb)) | |
| 579 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 580 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 581 | + | return gobject.SignalConnect(x.GoPointer(), "activate-cursor-row", cbRefPtr) | |
| 574 | 582 | } | |
| 575 | 583 | ||
| 576 | - | func (x *ListBox) ConnectMoveCursor(cb func(ListBox, MovementStep, int, bool, bool)) uint32 { | |
| 584 | + | func (x *ListBox) ConnectMoveCursor(cb *func(ListBox, MovementStep, int, bool, bool)) uint32 { | |
| 585 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 586 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 587 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 588 | + | } | |
| 589 | + | ||
| 577 | 590 | fcb := func(clsPtr uintptr, ObjectVarp MovementStep, P0Varp int, P1Varp bool, P2Varp bool) { | |
| 578 | 591 | fa := ListBox{} | |
| 579 | 592 | fa.Ptr = clsPtr | |
| 593 | + | cbFn := *cb | |
| 580 | 594 | ||
| 581 | - | cb(fa, ObjectVarp, P0Varp, P1Varp, P2Varp) | |
| 595 | + | cbFn(fa, ObjectVarp, P0Varp, P1Varp, P2Varp) | |
| 582 | 596 | ||
| 583 | 597 | } | |
| 584 | - | return gobject.SignalConnect(x.GoPointer(), "move-cursor", purego.NewCallback(fcb)) | |
| 598 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 599 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 600 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 585 | 601 | } | |
| 586 | 602 | ||
| 587 | 603 | // Emitted when a row has been activated by the user. | |
| 588 | - | func (x *ListBox) ConnectRowActivated(cb func(ListBox, uintptr)) uint32 { | |
| 604 | + | func (x *ListBox) ConnectRowActivated(cb *func(ListBox, uintptr)) uint32 { | |
| 605 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 606 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 607 | + | return gobject.SignalConnect(x.GoPointer(), "row-activated", cbRefPtr) | |
| 608 | + | } | |
| 609 | + | ||
| 589 | 610 | fcb := func(clsPtr uintptr, RowVarp uintptr) { | |
| 590 | 611 | fa := ListBox{} | |
| 591 | 612 | fa.Ptr = clsPtr | |
| 613 | + | cbFn := *cb | |
| 592 | 614 | ||
| 593 | - | cb(fa, RowVarp) | |
| 615 | + | cbFn(fa, RowVarp) | |
| 594 | 616 | ||
| 595 | 617 | } | |
| 596 | - | return gobject.SignalConnect(x.GoPointer(), "row-activated", purego.NewCallback(fcb)) | |
| 618 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 619 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 620 | + | return gobject.SignalConnect(x.GoPointer(), "row-activated", cbRefPtr) | |
| 597 | 621 | } | |
| 598 | 622 | ||
| 599 | 623 | // Emitted when a new row is selected, or (with a %NULL @row) | |
| @@ -602,15 +626,23 @@ func (x *ListBox) ConnectRowActivated(cb func(ListBox, uintptr)) uint32 { | |||
| 602 | 626 | // When the @box is using %GTK_SELECTION_MULTIPLE, this signal will not | |
| 603 | 627 | // give you the full picture of selection changes, and you should use | |
| 604 | 628 | // the [signal@Gtk.ListBox::selected-rows-changed] signal instead. | |
| 605 | - | func (x *ListBox) ConnectRowSelected(cb func(ListBox, uintptr)) uint32 { | |
| 629 | + | func (x *ListBox) ConnectRowSelected(cb *func(ListBox, uintptr)) uint32 { | |
| 630 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 631 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 632 | + | return gobject.SignalConnect(x.GoPointer(), "row-selected", cbRefPtr) | |
| 633 | + | } | |
| 634 | + | ||
| 606 | 635 | fcb := func(clsPtr uintptr, RowVarp uintptr) { | |
| 607 | 636 | fa := ListBox{} | |
| 608 | 637 | fa.Ptr = clsPtr | |
| 638 | + | cbFn := *cb | |
| 609 | 639 | ||
| 610 | - | cb(fa, RowVarp) | |
| 640 | + | cbFn(fa, RowVarp) | |
| 611 | 641 | ||
| 612 | 642 | } | |
| 613 | - | return gobject.SignalConnect(x.GoPointer(), "row-selected", purego.NewCallback(fcb)) | |
| 643 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 644 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 645 | + | return gobject.SignalConnect(x.GoPointer(), "row-selected", cbRefPtr) | |
| 614 | 646 | } | |
| 615 | 647 | ||
| 616 | 648 | // Emitted to select all children of the box, if the selection | |
| @@ -619,38 +651,62 @@ func (x *ListBox) ConnectRowSelected(cb func(ListBox, uintptr)) uint32 { | |||
| 619 | 651 | // This is a [keybinding signal](class.SignalAction.html). | |
| 620 | 652 | // | |
| 621 | 653 | // The default binding for this signal is <kbd>Ctrl</kbd>-<kbd>a</kbd>. | |
| 622 | - | func (x *ListBox) ConnectSelectAll(cb func(ListBox)) uint32 { | |
| 654 | + | func (x *ListBox) ConnectSelectAll(cb *func(ListBox)) uint32 { | |
| 655 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 656 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 657 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 658 | + | } | |
| 659 | + | ||
| 623 | 660 | fcb := func(clsPtr uintptr) { | |
| 624 | 661 | fa := ListBox{} | |
| 625 | 662 | fa.Ptr = clsPtr | |
| 663 | + | cbFn := *cb | |
| 626 | 664 | ||
| 627 | - | cb(fa) | |
| 665 | + | cbFn(fa) | |
| 628 | 666 | ||
| 629 | 667 | } | |
| 630 | - | return gobject.SignalConnect(x.GoPointer(), "select-all", purego.NewCallback(fcb)) | |
| 668 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 669 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 670 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 631 | 671 | } | |
| 632 | 672 | ||
| 633 | 673 | // Emitted when the set of selected rows changes. | |
| 634 | - | func (x *ListBox) ConnectSelectedRowsChanged(cb func(ListBox)) uint32 { | |
| 674 | + | func (x *ListBox) ConnectSelectedRowsChanged(cb *func(ListBox)) uint32 { | |
| 675 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 676 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 677 | + | return gobject.SignalConnect(x.GoPointer(), "selected-rows-changed", cbRefPtr) | |
| 678 | + | } | |
| 679 | + | ||
| 635 | 680 | fcb := func(clsPtr uintptr) { | |
| 636 | 681 | fa := ListBox{} | |
| 637 | 682 | fa.Ptr = clsPtr | |
| 683 | + | cbFn := *cb | |
| 638 | 684 | ||
| 639 | - | cb(fa) | |
| 685 | + | cbFn(fa) | |
| 640 | 686 | ||
| 641 | 687 | } | |
| 642 | - | return gobject.SignalConnect(x.GoPointer(), "selected-rows-changed", purego.NewCallback(fcb)) | |
| 688 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 689 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 690 | + | return gobject.SignalConnect(x.GoPointer(), "selected-rows-changed", cbRefPtr) | |
| 643 | 691 | } | |
| 644 | 692 | ||
| 645 | - | func (x *ListBox) ConnectToggleCursorRow(cb func(ListBox)) uint32 { | |
| 693 | + | func (x *ListBox) ConnectToggleCursorRow(cb *func(ListBox)) uint32 { | |
| 694 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 695 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 696 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-row", cbRefPtr) | |
| 697 | + | } | |
| 698 | + | ||
| 646 | 699 | fcb := func(clsPtr uintptr) { | |
| 647 | 700 | fa := ListBox{} | |
| 648 | 701 | fa.Ptr = clsPtr | |
| 702 | + | cbFn := *cb | |
| 649 | 703 | ||
| 650 | - | cb(fa) | |
| 704 | + | cbFn(fa) | |
| 651 | 705 | ||
| 652 | 706 | } | |
| 653 | - | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-row", purego.NewCallback(fcb)) | |
| 707 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 708 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 709 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-row", cbRefPtr) | |
| 654 | 710 | } | |
| 655 | 711 | ||
| 656 | 712 | // Emitted to unselect all children of the box, if the selection | |
| @@ -660,15 +716,23 @@ func (x *ListBox) ConnectToggleCursorRow(cb func(ListBox)) uint32 { | |||
| 660 | 716 | // | |
| 661 | 717 | // The default binding for this signal is | |
| 662 | 718 | // <kbd>Ctrl</kbd>-<kbd>Shift</kbd>-<kbd>a</kbd>. | |
| 663 | - | func (x *ListBox) ConnectUnselectAll(cb func(ListBox)) uint32 { | |
| 719 | + | func (x *ListBox) ConnectUnselectAll(cb *func(ListBox)) uint32 { | |
| 720 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 721 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 722 | + | return gobject.SignalConnect(x.GoPointer(), "unselect-all", cbRefPtr) | |
| 723 | + | } | |
| 724 | + | ||
| 664 | 725 | fcb := func(clsPtr uintptr) { | |
| 665 | 726 | fa := ListBox{} | |
| 666 | 727 | fa.Ptr = clsPtr | |
| 728 | + | cbFn := *cb | |
| 667 | 729 | ||
| 668 | - | cb(fa) | |
| 730 | + | cbFn(fa) | |
| 669 | 731 | ||
| 670 | 732 | } | |
| 671 | - | return gobject.SignalConnect(x.GoPointer(), "unselect-all", purego.NewCallback(fcb)) | |
| 733 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 734 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 735 | + | return gobject.SignalConnect(x.GoPointer(), "unselect-all", cbRefPtr) | |
| 672 | 736 | } | |
| 673 | 737 | ||
| 674 | 738 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
| @@ -998,15 +1062,23 @@ func (c *ListBoxRow) SetGoPointer(ptr uintptr) { | |||
| 998 | 1062 | // If you want to be notified when the user activates a row (by key or not), | |
| 999 | 1063 | // use the [signal@Gtk.ListBox::row-activated] signal on the row’s parent | |
| 1000 | 1064 | // `GtkListBox`. | |
| 1001 | - | func (x *ListBoxRow) ConnectActivate(cb func(ListBoxRow)) uint32 { | |
| 1065 | + | func (x *ListBoxRow) ConnectActivate(cb *func(ListBoxRow)) uint32 { | |
| 1066 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1067 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1068 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 1069 | + | } | |
| 1070 | + | ||
| 1002 | 1071 | fcb := func(clsPtr uintptr) { | |
| 1003 | 1072 | fa := ListBoxRow{} | |
| 1004 | 1073 | fa.Ptr = clsPtr | |
| 1074 | + | cbFn := *cb | |
| 1005 | 1075 | ||
| 1006 | - | cb(fa) | |
| 1076 | + | cbFn(fa) | |
| 1007 | 1077 | ||
| 1008 | 1078 | } | |
| 1009 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 1079 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1080 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1081 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 1010 | 1082 | } | |
| 1011 | 1083 | ||
| 1012 | 1084 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkliststore.go +6 -6
| @@ -566,9 +566,9 @@ func (x *ListStore) FilterNew(RootVar *TreePath) *TreeModelBase { | |||
| 566 | 566 | // | |
| 567 | 567 | // If @func returns %TRUE, then the tree ceases to be walked, | |
| 568 | 568 | // and gtk_tree_model_foreach() returns. | |
| 569 | - | func (x *ListStore) Foreach(FuncVar TreeModelForeachFunc, UserDataVar uintptr) { | |
| 569 | + | func (x *ListStore) Foreach(FuncVar *TreeModelForeachFunc, UserDataVar uintptr) { | |
| 570 | 570 | ||
| 571 | - | XGtkTreeModelForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 571 | + | XGtkTreeModelForeach(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar) | |
| 572 | 572 | ||
| 573 | 573 | } | |
| 574 | 574 | ||
| @@ -900,9 +900,9 @@ func (x *ListStore) HasDefaultSortFunc() bool { | |||
| 900 | 900 | // This means that once the model has been sorted, it can’t go back to the | |
| 901 | 901 | // default state. In this case, when the current sort column id of @sortable | |
| 902 | 902 | // is %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted. | |
| 903 | - | func (x *ListStore) SetDefaultSortFunc(SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 903 | + | func (x *ListStore) SetDefaultSortFunc(SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 904 | 904 | ||
| 905 | - | XGtkTreeSortableSetDefaultSortFunc(x.GoPointer(), purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 905 | + | XGtkTreeSortableSetDefaultSortFunc(x.GoPointer(), glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 906 | 906 | ||
| 907 | 907 | } | |
| 908 | 908 | ||
| @@ -924,9 +924,9 @@ func (x *ListStore) SetSortColumnId(SortColumnIdVar int, OrderVar SortType) { | |||
| 924 | 924 | // Sets the comparison function used when sorting to be @sort_func. If the | |
| 925 | 925 | // current sort column id of @sortable is the same as @sort_column_id, then | |
| 926 | 926 | // the model will sort using this function. | |
| 927 | - | func (x *ListStore) SetSortFunc(SortColumnIdVar int, SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 927 | + | func (x *ListStore) SetSortFunc(SortColumnIdVar int, SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 928 | 928 | ||
| 929 | - | XGtkTreeSortableSetSortFunc(x.GoPointer(), SortColumnIdVar, purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 929 | + | XGtkTreeSortableSetSortFunc(x.GoPointer(), SortColumnIdVar, glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 930 | 930 | ||
| 931 | 931 | } | |
| 932 | 932 | ||
M v4/gtk/gtklistview.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -283,15 +284,23 @@ func (c *ListView) SetGoPointer(ptr uintptr) { | |||
| 283 | 284 | // This allows for a convenient way to handle activation in a listview. | |
| 284 | 285 | // See [method@Gtk.ListItem.set_activatable] for details on how to use | |
| 285 | 286 | // this signal. | |
| 286 | - | func (x *ListView) ConnectActivate(cb func(ListView, uint)) uint32 { | |
| 287 | + | func (x *ListView) ConnectActivate(cb *func(ListView, uint)) uint32 { | |
| 288 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 289 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 290 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 291 | + | } | |
| 292 | + | ||
| 287 | 293 | fcb := func(clsPtr uintptr, PositionVarp uint) { | |
| 288 | 294 | fa := ListView{} | |
| 289 | 295 | fa.Ptr = clsPtr | |
| 296 | + | cbFn := *cb | |
| 290 | 297 | ||
| 291 | - | cb(fa, PositionVarp) | |
| 298 | + | cbFn(fa, PositionVarp) | |
| 292 | 299 | ||
| 293 | 300 | } | |
| 294 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 301 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 302 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 303 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 295 | 304 | } | |
| 296 | 305 | ||
| 297 | 306 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkmaplistmodel.go +4 -4
| @@ -71,10 +71,10 @@ func MapListModelNewFromInternalPtr(ptr uintptr) *MapListModel { | |||
| 71 | 71 | var xNewMapListModel func(uintptr, uintptr, uintptr, uintptr) uintptr | |
| 72 | 72 | ||
| 73 | 73 | // Creates a new `GtkMapListModel` for the given arguments. | |
| 74 | - | func NewMapListModel(ModelVar gio.ListModel, MapFuncVar MapListModelMapFunc, UserDataVar uintptr, UserDestroyVar glib.DestroyNotify) *MapListModel { | |
| 74 | + | func NewMapListModel(ModelVar gio.ListModel, MapFuncVar *MapListModelMapFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) *MapListModel { | |
| 75 | 75 | var cls *MapListModel | |
| 76 | 76 | ||
| 77 | - | cret := xNewMapListModel(ModelVar.GoPointer(), purego.NewCallback(MapFuncVar), UserDataVar, purego.NewCallback(UserDestroyVar)) | |
| 77 | + | cret := xNewMapListModel(ModelVar.GoPointer(), glib.NewCallback(MapFuncVar), UserDataVar, glib.NewCallback(UserDestroyVar)) | |
| 78 | 78 | ||
| 79 | 79 | if cret == 0 { | |
| 80 | 80 | return nil | |
| @@ -123,9 +123,9 @@ var xMapListModelSetMapFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 123 | 123 | // GTK makes no effort to ensure that @map_func conforms to the item type | |
| 124 | 124 | // of @self. It assumes that the caller knows what they are doing and the map | |
| 125 | 125 | // function returns items of the appropriate type. | |
| 126 | - | func (x *MapListModel) SetMapFunc(MapFuncVar MapListModelMapFunc, UserDataVar uintptr, UserDestroyVar glib.DestroyNotify) { | |
| 126 | + | func (x *MapListModel) SetMapFunc(MapFuncVar *MapListModelMapFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) { | |
| 127 | 127 | ||
| 128 | - | xMapListModelSetMapFunc(x.GoPointer(), purego.NewCallback(MapFuncVar), UserDataVar, purego.NewCallback(UserDestroyVar)) | |
| 128 | + | xMapListModelSetMapFunc(x.GoPointer(), glib.NewCallback(MapFuncVar), UserDataVar, glib.NewCallback(UserDestroyVar)) | |
| 129 | 129 | ||
| 130 | 130 | } | |
| 131 | 131 | ||
M v4/gtk/gtkmenubutton.go +15 -5
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| @@ -288,9 +290,9 @@ var xMenuButtonSetCreatePopupFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 288 | 290 | // | |
| 289 | 291 | // Using this function will not reset the menu widget attached to | |
| 290 | 292 | // @menu_button. Instead, this can be done manually in @func. | |
| 291 | - | func (x *MenuButton) SetCreatePopupFunc(FuncVar MenuButtonCreatePopupFunc, UserDataVar uintptr, DestroyNotifyVar glib.DestroyNotify) { | |
| 293 | + | func (x *MenuButton) SetCreatePopupFunc(FuncVar *MenuButtonCreatePopupFunc, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify) { | |
| 292 | 294 | ||
| 293 | - | xMenuButtonSetCreatePopupFunc(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar, purego.NewCallback(DestroyNotifyVar)) | |
| 295 | + | xMenuButtonSetCreatePopupFunc(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar, glib.NewCallback(DestroyNotifyVar)) | |
| 294 | 296 | ||
| 295 | 297 | } | |
| 296 | 298 | ||
| @@ -416,15 +418,23 @@ func (c *MenuButton) SetGoPointer(ptr uintptr) { | |||
| 416 | 418 | // | |
| 417 | 419 | // The `::activate` signal on `GtkMenuButton` is an action signal and | |
| 418 | 420 | // emitting it causes the button to pop up its menu. | |
| 419 | - | func (x *MenuButton) ConnectActivate(cb func(MenuButton)) uint32 { | |
| 421 | + | func (x *MenuButton) ConnectActivate(cb *func(MenuButton)) uint32 { | |
| 422 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 423 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 424 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 425 | + | } | |
| 426 | + | ||
| 420 | 427 | fcb := func(clsPtr uintptr) { | |
| 421 | 428 | fa := MenuButton{} | |
| 422 | 429 | fa.Ptr = clsPtr | |
| 430 | + | cbFn := *cb | |
| 423 | 431 | ||
| 424 | - | cb(fa) | |
| 432 | + | cbFn(fa) | |
| 425 | 433 | ||
| 426 | 434 | } | |
| 427 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 435 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 436 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 437 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 428 | 438 | } | |
| 429 | 439 | ||
| 430 | 440 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtknativedialog.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -191,15 +192,23 @@ func (c *NativeDialog) SetGoPointer(ptr uintptr) { | |||
| 191 | 192 | // | |
| 192 | 193 | // If you call [method@Gtk.NativeDialog.hide] before the user | |
| 193 | 194 | // responds to the dialog this signal will not be emitted. | |
| 194 | - | func (x *NativeDialog) ConnectResponse(cb func(NativeDialog, int)) uint32 { | |
| 195 | + | func (x *NativeDialog) ConnectResponse(cb *func(NativeDialog, int)) uint32 { | |
| 196 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 197 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 198 | + | return gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr) | |
| 199 | + | } | |
| 200 | + | ||
| 195 | 201 | fcb := func(clsPtr uintptr, ResponseIdVarp int) { | |
| 196 | 202 | fa := NativeDialog{} | |
| 197 | 203 | fa.Ptr = clsPtr | |
| 204 | + | cbFn := *cb | |
| 198 | 205 | ||
| 199 | - | cb(fa, ResponseIdVarp) | |
| 206 | + | cbFn(fa, ResponseIdVarp) | |
| 200 | 207 | ||
| 201 | 208 | } | |
| 202 | - | return gobject.SignalConnect(x.GoPointer(), "response", purego.NewCallback(fcb)) | |
| 209 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 210 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 211 | + | return gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr) | |
| 203 | 212 | } | |
| 204 | 213 | ||
| 205 | 214 | func init() { | |
M v4/gtk/gtknotebook.go +113 -30
| @@ -2,9 +2,12 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 12 | ) | |
| 10 | 13 | ||
| @@ -692,15 +695,23 @@ func (c *Notebook) SetGoPointer(ptr uintptr) { | |||
| 692 | 695 | c.Ptr = ptr | |
| 693 | 696 | } | |
| 694 | 697 | ||
| 695 | - | func (x *Notebook) ConnectChangeCurrentPage(cb func(Notebook, int) bool) uint32 { | |
| 698 | + | func (x *Notebook) ConnectChangeCurrentPage(cb *func(Notebook, int) bool) uint32 { | |
| 699 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 700 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 701 | + | return gobject.SignalConnect(x.GoPointer(), "change-current-page", cbRefPtr) | |
| 702 | + | } | |
| 703 | + | ||
| 696 | 704 | fcb := func(clsPtr uintptr, ObjectVarp int) bool { | |
| 697 | 705 | fa := Notebook{} | |
| 698 | 706 | fa.Ptr = clsPtr | |
| 707 | + | cbFn := *cb | |
| 699 | 708 | ||
| 700 | - | return cb(fa, ObjectVarp) | |
| 709 | + | return cbFn(fa, ObjectVarp) | |
| 701 | 710 | ||
| 702 | 711 | } | |
| 703 | - | return gobject.SignalConnect(x.GoPointer(), "change-current-page", purego.NewCallback(fcb)) | |
| 712 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 713 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 714 | + | return gobject.SignalConnect(x.GoPointer(), "change-current-page", cbRefPtr) | |
| 704 | 715 | } | |
| 705 | 716 | ||
| 706 | 717 | // The ::create-window signal is emitted when a detachable | |
| @@ -711,111 +722,183 @@ func (x *Notebook) ConnectChangeCurrentPage(cb func(Notebook, int) bool) uint32 | |||
| 711 | 722 | // responsible for moving/resizing the window and adding the | |
| 712 | 723 | // necessary properties to the notebook (e.g. the | |
| 713 | 724 | // `GtkNotebook`:group-name ). | |
| 714 | - | func (x *Notebook) ConnectCreateWindow(cb func(Notebook, uintptr) Notebook) uint32 { | |
| 725 | + | func (x *Notebook) ConnectCreateWindow(cb *func(Notebook, uintptr) Notebook) uint32 { | |
| 726 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 727 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 728 | + | return gobject.SignalConnect(x.GoPointer(), "create-window", cbRefPtr) | |
| 729 | + | } | |
| 730 | + | ||
| 715 | 731 | fcb := func(clsPtr uintptr, PageVarp uintptr) uintptr { | |
| 716 | 732 | fa := Notebook{} | |
| 717 | 733 | fa.Ptr = clsPtr | |
| 734 | + | cbFn := *cb | |
| 718 | 735 | ||
| 719 | - | CreateWindowCls := cb(fa, PageVarp) | |
| 736 | + | CreateWindowCls := cbFn(fa, PageVarp) | |
| 720 | 737 | return CreateWindowCls.Ptr | |
| 721 | 738 | ||
| 722 | 739 | } | |
| 723 | - | return gobject.SignalConnect(x.GoPointer(), "create-window", purego.NewCallback(fcb)) | |
| 740 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 741 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 742 | + | return gobject.SignalConnect(x.GoPointer(), "create-window", cbRefPtr) | |
| 724 | 743 | } | |
| 725 | 744 | ||
| 726 | - | func (x *Notebook) ConnectFocusTab(cb func(Notebook, NotebookTab) bool) uint32 { | |
| 745 | + | func (x *Notebook) ConnectFocusTab(cb *func(Notebook, NotebookTab) bool) uint32 { | |
| 746 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 747 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 748 | + | return gobject.SignalConnect(x.GoPointer(), "focus-tab", cbRefPtr) | |
| 749 | + | } | |
| 750 | + | ||
| 727 | 751 | fcb := func(clsPtr uintptr, ObjectVarp NotebookTab) bool { | |
| 728 | 752 | fa := Notebook{} | |
| 729 | 753 | fa.Ptr = clsPtr | |
| 754 | + | cbFn := *cb | |
| 730 | 755 | ||
| 731 | - | return cb(fa, ObjectVarp) | |
| 756 | + | return cbFn(fa, ObjectVarp) | |
| 732 | 757 | ||
| 733 | 758 | } | |
| 734 | - | return gobject.SignalConnect(x.GoPointer(), "focus-tab", purego.NewCallback(fcb)) | |
| 759 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 760 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 761 | + | return gobject.SignalConnect(x.GoPointer(), "focus-tab", cbRefPtr) | |
| 735 | 762 | } | |
| 736 | 763 | ||
| 737 | - | func (x *Notebook) ConnectMoveFocusOut(cb func(Notebook, DirectionType)) uint32 { | |
| 764 | + | func (x *Notebook) ConnectMoveFocusOut(cb *func(Notebook, DirectionType)) uint32 { | |
| 765 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 766 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 767 | + | return gobject.SignalConnect(x.GoPointer(), "move-focus-out", cbRefPtr) | |
| 768 | + | } | |
| 769 | + | ||
| 738 | 770 | fcb := func(clsPtr uintptr, ObjectVarp DirectionType) { | |
| 739 | 771 | fa := Notebook{} | |
| 740 | 772 | fa.Ptr = clsPtr | |
| 773 | + | cbFn := *cb | |
| 741 | 774 | ||
| 742 | - | cb(fa, ObjectVarp) | |
| 775 | + | cbFn(fa, ObjectVarp) | |
| 743 | 776 | ||
| 744 | 777 | } | |
| 745 | - | return gobject.SignalConnect(x.GoPointer(), "move-focus-out", purego.NewCallback(fcb)) | |
| 778 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 779 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 780 | + | return gobject.SignalConnect(x.GoPointer(), "move-focus-out", cbRefPtr) | |
| 746 | 781 | } | |
| 747 | 782 | ||
| 748 | 783 | // the ::page-added signal is emitted in the notebook | |
| 749 | 784 | // right after a page is added to the notebook. | |
| 750 | - | func (x *Notebook) ConnectPageAdded(cb func(Notebook, uintptr, uint)) uint32 { | |
| 785 | + | func (x *Notebook) ConnectPageAdded(cb *func(Notebook, uintptr, uint)) uint32 { | |
| 786 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 787 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 788 | + | return gobject.SignalConnect(x.GoPointer(), "page-added", cbRefPtr) | |
| 789 | + | } | |
| 790 | + | ||
| 751 | 791 | fcb := func(clsPtr uintptr, ChildVarp uintptr, PageNumVarp uint) { | |
| 752 | 792 | fa := Notebook{} | |
| 753 | 793 | fa.Ptr = clsPtr | |
| 794 | + | cbFn := *cb | |
| 754 | 795 | ||
| 755 | - | cb(fa, ChildVarp, PageNumVarp) | |
| 796 | + | cbFn(fa, ChildVarp, PageNumVarp) | |
| 756 | 797 | ||
| 757 | 798 | } | |
| 758 | - | return gobject.SignalConnect(x.GoPointer(), "page-added", purego.NewCallback(fcb)) | |
| 799 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 800 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 801 | + | return gobject.SignalConnect(x.GoPointer(), "page-added", cbRefPtr) | |
| 759 | 802 | } | |
| 760 | 803 | ||
| 761 | 804 | // the ::page-removed signal is emitted in the notebook | |
| 762 | 805 | // right after a page is removed from the notebook. | |
| 763 | - | func (x *Notebook) ConnectPageRemoved(cb func(Notebook, uintptr, uint)) uint32 { | |
| 806 | + | func (x *Notebook) ConnectPageRemoved(cb *func(Notebook, uintptr, uint)) uint32 { | |
| 807 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 808 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 809 | + | return gobject.SignalConnect(x.GoPointer(), "page-removed", cbRefPtr) | |
| 810 | + | } | |
| 811 | + | ||
| 764 | 812 | fcb := func(clsPtr uintptr, ChildVarp uintptr, PageNumVarp uint) { | |
| 765 | 813 | fa := Notebook{} | |
| 766 | 814 | fa.Ptr = clsPtr | |
| 815 | + | cbFn := *cb | |
| 767 | 816 | ||
| 768 | - | cb(fa, ChildVarp, PageNumVarp) | |
| 817 | + | cbFn(fa, ChildVarp, PageNumVarp) | |
| 769 | 818 | ||
| 770 | 819 | } | |
| 771 | - | return gobject.SignalConnect(x.GoPointer(), "page-removed", purego.NewCallback(fcb)) | |
| 820 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 821 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 822 | + | return gobject.SignalConnect(x.GoPointer(), "page-removed", cbRefPtr) | |
| 772 | 823 | } | |
| 773 | 824 | ||
| 774 | 825 | // the ::page-reordered signal is emitted in the notebook | |
| 775 | 826 | // right after a page has been reordered. | |
| 776 | - | func (x *Notebook) ConnectPageReordered(cb func(Notebook, uintptr, uint)) uint32 { | |
| 827 | + | func (x *Notebook) ConnectPageReordered(cb *func(Notebook, uintptr, uint)) uint32 { | |
| 828 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 829 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 830 | + | return gobject.SignalConnect(x.GoPointer(), "page-reordered", cbRefPtr) | |
| 831 | + | } | |
| 832 | + | ||
| 777 | 833 | fcb := func(clsPtr uintptr, ChildVarp uintptr, PageNumVarp uint) { | |
| 778 | 834 | fa := Notebook{} | |
| 779 | 835 | fa.Ptr = clsPtr | |
| 836 | + | cbFn := *cb | |
| 780 | 837 | ||
| 781 | - | cb(fa, ChildVarp, PageNumVarp) | |
| 838 | + | cbFn(fa, ChildVarp, PageNumVarp) | |
| 782 | 839 | ||
| 783 | 840 | } | |
| 784 | - | return gobject.SignalConnect(x.GoPointer(), "page-reordered", purego.NewCallback(fcb)) | |
| 841 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 842 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 843 | + | return gobject.SignalConnect(x.GoPointer(), "page-reordered", cbRefPtr) | |
| 785 | 844 | } | |
| 786 | 845 | ||
| 787 | - | func (x *Notebook) ConnectReorderTab(cb func(Notebook, DirectionType, bool) bool) uint32 { | |
| 846 | + | func (x *Notebook) ConnectReorderTab(cb *func(Notebook, DirectionType, bool) bool) uint32 { | |
| 847 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 848 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 849 | + | return gobject.SignalConnect(x.GoPointer(), "reorder-tab", cbRefPtr) | |
| 850 | + | } | |
| 851 | + | ||
| 788 | 852 | fcb := func(clsPtr uintptr, ObjectVarp DirectionType, P0Varp bool) bool { | |
| 789 | 853 | fa := Notebook{} | |
| 790 | 854 | fa.Ptr = clsPtr | |
| 855 | + | cbFn := *cb | |
| 791 | 856 | ||
| 792 | - | return cb(fa, ObjectVarp, P0Varp) | |
| 857 | + | return cbFn(fa, ObjectVarp, P0Varp) | |
| 793 | 858 | ||
| 794 | 859 | } | |
| 795 | - | return gobject.SignalConnect(x.GoPointer(), "reorder-tab", purego.NewCallback(fcb)) | |
| 860 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 861 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 862 | + | return gobject.SignalConnect(x.GoPointer(), "reorder-tab", cbRefPtr) | |
| 796 | 863 | } | |
| 797 | 864 | ||
| 798 | - | func (x *Notebook) ConnectSelectPage(cb func(Notebook, bool) bool) uint32 { | |
| 865 | + | func (x *Notebook) ConnectSelectPage(cb *func(Notebook, bool) bool) uint32 { | |
| 866 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 867 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 868 | + | return gobject.SignalConnect(x.GoPointer(), "select-page", cbRefPtr) | |
| 869 | + | } | |
| 870 | + | ||
| 799 | 871 | fcb := func(clsPtr uintptr, ObjectVarp bool) bool { | |
| 800 | 872 | fa := Notebook{} | |
| 801 | 873 | fa.Ptr = clsPtr | |
| 874 | + | cbFn := *cb | |
| 802 | 875 | ||
| 803 | - | return cb(fa, ObjectVarp) | |
| 876 | + | return cbFn(fa, ObjectVarp) | |
| 804 | 877 | ||
| 805 | 878 | } | |
| 806 | - | return gobject.SignalConnect(x.GoPointer(), "select-page", purego.NewCallback(fcb)) | |
| 879 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 880 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 881 | + | return gobject.SignalConnect(x.GoPointer(), "select-page", cbRefPtr) | |
| 807 | 882 | } | |
| 808 | 883 | ||
| 809 | 884 | // Emitted when the user or a function changes the current page. | |
| 810 | - | func (x *Notebook) ConnectSwitchPage(cb func(Notebook, uintptr, uint)) uint32 { | |
| 885 | + | func (x *Notebook) ConnectSwitchPage(cb *func(Notebook, uintptr, uint)) uint32 { | |
| 886 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 887 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 888 | + | return gobject.SignalConnect(x.GoPointer(), "switch-page", cbRefPtr) | |
| 889 | + | } | |
| 890 | + | ||
| 811 | 891 | fcb := func(clsPtr uintptr, PageVarp uintptr, PageNumVarp uint) { | |
| 812 | 892 | fa := Notebook{} | |
| 813 | 893 | fa.Ptr = clsPtr | |
| 894 | + | cbFn := *cb | |
| 814 | 895 | ||
| 815 | - | cb(fa, PageVarp, PageNumVarp) | |
| 896 | + | cbFn(fa, PageVarp, PageNumVarp) | |
| 816 | 897 | ||
| 817 | 898 | } | |
| 818 | - | return gobject.SignalConnect(x.GoPointer(), "switch-page", purego.NewCallback(fcb)) | |
| 899 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 900 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 901 | + | return gobject.SignalConnect(x.GoPointer(), "switch-page", cbRefPtr) | |
| 819 | 902 | } | |
| 820 | 903 | ||
| 821 | 904 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkoverlay.go +14 -3
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -180,15 +183,23 @@ func (c *Overlay) SetGoPointer(ptr uintptr) { | |||
| 180 | 183 | // be full-width/height). If the main child is a | |
| 181 | 184 | // `GtkScrolledWindow`, the overlays are placed relative | |
| 182 | 185 | // to its contents. | |
| 183 | - | func (x *Overlay) ConnectGetChildPosition(cb func(Overlay, uintptr, uintptr) bool) uint32 { | |
| 186 | + | func (x *Overlay) ConnectGetChildPosition(cb *func(Overlay, uintptr, uintptr) bool) uint32 { | |
| 187 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 188 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 189 | + | return gobject.SignalConnect(x.GoPointer(), "get-child-position", cbRefPtr) | |
| 190 | + | } | |
| 191 | + | ||
| 184 | 192 | fcb := func(clsPtr uintptr, WidgetVarp uintptr, AllocationVarp uintptr) bool { | |
| 185 | 193 | fa := Overlay{} | |
| 186 | 194 | fa.Ptr = clsPtr | |
| 195 | + | cbFn := *cb | |
| 187 | 196 | ||
| 188 | - | return cb(fa, WidgetVarp, AllocationVarp) | |
| 197 | + | return cbFn(fa, WidgetVarp, AllocationVarp) | |
| 189 | 198 | ||
| 190 | 199 | } | |
| 191 | - | return gobject.SignalConnect(x.GoPointer(), "get-child-position", purego.NewCallback(fcb)) | |
| 200 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 201 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 202 | + | return gobject.SignalConnect(x.GoPointer(), "get-child-position", cbRefPtr) | |
| 192 | 203 | } | |
| 193 | 204 | ||
| 194 | 205 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkpaned.go +69 -18
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -280,15 +283,23 @@ func (c *Paned) SetGoPointer(ptr uintptr) { | |||
| 280 | 283 | // | |
| 281 | 284 | // The default binding for this signal is <kbd>Return</kbd> or | |
| 282 | 285 | // <kbd>Space</kbd>. | |
| 283 | - | func (x *Paned) ConnectAcceptPosition(cb func(Paned) bool) uint32 { | |
| 286 | + | func (x *Paned) ConnectAcceptPosition(cb *func(Paned) bool) uint32 { | |
| 287 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 288 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 289 | + | return gobject.SignalConnect(x.GoPointer(), "accept-position", cbRefPtr) | |
| 290 | + | } | |
| 291 | + | ||
| 284 | 292 | fcb := func(clsPtr uintptr) bool { | |
| 285 | 293 | fa := Paned{} | |
| 286 | 294 | fa.Ptr = clsPtr | |
| 295 | + | cbFn := *cb | |
| 287 | 296 | ||
| 288 | - | return cb(fa) | |
| 297 | + | return cbFn(fa) | |
| 289 | 298 | ||
| 290 | 299 | } | |
| 291 | - | return gobject.SignalConnect(x.GoPointer(), "accept-position", purego.NewCallback(fcb)) | |
| 300 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 301 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 302 | + | return gobject.SignalConnect(x.GoPointer(), "accept-position", cbRefPtr) | |
| 292 | 303 | } | |
| 293 | 304 | ||
| 294 | 305 | // Emitted to cancel moving the position of the handle using key | |
| @@ -300,15 +311,23 @@ func (x *Paned) ConnectAcceptPosition(cb func(Paned) bool) uint32 { | |||
| 300 | 311 | // This is a [keybinding signal](class.SignalAction.html). | |
| 301 | 312 | // | |
| 302 | 313 | // The default binding for this signal is <kbd>Escape</kbd>. | |
| 303 | - | func (x *Paned) ConnectCancelPosition(cb func(Paned) bool) uint32 { | |
| 314 | + | func (x *Paned) ConnectCancelPosition(cb *func(Paned) bool) uint32 { | |
| 315 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 316 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 317 | + | return gobject.SignalConnect(x.GoPointer(), "cancel-position", cbRefPtr) | |
| 318 | + | } | |
| 319 | + | ||
| 304 | 320 | fcb := func(clsPtr uintptr) bool { | |
| 305 | 321 | fa := Paned{} | |
| 306 | 322 | fa.Ptr = clsPtr | |
| 323 | + | cbFn := *cb | |
| 307 | 324 | ||
| 308 | - | return cb(fa) | |
| 325 | + | return cbFn(fa) | |
| 309 | 326 | ||
| 310 | 327 | } | |
| 311 | - | return gobject.SignalConnect(x.GoPointer(), "cancel-position", purego.NewCallback(fcb)) | |
| 328 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 329 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 330 | + | return gobject.SignalConnect(x.GoPointer(), "cancel-position", cbRefPtr) | |
| 312 | 331 | } | |
| 313 | 332 | ||
| 314 | 333 | // Emitted to cycle the focus between the children of the paned. | |
| @@ -316,15 +335,23 @@ func (x *Paned) ConnectCancelPosition(cb func(Paned) bool) uint32 { | |||
| 316 | 335 | // This is a [keybinding signal](class.SignalAction.html). | |
| 317 | 336 | // | |
| 318 | 337 | // The default binding is <kbd>F6</kbd>. | |
| 319 | - | func (x *Paned) ConnectCycleChildFocus(cb func(Paned, bool) bool) uint32 { | |
| 338 | + | func (x *Paned) ConnectCycleChildFocus(cb *func(Paned, bool) bool) uint32 { | |
| 339 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 340 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 341 | + | return gobject.SignalConnect(x.GoPointer(), "cycle-child-focus", cbRefPtr) | |
| 342 | + | } | |
| 343 | + | ||
| 320 | 344 | fcb := func(clsPtr uintptr, ReversedVarp bool) bool { | |
| 321 | 345 | fa := Paned{} | |
| 322 | 346 | fa.Ptr = clsPtr | |
| 347 | + | cbFn := *cb | |
| 323 | 348 | ||
| 324 | - | return cb(fa, ReversedVarp) | |
| 349 | + | return cbFn(fa, ReversedVarp) | |
| 325 | 350 | ||
| 326 | 351 | } | |
| 327 | - | return gobject.SignalConnect(x.GoPointer(), "cycle-child-focus", purego.NewCallback(fcb)) | |
| 352 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 353 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 354 | + | return gobject.SignalConnect(x.GoPointer(), "cycle-child-focus", cbRefPtr) | |
| 328 | 355 | } | |
| 329 | 356 | ||
| 330 | 357 | // Emitted to cycle whether the paned should grab focus to allow | |
| @@ -333,29 +360,45 @@ func (x *Paned) ConnectCycleChildFocus(cb func(Paned, bool) bool) uint32 { | |||
| 333 | 360 | // This is a [keybinding signal](class.SignalAction.html). | |
| 334 | 361 | // | |
| 335 | 362 | // The default binding for this signal is <kbd>F8</kbd>. | |
| 336 | - | func (x *Paned) ConnectCycleHandleFocus(cb func(Paned, bool) bool) uint32 { | |
| 363 | + | func (x *Paned) ConnectCycleHandleFocus(cb *func(Paned, bool) bool) uint32 { | |
| 364 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 365 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 366 | + | return gobject.SignalConnect(x.GoPointer(), "cycle-handle-focus", cbRefPtr) | |
| 367 | + | } | |
| 368 | + | ||
| 337 | 369 | fcb := func(clsPtr uintptr, ReversedVarp bool) bool { | |
| 338 | 370 | fa := Paned{} | |
| 339 | 371 | fa.Ptr = clsPtr | |
| 372 | + | cbFn := *cb | |
| 340 | 373 | ||
| 341 | - | return cb(fa, ReversedVarp) | |
| 374 | + | return cbFn(fa, ReversedVarp) | |
| 342 | 375 | ||
| 343 | 376 | } | |
| 344 | - | return gobject.SignalConnect(x.GoPointer(), "cycle-handle-focus", purego.NewCallback(fcb)) | |
| 377 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 378 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 379 | + | return gobject.SignalConnect(x.GoPointer(), "cycle-handle-focus", cbRefPtr) | |
| 345 | 380 | } | |
| 346 | 381 | ||
| 347 | 382 | // Emitted to move the handle with key bindings. | |
| 348 | 383 | // | |
| 349 | 384 | // This is a [keybinding signal](class.SignalAction.html). | |
| 350 | - | func (x *Paned) ConnectMoveHandle(cb func(Paned, ScrollType) bool) uint32 { | |
| 385 | + | func (x *Paned) ConnectMoveHandle(cb *func(Paned, ScrollType) bool) uint32 { | |
| 386 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 387 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 388 | + | return gobject.SignalConnect(x.GoPointer(), "move-handle", cbRefPtr) | |
| 389 | + | } | |
| 390 | + | ||
| 351 | 391 | fcb := func(clsPtr uintptr, ScrollTypeVarp ScrollType) bool { | |
| 352 | 392 | fa := Paned{} | |
| 353 | 393 | fa.Ptr = clsPtr | |
| 394 | + | cbFn := *cb | |
| 354 | 395 | ||
| 355 | - | return cb(fa, ScrollTypeVarp) | |
| 396 | + | return cbFn(fa, ScrollTypeVarp) | |
| 356 | 397 | ||
| 357 | 398 | } | |
| 358 | - | return gobject.SignalConnect(x.GoPointer(), "move-handle", purego.NewCallback(fcb)) | |
| 399 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 400 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 401 | + | return gobject.SignalConnect(x.GoPointer(), "move-handle", cbRefPtr) | |
| 359 | 402 | } | |
| 360 | 403 | ||
| 361 | 404 | // Emitted to accept the current position of the handle and then | |
| @@ -364,15 +407,23 @@ func (x *Paned) ConnectMoveHandle(cb func(Paned, ScrollType) bool) uint32 { | |||
| 364 | 407 | // This is a [keybinding signal](class.SignalAction.html). | |
| 365 | 408 | // | |
| 366 | 409 | // The default binding is <kbd>Tab</kbd>. | |
| 367 | - | func (x *Paned) ConnectToggleHandleFocus(cb func(Paned) bool) uint32 { | |
| 410 | + | func (x *Paned) ConnectToggleHandleFocus(cb *func(Paned) bool) uint32 { | |
| 411 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 412 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 413 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-handle-focus", cbRefPtr) | |
| 414 | + | } | |
| 415 | + | ||
| 368 | 416 | fcb := func(clsPtr uintptr) bool { | |
| 369 | 417 | fa := Paned{} | |
| 370 | 418 | fa.Ptr = clsPtr | |
| 419 | + | cbFn := *cb | |
| 371 | 420 | ||
| 372 | - | return cb(fa) | |
| 421 | + | return cbFn(fa) | |
| 373 | 422 | ||
| 374 | 423 | } | |
| 375 | - | return gobject.SignalConnect(x.GoPointer(), "toggle-handle-focus", purego.NewCallback(fcb)) | |
| 424 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 425 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 426 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-handle-focus", cbRefPtr) | |
| 376 | 427 | } | |
| 377 | 428 | ||
| 378 | 429 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkpasswordentry.go +12 -3
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -138,15 +139,23 @@ func (c *PasswordEntry) SetGoPointer(ptr uintptr) { | |||
| 138 | 139 | // Emitted when the entry is activated. | |
| 139 | 140 | // | |
| 140 | 141 | // The keybindings for this signal are all forms of the Enter key. | |
| 141 | - | func (x *PasswordEntry) ConnectActivate(cb func(PasswordEntry)) uint32 { | |
| 142 | + | func (x *PasswordEntry) ConnectActivate(cb *func(PasswordEntry)) uint32 { | |
| 143 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 144 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 145 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 146 | + | } | |
| 147 | + | ||
| 142 | 148 | fcb := func(clsPtr uintptr) { | |
| 143 | 149 | fa := PasswordEntry{} | |
| 144 | 150 | fa.Ptr = clsPtr | |
| 151 | + | cbFn := *cb | |
| 145 | 152 | ||
| 146 | - | cb(fa) | |
| 153 | + | cbFn(fa) | |
| 147 | 154 | ||
| 148 | 155 | } | |
| 149 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 156 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 157 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 158 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 150 | 159 | } | |
| 151 | 160 | ||
| 152 | 161 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkpopover.go +23 -6
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gsk" | |
| 12 | 13 | ) | |
| @@ -368,27 +369,43 @@ func (c *Popover) SetGoPointer(ptr uintptr) { | |||
| 368 | 369 | // Emitted whend the user activates the default widget. | |
| 369 | 370 | // | |
| 370 | 371 | // This is a [keybinding signal](class.SignalAction.html). | |
| 371 | - | func (x *Popover) ConnectActivateDefault(cb func(Popover)) uint32 { | |
| 372 | + | func (x *Popover) ConnectActivateDefault(cb *func(Popover)) uint32 { | |
| 373 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 374 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 375 | + | return gobject.SignalConnect(x.GoPointer(), "activate-default", cbRefPtr) | |
| 376 | + | } | |
| 377 | + | ||
| 372 | 378 | fcb := func(clsPtr uintptr) { | |
| 373 | 379 | fa := Popover{} | |
| 374 | 380 | fa.Ptr = clsPtr | |
| 381 | + | cbFn := *cb | |
| 375 | 382 | ||
| 376 | - | cb(fa) | |
| 383 | + | cbFn(fa) | |
| 377 | 384 | ||
| 378 | 385 | } | |
| 379 | - | return gobject.SignalConnect(x.GoPointer(), "activate-default", purego.NewCallback(fcb)) | |
| 386 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 387 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 388 | + | return gobject.SignalConnect(x.GoPointer(), "activate-default", cbRefPtr) | |
| 380 | 389 | } | |
| 381 | 390 | ||
| 382 | 391 | // Emitted when the popover is closed. | |
| 383 | - | func (x *Popover) ConnectClosed(cb func(Popover)) uint32 { | |
| 392 | + | func (x *Popover) ConnectClosed(cb *func(Popover)) uint32 { | |
| 393 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 394 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 395 | + | return gobject.SignalConnect(x.GoPointer(), "closed", cbRefPtr) | |
| 396 | + | } | |
| 397 | + | ||
| 384 | 398 | fcb := func(clsPtr uintptr) { | |
| 385 | 399 | fa := Popover{} | |
| 386 | 400 | fa.Ptr = clsPtr | |
| 401 | + | cbFn := *cb | |
| 387 | 402 | ||
| 388 | - | cb(fa) | |
| 403 | + | cbFn(fa) | |
| 389 | 404 | ||
| 390 | 405 | } | |
| 391 | - | return gobject.SignalConnect(x.GoPointer(), "closed", purego.NewCallback(fcb)) | |
| 406 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 407 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 408 | + | return gobject.SignalConnect(x.GoPointer(), "closed", cbRefPtr) | |
| 392 | 409 | } | |
| 393 | 410 | ||
| 394 | 411 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkprinter.go +13 -5
| @@ -63,9 +63,9 @@ var xEnumeratePrinters func(uintptr, uintptr, uintptr, bool) | |||
| 63 | 63 | // Calls a function for all `GtkPrinter`s. | |
| 64 | 64 | // | |
| 65 | 65 | // If @func returns %TRUE, the enumeration is stopped. | |
| 66 | - | func EnumeratePrinters(FuncVar PrinterFunc, DataVar uintptr, DestroyVar glib.DestroyNotify, WaitVar bool) { | |
| 66 | + | func EnumeratePrinters(FuncVar *PrinterFunc, DataVar uintptr, DestroyVar *glib.DestroyNotify, WaitVar bool) { | |
| 67 | 67 | ||
| 68 | - | xEnumeratePrinters(purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyVar), WaitVar) | |
| 68 | + | xEnumeratePrinters(glib.NewCallback(FuncVar), DataVar, glib.NewCallback(DestroyVar), WaitVar) | |
| 69 | 69 | ||
| 70 | 70 | } | |
| 71 | 71 | ||
| @@ -361,15 +361,23 @@ func (c *Printer) SetGoPointer(ptr uintptr) { | |||
| 361 | 361 | // | |
| 362 | 362 | // The @success parameter indicates if the information was | |
| 363 | 363 | // actually obtained. | |
| 364 | - | func (x *Printer) ConnectDetailsAcquired(cb func(Printer, bool)) uint32 { | |
| 364 | + | func (x *Printer) ConnectDetailsAcquired(cb *func(Printer, bool)) uint32 { | |
| 365 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 366 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 367 | + | return gobject.SignalConnect(x.GoPointer(), "details-acquired", cbRefPtr) | |
| 368 | + | } | |
| 369 | + | ||
| 365 | 370 | fcb := func(clsPtr uintptr, SuccessVarp bool) { | |
| 366 | 371 | fa := Printer{} | |
| 367 | 372 | fa.Ptr = clsPtr | |
| 373 | + | cbFn := *cb | |
| 368 | 374 | ||
| 369 | - | cb(fa, SuccessVarp) | |
| 375 | + | cbFn(fa, SuccessVarp) | |
| 370 | 376 | ||
| 371 | 377 | } | |
| 372 | - | return gobject.SignalConnect(x.GoPointer(), "details-acquired", purego.NewCallback(fcb)) | |
| 378 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 379 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 380 | + | return gobject.SignalConnect(x.GoPointer(), "details-acquired", cbRefPtr) | |
| 373 | 381 | } | |
| 374 | 382 | ||
| 375 | 383 | func init() { | |
M v4/gtk/gtkprintjob.go +15 -5
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/cairo" | |
| @@ -221,9 +223,9 @@ func (x *PrintJob) GetTrackPrintStatus() bool { | |||
| 221 | 223 | var xPrintJobSend func(uintptr, uintptr, uintptr, uintptr) | |
| 222 | 224 | ||
| 223 | 225 | // Sends the print job off to the printer. | |
| 224 | - | func (x *PrintJob) Send(CallbackVar PrintJobCompleteFunc, UserDataVar uintptr, DnotifyVar glib.DestroyNotify) { | |
| 226 | + | func (x *PrintJob) Send(CallbackVar *PrintJobCompleteFunc, UserDataVar uintptr, DnotifyVar *glib.DestroyNotify) { | |
| 225 | 227 | ||
| 226 | - | xPrintJobSend(x.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, purego.NewCallback(DnotifyVar)) | |
| 228 | + | xPrintJobSend(x.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, glib.NewCallback(DnotifyVar)) | |
| 227 | 229 | ||
| 228 | 230 | } | |
| 229 | 231 | ||
| @@ -391,15 +393,23 @@ func (c *PrintJob) SetGoPointer(ptr uintptr) { | |||
| 391 | 393 | // | |
| 392 | 394 | // The signal handler can use [method@Gtk.PrintJob.get_status] | |
| 393 | 395 | // to obtain the new status. | |
| 394 | - | func (x *PrintJob) ConnectStatusChanged(cb func(PrintJob)) uint32 { | |
| 396 | + | func (x *PrintJob) ConnectStatusChanged(cb *func(PrintJob)) uint32 { | |
| 397 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 398 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 399 | + | return gobject.SignalConnect(x.GoPointer(), "status-changed", cbRefPtr) | |
| 400 | + | } | |
| 401 | + | ||
| 395 | 402 | fcb := func(clsPtr uintptr) { | |
| 396 | 403 | fa := PrintJob{} | |
| 397 | 404 | fa.Ptr = clsPtr | |
| 405 | + | cbFn := *cb | |
| 398 | 406 | ||
| 399 | - | cb(fa) | |
| 407 | + | cbFn(fa) | |
| 400 | 408 | ||
| 401 | 409 | } | |
| 402 | - | return gobject.SignalConnect(x.GoPointer(), "status-changed", purego.NewCallback(fcb)) | |
| 410 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 411 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 412 | + | return gobject.SignalConnect(x.GoPointer(), "status-changed", cbRefPtr) | |
| 403 | 413 | } | |
| 404 | 414 | ||
| 405 | 415 | func init() { | |
M v4/gtk/gtkprintoperation.go +123 -35
| @@ -160,9 +160,9 @@ var xPrintRunPageSetupDialogAsync func(uintptr, uintptr, uintptr, uintptr, uintp | |||
| 160 | 160 | // In contrast to gtk_print_run_page_setup_dialog(), this function returns after | |
| 161 | 161 | // showing the page setup dialog on platforms that support this, and calls @done_cb | |
| 162 | 162 | // from a signal handler for the ::response signal of the dialog. | |
| 163 | - | func PrintRunPageSetupDialogAsync(ParentVar *Window, PageSetupVar *PageSetup, SettingsVar *PrintSettings, DoneCbVar PageSetupDoneFunc, DataVar uintptr) { | |
| 163 | + | func PrintRunPageSetupDialogAsync(ParentVar *Window, PageSetupVar *PageSetup, SettingsVar *PrintSettings, DoneCbVar *PageSetupDoneFunc, DataVar uintptr) { | |
| 164 | 164 | ||
| 165 | - | xPrintRunPageSetupDialogAsync(ParentVar.GoPointer(), PageSetupVar.GoPointer(), SettingsVar.GoPointer(), purego.NewCallback(DoneCbVar), DataVar) | |
| 165 | + | xPrintRunPageSetupDialogAsync(ParentVar.GoPointer(), PageSetupVar.GoPointer(), SettingsVar.GoPointer(), glib.NewCallback(DoneCbVar), DataVar) | |
| 166 | 166 | ||
| 167 | 167 | } | |
| 168 | 168 | ||
| @@ -739,15 +739,23 @@ func (c *PrintOperation) SetGoPointer(ptr uintptr) { | |||
| 739 | 739 | // [class@Gtk.PrintContext] and paginate the document accordingly, | |
| 740 | 740 | // and then set the number of pages with | |
| 741 | 741 | // [method@Gtk.PrintOperation.set_n_pages]. | |
| 742 | - | func (x *PrintOperation) ConnectBeginPrint(cb func(PrintOperation, uintptr)) uint32 { | |
| 742 | + | func (x *PrintOperation) ConnectBeginPrint(cb *func(PrintOperation, uintptr)) uint32 { | |
| 743 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 744 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 745 | + | return gobject.SignalConnect(x.GoPointer(), "begin-print", cbRefPtr) | |
| 746 | + | } | |
| 747 | + | ||
| 743 | 748 | fcb := func(clsPtr uintptr, ContextVarp uintptr) { | |
| 744 | 749 | fa := PrintOperation{} | |
| 745 | 750 | fa.Ptr = clsPtr | |
| 751 | + | cbFn := *cb | |
| 746 | 752 | ||
| 747 | - | cb(fa, ContextVarp) | |
| 753 | + | cbFn(fa, ContextVarp) | |
| 748 | 754 | ||
| 749 | 755 | } | |
| 750 | - | return gobject.SignalConnect(x.GoPointer(), "begin-print", purego.NewCallback(fcb)) | |
| 756 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 757 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 758 | + | return gobject.SignalConnect(x.GoPointer(), "begin-print", cbRefPtr) | |
| 751 | 759 | } | |
| 752 | 760 | ||
| 753 | 761 | // Emitted when displaying the print dialog. | |
| @@ -761,16 +769,24 @@ func (x *PrintOperation) ConnectBeginPrint(cb func(PrintOperation, uintptr)) uin | |||
| 761 | 769 | // to stay around until the [signal@Gtk.PrintOperation::custom-widget-apply] | |
| 762 | 770 | // signal is emitted on the operation. Then you can read out any | |
| 763 | 771 | // information you need from the widgets. | |
| 764 | - | func (x *PrintOperation) ConnectCreateCustomWidget(cb func(PrintOperation) gobject.Object) uint32 { | |
| 772 | + | func (x *PrintOperation) ConnectCreateCustomWidget(cb *func(PrintOperation) gobject.Object) uint32 { | |
| 773 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 774 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 775 | + | return gobject.SignalConnect(x.GoPointer(), "create-custom-widget", cbRefPtr) | |
| 776 | + | } | |
| 777 | + | ||
| 765 | 778 | fcb := func(clsPtr uintptr) uintptr { | |
| 766 | 779 | fa := PrintOperation{} | |
| 767 | 780 | fa.Ptr = clsPtr | |
| 781 | + | cbFn := *cb | |
| 768 | 782 | ||
| 769 | - | CreateCustomWidgetCls := cb(fa) | |
| 783 | + | CreateCustomWidgetCls := cbFn(fa) | |
| 770 | 784 | return CreateCustomWidgetCls.Ptr | |
| 771 | 785 | ||
| 772 | 786 | } | |
| 773 | - | return gobject.SignalConnect(x.GoPointer(), "create-custom-widget", purego.NewCallback(fcb)) | |
| 787 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 788 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 789 | + | return gobject.SignalConnect(x.GoPointer(), "create-custom-widget", cbRefPtr) | |
| 774 | 790 | } | |
| 775 | 791 | ||
| 776 | 792 | // Emitted right before ::begin-print if you added | |
| @@ -779,15 +795,23 @@ func (x *PrintOperation) ConnectCreateCustomWidget(cb func(PrintOperation) gobje | |||
| 779 | 795 | // When you get this signal you should read the information from the | |
| 780 | 796 | // custom widgets, as the widgets are not guaranteed to be around at a | |
| 781 | 797 | // later time. | |
| 782 | - | func (x *PrintOperation) ConnectCustomWidgetApply(cb func(PrintOperation, uintptr)) uint32 { | |
| 798 | + | func (x *PrintOperation) ConnectCustomWidgetApply(cb *func(PrintOperation, uintptr)) uint32 { | |
| 799 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 800 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 801 | + | return gobject.SignalConnect(x.GoPointer(), "custom-widget-apply", cbRefPtr) | |
| 802 | + | } | |
| 803 | + | ||
| 783 | 804 | fcb := func(clsPtr uintptr, WidgetVarp uintptr) { | |
| 784 | 805 | fa := PrintOperation{} | |
| 785 | 806 | fa.Ptr = clsPtr | |
| 807 | + | cbFn := *cb | |
| 786 | 808 | ||
| 787 | - | cb(fa, WidgetVarp) | |
| 809 | + | cbFn(fa, WidgetVarp) | |
| 788 | 810 | ||
| 789 | 811 | } | |
| 790 | - | return gobject.SignalConnect(x.GoPointer(), "custom-widget-apply", purego.NewCallback(fcb)) | |
| 812 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 813 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 814 | + | return gobject.SignalConnect(x.GoPointer(), "custom-widget-apply", cbRefPtr) | |
| 791 | 815 | } | |
| 792 | 816 | ||
| 793 | 817 | // Emitted when the print operation run has finished doing | |
| @@ -800,15 +824,23 @@ func (x *PrintOperation) ConnectCustomWidgetApply(cb func(PrintOperation, uintpt | |||
| 800 | 824 | // If you enabled print status tracking then | |
| 801 | 825 | // [method@Gtk.PrintOperation.is_finished] may still return %FALSE | |
| 802 | 826 | // after the ::done signal was emitted. | |
| 803 | - | func (x *PrintOperation) ConnectDone(cb func(PrintOperation, PrintOperationResult)) uint32 { | |
| 827 | + | func (x *PrintOperation) ConnectDone(cb *func(PrintOperation, PrintOperationResult)) uint32 { | |
| 828 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 829 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 830 | + | return gobject.SignalConnect(x.GoPointer(), "done", cbRefPtr) | |
| 831 | + | } | |
| 832 | + | ||
| 804 | 833 | fcb := func(clsPtr uintptr, ResultVarp PrintOperationResult) { | |
| 805 | 834 | fa := PrintOperation{} | |
| 806 | 835 | fa.Ptr = clsPtr | |
| 836 | + | cbFn := *cb | |
| 807 | 837 | ||
| 808 | - | cb(fa, ResultVarp) | |
| 838 | + | cbFn(fa, ResultVarp) | |
| 809 | 839 | ||
| 810 | 840 | } | |
| 811 | - | return gobject.SignalConnect(x.GoPointer(), "done", purego.NewCallback(fcb)) | |
| 841 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 842 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 843 | + | return gobject.SignalConnect(x.GoPointer(), "done", cbRefPtr) | |
| 812 | 844 | } | |
| 813 | 845 | ||
| 814 | 846 | // Emitted for every page that is printed. | |
| @@ -865,30 +897,46 @@ func (x *PrintOperation) ConnectDone(cb func(PrintOperation, PrintOperationResul | |||
| 865 | 897 | // [method@Gtk.PrintOperation.set_unit] before starting the print | |
| 866 | 898 | // operation to set up the transformation of the cairo context | |
| 867 | 899 | // according to your needs. | |
| 868 | - | func (x *PrintOperation) ConnectDrawPage(cb func(PrintOperation, uintptr, int)) uint32 { | |
| 900 | + | func (x *PrintOperation) ConnectDrawPage(cb *func(PrintOperation, uintptr, int)) uint32 { | |
| 901 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 902 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 903 | + | return gobject.SignalConnect(x.GoPointer(), "draw-page", cbRefPtr) | |
| 904 | + | } | |
| 905 | + | ||
| 869 | 906 | fcb := func(clsPtr uintptr, ContextVarp uintptr, PageNrVarp int) { | |
| 870 | 907 | fa := PrintOperation{} | |
| 871 | 908 | fa.Ptr = clsPtr | |
| 909 | + | cbFn := *cb | |
| 872 | 910 | ||
| 873 | - | cb(fa, ContextVarp, PageNrVarp) | |
| 911 | + | cbFn(fa, ContextVarp, PageNrVarp) | |
| 874 | 912 | ||
| 875 | 913 | } | |
| 876 | - | return gobject.SignalConnect(x.GoPointer(), "draw-page", purego.NewCallback(fcb)) | |
| 914 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 915 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 916 | + | return gobject.SignalConnect(x.GoPointer(), "draw-page", cbRefPtr) | |
| 877 | 917 | } | |
| 878 | 918 | ||
| 879 | 919 | // Emitted after all pages have been rendered. | |
| 880 | 920 | // | |
| 881 | 921 | // A handler for this signal can clean up any resources that have | |
| 882 | 922 | // been allocated in the [signal@Gtk.PrintOperation::begin-print] handler. | |
| 883 | - | func (x *PrintOperation) ConnectEndPrint(cb func(PrintOperation, uintptr)) uint32 { | |
| 923 | + | func (x *PrintOperation) ConnectEndPrint(cb *func(PrintOperation, uintptr)) uint32 { | |
| 924 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 925 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 926 | + | return gobject.SignalConnect(x.GoPointer(), "end-print", cbRefPtr) | |
| 927 | + | } | |
| 928 | + | ||
| 884 | 929 | fcb := func(clsPtr uintptr, ContextVarp uintptr) { | |
| 885 | 930 | fa := PrintOperation{} | |
| 886 | 931 | fa.Ptr = clsPtr | |
| 932 | + | cbFn := *cb | |
| 887 | 933 | ||
| 888 | - | cb(fa, ContextVarp) | |
| 934 | + | cbFn(fa, ContextVarp) | |
| 889 | 935 | ||
| 890 | 936 | } | |
| 891 | - | return gobject.SignalConnect(x.GoPointer(), "end-print", purego.NewCallback(fcb)) | |
| 937 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 938 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 939 | + | return gobject.SignalConnect(x.GoPointer(), "end-print", cbRefPtr) | |
| 892 | 940 | } | |
| 893 | 941 | ||
| 894 | 942 | // Emitted after the ::begin-print signal, but before the actual rendering | |
| @@ -905,15 +953,23 @@ func (x *PrintOperation) ConnectEndPrint(cb func(PrintOperation, uintptr)) uint3 | |||
| 905 | 953 | // If you don't need to do pagination in chunks, you can simply do | |
| 906 | 954 | // it all in the ::begin-print handler, and set the number of pages | |
| 907 | 955 | // from there. | |
| 908 | - | func (x *PrintOperation) ConnectPaginate(cb func(PrintOperation, uintptr) bool) uint32 { | |
| 956 | + | func (x *PrintOperation) ConnectPaginate(cb *func(PrintOperation, uintptr) bool) uint32 { | |
| 957 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 958 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 959 | + | return gobject.SignalConnect(x.GoPointer(), "paginate", cbRefPtr) | |
| 960 | + | } | |
| 961 | + | ||
| 909 | 962 | fcb := func(clsPtr uintptr, ContextVarp uintptr) bool { | |
| 910 | 963 | fa := PrintOperation{} | |
| 911 | 964 | fa.Ptr = clsPtr | |
| 965 | + | cbFn := *cb | |
| 912 | 966 | ||
| 913 | - | return cb(fa, ContextVarp) | |
| 967 | + | return cbFn(fa, ContextVarp) | |
| 914 | 968 | ||
| 915 | 969 | } | |
| 916 | - | return gobject.SignalConnect(x.GoPointer(), "paginate", purego.NewCallback(fcb)) | |
| 970 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 971 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 972 | + | return gobject.SignalConnect(x.GoPointer(), "paginate", cbRefPtr) | |
| 917 | 973 | } | |
| 918 | 974 | ||
| 919 | 975 | // Gets emitted when a preview is requested from the native dialog. | |
| @@ -933,15 +989,23 @@ func (x *PrintOperation) ConnectPaginate(cb func(PrintOperation, uintptr) bool) | |||
| 933 | 989 | // are selected for print and render them. The preview must be | |
| 934 | 990 | // finished by calling [method@Gtk.PrintOperationPreview.end_preview] | |
| 935 | 991 | // (typically in response to the user clicking a close button). | |
| 936 | - | func (x *PrintOperation) ConnectPreview(cb func(PrintOperation, uintptr, uintptr, uintptr) bool) uint32 { | |
| 992 | + | func (x *PrintOperation) ConnectPreview(cb *func(PrintOperation, uintptr, uintptr, uintptr) bool) uint32 { | |
| 993 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 994 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 995 | + | return gobject.SignalConnect(x.GoPointer(), "preview", cbRefPtr) | |
| 996 | + | } | |
| 997 | + | ||
| 937 | 998 | fcb := func(clsPtr uintptr, PreviewVarp uintptr, ContextVarp uintptr, ParentVarp uintptr) bool { | |
| 938 | 999 | fa := PrintOperation{} | |
| 939 | 1000 | fa.Ptr = clsPtr | |
| 1001 | + | cbFn := *cb | |
| 940 | 1002 | ||
| 941 | - | return cb(fa, PreviewVarp, ContextVarp, ParentVarp) | |
| 1003 | + | return cbFn(fa, PreviewVarp, ContextVarp, ParentVarp) | |
| 942 | 1004 | ||
| 943 | 1005 | } | |
| 944 | - | return gobject.SignalConnect(x.GoPointer(), "preview", purego.NewCallback(fcb)) | |
| 1006 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1007 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1008 | + | return gobject.SignalConnect(x.GoPointer(), "preview", cbRefPtr) | |
| 945 | 1009 | } | |
| 946 | 1010 | ||
| 947 | 1011 | // Emitted once for every page that is printed. | |
| @@ -949,15 +1013,23 @@ func (x *PrintOperation) ConnectPreview(cb func(PrintOperation, uintptr, uintptr | |||
| 949 | 1013 | // This gives the application a chance to modify the page setup. | |
| 950 | 1014 | // Any changes done to @setup will be in force only for printing | |
| 951 | 1015 | // this page. | |
| 952 | - | func (x *PrintOperation) ConnectRequestPageSetup(cb func(PrintOperation, uintptr, int, uintptr)) uint32 { | |
| 1016 | + | func (x *PrintOperation) ConnectRequestPageSetup(cb *func(PrintOperation, uintptr, int, uintptr)) uint32 { | |
| 1017 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1018 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1019 | + | return gobject.SignalConnect(x.GoPointer(), "request-page-setup", cbRefPtr) | |
| 1020 | + | } | |
| 1021 | + | ||
| 953 | 1022 | fcb := func(clsPtr uintptr, ContextVarp uintptr, PageNrVarp int, SetupVarp uintptr) { | |
| 954 | 1023 | fa := PrintOperation{} | |
| 955 | 1024 | fa.Ptr = clsPtr | |
| 1025 | + | cbFn := *cb | |
| 956 | 1026 | ||
| 957 | - | cb(fa, ContextVarp, PageNrVarp, SetupVarp) | |
| 1027 | + | cbFn(fa, ContextVarp, PageNrVarp, SetupVarp) | |
| 958 | 1028 | ||
| 959 | 1029 | } | |
| 960 | - | return gobject.SignalConnect(x.GoPointer(), "request-page-setup", purego.NewCallback(fcb)) | |
| 1030 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1031 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1032 | + | return gobject.SignalConnect(x.GoPointer(), "request-page-setup", cbRefPtr) | |
| 961 | 1033 | } | |
| 962 | 1034 | ||
| 963 | 1035 | // Emitted at between the various phases of the print operation. | |
| @@ -965,30 +1037,46 @@ func (x *PrintOperation) ConnectRequestPageSetup(cb func(PrintOperation, uintptr | |||
| 965 | 1037 | // See [enum@Gtk.PrintStatus] for the phases that are being discriminated. | |
| 966 | 1038 | // Use [method@Gtk.PrintOperation.get_status] to find out the current | |
| 967 | 1039 | // status. | |
| 968 | - | func (x *PrintOperation) ConnectStatusChanged(cb func(PrintOperation)) uint32 { | |
| 1040 | + | func (x *PrintOperation) ConnectStatusChanged(cb *func(PrintOperation)) uint32 { | |
| 1041 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1042 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1043 | + | return gobject.SignalConnect(x.GoPointer(), "status-changed", cbRefPtr) | |
| 1044 | + | } | |
| 1045 | + | ||
| 969 | 1046 | fcb := func(clsPtr uintptr) { | |
| 970 | 1047 | fa := PrintOperation{} | |
| 971 | 1048 | fa.Ptr = clsPtr | |
| 1049 | + | cbFn := *cb | |
| 972 | 1050 | ||
| 973 | - | cb(fa) | |
| 1051 | + | cbFn(fa) | |
| 974 | 1052 | ||
| 975 | 1053 | } | |
| 976 | - | return gobject.SignalConnect(x.GoPointer(), "status-changed", purego.NewCallback(fcb)) | |
| 1054 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1055 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1056 | + | return gobject.SignalConnect(x.GoPointer(), "status-changed", cbRefPtr) | |
| 977 | 1057 | } | |
| 978 | 1058 | ||
| 979 | 1059 | // Emitted after change of selected printer. | |
| 980 | 1060 | // | |
| 981 | 1061 | // The actual page setup and print settings are passed to the custom | |
| 982 | 1062 | // widget, which can actualize itself according to this change. | |
| 983 | - | func (x *PrintOperation) ConnectUpdateCustomWidget(cb func(PrintOperation, uintptr, uintptr, uintptr)) uint32 { | |
| 1063 | + | func (x *PrintOperation) ConnectUpdateCustomWidget(cb *func(PrintOperation, uintptr, uintptr, uintptr)) uint32 { | |
| 1064 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1065 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1066 | + | return gobject.SignalConnect(x.GoPointer(), "update-custom-widget", cbRefPtr) | |
| 1067 | + | } | |
| 1068 | + | ||
| 984 | 1069 | fcb := func(clsPtr uintptr, WidgetVarp uintptr, SetupVarp uintptr, SettingsVarp uintptr) { | |
| 985 | 1070 | fa := PrintOperation{} | |
| 986 | 1071 | fa.Ptr = clsPtr | |
| 1072 | + | cbFn := *cb | |
| 987 | 1073 | ||
| 988 | - | cb(fa, WidgetVarp, SetupVarp, SettingsVarp) | |
| 1074 | + | cbFn(fa, WidgetVarp, SetupVarp, SettingsVarp) | |
| 989 | 1075 | ||
| 990 | 1076 | } | |
| 991 | - | return gobject.SignalConnect(x.GoPointer(), "update-custom-widget", purego.NewCallback(fcb)) | |
| 1077 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1078 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1079 | + | return gobject.SignalConnect(x.GoPointer(), "update-custom-widget", cbRefPtr) | |
| 992 | 1080 | } | |
| 993 | 1081 | ||
| 994 | 1082 | // Ends a preview. | |
M v4/gtk/gtkprintsettings.go +2 -2
| @@ -225,9 +225,9 @@ func (x *PrintSettings) Copy() *PrintSettings { | |||
| 225 | 225 | var xPrintSettingsForeach func(uintptr, uintptr, uintptr) | |
| 226 | 226 | ||
| 227 | 227 | // Calls @func for each key-value pair of @settings. | |
| 228 | - | func (x *PrintSettings) Foreach(FuncVar PrintSettingsFunc, UserDataVar uintptr) { | |
| 228 | + | func (x *PrintSettings) Foreach(FuncVar *PrintSettingsFunc, UserDataVar uintptr) { | |
| 229 | 229 | ||
| 230 | - | xPrintSettingsForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 230 | + | xPrintSettingsForeach(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar) | |
| 231 | 231 | ||
| 232 | 232 | } | |
| 233 | 233 | ||
M v4/gtk/gtkrange.go +45 -12
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -328,15 +329,23 @@ func (c *Range) SetGoPointer(ptr uintptr) { | |||
| 328 | 329 | ||
| 329 | 330 | // Emitted before clamping a value, to give the application a | |
| 330 | 331 | // chance to adjust the bounds. | |
| 331 | - | func (x *Range) ConnectAdjustBounds(cb func(Range, float64)) uint32 { | |
| 332 | + | func (x *Range) ConnectAdjustBounds(cb *func(Range, float64)) uint32 { | |
| 333 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 334 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 335 | + | return gobject.SignalConnect(x.GoPointer(), "adjust-bounds", cbRefPtr) | |
| 336 | + | } | |
| 337 | + | ||
| 332 | 338 | fcb := func(clsPtr uintptr, ValueVarp float64) { | |
| 333 | 339 | fa := Range{} | |
| 334 | 340 | fa.Ptr = clsPtr | |
| 341 | + | cbFn := *cb | |
| 335 | 342 | ||
| 336 | - | cb(fa, ValueVarp) | |
| 343 | + | cbFn(fa, ValueVarp) | |
| 337 | 344 | ||
| 338 | 345 | } | |
| 339 | - | return gobject.SignalConnect(x.GoPointer(), "adjust-bounds", purego.NewCallback(fcb)) | |
| 346 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 347 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 348 | + | return gobject.SignalConnect(x.GoPointer(), "adjust-bounds", cbRefPtr) | |
| 340 | 349 | } | |
| 341 | 350 | ||
| 342 | 351 | // Emitted when a scroll action is performed on a range. | |
| @@ -351,41 +360,65 @@ func (x *Range) ConnectAdjustBounds(cb func(Range, float64)) uint32 { | |||
| 351 | 360 | // the ::change-value signal is responsible for clamping the value | |
| 352 | 361 | // to the desired number of decimal digits; the default GTK | |
| 353 | 362 | // handler clamps the value based on [property@Gtk.Range:round-digits]. | |
| 354 | - | func (x *Range) ConnectChangeValue(cb func(Range, ScrollType, float64) bool) uint32 { | |
| 363 | + | func (x *Range) ConnectChangeValue(cb *func(Range, ScrollType, float64) bool) uint32 { | |
| 364 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 365 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 366 | + | return gobject.SignalConnect(x.GoPointer(), "change-value", cbRefPtr) | |
| 367 | + | } | |
| 368 | + | ||
| 355 | 369 | fcb := func(clsPtr uintptr, ScrollVarp ScrollType, ValueVarp float64) bool { | |
| 356 | 370 | fa := Range{} | |
| 357 | 371 | fa.Ptr = clsPtr | |
| 372 | + | cbFn := *cb | |
| 358 | 373 | ||
| 359 | - | return cb(fa, ScrollVarp, ValueVarp) | |
| 374 | + | return cbFn(fa, ScrollVarp, ValueVarp) | |
| 360 | 375 | ||
| 361 | 376 | } | |
| 362 | - | return gobject.SignalConnect(x.GoPointer(), "change-value", purego.NewCallback(fcb)) | |
| 377 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 378 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 379 | + | return gobject.SignalConnect(x.GoPointer(), "change-value", cbRefPtr) | |
| 363 | 380 | } | |
| 364 | 381 | ||
| 365 | 382 | // Virtual function that moves the slider. | |
| 366 | 383 | // | |
| 367 | 384 | // Used for keybindings. | |
| 368 | - | func (x *Range) ConnectMoveSlider(cb func(Range, ScrollType)) uint32 { | |
| 385 | + | func (x *Range) ConnectMoveSlider(cb *func(Range, ScrollType)) uint32 { | |
| 386 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 387 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 388 | + | return gobject.SignalConnect(x.GoPointer(), "move-slider", cbRefPtr) | |
| 389 | + | } | |
| 390 | + | ||
| 369 | 391 | fcb := func(clsPtr uintptr, StepVarp ScrollType) { | |
| 370 | 392 | fa := Range{} | |
| 371 | 393 | fa.Ptr = clsPtr | |
| 394 | + | cbFn := *cb | |
| 372 | 395 | ||
| 373 | - | cb(fa, StepVarp) | |
| 396 | + | cbFn(fa, StepVarp) | |
| 374 | 397 | ||
| 375 | 398 | } | |
| 376 | - | return gobject.SignalConnect(x.GoPointer(), "move-slider", purego.NewCallback(fcb)) | |
| 399 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 400 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 401 | + | return gobject.SignalConnect(x.GoPointer(), "move-slider", cbRefPtr) | |
| 377 | 402 | } | |
| 378 | 403 | ||
| 379 | 404 | // Emitted when the range value changes. | |
| 380 | - | func (x *Range) ConnectValueChanged(cb func(Range)) uint32 { | |
| 405 | + | func (x *Range) ConnectValueChanged(cb *func(Range)) uint32 { | |
| 406 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 407 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 408 | + | return gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr) | |
| 409 | + | } | |
| 410 | + | ||
| 381 | 411 | fcb := func(clsPtr uintptr) { | |
| 382 | 412 | fa := Range{} | |
| 383 | 413 | fa.Ptr = clsPtr | |
| 414 | + | cbFn := *cb | |
| 384 | 415 | ||
| 385 | - | cb(fa) | |
| 416 | + | cbFn(fa) | |
| 386 | 417 | ||
| 387 | 418 | } | |
| 388 | - | return gobject.SignalConnect(x.GoPointer(), "value-changed", purego.NewCallback(fcb)) | |
| 419 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 420 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 421 | + | return gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr) | |
| 389 | 422 | } | |
| 390 | 423 | ||
| 391 | 424 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkrecentmanager.go +11 -3
| @@ -589,15 +589,23 @@ func (c *RecentManager) SetGoPointer(ptr uintptr) { | |||
| 589 | 589 | // | |
| 590 | 590 | // This can happen either by calling [method@Gtk.RecentManager.add_item] | |
| 591 | 591 | // or by another application. | |
| 592 | - | func (x *RecentManager) ConnectChanged(cb func(RecentManager)) uint32 { | |
| 592 | + | func (x *RecentManager) ConnectChanged(cb *func(RecentManager)) uint32 { | |
| 593 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 594 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 595 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 596 | + | } | |
| 597 | + | ||
| 593 | 598 | fcb := func(clsPtr uintptr) { | |
| 594 | 599 | fa := RecentManager{} | |
| 595 | 600 | fa.Ptr = clsPtr | |
| 601 | + | cbFn := *cb | |
| 596 | 602 | ||
| 597 | - | cb(fa) | |
| 603 | + | cbFn(fa) | |
| 598 | 604 | ||
| 599 | 605 | } | |
| 600 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 606 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 607 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 608 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 601 | 609 | } | |
| 602 | 610 | ||
| 603 | 611 | var xRecentManagerGetDefault func() uintptr | |
M v4/gtk/gtkscale.go +2 -2
| @@ -298,9 +298,9 @@ var xScaleSetFormatValueFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 298 | 298 | // If #NULL is passed as @func, the value will be displayed on | |
| 299 | 299 | // its own, rounded according to the value of the | |
| 300 | 300 | // [property@GtkScale:digits] property. | |
| 301 | - | func (x *Scale) SetFormatValueFunc(FuncVar ScaleFormatValueFunc, UserDataVar uintptr, DestroyNotifyVar glib.DestroyNotify) { | |
| 301 | + | func (x *Scale) SetFormatValueFunc(FuncVar *ScaleFormatValueFunc, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify) { | |
| 302 | 302 | ||
| 303 | - | xScaleSetFormatValueFunc(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar, purego.NewCallback(DestroyNotifyVar)) | |
| 303 | + | xScaleSetFormatValueFunc(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar, glib.NewCallback(DestroyNotifyVar)) | |
| 304 | 304 | ||
| 305 | 305 | } | |
| 306 | 306 | ||
M v4/gtk/gtkscalebutton.go +34 -9
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -187,15 +188,23 @@ func (c *ScaleButton) SetGoPointer(ptr uintptr) { | |||
| 187 | 188 | // This is a [keybinding signal](class.SignalAction.html). | |
| 188 | 189 | // | |
| 189 | 190 | // The default binding for this signal is <kbd>Escape</kbd>. | |
| 190 | - | func (x *ScaleButton) ConnectPopdown(cb func(ScaleButton)) uint32 { | |
| 191 | + | func (x *ScaleButton) ConnectPopdown(cb *func(ScaleButton)) uint32 { | |
| 192 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 193 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 194 | + | return gobject.SignalConnect(x.GoPointer(), "popdown", cbRefPtr) | |
| 195 | + | } | |
| 196 | + | ||
| 191 | 197 | fcb := func(clsPtr uintptr) { | |
| 192 | 198 | fa := ScaleButton{} | |
| 193 | 199 | fa.Ptr = clsPtr | |
| 200 | + | cbFn := *cb | |
| 194 | 201 | ||
| 195 | - | cb(fa) | |
| 202 | + | cbFn(fa) | |
| 196 | 203 | ||
| 197 | 204 | } | |
| 198 | - | return gobject.SignalConnect(x.GoPointer(), "popdown", purego.NewCallback(fcb)) | |
| 205 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 206 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 207 | + | return gobject.SignalConnect(x.GoPointer(), "popdown", cbRefPtr) | |
| 199 | 208 | } | |
| 200 | 209 | ||
| 201 | 210 | // Emitted to popup the scale widget. | |
| @@ -204,27 +213,43 @@ func (x *ScaleButton) ConnectPopdown(cb func(ScaleButton)) uint32 { | |||
| 204 | 213 | // | |
| 205 | 214 | // The default bindings for this signal are <kbd>Space</kbd>, | |
| 206 | 215 | // <kbd>Enter</kbd> and <kbd>Return</kbd>. | |
| 207 | - | func (x *ScaleButton) ConnectPopup(cb func(ScaleButton)) uint32 { | |
| 216 | + | func (x *ScaleButton) ConnectPopup(cb *func(ScaleButton)) uint32 { | |
| 217 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 218 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 219 | + | return gobject.SignalConnect(x.GoPointer(), "popup", cbRefPtr) | |
| 220 | + | } | |
| 221 | + | ||
| 208 | 222 | fcb := func(clsPtr uintptr) { | |
| 209 | 223 | fa := ScaleButton{} | |
| 210 | 224 | fa.Ptr = clsPtr | |
| 225 | + | cbFn := *cb | |
| 211 | 226 | ||
| 212 | - | cb(fa) | |
| 227 | + | cbFn(fa) | |
| 213 | 228 | ||
| 214 | 229 | } | |
| 215 | - | return gobject.SignalConnect(x.GoPointer(), "popup", purego.NewCallback(fcb)) | |
| 230 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 231 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 232 | + | return gobject.SignalConnect(x.GoPointer(), "popup", cbRefPtr) | |
| 216 | 233 | } | |
| 217 | 234 | ||
| 218 | 235 | // Emitted when the value field has changed. | |
| 219 | - | func (x *ScaleButton) ConnectValueChanged(cb func(ScaleButton, float64)) uint32 { | |
| 236 | + | func (x *ScaleButton) ConnectValueChanged(cb *func(ScaleButton, float64)) uint32 { | |
| 237 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 238 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 239 | + | return gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr) | |
| 240 | + | } | |
| 241 | + | ||
| 220 | 242 | fcb := func(clsPtr uintptr, ValueVarp float64) { | |
| 221 | 243 | fa := ScaleButton{} | |
| 222 | 244 | fa.Ptr = clsPtr | |
| 245 | + | cbFn := *cb | |
| 223 | 246 | ||
| 224 | - | cb(fa, ValueVarp) | |
| 247 | + | cbFn(fa, ValueVarp) | |
| 225 | 248 | ||
| 226 | 249 | } | |
| 227 | - | return gobject.SignalConnect(x.GoPointer(), "value-changed", purego.NewCallback(fcb)) | |
| 250 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 251 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 252 | + | return gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr) | |
| 228 | 253 | } | |
| 229 | 254 | ||
| 230 | 255 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkscrolledwindow.go +47 -12
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -557,15 +560,23 @@ func (c *ScrolledWindow) SetGoPointer(ptr uintptr) { | |||
| 557 | 560 | // | |
| 558 | 561 | // Note: The @pos argument is LTR/RTL aware, so callers should be | |
| 559 | 562 | // aware too if intending to provide behavior on horizontal edges. | |
| 560 | - | func (x *ScrolledWindow) ConnectEdgeOvershot(cb func(ScrolledWindow, PositionType)) uint32 { | |
| 563 | + | func (x *ScrolledWindow) ConnectEdgeOvershot(cb *func(ScrolledWindow, PositionType)) uint32 { | |
| 564 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 565 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 566 | + | return gobject.SignalConnect(x.GoPointer(), "edge-overshot", cbRefPtr) | |
| 567 | + | } | |
| 568 | + | ||
| 561 | 569 | fcb := func(clsPtr uintptr, PosVarp PositionType) { | |
| 562 | 570 | fa := ScrolledWindow{} | |
| 563 | 571 | fa.Ptr = clsPtr | |
| 572 | + | cbFn := *cb | |
| 564 | 573 | ||
| 565 | - | cb(fa, PosVarp) | |
| 574 | + | cbFn(fa, PosVarp) | |
| 566 | 575 | ||
| 567 | 576 | } | |
| 568 | - | return gobject.SignalConnect(x.GoPointer(), "edge-overshot", purego.NewCallback(fcb)) | |
| 577 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 578 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 579 | + | return gobject.SignalConnect(x.GoPointer(), "edge-overshot", cbRefPtr) | |
| 569 | 580 | } | |
| 570 | 581 | ||
| 571 | 582 | // Emitted whenever user-initiated scrolling makes the scrolled | |
| @@ -577,15 +588,23 @@ func (x *ScrolledWindow) ConnectEdgeOvershot(cb func(ScrolledWindow, PositionTyp | |||
| 577 | 588 | // | |
| 578 | 589 | // Note: The @pos argument is LTR/RTL aware, so callers should be | |
| 579 | 590 | // aware too if intending to provide behavior on horizontal edges. | |
| 580 | - | func (x *ScrolledWindow) ConnectEdgeReached(cb func(ScrolledWindow, PositionType)) uint32 { | |
| 591 | + | func (x *ScrolledWindow) ConnectEdgeReached(cb *func(ScrolledWindow, PositionType)) uint32 { | |
| 592 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 593 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 594 | + | return gobject.SignalConnect(x.GoPointer(), "edge-reached", cbRefPtr) | |
| 595 | + | } | |
| 596 | + | ||
| 581 | 597 | fcb := func(clsPtr uintptr, PosVarp PositionType) { | |
| 582 | 598 | fa := ScrolledWindow{} | |
| 583 | 599 | fa.Ptr = clsPtr | |
| 600 | + | cbFn := *cb | |
| 584 | 601 | ||
| 585 | - | cb(fa, PosVarp) | |
| 602 | + | cbFn(fa, PosVarp) | |
| 586 | 603 | ||
| 587 | 604 | } | |
| 588 | - | return gobject.SignalConnect(x.GoPointer(), "edge-reached", purego.NewCallback(fcb)) | |
| 605 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 606 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 607 | + | return gobject.SignalConnect(x.GoPointer(), "edge-reached", cbRefPtr) | |
| 589 | 608 | } | |
| 590 | 609 | ||
| 591 | 610 | // Emitted when focus is moved away from the scrolled window by a | |
| @@ -596,15 +615,23 @@ func (x *ScrolledWindow) ConnectEdgeReached(cb func(ScrolledWindow, PositionType | |||
| 596 | 615 | // The default bindings for this signal are | |
| 597 | 616 | // `Ctrl + Tab` to move forward and `Ctrl + Shift + Tab` to | |
| 598 | 617 | // move backward. | |
| 599 | - | func (x *ScrolledWindow) ConnectMoveFocusOut(cb func(ScrolledWindow, DirectionType)) uint32 { | |
| 618 | + | func (x *ScrolledWindow) ConnectMoveFocusOut(cb *func(ScrolledWindow, DirectionType)) uint32 { | |
| 619 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 620 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 621 | + | return gobject.SignalConnect(x.GoPointer(), "move-focus-out", cbRefPtr) | |
| 622 | + | } | |
| 623 | + | ||
| 600 | 624 | fcb := func(clsPtr uintptr, DirectionTypeVarp DirectionType) { | |
| 601 | 625 | fa := ScrolledWindow{} | |
| 602 | 626 | fa.Ptr = clsPtr | |
| 627 | + | cbFn := *cb | |
| 603 | 628 | ||
| 604 | - | cb(fa, DirectionTypeVarp) | |
| 629 | + | cbFn(fa, DirectionTypeVarp) | |
| 605 | 630 | ||
| 606 | 631 | } | |
| 607 | - | return gobject.SignalConnect(x.GoPointer(), "move-focus-out", purego.NewCallback(fcb)) | |
| 632 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 633 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 634 | + | return gobject.SignalConnect(x.GoPointer(), "move-focus-out", cbRefPtr) | |
| 608 | 635 | } | |
| 609 | 636 | ||
| 610 | 637 | // Emitted when a keybinding that scrolls is pressed. | |
| @@ -613,15 +640,23 @@ func (x *ScrolledWindow) ConnectMoveFocusOut(cb func(ScrolledWindow, DirectionTy | |||
| 613 | 640 | // | |
| 614 | 641 | // The horizontal or vertical adjustment is updated which triggers a | |
| 615 | 642 | // signal that the scrolled window’s child may listen to and scroll itself. | |
| 616 | - | func (x *ScrolledWindow) ConnectScrollChild(cb func(ScrolledWindow, ScrollType, bool) bool) uint32 { | |
| 643 | + | func (x *ScrolledWindow) ConnectScrollChild(cb *func(ScrolledWindow, ScrollType, bool) bool) uint32 { | |
| 644 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 645 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 646 | + | return gobject.SignalConnect(x.GoPointer(), "scroll-child", cbRefPtr) | |
| 647 | + | } | |
| 648 | + | ||
| 617 | 649 | fcb := func(clsPtr uintptr, ScrollVarp ScrollType, HorizontalVarp bool) bool { | |
| 618 | 650 | fa := ScrolledWindow{} | |
| 619 | 651 | fa.Ptr = clsPtr | |
| 652 | + | cbFn := *cb | |
| 620 | 653 | ||
| 621 | - | return cb(fa, ScrollVarp, HorizontalVarp) | |
| 654 | + | return cbFn(fa, ScrollVarp, HorizontalVarp) | |
| 622 | 655 | ||
| 623 | 656 | } | |
| 624 | - | return gobject.SignalConnect(x.GoPointer(), "scroll-child", purego.NewCallback(fcb)) | |
| 657 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 658 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 659 | + | return gobject.SignalConnect(x.GoPointer(), "scroll-child", cbRefPtr) | |
| 625 | 660 | } | |
| 626 | 661 | ||
| 627 | 662 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtksearchentry.go +69 -18
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -151,15 +154,23 @@ func (c *SearchEntry) SetGoPointer(ptr uintptr) { | |||
| 151 | 154 | // Emitted when the entry is activated. | |
| 152 | 155 | // | |
| 153 | 156 | // The keybindings for this signal are all forms of the Enter key. | |
| 154 | - | func (x *SearchEntry) ConnectActivate(cb func(SearchEntry)) uint32 { | |
| 157 | + | func (x *SearchEntry) ConnectActivate(cb *func(SearchEntry)) uint32 { | |
| 158 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 159 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 160 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 161 | + | } | |
| 162 | + | ||
| 155 | 163 | fcb := func(clsPtr uintptr) { | |
| 156 | 164 | fa := SearchEntry{} | |
| 157 | 165 | fa.Ptr = clsPtr | |
| 166 | + | cbFn := *cb | |
| 158 | 167 | ||
| 159 | - | cb(fa) | |
| 168 | + | cbFn(fa) | |
| 160 | 169 | ||
| 161 | 170 | } | |
| 162 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 171 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 172 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 173 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 163 | 174 | } | |
| 164 | 175 | ||
| 165 | 176 | // Emitted when the user initiates a move to the next match | |
| @@ -171,15 +182,23 @@ func (x *SearchEntry) ConnectActivate(cb func(SearchEntry)) uint32 { | |||
| 171 | 182 | // between matches. | |
| 172 | 183 | // | |
| 173 | 184 | // The default bindings for this signal is Ctrl-g. | |
| 174 | - | func (x *SearchEntry) ConnectNextMatch(cb func(SearchEntry)) uint32 { | |
| 185 | + | func (x *SearchEntry) ConnectNextMatch(cb *func(SearchEntry)) uint32 { | |
| 186 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 187 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 188 | + | return gobject.SignalConnect(x.GoPointer(), "next-match", cbRefPtr) | |
| 189 | + | } | |
| 190 | + | ||
| 175 | 191 | fcb := func(clsPtr uintptr) { | |
| 176 | 192 | fa := SearchEntry{} | |
| 177 | 193 | fa.Ptr = clsPtr | |
| 194 | + | cbFn := *cb | |
| 178 | 195 | ||
| 179 | - | cb(fa) | |
| 196 | + | cbFn(fa) | |
| 180 | 197 | ||
| 181 | 198 | } | |
| 182 | - | return gobject.SignalConnect(x.GoPointer(), "next-match", purego.NewCallback(fcb)) | |
| 199 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 200 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 201 | + | return gobject.SignalConnect(x.GoPointer(), "next-match", cbRefPtr) | |
| 183 | 202 | } | |
| 184 | 203 | ||
| 185 | 204 | // Emitted when the user initiates a move to the previous match | |
| @@ -191,41 +210,65 @@ func (x *SearchEntry) ConnectNextMatch(cb func(SearchEntry)) uint32 { | |||
| 191 | 210 | // between matches. | |
| 192 | 211 | // | |
| 193 | 212 | // The default bindings for this signal is Ctrl-Shift-g. | |
| 194 | - | func (x *SearchEntry) ConnectPreviousMatch(cb func(SearchEntry)) uint32 { | |
| 213 | + | func (x *SearchEntry) ConnectPreviousMatch(cb *func(SearchEntry)) uint32 { | |
| 214 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 215 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 216 | + | return gobject.SignalConnect(x.GoPointer(), "previous-match", cbRefPtr) | |
| 217 | + | } | |
| 218 | + | ||
| 195 | 219 | fcb := func(clsPtr uintptr) { | |
| 196 | 220 | fa := SearchEntry{} | |
| 197 | 221 | fa.Ptr = clsPtr | |
| 222 | + | cbFn := *cb | |
| 198 | 223 | ||
| 199 | - | cb(fa) | |
| 224 | + | cbFn(fa) | |
| 200 | 225 | ||
| 201 | 226 | } | |
| 202 | - | return gobject.SignalConnect(x.GoPointer(), "previous-match", purego.NewCallback(fcb)) | |
| 227 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 228 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 229 | + | return gobject.SignalConnect(x.GoPointer(), "previous-match", cbRefPtr) | |
| 203 | 230 | } | |
| 204 | 231 | ||
| 205 | 232 | // Emitted with a delay. The length of the delay can be | |
| 206 | 233 | // changed with the [property@Gtk.SearchEntry:search-delay] | |
| 207 | 234 | // property. | |
| 208 | - | func (x *SearchEntry) ConnectSearchChanged(cb func(SearchEntry)) uint32 { | |
| 235 | + | func (x *SearchEntry) ConnectSearchChanged(cb *func(SearchEntry)) uint32 { | |
| 236 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 237 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 238 | + | return gobject.SignalConnect(x.GoPointer(), "search-changed", cbRefPtr) | |
| 239 | + | } | |
| 240 | + | ||
| 209 | 241 | fcb := func(clsPtr uintptr) { | |
| 210 | 242 | fa := SearchEntry{} | |
| 211 | 243 | fa.Ptr = clsPtr | |
| 244 | + | cbFn := *cb | |
| 212 | 245 | ||
| 213 | - | cb(fa) | |
| 246 | + | cbFn(fa) | |
| 214 | 247 | ||
| 215 | 248 | } | |
| 216 | - | return gobject.SignalConnect(x.GoPointer(), "search-changed", purego.NewCallback(fcb)) | |
| 249 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 250 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 251 | + | return gobject.SignalConnect(x.GoPointer(), "search-changed", cbRefPtr) | |
| 217 | 252 | } | |
| 218 | 253 | ||
| 219 | 254 | // Emitted when the user initiated a search on the entry. | |
| 220 | - | func (x *SearchEntry) ConnectSearchStarted(cb func(SearchEntry)) uint32 { | |
| 255 | + | func (x *SearchEntry) ConnectSearchStarted(cb *func(SearchEntry)) uint32 { | |
| 256 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 257 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 258 | + | return gobject.SignalConnect(x.GoPointer(), "search-started", cbRefPtr) | |
| 259 | + | } | |
| 260 | + | ||
| 221 | 261 | fcb := func(clsPtr uintptr) { | |
| 222 | 262 | fa := SearchEntry{} | |
| 223 | 263 | fa.Ptr = clsPtr | |
| 264 | + | cbFn := *cb | |
| 224 | 265 | ||
| 225 | - | cb(fa) | |
| 266 | + | cbFn(fa) | |
| 226 | 267 | ||
| 227 | 268 | } | |
| 228 | - | return gobject.SignalConnect(x.GoPointer(), "search-started", purego.NewCallback(fcb)) | |
| 269 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 270 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 271 | + | return gobject.SignalConnect(x.GoPointer(), "search-started", cbRefPtr) | |
| 229 | 272 | } | |
| 230 | 273 | ||
| 231 | 274 | // Emitted when the user stops a search via keyboard input. | |
| @@ -236,15 +279,23 @@ func (x *SearchEntry) ConnectSearchStarted(cb func(SearchEntry)) uint32 { | |||
| 236 | 279 | // the search entry in this case. | |
| 237 | 280 | // | |
| 238 | 281 | // The default bindings for this signal is Escape. | |
| 239 | - | func (x *SearchEntry) ConnectStopSearch(cb func(SearchEntry)) uint32 { | |
| 282 | + | func (x *SearchEntry) ConnectStopSearch(cb *func(SearchEntry)) uint32 { | |
| 283 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 284 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 285 | + | return gobject.SignalConnect(x.GoPointer(), "stop-search", cbRefPtr) | |
| 286 | + | } | |
| 287 | + | ||
| 240 | 288 | fcb := func(clsPtr uintptr) { | |
| 241 | 289 | fa := SearchEntry{} | |
| 242 | 290 | fa.Ptr = clsPtr | |
| 291 | + | cbFn := *cb | |
| 243 | 292 | ||
| 244 | - | cb(fa) | |
| 293 | + | cbFn(fa) | |
| 245 | 294 | ||
| 246 | 295 | } | |
| 247 | - | return gobject.SignalConnect(x.GoPointer(), "stop-search", purego.NewCallback(fcb)) | |
| 296 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 297 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 298 | + | return gobject.SignalConnect(x.GoPointer(), "stop-search", cbRefPtr) | |
| 248 | 299 | } | |
| 249 | 300 | ||
| 250 | 301 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkshortcutaction.go +2 -2
| @@ -129,10 +129,10 @@ var xNewCallbackAction func(uintptr, uintptr, uintptr) uintptr | |||
| 129 | 129 | ||
| 130 | 130 | // Create a custom action that calls the given @callback when | |
| 131 | 131 | // activated. | |
| 132 | - | func NewCallbackAction(CallbackVar ShortcutFunc, DataVar uintptr, DestroyVar glib.DestroyNotify) *CallbackAction { | |
| 132 | + | func NewCallbackAction(CallbackVar *ShortcutFunc, DataVar uintptr, DestroyVar *glib.DestroyNotify) *CallbackAction { | |
| 133 | 133 | var cls *CallbackAction | |
| 134 | 134 | ||
| 135 | - | cret := xNewCallbackAction(purego.NewCallback(CallbackVar), DataVar, purego.NewCallback(DestroyVar)) | |
| 135 | + | cret := xNewCallbackAction(glib.NewCallback(CallbackVar), DataVar, glib.NewCallback(DestroyVar)) | |
| 136 | 136 | ||
| 137 | 137 | if cret == 0 { | |
| 138 | 138 | return nil | |
M v4/gtk/gtkshortcutssection.go +12 -3
| @@ -5,6 +5,7 @@ import ( | |||
| 5 | 5 | "unsafe" | |
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 9 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 10 | ) | |
| 10 | 11 | ||
| @@ -46,15 +47,23 @@ func (c *ShortcutsSection) SetGoPointer(ptr uintptr) { | |||
| 46 | 47 | c.Ptr = ptr | |
| 47 | 48 | } | |
| 48 | 49 | ||
| 49 | - | func (x *ShortcutsSection) ConnectChangeCurrentPage(cb func(ShortcutsSection, int) bool) uint32 { | |
| 50 | + | func (x *ShortcutsSection) ConnectChangeCurrentPage(cb *func(ShortcutsSection, int) bool) uint32 { | |
| 51 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 52 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 53 | + | return gobject.SignalConnect(x.GoPointer(), "change-current-page", cbRefPtr) | |
| 54 | + | } | |
| 55 | + | ||
| 50 | 56 | fcb := func(clsPtr uintptr, ObjectVarp int) bool { | |
| 51 | 57 | fa := ShortcutsSection{} | |
| 52 | 58 | fa.Ptr = clsPtr | |
| 59 | + | cbFn := *cb | |
| 53 | 60 | ||
| 54 | - | return cb(fa, ObjectVarp) | |
| 61 | + | return cbFn(fa, ObjectVarp) | |
| 55 | 62 | ||
| 56 | 63 | } | |
| 57 | - | return gobject.SignalConnect(x.GoPointer(), "change-current-page", purego.NewCallback(fcb)) | |
| 64 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 65 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 66 | + | return gobject.SignalConnect(x.GoPointer(), "change-current-page", cbRefPtr) | |
| 58 | 67 | } | |
| 59 | 68 | ||
| 60 | 69 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkshortcutswindow.go +25 -6
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gsk" | |
| 9 | 12 | ) | |
| @@ -72,15 +75,23 @@ func (c *ShortcutsWindow) SetGoPointer(ptr uintptr) { | |||
| 72 | 75 | // This is a [keybinding signal](class.SignalAction.html). | |
| 73 | 76 | // | |
| 74 | 77 | // The default binding for this signal is the Escape key. | |
| 75 | - | func (x *ShortcutsWindow) ConnectClose(cb func(ShortcutsWindow)) uint32 { | |
| 78 | + | func (x *ShortcutsWindow) ConnectClose(cb *func(ShortcutsWindow)) uint32 { | |
| 79 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 80 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 81 | + | return gobject.SignalConnect(x.GoPointer(), "close", cbRefPtr) | |
| 82 | + | } | |
| 83 | + | ||
| 76 | 84 | fcb := func(clsPtr uintptr) { | |
| 77 | 85 | fa := ShortcutsWindow{} | |
| 78 | 86 | fa.Ptr = clsPtr | |
| 87 | + | cbFn := *cb | |
| 79 | 88 | ||
| 80 | - | cb(fa) | |
| 89 | + | cbFn(fa) | |
| 81 | 90 | ||
| 82 | 91 | } | |
| 83 | - | return gobject.SignalConnect(x.GoPointer(), "close", purego.NewCallback(fcb)) | |
| 92 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 93 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 94 | + | return gobject.SignalConnect(x.GoPointer(), "close", cbRefPtr) | |
| 84 | 95 | } | |
| 85 | 96 | ||
| 86 | 97 | // Emitted when the user uses a keybinding to start a search. | |
| @@ -88,15 +99,23 @@ func (x *ShortcutsWindow) ConnectClose(cb func(ShortcutsWindow)) uint32 { | |||
| 88 | 99 | // This is a [keybinding signal](class.SignalAction.html). | |
| 89 | 100 | // | |
| 90 | 101 | // The default binding for this signal is Control-F. | |
| 91 | - | func (x *ShortcutsWindow) ConnectSearch(cb func(ShortcutsWindow)) uint32 { | |
| 102 | + | func (x *ShortcutsWindow) ConnectSearch(cb *func(ShortcutsWindow)) uint32 { | |
| 103 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 104 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 105 | + | return gobject.SignalConnect(x.GoPointer(), "search", cbRefPtr) | |
| 106 | + | } | |
| 107 | + | ||
| 92 | 108 | fcb := func(clsPtr uintptr) { | |
| 93 | 109 | fa := ShortcutsWindow{} | |
| 94 | 110 | fa.Ptr = clsPtr | |
| 111 | + | cbFn := *cb | |
| 95 | 112 | ||
| 96 | - | cb(fa) | |
| 113 | + | cbFn(fa) | |
| 97 | 114 | ||
| 98 | 115 | } | |
| 99 | - | return gobject.SignalConnect(x.GoPointer(), "search", purego.NewCallback(fcb)) | |
| 116 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 117 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 118 | + | return gobject.SignalConnect(x.GoPointer(), "search", cbRefPtr) | |
| 100 | 119 | } | |
| 101 | 120 | ||
| 102 | 121 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkshow.go +2 -2
| @@ -28,9 +28,9 @@ var xShowUriFull func(uintptr, string, uint32, uintptr, uintptr, uintptr) | |||
| 28 | 28 | // | |
| 29 | 29 | // This is the recommended call to be used as it passes information | |
| 30 | 30 | // necessary for sandbox helpers to parent their dialogs properly. | |
| 31 | - | func ShowUriFull(ParentVar *Window, UriVar string, TimestampVar uint32, CancellableVar *gio.Cancellable, CallbackVar gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 31 | + | func ShowUriFull(ParentVar *Window, UriVar string, TimestampVar uint32, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { | |
| 32 | 32 | ||
| 33 | - | xShowUriFull(ParentVar.GoPointer(), UriVar, TimestampVar, CancellableVar.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar) | |
| 33 | + | xShowUriFull(ParentVar.GoPointer(), UriVar, TimestampVar, CancellableVar.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar) | |
| 34 | 34 | ||
| 35 | 35 | } | |
| 36 | 36 | ||
M v4/gtk/gtksignallistitemfactory.go +45 -12
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -102,15 +103,23 @@ func (c *SignalListItemFactory) SetGoPointer(ptr uintptr) { | |||
| 102 | 103 | // The [signal@Gtk.SignalListItemFactory::unbind] signal is the | |
| 103 | 104 | // opposite of this signal and can be used to undo everything done | |
| 104 | 105 | // in this signal. | |
| 105 | - | func (x *SignalListItemFactory) ConnectBind(cb func(SignalListItemFactory, uintptr)) uint32 { | |
| 106 | + | func (x *SignalListItemFactory) ConnectBind(cb *func(SignalListItemFactory, uintptr)) uint32 { | |
| 107 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 108 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 109 | + | return gobject.SignalConnect(x.GoPointer(), "bind", cbRefPtr) | |
| 110 | + | } | |
| 111 | + | ||
| 106 | 112 | fcb := func(clsPtr uintptr, ObjectVarp uintptr) { | |
| 107 | 113 | fa := SignalListItemFactory{} | |
| 108 | 114 | fa.Ptr = clsPtr | |
| 115 | + | cbFn := *cb | |
| 109 | 116 | ||
| 110 | - | cb(fa, ObjectVarp) | |
| 117 | + | cbFn(fa, ObjectVarp) | |
| 111 | 118 | ||
| 112 | 119 | } | |
| 113 | - | return gobject.SignalConnect(x.GoPointer(), "bind", purego.NewCallback(fcb)) | |
| 120 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 121 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 122 | + | return gobject.SignalConnect(x.GoPointer(), "bind", cbRefPtr) | |
| 114 | 123 | } | |
| 115 | 124 | ||
| 116 | 125 | // Emitted when a new listitem has been created and needs to be setup for use. | |
| @@ -119,15 +128,23 @@ func (x *SignalListItemFactory) ConnectBind(cb func(SignalListItemFactory, uintp | |||
| 119 | 128 | // | |
| 120 | 129 | // The [signal@Gtk.SignalListItemFactory::teardown] signal is the opposite | |
| 121 | 130 | // of this signal and can be used to undo everything done in this signal. | |
| 122 | - | func (x *SignalListItemFactory) ConnectSetup(cb func(SignalListItemFactory, uintptr)) uint32 { | |
| 131 | + | func (x *SignalListItemFactory) ConnectSetup(cb *func(SignalListItemFactory, uintptr)) uint32 { | |
| 132 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 133 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 134 | + | return gobject.SignalConnect(x.GoPointer(), "setup", cbRefPtr) | |
| 135 | + | } | |
| 136 | + | ||
| 123 | 137 | fcb := func(clsPtr uintptr, ObjectVarp uintptr) { | |
| 124 | 138 | fa := SignalListItemFactory{} | |
| 125 | 139 | fa.Ptr = clsPtr | |
| 140 | + | cbFn := *cb | |
| 126 | 141 | ||
| 127 | - | cb(fa, ObjectVarp) | |
| 142 | + | cbFn(fa, ObjectVarp) | |
| 128 | 143 | ||
| 129 | 144 | } | |
| 130 | - | return gobject.SignalConnect(x.GoPointer(), "setup", purego.NewCallback(fcb)) | |
| 145 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 146 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 147 | + | return gobject.SignalConnect(x.GoPointer(), "setup", cbRefPtr) | |
| 131 | 148 | } | |
| 132 | 149 | ||
| 133 | 150 | // Emitted when an object is about to be destroyed. | |
| @@ -136,15 +153,23 @@ func (x *SignalListItemFactory) ConnectSetup(cb func(SignalListItemFactory, uint | |||
| 136 | 153 | // | |
| 137 | 154 | // This signal is the opposite of the [signal@Gtk.SignalListItemFactory::setup] | |
| 138 | 155 | // signal and should be used to undo everything done in that signal. | |
| 139 | - | func (x *SignalListItemFactory) ConnectTeardown(cb func(SignalListItemFactory, uintptr)) uint32 { | |
| 156 | + | func (x *SignalListItemFactory) ConnectTeardown(cb *func(SignalListItemFactory, uintptr)) uint32 { | |
| 157 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 158 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 159 | + | return gobject.SignalConnect(x.GoPointer(), "teardown", cbRefPtr) | |
| 160 | + | } | |
| 161 | + | ||
| 140 | 162 | fcb := func(clsPtr uintptr, ObjectVarp uintptr) { | |
| 141 | 163 | fa := SignalListItemFactory{} | |
| 142 | 164 | fa.Ptr = clsPtr | |
| 165 | + | cbFn := *cb | |
| 143 | 166 | ||
| 144 | - | cb(fa, ObjectVarp) | |
| 167 | + | cbFn(fa, ObjectVarp) | |
| 145 | 168 | ||
| 146 | 169 | } | |
| 147 | - | return gobject.SignalConnect(x.GoPointer(), "teardown", purego.NewCallback(fcb)) | |
| 170 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 171 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 172 | + | return gobject.SignalConnect(x.GoPointer(), "teardown", cbRefPtr) | |
| 148 | 173 | } | |
| 149 | 174 | ||
| 150 | 175 | // Emitted when a object has been unbound from its item, for example when | |
| @@ -153,15 +178,23 @@ func (x *SignalListItemFactory) ConnectTeardown(cb func(SignalListItemFactory, u | |||
| 153 | 178 | // | |
| 154 | 179 | // This signal is the opposite of the [signal@Gtk.SignalListItemFactory::bind] | |
| 155 | 180 | // signal and should be used to undo everything done in that signal. | |
| 156 | - | func (x *SignalListItemFactory) ConnectUnbind(cb func(SignalListItemFactory, uintptr)) uint32 { | |
| 181 | + | func (x *SignalListItemFactory) ConnectUnbind(cb *func(SignalListItemFactory, uintptr)) uint32 { | |
| 182 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 183 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 184 | + | return gobject.SignalConnect(x.GoPointer(), "unbind", cbRefPtr) | |
| 185 | + | } | |
| 186 | + | ||
| 157 | 187 | fcb := func(clsPtr uintptr, ObjectVarp uintptr) { | |
| 158 | 188 | fa := SignalListItemFactory{} | |
| 159 | 189 | fa.Ptr = clsPtr | |
| 190 | + | cbFn := *cb | |
| 160 | 191 | ||
| 161 | - | cb(fa, ObjectVarp) | |
| 192 | + | cbFn(fa, ObjectVarp) | |
| 162 | 193 | ||
| 163 | 194 | } | |
| 164 | - | return gobject.SignalConnect(x.GoPointer(), "unbind", purego.NewCallback(fcb)) | |
| 195 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 196 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 197 | + | return gobject.SignalConnect(x.GoPointer(), "unbind", cbRefPtr) | |
| 165 | 198 | } | |
| 166 | 199 | ||
| 167 | 200 | func init() { | |
M v4/gtk/gtksorter.go +12 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -157,15 +158,23 @@ func (c *Sorter) SetGoPointer(ptr uintptr) { | |||
| 157 | 158 | // Depending on the @change parameter, it may be possible to update | |
| 158 | 159 | // the sort order without a full resorting. Refer to the | |
| 159 | 160 | // [enum@Gtk.SorterChange] documentation for details. | |
| 160 | - | func (x *Sorter) ConnectChanged(cb func(Sorter, SorterChange)) uint32 { | |
| 161 | + | func (x *Sorter) ConnectChanged(cb *func(Sorter, SorterChange)) uint32 { | |
| 162 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 163 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 164 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 165 | + | } | |
| 166 | + | ||
| 161 | 167 | fcb := func(clsPtr uintptr, ChangeVarp SorterChange) { | |
| 162 | 168 | fa := Sorter{} | |
| 163 | 169 | fa.Ptr = clsPtr | |
| 170 | + | cbFn := *cb | |
| 164 | 171 | ||
| 165 | - | cb(fa, ChangeVarp) | |
| 172 | + | cbFn(fa, ChangeVarp) | |
| 166 | 173 | ||
| 167 | 174 | } | |
| 168 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 175 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 176 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 177 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 169 | 178 | } | |
| 170 | 179 | ||
| 171 | 180 | func init() { | |
M v4/gtk/gtkspinbutton.go +58 -15
| @@ -2,9 +2,12 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 12 | ) | |
| 10 | 13 | ||
| @@ -501,15 +504,23 @@ func (c *SpinButton) SetGoPointer(ptr uintptr) { | |||
| 501 | 504 | // programmatically. | |
| 502 | 505 | // | |
| 503 | 506 | // The default bindings for this signal are Up/Down and PageUp/PageDown. | |
| 504 | - | func (x *SpinButton) ConnectChangeValue(cb func(SpinButton, ScrollType)) uint32 { | |
| 507 | + | func (x *SpinButton) ConnectChangeValue(cb *func(SpinButton, ScrollType)) uint32 { | |
| 508 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 509 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 510 | + | return gobject.SignalConnect(x.GoPointer(), "change-value", cbRefPtr) | |
| 511 | + | } | |
| 512 | + | ||
| 505 | 513 | fcb := func(clsPtr uintptr, ScrollVarp ScrollType) { | |
| 506 | 514 | fa := SpinButton{} | |
| 507 | 515 | fa.Ptr = clsPtr | |
| 516 | + | cbFn := *cb | |
| 508 | 517 | ||
| 509 | - | cb(fa, ScrollVarp) | |
| 518 | + | cbFn(fa, ScrollVarp) | |
| 510 | 519 | ||
| 511 | 520 | } | |
| 512 | - | return gobject.SignalConnect(x.GoPointer(), "change-value", purego.NewCallback(fcb)) | |
| 521 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 522 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 523 | + | return gobject.SignalConnect(x.GoPointer(), "change-value", cbRefPtr) | |
| 513 | 524 | } | |
| 514 | 525 | ||
| 515 | 526 | // Emitted to convert the users input into a double value. | |
| @@ -519,15 +530,23 @@ func (x *SpinButton) ConnectChangeValue(cb func(SpinButton, ScrollType)) uint32 | |||
| 519 | 530 | // new value. | |
| 520 | 531 | // | |
| 521 | 532 | // The default conversion uses g_strtod(). | |
| 522 | - | func (x *SpinButton) ConnectInput(cb func(SpinButton, float64) int) uint32 { | |
| 533 | + | func (x *SpinButton) ConnectInput(cb *func(SpinButton, float64) int) uint32 { | |
| 534 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 535 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 536 | + | return gobject.SignalConnect(x.GoPointer(), "input", cbRefPtr) | |
| 537 | + | } | |
| 538 | + | ||
| 523 | 539 | fcb := func(clsPtr uintptr, NewValueVarp float64) int { | |
| 524 | 540 | fa := SpinButton{} | |
| 525 | 541 | fa.Ptr = clsPtr | |
| 542 | + | cbFn := *cb | |
| 526 | 543 | ||
| 527 | - | return cb(fa, NewValueVarp) | |
| 544 | + | return cbFn(fa, NewValueVarp) | |
| 528 | 545 | ||
| 529 | 546 | } | |
| 530 | - | return gobject.SignalConnect(x.GoPointer(), "input", purego.NewCallback(fcb)) | |
| 547 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 548 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 549 | + | return gobject.SignalConnect(x.GoPointer(), "input", cbRefPtr) | |
| 531 | 550 | } | |
| 532 | 551 | ||
| 533 | 552 | // Emitted to tweak the formatting of the value for display. | |
| @@ -554,42 +573,66 @@ func (x *SpinButton) ConnectInput(cb func(SpinButton, float64) int) uint32 { | |||
| 554 | 573 | // } | |
| 555 | 574 | // | |
| 556 | 575 | // ``` | |
| 557 | - | func (x *SpinButton) ConnectOutput(cb func(SpinButton) bool) uint32 { | |
| 576 | + | func (x *SpinButton) ConnectOutput(cb *func(SpinButton) bool) uint32 { | |
| 577 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 578 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 579 | + | return gobject.SignalConnect(x.GoPointer(), "output", cbRefPtr) | |
| 580 | + | } | |
| 581 | + | ||
| 558 | 582 | fcb := func(clsPtr uintptr) bool { | |
| 559 | 583 | fa := SpinButton{} | |
| 560 | 584 | fa.Ptr = clsPtr | |
| 585 | + | cbFn := *cb | |
| 561 | 586 | ||
| 562 | - | return cb(fa) | |
| 587 | + | return cbFn(fa) | |
| 563 | 588 | ||
| 564 | 589 | } | |
| 565 | - | return gobject.SignalConnect(x.GoPointer(), "output", purego.NewCallback(fcb)) | |
| 590 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 591 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 592 | + | return gobject.SignalConnect(x.GoPointer(), "output", cbRefPtr) | |
| 566 | 593 | } | |
| 567 | 594 | ||
| 568 | 595 | // Emitted when the value is changed. | |
| 569 | 596 | // | |
| 570 | 597 | // Also see the [signal@Gtk.SpinButton::output] signal. | |
| 571 | - | func (x *SpinButton) ConnectValueChanged(cb func(SpinButton)) uint32 { | |
| 598 | + | func (x *SpinButton) ConnectValueChanged(cb *func(SpinButton)) uint32 { | |
| 599 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 600 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 601 | + | return gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr) | |
| 602 | + | } | |
| 603 | + | ||
| 572 | 604 | fcb := func(clsPtr uintptr) { | |
| 573 | 605 | fa := SpinButton{} | |
| 574 | 606 | fa.Ptr = clsPtr | |
| 607 | + | cbFn := *cb | |
| 575 | 608 | ||
| 576 | - | cb(fa) | |
| 609 | + | cbFn(fa) | |
| 577 | 610 | ||
| 578 | 611 | } | |
| 579 | - | return gobject.SignalConnect(x.GoPointer(), "value-changed", purego.NewCallback(fcb)) | |
| 612 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 613 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 614 | + | return gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr) | |
| 580 | 615 | } | |
| 581 | 616 | ||
| 582 | 617 | // Emitted right after the spinbutton wraps from its maximum | |
| 583 | 618 | // to its minimum value or vice-versa. | |
| 584 | - | func (x *SpinButton) ConnectWrapped(cb func(SpinButton)) uint32 { | |
| 619 | + | func (x *SpinButton) ConnectWrapped(cb *func(SpinButton)) uint32 { | |
| 620 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 621 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 622 | + | return gobject.SignalConnect(x.GoPointer(), "wrapped", cbRefPtr) | |
| 623 | + | } | |
| 624 | + | ||
| 585 | 625 | fcb := func(clsPtr uintptr) { | |
| 586 | 626 | fa := SpinButton{} | |
| 587 | 627 | fa.Ptr = clsPtr | |
| 628 | + | cbFn := *cb | |
| 588 | 629 | ||
| 589 | - | cb(fa) | |
| 630 | + | cbFn(fa) | |
| 590 | 631 | ||
| 591 | 632 | } | |
| 592 | - | return gobject.SignalConnect(x.GoPointer(), "wrapped", purego.NewCallback(fcb)) | |
| 633 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 634 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 635 | + | return gobject.SignalConnect(x.GoPointer(), "wrapped", cbRefPtr) | |
| 593 | 636 | } | |
| 594 | 637 | ||
| 595 | 638 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkstatusbar.go +25 -6
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -134,27 +137,43 @@ func (c *Statusbar) SetGoPointer(ptr uintptr) { | |||
| 134 | 137 | } | |
| 135 | 138 | ||
| 136 | 139 | // Emitted whenever a new message is popped off a statusbar's stack. | |
| 137 | - | func (x *Statusbar) ConnectTextPopped(cb func(Statusbar, uint, string)) uint32 { | |
| 140 | + | func (x *Statusbar) ConnectTextPopped(cb *func(Statusbar, uint, string)) uint32 { | |
| 141 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 142 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 143 | + | return gobject.SignalConnect(x.GoPointer(), "text-popped", cbRefPtr) | |
| 144 | + | } | |
| 145 | + | ||
| 138 | 146 | fcb := func(clsPtr uintptr, ContextIdVarp uint, TextVarp string) { | |
| 139 | 147 | fa := Statusbar{} | |
| 140 | 148 | fa.Ptr = clsPtr | |
| 149 | + | cbFn := *cb | |
| 141 | 150 | ||
| 142 | - | cb(fa, ContextIdVarp, TextVarp) | |
| 151 | + | cbFn(fa, ContextIdVarp, TextVarp) | |
| 143 | 152 | ||
| 144 | 153 | } | |
| 145 | - | return gobject.SignalConnect(x.GoPointer(), "text-popped", purego.NewCallback(fcb)) | |
| 154 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 155 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 156 | + | return gobject.SignalConnect(x.GoPointer(), "text-popped", cbRefPtr) | |
| 146 | 157 | } | |
| 147 | 158 | ||
| 148 | 159 | // Emitted whenever a new message gets pushed onto a statusbar's stack. | |
| 149 | - | func (x *Statusbar) ConnectTextPushed(cb func(Statusbar, uint, string)) uint32 { | |
| 160 | + | func (x *Statusbar) ConnectTextPushed(cb *func(Statusbar, uint, string)) uint32 { | |
| 161 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 162 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 163 | + | return gobject.SignalConnect(x.GoPointer(), "text-pushed", cbRefPtr) | |
| 164 | + | } | |
| 165 | + | ||
| 150 | 166 | fcb := func(clsPtr uintptr, ContextIdVarp uint, TextVarp string) { | |
| 151 | 167 | fa := Statusbar{} | |
| 152 | 168 | fa.Ptr = clsPtr | |
| 169 | + | cbFn := *cb | |
| 153 | 170 | ||
| 154 | - | cb(fa, ContextIdVarp, TextVarp) | |
| 171 | + | cbFn(fa, ContextIdVarp, TextVarp) | |
| 155 | 172 | ||
| 156 | 173 | } | |
| 157 | - | return gobject.SignalConnect(x.GoPointer(), "text-pushed", purego.NewCallback(fcb)) | |
| 174 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 175 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 176 | + | return gobject.SignalConnect(x.GoPointer(), "text-pushed", cbRefPtr) | |
| 158 | 177 | } | |
| 159 | 178 | ||
| 160 | 179 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkswitch.go +24 -6
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -115,15 +117,23 @@ func (c *Switch) SetGoPointer(ptr uintptr) { | |||
| 115 | 117 | // | |
| 116 | 118 | // Applications should never connect to this signal, | |
| 117 | 119 | // but use the [property@Gtk.Switch:active] property. | |
| 118 | - | func (x *Switch) ConnectActivate(cb func(Switch)) uint32 { | |
| 120 | + | func (x *Switch) ConnectActivate(cb *func(Switch)) uint32 { | |
| 121 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 122 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 123 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 124 | + | } | |
| 125 | + | ||
| 119 | 126 | fcb := func(clsPtr uintptr) { | |
| 120 | 127 | fa := Switch{} | |
| 121 | 128 | fa.Ptr = clsPtr | |
| 129 | + | cbFn := *cb | |
| 122 | 130 | ||
| 123 | - | cb(fa) | |
| 131 | + | cbFn(fa) | |
| 124 | 132 | ||
| 125 | 133 | } | |
| 126 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 134 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 135 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 136 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 127 | 137 | } | |
| 128 | 138 | ||
| 129 | 139 | // Emitted to change the underlying state. | |
| @@ -141,15 +151,23 @@ func (x *Switch) ConnectActivate(cb func(Switch)) uint32 { | |||
| 141 | 151 | // Visually, the underlying state is represented by the trough color of | |
| 142 | 152 | // the switch, while the [property@Gtk.Switch:active] property is | |
| 143 | 153 | // represented by the position of the switch. | |
| 144 | - | func (x *Switch) ConnectStateSet(cb func(Switch, bool) bool) uint32 { | |
| 154 | + | func (x *Switch) ConnectStateSet(cb *func(Switch, bool) bool) uint32 { | |
| 155 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 156 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 157 | + | return gobject.SignalConnect(x.GoPointer(), "state-set", cbRefPtr) | |
| 158 | + | } | |
| 159 | + | ||
| 145 | 160 | fcb := func(clsPtr uintptr, StateVarp bool) bool { | |
| 146 | 161 | fa := Switch{} | |
| 147 | 162 | fa.Ptr = clsPtr | |
| 163 | + | cbFn := *cb | |
| 148 | 164 | ||
| 149 | - | return cb(fa, StateVarp) | |
| 165 | + | return cbFn(fa, StateVarp) | |
| 150 | 166 | ||
| 151 | 167 | } | |
| 152 | - | return gobject.SignalConnect(x.GoPointer(), "state-set", purego.NewCallback(fcb)) | |
| 168 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 169 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 170 | + | return gobject.SignalConnect(x.GoPointer(), "state-set", cbRefPtr) | |
| 153 | 171 | } | |
| 154 | 172 | ||
| 155 | 173 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtktext.go +124 -33
| @@ -2,9 +2,12 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 8 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 9 | 12 | "github.com/jwijenbergh/puregotk/v4/graphene" | |
| 10 | 13 | "github.com/jwijenbergh/puregotk/v4/pango" | |
| @@ -542,15 +545,23 @@ func (c *Text) SetGoPointer(ptr uintptr) { | |||
| 542 | 545 | // | |
| 543 | 546 | // The default bindings for this signal are all forms | |
| 544 | 547 | // of the <kbd>Enter</kbd> key. | |
| 545 | - | func (x *Text) ConnectActivate(cb func(Text)) uint32 { | |
| 548 | + | func (x *Text) ConnectActivate(cb *func(Text)) uint32 { | |
| 549 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 550 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 551 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 552 | + | } | |
| 553 | + | ||
| 546 | 554 | fcb := func(clsPtr uintptr) { | |
| 547 | 555 | fa := Text{} | |
| 548 | 556 | fa.Ptr = clsPtr | |
| 557 | + | cbFn := *cb | |
| 549 | 558 | ||
| 550 | - | cb(fa) | |
| 559 | + | cbFn(fa) | |
| 551 | 560 | ||
| 552 | 561 | } | |
| 553 | - | return gobject.SignalConnect(x.GoPointer(), "activate", purego.NewCallback(fcb)) | |
| 562 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 563 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 564 | + | return gobject.SignalConnect(x.GoPointer(), "activate", cbRefPtr) | |
| 554 | 565 | } | |
| 555 | 566 | ||
| 556 | 567 | // Emitted when the user asks for it. | |
| @@ -559,15 +570,23 @@ func (x *Text) ConnectActivate(cb func(Text)) uint32 { | |||
| 559 | 570 | // | |
| 560 | 571 | // The default bindings for this signal are | |
| 561 | 572 | // <kbd>Backspace</kbd> and <kbd>Shift</kbd>-<kbd>Backspace</kbd>. | |
| 562 | - | func (x *Text) ConnectBackspace(cb func(Text)) uint32 { | |
| 573 | + | func (x *Text) ConnectBackspace(cb *func(Text)) uint32 { | |
| 574 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 575 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 576 | + | return gobject.SignalConnect(x.GoPointer(), "backspace", cbRefPtr) | |
| 577 | + | } | |
| 578 | + | ||
| 563 | 579 | fcb := func(clsPtr uintptr) { | |
| 564 | 580 | fa := Text{} | |
| 565 | 581 | fa.Ptr = clsPtr | |
| 582 | + | cbFn := *cb | |
| 566 | 583 | ||
| 567 | - | cb(fa) | |
| 584 | + | cbFn(fa) | |
| 568 | 585 | ||
| 569 | 586 | } | |
| 570 | - | return gobject.SignalConnect(x.GoPointer(), "backspace", purego.NewCallback(fcb)) | |
| 587 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 588 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 589 | + | return gobject.SignalConnect(x.GoPointer(), "backspace", cbRefPtr) | |
| 571 | 590 | } | |
| 572 | 591 | ||
| 573 | 592 | // Emitted to copy the selection to the clipboard. | |
| @@ -577,15 +596,23 @@ func (x *Text) ConnectBackspace(cb func(Text)) uint32 { | |||
| 577 | 596 | // The default bindings for this signal are | |
| 578 | 597 | // <kbd>Ctrl</kbd>-<kbd>c</kbd> and | |
| 579 | 598 | // <kbd>Ctrl</kbd>-<kbd>Insert</kbd>. | |
| 580 | - | func (x *Text) ConnectCopyClipboard(cb func(Text)) uint32 { | |
| 599 | + | func (x *Text) ConnectCopyClipboard(cb *func(Text)) uint32 { | |
| 600 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 601 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 602 | + | return gobject.SignalConnect(x.GoPointer(), "copy-clipboard", cbRefPtr) | |
| 603 | + | } | |
| 604 | + | ||
| 581 | 605 | fcb := func(clsPtr uintptr) { | |
| 582 | 606 | fa := Text{} | |
| 583 | 607 | fa.Ptr = clsPtr | |
| 608 | + | cbFn := *cb | |
| 584 | 609 | ||
| 585 | - | cb(fa) | |
| 610 | + | cbFn(fa) | |
| 586 | 611 | ||
| 587 | 612 | } | |
| 588 | - | return gobject.SignalConnect(x.GoPointer(), "copy-clipboard", purego.NewCallback(fcb)) | |
| 613 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 614 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 615 | + | return gobject.SignalConnect(x.GoPointer(), "copy-clipboard", cbRefPtr) | |
| 589 | 616 | } | |
| 590 | 617 | ||
| 591 | 618 | // Emitted to cut the selection to the clipboard. | |
| @@ -595,15 +622,23 @@ func (x *Text) ConnectCopyClipboard(cb func(Text)) uint32 { | |||
| 595 | 622 | // The default bindings for this signal are | |
| 596 | 623 | // <kbd>Ctrl</kbd>-<kbd>x</kbd> and | |
| 597 | 624 | // <kbd>Shift</kbd>-<kbd>Delete</kbd>. | |
| 598 | - | func (x *Text) ConnectCutClipboard(cb func(Text)) uint32 { | |
| 625 | + | func (x *Text) ConnectCutClipboard(cb *func(Text)) uint32 { | |
| 626 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 627 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 628 | + | return gobject.SignalConnect(x.GoPointer(), "cut-clipboard", cbRefPtr) | |
| 629 | + | } | |
| 630 | + | ||
| 599 | 631 | fcb := func(clsPtr uintptr) { | |
| 600 | 632 | fa := Text{} | |
| 601 | 633 | fa.Ptr = clsPtr | |
| 634 | + | cbFn := *cb | |
| 602 | 635 | ||
| 603 | - | cb(fa) | |
| 636 | + | cbFn(fa) | |
| 604 | 637 | ||
| 605 | 638 | } | |
| 606 | - | return gobject.SignalConnect(x.GoPointer(), "cut-clipboard", purego.NewCallback(fcb)) | |
| 639 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 640 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 641 | + | return gobject.SignalConnect(x.GoPointer(), "cut-clipboard", cbRefPtr) | |
| 607 | 642 | } | |
| 608 | 643 | ||
| 609 | 644 | // Emitted when the user initiates a text deletion. | |
| @@ -617,15 +652,23 @@ func (x *Text) ConnectCutClipboard(cb func(Text)) uint32 { | |||
| 617 | 652 | // The default bindings for this signal are <kbd>Delete</kbd> | |
| 618 | 653 | // for deleting a character and <kbd>Ctrl</kbd>-<kbd>Delete</kbd> | |
| 619 | 654 | // for deleting a word. | |
| 620 | - | func (x *Text) ConnectDeleteFromCursor(cb func(Text, DeleteType, int)) uint32 { | |
| 655 | + | func (x *Text) ConnectDeleteFromCursor(cb *func(Text, DeleteType, int)) uint32 { | |
| 656 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 657 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 658 | + | return gobject.SignalConnect(x.GoPointer(), "delete-from-cursor", cbRefPtr) | |
| 659 | + | } | |
| 660 | + | ||
| 621 | 661 | fcb := func(clsPtr uintptr, TypeVarp DeleteType, CountVarp int) { | |
| 622 | 662 | fa := Text{} | |
| 623 | 663 | fa.Ptr = clsPtr | |
| 664 | + | cbFn := *cb | |
| 624 | 665 | ||
| 625 | - | cb(fa, TypeVarp, CountVarp) | |
| 666 | + | cbFn(fa, TypeVarp, CountVarp) | |
| 626 | 667 | ||
| 627 | 668 | } | |
| 628 | - | return gobject.SignalConnect(x.GoPointer(), "delete-from-cursor", purego.NewCallback(fcb)) | |
| 669 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 670 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 671 | + | return gobject.SignalConnect(x.GoPointer(), "delete-from-cursor", cbRefPtr) | |
| 629 | 672 | } | |
| 630 | 673 | ||
| 631 | 674 | // Emitted when the user initiates the insertion of a | |
| @@ -634,15 +677,23 @@ func (x *Text) ConnectDeleteFromCursor(cb func(Text, DeleteType, int)) uint32 { | |||
| 634 | 677 | // This is a [keybinding signal](class.SignalAction.html). | |
| 635 | 678 | // | |
| 636 | 679 | // This signal has no default bindings. | |
| 637 | - | func (x *Text) ConnectInsertAtCursor(cb func(Text, string)) uint32 { | |
| 680 | + | func (x *Text) ConnectInsertAtCursor(cb *func(Text, string)) uint32 { | |
| 681 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 682 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 683 | + | return gobject.SignalConnect(x.GoPointer(), "insert-at-cursor", cbRefPtr) | |
| 684 | + | } | |
| 685 | + | ||
| 638 | 686 | fcb := func(clsPtr uintptr, StringVarp string) { | |
| 639 | 687 | fa := Text{} | |
| 640 | 688 | fa.Ptr = clsPtr | |
| 689 | + | cbFn := *cb | |
| 641 | 690 | ||
| 642 | - | cb(fa, StringVarp) | |
| 691 | + | cbFn(fa, StringVarp) | |
| 643 | 692 | ||
| 644 | 693 | } | |
| 645 | - | return gobject.SignalConnect(x.GoPointer(), "insert-at-cursor", purego.NewCallback(fcb)) | |
| 694 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 695 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 696 | + | return gobject.SignalConnect(x.GoPointer(), "insert-at-cursor", cbRefPtr) | |
| 646 | 697 | } | |
| 647 | 698 | ||
| 648 | 699 | // Emitted to present the Emoji chooser for the widget. | |
| @@ -652,15 +703,23 @@ func (x *Text) ConnectInsertAtCursor(cb func(Text, string)) uint32 { | |||
| 652 | 703 | // The default bindings for this signal are | |
| 653 | 704 | // <kbd>Ctrl</kbd>-<kbd>.</kbd> and | |
| 654 | 705 | // <kbd>Ctrl</kbd>-<kbd>;</kbd> | |
| 655 | - | func (x *Text) ConnectInsertEmoji(cb func(Text)) uint32 { | |
| 706 | + | func (x *Text) ConnectInsertEmoji(cb *func(Text)) uint32 { | |
| 707 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 708 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 709 | + | return gobject.SignalConnect(x.GoPointer(), "insert-emoji", cbRefPtr) | |
| 710 | + | } | |
| 711 | + | ||
| 656 | 712 | fcb := func(clsPtr uintptr) { | |
| 657 | 713 | fa := Text{} | |
| 658 | 714 | fa.Ptr = clsPtr | |
| 715 | + | cbFn := *cb | |
| 659 | 716 | ||
| 660 | - | cb(fa) | |
| 717 | + | cbFn(fa) | |
| 661 | 718 | ||
| 662 | 719 | } | |
| 663 | - | return gobject.SignalConnect(x.GoPointer(), "insert-emoji", purego.NewCallback(fcb)) | |
| 720 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 721 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 722 | + | return gobject.SignalConnect(x.GoPointer(), "insert-emoji", cbRefPtr) | |
| 664 | 723 | } | |
| 665 | 724 | ||
| 666 | 725 | // Emitted when the user initiates a cursor movement. | |
| @@ -683,15 +742,23 @@ func (x *Text) ConnectInsertEmoji(cb func(Text)) uint32 { | |||
| 683 | 742 | // move by individual characters/lines | |
| 684 | 743 | // - <kbd>Ctrl</kbd>-<kbd>→</kbd>, etc. move by words/paragraphs | |
| 685 | 744 | // - <kbd>Home</kbd>, <kbd>End</kbd> move to the ends of the buffer | |
| 686 | - | func (x *Text) ConnectMoveCursor(cb func(Text, MovementStep, int, bool)) uint32 { | |
| 745 | + | func (x *Text) ConnectMoveCursor(cb *func(Text, MovementStep, int, bool)) uint32 { | |
| 746 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 747 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 748 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 749 | + | } | |
| 750 | + | ||
| 687 | 751 | fcb := func(clsPtr uintptr, StepVarp MovementStep, CountVarp int, ExtendVarp bool) { | |
| 688 | 752 | fa := Text{} | |
| 689 | 753 | fa.Ptr = clsPtr | |
| 754 | + | cbFn := *cb | |
| 690 | 755 | ||
| 691 | - | cb(fa, StepVarp, CountVarp, ExtendVarp) | |
| 756 | + | cbFn(fa, StepVarp, CountVarp, ExtendVarp) | |
| 692 | 757 | ||
| 693 | 758 | } | |
| 694 | - | return gobject.SignalConnect(x.GoPointer(), "move-cursor", purego.NewCallback(fcb)) | |
| 759 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 760 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 761 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 695 | 762 | } | |
| 696 | 763 | ||
| 697 | 764 | // Emitted to paste the contents of the clipboard. | |
| @@ -700,15 +767,23 @@ func (x *Text) ConnectMoveCursor(cb func(Text, MovementStep, int, bool)) uint32 | |||
| 700 | 767 | // | |
| 701 | 768 | // The default bindings for this signal are | |
| 702 | 769 | // <kbd>Ctrl</kbd>-<kbd>v</kbd> and <kbd>Shift</kbd>-<kbd>Insert</kbd>. | |
| 703 | - | func (x *Text) ConnectPasteClipboard(cb func(Text)) uint32 { | |
| 770 | + | func (x *Text) ConnectPasteClipboard(cb *func(Text)) uint32 { | |
| 771 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 772 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 773 | + | return gobject.SignalConnect(x.GoPointer(), "paste-clipboard", cbRefPtr) | |
| 774 | + | } | |
| 775 | + | ||
| 704 | 776 | fcb := func(clsPtr uintptr) { | |
| 705 | 777 | fa := Text{} | |
| 706 | 778 | fa.Ptr = clsPtr | |
| 779 | + | cbFn := *cb | |
| 707 | 780 | ||
| 708 | - | cb(fa) | |
| 781 | + | cbFn(fa) | |
| 709 | 782 | ||
| 710 | 783 | } | |
| 711 | - | return gobject.SignalConnect(x.GoPointer(), "paste-clipboard", purego.NewCallback(fcb)) | |
| 784 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 785 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 786 | + | return gobject.SignalConnect(x.GoPointer(), "paste-clipboard", cbRefPtr) | |
| 712 | 787 | } | |
| 713 | 788 | ||
| 714 | 789 | // Emitted when the preedit text changes. | |
| @@ -716,15 +791,23 @@ func (x *Text) ConnectPasteClipboard(cb func(Text)) uint32 { | |||
| 716 | 791 | // If an input method is used, the typed text will not immediately | |
| 717 | 792 | // be committed to the buffer. So if you are interested in the text, | |
| 718 | 793 | // connect to this signal. | |
| 719 | - | func (x *Text) ConnectPreeditChanged(cb func(Text, string)) uint32 { | |
| 794 | + | func (x *Text) ConnectPreeditChanged(cb *func(Text, string)) uint32 { | |
| 795 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 796 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 797 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-changed", cbRefPtr) | |
| 798 | + | } | |
| 799 | + | ||
| 720 | 800 | fcb := func(clsPtr uintptr, PreeditVarp string) { | |
| 721 | 801 | fa := Text{} | |
| 722 | 802 | fa.Ptr = clsPtr | |
| 803 | + | cbFn := *cb | |
| 723 | 804 | ||
| 724 | - | cb(fa, PreeditVarp) | |
| 805 | + | cbFn(fa, PreeditVarp) | |
| 725 | 806 | ||
| 726 | 807 | } | |
| 727 | - | return gobject.SignalConnect(x.GoPointer(), "preedit-changed", purego.NewCallback(fcb)) | |
| 808 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 809 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 810 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-changed", cbRefPtr) | |
| 728 | 811 | } | |
| 729 | 812 | ||
| 730 | 813 | // Emitted to toggle the overwrite mode of the `GtkText`. | |
| @@ -732,15 +815,23 @@ func (x *Text) ConnectPreeditChanged(cb func(Text, string)) uint32 { | |||
| 732 | 815 | // This is a [keybinding signal](class.SignalAction.html). | |
| 733 | 816 | // | |
| 734 | 817 | // The default bindings for this signal is <kbd>Insert</kbd>. | |
| 735 | - | func (x *Text) ConnectToggleOverwrite(cb func(Text)) uint32 { | |
| 818 | + | func (x *Text) ConnectToggleOverwrite(cb *func(Text)) uint32 { | |
| 819 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 820 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 821 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-overwrite", cbRefPtr) | |
| 822 | + | } | |
| 823 | + | ||
| 736 | 824 | fcb := func(clsPtr uintptr) { | |
| 737 | 825 | fa := Text{} | |
| 738 | 826 | fa.Ptr = clsPtr | |
| 827 | + | cbFn := *cb | |
| 739 | 828 | ||
| 740 | - | cb(fa) | |
| 829 | + | cbFn(fa) | |
| 741 | 830 | ||
| 742 | 831 | } | |
| 743 | - | return gobject.SignalConnect(x.GoPointer(), "toggle-overwrite", purego.NewCallback(fcb)) | |
| 832 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 833 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 834 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-overwrite", cbRefPtr) | |
| 744 | 835 | } | |
| 745 | 836 | ||
| 746 | 837 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtktextbuffer.go +166 -45
| @@ -7,6 +7,7 @@ import ( | |||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 10 | 11 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 11 | 12 | ) | |
| 12 | 13 | ||
| @@ -1157,15 +1158,23 @@ func (c *TextBuffer) SetGoPointer(ptr uintptr) { | |||
| 1157 | 1158 | // [method@Gtk.TextBuffer.apply_tag], | |
| 1158 | 1159 | // [method@Gtk.TextBuffer.insert_with_tags], | |
| 1159 | 1160 | // [method@Gtk.TextBuffer.insert_range]. | |
| 1160 | - | func (x *TextBuffer) ConnectApplyTag(cb func(TextBuffer, uintptr, uintptr, uintptr)) uint32 { | |
| 1161 | + | func (x *TextBuffer) ConnectApplyTag(cb *func(TextBuffer, uintptr, uintptr, uintptr)) uint32 { | |
| 1162 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1163 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1164 | + | return gobject.SignalConnect(x.GoPointer(), "apply-tag", cbRefPtr) | |
| 1165 | + | } | |
| 1166 | + | ||
| 1161 | 1167 | fcb := func(clsPtr uintptr, TagVarp uintptr, StartVarp uintptr, EndVarp uintptr) { | |
| 1162 | 1168 | fa := TextBuffer{} | |
| 1163 | 1169 | fa.Ptr = clsPtr | |
| 1170 | + | cbFn := *cb | |
| 1164 | 1171 | ||
| 1165 | - | cb(fa, TagVarp, StartVarp, EndVarp) | |
| 1172 | + | cbFn(fa, TagVarp, StartVarp, EndVarp) | |
| 1166 | 1173 | ||
| 1167 | 1174 | } | |
| 1168 | - | return gobject.SignalConnect(x.GoPointer(), "apply-tag", purego.NewCallback(fcb)) | |
| 1175 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1176 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1177 | + | return gobject.SignalConnect(x.GoPointer(), "apply-tag", cbRefPtr) | |
| 1169 | 1178 | } | |
| 1170 | 1179 | ||
| 1171 | 1180 | // Emitted at the beginning of a single user-visible | |
| @@ -1178,27 +1187,43 @@ func (x *TextBuffer) ConnectApplyTag(cb func(TextBuffer, uintptr, uintptr, uintp | |||
| 1178 | 1187 | // [method@Gtk.TextBuffer.delete_interactive], | |
| 1179 | 1188 | // [method@Gtk.TextBuffer.backspace], | |
| 1180 | 1189 | // [method@Gtk.TextBuffer.delete_selection]. | |
| 1181 | - | func (x *TextBuffer) ConnectBeginUserAction(cb func(TextBuffer)) uint32 { | |
| 1190 | + | func (x *TextBuffer) ConnectBeginUserAction(cb *func(TextBuffer)) uint32 { | |
| 1191 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1192 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1193 | + | return gobject.SignalConnect(x.GoPointer(), "begin-user-action", cbRefPtr) | |
| 1194 | + | } | |
| 1195 | + | ||
| 1182 | 1196 | fcb := func(clsPtr uintptr) { | |
| 1183 | 1197 | fa := TextBuffer{} | |
| 1184 | 1198 | fa.Ptr = clsPtr | |
| 1199 | + | cbFn := *cb | |
| 1185 | 1200 | ||
| 1186 | - | cb(fa) | |
| 1201 | + | cbFn(fa) | |
| 1187 | 1202 | ||
| 1188 | 1203 | } | |
| 1189 | - | return gobject.SignalConnect(x.GoPointer(), "begin-user-action", purego.NewCallback(fcb)) | |
| 1204 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1205 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1206 | + | return gobject.SignalConnect(x.GoPointer(), "begin-user-action", cbRefPtr) | |
| 1190 | 1207 | } | |
| 1191 | 1208 | ||
| 1192 | 1209 | // Emitted when the content of a `GtkTextBuffer` has changed. | |
| 1193 | - | func (x *TextBuffer) ConnectChanged(cb func(TextBuffer)) uint32 { | |
| 1210 | + | func (x *TextBuffer) ConnectChanged(cb *func(TextBuffer)) uint32 { | |
| 1211 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1212 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1213 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 1214 | + | } | |
| 1215 | + | ||
| 1194 | 1216 | fcb := func(clsPtr uintptr) { | |
| 1195 | 1217 | fa := TextBuffer{} | |
| 1196 | 1218 | fa.Ptr = clsPtr | |
| 1219 | + | cbFn := *cb | |
| 1197 | 1220 | ||
| 1198 | - | cb(fa) | |
| 1221 | + | cbFn(fa) | |
| 1199 | 1222 | ||
| 1200 | 1223 | } | |
| 1201 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 1224 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1225 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1226 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 1202 | 1227 | } | |
| 1203 | 1228 | ||
| 1204 | 1229 | // Emitted to delete a range from a `GtkTextBuffer`. | |
| @@ -1212,15 +1237,23 @@ func (x *TextBuffer) ConnectChanged(cb func(TextBuffer)) uint32 { | |||
| 1212 | 1237 | // the deleted text. | |
| 1213 | 1238 | // | |
| 1214 | 1239 | // See also: [method@Gtk.TextBuffer.delete]. | |
| 1215 | - | func (x *TextBuffer) ConnectDeleteRange(cb func(TextBuffer, uintptr, uintptr)) uint32 { | |
| 1240 | + | func (x *TextBuffer) ConnectDeleteRange(cb *func(TextBuffer, uintptr, uintptr)) uint32 { | |
| 1241 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1242 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1243 | + | return gobject.SignalConnect(x.GoPointer(), "delete-range", cbRefPtr) | |
| 1244 | + | } | |
| 1245 | + | ||
| 1216 | 1246 | fcb := func(clsPtr uintptr, StartVarp uintptr, EndVarp uintptr) { | |
| 1217 | 1247 | fa := TextBuffer{} | |
| 1218 | 1248 | fa.Ptr = clsPtr | |
| 1249 | + | cbFn := *cb | |
| 1219 | 1250 | ||
| 1220 | - | cb(fa, StartVarp, EndVarp) | |
| 1251 | + | cbFn(fa, StartVarp, EndVarp) | |
| 1221 | 1252 | ||
| 1222 | 1253 | } | |
| 1223 | - | return gobject.SignalConnect(x.GoPointer(), "delete-range", purego.NewCallback(fcb)) | |
| 1254 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1255 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1256 | + | return gobject.SignalConnect(x.GoPointer(), "delete-range", cbRefPtr) | |
| 1224 | 1257 | } | |
| 1225 | 1258 | ||
| 1226 | 1259 | // Emitted at the end of a single user-visible | |
| @@ -1234,15 +1267,23 @@ func (x *TextBuffer) ConnectDeleteRange(cb func(TextBuffer, uintptr, uintptr)) u | |||
| 1234 | 1267 | // [method@Gtk.TextBuffer.backspace], | |
| 1235 | 1268 | // [method@Gtk.TextBuffer.delete_selection], | |
| 1236 | 1269 | // [method@Gtk.TextBuffer.backspace]. | |
| 1237 | - | func (x *TextBuffer) ConnectEndUserAction(cb func(TextBuffer)) uint32 { | |
| 1270 | + | func (x *TextBuffer) ConnectEndUserAction(cb *func(TextBuffer)) uint32 { | |
| 1271 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1272 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1273 | + | return gobject.SignalConnect(x.GoPointer(), "end-user-action", cbRefPtr) | |
| 1274 | + | } | |
| 1275 | + | ||
| 1238 | 1276 | fcb := func(clsPtr uintptr) { | |
| 1239 | 1277 | fa := TextBuffer{} | |
| 1240 | 1278 | fa.Ptr = clsPtr | |
| 1279 | + | cbFn := *cb | |
| 1241 | 1280 | ||
| 1242 | - | cb(fa) | |
| 1281 | + | cbFn(fa) | |
| 1243 | 1282 | ||
| 1244 | 1283 | } | |
| 1245 | - | return gobject.SignalConnect(x.GoPointer(), "end-user-action", purego.NewCallback(fcb)) | |
| 1284 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1285 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1286 | + | return gobject.SignalConnect(x.GoPointer(), "end-user-action", cbRefPtr) | |
| 1246 | 1287 | } | |
| 1247 | 1288 | ||
| 1248 | 1289 | // Emitted to insert a `GtkTextChildAnchor` in a `GtkTextBuffer`. | |
| @@ -1255,15 +1296,23 @@ func (x *TextBuffer) ConnectEndUserAction(cb func(TextBuffer)) uint32 { | |||
| 1255 | 1296 | // it to be placed after the inserted @anchor. | |
| 1256 | 1297 | // | |
| 1257 | 1298 | // See also: [method@Gtk.TextBuffer.insert_child_anchor]. | |
| 1258 | - | func (x *TextBuffer) ConnectInsertChildAnchor(cb func(TextBuffer, uintptr, uintptr)) uint32 { | |
| 1299 | + | func (x *TextBuffer) ConnectInsertChildAnchor(cb *func(TextBuffer, uintptr, uintptr)) uint32 { | |
| 1300 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1301 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1302 | + | return gobject.SignalConnect(x.GoPointer(), "insert-child-anchor", cbRefPtr) | |
| 1303 | + | } | |
| 1304 | + | ||
| 1259 | 1305 | fcb := func(clsPtr uintptr, LocationVarp uintptr, AnchorVarp uintptr) { | |
| 1260 | 1306 | fa := TextBuffer{} | |
| 1261 | 1307 | fa.Ptr = clsPtr | |
| 1308 | + | cbFn := *cb | |
| 1262 | 1309 | ||
| 1263 | - | cb(fa, LocationVarp, AnchorVarp) | |
| 1310 | + | cbFn(fa, LocationVarp, AnchorVarp) | |
| 1264 | 1311 | ||
| 1265 | 1312 | } | |
| 1266 | - | return gobject.SignalConnect(x.GoPointer(), "insert-child-anchor", purego.NewCallback(fcb)) | |
| 1313 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1314 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1315 | + | return gobject.SignalConnect(x.GoPointer(), "insert-child-anchor", cbRefPtr) | |
| 1267 | 1316 | } | |
| 1268 | 1317 | ||
| 1269 | 1318 | // Emitted to insert a `GdkPaintable` in a `GtkTextBuffer`. | |
| @@ -1276,15 +1325,23 @@ func (x *TextBuffer) ConnectInsertChildAnchor(cb func(TextBuffer, uintptr, uintp | |||
| 1276 | 1325 | // it to be placed after the inserted @paintable. | |
| 1277 | 1326 | // | |
| 1278 | 1327 | // See also: [method@Gtk.TextBuffer.insert_paintable]. | |
| 1279 | - | func (x *TextBuffer) ConnectInsertPaintable(cb func(TextBuffer, uintptr, uintptr)) uint32 { | |
| 1328 | + | func (x *TextBuffer) ConnectInsertPaintable(cb *func(TextBuffer, uintptr, uintptr)) uint32 { | |
| 1329 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1330 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1331 | + | return gobject.SignalConnect(x.GoPointer(), "insert-paintable", cbRefPtr) | |
| 1332 | + | } | |
| 1333 | + | ||
| 1280 | 1334 | fcb := func(clsPtr uintptr, LocationVarp uintptr, PaintableVarp uintptr) { | |
| 1281 | 1335 | fa := TextBuffer{} | |
| 1282 | 1336 | fa.Ptr = clsPtr | |
| 1337 | + | cbFn := *cb | |
| 1283 | 1338 | ||
| 1284 | - | cb(fa, LocationVarp, PaintableVarp) | |
| 1339 | + | cbFn(fa, LocationVarp, PaintableVarp) | |
| 1285 | 1340 | ||
| 1286 | 1341 | } | |
| 1287 | - | return gobject.SignalConnect(x.GoPointer(), "insert-paintable", purego.NewCallback(fcb)) | |
| 1342 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1343 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1344 | + | return gobject.SignalConnect(x.GoPointer(), "insert-paintable", cbRefPtr) | |
| 1288 | 1345 | } | |
| 1289 | 1346 | ||
| 1290 | 1347 | // Emitted to insert text in a `GtkTextBuffer`. | |
| @@ -1298,29 +1355,45 @@ func (x *TextBuffer) ConnectInsertPaintable(cb func(TextBuffer, uintptr, uintptr | |||
| 1298 | 1355 | // | |
| 1299 | 1356 | // See also: [method@Gtk.TextBuffer.insert], | |
| 1300 | 1357 | // [method@Gtk.TextBuffer.insert_range]. | |
| 1301 | - | func (x *TextBuffer) ConnectInsertText(cb func(TextBuffer, uintptr, string, int)) uint32 { | |
| 1358 | + | func (x *TextBuffer) ConnectInsertText(cb *func(TextBuffer, uintptr, string, int)) uint32 { | |
| 1359 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1360 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1361 | + | return gobject.SignalConnect(x.GoPointer(), "insert-text", cbRefPtr) | |
| 1362 | + | } | |
| 1363 | + | ||
| 1302 | 1364 | fcb := func(clsPtr uintptr, LocationVarp uintptr, TextVarp string, LenVarp int) { | |
| 1303 | 1365 | fa := TextBuffer{} | |
| 1304 | 1366 | fa.Ptr = clsPtr | |
| 1367 | + | cbFn := *cb | |
| 1305 | 1368 | ||
| 1306 | - | cb(fa, LocationVarp, TextVarp, LenVarp) | |
| 1369 | + | cbFn(fa, LocationVarp, TextVarp, LenVarp) | |
| 1307 | 1370 | ||
| 1308 | 1371 | } | |
| 1309 | - | return gobject.SignalConnect(x.GoPointer(), "insert-text", purego.NewCallback(fcb)) | |
| 1372 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1373 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1374 | + | return gobject.SignalConnect(x.GoPointer(), "insert-text", cbRefPtr) | |
| 1310 | 1375 | } | |
| 1311 | 1376 | ||
| 1312 | 1377 | // Emitted as notification after a `GtkTextMark` is deleted. | |
| 1313 | 1378 | // | |
| 1314 | 1379 | // See also: [method@Gtk.TextBuffer.delete_mark]. | |
| 1315 | - | func (x *TextBuffer) ConnectMarkDeleted(cb func(TextBuffer, uintptr)) uint32 { | |
| 1380 | + | func (x *TextBuffer) ConnectMarkDeleted(cb *func(TextBuffer, uintptr)) uint32 { | |
| 1381 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1382 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1383 | + | return gobject.SignalConnect(x.GoPointer(), "mark-deleted", cbRefPtr) | |
| 1384 | + | } | |
| 1385 | + | ||
| 1316 | 1386 | fcb := func(clsPtr uintptr, MarkVarp uintptr) { | |
| 1317 | 1387 | fa := TextBuffer{} | |
| 1318 | 1388 | fa.Ptr = clsPtr | |
| 1389 | + | cbFn := *cb | |
| 1319 | 1390 | ||
| 1320 | - | cb(fa, MarkVarp) | |
| 1391 | + | cbFn(fa, MarkVarp) | |
| 1321 | 1392 | ||
| 1322 | 1393 | } | |
| 1323 | - | return gobject.SignalConnect(x.GoPointer(), "mark-deleted", purego.NewCallback(fcb)) | |
| 1394 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1395 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1396 | + | return gobject.SignalConnect(x.GoPointer(), "mark-deleted", cbRefPtr) | |
| 1324 | 1397 | } | |
| 1325 | 1398 | ||
| 1326 | 1399 | // Emitted as notification after a `GtkTextMark` is set. | |
| @@ -1328,29 +1401,45 @@ func (x *TextBuffer) ConnectMarkDeleted(cb func(TextBuffer, uintptr)) uint32 { | |||
| 1328 | 1401 | // See also: | |
| 1329 | 1402 | // [method@Gtk.TextBuffer.create_mark], | |
| 1330 | 1403 | // [method@Gtk.TextBuffer.move_mark]. | |
| 1331 | - | func (x *TextBuffer) ConnectMarkSet(cb func(TextBuffer, uintptr, uintptr)) uint32 { | |
| 1404 | + | func (x *TextBuffer) ConnectMarkSet(cb *func(TextBuffer, uintptr, uintptr)) uint32 { | |
| 1405 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1406 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1407 | + | return gobject.SignalConnect(x.GoPointer(), "mark-set", cbRefPtr) | |
| 1408 | + | } | |
| 1409 | + | ||
| 1332 | 1410 | fcb := func(clsPtr uintptr, LocationVarp uintptr, MarkVarp uintptr) { | |
| 1333 | 1411 | fa := TextBuffer{} | |
| 1334 | 1412 | fa.Ptr = clsPtr | |
| 1413 | + | cbFn := *cb | |
| 1335 | 1414 | ||
| 1336 | - | cb(fa, LocationVarp, MarkVarp) | |
| 1415 | + | cbFn(fa, LocationVarp, MarkVarp) | |
| 1337 | 1416 | ||
| 1338 | 1417 | } | |
| 1339 | - | return gobject.SignalConnect(x.GoPointer(), "mark-set", purego.NewCallback(fcb)) | |
| 1418 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1419 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1420 | + | return gobject.SignalConnect(x.GoPointer(), "mark-set", cbRefPtr) | |
| 1340 | 1421 | } | |
| 1341 | 1422 | ||
| 1342 | 1423 | // Emitted when the modified bit of a `GtkTextBuffer` flips. | |
| 1343 | 1424 | // | |
| 1344 | 1425 | // See also: [method@Gtk.TextBuffer.set_modified]. | |
| 1345 | - | func (x *TextBuffer) ConnectModifiedChanged(cb func(TextBuffer)) uint32 { | |
| 1426 | + | func (x *TextBuffer) ConnectModifiedChanged(cb *func(TextBuffer)) uint32 { | |
| 1427 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1428 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1429 | + | return gobject.SignalConnect(x.GoPointer(), "modified-changed", cbRefPtr) | |
| 1430 | + | } | |
| 1431 | + | ||
| 1346 | 1432 | fcb := func(clsPtr uintptr) { | |
| 1347 | 1433 | fa := TextBuffer{} | |
| 1348 | 1434 | fa.Ptr = clsPtr | |
| 1435 | + | cbFn := *cb | |
| 1349 | 1436 | ||
| 1350 | - | cb(fa) | |
| 1437 | + | cbFn(fa) | |
| 1351 | 1438 | ||
| 1352 | 1439 | } | |
| 1353 | - | return gobject.SignalConnect(x.GoPointer(), "modified-changed", purego.NewCallback(fcb)) | |
| 1440 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1441 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1442 | + | return gobject.SignalConnect(x.GoPointer(), "modified-changed", cbRefPtr) | |
| 1354 | 1443 | } | |
| 1355 | 1444 | ||
| 1356 | 1445 | // Emitted after paste operation has been completed. | |
| @@ -1358,28 +1447,44 @@ func (x *TextBuffer) ConnectModifiedChanged(cb func(TextBuffer)) uint32 { | |||
| 1358 | 1447 | // This is useful to properly scroll the view to the end | |
| 1359 | 1448 | // of the pasted text. See [method@Gtk.TextBuffer.paste_clipboard] | |
| 1360 | 1449 | // for more details. | |
| 1361 | - | func (x *TextBuffer) ConnectPasteDone(cb func(TextBuffer, uintptr)) uint32 { | |
| 1450 | + | func (x *TextBuffer) ConnectPasteDone(cb *func(TextBuffer, uintptr)) uint32 { | |
| 1451 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1452 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1453 | + | return gobject.SignalConnect(x.GoPointer(), "paste-done", cbRefPtr) | |
| 1454 | + | } | |
| 1455 | + | ||
| 1362 | 1456 | fcb := func(clsPtr uintptr, ClipboardVarp uintptr) { | |
| 1363 | 1457 | fa := TextBuffer{} | |
| 1364 | 1458 | fa.Ptr = clsPtr | |
| 1459 | + | cbFn := *cb | |
| 1365 | 1460 | ||
| 1366 | - | cb(fa, ClipboardVarp) | |
| 1461 | + | cbFn(fa, ClipboardVarp) | |
| 1367 | 1462 | ||
| 1368 | 1463 | } | |
| 1369 | - | return gobject.SignalConnect(x.GoPointer(), "paste-done", purego.NewCallback(fcb)) | |
| 1464 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1465 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1466 | + | return gobject.SignalConnect(x.GoPointer(), "paste-done", cbRefPtr) | |
| 1370 | 1467 | } | |
| 1371 | 1468 | ||
| 1372 | 1469 | // Emitted when a request has been made to redo the | |
| 1373 | 1470 | // previously undone operation. | |
| 1374 | - | func (x *TextBuffer) ConnectRedo(cb func(TextBuffer)) uint32 { | |
| 1471 | + | func (x *TextBuffer) ConnectRedo(cb *func(TextBuffer)) uint32 { | |
| 1472 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1473 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1474 | + | return gobject.SignalConnect(x.GoPointer(), "redo", cbRefPtr) | |
| 1475 | + | } | |
| 1476 | + | ||
| 1375 | 1477 | fcb := func(clsPtr uintptr) { | |
| 1376 | 1478 | fa := TextBuffer{} | |
| 1377 | 1479 | fa.Ptr = clsPtr | |
| 1480 | + | cbFn := *cb | |
| 1378 | 1481 | ||
| 1379 | - | cb(fa) | |
| 1482 | + | cbFn(fa) | |
| 1380 | 1483 | ||
| 1381 | 1484 | } | |
| 1382 | - | return gobject.SignalConnect(x.GoPointer(), "redo", purego.NewCallback(fcb)) | |
| 1485 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1486 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1487 | + | return gobject.SignalConnect(x.GoPointer(), "redo", cbRefPtr) | |
| 1383 | 1488 | } | |
| 1384 | 1489 | ||
| 1385 | 1490 | // Emitted to remove all occurrences of @tag from a range | |
| @@ -1392,29 +1497,45 @@ func (x *TextBuffer) ConnectRedo(cb func(TextBuffer)) uint32 { | |||
| 1392 | 1497 | // to revalidate them). | |
| 1393 | 1498 | // | |
| 1394 | 1499 | // See also: [method@Gtk.TextBuffer.remove_tag]. | |
| 1395 | - | func (x *TextBuffer) ConnectRemoveTag(cb func(TextBuffer, uintptr, uintptr, uintptr)) uint32 { | |
| 1500 | + | func (x *TextBuffer) ConnectRemoveTag(cb *func(TextBuffer, uintptr, uintptr, uintptr)) uint32 { | |
| 1501 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1502 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1503 | + | return gobject.SignalConnect(x.GoPointer(), "remove-tag", cbRefPtr) | |
| 1504 | + | } | |
| 1505 | + | ||
| 1396 | 1506 | fcb := func(clsPtr uintptr, TagVarp uintptr, StartVarp uintptr, EndVarp uintptr) { | |
| 1397 | 1507 | fa := TextBuffer{} | |
| 1398 | 1508 | fa.Ptr = clsPtr | |
| 1509 | + | cbFn := *cb | |
| 1399 | 1510 | ||
| 1400 | - | cb(fa, TagVarp, StartVarp, EndVarp) | |
| 1511 | + | cbFn(fa, TagVarp, StartVarp, EndVarp) | |
| 1401 | 1512 | ||
| 1402 | 1513 | } | |
| 1403 | - | return gobject.SignalConnect(x.GoPointer(), "remove-tag", purego.NewCallback(fcb)) | |
| 1514 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1515 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1516 | + | return gobject.SignalConnect(x.GoPointer(), "remove-tag", cbRefPtr) | |
| 1404 | 1517 | } | |
| 1405 | 1518 | ||
| 1406 | 1519 | // Emitted when a request has been made to undo the | |
| 1407 | 1520 | // previous operation or set of operations that have | |
| 1408 | 1521 | // been grouped together. | |
| 1409 | - | func (x *TextBuffer) ConnectUndo(cb func(TextBuffer)) uint32 { | |
| 1522 | + | func (x *TextBuffer) ConnectUndo(cb *func(TextBuffer)) uint32 { | |
| 1523 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1524 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1525 | + | return gobject.SignalConnect(x.GoPointer(), "undo", cbRefPtr) | |
| 1526 | + | } | |
| 1527 | + | ||
| 1410 | 1528 | fcb := func(clsPtr uintptr) { | |
| 1411 | 1529 | fa := TextBuffer{} | |
| 1412 | 1530 | fa.Ptr = clsPtr | |
| 1531 | + | cbFn := *cb | |
| 1413 | 1532 | ||
| 1414 | - | cb(fa) | |
| 1533 | + | cbFn(fa) | |
| 1415 | 1534 | ||
| 1416 | 1535 | } | |
| 1417 | - | return gobject.SignalConnect(x.GoPointer(), "undo", purego.NewCallback(fcb)) | |
| 1536 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1537 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1538 | + | return gobject.SignalConnect(x.GoPointer(), "undo", cbRefPtr) | |
| 1418 | 1539 | } | |
| 1419 | 1540 | ||
| 1420 | 1541 | func init() { | |
M v4/gtk/gtktextiter.go +4 -4
| @@ -124,9 +124,9 @@ var xTextIterBackwardFindChar func(uintptr, uintptr, uintptr, *TextIter) bool | |||
| 124 | 124 | ||
| 125 | 125 | // Same as gtk_text_iter_forward_find_char(), | |
| 126 | 126 | // but goes backward from @iter. | |
| 127 | - | func (x *TextIter) BackwardFindChar(PredVar TextCharPredicate, UserDataVar uintptr, LimitVar *TextIter) bool { | |
| 127 | + | func (x *TextIter) BackwardFindChar(PredVar *TextCharPredicate, UserDataVar uintptr, LimitVar *TextIter) bool { | |
| 128 | 128 | ||
| 129 | - | cret := xTextIterBackwardFindChar(x.GoPointer(), purego.NewCallback(PredVar), UserDataVar, LimitVar) | |
| 129 | + | cret := xTextIterBackwardFindChar(x.GoPointer(), glib.NewCallback(PredVar), UserDataVar, LimitVar) | |
| 130 | 130 | return cret | |
| 131 | 131 | } | |
| 132 | 132 | ||
| @@ -539,9 +539,9 @@ var xTextIterForwardFindChar func(uintptr, uintptr, uintptr, *TextIter) bool | |||
| 539 | 539 | // If @pred returns %TRUE, returns %TRUE and stops scanning. | |
| 540 | 540 | // If @pred never returns %TRUE, @iter is set to @limit if | |
| 541 | 541 | // @limit is non-%NULL, otherwise to the end iterator. | |
| 542 | - | func (x *TextIter) ForwardFindChar(PredVar TextCharPredicate, UserDataVar uintptr, LimitVar *TextIter) bool { | |
| 542 | + | func (x *TextIter) ForwardFindChar(PredVar *TextCharPredicate, UserDataVar uintptr, LimitVar *TextIter) bool { | |
| 543 | 543 | ||
| 544 | - | cret := xTextIterForwardFindChar(x.GoPointer(), purego.NewCallback(PredVar), UserDataVar, LimitVar) | |
| 544 | + | cret := xTextIterForwardFindChar(x.GoPointer(), glib.NewCallback(PredVar), UserDataVar, LimitVar) | |
| 545 | 545 | return cret | |
| 546 | 546 | } | |
| 547 | 547 | ||
M v4/gtk/gtktexttagtable.go +38 -11
| @@ -2,8 +2,11 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 7 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 8 | 11 | ) | |
| 9 | 12 | ||
| @@ -82,9 +85,9 @@ var xTextTagTableForeach func(uintptr, uintptr, uintptr) | |||
| 82 | 85 | // | |
| 83 | 86 | // Note that the table may not be modified while iterating | |
| 84 | 87 | // over it (you can’t add/remove tags). | |
| 85 | - | func (x *TextTagTable) Foreach(FuncVar TextTagTableForeach, DataVar uintptr) { | |
| 88 | + | func (x *TextTagTable) Foreach(FuncVar *TextTagTableForeach, DataVar uintptr) { | |
| 86 | 89 | ||
| 87 | - | xTextTagTableForeach(x.GoPointer(), purego.NewCallback(FuncVar), DataVar) | |
| 90 | + | xTextTagTableForeach(x.GoPointer(), glib.NewCallback(FuncVar), DataVar) | |
| 88 | 91 | ||
| 89 | 92 | } | |
| 90 | 93 | ||
| @@ -137,42 +140,66 @@ func (c *TextTagTable) SetGoPointer(ptr uintptr) { | |||
| 137 | 140 | } | |
| 138 | 141 | ||
| 139 | 142 | // Emitted every time a new tag is added in the `GtkTextTagTable`. | |
| 140 | - | func (x *TextTagTable) ConnectTagAdded(cb func(TextTagTable, uintptr)) uint32 { | |
| 143 | + | func (x *TextTagTable) ConnectTagAdded(cb *func(TextTagTable, uintptr)) uint32 { | |
| 144 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 145 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 146 | + | return gobject.SignalConnect(x.GoPointer(), "tag-added", cbRefPtr) | |
| 147 | + | } | |
| 148 | + | ||
| 141 | 149 | fcb := func(clsPtr uintptr, TagVarp uintptr) { | |
| 142 | 150 | fa := TextTagTable{} | |
| 143 | 151 | fa.Ptr = clsPtr | |
| 152 | + | cbFn := *cb | |
| 144 | 153 | ||
| 145 | - | cb(fa, TagVarp) | |
| 154 | + | cbFn(fa, TagVarp) | |
| 146 | 155 | ||
| 147 | 156 | } | |
| 148 | - | return gobject.SignalConnect(x.GoPointer(), "tag-added", purego.NewCallback(fcb)) | |
| 157 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 158 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 159 | + | return gobject.SignalConnect(x.GoPointer(), "tag-added", cbRefPtr) | |
| 149 | 160 | } | |
| 150 | 161 | ||
| 151 | 162 | // Emitted every time a tag in the `GtkTextTagTable` changes. | |
| 152 | - | func (x *TextTagTable) ConnectTagChanged(cb func(TextTagTable, uintptr, bool)) uint32 { | |
| 163 | + | func (x *TextTagTable) ConnectTagChanged(cb *func(TextTagTable, uintptr, bool)) uint32 { | |
| 164 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 165 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 166 | + | return gobject.SignalConnect(x.GoPointer(), "tag-changed", cbRefPtr) | |
| 167 | + | } | |
| 168 | + | ||
| 153 | 169 | fcb := func(clsPtr uintptr, TagVarp uintptr, SizeChangedVarp bool) { | |
| 154 | 170 | fa := TextTagTable{} | |
| 155 | 171 | fa.Ptr = clsPtr | |
| 172 | + | cbFn := *cb | |
| 156 | 173 | ||
| 157 | - | cb(fa, TagVarp, SizeChangedVarp) | |
| 174 | + | cbFn(fa, TagVarp, SizeChangedVarp) | |
| 158 | 175 | ||
| 159 | 176 | } | |
| 160 | - | return gobject.SignalConnect(x.GoPointer(), "tag-changed", purego.NewCallback(fcb)) | |
| 177 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 178 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 179 | + | return gobject.SignalConnect(x.GoPointer(), "tag-changed", cbRefPtr) | |
| 161 | 180 | } | |
| 162 | 181 | ||
| 163 | 182 | // Emitted every time a tag is removed from the `GtkTextTagTable`. | |
| 164 | 183 | // | |
| 165 | 184 | // The @tag is still valid by the time the signal is emitted, but | |
| 166 | 185 | // it is not associated with a tag table any more. | |
| 167 | - | func (x *TextTagTable) ConnectTagRemoved(cb func(TextTagTable, uintptr)) uint32 { | |
| 186 | + | func (x *TextTagTable) ConnectTagRemoved(cb *func(TextTagTable, uintptr)) uint32 { | |
| 187 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 188 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 189 | + | return gobject.SignalConnect(x.GoPointer(), "tag-removed", cbRefPtr) | |
| 190 | + | } | |
| 191 | + | ||
| 168 | 192 | fcb := func(clsPtr uintptr, TagVarp uintptr) { | |
| 169 | 193 | fa := TextTagTable{} | |
| 170 | 194 | fa.Ptr = clsPtr | |
| 195 | + | cbFn := *cb | |
| 171 | 196 | ||
| 172 | - | cb(fa, TagVarp) | |
| 197 | + | cbFn(fa, TagVarp) | |
| 173 | 198 | ||
| 174 | 199 | } | |
| 175 | - | return gobject.SignalConnect(x.GoPointer(), "tag-removed", purego.NewCallback(fcb)) | |
| 200 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 201 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 202 | + | return gobject.SignalConnect(x.GoPointer(), "tag-removed", cbRefPtr) | |
| 176 | 203 | } | |
| 177 | 204 | ||
| 178 | 205 | // Gets the ID of the @buildable object. | |
M v4/gtk/gtktextview.go +166 -45
| @@ -8,6 +8,7 @@ import ( | |||
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | 9 | "github.com/jwijenbergh/puregotk/v4/gdk" | |
| 10 | 10 | "github.com/jwijenbergh/puregotk/v4/gio" | |
| 11 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 11 | 12 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 12 | 13 | "github.com/jwijenbergh/puregotk/v4/pango" | |
| 13 | 14 | ) | |
| @@ -1137,15 +1138,23 @@ func (c *TextView) SetGoPointer(ptr uintptr) { | |||
| 1137 | 1138 | // | |
| 1138 | 1139 | // The default bindings for this signal are | |
| 1139 | 1140 | // <kbd>Backspace</kbd> and <kbd>Shift</kbd>-<kbd>Backspace</kbd>. | |
| 1140 | - | func (x *TextView) ConnectBackspace(cb func(TextView)) uint32 { | |
| 1141 | + | func (x *TextView) ConnectBackspace(cb *func(TextView)) uint32 { | |
| 1142 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1143 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1144 | + | return gobject.SignalConnect(x.GoPointer(), "backspace", cbRefPtr) | |
| 1145 | + | } | |
| 1146 | + | ||
| 1141 | 1147 | fcb := func(clsPtr uintptr) { | |
| 1142 | 1148 | fa := TextView{} | |
| 1143 | 1149 | fa.Ptr = clsPtr | |
| 1150 | + | cbFn := *cb | |
| 1144 | 1151 | ||
| 1145 | - | cb(fa) | |
| 1152 | + | cbFn(fa) | |
| 1146 | 1153 | ||
| 1147 | 1154 | } | |
| 1148 | - | return gobject.SignalConnect(x.GoPointer(), "backspace", purego.NewCallback(fcb)) | |
| 1155 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1156 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1157 | + | return gobject.SignalConnect(x.GoPointer(), "backspace", cbRefPtr) | |
| 1149 | 1158 | } | |
| 1150 | 1159 | ||
| 1151 | 1160 | // Gets emitted to copy the selection to the clipboard. | |
| @@ -1155,15 +1164,23 @@ func (x *TextView) ConnectBackspace(cb func(TextView)) uint32 { | |||
| 1155 | 1164 | // The default bindings for this signal are | |
| 1156 | 1165 | // <kbd>Ctrl</kbd>-<kbd>c</kbd> and | |
| 1157 | 1166 | // <kbd>Ctrl</kbd>-<kbd>Insert</kbd>. | |
| 1158 | - | func (x *TextView) ConnectCopyClipboard(cb func(TextView)) uint32 { | |
| 1167 | + | func (x *TextView) ConnectCopyClipboard(cb *func(TextView)) uint32 { | |
| 1168 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1169 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1170 | + | return gobject.SignalConnect(x.GoPointer(), "copy-clipboard", cbRefPtr) | |
| 1171 | + | } | |
| 1172 | + | ||
| 1159 | 1173 | fcb := func(clsPtr uintptr) { | |
| 1160 | 1174 | fa := TextView{} | |
| 1161 | 1175 | fa.Ptr = clsPtr | |
| 1176 | + | cbFn := *cb | |
| 1162 | 1177 | ||
| 1163 | - | cb(fa) | |
| 1178 | + | cbFn(fa) | |
| 1164 | 1179 | ||
| 1165 | 1180 | } | |
| 1166 | - | return gobject.SignalConnect(x.GoPointer(), "copy-clipboard", purego.NewCallback(fcb)) | |
| 1181 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1182 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1183 | + | return gobject.SignalConnect(x.GoPointer(), "copy-clipboard", cbRefPtr) | |
| 1167 | 1184 | } | |
| 1168 | 1185 | ||
| 1169 | 1186 | // Gets emitted to cut the selection to the clipboard. | |
| @@ -1173,15 +1190,23 @@ func (x *TextView) ConnectCopyClipboard(cb func(TextView)) uint32 { | |||
| 1173 | 1190 | // The default bindings for this signal are | |
| 1174 | 1191 | // <kbd>Ctrl</kbd>-<kbd>x</kbd> and | |
| 1175 | 1192 | // <kbd>Shift</kbd>-<kbd>Delete</kbd>. | |
| 1176 | - | func (x *TextView) ConnectCutClipboard(cb func(TextView)) uint32 { | |
| 1193 | + | func (x *TextView) ConnectCutClipboard(cb *func(TextView)) uint32 { | |
| 1194 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1195 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1196 | + | return gobject.SignalConnect(x.GoPointer(), "cut-clipboard", cbRefPtr) | |
| 1197 | + | } | |
| 1198 | + | ||
| 1177 | 1199 | fcb := func(clsPtr uintptr) { | |
| 1178 | 1200 | fa := TextView{} | |
| 1179 | 1201 | fa.Ptr = clsPtr | |
| 1202 | + | cbFn := *cb | |
| 1180 | 1203 | ||
| 1181 | - | cb(fa) | |
| 1204 | + | cbFn(fa) | |
| 1182 | 1205 | ||
| 1183 | 1206 | } | |
| 1184 | - | return gobject.SignalConnect(x.GoPointer(), "cut-clipboard", purego.NewCallback(fcb)) | |
| 1207 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1208 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1209 | + | return gobject.SignalConnect(x.GoPointer(), "cut-clipboard", cbRefPtr) | |
| 1185 | 1210 | } | |
| 1186 | 1211 | ||
| 1187 | 1212 | // Gets emitted when the user initiates a text deletion. | |
| @@ -1196,27 +1221,43 @@ func (x *TextView) ConnectCutClipboard(cb func(TextView)) uint32 { | |||
| 1196 | 1221 | // deleting a character, <kbd>Ctrl</kbd>-<kbd>Delete</kbd> for | |
| 1197 | 1222 | // deleting a word and <kbd>Ctrl</kbd>-<kbd>Backspace</kbd> for | |
| 1198 | 1223 | // deleting a word backwards. | |
| 1199 | - | func (x *TextView) ConnectDeleteFromCursor(cb func(TextView, DeleteType, int)) uint32 { | |
| 1224 | + | func (x *TextView) ConnectDeleteFromCursor(cb *func(TextView, DeleteType, int)) uint32 { | |
| 1225 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1226 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1227 | + | return gobject.SignalConnect(x.GoPointer(), "delete-from-cursor", cbRefPtr) | |
| 1228 | + | } | |
| 1229 | + | ||
| 1200 | 1230 | fcb := func(clsPtr uintptr, TypeVarp DeleteType, CountVarp int) { | |
| 1201 | 1231 | fa := TextView{} | |
| 1202 | 1232 | fa.Ptr = clsPtr | |
| 1233 | + | cbFn := *cb | |
| 1203 | 1234 | ||
| 1204 | - | cb(fa, TypeVarp, CountVarp) | |
| 1235 | + | cbFn(fa, TypeVarp, CountVarp) | |
| 1205 | 1236 | ||
| 1206 | 1237 | } | |
| 1207 | - | return gobject.SignalConnect(x.GoPointer(), "delete-from-cursor", purego.NewCallback(fcb)) | |
| 1238 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1239 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1240 | + | return gobject.SignalConnect(x.GoPointer(), "delete-from-cursor", cbRefPtr) | |
| 1208 | 1241 | } | |
| 1209 | 1242 | ||
| 1210 | 1243 | // Emitted when the selection needs to be extended at @location. | |
| 1211 | - | func (x *TextView) ConnectExtendSelection(cb func(TextView, TextExtendSelection, uintptr, uintptr, uintptr) bool) uint32 { | |
| 1244 | + | func (x *TextView) ConnectExtendSelection(cb *func(TextView, TextExtendSelection, uintptr, uintptr, uintptr) bool) uint32 { | |
| 1245 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1246 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1247 | + | return gobject.SignalConnect(x.GoPointer(), "extend-selection", cbRefPtr) | |
| 1248 | + | } | |
| 1249 | + | ||
| 1212 | 1250 | fcb := func(clsPtr uintptr, GranularityVarp TextExtendSelection, LocationVarp uintptr, StartVarp uintptr, EndVarp uintptr) bool { | |
| 1213 | 1251 | fa := TextView{} | |
| 1214 | 1252 | fa.Ptr = clsPtr | |
| 1253 | + | cbFn := *cb | |
| 1215 | 1254 | ||
| 1216 | - | return cb(fa, GranularityVarp, LocationVarp, StartVarp, EndVarp) | |
| 1255 | + | return cbFn(fa, GranularityVarp, LocationVarp, StartVarp, EndVarp) | |
| 1217 | 1256 | ||
| 1218 | 1257 | } | |
| 1219 | - | return gobject.SignalConnect(x.GoPointer(), "extend-selection", purego.NewCallback(fcb)) | |
| 1258 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1259 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1260 | + | return gobject.SignalConnect(x.GoPointer(), "extend-selection", cbRefPtr) | |
| 1220 | 1261 | } | |
| 1221 | 1262 | ||
| 1222 | 1263 | // Gets emitted when the user initiates the insertion of a | |
| @@ -1225,15 +1266,23 @@ func (x *TextView) ConnectExtendSelection(cb func(TextView, TextExtendSelection, | |||
| 1225 | 1266 | // The ::insert-at-cursor signal is a [keybinding signal](class.SignalAction.html). | |
| 1226 | 1267 | // | |
| 1227 | 1268 | // This signal has no default bindings. | |
| 1228 | - | func (x *TextView) ConnectInsertAtCursor(cb func(TextView, string)) uint32 { | |
| 1269 | + | func (x *TextView) ConnectInsertAtCursor(cb *func(TextView, string)) uint32 { | |
| 1270 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1271 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1272 | + | return gobject.SignalConnect(x.GoPointer(), "insert-at-cursor", cbRefPtr) | |
| 1273 | + | } | |
| 1274 | + | ||
| 1229 | 1275 | fcb := func(clsPtr uintptr, StringVarp string) { | |
| 1230 | 1276 | fa := TextView{} | |
| 1231 | 1277 | fa.Ptr = clsPtr | |
| 1278 | + | cbFn := *cb | |
| 1232 | 1279 | ||
| 1233 | - | cb(fa, StringVarp) | |
| 1280 | + | cbFn(fa, StringVarp) | |
| 1234 | 1281 | ||
| 1235 | 1282 | } | |
| 1236 | - | return gobject.SignalConnect(x.GoPointer(), "insert-at-cursor", purego.NewCallback(fcb)) | |
| 1283 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1284 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1285 | + | return gobject.SignalConnect(x.GoPointer(), "insert-at-cursor", cbRefPtr) | |
| 1237 | 1286 | } | |
| 1238 | 1287 | ||
| 1239 | 1288 | // Gets emitted to present the Emoji chooser for the @text_view. | |
| @@ -1243,15 +1292,23 @@ func (x *TextView) ConnectInsertAtCursor(cb func(TextView, string)) uint32 { | |||
| 1243 | 1292 | // The default bindings for this signal are | |
| 1244 | 1293 | // <kbd>Ctrl</kbd>-<kbd>.</kbd> and | |
| 1245 | 1294 | // <kbd>Ctrl</kbd>-<kbd>;</kbd> | |
| 1246 | - | func (x *TextView) ConnectInsertEmoji(cb func(TextView)) uint32 { | |
| 1295 | + | func (x *TextView) ConnectInsertEmoji(cb *func(TextView)) uint32 { | |
| 1296 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1297 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1298 | + | return gobject.SignalConnect(x.GoPointer(), "insert-emoji", cbRefPtr) | |
| 1299 | + | } | |
| 1300 | + | ||
| 1247 | 1301 | fcb := func(clsPtr uintptr) { | |
| 1248 | 1302 | fa := TextView{} | |
| 1249 | 1303 | fa.Ptr = clsPtr | |
| 1304 | + | cbFn := *cb | |
| 1250 | 1305 | ||
| 1251 | - | cb(fa) | |
| 1306 | + | cbFn(fa) | |
| 1252 | 1307 | ||
| 1253 | 1308 | } | |
| 1254 | - | return gobject.SignalConnect(x.GoPointer(), "insert-emoji", purego.NewCallback(fcb)) | |
| 1309 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1310 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1311 | + | return gobject.SignalConnect(x.GoPointer(), "insert-emoji", cbRefPtr) | |
| 1255 | 1312 | } | |
| 1256 | 1313 | ||
| 1257 | 1314 | // Gets emitted when the user initiates a cursor movement. | |
| @@ -1276,15 +1333,23 @@ func (x *TextView) ConnectInsertEmoji(cb func(TextView)) uint32 { | |||
| 1276 | 1333 | // - <kbd>PgUp</kbd>, <kbd>PgDn</kbd> move vertically by pages | |
| 1277 | 1334 | // - <kbd>Ctrl</kbd>-<kbd>PgUp</kbd>, <kbd>Ctrl</kbd>-<kbd>PgDn</kbd> | |
| 1278 | 1335 | // move horizontally by pages | |
| 1279 | - | func (x *TextView) ConnectMoveCursor(cb func(TextView, MovementStep, int, bool)) uint32 { | |
| 1336 | + | func (x *TextView) ConnectMoveCursor(cb *func(TextView, MovementStep, int, bool)) uint32 { | |
| 1337 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1338 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1339 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 1340 | + | } | |
| 1341 | + | ||
| 1280 | 1342 | fcb := func(clsPtr uintptr, StepVarp MovementStep, CountVarp int, ExtendSelectionVarp bool) { | |
| 1281 | 1343 | fa := TextView{} | |
| 1282 | 1344 | fa.Ptr = clsPtr | |
| 1345 | + | cbFn := *cb | |
| 1283 | 1346 | ||
| 1284 | - | cb(fa, StepVarp, CountVarp, ExtendSelectionVarp) | |
| 1347 | + | cbFn(fa, StepVarp, CountVarp, ExtendSelectionVarp) | |
| 1285 | 1348 | ||
| 1286 | 1349 | } | |
| 1287 | - | return gobject.SignalConnect(x.GoPointer(), "move-cursor", purego.NewCallback(fcb)) | |
| 1350 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1351 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1352 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 1288 | 1353 | } | |
| 1289 | 1354 | ||
| 1290 | 1355 | // Gets emitted to move the viewport. | |
| @@ -1295,15 +1360,23 @@ func (x *TextView) ConnectMoveCursor(cb func(TextView, MovementStep, int, bool)) | |||
| 1295 | 1360 | // window. | |
| 1296 | 1361 | // | |
| 1297 | 1362 | // There are no default bindings for this signal. | |
| 1298 | - | func (x *TextView) ConnectMoveViewport(cb func(TextView, ScrollStep, int)) uint32 { | |
| 1363 | + | func (x *TextView) ConnectMoveViewport(cb *func(TextView, ScrollStep, int)) uint32 { | |
| 1364 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1365 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1366 | + | return gobject.SignalConnect(x.GoPointer(), "move-viewport", cbRefPtr) | |
| 1367 | + | } | |
| 1368 | + | ||
| 1299 | 1369 | fcb := func(clsPtr uintptr, StepVarp ScrollStep, CountVarp int) { | |
| 1300 | 1370 | fa := TextView{} | |
| 1301 | 1371 | fa.Ptr = clsPtr | |
| 1372 | + | cbFn := *cb | |
| 1302 | 1373 | ||
| 1303 | - | cb(fa, StepVarp, CountVarp) | |
| 1374 | + | cbFn(fa, StepVarp, CountVarp) | |
| 1304 | 1375 | ||
| 1305 | 1376 | } | |
| 1306 | - | return gobject.SignalConnect(x.GoPointer(), "move-viewport", purego.NewCallback(fcb)) | |
| 1377 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1378 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1379 | + | return gobject.SignalConnect(x.GoPointer(), "move-viewport", cbRefPtr) | |
| 1307 | 1380 | } | |
| 1308 | 1381 | ||
| 1309 | 1382 | // Gets emitted to paste the contents of the clipboard | |
| @@ -1314,15 +1387,23 @@ func (x *TextView) ConnectMoveViewport(cb func(TextView, ScrollStep, int)) uint3 | |||
| 1314 | 1387 | // The default bindings for this signal are | |
| 1315 | 1388 | // <kbd>Ctrl</kbd>-<kbd>v</kbd> and | |
| 1316 | 1389 | // <kbd>Shift</kbd>-<kbd>Insert</kbd>. | |
| 1317 | - | func (x *TextView) ConnectPasteClipboard(cb func(TextView)) uint32 { | |
| 1390 | + | func (x *TextView) ConnectPasteClipboard(cb *func(TextView)) uint32 { | |
| 1391 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1392 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1393 | + | return gobject.SignalConnect(x.GoPointer(), "paste-clipboard", cbRefPtr) | |
| 1394 | + | } | |
| 1395 | + | ||
| 1318 | 1396 | fcb := func(clsPtr uintptr) { | |
| 1319 | 1397 | fa := TextView{} | |
| 1320 | 1398 | fa.Ptr = clsPtr | |
| 1399 | + | cbFn := *cb | |
| 1321 | 1400 | ||
| 1322 | - | cb(fa) | |
| 1401 | + | cbFn(fa) | |
| 1323 | 1402 | ||
| 1324 | 1403 | } | |
| 1325 | - | return gobject.SignalConnect(x.GoPointer(), "paste-clipboard", purego.NewCallback(fcb)) | |
| 1404 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1405 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1406 | + | return gobject.SignalConnect(x.GoPointer(), "paste-clipboard", cbRefPtr) | |
| 1326 | 1407 | } | |
| 1327 | 1408 | ||
| 1328 | 1409 | // Emitted when preedit text of the active IM changes. | |
| @@ -1333,15 +1414,23 @@ func (x *TextView) ConnectPasteClipboard(cb func(TextView)) uint32 { | |||
| 1333 | 1414 | // | |
| 1334 | 1415 | // This signal is only emitted if the text at the given position | |
| 1335 | 1416 | // is actually editable. | |
| 1336 | - | func (x *TextView) ConnectPreeditChanged(cb func(TextView, string)) uint32 { | |
| 1417 | + | func (x *TextView) ConnectPreeditChanged(cb *func(TextView, string)) uint32 { | |
| 1418 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1419 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1420 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-changed", cbRefPtr) | |
| 1421 | + | } | |
| 1422 | + | ||
| 1337 | 1423 | fcb := func(clsPtr uintptr, PreeditVarp string) { | |
| 1338 | 1424 | fa := TextView{} | |
| 1339 | 1425 | fa.Ptr = clsPtr | |
| 1426 | + | cbFn := *cb | |
| 1340 | 1427 | ||
| 1341 | - | cb(fa, PreeditVarp) | |
| 1428 | + | cbFn(fa, PreeditVarp) | |
| 1342 | 1429 | ||
| 1343 | 1430 | } | |
| 1344 | - | return gobject.SignalConnect(x.GoPointer(), "preedit-changed", purego.NewCallback(fcb)) | |
| 1431 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1432 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1433 | + | return gobject.SignalConnect(x.GoPointer(), "preedit-changed", cbRefPtr) | |
| 1345 | 1434 | } | |
| 1346 | 1435 | ||
| 1347 | 1436 | // Gets emitted to select or unselect the complete contents of the text view. | |
| @@ -1353,15 +1442,23 @@ func (x *TextView) ConnectPreeditChanged(cb func(TextView, string)) uint32 { | |||
| 1353 | 1442 | // <kbd>Ctrl</kbd>-<kbd>/</kbd> for selecting and | |
| 1354 | 1443 | // <kbd>Shift</kbd>-<kbd>Ctrl</kbd>-<kbd>a</kbd> and | |
| 1355 | 1444 | // <kbd>Ctrl</kbd>-<kbd>\</kbd> for unselecting. | |
| 1356 | - | func (x *TextView) ConnectSelectAll(cb func(TextView, bool)) uint32 { | |
| 1445 | + | func (x *TextView) ConnectSelectAll(cb *func(TextView, bool)) uint32 { | |
| 1446 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1447 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1448 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 1449 | + | } | |
| 1450 | + | ||
| 1357 | 1451 | fcb := func(clsPtr uintptr, SelectVarp bool) { | |
| 1358 | 1452 | fa := TextView{} | |
| 1359 | 1453 | fa.Ptr = clsPtr | |
| 1454 | + | cbFn := *cb | |
| 1360 | 1455 | ||
| 1361 | - | cb(fa, SelectVarp) | |
| 1456 | + | cbFn(fa, SelectVarp) | |
| 1362 | 1457 | ||
| 1363 | 1458 | } | |
| 1364 | - | return gobject.SignalConnect(x.GoPointer(), "select-all", purego.NewCallback(fcb)) | |
| 1459 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1460 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1461 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 1365 | 1462 | } | |
| 1366 | 1463 | ||
| 1367 | 1464 | // Gets emitted when the user initiates settings the "anchor" mark. | |
| @@ -1372,15 +1469,23 @@ func (x *TextView) ConnectSelectAll(cb func(TextView, bool)) uint32 { | |||
| 1372 | 1469 | // "insert" mark. | |
| 1373 | 1470 | // | |
| 1374 | 1471 | // This signal has no default bindings. | |
| 1375 | - | func (x *TextView) ConnectSetAnchor(cb func(TextView)) uint32 { | |
| 1472 | + | func (x *TextView) ConnectSetAnchor(cb *func(TextView)) uint32 { | |
| 1473 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1474 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1475 | + | return gobject.SignalConnect(x.GoPointer(), "set-anchor", cbRefPtr) | |
| 1476 | + | } | |
| 1477 | + | ||
| 1376 | 1478 | fcb := func(clsPtr uintptr) { | |
| 1377 | 1479 | fa := TextView{} | |
| 1378 | 1480 | fa.Ptr = clsPtr | |
| 1481 | + | cbFn := *cb | |
| 1379 | 1482 | ||
| 1380 | - | cb(fa) | |
| 1483 | + | cbFn(fa) | |
| 1381 | 1484 | ||
| 1382 | 1485 | } | |
| 1383 | - | return gobject.SignalConnect(x.GoPointer(), "set-anchor", purego.NewCallback(fcb)) | |
| 1486 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1487 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1488 | + | return gobject.SignalConnect(x.GoPointer(), "set-anchor", cbRefPtr) | |
| 1384 | 1489 | } | |
| 1385 | 1490 | ||
| 1386 | 1491 | // Gets emitted to toggle the `cursor-visible` property. | |
| @@ -1389,15 +1494,23 @@ func (x *TextView) ConnectSetAnchor(cb func(TextView)) uint32 { | |||
| 1389 | 1494 | // [keybinding signal](class.SignalAction.html). | |
| 1390 | 1495 | // | |
| 1391 | 1496 | // The default binding for this signal is <kbd>F7</kbd>. | |
| 1392 | - | func (x *TextView) ConnectToggleCursorVisible(cb func(TextView)) uint32 { | |
| 1497 | + | func (x *TextView) ConnectToggleCursorVisible(cb *func(TextView)) uint32 { | |
| 1498 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1499 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1500 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-visible", cbRefPtr) | |
| 1501 | + | } | |
| 1502 | + | ||
| 1393 | 1503 | fcb := func(clsPtr uintptr) { | |
| 1394 | 1504 | fa := TextView{} | |
| 1395 | 1505 | fa.Ptr = clsPtr | |
| 1506 | + | cbFn := *cb | |
| 1396 | 1507 | ||
| 1397 | - | cb(fa) | |
| 1508 | + | cbFn(fa) | |
| 1398 | 1509 | ||
| 1399 | 1510 | } | |
| 1400 | - | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-visible", purego.NewCallback(fcb)) | |
| 1511 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1512 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1513 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-visible", cbRefPtr) | |
| 1401 | 1514 | } | |
| 1402 | 1515 | ||
| 1403 | 1516 | // Gets emitted to toggle the overwrite mode of the text view. | |
| @@ -1405,15 +1518,23 @@ func (x *TextView) ConnectToggleCursorVisible(cb func(TextView)) uint32 { | |||
| 1405 | 1518 | // The ::toggle-overwrite signal is a [keybinding signal](class.SignalAction.html). | |
| 1406 | 1519 | // | |
| 1407 | 1520 | // The default binding for this signal is <kbd>Insert</kbd>. | |
| 1408 | - | func (x *TextView) ConnectToggleOverwrite(cb func(TextView)) uint32 { | |
| 1521 | + | func (x *TextView) ConnectToggleOverwrite(cb *func(TextView)) uint32 { | |
| 1522 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1523 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1524 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-overwrite", cbRefPtr) | |
| 1525 | + | } | |
| 1526 | + | ||
| 1409 | 1527 | fcb := func(clsPtr uintptr) { | |
| 1410 | 1528 | fa := TextView{} | |
| 1411 | 1529 | fa.Ptr = clsPtr | |
| 1530 | + | cbFn := *cb | |
| 1412 | 1531 | ||
| 1413 | - | cb(fa) | |
| 1532 | + | cbFn(fa) | |
| 1414 | 1533 | ||
| 1415 | 1534 | } | |
| 1416 | - | return gobject.SignalConnect(x.GoPointer(), "toggle-overwrite", purego.NewCallback(fcb)) | |
| 1535 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1536 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1537 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-overwrite", cbRefPtr) | |
| 1417 | 1538 | } | |
| 1418 | 1539 | ||
| 1419 | 1540 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtktogglebutton.go +11 -3
| @@ -227,15 +227,23 @@ func (c *ToggleButton) SetGoPointer(ptr uintptr) { | |||
| 227 | 227 | } | |
| 228 | 228 | ||
| 229 | 229 | // Emitted whenever the `GtkToggleButton`'s state is changed. | |
| 230 | - | func (x *ToggleButton) ConnectToggled(cb func(ToggleButton)) uint32 { | |
| 230 | + | func (x *ToggleButton) ConnectToggled(cb *func(ToggleButton)) uint32 { | |
| 231 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 232 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 233 | + | return gobject.SignalConnect(x.GoPointer(), "toggled", cbRefPtr) | |
| 234 | + | } | |
| 235 | + | ||
| 231 | 236 | fcb := func(clsPtr uintptr) { | |
| 232 | 237 | fa := ToggleButton{} | |
| 233 | 238 | fa.Ptr = clsPtr | |
| 239 | + | cbFn := *cb | |
| 234 | 240 | ||
| 235 | - | cb(fa) | |
| 241 | + | cbFn(fa) | |
| 236 | 242 | ||
| 237 | 243 | } | |
| 238 | - | return gobject.SignalConnect(x.GoPointer(), "toggled", purego.NewCallback(fcb)) | |
| 244 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 245 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 246 | + | return gobject.SignalConnect(x.GoPointer(), "toggled", cbRefPtr) | |
| 239 | 247 | } | |
| 240 | 248 | ||
| 241 | 249 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtktreelistmodel.go +2 -2
| @@ -51,10 +51,10 @@ var xNewTreeListModel func(uintptr, bool, bool, uintptr, uintptr, uintptr) uintp | |||
| 51 | 51 | ||
| 52 | 52 | // Creates a new empty `GtkTreeListModel` displaying @root | |
| 53 | 53 | // with all rows collapsed. | |
| 54 | - | func NewTreeListModel(RootVar gio.ListModel, PassthroughVar bool, AutoexpandVar bool, CreateFuncVar TreeListModelCreateModelFunc, UserDataVar uintptr, UserDestroyVar glib.DestroyNotify) *TreeListModel { | |
| 54 | + | func NewTreeListModel(RootVar gio.ListModel, PassthroughVar bool, AutoexpandVar bool, CreateFuncVar *TreeListModelCreateModelFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) *TreeListModel { | |
| 55 | 55 | var cls *TreeListModel | |
| 56 | 56 | ||
| 57 | - | cret := xNewTreeListModel(RootVar.GoPointer(), PassthroughVar, AutoexpandVar, purego.NewCallback(CreateFuncVar), UserDataVar, purego.NewCallback(UserDestroyVar)) | |
| 57 | + | cret := xNewTreeListModel(RootVar.GoPointer(), PassthroughVar, AutoexpandVar, glib.NewCallback(CreateFuncVar), UserDataVar, glib.NewCallback(UserDestroyVar)) | |
| 58 | 58 | ||
| 59 | 59 | if cret == 0 { | |
| 60 | 60 | return nil | |
M v4/gtk/gtktreemodel.go +4 -3
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -609,7 +610,7 @@ type TreeModel interface { | |||
| 609 | 610 | GoPointer() uintptr | |
| 610 | 611 | SetGoPointer(uintptr) | |
| 611 | 612 | FilterNew(RootVar *TreePath) *TreeModelBase | |
| 612 | - | Foreach(FuncVar TreeModelForeachFunc, UserDataVar uintptr) | |
| 613 | + | Foreach(FuncVar *TreeModelForeachFunc, UserDataVar uintptr) | |
| 613 | 614 | Get(IterVar *TreeIter, varArgs ...interface{}) | |
| 614 | 615 | GetColumnType(IndexVar int) []interface{} | |
| 615 | 616 | GetFlags() TreeModelFlags | |
| @@ -668,9 +669,9 @@ func (x *TreeModelBase) FilterNew(RootVar *TreePath) *TreeModelBase { | |||
| 668 | 669 | // | |
| 669 | 670 | // If @func returns %TRUE, then the tree ceases to be walked, | |
| 670 | 671 | // and gtk_tree_model_foreach() returns. | |
| 671 | - | func (x *TreeModelBase) Foreach(FuncVar TreeModelForeachFunc, UserDataVar uintptr) { | |
| 672 | + | func (x *TreeModelBase) Foreach(FuncVar *TreeModelForeachFunc, UserDataVar uintptr) { | |
| 672 | 673 | ||
| 673 | - | XGtkTreeModelForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 674 | + | XGtkTreeModelForeach(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar) | |
| 674 | 675 | ||
| 675 | 676 | } | |
| 676 | 677 | ||
M v4/gtk/gtktreemodelfilter.go +6 -6
| @@ -214,9 +214,9 @@ var xTreeModelFilterSetModifyFunc func(uintptr, int, uintptr, uintptr, uintptr, | |||
| 214 | 214 | // | |
| 215 | 215 | // Note that gtk_tree_model_filter_set_modify_func() | |
| 216 | 216 | // can only be called once for a given filter model. | |
| 217 | - | func (x *TreeModelFilter) SetModifyFunc(NColumnsVar int, TypesVar uintptr, FuncVar TreeModelFilterModifyFunc, DataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 217 | + | func (x *TreeModelFilter) SetModifyFunc(NColumnsVar int, TypesVar uintptr, FuncVar *TreeModelFilterModifyFunc, DataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 218 | 218 | ||
| 219 | - | xTreeModelFilterSetModifyFunc(x.GoPointer(), NColumnsVar, TypesVar, purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyVar)) | |
| 219 | + | xTreeModelFilterSetModifyFunc(x.GoPointer(), NColumnsVar, TypesVar, glib.NewCallback(FuncVar), DataVar, glib.NewCallback(DestroyVar)) | |
| 220 | 220 | ||
| 221 | 221 | } | |
| 222 | 222 | ||
| @@ -276,9 +276,9 @@ var xTreeModelFilterSetVisibleFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 276 | 276 | // Note that gtk_tree_model_filter_set_visible_func() or | |
| 277 | 277 | // gtk_tree_model_filter_set_visible_column() can only be called | |
| 278 | 278 | // once for a given filter model. | |
| 279 | - | func (x *TreeModelFilter) SetVisibleFunc(FuncVar TreeModelFilterVisibleFunc, DataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 279 | + | func (x *TreeModelFilter) SetVisibleFunc(FuncVar *TreeModelFilterVisibleFunc, DataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 280 | 280 | ||
| 281 | - | xTreeModelFilterSetVisibleFunc(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyVar)) | |
| 281 | + | xTreeModelFilterSetVisibleFunc(x.GoPointer(), glib.NewCallback(FuncVar), DataVar, glib.NewCallback(DestroyVar)) | |
| 282 | 282 | ||
| 283 | 283 | } | |
| 284 | 284 | ||
| @@ -345,9 +345,9 @@ func (x *TreeModelFilter) FilterNew(RootVar *TreePath) *TreeModelBase { | |||
| 345 | 345 | // | |
| 346 | 346 | // If @func returns %TRUE, then the tree ceases to be walked, | |
| 347 | 347 | // and gtk_tree_model_foreach() returns. | |
| 348 | - | func (x *TreeModelFilter) Foreach(FuncVar TreeModelForeachFunc, UserDataVar uintptr) { | |
| 348 | + | func (x *TreeModelFilter) Foreach(FuncVar *TreeModelForeachFunc, UserDataVar uintptr) { | |
| 349 | 349 | ||
| 350 | - | XGtkTreeModelForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 350 | + | XGtkTreeModelForeach(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar) | |
| 351 | 351 | ||
| 352 | 352 | } | |
| 353 | 353 | ||
M v4/gtk/gtktreemodelsort.go +6 -6
| @@ -317,9 +317,9 @@ func (x *TreeModelSort) FilterNew(RootVar *TreePath) *TreeModelBase { | |||
| 317 | 317 | // | |
| 318 | 318 | // If @func returns %TRUE, then the tree ceases to be walked, | |
| 319 | 319 | // and gtk_tree_model_foreach() returns. | |
| 320 | - | func (x *TreeModelSort) Foreach(FuncVar TreeModelForeachFunc, UserDataVar uintptr) { | |
| 320 | + | func (x *TreeModelSort) Foreach(FuncVar *TreeModelForeachFunc, UserDataVar uintptr) { | |
| 321 | 321 | ||
| 322 | - | XGtkTreeModelForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 322 | + | XGtkTreeModelForeach(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar) | |
| 323 | 323 | ||
| 324 | 324 | } | |
| 325 | 325 | ||
| @@ -651,9 +651,9 @@ func (x *TreeModelSort) HasDefaultSortFunc() bool { | |||
| 651 | 651 | // This means that once the model has been sorted, it can’t go back to the | |
| 652 | 652 | // default state. In this case, when the current sort column id of @sortable | |
| 653 | 653 | // is %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted. | |
| 654 | - | func (x *TreeModelSort) SetDefaultSortFunc(SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 654 | + | func (x *TreeModelSort) SetDefaultSortFunc(SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 655 | 655 | ||
| 656 | - | XGtkTreeSortableSetDefaultSortFunc(x.GoPointer(), purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 656 | + | XGtkTreeSortableSetDefaultSortFunc(x.GoPointer(), glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 657 | 657 | ||
| 658 | 658 | } | |
| 659 | 659 | ||
| @@ -675,9 +675,9 @@ func (x *TreeModelSort) SetSortColumnId(SortColumnIdVar int, OrderVar SortType) | |||
| 675 | 675 | // Sets the comparison function used when sorting to be @sort_func. If the | |
| 676 | 676 | // current sort column id of @sortable is the same as @sort_column_id, then | |
| 677 | 677 | // the model will sort using this function. | |
| 678 | - | func (x *TreeModelSort) SetSortFunc(SortColumnIdVar int, SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 678 | + | func (x *TreeModelSort) SetSortFunc(SortColumnIdVar int, SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 679 | 679 | ||
| 680 | - | XGtkTreeSortableSetSortFunc(x.GoPointer(), SortColumnIdVar, purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 680 | + | XGtkTreeSortableSetSortFunc(x.GoPointer(), SortColumnIdVar, glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 681 | 681 | ||
| 682 | 682 | } | |
| 683 | 683 | ||
M v4/gtk/gtktreeselection.go +17 -7
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -201,9 +203,9 @@ var xTreeSelectionSelectedForeach func(uintptr, uintptr, uintptr) | |||
| 201 | 203 | // Calls a function for each selected node. Note that you cannot modify | |
| 202 | 204 | // the tree or selection from within this function. As a result, | |
| 203 | 205 | // gtk_tree_selection_get_selected_rows() might be more useful. | |
| 204 | - | func (x *TreeSelection) SelectedForeach(FuncVar TreeSelectionForeachFunc, DataVar uintptr) { | |
| 206 | + | func (x *TreeSelection) SelectedForeach(FuncVar *TreeSelectionForeachFunc, DataVar uintptr) { | |
| 205 | 207 | ||
| 206 | - | xTreeSelectionSelectedForeach(x.GoPointer(), purego.NewCallback(FuncVar), DataVar) | |
| 208 | + | xTreeSelectionSelectedForeach(x.GoPointer(), glib.NewCallback(FuncVar), DataVar) | |
| 207 | 209 | ||
| 208 | 210 | } | |
| 209 | 211 | ||
| @@ -226,9 +228,9 @@ var xTreeSelectionSetSelectFunction func(uintptr, uintptr, uintptr, uintptr) | |||
| 226 | 228 | // giving some control over which nodes are selected. The select function | |
| 227 | 229 | // should return %TRUE if the state of the node may be toggled, and %FALSE | |
| 228 | 230 | // if the state of the node should be left unchanged. | |
| 229 | - | func (x *TreeSelection) SetSelectFunction(FuncVar TreeSelectionFunc, DataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 231 | + | func (x *TreeSelection) SetSelectFunction(FuncVar *TreeSelectionFunc, DataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 230 | 232 | ||
| 231 | - | xTreeSelectionSetSelectFunction(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyVar)) | |
| 233 | + | xTreeSelectionSetSelectFunction(x.GoPointer(), glib.NewCallback(FuncVar), DataVar, glib.NewCallback(DestroyVar)) | |
| 232 | 234 | ||
| 233 | 235 | } | |
| 234 | 236 | ||
| @@ -281,15 +283,23 @@ func (c *TreeSelection) SetGoPointer(ptr uintptr) { | |||
| 281 | 283 | // this signal is mostly a hint. It may only be emitted once when a range | |
| 282 | 284 | // of rows are selected, and it may occasionally be emitted when nothing | |
| 283 | 285 | // has happened. | |
| 284 | - | func (x *TreeSelection) ConnectChanged(cb func(TreeSelection)) uint32 { | |
| 286 | + | func (x *TreeSelection) ConnectChanged(cb *func(TreeSelection)) uint32 { | |
| 287 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 288 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 289 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 290 | + | } | |
| 291 | + | ||
| 285 | 292 | fcb := func(clsPtr uintptr) { | |
| 286 | 293 | fa := TreeSelection{} | |
| 287 | 294 | fa.Ptr = clsPtr | |
| 295 | + | cbFn := *cb | |
| 288 | 296 | ||
| 289 | - | cb(fa) | |
| 297 | + | cbFn(fa) | |
| 290 | 298 | ||
| 291 | 299 | } | |
| 292 | - | return gobject.SignalConnect(x.GoPointer(), "changed", purego.NewCallback(fcb)) | |
| 300 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 301 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 302 | + | return gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) | |
| 293 | 303 | } | |
| 294 | 304 | ||
| 295 | 305 | func init() { | |
M v4/gtk/gtktreesortable.go +6 -6
| @@ -41,9 +41,9 @@ type TreeSortable interface { | |||
| 41 | 41 | SetGoPointer(uintptr) | |
| 42 | 42 | GetSortColumnId(SortColumnIdVar int, OrderVar *SortType) bool | |
| 43 | 43 | HasDefaultSortFunc() bool | |
| 44 | - | SetDefaultSortFunc(SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) | |
| 44 | + | SetDefaultSortFunc(SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) | |
| 45 | 45 | SetSortColumnId(SortColumnIdVar int, OrderVar SortType) | |
| 46 | - | SetSortFunc(SortColumnIdVar int, SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) | |
| 46 | + | SetSortFunc(SortColumnIdVar int, SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) | |
| 47 | 47 | SortColumnChanged() | |
| 48 | 48 | } | |
| 49 | 49 | type TreeSortableBase struct { | |
| @@ -86,9 +86,9 @@ func (x *TreeSortableBase) HasDefaultSortFunc() bool { | |||
| 86 | 86 | // This means that once the model has been sorted, it can’t go back to the | |
| 87 | 87 | // default state. In this case, when the current sort column id of @sortable | |
| 88 | 88 | // is %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted. | |
| 89 | - | func (x *TreeSortableBase) SetDefaultSortFunc(SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 89 | + | func (x *TreeSortableBase) SetDefaultSortFunc(SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 90 | 90 | ||
| 91 | - | XGtkTreeSortableSetDefaultSortFunc(x.GoPointer(), purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 91 | + | XGtkTreeSortableSetDefaultSortFunc(x.GoPointer(), glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 92 | 92 | ||
| 93 | 93 | } | |
| 94 | 94 | ||
| @@ -110,9 +110,9 @@ func (x *TreeSortableBase) SetSortColumnId(SortColumnIdVar int, OrderVar SortTyp | |||
| 110 | 110 | // Sets the comparison function used when sorting to be @sort_func. If the | |
| 111 | 111 | // current sort column id of @sortable is the same as @sort_column_id, then | |
| 112 | 112 | // the model will sort using this function. | |
| 113 | - | func (x *TreeSortableBase) SetSortFunc(SortColumnIdVar int, SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 113 | + | func (x *TreeSortableBase) SetSortFunc(SortColumnIdVar int, SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 114 | 114 | ||
| 115 | - | XGtkTreeSortableSetSortFunc(x.GoPointer(), SortColumnIdVar, purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 115 | + | XGtkTreeSortableSetSortFunc(x.GoPointer(), SortColumnIdVar, glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 116 | 116 | ||
| 117 | 117 | } | |
| 118 | 118 | ||
M v4/gtk/gtktreestore.go +6 -6
| @@ -477,9 +477,9 @@ func (x *TreeStore) FilterNew(RootVar *TreePath) *TreeModelBase { | |||
| 477 | 477 | // | |
| 478 | 478 | // If @func returns %TRUE, then the tree ceases to be walked, | |
| 479 | 479 | // and gtk_tree_model_foreach() returns. | |
| 480 | - | func (x *TreeStore) Foreach(FuncVar TreeModelForeachFunc, UserDataVar uintptr) { | |
| 480 | + | func (x *TreeStore) Foreach(FuncVar *TreeModelForeachFunc, UserDataVar uintptr) { | |
| 481 | 481 | ||
| 482 | - | XGtkTreeModelForeach(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar) | |
| 482 | + | XGtkTreeModelForeach(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar) | |
| 483 | 483 | ||
| 484 | 484 | } | |
| 485 | 485 | ||
| @@ -811,9 +811,9 @@ func (x *TreeStore) HasDefaultSortFunc() bool { | |||
| 811 | 811 | // This means that once the model has been sorted, it can’t go back to the | |
| 812 | 812 | // default state. In this case, when the current sort column id of @sortable | |
| 813 | 813 | // is %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted. | |
| 814 | - | func (x *TreeStore) SetDefaultSortFunc(SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 814 | + | func (x *TreeStore) SetDefaultSortFunc(SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 815 | 815 | ||
| 816 | - | XGtkTreeSortableSetDefaultSortFunc(x.GoPointer(), purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 816 | + | XGtkTreeSortableSetDefaultSortFunc(x.GoPointer(), glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 817 | 817 | ||
| 818 | 818 | } | |
| 819 | 819 | ||
| @@ -835,9 +835,9 @@ func (x *TreeStore) SetSortColumnId(SortColumnIdVar int, OrderVar SortType) { | |||
| 835 | 835 | // Sets the comparison function used when sorting to be @sort_func. If the | |
| 836 | 836 | // current sort column id of @sortable is the same as @sort_column_id, then | |
| 837 | 837 | // the model will sort using this function. | |
| 838 | - | func (x *TreeStore) SetSortFunc(SortColumnIdVar int, SortFuncVar TreeIterCompareFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 838 | + | func (x *TreeStore) SetSortFunc(SortColumnIdVar int, SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 839 | 839 | ||
| 840 | - | XGtkTreeSortableSetSortFunc(x.GoPointer(), SortColumnIdVar, purego.NewCallback(SortFuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 840 | + | XGtkTreeSortableSetSortFunc(x.GoPointer(), SortColumnIdVar, glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 841 | 841 | ||
| 842 | 842 | } | |
| 843 | 843 | ||
M v4/gtk/gtktreeview.go +175 -55
| @@ -793,9 +793,9 @@ var xTreeViewInsertColumnWithDataFunc func(uintptr, int, string, uintptr, uintpt | |||
| 793 | 793 | // gtk_tree_view_column_set_cell_data_func(), gtk_tree_view_column_pack_start(). | |
| 794 | 794 | // If @tree_view has “fixed_height” mode enabled, then the new column will have its | |
| 795 | 795 | // “sizing” property set to be GTK_TREE_VIEW_COLUMN_FIXED. | |
| 796 | - | func (x *TreeView) InsertColumnWithDataFunc(PositionVar int, TitleVar string, CellVar *CellRenderer, FuncVar TreeCellDataFunc, DataVar uintptr, DnotifyVar glib.DestroyNotify) int { | |
| 796 | + | func (x *TreeView) InsertColumnWithDataFunc(PositionVar int, TitleVar string, CellVar *CellRenderer, FuncVar *TreeCellDataFunc, DataVar uintptr, DnotifyVar *glib.DestroyNotify) int { | |
| 797 | 797 | ||
| 798 | - | cret := xTreeViewInsertColumnWithDataFunc(x.GoPointer(), PositionVar, TitleVar, CellVar.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DnotifyVar)) | |
| 798 | + | cret := xTreeViewInsertColumnWithDataFunc(x.GoPointer(), PositionVar, TitleVar, CellVar.GoPointer(), glib.NewCallback(FuncVar), DataVar, glib.NewCallback(DnotifyVar)) | |
| 799 | 799 | return cret | |
| 800 | 800 | } | |
| 801 | 801 | ||
| @@ -837,9 +837,9 @@ func (x *TreeView) IsRubberBandingActive() bool { | |||
| 837 | 837 | var xTreeViewMapExpandedRows func(uintptr, uintptr, uintptr) | |
| 838 | 838 | ||
| 839 | 839 | // Calls @func on all expanded rows. | |
| 840 | - | func (x *TreeView) MapExpandedRows(FuncVar TreeViewMappingFunc, DataVar uintptr) { | |
| 840 | + | func (x *TreeView) MapExpandedRows(FuncVar *TreeViewMappingFunc, DataVar uintptr) { | |
| 841 | 841 | ||
| 842 | - | xTreeViewMapExpandedRows(x.GoPointer(), purego.NewCallback(FuncVar), DataVar) | |
| 842 | + | xTreeViewMapExpandedRows(x.GoPointer(), glib.NewCallback(FuncVar), DataVar) | |
| 843 | 843 | ||
| 844 | 844 | } | |
| 845 | 845 | ||
| @@ -940,9 +940,9 @@ var xTreeViewSetColumnDragFunction func(uintptr, uintptr, uintptr, uintptr) | |||
| 940 | 940 | // are %NULL, then they indicate an edge. If @func is set to be %NULL, then | |
| 941 | 941 | // @tree_view reverts to the default behavior of allowing all columns to be | |
| 942 | 942 | // dropped everywhere. | |
| 943 | - | func (x *TreeView) SetColumnDragFunction(FuncVar TreeViewColumnDropFunc, UserDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 943 | + | func (x *TreeView) SetColumnDragFunction(FuncVar *TreeViewColumnDropFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 944 | 944 | ||
| 945 | - | xTreeViewSetColumnDragFunction(x.GoPointer(), purego.NewCallback(FuncVar), UserDataVar, purego.NewCallback(DestroyVar)) | |
| 945 | + | xTreeViewSetColumnDragFunction(x.GoPointer(), glib.NewCallback(FuncVar), UserDataVar, glib.NewCallback(DestroyVar)) | |
| 946 | 946 | ||
| 947 | 947 | } | |
| 948 | 948 | ||
| @@ -1148,9 +1148,9 @@ var xTreeViewSetRowSeparatorFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 1148 | 1148 | // Sets the row separator function, which is used to determine | |
| 1149 | 1149 | // whether a row should be drawn as a separator. If the row separator | |
| 1150 | 1150 | // function is %NULL, no separators are drawn. This is the default value. | |
| 1151 | - | func (x *TreeView) SetRowSeparatorFunc(FuncVar TreeViewRowSeparatorFunc, DataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 1151 | + | func (x *TreeView) SetRowSeparatorFunc(FuncVar *TreeViewRowSeparatorFunc, DataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 1152 | 1152 | ||
| 1153 | - | xTreeViewSetRowSeparatorFunc(x.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DestroyVar)) | |
| 1153 | + | xTreeViewSetRowSeparatorFunc(x.GoPointer(), glib.NewCallback(FuncVar), DataVar, glib.NewCallback(DestroyVar)) | |
| 1154 | 1154 | ||
| 1155 | 1155 | } | |
| 1156 | 1156 | ||
| @@ -1200,9 +1200,9 @@ var xTreeViewSetSearchEqualFunc func(uintptr, uintptr, uintptr, uintptr) | |||
| 1200 | 1200 | // Sets the compare function for the interactive search capabilities; note | |
| 1201 | 1201 | // that somewhat like strcmp() returning 0 for equality | |
| 1202 | 1202 | // `GtkTreeView`SearchEqualFunc returns %FALSE on matches. | |
| 1203 | - | func (x *TreeView) SetSearchEqualFunc(SearchEqualFuncVar TreeViewSearchEqualFunc, SearchUserDataVar uintptr, SearchDestroyVar glib.DestroyNotify) { | |
| 1203 | + | func (x *TreeView) SetSearchEqualFunc(SearchEqualFuncVar *TreeViewSearchEqualFunc, SearchUserDataVar uintptr, SearchDestroyVar *glib.DestroyNotify) { | |
| 1204 | 1204 | ||
| 1205 | - | xTreeViewSetSearchEqualFunc(x.GoPointer(), purego.NewCallback(SearchEqualFuncVar), SearchUserDataVar, purego.NewCallback(SearchDestroyVar)) | |
| 1205 | + | xTreeViewSetSearchEqualFunc(x.GoPointer(), glib.NewCallback(SearchEqualFuncVar), SearchUserDataVar, glib.NewCallback(SearchDestroyVar)) | |
| 1206 | 1206 | ||
| 1207 | 1207 | } | |
| 1208 | 1208 | ||
| @@ -1300,38 +1300,62 @@ func (c *TreeView) SetGoPointer(ptr uintptr) { | |||
| 1300 | 1300 | } | |
| 1301 | 1301 | ||
| 1302 | 1302 | // The number of columns of the treeview has changed. | |
| 1303 | - | func (x *TreeView) ConnectColumnsChanged(cb func(TreeView)) uint32 { | |
| 1303 | + | func (x *TreeView) ConnectColumnsChanged(cb *func(TreeView)) uint32 { | |
| 1304 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1305 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1306 | + | return gobject.SignalConnect(x.GoPointer(), "columns-changed", cbRefPtr) | |
| 1307 | + | } | |
| 1308 | + | ||
| 1304 | 1309 | fcb := func(clsPtr uintptr) { | |
| 1305 | 1310 | fa := TreeView{} | |
| 1306 | 1311 | fa.Ptr = clsPtr | |
| 1312 | + | cbFn := *cb | |
| 1307 | 1313 | ||
| 1308 | - | cb(fa) | |
| 1314 | + | cbFn(fa) | |
| 1309 | 1315 | ||
| 1310 | 1316 | } | |
| 1311 | - | return gobject.SignalConnect(x.GoPointer(), "columns-changed", purego.NewCallback(fcb)) | |
| 1317 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1318 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1319 | + | return gobject.SignalConnect(x.GoPointer(), "columns-changed", cbRefPtr) | |
| 1312 | 1320 | } | |
| 1313 | 1321 | ||
| 1314 | 1322 | // The position of the cursor (focused cell) has changed. | |
| 1315 | - | func (x *TreeView) ConnectCursorChanged(cb func(TreeView)) uint32 { | |
| 1323 | + | func (x *TreeView) ConnectCursorChanged(cb *func(TreeView)) uint32 { | |
| 1324 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1325 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1326 | + | return gobject.SignalConnect(x.GoPointer(), "cursor-changed", cbRefPtr) | |
| 1327 | + | } | |
| 1328 | + | ||
| 1316 | 1329 | fcb := func(clsPtr uintptr) { | |
| 1317 | 1330 | fa := TreeView{} | |
| 1318 | 1331 | fa.Ptr = clsPtr | |
| 1332 | + | cbFn := *cb | |
| 1319 | 1333 | ||
| 1320 | - | cb(fa) | |
| 1334 | + | cbFn(fa) | |
| 1321 | 1335 | ||
| 1322 | 1336 | } | |
| 1323 | - | return gobject.SignalConnect(x.GoPointer(), "cursor-changed", purego.NewCallback(fcb)) | |
| 1337 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1338 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1339 | + | return gobject.SignalConnect(x.GoPointer(), "cursor-changed", cbRefPtr) | |
| 1324 | 1340 | } | |
| 1325 | 1341 | ||
| 1326 | - | func (x *TreeView) ConnectExpandCollapseCursorRow(cb func(TreeView, bool, bool, bool) bool) uint32 { | |
| 1342 | + | func (x *TreeView) ConnectExpandCollapseCursorRow(cb *func(TreeView, bool, bool, bool) bool) uint32 { | |
| 1343 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1344 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1345 | + | return gobject.SignalConnect(x.GoPointer(), "expand-collapse-cursor-row", cbRefPtr) | |
| 1346 | + | } | |
| 1347 | + | ||
| 1327 | 1348 | fcb := func(clsPtr uintptr, ObjectVarp bool, P0Varp bool, P1Varp bool) bool { | |
| 1328 | 1349 | fa := TreeView{} | |
| 1329 | 1350 | fa.Ptr = clsPtr | |
| 1351 | + | cbFn := *cb | |
| 1330 | 1352 | ||
| 1331 | - | return cb(fa, ObjectVarp, P0Varp, P1Varp) | |
| 1353 | + | return cbFn(fa, ObjectVarp, P0Varp, P1Varp) | |
| 1332 | 1354 | ||
| 1333 | 1355 | } | |
| 1334 | - | return gobject.SignalConnect(x.GoPointer(), "expand-collapse-cursor-row", purego.NewCallback(fcb)) | |
| 1356 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1357 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1358 | + | return gobject.SignalConnect(x.GoPointer(), "expand-collapse-cursor-row", cbRefPtr) | |
| 1335 | 1359 | } | |
| 1336 | 1360 | ||
| 1337 | 1361 | // The `GtkTreeView`::move-cursor signal is a [keybinding | |
| @@ -1343,15 +1367,23 @@ func (x *TreeView) ConnectExpandCollapseCursorRow(cb func(TreeView, bool, bool, | |||
| 1343 | 1367 | // programmatically. In contrast to gtk_tree_view_set_cursor() and | |
| 1344 | 1368 | // gtk_tree_view_set_cursor_on_cell() when moving horizontally | |
| 1345 | 1369 | // `GtkTreeView`::move-cursor does not reset the current selection. | |
| 1346 | - | func (x *TreeView) ConnectMoveCursor(cb func(TreeView, MovementStep, int, bool, bool) bool) uint32 { | |
| 1370 | + | func (x *TreeView) ConnectMoveCursor(cb *func(TreeView, MovementStep, int, bool, bool) bool) uint32 { | |
| 1371 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1372 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1373 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 1374 | + | } | |
| 1375 | + | ||
| 1347 | 1376 | fcb := func(clsPtr uintptr, StepVarp MovementStep, DirectionVarp int, ExtendVarp bool, ModifyVarp bool) bool { | |
| 1348 | 1377 | fa := TreeView{} | |
| 1349 | 1378 | fa.Ptr = clsPtr | |
| 1379 | + | cbFn := *cb | |
| 1350 | 1380 | ||
| 1351 | - | return cb(fa, StepVarp, DirectionVarp, ExtendVarp, ModifyVarp) | |
| 1381 | + | return cbFn(fa, StepVarp, DirectionVarp, ExtendVarp, ModifyVarp) | |
| 1352 | 1382 | ||
| 1353 | 1383 | } | |
| 1354 | - | return gobject.SignalConnect(x.GoPointer(), "move-cursor", purego.NewCallback(fcb)) | |
| 1384 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1385 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1386 | + | return gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr) | |
| 1355 | 1387 | } | |
| 1356 | 1388 | ||
| 1357 | 1389 | // The "row-activated" signal is emitted when the method | |
| @@ -1368,131 +1400,219 @@ func (x *TreeView) ConnectMoveCursor(cb func(TreeView, MovementStep, int, bool, | |||
| 1368 | 1400 | // For selection handling refer to the | |
| 1369 | 1401 | // [tree widget conceptual overview](section-tree-widget.html) | |
| 1370 | 1402 | // as well as `GtkTreeSelection`. | |
| 1371 | - | func (x *TreeView) ConnectRowActivated(cb func(TreeView, uintptr, uintptr)) uint32 { | |
| 1403 | + | func (x *TreeView) ConnectRowActivated(cb *func(TreeView, uintptr, uintptr)) uint32 { | |
| 1404 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1405 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1406 | + | return gobject.SignalConnect(x.GoPointer(), "row-activated", cbRefPtr) | |
| 1407 | + | } | |
| 1408 | + | ||
| 1372 | 1409 | fcb := func(clsPtr uintptr, PathVarp uintptr, ColumnVarp uintptr) { | |
| 1373 | 1410 | fa := TreeView{} | |
| 1374 | 1411 | fa.Ptr = clsPtr | |
| 1412 | + | cbFn := *cb | |
| 1375 | 1413 | ||
| 1376 | - | cb(fa, PathVarp, ColumnVarp) | |
| 1414 | + | cbFn(fa, PathVarp, ColumnVarp) | |
| 1377 | 1415 | ||
| 1378 | 1416 | } | |
| 1379 | - | return gobject.SignalConnect(x.GoPointer(), "row-activated", purego.NewCallback(fcb)) | |
| 1417 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1418 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1419 | + | return gobject.SignalConnect(x.GoPointer(), "row-activated", cbRefPtr) | |
| 1380 | 1420 | } | |
| 1381 | 1421 | ||
| 1382 | 1422 | // The given row has been collapsed (child nodes are hidden). | |
| 1383 | - | func (x *TreeView) ConnectRowCollapsed(cb func(TreeView, uintptr, uintptr)) uint32 { | |
| 1423 | + | func (x *TreeView) ConnectRowCollapsed(cb *func(TreeView, uintptr, uintptr)) uint32 { | |
| 1424 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1425 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1426 | + | return gobject.SignalConnect(x.GoPointer(), "row-collapsed", cbRefPtr) | |
| 1427 | + | } | |
| 1428 | + | ||
| 1384 | 1429 | fcb := func(clsPtr uintptr, IterVarp uintptr, PathVarp uintptr) { | |
| 1385 | 1430 | fa := TreeView{} | |
| 1386 | 1431 | fa.Ptr = clsPtr | |
| 1432 | + | cbFn := *cb | |
| 1387 | 1433 | ||
| 1388 | - | cb(fa, IterVarp, PathVarp) | |
| 1434 | + | cbFn(fa, IterVarp, PathVarp) | |
| 1389 | 1435 | ||
| 1390 | 1436 | } | |
| 1391 | - | return gobject.SignalConnect(x.GoPointer(), "row-collapsed", purego.NewCallback(fcb)) | |
| 1437 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1438 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1439 | + | return gobject.SignalConnect(x.GoPointer(), "row-collapsed", cbRefPtr) | |
| 1392 | 1440 | } | |
| 1393 | 1441 | ||
| 1394 | 1442 | // The given row has been expanded (child nodes are shown). | |
| 1395 | - | func (x *TreeView) ConnectRowExpanded(cb func(TreeView, uintptr, uintptr)) uint32 { | |
| 1443 | + | func (x *TreeView) ConnectRowExpanded(cb *func(TreeView, uintptr, uintptr)) uint32 { | |
| 1444 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1445 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1446 | + | return gobject.SignalConnect(x.GoPointer(), "row-expanded", cbRefPtr) | |
| 1447 | + | } | |
| 1448 | + | ||
| 1396 | 1449 | fcb := func(clsPtr uintptr, IterVarp uintptr, PathVarp uintptr) { | |
| 1397 | 1450 | fa := TreeView{} | |
| 1398 | 1451 | fa.Ptr = clsPtr | |
| 1452 | + | cbFn := *cb | |
| 1399 | 1453 | ||
| 1400 | - | cb(fa, IterVarp, PathVarp) | |
| 1454 | + | cbFn(fa, IterVarp, PathVarp) | |
| 1401 | 1455 | ||
| 1402 | 1456 | } | |
| 1403 | - | return gobject.SignalConnect(x.GoPointer(), "row-expanded", purego.NewCallback(fcb)) | |
| 1457 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1458 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1459 | + | return gobject.SignalConnect(x.GoPointer(), "row-expanded", cbRefPtr) | |
| 1404 | 1460 | } | |
| 1405 | 1461 | ||
| 1406 | - | func (x *TreeView) ConnectSelectAll(cb func(TreeView) bool) uint32 { | |
| 1462 | + | func (x *TreeView) ConnectSelectAll(cb *func(TreeView) bool) uint32 { | |
| 1463 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1464 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1465 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 1466 | + | } | |
| 1467 | + | ||
| 1407 | 1468 | fcb := func(clsPtr uintptr) bool { | |
| 1408 | 1469 | fa := TreeView{} | |
| 1409 | 1470 | fa.Ptr = clsPtr | |
| 1471 | + | cbFn := *cb | |
| 1410 | 1472 | ||
| 1411 | - | return cb(fa) | |
| 1473 | + | return cbFn(fa) | |
| 1412 | 1474 | ||
| 1413 | 1475 | } | |
| 1414 | - | return gobject.SignalConnect(x.GoPointer(), "select-all", purego.NewCallback(fcb)) | |
| 1476 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1477 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1478 | + | return gobject.SignalConnect(x.GoPointer(), "select-all", cbRefPtr) | |
| 1415 | 1479 | } | |
| 1416 | 1480 | ||
| 1417 | - | func (x *TreeView) ConnectSelectCursorParent(cb func(TreeView) bool) uint32 { | |
| 1481 | + | func (x *TreeView) ConnectSelectCursorParent(cb *func(TreeView) bool) uint32 { | |
| 1482 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1483 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1484 | + | return gobject.SignalConnect(x.GoPointer(), "select-cursor-parent", cbRefPtr) | |
| 1485 | + | } | |
| 1486 | + | ||
| 1418 | 1487 | fcb := func(clsPtr uintptr) bool { | |
| 1419 | 1488 | fa := TreeView{} | |
| 1420 | 1489 | fa.Ptr = clsPtr | |
| 1490 | + | cbFn := *cb | |
| 1421 | 1491 | ||
| 1422 | - | return cb(fa) | |
| 1492 | + | return cbFn(fa) | |
| 1423 | 1493 | ||
| 1424 | 1494 | } | |
| 1425 | - | return gobject.SignalConnect(x.GoPointer(), "select-cursor-parent", purego.NewCallback(fcb)) | |
| 1495 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1496 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1497 | + | return gobject.SignalConnect(x.GoPointer(), "select-cursor-parent", cbRefPtr) | |
| 1426 | 1498 | } | |
| 1427 | 1499 | ||
| 1428 | - | func (x *TreeView) ConnectSelectCursorRow(cb func(TreeView, bool) bool) uint32 { | |
| 1500 | + | func (x *TreeView) ConnectSelectCursorRow(cb *func(TreeView, bool) bool) uint32 { | |
| 1501 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1502 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1503 | + | return gobject.SignalConnect(x.GoPointer(), "select-cursor-row", cbRefPtr) | |
| 1504 | + | } | |
| 1505 | + | ||
| 1429 | 1506 | fcb := func(clsPtr uintptr, ObjectVarp bool) bool { | |
| 1430 | 1507 | fa := TreeView{} | |
| 1431 | 1508 | fa.Ptr = clsPtr | |
| 1509 | + | cbFn := *cb | |
| 1432 | 1510 | ||
| 1433 | - | return cb(fa, ObjectVarp) | |
| 1511 | + | return cbFn(fa, ObjectVarp) | |
| 1434 | 1512 | ||
| 1435 | 1513 | } | |
| 1436 | - | return gobject.SignalConnect(x.GoPointer(), "select-cursor-row", purego.NewCallback(fcb)) | |
| 1514 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1515 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1516 | + | return gobject.SignalConnect(x.GoPointer(), "select-cursor-row", cbRefPtr) | |
| 1437 | 1517 | } | |
| 1438 | 1518 | ||
| 1439 | - | func (x *TreeView) ConnectStartInteractiveSearch(cb func(TreeView) bool) uint32 { | |
| 1519 | + | func (x *TreeView) ConnectStartInteractiveSearch(cb *func(TreeView) bool) uint32 { | |
| 1520 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1521 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1522 | + | return gobject.SignalConnect(x.GoPointer(), "start-interactive-search", cbRefPtr) | |
| 1523 | + | } | |
| 1524 | + | ||
| 1440 | 1525 | fcb := func(clsPtr uintptr) bool { | |
| 1441 | 1526 | fa := TreeView{} | |
| 1442 | 1527 | fa.Ptr = clsPtr | |
| 1528 | + | cbFn := *cb | |
| 1443 | 1529 | ||
| 1444 | - | return cb(fa) | |
| 1530 | + | return cbFn(fa) | |
| 1445 | 1531 | ||
| 1446 | 1532 | } | |
| 1447 | - | return gobject.SignalConnect(x.GoPointer(), "start-interactive-search", purego.NewCallback(fcb)) | |
| 1533 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1534 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1535 | + | return gobject.SignalConnect(x.GoPointer(), "start-interactive-search", cbRefPtr) | |
| 1448 | 1536 | } | |
| 1449 | 1537 | ||
| 1450 | 1538 | // The given row is about to be collapsed (hide its children nodes). Use this | |
| 1451 | 1539 | // signal if you need to control the collapsibility of individual rows. | |
| 1452 | - | func (x *TreeView) ConnectTestCollapseRow(cb func(TreeView, uintptr, uintptr) bool) uint32 { | |
| 1540 | + | func (x *TreeView) ConnectTestCollapseRow(cb *func(TreeView, uintptr, uintptr) bool) uint32 { | |
| 1541 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1542 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1543 | + | return gobject.SignalConnect(x.GoPointer(), "test-collapse-row", cbRefPtr) | |
| 1544 | + | } | |
| 1545 | + | ||
| 1453 | 1546 | fcb := func(clsPtr uintptr, IterVarp uintptr, PathVarp uintptr) bool { | |
| 1454 | 1547 | fa := TreeView{} | |
| 1455 | 1548 | fa.Ptr = clsPtr | |
| 1549 | + | cbFn := *cb | |
| 1456 | 1550 | ||
| 1457 | - | return cb(fa, IterVarp, PathVarp) | |
| 1551 | + | return cbFn(fa, IterVarp, PathVarp) | |
| 1458 | 1552 | ||
| 1459 | 1553 | } | |
| 1460 | - | return gobject.SignalConnect(x.GoPointer(), "test-collapse-row", purego.NewCallback(fcb)) | |
| 1554 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1555 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1556 | + | return gobject.SignalConnect(x.GoPointer(), "test-collapse-row", cbRefPtr) | |
| 1461 | 1557 | } | |
| 1462 | 1558 | ||
| 1463 | 1559 | // The given row is about to be expanded (show its children nodes). Use this | |
| 1464 | 1560 | // signal if you need to control the expandability of individual rows. | |
| 1465 | - | func (x *TreeView) ConnectTestExpandRow(cb func(TreeView, uintptr, uintptr) bool) uint32 { | |
| 1561 | + | func (x *TreeView) ConnectTestExpandRow(cb *func(TreeView, uintptr, uintptr) bool) uint32 { | |
| 1562 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1563 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1564 | + | return gobject.SignalConnect(x.GoPointer(), "test-expand-row", cbRefPtr) | |
| 1565 | + | } | |
| 1566 | + | ||
| 1466 | 1567 | fcb := func(clsPtr uintptr, IterVarp uintptr, PathVarp uintptr) bool { | |
| 1467 | 1568 | fa := TreeView{} | |
| 1468 | 1569 | fa.Ptr = clsPtr | |
| 1570 | + | cbFn := *cb | |
| 1469 | 1571 | ||
| 1470 | - | return cb(fa, IterVarp, PathVarp) | |
| 1572 | + | return cbFn(fa, IterVarp, PathVarp) | |
| 1471 | 1573 | ||
| 1472 | 1574 | } | |
| 1473 | - | return gobject.SignalConnect(x.GoPointer(), "test-expand-row", purego.NewCallback(fcb)) | |
| 1575 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1576 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1577 | + | return gobject.SignalConnect(x.GoPointer(), "test-expand-row", cbRefPtr) | |
| 1474 | 1578 | } | |
| 1475 | 1579 | ||
| 1476 | - | func (x *TreeView) ConnectToggleCursorRow(cb func(TreeView) bool) uint32 { | |
| 1580 | + | func (x *TreeView) ConnectToggleCursorRow(cb *func(TreeView) bool) uint32 { | |
| 1581 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1582 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1583 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-row", cbRefPtr) | |
| 1584 | + | } | |
| 1585 | + | ||
| 1477 | 1586 | fcb := func(clsPtr uintptr) bool { | |
| 1478 | 1587 | fa := TreeView{} | |
| 1479 | 1588 | fa.Ptr = clsPtr | |
| 1589 | + | cbFn := *cb | |
| 1480 | 1590 | ||
| 1481 | - | return cb(fa) | |
| 1591 | + | return cbFn(fa) | |
| 1482 | 1592 | ||
| 1483 | 1593 | } | |
| 1484 | - | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-row", purego.NewCallback(fcb)) | |
| 1594 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1595 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1596 | + | return gobject.SignalConnect(x.GoPointer(), "toggle-cursor-row", cbRefPtr) | |
| 1485 | 1597 | } | |
| 1486 | 1598 | ||
| 1487 | - | func (x *TreeView) ConnectUnselectAll(cb func(TreeView) bool) uint32 { | |
| 1599 | + | func (x *TreeView) ConnectUnselectAll(cb *func(TreeView) bool) uint32 { | |
| 1600 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1601 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1602 | + | return gobject.SignalConnect(x.GoPointer(), "unselect-all", cbRefPtr) | |
| 1603 | + | } | |
| 1604 | + | ||
| 1488 | 1605 | fcb := func(clsPtr uintptr) bool { | |
| 1489 | 1606 | fa := TreeView{} | |
| 1490 | 1607 | fa.Ptr = clsPtr | |
| 1608 | + | cbFn := *cb | |
| 1491 | 1609 | ||
| 1492 | - | return cb(fa) | |
| 1610 | + | return cbFn(fa) | |
| 1493 | 1611 | ||
| 1494 | 1612 | } | |
| 1495 | - | return gobject.SignalConnect(x.GoPointer(), "unselect-all", purego.NewCallback(fcb)) | |
| 1613 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1614 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1615 | + | return gobject.SignalConnect(x.GoPointer(), "unselect-all", cbRefPtr) | |
| 1496 | 1616 | } | |
| 1497 | 1617 | ||
| 1498 | 1618 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtktreeviewcolumn.go +15 -5
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | package gtk | |
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | + | "unsafe" | |
| 6 | + | ||
| 5 | 7 | "github.com/jwijenbergh/purego" | |
| 6 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 7 | 9 | "github.com/jwijenbergh/puregotk/v4/glib" | |
| @@ -505,9 +507,9 @@ var xTreeViewColumnSetCellDataFunc func(uintptr, uintptr, uintptr, uintptr, uint | |||
| 505 | 507 | // setting the column value, and should set the value of @tree_column's | |
| 506 | 508 | // cell renderer as appropriate. @func may be %NULL to remove an | |
| 507 | 509 | // older one. | |
| 508 | - | func (x *TreeViewColumn) SetCellDataFunc(CellRendererVar *CellRenderer, FuncVar TreeCellDataFunc, FuncDataVar uintptr, DestroyVar glib.DestroyNotify) { | |
| 510 | + | func (x *TreeViewColumn) SetCellDataFunc(CellRendererVar *CellRenderer, FuncVar *TreeCellDataFunc, FuncDataVar uintptr, DestroyVar *glib.DestroyNotify) { | |
| 509 | 511 | ||
| 510 | - | xTreeViewColumnSetCellDataFunc(x.GoPointer(), CellRendererVar.GoPointer(), purego.NewCallback(FuncVar), FuncDataVar, purego.NewCallback(DestroyVar)) | |
| 512 | + | xTreeViewColumnSetCellDataFunc(x.GoPointer(), CellRendererVar.GoPointer(), glib.NewCallback(FuncVar), FuncDataVar, glib.NewCallback(DestroyVar)) | |
| 511 | 513 | ||
| 512 | 514 | } | |
| 513 | 515 | ||
| @@ -699,15 +701,23 @@ func (c *TreeViewColumn) SetGoPointer(ptr uintptr) { | |||
| 699 | 701 | } | |
| 700 | 702 | ||
| 701 | 703 | // Emitted when the column's header has been clicked. | |
| 702 | - | func (x *TreeViewColumn) ConnectClicked(cb func(TreeViewColumn)) uint32 { | |
| 704 | + | func (x *TreeViewColumn) ConnectClicked(cb *func(TreeViewColumn)) uint32 { | |
| 705 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 706 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 707 | + | return gobject.SignalConnect(x.GoPointer(), "clicked", cbRefPtr) | |
| 708 | + | } | |
| 709 | + | ||
| 703 | 710 | fcb := func(clsPtr uintptr) { | |
| 704 | 711 | fa := TreeViewColumn{} | |
| 705 | 712 | fa.Ptr = clsPtr | |
| 713 | + | cbFn := *cb | |
| 706 | 714 | ||
| 707 | - | cb(fa) | |
| 715 | + | cbFn(fa) | |
| 708 | 716 | ||
| 709 | 717 | } | |
| 710 | - | return gobject.SignalConnect(x.GoPointer(), "clicked", purego.NewCallback(fcb)) | |
| 718 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 719 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 720 | + | return gobject.SignalConnect(x.GoPointer(), "clicked", cbRefPtr) | |
| 711 | 721 | } | |
| 712 | 722 | ||
| 713 | 723 | // Gets the ID of the @buildable object. | |
M v4/gtk/gtkwidget.go +151 -47
| @@ -92,9 +92,9 @@ var xWidgetClassAddBinding func(uintptr, uint, gdk.ModifierType, uintptr, string | |||
| 92 | 92 | // initialization. It does not provide for user_data, if you need that, | |
| 93 | 93 | // you will have to use [method@GtkWidgetClass.add_shortcut] with a custom | |
| 94 | 94 | // shortcut. | |
| 95 | - | func (x *WidgetClass) AddBinding(KeyvalVar uint, ModsVar gdk.ModifierType, CallbackVar ShortcutFunc, FormatStringVar string, varArgs ...interface{}) { | |
| 95 | + | func (x *WidgetClass) AddBinding(KeyvalVar uint, ModsVar gdk.ModifierType, CallbackVar *ShortcutFunc, FormatStringVar string, varArgs ...interface{}) { | |
| 96 | 96 | ||
| 97 | - | xWidgetClassAddBinding(x.GoPointer(), KeyvalVar, ModsVar, purego.NewCallback(CallbackVar), FormatStringVar, varArgs...) | |
| 97 | + | xWidgetClassAddBinding(x.GoPointer(), KeyvalVar, ModsVar, glib.NewCallback(CallbackVar), FormatStringVar, varArgs...) | |
| 98 | 98 | ||
| 99 | 99 | } | |
| 100 | 100 | ||
| @@ -160,9 +160,9 @@ var xWidgetClassBindTemplateCallbackFull func(uintptr, string, uintptr) | |||
| 160 | 160 | // | |
| 161 | 161 | // Note that this must be called from a composite widget classes | |
| 162 | 162 | // class initializer after calling [method@Gtk.WidgetClass.set_template]. | |
| 163 | - | func (x *WidgetClass) BindTemplateCallbackFull(CallbackNameVar string, CallbackSymbolVar gobject.Callback) { | |
| 163 | + | func (x *WidgetClass) BindTemplateCallbackFull(CallbackNameVar string, CallbackSymbolVar *gobject.Callback) { | |
| 164 | 164 | ||
| 165 | - | xWidgetClassBindTemplateCallbackFull(x.GoPointer(), CallbackNameVar, purego.NewCallback(CallbackSymbolVar)) | |
| 165 | + | xWidgetClassBindTemplateCallbackFull(x.GoPointer(), CallbackNameVar, glib.NewCallback(CallbackSymbolVar)) | |
| 166 | 166 | ||
| 167 | 167 | } | |
| 168 | 168 | ||
| @@ -258,9 +258,9 @@ var xWidgetClassInstallAction func(uintptr, string, string, uintptr) | |||
| 258 | 258 | // | |
| 259 | 259 | // Actions installed by this function are stateless. The only state | |
| 260 | 260 | // they have is whether they are enabled or not. | |
| 261 | - | func (x *WidgetClass) InstallAction(ActionNameVar string, ParameterTypeVar string, ActivateVar WidgetActionActivateFunc) { | |
| 261 | + | func (x *WidgetClass) InstallAction(ActionNameVar string, ParameterTypeVar string, ActivateVar *WidgetActionActivateFunc) { | |
| 262 | 262 | ||
| 263 | - | xWidgetClassInstallAction(x.GoPointer(), ActionNameVar, ParameterTypeVar, purego.NewCallback(ActivateVar)) | |
| 263 | + | xWidgetClassInstallAction(x.GoPointer(), ActionNameVar, ParameterTypeVar, glib.NewCallback(ActivateVar)) | |
| 264 | 264 | ||
| 265 | 265 | } | |
| 266 | 266 | ||
| @@ -995,9 +995,9 @@ var xWidgetAddTickCallback func(uintptr, uintptr, uintptr, uintptr) uint | |||
| 995 | 995 | // This is a more convenient alternative to connecting directly to the | |
| 996 | 996 | // [signal@Gdk.FrameClock::update] signal of `GdkFrameClock`, since you | |
| 997 | 997 | // don't have to worry about when a `GdkFrameClock` is assigned to a widget. | |
| 998 | - | func (x *Widget) AddTickCallback(CallbackVar TickCallback, UserDataVar uintptr, NotifyVar glib.DestroyNotify) uint { | |
| 998 | + | func (x *Widget) AddTickCallback(CallbackVar *TickCallback, UserDataVar uintptr, NotifyVar *glib.DestroyNotify) uint { | |
| 999 | 999 | ||
| 1000 | - | cret := xWidgetAddTickCallback(x.GoPointer(), purego.NewCallback(CallbackVar), UserDataVar, purego.NewCallback(NotifyVar)) | |
| 1000 | + | cret := xWidgetAddTickCallback(x.GoPointer(), glib.NewCallback(CallbackVar), UserDataVar, glib.NewCallback(NotifyVar)) | |
| 1001 | 1001 | return cret | |
| 1002 | 1002 | } | |
| 1003 | 1003 | ||
| @@ -3461,53 +3461,85 @@ func (c *Widget) SetGoPointer(ptr uintptr) { | |||
| 3461 | 3461 | // May result in finalization of the widget if all references are released. | |
| 3462 | 3462 | // | |
| 3463 | 3463 | // This signal is not suitable for saving widget state. | |
| 3464 | - | func (x *Widget) ConnectDestroy(cb func(Widget)) uint32 { | |
| 3464 | + | func (x *Widget) ConnectDestroy(cb *func(Widget)) uint32 { | |
| 3465 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3466 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3467 | + | return gobject.SignalConnect(x.GoPointer(), "destroy", cbRefPtr) | |
| 3468 | + | } | |
| 3469 | + | ||
| 3465 | 3470 | fcb := func(clsPtr uintptr) { | |
| 3466 | 3471 | fa := Widget{} | |
| 3467 | 3472 | fa.Ptr = clsPtr | |
| 3473 | + | cbFn := *cb | |
| 3468 | 3474 | ||
| 3469 | - | cb(fa) | |
| 3475 | + | cbFn(fa) | |
| 3470 | 3476 | ||
| 3471 | 3477 | } | |
| 3472 | - | return gobject.SignalConnect(x.GoPointer(), "destroy", purego.NewCallback(fcb)) | |
| 3478 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3479 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3480 | + | return gobject.SignalConnect(x.GoPointer(), "destroy", cbRefPtr) | |
| 3473 | 3481 | } | |
| 3474 | 3482 | ||
| 3475 | 3483 | // Emitted when the text direction of a widget changes. | |
| 3476 | - | func (x *Widget) ConnectDirectionChanged(cb func(Widget, TextDirection)) uint32 { | |
| 3484 | + | func (x *Widget) ConnectDirectionChanged(cb *func(Widget, TextDirection)) uint32 { | |
| 3485 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3486 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3487 | + | return gobject.SignalConnect(x.GoPointer(), "direction-changed", cbRefPtr) | |
| 3488 | + | } | |
| 3489 | + | ||
| 3477 | 3490 | fcb := func(clsPtr uintptr, PreviousDirectionVarp TextDirection) { | |
| 3478 | 3491 | fa := Widget{} | |
| 3479 | 3492 | fa.Ptr = clsPtr | |
| 3493 | + | cbFn := *cb | |
| 3480 | 3494 | ||
| 3481 | - | cb(fa, PreviousDirectionVarp) | |
| 3495 | + | cbFn(fa, PreviousDirectionVarp) | |
| 3482 | 3496 | ||
| 3483 | 3497 | } | |
| 3484 | - | return gobject.SignalConnect(x.GoPointer(), "direction-changed", purego.NewCallback(fcb)) | |
| 3498 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3499 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3500 | + | return gobject.SignalConnect(x.GoPointer(), "direction-changed", cbRefPtr) | |
| 3485 | 3501 | } | |
| 3486 | 3502 | ||
| 3487 | 3503 | // Emitted when @widget is hidden. | |
| 3488 | - | func (x *Widget) ConnectHide(cb func(Widget)) uint32 { | |
| 3504 | + | func (x *Widget) ConnectHide(cb *func(Widget)) uint32 { | |
| 3505 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3506 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3507 | + | return gobject.SignalConnect(x.GoPointer(), "hide", cbRefPtr) | |
| 3508 | + | } | |
| 3509 | + | ||
| 3489 | 3510 | fcb := func(clsPtr uintptr) { | |
| 3490 | 3511 | fa := Widget{} | |
| 3491 | 3512 | fa.Ptr = clsPtr | |
| 3513 | + | cbFn := *cb | |
| 3492 | 3514 | ||
| 3493 | - | cb(fa) | |
| 3515 | + | cbFn(fa) | |
| 3494 | 3516 | ||
| 3495 | 3517 | } | |
| 3496 | - | return gobject.SignalConnect(x.GoPointer(), "hide", purego.NewCallback(fcb)) | |
| 3518 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3519 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3520 | + | return gobject.SignalConnect(x.GoPointer(), "hide", cbRefPtr) | |
| 3497 | 3521 | } | |
| 3498 | 3522 | ||
| 3499 | 3523 | // Emitted if keyboard navigation fails. | |
| 3500 | 3524 | // | |
| 3501 | 3525 | // See [method@Gtk.Widget.keynav_failed] for details. | |
| 3502 | - | func (x *Widget) ConnectKeynavFailed(cb func(Widget, DirectionType) bool) uint32 { | |
| 3526 | + | func (x *Widget) ConnectKeynavFailed(cb *func(Widget, DirectionType) bool) uint32 { | |
| 3527 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3528 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3529 | + | return gobject.SignalConnect(x.GoPointer(), "keynav-failed", cbRefPtr) | |
| 3530 | + | } | |
| 3531 | + | ||
| 3503 | 3532 | fcb := func(clsPtr uintptr, DirectionVarp DirectionType) bool { | |
| 3504 | 3533 | fa := Widget{} | |
| 3505 | 3534 | fa.Ptr = clsPtr | |
| 3535 | + | cbFn := *cb | |
| 3506 | 3536 | ||
| 3507 | - | return cb(fa, DirectionVarp) | |
| 3537 | + | return cbFn(fa, DirectionVarp) | |
| 3508 | 3538 | ||
| 3509 | 3539 | } | |
| 3510 | - | return gobject.SignalConnect(x.GoPointer(), "keynav-failed", purego.NewCallback(fcb)) | |
| 3540 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3541 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3542 | + | return gobject.SignalConnect(x.GoPointer(), "keynav-failed", cbRefPtr) | |
| 3511 | 3543 | } | |
| 3512 | 3544 | ||
| 3513 | 3545 | // Emitted when @widget is going to be mapped. | |
| @@ -3519,42 +3551,66 @@ func (x *Widget) ConnectKeynavFailed(cb func(Widget, DirectionType) bool) uint32 | |||
| 3519 | 3551 | // The ::map signal can be used to determine whether a widget will be drawn, | |
| 3520 | 3552 | // for instance it can resume an animation that was stopped during the | |
| 3521 | 3553 | // emission of [signal@Gtk.Widget::unmap]. | |
| 3522 | - | func (x *Widget) ConnectMap(cb func(Widget)) uint32 { | |
| 3554 | + | func (x *Widget) ConnectMap(cb *func(Widget)) uint32 { | |
| 3555 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3556 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3557 | + | return gobject.SignalConnect(x.GoPointer(), "map", cbRefPtr) | |
| 3558 | + | } | |
| 3559 | + | ||
| 3523 | 3560 | fcb := func(clsPtr uintptr) { | |
| 3524 | 3561 | fa := Widget{} | |
| 3525 | 3562 | fa.Ptr = clsPtr | |
| 3563 | + | cbFn := *cb | |
| 3526 | 3564 | ||
| 3527 | - | cb(fa) | |
| 3565 | + | cbFn(fa) | |
| 3528 | 3566 | ||
| 3529 | 3567 | } | |
| 3530 | - | return gobject.SignalConnect(x.GoPointer(), "map", purego.NewCallback(fcb)) | |
| 3568 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3569 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3570 | + | return gobject.SignalConnect(x.GoPointer(), "map", cbRefPtr) | |
| 3531 | 3571 | } | |
| 3532 | 3572 | ||
| 3533 | 3573 | // Emitted when a widget is activated via a mnemonic. | |
| 3534 | 3574 | // | |
| 3535 | 3575 | // The default handler for this signal activates @widget if @group_cycling | |
| 3536 | 3576 | // is %FALSE, or just makes @widget grab focus if @group_cycling is %TRUE. | |
| 3537 | - | func (x *Widget) ConnectMnemonicActivate(cb func(Widget, bool) bool) uint32 { | |
| 3577 | + | func (x *Widget) ConnectMnemonicActivate(cb *func(Widget, bool) bool) uint32 { | |
| 3578 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3579 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3580 | + | return gobject.SignalConnect(x.GoPointer(), "mnemonic-activate", cbRefPtr) | |
| 3581 | + | } | |
| 3582 | + | ||
| 3538 | 3583 | fcb := func(clsPtr uintptr, GroupCyclingVarp bool) bool { | |
| 3539 | 3584 | fa := Widget{} | |
| 3540 | 3585 | fa.Ptr = clsPtr | |
| 3586 | + | cbFn := *cb | |
| 3541 | 3587 | ||
| 3542 | - | return cb(fa, GroupCyclingVarp) | |
| 3588 | + | return cbFn(fa, GroupCyclingVarp) | |
| 3543 | 3589 | ||
| 3544 | 3590 | } | |
| 3545 | - | return gobject.SignalConnect(x.GoPointer(), "mnemonic-activate", purego.NewCallback(fcb)) | |
| 3591 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3592 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3593 | + | return gobject.SignalConnect(x.GoPointer(), "mnemonic-activate", cbRefPtr) | |
| 3546 | 3594 | } | |
| 3547 | 3595 | ||
| 3548 | 3596 | // Emitted when the focus is moved. | |
| 3549 | - | func (x *Widget) ConnectMoveFocus(cb func(Widget, DirectionType)) uint32 { | |
| 3597 | + | func (x *Widget) ConnectMoveFocus(cb *func(Widget, DirectionType)) uint32 { | |
| 3598 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3599 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3600 | + | return gobject.SignalConnect(x.GoPointer(), "move-focus", cbRefPtr) | |
| 3601 | + | } | |
| 3602 | + | ||
| 3550 | 3603 | fcb := func(clsPtr uintptr, DirectionVarp DirectionType) { | |
| 3551 | 3604 | fa := Widget{} | |
| 3552 | 3605 | fa.Ptr = clsPtr | |
| 3606 | + | cbFn := *cb | |
| 3553 | 3607 | ||
| 3554 | - | cb(fa, DirectionVarp) | |
| 3608 | + | cbFn(fa, DirectionVarp) | |
| 3555 | 3609 | ||
| 3556 | 3610 | } | |
| 3557 | - | return gobject.SignalConnect(x.GoPointer(), "move-focus", purego.NewCallback(fcb)) | |
| 3611 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3612 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3613 | + | return gobject.SignalConnect(x.GoPointer(), "move-focus", cbRefPtr) | |
| 3558 | 3614 | } | |
| 3559 | 3615 | ||
| 3560 | 3616 | // Emitted when the widgets tooltip is about to be shown. | |
| @@ -3571,56 +3627,88 @@ func (x *Widget) ConnectMoveFocus(cb func(Widget, DirectionType)) uint32 { | |||
| 3571 | 3627 | // | |
| 3572 | 3628 | // The signal handler is free to manipulate @tooltip with the therefore | |
| 3573 | 3629 | // destined function calls. | |
| 3574 | - | func (x *Widget) ConnectQueryTooltip(cb func(Widget, int, int, bool, uintptr) bool) uint32 { | |
| 3630 | + | func (x *Widget) ConnectQueryTooltip(cb *func(Widget, int, int, bool, uintptr) bool) uint32 { | |
| 3631 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3632 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3633 | + | return gobject.SignalConnect(x.GoPointer(), "query-tooltip", cbRefPtr) | |
| 3634 | + | } | |
| 3635 | + | ||
| 3575 | 3636 | fcb := func(clsPtr uintptr, XVarp int, YVarp int, KeyboardModeVarp bool, TooltipVarp uintptr) bool { | |
| 3576 | 3637 | fa := Widget{} | |
| 3577 | 3638 | fa.Ptr = clsPtr | |
| 3639 | + | cbFn := *cb | |
| 3578 | 3640 | ||
| 3579 | - | return cb(fa, XVarp, YVarp, KeyboardModeVarp, TooltipVarp) | |
| 3641 | + | return cbFn(fa, XVarp, YVarp, KeyboardModeVarp, TooltipVarp) | |
| 3580 | 3642 | ||
| 3581 | 3643 | } | |
| 3582 | - | return gobject.SignalConnect(x.GoPointer(), "query-tooltip", purego.NewCallback(fcb)) | |
| 3644 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3645 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3646 | + | return gobject.SignalConnect(x.GoPointer(), "query-tooltip", cbRefPtr) | |
| 3583 | 3647 | } | |
| 3584 | 3648 | ||
| 3585 | 3649 | // Emitted when @widget is associated with a `GdkSurface`. | |
| 3586 | 3650 | // | |
| 3587 | 3651 | // This means that [method@Gtk.Widget.realize] has been called | |
| 3588 | 3652 | // or the widget has been mapped (that is, it is going to be drawn). | |
| 3589 | - | func (x *Widget) ConnectRealize(cb func(Widget)) uint32 { | |
| 3653 | + | func (x *Widget) ConnectRealize(cb *func(Widget)) uint32 { | |
| 3654 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3655 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3656 | + | return gobject.SignalConnect(x.GoPointer(), "realize", cbRefPtr) | |
| 3657 | + | } | |
| 3658 | + | ||
| 3590 | 3659 | fcb := func(clsPtr uintptr) { | |
| 3591 | 3660 | fa := Widget{} | |
| 3592 | 3661 | fa.Ptr = clsPtr | |
| 3662 | + | cbFn := *cb | |
| 3593 | 3663 | ||
| 3594 | - | cb(fa) | |
| 3664 | + | cbFn(fa) | |
| 3595 | 3665 | ||
| 3596 | 3666 | } | |
| 3597 | - | return gobject.SignalConnect(x.GoPointer(), "realize", purego.NewCallback(fcb)) | |
| 3667 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3668 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3669 | + | return gobject.SignalConnect(x.GoPointer(), "realize", cbRefPtr) | |
| 3598 | 3670 | } | |
| 3599 | 3671 | ||
| 3600 | 3672 | // Emitted when @widget is shown. | |
| 3601 | - | func (x *Widget) ConnectShow(cb func(Widget)) uint32 { | |
| 3673 | + | func (x *Widget) ConnectShow(cb *func(Widget)) uint32 { | |
| 3674 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3675 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3676 | + | return gobject.SignalConnect(x.GoPointer(), "show", cbRefPtr) | |
| 3677 | + | } | |
| 3678 | + | ||
| 3602 | 3679 | fcb := func(clsPtr uintptr) { | |
| 3603 | 3680 | fa := Widget{} | |
| 3604 | 3681 | fa.Ptr = clsPtr | |
| 3682 | + | cbFn := *cb | |
| 3605 | 3683 | ||
| 3606 | - | cb(fa) | |
| 3684 | + | cbFn(fa) | |
| 3607 | 3685 | ||
| 3608 | 3686 | } | |
| 3609 | - | return gobject.SignalConnect(x.GoPointer(), "show", purego.NewCallback(fcb)) | |
| 3687 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3688 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3689 | + | return gobject.SignalConnect(x.GoPointer(), "show", cbRefPtr) | |
| 3610 | 3690 | } | |
| 3611 | 3691 | ||
| 3612 | 3692 | // Emitted when the widget state changes. | |
| 3613 | 3693 | // | |
| 3614 | 3694 | // See [method@Gtk.Widget.get_state_flags]. | |
| 3615 | - | func (x *Widget) ConnectStateFlagsChanged(cb func(Widget, StateFlags)) uint32 { | |
| 3695 | + | func (x *Widget) ConnectStateFlagsChanged(cb *func(Widget, StateFlags)) uint32 { | |
| 3696 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3697 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3698 | + | return gobject.SignalConnect(x.GoPointer(), "state-flags-changed", cbRefPtr) | |
| 3699 | + | } | |
| 3700 | + | ||
| 3616 | 3701 | fcb := func(clsPtr uintptr, FlagsVarp StateFlags) { | |
| 3617 | 3702 | fa := Widget{} | |
| 3618 | 3703 | fa.Ptr = clsPtr | |
| 3704 | + | cbFn := *cb | |
| 3619 | 3705 | ||
| 3620 | - | cb(fa, FlagsVarp) | |
| 3706 | + | cbFn(fa, FlagsVarp) | |
| 3621 | 3707 | ||
| 3622 | 3708 | } | |
| 3623 | - | return gobject.SignalConnect(x.GoPointer(), "state-flags-changed", purego.NewCallback(fcb)) | |
| 3709 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3710 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3711 | + | return gobject.SignalConnect(x.GoPointer(), "state-flags-changed", cbRefPtr) | |
| 3624 | 3712 | } | |
| 3625 | 3713 | ||
| 3626 | 3714 | // Emitted when @widget is going to be unmapped. | |
| @@ -3630,30 +3718,46 @@ func (x *Widget) ConnectStateFlagsChanged(cb func(Widget, StateFlags)) uint32 { | |||
| 3630 | 3718 | // | |
| 3631 | 3719 | // As ::unmap indicates that a widget will not be shown any longer, | |
| 3632 | 3720 | // it can be used to, for example, stop an animation on the widget. | |
| 3633 | - | func (x *Widget) ConnectUnmap(cb func(Widget)) uint32 { | |
| 3721 | + | func (x *Widget) ConnectUnmap(cb *func(Widget)) uint32 { | |
| 3722 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3723 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3724 | + | return gobject.SignalConnect(x.GoPointer(), "unmap", cbRefPtr) | |
| 3725 | + | } | |
| 3726 | + | ||
| 3634 | 3727 | fcb := func(clsPtr uintptr) { | |
| 3635 | 3728 | fa := Widget{} | |
| 3636 | 3729 | fa.Ptr = clsPtr | |
| 3730 | + | cbFn := *cb | |
| 3637 | 3731 | ||
| 3638 | - | cb(fa) | |
| 3732 | + | cbFn(fa) | |
| 3639 | 3733 | ||
| 3640 | 3734 | } | |
| 3641 | - | return gobject.SignalConnect(x.GoPointer(), "unmap", purego.NewCallback(fcb)) | |
| 3735 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3736 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3737 | + | return gobject.SignalConnect(x.GoPointer(), "unmap", cbRefPtr) | |
| 3642 | 3738 | } | |
| 3643 | 3739 | ||
| 3644 | 3740 | // Emitted when the `GdkSurface` associated with @widget is destroyed. | |
| 3645 | 3741 | // | |
| 3646 | 3742 | // This means that [method@Gtk.Widget.unrealize] has been called | |
| 3647 | 3743 | // or the widget has been unmapped (that is, it is going to be hidden). | |
| 3648 | - | func (x *Widget) ConnectUnrealize(cb func(Widget)) uint32 { | |
| 3744 | + | func (x *Widget) ConnectUnrealize(cb *func(Widget)) uint32 { | |
| 3745 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 3746 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 3747 | + | return gobject.SignalConnect(x.GoPointer(), "unrealize", cbRefPtr) | |
| 3748 | + | } | |
| 3749 | + | ||
| 3649 | 3750 | fcb := func(clsPtr uintptr) { | |
| 3650 | 3751 | fa := Widget{} | |
| 3651 | 3752 | fa.Ptr = clsPtr | |
| 3753 | + | cbFn := *cb | |
| 3652 | 3754 | ||
| 3653 | - | cb(fa) | |
| 3755 | + | cbFn(fa) | |
| 3654 | 3756 | ||
| 3655 | 3757 | } | |
| 3656 | - | return gobject.SignalConnect(x.GoPointer(), "unrealize", purego.NewCallback(fcb)) | |
| 3758 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 3759 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 3760 | + | return gobject.SignalConnect(x.GoPointer(), "unrealize", cbRefPtr) | |
| 3657 | 3761 | } | |
| 3658 | 3762 | ||
| 3659 | 3763 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/gtk/gtkwindow.go +55 -15
| @@ -950,42 +950,66 @@ func (c *Window) SetGoPointer(ptr uintptr) { | |||
| 950 | 950 | // of @window. | |
| 951 | 951 | // | |
| 952 | 952 | // This is a [keybinding signal](class.SignalAction.html). | |
| 953 | - | func (x *Window) ConnectActivateDefault(cb func(Window)) uint32 { | |
| 953 | + | func (x *Window) ConnectActivateDefault(cb *func(Window)) uint32 { | |
| 954 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 955 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 956 | + | return gobject.SignalConnect(x.GoPointer(), "activate-default", cbRefPtr) | |
| 957 | + | } | |
| 958 | + | ||
| 954 | 959 | fcb := func(clsPtr uintptr) { | |
| 955 | 960 | fa := Window{} | |
| 956 | 961 | fa.Ptr = clsPtr | |
| 962 | + | cbFn := *cb | |
| 957 | 963 | ||
| 958 | - | cb(fa) | |
| 964 | + | cbFn(fa) | |
| 959 | 965 | ||
| 960 | 966 | } | |
| 961 | - | return gobject.SignalConnect(x.GoPointer(), "activate-default", purego.NewCallback(fcb)) | |
| 967 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 968 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 969 | + | return gobject.SignalConnect(x.GoPointer(), "activate-default", cbRefPtr) | |
| 962 | 970 | } | |
| 963 | 971 | ||
| 964 | 972 | // Emitted when the user activates the currently focused | |
| 965 | 973 | // widget of @window. | |
| 966 | 974 | // | |
| 967 | 975 | // This is a [keybinding signal](class.SignalAction.html). | |
| 968 | - | func (x *Window) ConnectActivateFocus(cb func(Window)) uint32 { | |
| 976 | + | func (x *Window) ConnectActivateFocus(cb *func(Window)) uint32 { | |
| 977 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 978 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 979 | + | return gobject.SignalConnect(x.GoPointer(), "activate-focus", cbRefPtr) | |
| 980 | + | } | |
| 981 | + | ||
| 969 | 982 | fcb := func(clsPtr uintptr) { | |
| 970 | 983 | fa := Window{} | |
| 971 | 984 | fa.Ptr = clsPtr | |
| 985 | + | cbFn := *cb | |
| 972 | 986 | ||
| 973 | - | cb(fa) | |
| 987 | + | cbFn(fa) | |
| 974 | 988 | ||
| 975 | 989 | } | |
| 976 | - | return gobject.SignalConnect(x.GoPointer(), "activate-focus", purego.NewCallback(fcb)) | |
| 990 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 991 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 992 | + | return gobject.SignalConnect(x.GoPointer(), "activate-focus", cbRefPtr) | |
| 977 | 993 | } | |
| 978 | 994 | ||
| 979 | 995 | // Emitted when the user clicks on the close button of the window. | |
| 980 | - | func (x *Window) ConnectCloseRequest(cb func(Window) bool) uint32 { | |
| 996 | + | func (x *Window) ConnectCloseRequest(cb *func(Window) bool) uint32 { | |
| 997 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 998 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 999 | + | return gobject.SignalConnect(x.GoPointer(), "close-request", cbRefPtr) | |
| 1000 | + | } | |
| 1001 | + | ||
| 981 | 1002 | fcb := func(clsPtr uintptr) bool { | |
| 982 | 1003 | fa := Window{} | |
| 983 | 1004 | fa.Ptr = clsPtr | |
| 1005 | + | cbFn := *cb | |
| 984 | 1006 | ||
| 985 | - | return cb(fa) | |
| 1007 | + | return cbFn(fa) | |
| 986 | 1008 | ||
| 987 | 1009 | } | |
| 988 | - | return gobject.SignalConnect(x.GoPointer(), "close-request", purego.NewCallback(fcb)) | |
| 1010 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1011 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1012 | + | return gobject.SignalConnect(x.GoPointer(), "close-request", cbRefPtr) | |
| 989 | 1013 | } | |
| 990 | 1014 | ||
| 991 | 1015 | // Emitted when the user enables or disables interactive debugging. | |
| @@ -998,28 +1022,44 @@ func (x *Window) ConnectCloseRequest(cb func(Window) bool) uint32 { | |||
| 998 | 1022 | // | |
| 999 | 1023 | // The default bindings for this signal are Ctrl-Shift-I | |
| 1000 | 1024 | // and Ctrl-Shift-D. | |
| 1001 | - | func (x *Window) ConnectEnableDebugging(cb func(Window, bool) bool) uint32 { | |
| 1025 | + | func (x *Window) ConnectEnableDebugging(cb *func(Window, bool) bool) uint32 { | |
| 1026 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1027 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1028 | + | return gobject.SignalConnect(x.GoPointer(), "enable-debugging", cbRefPtr) | |
| 1029 | + | } | |
| 1030 | + | ||
| 1002 | 1031 | fcb := func(clsPtr uintptr, ToggleVarp bool) bool { | |
| 1003 | 1032 | fa := Window{} | |
| 1004 | 1033 | fa.Ptr = clsPtr | |
| 1034 | + | cbFn := *cb | |
| 1005 | 1035 | ||
| 1006 | - | return cb(fa, ToggleVarp) | |
| 1036 | + | return cbFn(fa, ToggleVarp) | |
| 1007 | 1037 | ||
| 1008 | 1038 | } | |
| 1009 | - | return gobject.SignalConnect(x.GoPointer(), "enable-debugging", purego.NewCallback(fcb)) | |
| 1039 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1040 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1041 | + | return gobject.SignalConnect(x.GoPointer(), "enable-debugging", cbRefPtr) | |
| 1010 | 1042 | } | |
| 1011 | 1043 | ||
| 1012 | 1044 | // emitted when the set of accelerators or mnemonics that | |
| 1013 | 1045 | // are associated with @window changes. | |
| 1014 | - | func (x *Window) ConnectKeysChanged(cb func(Window)) uint32 { | |
| 1046 | + | func (x *Window) ConnectKeysChanged(cb *func(Window)) uint32 { | |
| 1047 | + | cbPtr := uintptr(unsafe.Pointer(cb)) | |
| 1048 | + | if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { | |
| 1049 | + | return gobject.SignalConnect(x.GoPointer(), "keys-changed", cbRefPtr) | |
| 1050 | + | } | |
| 1051 | + | ||
| 1015 | 1052 | fcb := func(clsPtr uintptr) { | |
| 1016 | 1053 | fa := Window{} | |
| 1017 | 1054 | fa.Ptr = clsPtr | |
| 1055 | + | cbFn := *cb | |
| 1018 | 1056 | ||
| 1019 | - | cb(fa) | |
| 1057 | + | cbFn(fa) | |
| 1020 | 1058 | ||
| 1021 | 1059 | } | |
| 1022 | - | return gobject.SignalConnect(x.GoPointer(), "keys-changed", purego.NewCallback(fcb)) | |
| 1060 | + | cbRefPtr := purego.NewCallback(fcb) | |
| 1061 | + | glib.SaveCallback(cbPtr, cbRefPtr) | |
| 1062 | + | return gobject.SignalConnect(x.GoPointer(), "keys-changed", cbRefPtr) | |
| 1023 | 1063 | } | |
| 1024 | 1064 | ||
| 1025 | 1065 | // Retrieves the `GtkAccessibleRole` for the given `GtkAccessible`. | |
M v4/pango/pango-attributes.go +4 -4
| @@ -265,9 +265,9 @@ var xAttrListFilter func(uintptr, uintptr, uintptr) *AttrList | |||
| 265 | 265 | // Given a `PangoAttrList` and callback function, removes | |
| 266 | 266 | // any elements of @list for which @func returns %TRUE and | |
| 267 | 267 | // inserts them into a new list. | |
| 268 | - | func (x *AttrList) Filter(FuncVar AttrFilterFunc, DataVar uintptr) *AttrList { | |
| 268 | + | func (x *AttrList) Filter(FuncVar *AttrFilterFunc, DataVar uintptr) *AttrList { | |
| 269 | 269 | ||
| 270 | - | cret := xAttrListFilter(x.GoPointer(), purego.NewCallback(FuncVar), DataVar) | |
| 270 | + | cret := xAttrListFilter(x.GoPointer(), glib.NewCallback(FuncVar), DataVar) | |
| 271 | 271 | return cret | |
| 272 | 272 | } | |
| 273 | 273 | ||
| @@ -1110,9 +1110,9 @@ var xAttrShapeNewWithData func(*Rectangle, *Rectangle, uintptr, uintptr, uintptr | |||
| 1110 | 1110 | // Like [func@Pango.AttrShape.new], but a user data pointer | |
| 1111 | 1111 | // is also provided; this pointer can be accessed when later | |
| 1112 | 1112 | // rendering the glyph. | |
| 1113 | - | func AttrShapeNewWithData(InkRectVar *Rectangle, LogicalRectVar *Rectangle, DataVar uintptr, CopyFuncVar AttrDataCopyFunc, DestroyFuncVar glib.DestroyNotify) *Attribute { | |
| 1113 | + | func AttrShapeNewWithData(InkRectVar *Rectangle, LogicalRectVar *Rectangle, DataVar uintptr, CopyFuncVar *AttrDataCopyFunc, DestroyFuncVar *glib.DestroyNotify) *Attribute { | |
| 1114 | 1114 | ||
| 1115 | - | cret := xAttrShapeNewWithData(InkRectVar, LogicalRectVar, DataVar, purego.NewCallback(CopyFuncVar), purego.NewCallback(DestroyFuncVar)) | |
| 1115 | + | cret := xAttrShapeNewWithData(InkRectVar, LogicalRectVar, DataVar, glib.NewCallback(CopyFuncVar), glib.NewCallback(DestroyFuncVar)) | |
| 1116 | 1116 | return cret | |
| 1117 | 1117 | } | |
| 1118 | 1118 | ||
M v4/pango/pango-fontset.go +3 -2
| @@ -6,6 +6,7 @@ import ( | |||
| 6 | 6 | ||
| 7 | 7 | "github.com/jwijenbergh/purego" | |
| 8 | 8 | "github.com/jwijenbergh/puregotk/internal/core" | |
| 9 | + | "github.com/jwijenbergh/puregotk/v4/glib" | |
| 9 | 10 | "github.com/jwijenbergh/puregotk/v4/gobject" | |
| 10 | 11 | ) | |
| 11 | 12 | ||
| @@ -52,9 +53,9 @@ var xFontsetForeach func(uintptr, uintptr, uintptr) | |||
| 52 | 53 | // each one. | |
| 53 | 54 | // | |
| 54 | 55 | // If @func returns %TRUE, that stops the iteration. | |
| 55 | - | func (x *Fontset) Foreach(FuncVar FontsetForeachFunc, DataVar uintptr) { | |
| 56 | + | func (x *Fontset) Foreach(FuncVar *FontsetForeachFunc, DataVar uintptr) { | |
| 56 | 57 | ||
| 57 | - | xFontsetForeach(x.GoPointer(), purego.NewCallback(FuncVar), DataVar) | |
| 58 | + | xFontsetForeach(x.GoPointer(), glib.NewCallback(FuncVar), DataVar) | |
| 58 | 59 | ||
| 59 | 60 | } | |
| 60 | 61 | ||
M v4/pangocairo/pangocairo.go +2 -2
| @@ -213,9 +213,9 @@ var xContextSetShapeRenderer func(uintptr, uintptr, uintptr, uintptr) | |||
| 213 | 213 | // of type %PANGO_ATTR_SHAPE. | |
| 214 | 214 | // | |
| 215 | 215 | // See `PangoCairoShapeRendererFunc` for details. | |
| 216 | - | func ContextSetShapeRenderer(ContextVar *pango.Context, FuncVar ShapeRendererFunc, DataVar uintptr, DnotifyVar glib.DestroyNotify) { | |
| 216 | + | func ContextSetShapeRenderer(ContextVar *pango.Context, FuncVar *ShapeRendererFunc, DataVar uintptr, DnotifyVar *glib.DestroyNotify) { | |
| 217 | 217 | ||
| 218 | - | xContextSetShapeRenderer(ContextVar.GoPointer(), purego.NewCallback(FuncVar), DataVar, purego.NewCallback(DnotifyVar)) | |
| 218 | + | xContextSetShapeRenderer(ContextVar.GoPointer(), glib.NewCallback(FuncVar), DataVar, glib.NewCallback(DnotifyVar)) | |
| 219 | 219 | ||
| 220 | 220 | } | |
| 221 | 221 | ||