Re: typecasting -- GtkItemFactoryEntry->callback_action
- From: Havoc Pennington <hp redhat com>
- To: Russell Francis <frussell p1 cs ohiou edu>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: typecasting -- GtkItemFactoryEntry->callback_action
- Date: 16 Aug 2001 18:34:49 -0400
Russell Francis <frussell p1 cs ohiou edu> writes:
I am using ItemFactory to build a menu system and it is working great, I
just have a question about the "proper" way to do something?
I wish for the activated menu item to call a function with a pointer
as a variable not a guint like the ItemFactory structure wants.
void function(GtkWidget *widget, gpointer data); NOT
void function(GtkWidget *widget, guint data);
The GtkItemFactoryEntry->callback_action is a guint so I have been
typecasting a gpointer to guint when initializing the GtkItemFactoryEntry
and then typecasting back to gpointer in the callback function. This is
working because (void *) and guint are the same size. I can't help but
think there is a better [and less likly to break :-] way to do this.
Yeah, casting pointer to uint is not portable.
You just want to keep a mapping from uint to pointer somewhere. Maybe
a hash table or array.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]