new PDB wrappers in libgimp and plugin code cleanup

--Sven
This commit is contained in:
Sven Neumann 2000-01-14 21:38:47 +00:00
parent 078f6cfe3d
commit f4fc693164
14 changed files with 187 additions and 295 deletions

View File

@ -1,3 +1,19 @@
Fri Jan 14 22:34:13 CET 2000 Sven Neumann <sven@gimp.org>
* libgimp/gimp.h
* libgimp/gimpselection.c: added a few new PDB wrappers
* plug-ins/common/align_layers.c
* plug-ins/common/blinds.c
* plug-ins/common/checkerboard.c
* plug-ins/common/curve_bend.c
* plug-ins/common/guillotine.c
* plug-ins/common/sample_colorize.c
* plug-ins/gdyntext/gdyntext.c
* plug-ins/sel2path/sel2path.c
* plug-ins/twain/twain.c
* plug-ins/winsnap/winsnap.c: replaced PDB calls with libgimp functions
Fri Jan 14 20:54:31 CET 2000 Sven Neumann <sven@gimp.org>
* app/module_db.c

View File

@ -746,11 +746,18 @@ guchar* gimp_drawable_get_thumbnail_data (gint32 drawable_ID,
* Selections *
****************************************/
gint32 gimp_selection_is_empty (gint32 image_ID);
gint32 gimp_selection_bounds (gint32 image_ID,
gint32 *non_empty,
gint32 *x1,
gint32 *y1,
gint32 *x2,
gint32 *y2);
gint32 gimp_selection_float (gint32 image_ID,
gint32 drawable_ID,
gint32 x_offset,
gint32 y_offset);
gint32 gimp_selection_is_empty (gint32 image_ID);
void gimp_selection_none (gint32 image_ID);
/****************************************

View File

@ -20,24 +20,36 @@
#include "gimp.h"
gint32
gimp_selection_is_empty (gint32 image_ID)
gimp_selection_bounds (gint32 image_ID,
gint *non_empty,
gint *x1,
gint *y1,
gint *x2,
gint *y2)
{
GParam *return_vals;
int nreturn_vals;
gint32 is_empty;
gint nreturn_vals;
gint result;
return_vals = gimp_run_procedure ("gimp_selection_bounds",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
result = FALSE;
return_vals = gimp_run_procedure ("gimp_selection_is_empty",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
is_empty = TRUE;
if (return_vals[0].data.d_status == STATUS_SUCCESS)
is_empty = return_vals[1].data.d_int32;
{
result = TRUE;
*non_empty = return_vals[1].data.d_int32;
*x1 = return_vals[2].data.d_int32;
*y1 = return_vals[3].data.d_int32;
*x2 = return_vals[4].data.d_int32;
*y2 = return_vals[5].data.d_int32;
}
gimp_destroy_params (return_vals, nreturn_vals);
return is_empty;
return result;
}
gint32
@ -66,3 +78,39 @@ gimp_selection_float (gint32 image_ID,
return layer_ID;
}
gint32
gimp_selection_is_empty (gint32 image_ID)
{
GParam *return_vals;
gint nreturn_vals;
gint32 is_empty;
return_vals = gimp_run_procedure ("gimp_selection_is_empty",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
is_empty = TRUE;
if (return_vals[0].data.d_status == STATUS_SUCCESS)
is_empty = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return is_empty;
}
void
gimp_selection_none (gint32 image_ID)
{
GParam *return_vals;
gint nreturn_vals;
return_vals = gimp_run_procedure ("gimp_selection_none",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
gimp_destroy_params (return_vals, nreturn_vals);
return;
}

View File

@ -20,24 +20,36 @@
#include "gimp.h"
gint32
gimp_selection_is_empty (gint32 image_ID)
gimp_selection_bounds (gint32 image_ID,
gint *non_empty,
gint *x1,
gint *y1,
gint *x2,
gint *y2)
{
GParam *return_vals;
int nreturn_vals;
gint32 is_empty;
gint nreturn_vals;
gint result;
return_vals = gimp_run_procedure ("gimp_selection_bounds",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
result = FALSE;
return_vals = gimp_run_procedure ("gimp_selection_is_empty",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
is_empty = TRUE;
if (return_vals[0].data.d_status == STATUS_SUCCESS)
is_empty = return_vals[1].data.d_int32;
{
result = TRUE;
*non_empty = return_vals[1].data.d_int32;
*x1 = return_vals[2].data.d_int32;
*y1 = return_vals[3].data.d_int32;
*x2 = return_vals[4].data.d_int32;
*y2 = return_vals[5].data.d_int32;
}
gimp_destroy_params (return_vals, nreturn_vals);
return is_empty;
return result;
}
gint32
@ -66,3 +78,39 @@ gimp_selection_float (gint32 image_ID,
return layer_ID;
}
gint32
gimp_selection_is_empty (gint32 image_ID)
{
GParam *return_vals;
gint nreturn_vals;
gint32 is_empty;
return_vals = gimp_run_procedure ("gimp_selection_is_empty",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
is_empty = TRUE;
if (return_vals[0].data.d_status == STATUS_SUCCESS)
is_empty = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return is_empty;
}
void
gimp_selection_none (gint32 image_ID)
{
GParam *return_vals;
gint nreturn_vals;
return_vals = gimp_run_procedure ("gimp_selection_none",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
gimp_destroy_params (return_vals, nreturn_vals);
return;
}

View File

@ -290,9 +290,7 @@ run (gchar *name,
static GStatusType
align_layers (gint32 image_id)
{
GParam* return_vals;
gint retvals;
gint layer_num = 0;
gint layer_num = 0;
gint visible_layer_num = 1;
gint *layers = NULL;
gint index, vindex;
@ -369,11 +367,7 @@ align_layers (gint32 image_id)
base_y = min_y;
}
return_vals = gimp_run_procedure ("gimp_undo_push_group_start",
&retvals,
PARAM_IMAGE, image_id,
PARAM_END);
gimp_destroy_params (return_vals, retvals);
gimp_undo_push_group_start (image_id);
for (vindex = -1, index = 0; index < layer_num; index++)
{
@ -427,11 +421,9 @@ align_layers (gint32 image_id)
}
gimp_layer_set_offsets (layers[index], x, y);
}
return_vals = gimp_run_procedure ("gimp_undo_push_group_end",
&retvals,
PARAM_IMAGE, image_id,
PARAM_END);
gimp_destroy_params (return_vals, retvals);
gimp_undo_push_group_end (image_id);
return STATUS_SUCCESS;
}

View File

@ -809,8 +809,6 @@ blindsapply (guchar *srow,
static int
blinds_get_bg (guchar *bg)
{
GParam *return_vals;
gint nreturn_vals;
/* Get the background color */
int retval = FALSE; /*Return TRUE if of GREYA type */
@ -821,25 +819,7 @@ blinds_get_bg (guchar *bg)
break;
case RGB_IMAGE :
return_vals = gimp_run_procedure ("gimp_palette_get_foreground",
&nreturn_vals,
PARAM_END);
return_vals = gimp_run_procedure ("gimp_palette_get_background",
&nreturn_vals,
PARAM_END);
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
bg[0] = return_vals[1].data.d_color.red;
bg[1] = return_vals[1].data.d_color.green;
bg[2] = return_vals[1].data.d_color.blue;
}
else
{
bg[0] = 0;
bg[1] = 0;
bg[2] = 0;
}
gimp_palette_get_background (&bg[0], &bg[1], &bg[2]);
break;
case GRAYA_IMAGE:

View File

@ -192,14 +192,12 @@ static void
check (GDrawable *drawable)
{
GPixelRgn dest_rgn;
GParam *return_vals;
gint nreturn_vals;
guchar *dest_row;
guchar *dest;
gint row, col;
gint progress, max_progress;
gint x1, y1, x2, y2, x, y;
guint8 fg[4],bg[4];
guchar fg[4],bg[4];
gint bp;
gpointer pr;
@ -217,45 +215,14 @@ check (GDrawable *drawable)
case RGBA_IMAGE:
fg[3] = 255;
bg[3] = 255;
case RGB_IMAGE :
return_vals = gimp_run_procedure ("gimp_palette_get_foreground",
&nreturn_vals,
PARAM_END);
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
fg[0] = return_vals[1].data.d_color.red;
fg[1] = return_vals[1].data.d_color.green;
fg[2] = return_vals[1].data.d_color.blue;
}
else
{
fg[0] = 255;
fg[1] = 255;
fg[2] = 255;
}
return_vals = gimp_run_procedure ("gimp_palette_get_background",
&nreturn_vals,
PARAM_END);
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
bg[0] = return_vals[1].data.d_color.red;
bg[1] = return_vals[1].data.d_color.green;
bg[2] = return_vals[1].data.d_color.blue;
}
else
{
bg[0] = 0;
bg[1] = 0;
bg[2] = 0;
}
case RGB_IMAGE:
gimp_palette_get_foreground (&fg[0], &fg[1], &fg[2]);
gimp_palette_get_background (&bg[0], &bg[1], &bg[2]);
break;
case GRAYA_IMAGE:
fg[1] = 255;
bg[1] = 255;
case GRAY_IMAGE :
case GRAY_IMAGE:
fg[0] = 255;
bg[0] = 0;
break;

View File

@ -547,35 +547,6 @@ gint32 p_gimp_edit_paste(gint32 image_id, gint32 drawable_id, gint32 paste_into
return(-1);
} /* end p_gimp_edit_paste */
/* ============================================================================
* p_get_gimp_selection_bounds
*
* ============================================================================
*/
gint
p_get_gimp_selection_bounds (gint32 image_id, gint32 *x1, gint32 *y1, gint32 *x2, gint32 *y2)
{
static char *l_get_sel_bounds_proc = "gimp_selection_bounds";
GParam *return_vals;
int nreturn_vals;
return_vals = gimp_run_procedure (l_get_sel_bounds_proc,
&nreturn_vals,
PARAM_IMAGE, image_id,
PARAM_END);
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
*x1 = return_vals[2].data.d_int32;
*y1 = return_vals[3].data.d_int32;
*x2 = return_vals[4].data.d_int32;
*y2 = return_vals[5].data.d_int32;
return(return_vals[1].data.d_int32);
}
printf("Error: PDB call of %s failed staus=%d\n",
l_get_sel_bounds_proc, (int)return_vals[0].data.d_status);
return(FALSE);
} /* end p_get_gimp_selection_bounds */
/* ============================================================================
* p_if_selection_float_it
@ -587,7 +558,8 @@ p_if_selection_float_it(gint32 image_id, gint32 layer_id)
{
gint32 l_sel_channel_id;
gint32 l_layer_id;
gint32 l_x1, l_x2, l_y1, l_y2;
gint32 l_x1, l_x2, l_y1, l_y2;
gint32 non_empty;
l_layer_id = layer_id;
if(!gimp_layer_is_floating_selection (layer_id) )
@ -595,8 +567,8 @@ p_if_selection_float_it(gint32 image_id, gint32 layer_id)
/* check and see if we have a selection mask */
l_sel_channel_id = gimp_image_get_selection(image_id);
if((p_get_gimp_selection_bounds(image_id, &l_x1, &l_y1, &l_x2, &l_y2))
&& (l_sel_channel_id >= 0))
if (gimp_selection_bounds (image_id, &non_empty, &l_x1, &l_y1, &l_x2, &l_y2)
&& (l_sel_channel_id >= 0))
{
/* selection is TRUE, make a layer (floating selection) from the selection */
p_gimp_edit_copy(image_id, layer_id);
@ -817,8 +789,7 @@ run (char *name, /* name of plugin */
l_image_id = param[1].data.d_int32;
l_layer_id = param[2].data.d_drawable;
gimp_run_procedure ("gimp_undo_push_group_start", &l_nreturn_vals,
PARAM_IMAGE, l_image_id, PARAM_END);
gimp_undo_push_group_start (l_image_id);
if(!gimp_drawable_is_layer(l_layer_id))
{
@ -933,8 +904,7 @@ run (char *name, /* name of plugin */
values[0].data.d_status = status;
values[1].data.d_int32 = l_bent_layer_id; /* return the id of handled layer */
gimp_run_procedure ("gimp_undo_push_group_end", &l_nreturn_vals,
PARAM_IMAGE, l_image_id, PARAM_END);
gimp_undo_push_group_end (l_image_id);
if(gb_debug) printf("end run curve_bend plugin\n");

View File

@ -243,9 +243,7 @@ guillotine(gint32 image_ID)
gimp_image_undo_disable (new_image);
gimp_run_procedure ("gimp_undo_push_group_start", &nreturn_vals,
PARAM_IMAGE, new_image,
PARAM_END);
/* gimp_undo_push_group_start (new_image); */
/* printf("(%dx%d:%d,%d:%d,%d)\n", */
/* (vguides[x+1]-vguides[x]), */
@ -261,9 +259,7 @@ guillotine(gint32 image_ID)
PARAM_INT32, hguides[y],
PARAM_END);
gimp_run_procedure ("gimp_undo_push_group_end", &nreturn_vals,
PARAM_IMAGE, new_image,
PARAM_END);
/* gimp_undo_push_group_end (new_image); */
gimp_image_undo_enable (new_image);

View File

@ -1694,35 +1694,6 @@ p_gimp_convert_rgb (gint32 image_id)
return(FALSE);
} /* end p_gimp_convert_rgb */
/* ============================================================================
* p_get_gimp_selection_bounds
*
* ============================================================================
*/
gint
p_get_gimp_selection_bounds (gint32 image_id, gint32 *x1, gint32 *y1, gint32 *x2, gint32 *y2)
{
static char *l_get_sel_bounds_proc = "gimp_selection_bounds";
GParam *return_vals;
int nreturn_vals;
return_vals = gimp_run_procedure (l_get_sel_bounds_proc,
&nreturn_vals,
PARAM_IMAGE, image_id,
PARAM_END);
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
*x1 = return_vals[2].data.d_int32;
*y1 = return_vals[3].data.d_int32;
*x2 = return_vals[4].data.d_int32;
*y2 = return_vals[5].data.d_int32;
return(return_vals[1].data.d_int32);
}
printf("Error: PDB call of %s failed staus=%d\n",
l_get_sel_bounds_proc, (int)return_vals[0].data.d_status);
return(FALSE);
} /* end p_get_gimp_selection_bounds */
/* -----------------------------
* DEBUG print procedures START
@ -2575,6 +2546,7 @@ p_init_gdrw(t_GDRW *gdrw, GDrawable *drawable, int dirty, int shadow)
gint l_offsetx, l_offsety;
gint l_sel_offsetx, l_sel_offsety;
t_GDRW *l_sel_gdrw;
gint32 non_empty;
if(g_Sdebug) printf("\np_init_gdrw: drawable %x ID: %d\n", (int)drawable, (int)drawable->id);
@ -2623,8 +2595,8 @@ p_init_gdrw(t_GDRW *gdrw, GDrawable *drawable, int dirty, int shadow)
printf("p_init_gdrw: OFFS x: %d y: %d\n", (int)l_offsetx, (int)l_offsety );
}
if((p_get_gimp_selection_bounds(l_image_id, &l_x1, &l_y1, &l_x2, &l_y2))
&& (l_sel_channel_id >= 0))
if (gimp_selection_bounds (l_image_id, &non_empty, &l_x1, &l_y1, &l_x2, &l_y2)
&& (l_sel_channel_id >= 0))
{
/* selection is TRUE */
l_sel_gdrw = (t_GDRW *) calloc(1, sizeof(t_GDRW));

View File

@ -413,7 +413,7 @@ void gdt_render_text(GdtVals *data)
void gdt_render_text_p(GdtVals *data, gboolean show_progress)
{
gint layer_ox, layer_oy, i, nret_vals, xoffs;
gint32 layer_f, selection_empty, selection_channel;
gint32 layer_f, selection_channel;
gint32 text_width, text_height;
gint32 text_ascent, text_descent;
gint32 layer_width, layer_height;
@ -422,26 +422,25 @@ void gdt_render_text_p(GdtVals *data, gboolean show_progress)
gint32 *text_lines_w;
GParam *ret_vals;
GParamColor old_color, text_color;
gint32 selection_empty;
if (show_progress)
gimp_progress_init(_("GIMP Dynamic Text"));
gimp_undo_push_group_start (data->image_id);
/* save and remove current selection */
ret_vals = gimp_run_procedure("gimp_selection_is_empty", &nret_vals,
PARAM_IMAGE, data->image_id, PARAM_END);
selection_empty = ret_vals[1].data.d_int32;
gimp_destroy_params(ret_vals, nret_vals);
if (selection_empty == FALSE) {
/* there is an active selection to save */
ret_vals = gimp_run_procedure("gimp_selection_save", &nret_vals,
PARAM_IMAGE, data->image_id, PARAM_END);
selection_channel = ret_vals[1].data.d_int32;
gimp_destroy_params(ret_vals, nret_vals);
ret_vals = gimp_run_procedure("gimp_selection_none", &nret_vals,
PARAM_IMAGE, data->image_id, PARAM_END);
gimp_destroy_params(ret_vals, nret_vals);
}
selection_empty = gimp_selection_is_empty (data->image_id);
if (!selection_empty)
{
/* there is an active selection to save */
ret_vals = gimp_run_procedure("gimp_selection_save", &nret_vals,
PARAM_IMAGE, data->image_id, PARAM_END);
selection_channel = ret_vals[1].data.d_int32;
gimp_destroy_params(ret_vals, nret_vals);
gimp_selection_none (data->image_id);
}
text_style = g_strsplit(data->font_style, "-", 3);

View File

@ -38,13 +38,13 @@
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#include "libgimp/stdplugins-intl.h"
#include "global.h"
#include "types.h"
#include "pxl-outline.h"
#include "fit.h"
#include "spline.h"
#include "sel2path.h"
#include "libgimp/stdplugins-intl.h"
#define MID_POINT 127
@ -66,9 +66,6 @@ static void sel2path_reset_callback (GtkWidget *,gpointer);
static void dialog_print_selVals(SELVALS *);
gboolean do_sel2path (gint32,gint32);
static gint gimp_selection_bounds (gint32,gint *,gint *,gint *,gint *,gint *);
static gint gimp_selection_is_empty (gint32);
static gint gimp_selection_none (gint32);
static gint gimp_path_set_points (gint32,gchar *,gint,gint,gdouble *);
@ -616,39 +613,6 @@ do_sel2path(gint32 drawable_ID,gint32 image_ID )
return TRUE;
}
static gint
gimp_selection_bounds (gint32 image_ID,
gint *has_sel,
gint *x1,
gint *y1,
gint *x2,
gint *y2)
{
GParam *return_vals;
int nreturn_vals;
int result;
return_vals = gimp_run_procedure ("gimp_selection_bounds",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
result = FALSE;
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
result = TRUE;
*has_sel = return_vals[1].data.d_int32;
*x1 = return_vals[2].data.d_int32;
*y1 = return_vals[3].data.d_int32;
*x2 = return_vals[4].data.d_int32;
*y2 = return_vals[5].data.d_int32;
}
gimp_destroy_params (return_vals, nreturn_vals);
return result;
}
static gint
gimp_path_set_points (gint32 image_ID,
gchar *name,
@ -689,52 +653,6 @@ gimp_path_set_points (gint32 image_ID,
return result;
}
static gint
gimp_selection_is_empty (gint32 image_ID)
{
GParam *return_vals;
gint nreturn_vals;
gint result;
return_vals = gimp_run_procedure ("gimp_selection_is_empty",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
result = FALSE;
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
result = return_vals[1].data.d_int32;
}
gimp_destroy_params (return_vals, nreturn_vals);
return result;
}
static gint
gimp_selection_none (gint32 image_ID)
{
GParam *return_vals;
gint nreturn_vals;
gint result;
return_vals = gimp_run_procedure ("gimp_selection_none",
&nreturn_vals,
PARAM_IMAGE, image_ID,
PARAM_END);
result = FALSE;
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
result = return_vals[1].data.d_int32;
}
gimp_destroy_params (return_vals, nreturn_vals);
return result;
}
void
safe_free (address *item)
{

View File

@ -513,24 +513,6 @@ query(void)
return_vals);
}
/*
* twainDisplayImage
*
* Display the image specified by the image id.
*/
static gint
twainDisplayImage(gint32 image)
{
GParam *params;
gint retval;
params = gimp_run_procedure ("gimp_display_new",
&retval,
PARAM_IMAGE, image,
PARAM_END);
return retval;
}
/* Return values storage */
static GParam values[3];
@ -1109,7 +1091,7 @@ endTransferCallback(int completionState, int pendingCount, void *clientData)
/* Display the image */
LogMessage("Displaying image %d\n", theClientData->image_id);
twainDisplayImage(theClientData->image_id);
gimp_display_new (theClientData->image_id);
} else {
/* The transfer did not complete successfully */
LogMessage("Deleting image\n");

View File

@ -83,7 +83,7 @@ static void init(void);
static void quit(void);
static void query(void);
static void run(char *, int, GParam *, int *, GParam **);
static gint sendBMPToGimp(HBITMAP hBMP, HDC hDC, RECT rect);
static void sendBMPToGimp(HBITMAP hBMP, HDC hDC, RECT rect);
BOOL CALLBACK dialogProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
@ -1160,16 +1160,14 @@ flipRedAndBlueBytes(int width, int height)
* Take the captured data and send it across
* to the GIMP.
*/
static gint
static void
sendBMPToGimp(HBITMAP hBMP, HDC hDC, RECT rect)
{
int row;
int width, height;
int imageType, layerType;
gint retval;
gint32 image_id;
gint32 layer_id;
GParam *params;
GPixelRgn pixel_rgn;
GDrawable *drawable;
@ -1218,8 +1216,7 @@ sendBMPToGimp(HBITMAP hBMP, HDC hDC, RECT rect)
}
/* Finish up */
gimp_drawable_detach(drawable);
params = gimp_run_procedure ("gimp_display_new", &retval,
PARAM_IMAGE, image_id, PARAM_END);
return retval;
gimp_display_new (image_id);
return;
}