Thanks for answering. So basically...
(About the g_object_weak_ref)

GDate *date = g_date_new_dmy (1,1,2006);
GtkEntry *entry = gtk_entry_new ();

g_object_weak_ref (G_OBJECT (entry),
                                (GWeakNotify) g_date_free,
                                date);

After doing this, before entry is freed gtk would call g_date_free and 
free date. Am i wrong? I tried this with a GWeakNotify function that 
just prints something, but it didn't seem to work.

There's something else, i want to add more reference to other dates, to 
new ones, if i want them to be week referenced i'd have to call

g_object_add_weak_pointer ( 
<http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#GObject>G_OBJECT
 (entry), another_date);

or

g_object_weak_ref again?


Thanks anyway! Matias

Nikhil Dinesh escribió:
>> *- Is there a way to pass a function to free certain struct in a 
>> GtkTreeModel so GTK frees the allocated space when the model's reference 
>> count reach to 0? (without registering it as a G_TYPE).*
>>   
>>     
>
> One way is to register the struct as a "weak reference" to the model, 
> using g_object_weak_ref. See:
>
> http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html
>   
>> *- When reference count starts? I read somewhere that it starts when you 
>> add the widget into a container, is it always this way??? Eg:*
>>   
>>     
> Reference counting starts when an object is created. In your example:
>
>    GtkWidget *entry = gtk_entry_new ();
>
> After this statement, there is one reference to the entry. When 
> gtk_container_add is invoked, it takes over ownership of this 
> reference.  That is when the container is destroyed, g_object_unref is 
> invoked on the entry. So one needs to invoke destroy only on the root 
> widget (typically).
>
>   
>> //*No reference counting on GtkEntry*//
>>     GtkWidget *entry = gtk_entry_new ();
>> //*Reference counting starts here *//
>>     gtk_container_add (GTK_CONTAINER (window), entry);/
>> /* Another doubt: in this case, reference couting starts with 1 or 2? */
>> /
>> -* If i get a string from a GtkTreeModel, it gives me a copy or the 
>> actual pointer to the data?
>>   
>>     
> If you're using the get_value method on the iterator, the object is 
> "copied" into the GValue supplied. Typically this gives you just a 
> reference, and invoking g_value_unset results in just decrementing the  
> reference count. But what exactly happens during copying depends on your 
> object. See:
>
> http://developer.gnome.org/doc/API/2.0/gobject/gobject-Generic-values.html
>
>   
>> *That's it, thanks in advance. Matias.
>> _______________________________________________
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>>   
>>     
>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
>   

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to