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>
* app/actions/actions.[ch]: added some utility functions to get a
......
......@@ -32,4 +32,50 @@ GimpDisplay * action_data_get_display (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__ */
......@@ -53,24 +53,6 @@ static void channels_color_changed (GimpColorButton *button,
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 */
void
......
......@@ -27,31 +27,16 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpimagedock.h"
#include "display/gimpdisplay.h"
#include "gui/dialogs.h"
#include "dialogs-commands.h"
#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; \
\
if (! widget) \
return
#include "actions.h"
#include "dialogs-commands.h"
/* local function prototypes */
......
......@@ -41,23 +41,6 @@
#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 */
void
......
......@@ -51,23 +51,6 @@
#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 */
static void cut_named_buffer_callback (GtkWidget *widget,
......@@ -173,33 +156,31 @@ void
edit_paste_as_new_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
Gimp *gimp;
return_if_no_gimp (gimp, data);
if (gdisp->gimage->gimp->global_buffer)
{
gimp_edit_paste_as_new (gdisp->gimage->gimp,
gdisp->gimage,
gdisp->gimage->gimp->global_buffer);
}
if (gimp->global_buffer)
gimp_edit_paste_as_new (gimp, action_data_get_image (data),
gimp->global_buffer);
}
void
edit_named_cut_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
GtkWidget *qbox;
return_if_no_display (gdisp, data);
GimpImage *gimage;
GtkWidget *widget;
GtkWidget *qbox;
return_if_no_image (gimage, data);
return_if_no_widget (widget, data);
qbox = gimp_query_string_box (_("Cut Named"),
gdisp->shell,
qbox = gimp_query_string_box (_("Cut Named"), widget,
gimp_standard_help_func,
GIMP_HELP_BUFFER_CUT,
_("Enter a name for this buffer"),
NULL,
G_OBJECT (gdisp->gimage), "disconnect",
cut_named_buffer_callback, gdisp->gimage);
G_OBJECT (gimage), "disconnect",
cut_named_buffer_callback, gimage);
gtk_widget_show (qbox);
}
......@@ -207,18 +188,19 @@ void
edit_named_copy_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
GtkWidget *qbox;
return_if_no_display (gdisp, data);
GimpImage *gimage;
GtkWidget *widget;
GtkWidget *qbox;
return_if_no_image (gimage, data);
return_if_no_widget (widget, data);
qbox = gimp_query_string_box (_("Copy Named"),
gdisp->shell,
qbox = gimp_query_string_box (_("Copy Named"), widget,
gimp_standard_help_func,
GIMP_HELP_BUFFER_COPY,
_("Enter a name for this buffer"),
NULL,
G_OBJECT (gdisp->gimage), "disconnect",
copy_named_buffer_callback, gdisp->gimage);
G_OBJECT (gimage), "disconnect",
copy_named_buffer_callback, gimage);
gtk_widget_show (qbox);
}
......@@ -226,11 +208,11 @@ void
edit_named_paste_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
GtkWidget *widget;
return_if_no_widget (widget, data);
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);
}
......@@ -267,13 +249,13 @@ void
edit_stroke_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpDrawable *drawable;
return_if_no_display (gdisp, data);
GtkWidget *widget;
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
......@@ -285,6 +267,7 @@ edit_stroke_selection (GimpItem *item,
GtkWidget *dialog;
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (GTK_IS_WIDGET (parent));
gimage = gimp_item_get_image (item);
......
......@@ -61,22 +61,6 @@
#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 */
static void file_new_template_callback (GtkWidget *widget,
......
......@@ -68,18 +68,7 @@ typedef struct
} ImageResize;
#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 functions */
/* local function prototypes */
static void image_resize_callback (GtkWidget *widget,
gpointer data);
......@@ -122,11 +111,13 @@ void
image_convert_indexed_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
GtkWidget *dialog;
return_if_no_display (gdisp, data);
GimpImage *gimage;
GtkWidget *widget;
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);
}
......@@ -254,20 +245,20 @@ void
image_crop_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
gint x1, y1, x2, y2;
return_if_no_display (gdisp, data);
GimpImage *gimage;
gint x1, y1, x2, y2;
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))
{
g_message (_("Cannot crop because the current selection is empty."));
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);
gimp_image_flush (gdisp->gimage);
gimp_image_flush (gimage);
}
void
......@@ -289,10 +280,12 @@ void
image_merge_layers_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
GimpImage *gimage;
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
......
......@@ -80,23 +80,6 @@ static void layers_resize_layer_query (GimpImage *gimage,
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 */
void
......
......@@ -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 */
static void qmask_channel_query (GimpDisplayShell *shell);
......
......@@ -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 */
static void qmask_channel_query (GimpDisplayShell *shell);
......
......@@ -45,18 +45,7 @@
#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
/* local functions */
/* local function prototypes */
static void gimp_image_mask_feather_callback (GtkWidget *widget,
gdouble size,
......@@ -272,14 +261,16 @@ void
select_save_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
GimpImage *gimage;
GtkWidget *widget;
return_if_no_image (gimage, data);
return_if_no_widget (widget, data);
gimp_selection_save (gimp_image_get_mask (gdisp->gimage));
gimp_image_flush (gdisp->gimage);
gimp_selection_save (gimp_image_get_mask (gimage));
gimp_image_flush (gimage);
gimp_dialog_factory_dialog_raise (global_dock_factory,
gtk_widget_get_screen (gdisp->shell),
gtk_widget_get_screen (widget),
"gimp-channel-list", -1);
}
......
......@@ -61,22 +61,7 @@
#include "gimp-intl.h"
#define return_if_no_image(gimage,data) \
gimage = action_data_get_image (data); \
if (! gimage) \
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
#define return_if_no_widget(widget,data) \
widget = action_data_get_widget (data); \
if (! widget) \
return
/* local function prototypes */
static void vectors_import_query (GimpImage *gimage,
GtkWidget *parent);
......
......@@ -50,11 +50,6 @@
#include "view-commands.h"
#define return_if_no_display(gdisp, data) \
gdisp = action_data_get_display (data); \
if (! gdisp) \
return
#define SET_ACTIVE(manager,group_name,action_name,active) \
{ GimpActionGroup *group = \
gimp_ui_manager_get_action_group (manager, group_name); \
......@@ -65,6 +60,8 @@
gimp_context_get_display (gimp_get_user_context ((gdisp)->gimage->gimp)))
/* public functions */
void
view_zoom_out_cmd_callback (GtkAction *action,
gpointer data)
......
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