gtkObjectRef {RGtk}R Documentation

Increment and decrement GtkObject references

Description

This allows the R programmer to explicitly increment and decrement the references to a GtkObject. This is useful, indeed necessary, if one needs to ensure that a particular GtkObject needs to exist even if it would be garbage collected by Gtk's own reference mechanism. For example, if we remove a GtkWidget from a GUI but want to use it later, we should increase the reference count by 1 before removing it and decrement it after we have added it to the new GUI.

Usage

gtkObjectRef(obj)
gtkObjectUnref(obj)

Arguments

obj the GtkObject whose reference count is to be altered.

Details

These functions are direct interfaces to the gtk_object_ref and gtk_object_unref routines in the Gtk library.

Value

Author(s)

Duncan Temple Lang <duncan@research.bell-labs.com>

References

Information on the package is available from http://www.omegahat.org/RGtk.

Information on Gtk is available from http://www.gtk.org.

See Also

gtkContainerRemove

Examples

## Don't run: 
 win = gtkWindow()
 b1 = gtkButton("A button")
 b2 = gtkButton("Another button")

 b1$Ref()
 b2$Ref()

 b1$AddCallback("clicked",
                   function(b, w)  {
                      win$Remove(w)
                      win$Add(b)
                   }, b2)
 b2$AddCallback("clicked",
                   function(b, w)  {
                      win$Remove(w)
                      win$Add(b)
                   }, b1)

 win$AddCallback("destroy",
                  function(obj) {
                    b1$Unref()
                    b2$Unref()
                  })
## End Don't run 

[Package Contents]