Commit 3590757d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/actions/actions.h. added the various return_if_no_foo() macros here.

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

	* app/actions/actions.h. added the various return_if_no_foo()
	macros here.

	* app/actions/channels-commands.c
	* app/actions/dialogs-commands.c
	* app/actions/drawable-commands.c
	* app/actions/edit-commands.c
	* app/actions/file-commands.c
	* app/actions/image-commands.c
	* app/actions/layers-commands.c
	* app/actions/qmask-commands.c
	* app/actions/select-commands.c
	* app/actions/vectors-commands.c
	* app/actions/view-commands.c: removed them here. Some cleanup.
parent d745841e
2004-05-03 Michael Natterer <mitch@gimp.org>
* app/actions/actions.h. added the various return_if_no_foo()
macros here.
* app/actions/channels-commands.c
* app/actions/dialogs-commands.c
* app/actions/drawable-commands.c
* app/actions/edit-commands.c
* app/actions/file-commands.c
* app/actions/image-commands.c
* app/actions/layers-commands.c
* app/actions/qmask-commands.c
* app/actions/select-commands.c
* app/actions/vectors-commands.c
* app/actions/view-commands.c: removed them here. Some cleanup.
2004-05-03 Michael Natterer <mitch@gimp.org> 2004-05-03 Michael Natterer <mitch@gimp.org>
* app/actions/actions.[ch]: added some utility functions to get a * app/actions/actions.[ch]: added some utility functions to get a
......
...@@ -32,4 +32,50 @@ GimpDisplay * action_data_get_display (gpointer data); ...@@ -32,4 +32,50 @@ GimpDisplay * action_data_get_display (gpointer data);
GtkWidget * action_data_get_widget (gpointer data); GtkWidget * action_data_get_widget (gpointer data);
#define return_if_no_gimp(gimp,data) \
gimp = action_data_get_gimp (data); \
if (! gimp) \
return
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
return
#define return_if_no_display(gdisp,data) \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_widget(widget,data) \
widget = action_data_get_widget (data); \
if (! widget) \
return
#define return_if_no_drawable(gimage,drawable,data) \
return_if_no_image (gimage,data); \
drawable = gimp_image_active_drawable (gimage); \
if (! drawable) \
return
#define return_if_no_layer(gimage,layer,data) \
return_if_no_image (gimage,data); \
layer = gimp_image_get_active_layer (gimage); \
if (! layer) \
return
#define return_if_no_channel(gimage,channel,data) \
return_if_no_image (gimage,data); \
channel = gimp_image_get_active_channel (gimage); \
if (! channel) \
return
#define return_if_no_vectors(gimage,vectors,data) \
return_if_no_image (gimage,data); \
vectors = gimp_image_get_active_vectors (gimage); \
if (! vectors) \
return
#endif /* __ACTIONS_H__ */ #endif /* __ACTIONS_H__ */
...@@ -53,24 +53,6 @@ static void channels_color_changed (GimpColorButton *button, ...@@ -53,24 +53,6 @@ static void channels_color_changed (GimpColorButton *button,
gpointer data); gpointer data);
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
return
#define return_if_no_channel(gimage,channel,data) \
return_if_no_image (gimage,data); \
channel = gimp_image_get_active_channel (gimage); \
if (! channel) \
return
#define return_if_no_widget(widget,data) \
widget = action_data_get_widget (data); \
if (! widget) \
return
/* public functions */ /* public functions */
void void
......
...@@ -27,31 +27,16 @@ ...@@ -27,31 +27,16 @@
#include "actions-types.h" #include "actions-types.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpcontext.h"
#include "widgets/gimpdialogfactory.h" #include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockable.h" #include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h" #include "widgets/gimpdockbook.h"
#include "widgets/gimpimagedock.h" #include "widgets/gimpimagedock.h"
#include "display/gimpdisplay.h"
#include "gui/dialogs.h" #include "gui/dialogs.h"
#include "dialogs-commands.h"
#include "actions.h"
#define return_if_no_widget(widget,data) \ #include "dialogs-commands.h"
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; \
\
if (! widget) \
return
/* local function prototypes */ /* local function prototypes */
......
...@@ -41,23 +41,6 @@ ...@@ -41,23 +41,6 @@
#include "gimp-intl.h" #include "gimp-intl.h"
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
return
#define return_if_no_drawable(gimage,drawable,data) \
return_if_no_image (gimage,data); \
drawable = gimp_image_active_drawable (gimage); \
if (! drawable) \
return
#define return_if_no_widget(widget,data) \
widget = action_data_get_widget (data); \
if (! widget) \
return
/* public functions */ /* public functions */
void void
......
...@@ -51,23 +51,6 @@ ...@@ -51,23 +51,6 @@
#include "gimp-intl.h" #include "gimp-intl.h"
#define return_if_no_display(gdisp,data) \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
return
#define return_if_no_drawable(gimage,drawable,data) \
return_if_no_image (gimage, data); \
drawable = gimp_image_active_drawable (gimage); \
if (! drawable) \
return;
/* local function prototypes */ /* local function prototypes */
static void cut_named_buffer_callback (GtkWidget *widget, static void cut_named_buffer_callback (GtkWidget *widget,
...@@ -173,33 +156,31 @@ void ...@@ -173,33 +156,31 @@ void
edit_paste_as_new_cmd_callback (GtkAction *action, edit_paste_as_new_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
{ {
GimpDisplay *gdisp; Gimp *gimp;
return_if_no_display (gdisp, data); return_if_no_gimp (gimp, data);
if (gdisp->gimage->gimp->global_buffer) if (gimp->global_buffer)
{ gimp_edit_paste_as_new (gimp, action_data_get_image (data),
gimp_edit_paste_as_new (gdisp->gimage->gimp, gimp->global_buffer);
gdisp->gimage,
gdisp->gimage->gimp->global_buffer);
}
} }
void void
edit_named_cut_cmd_callback (GtkAction *action, edit_named_cut_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
{ {
GimpDisplay *gdisp; GimpImage *gimage;
GtkWidget *qbox; GtkWidget *widget;
return_if_no_display (gdisp, data); GtkWidget *qbox;
return_if_no_image (gimage, data);
return_if_no_widget (widget, data);
qbox = gimp_query_string_box (_("Cut Named"), qbox = gimp_query_string_box (_("Cut Named"), widget,
gdisp->shell,
gimp_standard_help_func, gimp_standard_help_func,
GIMP_HELP_BUFFER_CUT, GIMP_HELP_BUFFER_CUT,
_("Enter a name for this buffer"), _("Enter a name for this buffer"),
NULL, NULL,
G_OBJECT (gdisp->gimage), "disconnect", G_OBJECT (gimage), "disconnect",
cut_named_buffer_callback, gdisp->gimage); cut_named_buffer_callback, gimage);
gtk_widget_show (qbox); gtk_widget_show (qbox);
} }
...@@ -207,18 +188,19 @@ void ...@@ -207,18 +188,19 @@ void
edit_named_copy_cmd_callback (GtkAction *action, edit_named_copy_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
{ {
GimpDisplay *gdisp; GimpImage *gimage;
GtkWidget *qbox; GtkWidget *widget;
return_if_no_display (gdisp, data); GtkWidget *qbox;
return_if_no_image (gimage, data);
return_if_no_widget (widget, data);
qbox = gimp_query_string_box (_("Copy Named"), qbox = gimp_query_string_box (_("Copy Named"), widget,
gdisp->shell,
gimp_standard_help_func, gimp_standard_help_func,
GIMP_HELP_BUFFER_COPY, GIMP_HELP_BUFFER_COPY,
_("Enter a name for this buffer"), _("Enter a name for this buffer"),
NULL, NULL,
G_OBJECT (gdisp->gimage), "disconnect", G_OBJECT (gimage), "disconnect",
copy_named_buffer_callback, gdisp->gimage); copy_named_buffer_callback, gimage);
gtk_widget_show (qbox); gtk_widget_show (qbox);
} }
...@@ -226,11 +208,11 @@ void ...@@ -226,11 +208,11 @@ void
edit_named_paste_cmd_callback (GtkAction *action, edit_named_paste_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
{ {
GimpDisplay *gdisp; GtkWidget *widget;
return_if_no_display (gdisp, data); return_if_no_widget (widget, data);
gimp_dialog_factory_dialog_raise (global_dock_factory, gimp_dialog_factory_dialog_raise (global_dock_factory,
gtk_widget_get_screen (gdisp->shell), gtk_widget_get_screen (widget),
"gimp-buffer-list|gimp-buffer-grid", -1); "gimp-buffer-list|gimp-buffer-grid", -1);
} }
...@@ -267,13 +249,13 @@ void ...@@ -267,13 +249,13 @@ void
edit_stroke_cmd_callback (GtkAction *action, edit_stroke_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
{ {
GimpDisplay *gdisp;
GimpImage *gimage; GimpImage *gimage;
GimpDrawable *drawable; GimpDrawable *drawable;
return_if_no_display (gdisp, data); GtkWidget *widget;
return_if_no_drawable (gimage, drawable, data); return_if_no_drawable (gimage, drawable, data);
return_if_no_widget (widget, data);
edit_stroke_selection (GIMP_ITEM (gimp_image_get_mask (gimage)), gdisp->shell); edit_stroke_selection (GIMP_ITEM (gimp_image_get_mask (gimage)), widget);
} }
void void
...@@ -285,6 +267,7 @@ edit_stroke_selection (GimpItem *item, ...@@ -285,6 +267,7 @@ edit_stroke_selection (GimpItem *item,
GtkWidget *dialog; GtkWidget *dialog;
g_return_if_fail (GIMP_IS_ITEM (item)); g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (GTK_IS_WIDGET (parent));
gimage = gimp_item_get_image (item); gimage = gimp_item_get_image (item);
......
...@@ -61,22 +61,6 @@ ...@@ -61,22 +61,6 @@
#define REVERT_DATA_KEY "revert-confirm-dialog" #define REVERT_DATA_KEY "revert-confirm-dialog"
#define return_if_no_gimp(gimp,data) \
gimp = action_data_get_gimp (data); \
if (! gimp) \
return
#define return_if_no_display(gdisp,data) \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_widget(widget,data) \
widget = action_data_get_widget (data); \
if (! widget) \
return
/* local function prototypes */ /* local function prototypes */
static void file_new_template_callback (GtkWidget *widget, static void file_new_template_callback (GtkWidget *widget,
......
...@@ -68,18 +68,7 @@ typedef struct ...@@ -68,18 +68,7 @@ typedef struct
} ImageResize; } ImageResize;
#define return_if_no_display(gdisp,data) \ /* local function prototypes */
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
return
/* local functions */
static void image_resize_callback (GtkWidget *widget, static void image_resize_callback (GtkWidget *widget,
gpointer data); gpointer data);
...@@ -122,11 +111,13 @@ void ...@@ -122,11 +111,13 @@ void
image_convert_indexed_cmd_callback (GtkAction *action, image_convert_indexed_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
{ {
GimpDisplay *gdisp; GimpImage *gimage;
GtkWidget *dialog; GtkWidget *widget;
return_if_no_display (gdisp, data); GtkWidget *dialog;
return_if_no_image (gimage, data);
return_if_no_widget (widget, data);
dialog = convert_dialog_new (gdisp->gimage, gdisp->shell); dialog = convert_dialog_new (gimage, widget);
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }
...@@ -254,20 +245,20 @@ void ...@@ -254,20 +245,20 @@ void
image_crop_cmd_callback (GtkAction *action, image_crop_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
{ {
GimpDisplay *gdisp; GimpImage *gimage;
gint x1, y1, x2, y2; gint x1, y1, x2, y2;
return_if_no_display (gdisp, data); return_if_no_image (gimage, data);
if (! gimp_channel_bounds (gimp_image_get_mask (gdisp->gimage), if (! gimp_channel_bounds (gimp_image_get_mask (gimage),
&x1, &y1, &x2, &y2)) &x1, &y1, &x2, &y2))
{ {
g_message (_("Cannot crop because the current selection is empty.")); g_message (_("Cannot crop because the current selection is empty."));
return; return;
} }
gimp_image_crop (gdisp->gimage, gimp_get_user_context (gdisp->gimage->gimp), gimp_image_crop (gimage, gimp_get_user_context (gimage->gimp),
x1, y1, x2, y2, FALSE, TRUE); x1, y1, x2, y2, FALSE, TRUE);
gimp_image_flush (gdisp->gimage); gimp_image_flush (gimage);
} }
void void
...@@ -289,10 +280,12 @@ void ...@@ -289,10 +280,12 @@ void
image_merge_layers_cmd_callback (GtkAction *action, image_merge_layers_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
{ {
GimpDisplay *gdisp; GimpImage *gimage;
return_if_no_display (gdisp, data); GtkWidget *widget;
return_if_no_image (gimage, data);
return_if_no_widget (widget, data);
image_layers_merge_query (gdisp->gimage, TRUE, gdisp->shell); image_layers_merge_query (gimage, TRUE, widget);
} }
void void
......
...@@ -80,23 +80,6 @@ static void layers_resize_layer_query (GimpImage *gimage, ...@@ -80,23 +80,6 @@ static void layers_resize_layer_query (GimpImage *gimage,
GtkWidget *parent); GtkWidget *parent);
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
return
#define return_if_no_layer(gimage,layer,data) \
return_if_no_image (gimage,data); \
layer = gimp_image_get_active_layer (gimage); \
if (! layer) \
return
#define return_if_no_widget(widget,data) \
widget = action_data_get_widget (data); \
if (! widget) \
return
/* public functions */ /* public functions */
void void
......
...@@ -55,17 +55,6 @@ struct _EditQmaskOptions ...@@ -55,17 +55,6 @@ struct _EditQmaskOptions
}; };
#define return_if_no_display(gdisp,data) \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
return
/* local function prototypes */ /* local function prototypes */
static void qmask_channel_query (GimpDisplayShell *shell); static void qmask_channel_query (GimpDisplayShell *shell);
......
...@@ -55,17 +55,6 @@ struct _EditQmaskOptions ...@@ -55,17 +55,6 @@ struct _EditQmaskOptions
}; };
#define return_if_no_display(gdisp,data) \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
return
/* local function prototypes */ /* local function prototypes */
static void qmask_channel_query (GimpDisplayShell *shell); static void qmask_channel_query (GimpDisplayShell *shell);
......
...@@ -45,18 +45,7 @@ ...@@ -45,18 +45,7 @@
#include "gimp-intl.h" #include "gimp-intl.h"
#define return_if_no_display(gdisp,data) \ /* local function prototypes */
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
return
/* local functions */
static void gimp_image_mask_feather_callback (GtkWidget *widget, static void gimp_image_mask_feather_callback (GtkWidget *widget,
gdouble size, gdouble size,
...@@ -272,14 +261,16 @@ void ...@@ -272,14 +261,16 @@ void
select_save_cmd_callback (GtkAction *action, select_save_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
{ {
GimpDisplay *gdisp; GimpImage *gimage;
return_if_no_display (gdisp, data); GtkWidget *widget;
return_if_no_image (gimage, data);
return_if_no_widget (widget, data);
gimp_selection_save (gimp_image_get_mask (gdisp->gimage)); gimp_selection_save (gimp_image_get_mask (gimage));
gimp_image_flush (gdisp->gimage); gimp_image_flush (gimage);
gimp_dialog_factory_dialog_raise (global_dock_factory, gimp_dialog_factory_dialog_raise (global_dock_factory,
gtk_widget_get_screen (gdisp->shell), gtk_widget_get_screen (widget),
"gimp-channel-list", -1); "gimp-channel-list", -1);
} }
......
...@@ -61,22 +61,7 @@ ...@@ -61,22 +61,7 @@
#include "gimp-intl.h" #include "gimp-intl.h"