Re: Passing data to menu callback
- From: Erik Andersen <andersen xmission com>
- To: halfline <halfline hawaii rr com>
- Cc: gnome-devel-list gnome org
- Subject: Re: Passing data to menu callback
- Date: Sat, 31 Jul 1999 23:58:51 -0600
On Sat, Jul 31, 1999 at 07:11:57PM -1000, halfline wrote:
> I'm trying to pass an integer through the user data field of the
> GNOMEUIINFO_ITEM_DATA
> macro. I pass it by casting it (gpointer) &var, but when i try to re case it
> back as integer it
> gives me some junk number.. y?
>
> Here are the functions that pertain to it
>
Your callback is getting a pointer to a widget... In
gnomehack, I do the following to pass an int through a menu
(nethack/win/gnome/GnomeHackMainWindow.c if you want to look
at the code in CVS):
GnomeUIInfo edit_menu[] = {
{
GNOME_APP_UI_ITEM, N_("Inventory"),
N_("Edit/View your Inventory"), ghack_accelerator_selected,
GINT_TO_POINTER('i'), NULL, GNOME_APP_PIXMAP_NONE, NULL, 'i', 0
},
etc....
}
static void
ghack_accelerator_selected (GtkWidget *widget, gpointer data)
{
GdkEventKey event;
int key = GPOINTER_TO_INT( data);
/* Do stuff with the key value */
}
Good luck,
-Erik
--
Erik B. Andersen Web: http://www.xmission.com/~andersen/
email: andersee@debian.org
--This message was written using 73% post-consumer electrons--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]