Re: Using g_type_fronm_name ()


Ariel Rios <ariel gnu org> writes:

> How is g_type_from_name() suppose to work?
> I do not know what arg to pass to the function?
> I have tried with 'GtkWidget', "GtkType", etc to no avail.
> int
> main(){
> g_print ("hello\n");
> printf ("%ld\n", g_type_from_name ("GtkWidget"));
> return 1;
> }

g_type_from_name() can only work with types that have already been
registered with the type system. Try something like this instead:

  g_type_init ();
  g_type_class_ref (GTK_TYPE_WIDGET);
  g_print ("GtkObject: %ld\n", g_type_from_name ("GtkObject"));
  g_print ("GtkWidget: %ld\n", g_type_from_name ("GtkWidget"));
  return 0;

Salut, Sven

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