Gtk+ Item Factory Problem

Started by
6 comments, last by ontheheap 19 years, 5 months ago
This is my menu:

static GtkItemFactoryEntry menu_items[] = {
	
	{ "/_File",NULL,NULL,0,"<Branch>" },
	{ "/File/_New Game",NULL,new_game,0,"<StockItem>", 	GTK_STOCK_NEW 	},
	{ "/File/sep1",	NULL,NULL,0,"<Separator>" },
	{ "/File/_Quit",NULL,gtk_main_quit,0,"<StockItem>", GTK_STOCK_QUIT },
	
	{ "/_Network",NULL,NULL,0,"<Branch>" },
	{ "/Network/_Host Game",NULL,NULL,0,"<Item>" },
	{ "/Network/_Connect",NULL,NULL,0,"<Item>" },
	
	{ "/_Settings",NULL,NULL,0,"<Branch>" },
	{ "/Settings/Colors",NULL,NULL,0,"<Item>" },
	{ "/Settings/AI",NULL,NULL,0,"<Item>" },
	
};

The problem is new_game, which is:

static void new_game(GtkWidget *w, gpointer data)
{
	g_message("Starting new single player game\n");
	// start a new single player game
}

And I'm getting the following error: menu.h:35: error: invalid conversion from `void (*)(GtkWidget*, void*)' to ` void (*)()' So I went to gtk.org/tutorial to see if they had any example code and I found this. I copy/pasted the code from that page thinking I would be able to figure out what I was doing wrong but noooo, that code gives me the same error. Other than that everything works fine. Any ideas?
Advertisement
Almost on page 3 and no response? *bump 2 teh ump-ski" =)
are you compiling with gcc or g++?
I'm using g++. gcc gives me the following error:


/tmp/ccPDikiA.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

Here's the dealio.

You're using C++ stuff with GTK+. That's bad.

GTK+ expects C's MUCH relaxed rules about casting. Essentially, that's not an error....unless you're using a C++ compiler.

So.... either drop the C++ junk or use gtkmm.

edit: oh yeah, or explicitly cast. It's ugly, but that error really isn't an error, so...
OK, switching over to c has completely screwed up everything. I'm getting a ton of undefined errors. At least I know where I was going wrong though. Thanks.
lol. what's become undefined? anything other than expected stuff? (new/delete/etc)
Well, I've since scrapped the code (only like 100 lines, no big loss), but I was getting about 30 undefined errors to just about every gtk function and macro I was using. I tried compiling it manually using `pkg-config` thinking perhaps the IDE was screwing something up, but I got the same errors. I'm sure it was just something with how I had the code organized.

I seriously don't want to code in C anymore. I took a look at gtkmm, but I'm starting to lean towards Qt. I've been playing around with some examples and whatnot and I'm very impressed. Plus I'd like to (someday) contribute code to KDE, and since they use Qt it's makes more sense to learn that over Gtk+.



This topic is closed to new replies.

Advertisement