added some utility functions to get a Gimp, GimpImage, GimpDisplay and

2004-05-03  Michael Natterer  <mitch@gimp.org>

	* app/actions/actions.[ch]: added some utility functions to get a
	Gimp, GimpImage, GimpDisplay and GtkWidget from the "data" pointer
	passed to action callbacks.

	* app/actions/channels-actions.c
	* app/actions/channels-commands.c
	* app/actions/drawable-actions.c
	* app/actions/drawable-commands.c
	* app/actions/edit-actions.c
	* app/actions/edit-commands.c
	* app/actions/file-actions.c
	* app/actions/file-commands.c
	* app/actions/help-commands.c
	* app/actions/image-actions.c
	* app/actions/image-commands.c
	* app/actions/layers-actions.c
	* app/actions/layers-commands.c
	* app/actions/plug-in-actions.c
	* app/actions/plug-in-commands.c
	* app/actions/qmask-actions.c
	* app/actions/qmask-commands.c
	* app/actions/select-actions.c
	* app/actions/select-commands.c
	* app/actions/tools-commands.c
	* app/actions/vectors-actions.c
	* app/actions/vectors-commands.c
	* app/actions/view-commands.c: use the new functions instead of
	duplicating insane macros and if() constructs over and over again.
This commit is contained in:
Michael Natterer 2004-05-03 14:03:51 +00:00 committed by Michael Natterer
parent 3c38214c27
commit d745841e4d
28 changed files with 267 additions and 531 deletions

View File

@ -1,3 +1,34 @@
2004-05-03 Michael Natterer <mitch@gimp.org>
* app/actions/actions.[ch]: added some utility functions to get a
Gimp, GimpImage, GimpDisplay and GtkWidget from the "data" pointer
passed to action callbacks.
* app/actions/channels-actions.c
* app/actions/channels-commands.c
* app/actions/drawable-actions.c
* app/actions/drawable-commands.c
* app/actions/edit-actions.c
* app/actions/edit-commands.c
* app/actions/file-actions.c
* app/actions/file-commands.c
* app/actions/help-commands.c
* app/actions/image-actions.c
* app/actions/image-commands.c
* app/actions/layers-actions.c
* app/actions/layers-commands.c
* app/actions/plug-in-actions.c
* app/actions/plug-in-commands.c
* app/actions/qmask-actions.c
* app/actions/qmask-commands.c
* app/actions/select-actions.c
* app/actions/select-commands.c
* app/actions/tools-commands.c
* app/actions/vectors-actions.c
* app/actions/vectors-commands.c
* app/actions/view-commands.c: use the new functions instead of
duplicating insane macros and if() constructs over and over again.
2004-05-03 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpwidgets.c: use a GimpFrame for

View File

@ -25,8 +25,18 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "widgets/gimpactionfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpimageeditor.h"
#include "widgets/gimpitemtreeview.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "gui/dialogs.h"
#include "brushes-actions.h"
#include "buffers-actions.h"
@ -201,3 +211,82 @@ actions_exit (Gimp *gimp)
g_object_unref (global_action_factory);
global_action_factory = NULL;
}
Gimp *
action_data_get_gimp (gpointer data)
{
if (! data)
return NULL;
if (GIMP_IS_DISPLAY (data))
return ((GimpDisplay *) data)->gimage->gimp;
else if (GIMP_IS_DISPLAY_SHELL (data))
return ((GimpDisplayShell *) data)->gdisp->gimage->gimp;
else if (GIMP_IS_ITEM_TREE_VIEW (data))
return ((GimpItemTreeView *) data)->gimage->gimp;
else if (GIMP_IS_IMAGE_EDITOR (data))
return ((GimpImageEditor *) data)->gimage->gimp;
else if (GIMP_IS_GIMP (data))
return data;
else if (GIMP_IS_DOCK (data))
return ((GimpDock *) data)->context->gimp;
return NULL;
}
GimpImage *
action_data_get_image (gpointer data)
{
if (! data)
return NULL;
if (GIMP_IS_DISPLAY (data))
return ((GimpDisplay *) data)->gimage;
else if (GIMP_IS_DISPLAY_SHELL (data))
return ((GimpDisplayShell *) data)->gdisp->gimage;
else if (GIMP_IS_ITEM_TREE_VIEW (data))
return ((GimpItemTreeView *) data)->gimage;
else if (GIMP_IS_IMAGE_EDITOR (data))
return ((GimpImageEditor *) data)->gimage;
else if (GIMP_IS_GIMP (data))
return gimp_context_get_image (gimp_get_user_context (data));
else if (GIMP_IS_DOCK (data))
return gimp_context_get_image (((GimpDock *) data)->context);
return NULL;
}
GimpDisplay *
action_data_get_display (gpointer data)
{
if (! data)
return NULL;
if (GIMP_IS_DISPLAY (data))
return data;
else if (GIMP_IS_DISPLAY_SHELL (data))
return ((GimpDisplayShell *) data)->gdisp;
else if (GIMP_IS_GIMP (data))
return gimp_context_get_display (gimp_get_user_context (data));
else if (GIMP_IS_DOCK (data))
return gimp_context_get_display (((GimpDock *) data)->context);
return NULL;
}
GtkWidget *
action_data_get_widget (gpointer data)
{
if (! data)
return NULL;
if (GIMP_IS_DISPLAY (data))
return ((GimpDisplay *) data)->shell;
else if (GIMP_IS_GIMP (data))
return dialogs_get_toolbox ();
else if (GTK_IS_WIDGET (data))
return data;
return NULL;
}

View File

@ -23,8 +23,13 @@
extern GimpActionFactory *global_action_factory;
void actions_init (Gimp *gimp);
void actions_exit (Gimp *gimp);
void actions_init (Gimp *gimp);
void actions_exit (Gimp *gimp);
Gimp * action_data_get_gimp (gpointer data);
GimpImage * action_data_get_image (gpointer data);
GimpDisplay * action_data_get_display (gpointer data);
GtkWidget * action_data_get_widget (gpointer data);
#endif /* __ACTIONS_H__ */

View File

@ -30,11 +30,8 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpcomponenteditor.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemtreeview.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "channels-actions.h"
#include "channels-commands.h"
@ -128,7 +125,7 @@ void
channels_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *gimage = NULL;
GimpImage *gimage;
GimpChannel *channel = NULL;
gboolean fs = FALSE;
gboolean component = FALSE;
@ -147,12 +144,7 @@ channels_actions_update (GimpActionGroup *group,
}
else
{
if (GIMP_IS_ITEM_TREE_VIEW (data))
gimage = GIMP_ITEM_TREE_VIEW (data)->gimage;
else if (GIMP_IS_DISPLAY_SHELL (data))
gimage = GIMP_DISPLAY_SHELL (data)->gdisp->gimage;
else if (GIMP_IS_DISPLAY (data))
gimage = GIMP_DISPLAY (data)->gimage;
gimage = action_data_get_image (data);
if (gimage)
{

View File

@ -30,7 +30,6 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpchannel-select.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
@ -38,13 +37,9 @@
#include "widgets/gimpcomponenteditor.h"
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemtreeview.h"
#include "widgets/gimpviewabledialog.h"
#include "display/gimpdisplay.h"
#include "gui/dialogs.h"
#include "actions.h"
#include "channels-commands.h"
#include "gimp-intl.h"
@ -59,19 +54,7 @@ static void channels_color_changed (GimpColorButton *button,
#define return_if_no_image(gimage,data) \
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_DOCK (data)) \
gimage = gimp_context_get_image (((GimpDock *) data)->context); \
else if (GIMP_IS_COMPONENT_EDITOR (data)) \
gimage = ((GimpImageEditor *) data)->gimage; \
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
gimage = ((GimpItemTreeView *) data)->gimage; \
else \
gimage = NULL; \
\
gimage = action_data_get_image (data); \
if (! gimage) \
return
@ -82,19 +65,7 @@ static void channels_color_changed (GimpColorButton *button,
return
#define return_if_no_widget(widget,data) \
if (GIMP_IS_DISPLAY (data)) \
widget = ((GimpDisplay *) data)->shell; \
else if (GIMP_IS_GIMP (data)) \
widget = dialogs_get_toolbox (); \
else if (GIMP_IS_DOCK (data)) \
widget = data; \
else if (GIMP_IS_COMPONENT_EDITOR (data)) \
widget = data; \
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
widget = data; \
else \
widget = NULL; \
\
widget = action_data_get_widget (data); \
if (! widget) \
return

View File

@ -33,9 +33,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "drawable-actions.h"
#include "drawable-commands.h"
@ -119,29 +117,16 @@ void
drawable_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
GimpImage *gimage = NULL;
GimpDrawable *drawable = NULL;
gboolean is_rgb = FALSE;
gboolean is_gray = FALSE;
gboolean is_indexed = FALSE;
GimpImage *gimage;
GimpDrawable *drawable = NULL;
gboolean is_rgb = FALSE;
gboolean is_gray = FALSE;
gboolean is_indexed = FALSE;
if (GIMP_IS_DISPLAY_SHELL (data))
{
shell = GIMP_DISPLAY_SHELL (data);
gdisp = shell->gdisp;
}
else if (GIMP_IS_DISPLAY (data))
{
gdisp = GIMP_DISPLAY (data);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
}
gimage = action_data_get_image (data);
if (gdisp)
if (gimage)
{
gimage = gdisp->gimage;
drawable = gimp_image_active_drawable (gimage);
if (drawable)

View File

@ -18,8 +18,6 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
@ -27,7 +25,6 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpdrawable-desaturate.h"
#include "core/gimpdrawable-equalize.h"
@ -36,31 +33,16 @@
#include "core/gimpimage-undo.h"
#include "core/gimpitem-linked.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpitemtreeview.h"
#include "display/gimpdisplay.h"
#include "gui/dialogs.h"
#include "gui/offset-dialog.h"
#include "actions.h"
#include "drawable-commands.h"
#include "gimp-intl.h"
#define return_if_no_image(gimage,data) \
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_DOCK (data)) \
gimage = gimp_context_get_image (((GimpDock *) data)->context); \
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
gimage = ((GimpItemTreeView *) data)->gimage; \
else \
gimage = NULL; \
\
gimage = action_data_get_image (data); \
if (! gimage) \
return
@ -71,17 +53,7 @@
return
#define return_if_no_widget(widget,data) \
if (GIMP_IS_DISPLAY (data)) \
widget = ((GimpDisplay *) data)->shell; \
else if (GIMP_IS_GIMP (data)) \
widget = dialogs_get_toolbox (); \
else if (GIMP_IS_DOCK (data)) \
widget = data; \
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
widget = data; \
else \
widget = NULL; \
\
widget = action_data_get_widget (data); \
if (! widget) \
return

View File

@ -36,11 +36,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-appearance.h"
#include "display/gimpdisplayshell-selection.h"
#include "actions.h"
#include "edit-actions.h"
#include "edit-commands.h"
@ -190,27 +186,14 @@ void
edit_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
GimpImage *gimage = NULL;
GimpDrawable *drawable = NULL;
gboolean sel = FALSE;
GimpImage *gimage;
GimpDrawable *drawable = NULL;
gboolean sel = FALSE;
if (GIMP_IS_DISPLAY_SHELL (data))
{
shell = GIMP_DISPLAY_SHELL (data);
gdisp = shell->gdisp;
}
else if (GIMP_IS_DISPLAY (data))
{
gdisp = GIMP_DISPLAY (data);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
}
gimage = action_data_get_image (data);
if (gdisp)
if (gimage)
{
gimage = gdisp->gimage;
sel = ! gimp_channel_is_empty (gimp_image_get_mask (gimage));
drawable = gimp_image_active_drawable (gimage);
@ -225,7 +208,7 @@ edit_actions_update (GimpActionGroup *group,
gchar *undo_name = NULL;
gchar *redo_name = NULL;
if (gdisp && gimp_image_undo_is_enabled (gimage))
if (gimage && gimp_image_undo_is_enabled (gimage))
{
GimpUndo *undo;
GimpUndo *redo;
@ -256,10 +239,10 @@ edit_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("edit-cut", drawable);
SET_SENSITIVE ("edit-copy", drawable);
SET_SENSITIVE ("edit-paste", gdisp && group->gimp->global_buffer);
SET_SENSITIVE ("edit-paste-into", gdisp && group->gimp->global_buffer);
SET_SENSITIVE ("edit-paste", gimage && group->gimp->global_buffer);
SET_SENSITIVE ("edit-paste-into", gimage && group->gimp->global_buffer);
SET_SENSITIVE ("edit-named-cut", drawable);
SET_SENSITIVE ("edit-named-cut", drawable);
SET_SENSITIVE ("edit-named-paste", drawable);
SET_SENSITIVE ("edit-clear", drawable);

View File

@ -30,7 +30,6 @@
#include "core/gimp-edit.h"
#include "core/gimpbuffer.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
@ -40,39 +39,25 @@
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-transform.h"
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpdialogfactory.h"
#include "gui/dialogs.h"
#include "gui/stroke-dialog.h"
#include "actions.h"
#include "edit-commands.h"
#include "gimp-intl.h"
#define return_if_no_display(gdisp,data) \
if (GIMP_IS_DISPLAY (data)) \
gdisp = data; \
else if (GIMP_IS_GIMP (data)) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gdisp = gimp_context_get_display (((GimpDock *) data)->context); \
else \
gdisp = NULL; \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
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_DOCK (data)) \
gimage = gimp_context_get_image (((GimpDock *) data)->context); \
else \
gimage = NULL; \
gimage = action_data_get_image (data); \
if (! gimage) \
return

View File

@ -36,9 +36,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "file-actions.h"
#include "file-commands.h"
@ -173,38 +171,23 @@ void
file_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
GimpImage *gimage = NULL;
GimpDrawable *drawable = NULL;
GimpImage *gimage = NULL;
GimpDrawable *drawable = NULL;
if (GIMP_IS_DISPLAY_SHELL (data))
{
shell = GIMP_DISPLAY_SHELL (data);
gdisp = shell->gdisp;
}
else if (GIMP_IS_DISPLAY (data))
{
gdisp = GIMP_DISPLAY (data);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
}
gimage = action_data_get_image (data);
if (gdisp)
{
gimage = gdisp->gimage;
drawable = gimp_image_active_drawable (gimage);
}
if (gimage)
drawable = gimp_image_active_drawable (gimage);
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
SET_SENSITIVE ("file-save", gdisp && drawable);
SET_SENSITIVE ("file-save-as", gdisp && drawable);
SET_SENSITIVE ("file-save-a-copy", gdisp && drawable);
SET_SENSITIVE ("file-save-as-template", gdisp);
SET_SENSITIVE ("file-revert", gdisp && GIMP_OBJECT (gimage)->name);
SET_SENSITIVE ("file-close", gdisp);
SET_SENSITIVE ("file-save", gimage && drawable);
SET_SENSITIVE ("file-save-as", gimage && drawable);
SET_SENSITIVE ("file-save-a-copy", gimage && drawable);
SET_SENSITIVE ("file-save-as-template", gimage);
SET_SENSITIVE ("file-revert", gimage && GIMP_OBJECT (gimage)->name);
SET_SENSITIVE ("file-close", gimage);
#undef SET_SENSITIVE
}

View File

@ -39,7 +39,6 @@
#include "file/file-save.h"
#include "file/file-utils.h"
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpdialogfactory.h"
@ -53,6 +52,7 @@
#include "gui/file-save-dialog.h"
#include "gui/menus.h"
#include "actions.h"
#include "file-commands.h"
#include "gimp-intl.h"
@ -62,38 +62,17 @@
#define return_if_no_gimp(gimp,data) \
if (GIMP_IS_DISPLAY (data)) \
gimp = ((GimpDisplay *) data)->gimage->gimp; \
else if (GIMP_IS_GIMP (data)) \
gimp = data; \
else if (GIMP_IS_DOCK (data)) \
gimp = ((GimpDock *) data)->context->gimp; \
else \
gimp = NULL; \
gimp = action_data_get_gimp (data); \
if (! gimp) \
return
#define return_if_no_display(gdisp,data) \
if (GIMP_IS_DISPLAY (data)) \
gdisp = data; \
else if (GIMP_IS_GIMP (data)) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gdisp = gimp_context_get_display (((GimpDock *) data)->context); \
else \
gdisp = NULL; \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_widget(widget,data) \
if (GIMP_IS_DISPLAY (data)) \
widget = ((GimpDisplay *) data)->shell; \
else if (GIMP_IS_GIMP (data)) \
widget = dialogs_get_toolbox (); \
else if (GIMP_IS_DOCK (data)) \
widget = data; \
else \
widget = NULL; \
widget = action_data_get_widget (data); \
if (! widget) \
return

View File

@ -24,14 +24,7 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "widgets/gimpdock.h"
#include "display/gimpdisplay.h"
#include "gui/dialogs.h"
#include "actions.h"
#include "help-commands.h"
@ -46,14 +39,7 @@ void
help_context_help_cmd_callback (GtkAction *action,
gpointer data)
{
GtkWidget *widget = NULL;
if (GIMP_IS_GIMP (data))
widget = dialogs_get_toolbox ();
else if (GIMP_IS_DISPLAY (data))
widget = GIMP_DISPLAY (data)->shell;
else if (GIMP_IS_DOCK (data))
widget = data;
GtkWidget *widget = action_data_get_widget (data);
if (widget)
gimp_context_help (widget);

View File

@ -34,9 +34,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "image-actions.h"
#include "image-commands.h"
@ -165,34 +163,21 @@ void
image_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
GimpImage *gimage = NULL;
gboolean is_rgb = FALSE;
gboolean is_gray = FALSE;
gboolean is_indexed = FALSE;
gboolean fs = FALSE;
gboolean aux = FALSE;
gboolean lp = FALSE;
gboolean sel = FALSE;
GimpImage *gimage;
gboolean is_rgb = FALSE;
gboolean is_gray = FALSE;
gboolean is_indexed = FALSE;
gboolean fs = FALSE;
gboolean aux = FALSE;
gboolean lp = FALSE;
gboolean sel = FALSE;
if (GIMP_IS_DISPLAY_SHELL (data))
{
shell = GIMP_DISPLAY_SHELL (data);
gdisp = shell->gdisp;
}
else if (GIMP_IS_DISPLAY (data))
{
gdisp = GIMP_DISPLAY (data);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
}
gimage = action_data_get_image (data);
if (gdisp)
if (gimage)
{
GimpImageBaseType base_type;
gimage = gdisp->gimage;
base_type = gimp_image_base_type (gimage);
is_rgb = (base_type == GIMP_RGB);
@ -208,23 +193,23 @@ image_actions_update (GimpActionGroup *group,
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
SET_SENSITIVE ("image-convert-rgb", gdisp && ! is_rgb);
SET_SENSITIVE ("image-convert-grayscale", gdisp && ! is_gray);
SET_SENSITIVE ("image-convert-indexed", gdisp && ! is_indexed);
SET_SENSITIVE ("image-convert-rgb", gimage && ! is_rgb);
SET_SENSITIVE ("image-convert-grayscale", gimage && ! is_gray);
SET_SENSITIVE ("image-convert-indexed", gimage && ! is_indexed);
SET_SENSITIVE ("image-flip-horizontal", gdisp);
SET_SENSITIVE ("image-flip-vertical", gdisp);
SET_SENSITIVE ("image-rotate-90", gdisp);
SET_SENSITIVE ("image-rotate-180", gdisp);
SET_SENSITIVE ("image-rotate-270", gdisp);
SET_SENSITIVE ("image-flip-horizontal", gimage);
SET_SENSITIVE ("image-flip-vertical", gimage);
SET_SENSITIVE ("image-rotate-90", gimage);
SET_SENSITIVE ("image-rotate-180", gimage);
SET_SENSITIVE ("image-rotate-270", gimage);
SET_SENSITIVE ("image-resize", gdisp);
SET_SENSITIVE ("image-scale", gdisp);
SET_SENSITIVE ("image-crop", gdisp && sel);
SET_SENSITIVE ("image-duplicate", gdisp);
SET_SENSITIVE ("image-merge-layers", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("image-flatten", gdisp && !fs && !aux && lp);
SET_SENSITIVE ("image-configure-grid", gdisp);
SET_SENSITIVE ("image-resize", gimage);
SET_SENSITIVE ("image-scale", gimage);
SET_SENSITIVE ("image-crop", gimage && sel);
SET_SENSITIVE ("image-duplicate", gimage);
SET_SENSITIVE ("image-merge-layers", gimage && !fs && !aux && lp);
SET_SENSITIVE ("image-flatten", gimage && !fs && !aux && lp);
SET_SENSITIVE ("image-configure-grid", gimage);
#undef SET_SENSITIVE
}

View File

@ -54,6 +54,7 @@
#include "gui/grid-dialog.h"
#include "gui/resize-dialog.h"
#include "actions.h"
#include "image-commands.h"
#include "gimp-intl.h"
@ -68,26 +69,12 @@ typedef struct
#define return_if_no_display(gdisp,data) \
if (GIMP_IS_DISPLAY (data)) \
gdisp = data; \
else if (GIMP_IS_GIMP (data)) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gdisp = gimp_context_get_display (((GimpDock *) data)->context); \
else \
gdisp = NULL; \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
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_DOCK (data)) \
gimage = gimp_context_get_image (((GimpDock *) data)->context); \
else \
gimage = NULL; \
gimage = action_data_get_image (data); \
if (! gimage) \
return

View File

@ -32,11 +32,8 @@
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpitemtreeview.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "layers-actions.h"
#include "layers-commands.h"
@ -255,7 +252,7 @@ void
layers_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *gimage = NULL;
GimpImage *gimage;
GimpLayer *layer = NULL;
gboolean fs = FALSE; /* floating sel */
gboolean ac = FALSE; /* active channel */
@ -267,12 +264,7 @@ layers_actions_update (GimpActionGroup *group,
GList *next = NULL;
GList *prev = NULL;
if (GIMP_IS_ITEM_TREE_VIEW (data))
gimage = GIMP_ITEM_TREE_VIEW (data)->gimage;
else if (GIMP_IS_DISPLAY_SHELL (data))
gimage = GIMP_DISPLAY_SHELL (data)->gdisp->gimage;
else if (GIMP_IS_DISPLAY (data))
gimage = GIMP_DISPLAY (data)->gimage;
gimage = action_data_get_image (data);
if (gimage)
{

View File

@ -58,9 +58,9 @@
#include "tools/gimptexttool.h"
#include "tools/tool_manager.h"
#include "gui/dialogs.h"
#include "gui/resize-dialog.h"
#include "actions.h"
#include "layers-commands.h"
#include "image-commands.h"
@ -81,16 +81,7 @@ static void layers_resize_layer_query (GimpImage *gimage,
#define return_if_no_image(gimage,data) \
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_DOCK (data)) \
gimage = gimp_context_get_image (((GimpDock *) data)->context); \
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
gimage = ((GimpItemTreeView *) data)->gimage; \
else \
gimage = NULL; \
gimage = action_data_get_image (data); \
if (! gimage) \
return
@ -101,16 +92,7 @@ static void layers_resize_layer_query (GimpImage *gimage,
return
#define return_if_no_widget(widget,data) \
if (GIMP_IS_DISPLAY (data)) \
widget = ((GimpDisplay *) data)->shell; \
else if (GIMP_IS_GIMP (data)) \
widget = dialogs_get_toolbox (); \
else if (GIMP_IS_DOCK (data)) \
widget = data; \
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
widget = data; \
else \
widget = NULL; \
widget = action_data_get_widget (data); \
if (! widget) \
return

View File

@ -28,7 +28,6 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
@ -39,11 +38,8 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemtreeview.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "plug-in-actions.h"
#include "plug-in-commands.h"
@ -135,16 +131,11 @@ void
plug_in_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *gimage = NULL;
GimpImage *gimage;
GimpImageType type = -1;
GSList *list;
if (GIMP_IS_ITEM_TREE_VIEW (data))
gimage = GIMP_ITEM_TREE_VIEW (data)->gimage;
else if (GIMP_IS_DISPLAY_SHELL (data))
gimage = GIMP_DISPLAY_SHELL (data)->gdisp->gimage;
else if (GIMP_IS_DISPLAY (data))
gimage = GIMP_DISPLAY (data)->gimage;
gimage = action_data_get_image (data);
if (gimage)
{

View File

@ -25,7 +25,6 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpitem.h"
@ -33,26 +32,12 @@
#include "plug-in/plug-in-run.h"
#include "plug-in/plug-in-proc.h"
#include "widgets/gimpdock.h"
#include "display/gimpdisplay.h"
#include "actions.h"
#include "plug-in-commands.h"
#define return_if_no_display(gdisp,data) \
if (GIMP_IS_DISPLAY (data)) \
gdisp = data; \
else if (GIMP_IS_GIMP (data)) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gdisp = gimp_context_get_display (((GimpDock *) data)->context); \
else \
gdisp = NULL; \
if (! gdisp) \
return
void
plug_in_run_cmd_callback (GtkAction *action,
PlugInProcDef *proc_def,
@ -66,13 +51,8 @@ plug_in_run_cmd_callback (GtkAction *action,
gint argc;
GimpImageType drawable_type = GIMP_RGB_IMAGE;
if (GIMP_IS_DISPLAY (data))
gimp = ((GimpDisplay *) data)->gimage->gimp;
else if (GIMP_IS_GIMP (data))
gimp = data;
else if (GIMP_IS_DOCK (data))
gimp = ((GimpDock *) data)->context->gimp;
else
gimp = action_data_get_gimp (data);
if (! gimp)
return;
proc_rec = &proc_def->db_info;
@ -98,9 +78,7 @@ plug_in_run_cmd_callback (GtkAction *action,
if (proc_rec->num_args >= 2 &&
proc_rec->args[1].arg_type == GIMP_PDB_IMAGE)
{
GimpDisplay *gdisplay;
gdisplay = gimp_context_get_display (gimp_get_user_context (gimp));
GimpDisplay *gdisplay = action_data_get_display (data);
if (gdisplay)
{
@ -169,10 +147,12 @@ plug_in_repeat_cmd_callback (GtkAction *action,
GimpDisplay *gdisp;
GimpDrawable *drawable;
gboolean interactive;
return_if_no_display (gdisp, data);
gdisp = action_data_get_display (data);
if (! gdisp)
return;
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! drawable)
return;

View File

@ -29,9 +29,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "qmask-actions.h"
#include "qmask-commands.h"
@ -100,23 +98,9 @@ void
qmask_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
GimpImage *gimage = NULL;
GimpImage *gimage;
if (GIMP_IS_DISPLAY_SHELL (data))
{
shell = GIMP_DISPLAY_SHELL (data);
gdisp = shell->gdisp;
}
else if (GIMP_IS_DISPLAY (data))
{
gdisp = GIMP_DISPLAY (data);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
}
if (gdisp)
gimage = gdisp->gimage;
gimage = action_data_get_image (data);
#define SET_ACTIVE(action,active) \
gimp_action_group_set_action_active (group, action, (active))

View File

@ -27,18 +27,17 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-qmask.h"
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpviewabledialog.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "qmask-commands.h"
#include "gimp-intl.h"
@ -57,30 +56,12 @@ struct _EditQmaskOptions
#define return_if_no_display(gdisp,data) \
if (GIMP_IS_DISPLAY (data)) \
gdisp = data; \
else if (GIMP_IS_DISPLAY_SHELL (data)) \
gdisp = ((GimpDisplayShell *) data)->gdisp; \
else if (GIMP_IS_GIMP (data)) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gdisp = gimp_context_get_display (((GimpDock *) data)->context); \
else \
gdisp = NULL; \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_DISPLAY_SHELL (data)) \
gimage = ((GimpDisplayShell *) data)->gdisp->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gimage = gimp_context_get_image (((GimpDock *) data)->context); \
else \
gimage = NULL; \
gimage = action_data_get_image (data); \
if (! gimage) \
return

View File

@ -29,9 +29,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "qmask-actions.h"
#include "qmask-commands.h"
@ -100,23 +98,9 @@ void
qmask_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
GimpImage *gimage = NULL;
GimpImage *gimage;
if (GIMP_IS_DISPLAY_SHELL (data))
{
shell = GIMP_DISPLAY_SHELL (data);
gdisp = shell->gdisp;
}
else if (GIMP_IS_DISPLAY (data))
{
gdisp = GIMP_DISPLAY (data);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
}
if (gdisp)
gimage = gdisp->gimage;
gimage = action_data_get_image (data);
#define SET_ACTIVE(action,active) \
gimp_action_group_set_action_active (group, action, (active))

View File

@ -27,18 +27,17 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-qmask.h"
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpviewabledialog.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "qmask-commands.h"
#include "gimp-intl.h"
@ -57,30 +56,12 @@ struct _EditQmaskOptions
#define return_if_no_display(gdisp,data) \
if (GIMP_IS_DISPLAY (data)) \
gdisp = data; \
else if (GIMP_IS_DISPLAY_SHELL (data)) \
gdisp = ((GimpDisplayShell *) data)->gdisp; \
else if (GIMP_IS_GIMP (data)) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gdisp = gimp_context_get_display (((GimpDock *) data)->context); \
else \
gdisp = NULL; \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
if (GIMP_IS_DISPLAY (data)) \
gimage = ((GimpDisplay *) data)->gimage; \
else if (GIMP_IS_DISPLAY_SHELL (data)) \
gimage = ((GimpDisplayShell *) data)->gdisp->gimage; \
else if (GIMP_IS_GIMP (data)) \
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gimage = gimp_context_get_image (((GimpDock *) data)->context); \
else \
gimage = NULL; \
gimage = action_data_get_image (data); \
if (! gimage) \
return

View File

@ -31,9 +31,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "select-actions.h"
#include "select-commands.h"
#include "tools-commands.h"
@ -134,29 +132,16 @@ void
select_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
GimpImage *gimage = NULL;
GimpVectors *vectors = NULL;
gboolean fs = FALSE;
gboolean lp = FALSE;
gboolean sel = FALSE;
GimpImage *gimage;
GimpVectors *vectors = NULL;
gboolean fs = FALSE;
gboolean lp = FALSE;
gboolean sel = FALSE;
if (GIMP_IS_DISPLAY_SHELL (data))
{
shell = GIMP_DISPLAY_SHELL (data);
gdisp = shell->gdisp;
}
else if (GIMP_IS_DISPLAY (data))
{
gdisp = GIMP_DISPLAY (data);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
}
gimage = action_data_get_image (data);
if (gdisp)
if (gimage)
{
gimage = gdisp->gimage;
fs = (gimp_image_floating_sel (gimage) != NULL);
lp = ! gimp_image_is_empty (gimage);
sel = ! gimp_channel_is_empty (gimp_image_get_mask (gimage));

View File

@ -28,11 +28,9 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpchannel-select.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpselection.h"
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpdialogfactory.h"
@ -41,32 +39,19 @@
#include "gui/dialogs.h"
#include "actions.h"
#include "select-commands.h"
#include "gimp-intl.h"
#define return_if_no_display(gdisp,data) \
if (GIMP_IS_DISPLAY (data)) \
gdisp = data; \
else if (GIMP_IS_GIMP (data)) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gdisp = gimp_context_get_display (((GimpDock *) data)->context); \
else \
gdisp = NULL; \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
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_DOCK (data)) \
gimage = gimp_context_get_image (((GimpDock *) data)->context); \
else \
gimage = NULL; \
gimage = action_data_get_image (data); \
if (! gimage) \
return

View File

@ -28,35 +28,22 @@
#include "core/gimpimage.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpdock.h"
#include "display/gimpdisplay.h"
#include "tools/gimptool.h"
#include "tools/tool_manager.h"
#include "actions.h"
#include "tools-commands.h"
#define return_if_no_gimp(gimp,data) \
if (GIMP_IS_DISPLAY (data)) \
gimp = ((GimpDisplay *) data)->gimage->gimp; \
else if (GIMP_IS_GIMP (data)) \
gimp = data; \
else if (GIMP_IS_DOCK (data)) \
gimp = ((GimpDock *) data)->context->gimp; \
else \
gimp = NULL; \
if (! gimp) \
return
void
tools_default_colors_cmd_callback (GtkAction *action,
gpointer data)
{
Gimp *gimp;
return_if_no_gimp (gimp, data);
Gimp *gimp = action_data_get_gimp (data);
if (! gimp)
return;
gimp_context_set_default_colors (gimp_get_user_context (gimp));
}
@ -65,8 +52,9 @@ void
tools_swap_colors_cmd_callback (GtkAction *action,
gpointer data)
{
Gimp *gimp;
return_if_no_gimp (gimp, data);
Gimp *gimp = action_data_get_gimp (data);
if (! gimp)
return;
gimp_context_swap_colors (gimp_get_user_context (gimp));
}
@ -80,7 +68,10 @@ tools_select_cmd_callback (GtkAction *action,
GimpToolInfo *tool_info;
GimpContext *context;
GimpDisplay *gdisp;
return_if_no_gimp (gimp, data);
gimp = action_data_get_gimp (data);
if (! gimp)
return;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list, value);

View File

@ -30,11 +30,8 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemtreeview.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "actions.h"
#include "vectors-actions.h"
#include "vectors-commands.h"
@ -168,19 +165,14 @@ void
vectors_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *gimage = NULL;
GimpImage *gimage;
GimpVectors *vectors = NULL;
gboolean mask_empty = TRUE;
gboolean global_buf = FALSE;
GList *next = NULL;
GList *prev = NULL;
if (GIMP_IS_ITEM_TREE_VIEW (data))
gimage = GIMP_ITEM_TREE_VIEW (data)->gimage;
else if (GIMP_IS_DISPLAY_SHELL (data))
gimage = GIMP_DISPLAY_SHELL (data)->gdisp->gimage;
else if (GIMP_IS_DISPLAY (data))
gimage = GIMP_DISPLAY (data)->gimage;
gimage = action_data_get_image (data);
if (gimage)
{

View File

@ -45,7 +45,6 @@
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemtreeview.h"
#include "widgets/gimpviewabledialog.h"
#include "display/gimpdisplay.h"
@ -54,26 +53,16 @@
#include "tools/gimpvectortool.h"
#include "tools/tool_manager.h"
#include "gui/dialogs.h"
#include "gui/stroke-dialog.h"
#include "actions.h"
#include "vectors-commands.h"
#include "gimp-intl.h"
#define return_if_no_image(gimage,data) \
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_DOCK (data)) \
gimage = gimp_context_get_image (((GimpDock *) data)->context); \
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
gimage = ((GimpItemTreeView *) data)->gimage; \
else \
gimage = NULL; \
\
gimage = action_data_get_image (data); \
if (! gimage) \
return
@ -84,16 +73,7 @@
return
#define return_if_no_widget(widget,data) \
if (GIMP_IS_DISPLAY (data)) \
widget = ((GimpDisplay *) data)->shell; \
else if (GIMP_IS_GIMP (data)) \
widget = dialogs_get_toolbox (); \
else if (GIMP_IS_DOCK (data)) \
widget = data; \
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
widget = data; \
else \
widget = NULL; \
widget = action_data_get_widget (data); \
if (! widget) \
return
@ -176,9 +156,10 @@ vectors_duplicate_cmd_callback (GtkAction *action,
GimpVectors *new_vectors;
return_if_no_vectors (gimage, active_vectors, data);
new_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (active_vectors),
G_TYPE_FROM_INSTANCE (active_vectors),
TRUE));
new_vectors =
GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (active_vectors),
G_TYPE_FROM_INSTANCE (active_vectors),
TRUE));
gimp_image_add_vectors (gimage, new_vectors, -1);
gimp_image_flush (gimage);
}

View File

@ -46,18 +46,12 @@
#include "gui/info-dialog.h"
#include "gui/info-window.h"
#include "actions.h"
#include "view-commands.h"
#define return_if_no_display(gdisp, data) \
if (GIMP_IS_DISPLAY (data)) \
gdisp = data; \
else if (GIMP_IS_GIMP (data)) \
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
else if (GIMP_IS_DOCK (data)) \
gdisp = gimp_context_get_display (((GimpDock *) data)->context); \
else \
gdisp = NULL; \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return