Re: Fun with Gtk+/Gnome args



gtk_object_get_arg_info (...) gives you a pointer to system arginfo
struct
associated with class. So better do not try freeing it ;)

Lauris

> I am trying to use the type system in Gtk+/Gnome to do some
> introspection.  The first time I call gtk_object_arg_get_info() all goes
> well.  Subsequent calls, however, fail.  Here is a small test program
> that exhibits the problem:
/.../
> void test( void )
> {
>   GtkArgInfo *arg_info   = g_new0( GtkArgInfo, 1 );

You do not have to allocate it, because pointer will be set pointing to
class arginfo struct

>   gchar      *msg        = NULL;
>   gchar      *arg_name      = "can_focus";
>   gchar      *arg_value     = "True";
> 
>   /* Get argument info for this argument */
>   msg = gtk_object_arg_get_info( gtk_type, arg_name, &arg_info );  
>   if( NULL == msg ) /* all went ok */
>     {
>       g_print( "%s\n", arg_value );
>     }
>   else 
>     {
>       g_print( "%s\n", msg );
>       g_free( msg );
>     }
> 
>   g_free( arg_info ); 

 Â Â Â ^--------- DO NOT DO THAT

> }
> 
> 
> /*** End test program ***/
> 
> Running this program gives the following output:
> 
> True
> could not find argument "can_focus" in the `GtkButton' class ancestry
> 
> 
> Any ideas what would cause this behavior?  Help much appreciated!
> 
> John
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> _______________________________________________
> gnome-devel-list mailing list
> gnome-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gnome-devel-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]