Re: [gtk-list] Help With Menu Accelerators and GtkItemFactor



If you are using gtk_item_factory_create_items(), the last
parameter is the callback data which gets passed to all
the callbacks.  (Which if I understand your message, is how
your code is currently set up).

 void gtk_item_factory_create_items( GtkItemFactory *ifactory,
guint n_entries, GtkItemFactoryEntry *entries,
gpointer callback_data)

If you need to pass different data to different
callbacks (as you were probably doing with manual menu
creation (??)), you could use the singular form,
gtk_item_factory_create_item()
which ties the callback data to that entry in the item_factory array.

void gtk_item_factory_create_item( GtkItemFactory *ifactory,
GtkItemFactoryEntry *entry, gpointer callback_data,
guint callback_type)

Of course, this only creates one item factory entity, rather than
parsing the entire array, so you still have to create the other entries.
The callback_type (4th parameter) also gives you some control
over the function prototype of the callback - in case you'd like it
to look more like the callbacks you've used before.

Hope this helps,
Donna

P.S. Yes, I'd stay away from globals.  But, that'll start a whole
new C flameing topic!

----- Original Message -----
From: VAB <alexb@ufl.edu>
To: gtk list <gtk-list@redhat.com>
Sent: Monday, August 30, 1999 11:51 AM
Subject: [gtk-list] Help With Menu Accelerators and GtkItemFactor


> Hello, I'm working on developing a GTK 1.2.4 application.  I am
> currently wondering how to pass gpointers through menu item
> callback functions when my menus have been created through the
> item factory.
>
> In an older version of the application I wrote, I used manual
> menu creation.  I'm currently attempting to switch the app
> over to the use of the Item Factory.  I was able to create
> the menus OK, but I don't understand how to pass a pointer
> to a structure which my menu items need access to.  I
> was doing this with gtk_signal_connect.  But I don't
> understand how to tell the callback to pass the gpointer
> when I'm using the Item Factory.  I was unable to find an
> explanation of how to do this in any of the GTK
> documentation and all of the GTK applications I've looked
> t (gzilla, gIDE, gEdit) used their own menu construction
> code which I found very confusing.
>
> Currently my app's datastructures are all linked into a
> large struct which I pass around my application code as
> a gpointer.  Is this how gtk apps are normally written
> or am I missing something?  I'd rather not just make
> everything global as that doesn't seem logical to me.
> However, I am finding passing data around difficult in
> GTK - I come from an OO background and don't have much
> experience with non-OO programing.  I do not wish to
> use gtk-- to write my app.
>
> Thanks.
>
>         - VAB
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
/dev/null
>
>
>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]