Fun with Gtk+/Gnome args



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:

/*** Test program ***/

#include <gtk/gtk.h>

void test( void );

static GtkType gtk_type;

int main( int argc, char *argv[] )
{

  gtk_init( &argc, &argv );

  GTK_TYPE_BUTTON;

  /* Get the GtkType, and make sure the class is loaded */
  gtk_type = gtk_type_from_name( "GtkButton" );
  gtk_type_class( gtk_type );

  test();
  test();

  return 0;
}

void test( void )
{
  GtkArgInfo *arg_info   = g_new0( GtkArgInfo, 1 );
  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 ); 
}


/*** 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





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