Re: Item Factory Entry Callback Data
- From: Tim Janik <timj gtk org>
- To: Shaw Terwilliger <sterwill postman abisource com>
- cc: Gtk+ MList <gtk-list redhat com>
- Subject: Re: Item Factory Entry Callback Data
- Date: Fri, 20 Nov 1998 14:29:22 +0100 (CET)
On Wed, 18 Nov 1998, Shaw Terwilliger wrote:
> I've got a basic design question about the item factory's
> callback mechanisms. As it stands, it looks like the factory
> only allows a single callback_data item across all factory
> items. Each entry has a callback_type parameter, which
> looks like it would hold some very basic callback data dear
> to each entry, but there doesn't appear to be a way to
> assign real data (through a pointer) to each individual item.
>
> >From gtk/gtkitemfactory.h:
>
> void gtk_item_factory_create_item (GtkItemFactory
> *ifactory,
> GtkItemFactoryEntry *entry,
> gpointer
> callback_data,
> guint
> callback_type);
> void gtk_item_factory_create_items (GtkItemFactory
> *ifactory,
> guint
> n_entries,
> GtkItemFactoryEntry
> *entries,
> gpointer
> callback_data);
> void gtk_item_factory_create_items_ac(GtkItemFactory
> *ifactory,
> guint
> n_entries,
> GtkItemFactoryEntry
> *entries,
> gpointer
> callback_data,
> guint
> callback_type);
>
> Each of these creation methods take a single callback_data
> element, which is passed to the appropriate callback (an
> attribute of each entry) on activate.
>
> In short, I'd really like to be able to set individual callback
> data elements for each entry, so that each menu item (in my
> case) can identify itself to the callback. We're using a
> single, static callback handler as the callback for each
> menu item (somewhat neccessary in C++), instead of writing
> multitudes of static callbacks for each menu item. In fact,
> since we have run-time changable menus, this would be near
> impossible.
use gtk_item_factory_create_item() and its associated callback_data pointer.
if you use gtk_item_factory_create_items() all items get the same callback_data
pointer assigned, this is intentional behaviour since you'd usually do something
like:
void
gtk_item_factory_create_items (ifac,
sizeof (entries) / sizeof (entries[0]),
entries,
window);
with all entries having different callback_action values, e.g. from
an enum, so you can later:
enum {
MY_APP_LOAD,
MY_APP_SAVE,
MY_APP_QUIT
};
static void
ifactory_callback (GtkWidget *window,
guint callback_action,
GtkWidget *menu_item)
{
switch (callback_action)
{
case MY_APP_LOAD:
case MY_APP_SAVE:
case MY_APP_QUIT:
}
}
>
> Shaw Terwilliger
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]