Commit f44500aa authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

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).
parent 6098d871
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).
2003-01-12 Dave Neary <bolsh@gimp.org>
* plug-ins/common/plugin-def.pl
......@@ -94,7 +118,6 @@
* app/gui/images-commands.c
* app/gui/palette-editor-commands.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c: simply cast the passed "data"
pointer instead of calling gimp_widget_get_callback_context().
Don't #include "widgets/gimpwidgets-utils.h".
......
......@@ -37,8 +37,8 @@
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpitemlistview.h"
#include "widgets/gimpviewabledialog.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
......@@ -58,13 +58,15 @@ static void channels_color_changed (GimpColorButton *button,
#define return_if_no_image(gimage,data) \
gimage = (GimpImage *) gimp_widget_get_callback_context (widget); \
if (! GIMP_IS_IMAGE (gimage)) { \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
} \
else if (GIMP_IS_ITEM_LIST_VIEW (data)) \
gimage = ((GimpItemListView *) data)->gimage; \
else \
gimage = NULL; \
\
if (! gimage) \
return
......@@ -548,7 +550,7 @@ channels_menu_update (GtkItemFactory *factory,
GList *next = NULL;
GList *prev = NULL;
gimage = GIMP_IMAGE (data);
gimage = GIMP_ITEM_LIST_VIEW (data)->gimage;
channel = gimp_image_get_active_channel (gimage);
......
......@@ -35,7 +35,7 @@
#include "core/gimpimage.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpitemlistview.h"
#include "display/gimpdisplay.h"
......@@ -46,13 +46,15 @@
#define return_if_no_image(gimage,data) \
gimage = (GimpImage *) gimp_widget_get_callback_context (widget); \
if (! GIMP_IS_IMAGE (gimage)) { \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
} \
else if (GIMP_IS_ITEM_LIST_VIEW (data)) \
gimage = ((GimpItemListView *) data)->gimage; \
else \
gimage = NULL; \
\
if (! gimage) \
return
......
......@@ -42,8 +42,8 @@
#include "widgets/gimpenummenu.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpitemlistview.h"
#include "widgets/gimpviewabledialog.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
......@@ -65,13 +65,15 @@ static void layers_resize_layer_query (GimpImage *gimage,
#define return_if_no_image(gimage,data) \
gimage = (GimpImage *) gimp_widget_get_callback_context (widget); \
if (! GIMP_IS_IMAGE (gimage)) { \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
} \
else if (GIMP_IS_ITEM_LIST_VIEW (data)) \
gimage = ((GimpItemListView *) data)->gimage; \
else \
gimage = NULL; \
\
if (! gimage) \
return
......@@ -1166,7 +1168,7 @@ layers_menu_update (GtkItemFactory *factory,
GList *next = NULL;
GList *prev = NULL;
gimage = GIMP_IMAGE (data);
gimage = GIMP_ITEM_LIST_VIEW (data)->gimage;
layer = gimp_image_get_active_layer (gimage);
......
......@@ -42,8 +42,8 @@
#include "vectors/gimpvectors.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpitemlistview.h"
#include "widgets/gimpviewabledialog.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
......@@ -59,15 +59,15 @@
#define return_if_no_image(gimage,data) \
gimage = (GimpImage *) gimp_widget_get_callback_context (widget); \
if (! GIMP_IS_IMAGE (gimage)) { \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_ITEM_LIST_VIEW (data)) \
gimage = ((GimpItemListView *) data)->gimage; \
else \
gimage = NULL; \
} \
\
if (! gimage) \
return
......@@ -640,7 +640,7 @@ vectors_menu_update (GtkItemFactory *factory,
GList *next = NULL;
GList *prev = NULL;
gimage = GIMP_IMAGE (data);
gimage = GIMP_ITEM_LIST_VIEW (data)->gimage;
vectors = gimp_image_get_active_vectors (gimage);
......
......@@ -612,7 +612,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case 3:
state |= GDK_BUTTON3_MASK;
gimp_item_factory_popup_with_data (shell->popup_factory,
gimage,
gdisp,
NULL);
return_val = TRUE;
break;
......@@ -990,6 +990,8 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
{
/* Hide or show all dialogs */
g_print ("toggle dialogs\n");
gimp_dialog_factories_toggle (global_toolbox_factory);
}
......@@ -1574,7 +1576,7 @@ gimp_display_shell_origin_menu_popup (GimpDisplayShell *shell,
shell->origin);
gtk_item_factory_popup_with_data (factory,
shell->gdisp->gimage,
shell->gdisp,
NULL,
x, y,
button, time);
......
......@@ -54,7 +54,6 @@
#include "widgets/gimpdnd.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui/info-window.h"
#include "gui/plug-in-menus.h"
......@@ -101,8 +100,6 @@ static void gimp_display_shell_destroy (GtkObject *object
static gboolean gimp_display_shell_delete_event (GtkWidget *widget,
GdkEventAny *aevent);
static gpointer gimp_display_shell_get_accel_context (gpointer data);
static void gimp_display_shell_display_area (GimpDisplayShell *shell,
gint x,
gint y,
......@@ -495,10 +492,8 @@ gimp_display_shell_new (GimpDisplay *gdisp,
FALSE);
/* The accelerator table for images */
gimp_window_add_accel_group (GTK_WINDOW (shell),
GTK_ITEM_FACTORY (shell->menubar_factory),
gimp_display_shell_get_accel_context,
shell);
gtk_window_add_accel_group (GTK_WINDOW (shell),
GTK_ITEM_FACTORY (shell->menubar_factory)->accel_group);
/* GtkTable widgets are not able to shrink a row/column correctly if
* widgets are attached with GTK_EXPAND even if those widgets have
......@@ -1845,19 +1840,6 @@ gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
/* private functions */
static gpointer
gimp_display_shell_get_accel_context (gpointer data)
{
GimpDisplayShell *shell;
shell = (GimpDisplayShell *) data;
if (shell)
return shell->gdisp->gimage;
return NULL;
}
static void
gimp_display_shell_display_area (GimpDisplayShell *shell,
gint x,
......
......@@ -54,7 +54,6 @@
#include "widgets/gimpdnd.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "gui/info-window.h"
#include "gui/plug-in-menus.h"
......@@ -101,8 +100,6 @@ static void gimp_display_shell_destroy (GtkObject *object
static gboolean gimp_display_shell_delete_event (GtkWidget *widget,
GdkEventAny *aevent);
static gpointer gimp_display_shell_get_accel_context (gpointer data);
static void gimp_display_shell_display_area (GimpDisplayShell *shell,
gint x,
gint y,
......@@ -495,10 +492,8 @@ gimp_display_shell_new (GimpDisplay *gdisp,
FALSE);
/* The accelerator table for images */
gimp_window_add_accel_group (GTK_WINDOW (shell),
GTK_ITEM_FACTORY (shell->menubar_factory),
gimp_display_shell_get_accel_context,
shell);
gtk_window_add_accel_group (GTK_WINDOW (shell),
GTK_ITEM_FACTORY (shell->menubar_factory)->accel_group);
/* GtkTable widgets are not able to shrink a row/column correctly if
* widgets are attached with GTK_EXPAND even if those widgets have
......@@ -1845,19 +1840,6 @@ gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
/* private functions */
static gpointer
gimp_display_shell_get_accel_context (gpointer data)
{
GimpDisplayShell *shell;
shell = (GimpDisplayShell *) data;
if (shell)
return shell->gdisp->gimage;
return NULL;
}
static void
gimp_display_shell_display_area (GimpDisplayShell *shell,
gint x,
......
......@@ -37,8 +37,8 @@
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpitemlistview.h"
#include "widgets/gimpviewabledialog.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
......@@ -58,13 +58,15 @@ static void channels_color_changed (GimpColorButton *button,
#define return_if_no_image(gimage,data) \
gimage = (GimpImage *) gimp_widget_get_callback_context (widget); \
if (! GIMP_IS_IMAGE (gimage)) { \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
} \
else if (GIMP_IS_ITEM_LIST_VIEW (data)) \
gimage = ((GimpItemListView *) data)->gimage; \
else \
gimage = NULL; \
\
if (! gimage) \
return
......@@ -548,7 +550,7 @@ channels_menu_update (GtkItemFactory *factory,
GList *next = NULL;
GList *prev = NULL;
gimage = GIMP_IMAGE (data);
gimage = GIMP_ITEM_LIST_VIEW (data)->gimage;
channel = gimp_image_get_active_channel (gimage);
......
......@@ -35,7 +35,7 @@
#include "core/gimpimage.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "widgets/gimpitemlistview.h"
#include "display/gimpdisplay.h"
......@@ -46,13 +46,15 @@
#define return_if_no_image(gimage,data) \
gimage = (GimpImage *) gimp_widget_get_callback_context (widget); \
if (! GIMP_IS_IMAGE (gimage)) { \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
} \
else if (GIMP_IS_ITEM_LIST_VIEW (data)) \
gimage = ((GimpItemListView *) data)->gimage; \
else \
gimage = NULL; \
\
if (! gimage) \
return
......
......@@ -42,8 +42,8 @@
#include "widgets/gimpenummenu.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpitemlistview.h"
#include "widgets/gimpviewabledialog.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
......@@ -65,13 +65,15 @@ static void layers_resize_layer_query (GimpImage *gimage,
#define return_if_no_image(gimage,data) \
gimage = (GimpImage *) gimp_widget_get_callback_context (widget); \
if (! GIMP_IS_IMAGE (gimage)) { \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
} \
else if (GIMP_IS_ITEM_LIST_VIEW (data)) \
gimage = ((GimpItemListView *) data)->gimage; \
else \
gimage = NULL; \
\
if (! gimage) \
return
......@@ -1166,7 +1168,7 @@ layers_menu_update (GtkItemFactory *factory,
GList *next = NULL;
GList *prev = NULL;
gimage = GIMP_IMAGE (data);
gimage = GIMP_ITEM_LIST_VIEW (data)->gimage;
layer = gimp_image_get_active_layer (gimage);
......
......@@ -42,8 +42,8 @@
#include "vectors/gimpvectors.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpitemlistview.h"
#include "widgets/gimpviewabledialog.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
......@@ -59,15 +59,15 @@
#define return_if_no_image(gimage,data) \
gimage = (GimpImage *) gimp_widget_get_callback_context (widget); \
if (! GIMP_IS_IMAGE (gimage)) { \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_ITEM_LIST_VIEW (data)) \
gimage = ((GimpItemListView *) data)->gimage; \
else \
gimage = NULL; \
} \
\
if (! gimage) \
return
......@@ -640,7 +640,7 @@ vectors_menu_update (GtkItemFactory *factory,
GList *next = NULL;
GList *prev = NULL;
gimage = GIMP_IMAGE (data);
gimage = GIMP_ITEM_LIST_VIEW (data)->gimage;
vectors = gimp_image_get_active_vectors (gimage);
......
......@@ -357,7 +357,7 @@ gimp_item_list_view_new (gint preview_size,
list_view->item_factory = gimp_menu_factory_menu_new (menu_factory,
menu_identifier,
GTK_TYPE_MENU,
menu_factory->gimp,
list_view,
FALSE);
/* connect "drop to new" manually as it makes a difference whether
......@@ -536,7 +536,7 @@ gimp_item_list_view_context_item (GimpContainerView *view,
gimage = gimp_item_get_image (GIMP_ITEM (item));
gimp_item_factory_popup_with_data (item_view->item_factory,
gimage,
item_view,
NULL);
}
}
......
......@@ -357,7 +357,7 @@ gimp_item_list_view_new (gint preview_size,
list_view->item_factory = gimp_menu_factory_menu_new (menu_factory,
menu_identifier,
GTK_TYPE_MENU,
menu_factory->gimp,
list_view,
FALSE);
/* connect "drop to new" manually as it makes a difference whether
......@@ -536,7 +536,7 @@ gimp_item_list_view_context_item (GimpContainerView *view,
gimage = gimp_item_get_image (GIMP_ITEM (item));
gimp_item_factory_popup_with_data (item_view->item_factory,
gimage,
item_view,
NULL);
}
}
......
......@@ -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,
......
......@@ -36,15 +36,6 @@ void gimp_menu_position (GtkMenu *menu,
guint *button,
guint32 *activate_time);
void gimp_window_add_accel_group (GtkWindow *window,
GtkItemFactory *item_factory,
GimpGetAccelContextFunc get_context_func,
gpointer get_context_data);
void gimp_window_remove_accel_group (GtkWindow *window,
GtkItemFactory *item_factory);
gpointer gimp_widget_get_callback_context (GtkWidget *widget);
void gimp_table_attach_stock (GtkTable *table,
gint column,
gint row,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment