Not understanding the g_type_from_name() behaviour
- From: Marc Balmer <marc msys ch>
- To: gtk-app-devel-list gnome org
- Subject: Not understanding the g_type_from_name() behaviour
- Date: Sun, 13 May 2012 10:37:16 +0200
I have a (hopefully) basic question. g_type_from_name() does not behave
as I would it expect to behave:
When I call it with e.g. "GtkButton", I get GTK_TYPE_BUTTON. But when I
call it with "GtkFrame", it returns 0 (no such type found).
To add to my confusion, when I call "printf("%s\n",
g_type_name(GTK_TYPE_FRAME)" before calling g_type_from_name(), it
returns "GtkFrame" (as expected) and the following call to
g_type_from_name() succeeds as well.
I am obviously missing sth here, or making a stupid mistake, so any
pointers would be greatly appreciated.
- mb
#include <gtk/gtk.h>
int
main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
g_type_init();
/* Uncomment the following line, GtkFrame will be found */
/* printf("%s\n", g_type_name(GTK_TYPE_FRAME)); */
if (g_type_from_name("GtkFrame") == 0)
printf("no GtkFrame\n");
else
printf("GtkFrame exists\n");
if (g_type_from_name("GtkButton") == 0)
printf("no GtkButton\n");
else
printf("GtkButton exists\n");
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]