Item Factory Entry Callback Data



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.

Couldn't this be implemented easily by modifying:

struct _GtkItemFactoryEntry
{
  gchar *path;
  gchar *accelerator;

  GtkItemFactoryCallback callback;
  guint                  callback_action;
  gchar          *item_type;
};

to include a "void * callback_data" element, and having the 
factory honor that element before looking at the create()
argument?

-- 
Shaw Terwilliger



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