Re: callback_data in Gtk2::SimpleMenu [and Gtk2::ItemFactory (well, Gtk2.pm)]



[Sorry, I ment for my reply to go to the list. I'm sending this
message there as well.]

On Sun, 01 Feb 2004, Ross McFarland wrote:
On Sun, 2004-02-01 at 16:41, Don Armstrong wrote:
It looks like you actually get n+1 callback_data per call to
create_items where n is the number of GtkItemFactoryEntry you
have.

nope. gtk_item_factory_create_items is not var arg's so you get 1
user_data per call, it takes a single user_data that is used for all
the entries' callbacks.

It has a single callback_data [which is quite different from
user_data] for the function, and each GtkItemFactoryEntry has a
GtkItemFactoryCallback1 which has it's own callback_data as well as a
callback:

void        (*GtkItemFactoryCallback1)      (gpointer callback_data,
                                             guint callback_action,
                                             GtkWidget *widget);

[I don't quite understand why you're talking about user_data in the
section that I've snipped... that's a totally different issue than the
callback_data.]

SimpleMenu probably should be passing a hashref instead of an
arrayref per entry like it is currently doing... that will
alleviate some of the dependency on exact function order.

not at all, it's a lot of extra over-head for no reason, it's hidden
from the user and so long as it's kept in sync with the
implementation of itemfactory (which it can and will have to be
since they're released together and tested well) the lowest overhead
is the best.

The current stable version of create_item already supports being
called with a hashref, so the overhead argument, while plausible,
isn't important since you've already added in the
overhead. Furthermore, that second of code is only being called once
per menu creation. Worrying about optimization there is kind of silly,
IMO.


Don Armstrong

-- 
If you have the slightest bit of intellectual integrity you cannot
support the government. -- anonymous

http://www.donarmstrong.com
http://www.anylevel.com
http://rzlab.ucr.edu



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