Package: gobject

Function g-object-set-data-full

Lambda List

g-object-set-data-full (object key data destroy)

Arguments

object -- g-object instance containing the associations
key -- a string with the name of the key
data -- data as a pointer to associate with that key
destroy -- callback function to call when the association is destroyed

Details

Like the g-object-data function except it adds notification for when the association is destroyed, either by setting it to a different value or when the object is destroyed.

Note that the destroy callback function is not called if the data argument is nil.

Note

You must define a callback function and pass the pointer of the callback function. See the example for the syntax to use.

Examples

This code example shows the usage of the g-object-set-data-full function with a destroy notify handler. The code is taken from the gtk-widget-factory demo.
;; Callback function for the destroy notify handler
(defcallback pulse-remove :void ((data :pointer))
  (g-source-remove (pointer-address data)))

;; Function called by the timeout handler (defun pulse-it (widget) ;; Pulse the widget which is an entry or a progress bar (if (eq 'gtk-entry (type-of widget)) (gtk-entry-progress-pulse widget) (gtk-progress-bar-pulse widget)) ;; Set a timeout handler and store the handler on the property list (g-object-set-data-full widget "pulse-id" (make-pointer (g-timeout-add *pulse-time* (lambda () (pulse-it widget)))) (callback pulse-remove)) ;; Remove the source +g-source-remove+)
 

See also

2021-9-11