gtkObjectRef              package:RGtk              R Documentation

_I_n_c_r_e_m_e_n_t _a_n_d _d_e_c_r_e_m_e_n_t _G_t_k_O_b_j_e_c_t _r_e_f_e_r_e_n_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     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.

_U_s_a_g_e:

     gtkObjectRef(obj)
     gtkObjectUnref(obj)

_A_r_g_u_m_e_n_t_s:

     obj: the GtkObject whose reference count is to be altered.

_D_e_t_a_i_l_s:

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

_V_a_l_u_e:

_A_u_t_h_o_r(_s):

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

_R_e_f_e_r_e_n_c_e_s:

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

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

_S_e_e _A_l_s_o:

     'gtkContainerRemove'

_E_x_a_m_p_l_e_s:

     ## Not 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(Not run) 

