Jump to content
  • Advertisement
Sign in to follow this  
ontheheap

Gtk+ Item Factory Problem

This topic is 5162 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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+.



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!