pass the GimpItemListView as "data" to the item_factory callbacks, not
2003-01-12 Michael Natterer <mitch@gimp.org> * app/widgets/gimpitemlistview.c: pass the GimpItemListView as "data" to the item_factory callbacks, not just a "Gimp" pointer. * app/display/gimpdisplayshell.c: use gtk_window_add_accel_group(), not gimp_window_add_accel_group() because we now attach the menubar's accel group, which has the GimpDisplay as callback data. * app/display/gimpdisplayshell-callbacks.c: pass the GimpDisplay as "popup_data" to *_item_factory_popup_with_data(). * app/gui/channels-commands.c * app/gui/drawable-commands.c * app/gui/layers-commands.c * app/gui/vectors-commands.c: changed accordingly. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_window_[add|remove]_accel_group() and gimp_widget_get_callback_context() because they were evil hacks which are no longer needed now that all item_factories have proper callback data (no just Gimp pointers).
This commit is contained in:
committed by
Michael Natterer
parent
6098d87148
commit
f44500aa69
@ -240,119 +240,6 @@ gimp_menu_position (GtkMenu *menu,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef struct _GimpAccelContextData GimpAccelContextData;
|
||||
|
||||
struct _GimpAccelContextData
|
||||
{
|
||||
GtkItemFactory *item_factory;
|
||||
GimpGetAccelContextFunc get_context_func;
|
||||
gpointer get_context_data;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
gimp_window_accel_key_press (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GimpAccelContextData *context_data)
|
||||
{
|
||||
gpointer accel_context;
|
||||
|
||||
accel_context =
|
||||
context_data->get_context_func (context_data->get_context_data);
|
||||
|
||||
g_object_set_data (G_OBJECT (context_data->item_factory),
|
||||
"gimp-accel-context", accel_context);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_window_accel_key_release (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GimpAccelContextData *context_data)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (context_data->item_factory),
|
||||
"gimp-accel-context", NULL);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_window_add_accel_group (GtkWindow *window,
|
||||
GtkItemFactory *item_factory,
|
||||
GimpGetAccelContextFunc get_context_func,
|
||||
gpointer get_context_data)
|
||||
{
|
||||
if (get_context_func)
|
||||
{
|
||||
GimpAccelContextData *context_data;
|
||||
|
||||
context_data = g_new0 (GimpAccelContextData, 1);
|
||||
|
||||
context_data->item_factory = item_factory;
|
||||
context_data->get_context_func = get_context_func;
|
||||
context_data->get_context_data = get_context_data;
|
||||
|
||||
g_object_set_data_full (G_OBJECT (window), "gimp-accel-conext-data",
|
||||
context_data,
|
||||
(GDestroyNotify) g_free);
|
||||
|
||||
g_signal_connect (window, "key_press_event",
|
||||
G_CALLBACK (gimp_window_accel_key_press),
|
||||
context_data);
|
||||
g_signal_connect (window, "key_release_event",
|
||||
G_CALLBACK (gimp_window_accel_key_release),
|
||||
context_data);
|
||||
}
|
||||
|
||||
gtk_window_add_accel_group (window, item_factory->accel_group);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_window_remove_accel_group (GtkWindow *window,
|
||||
GtkItemFactory *item_factory)
|
||||
{
|
||||
GimpAccelContextData *context_data;
|
||||
|
||||
context_data = g_object_get_data (G_OBJECT (window),
|
||||
"gimp-accel-conext-data");
|
||||
|
||||
if (context_data)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (window,
|
||||
G_CALLBACK (gimp_window_accel_key_press),
|
||||
context_data);
|
||||
g_signal_handlers_disconnect_by_func (window,
|
||||
G_CALLBACK (gimp_window_accel_key_release),
|
||||
context_data);
|
||||
|
||||
g_object_set_data (G_OBJECT (window), "gimp-accel-conext-data", NULL);
|
||||
}
|
||||
|
||||
gtk_window_remove_accel_group (window, item_factory->accel_group);
|
||||
}
|
||||
|
||||
gpointer
|
||||
gimp_widget_get_callback_context (GtkWidget *widget)
|
||||
{
|
||||
GtkItemFactory *ifactory;
|
||||
gpointer popup_context;
|
||||
gpointer accel_context = NULL;
|
||||
|
||||
ifactory = gtk_item_factory_from_widget (widget);
|
||||
|
||||
popup_context = gtk_item_factory_popup_data_from_widget (widget);
|
||||
|
||||
if (ifactory)
|
||||
accel_context = g_object_get_data (G_OBJECT (ifactory),
|
||||
"gimp-accel-context");
|
||||
|
||||
if (popup_context)
|
||||
return popup_context;
|
||||
|
||||
return accel_context;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_table_attach_stock (GtkTable *table,
|
||||
gint column,
|
||||
|
||||
Reference in New Issue
Block a user