Fixed some selection editor problems (bug #127644):

2003-11-22  Sven Neumann  <sven@gimp.org>

	Fixed some selection editor problems (bug #127644):

	* plug-ins/sel2path/sel2path.c: use the given image_ID, ignore the
	drawable_ID. This plug-in doesn't operate on a drawable at all.

	* plug-ins/imagemap/imap_main.c: pass a valid image_ID to sel2path.

	* app/gui/vectors-commands.c: don't attempt to create a valid
	drawable_ID for the call to sel2path since it isn't used anyway.

	* app/core/gimpdrawable-stroke.c (gimp_drawable_stroke_boundary):
	just return when being called with an empty boundary.
This commit is contained in:
Sven Neumann 2003-11-22 13:38:11 +00:00 committed by Sven Neumann
parent c0c1043a6d
commit 722fb64dbd
6 changed files with 63 additions and 55 deletions

View File

@ -1,3 +1,18 @@
2003-11-22 Sven Neumann <sven@gimp.org>
Fixed some selection editor problems (bug #127644):
* plug-ins/sel2path/sel2path.c: use the given image_ID, ignore the
drawable_ID. This plug-in doesn't operate on a drawable at all.
* plug-ins/imagemap/imap_main.c: pass a valid image_ID to sel2path.
* app/gui/vectors-commands.c: don't attempt to create a valid
drawable_ID for the call to sel2path since it isn't used anyway.
* app/core/gimpdrawable-stroke.c (gimp_drawable_stroke_boundary):
just return when being called with an empty boundary.
2003-11-22 Sven Neumann <sven@gimp.org> 2003-11-22 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpwidgets.def: added symbols for * libgimpwidgets/gimpwidgets.def: added symbols for

View File

@ -302,14 +302,10 @@ vectors_selection_to_vectors (GimpImage *gimage,
{ {
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
GimpDrawable *drawable;
GimpDisplay *gdisp; GimpDisplay *gdisp;
g_return_if_fail (GIMP_IS_IMAGE (gimage)); g_return_if_fail (GIMP_IS_IMAGE (gimage));
drawable = gimp_image_active_drawable (gimage);
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
if (advanced) if (advanced)
proc_rec = procedural_db_lookup (gimage->gimp, proc_rec = procedural_db_lookup (gimage->gimp,
"plug_in_sel2path_advanced"); "plug_in_sel2path_advanced");
@ -323,6 +319,8 @@ vectors_selection_to_vectors (GimpImage *gimage,
return; return;
} }
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
/* plug-in arguments as if called by <Image>/Filters/... */ /* plug-in arguments as if called by <Image>/Filters/... */
args = g_new (Argument, 3); args = g_new (Argument, 3);
@ -331,7 +329,7 @@ vectors_selection_to_vectors (GimpImage *gimage,
args[1].arg_type = GIMP_PDB_IMAGE; args[1].arg_type = GIMP_PDB_IMAGE;
args[1].value.pdb_int = (gint32) gimp_image_get_ID (gimage); args[1].value.pdb_int = (gint32) gimp_image_get_ID (gimage);
args[2].arg_type = GIMP_PDB_DRAWABLE; args[2].arg_type = GIMP_PDB_DRAWABLE;
args[2].value.pdb_int = (gint32) gimp_item_get_ID (GIMP_ITEM (drawable)); args[2].value.pdb_int = -1; /* unused */
plug_in_run (gimage->gimp, plug_in_run (gimage->gimp,
proc_rec, args, 3, FALSE, TRUE, proc_rec, args, 3, FALSE, TRUE,

View File

@ -78,8 +78,11 @@ gimp_drawable_stroke_boundary (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options)); g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
if (n_bound_segs == 0)
return;
g_return_if_fail (bound_segs != NULL); g_return_if_fail (bound_segs != NULL);
g_return_if_fail (n_bound_segs > 0);
sorted_segs = sort_boundary (bound_segs, n_bound_segs, &n_stroke_segs); sorted_segs = sort_boundary (bound_segs, n_bound_segs, &n_stroke_segs);
stroke_segs = simplify_boundary (sorted_segs, n_stroke_segs, &n_bound_segs); stroke_segs = simplify_boundary (sorted_segs, n_stroke_segs, &n_bound_segs);

View File

@ -302,14 +302,10 @@ vectors_selection_to_vectors (GimpImage *gimage,
{ {
ProcRecord *proc_rec; ProcRecord *proc_rec;
Argument *args; Argument *args;
GimpDrawable *drawable;
GimpDisplay *gdisp; GimpDisplay *gdisp;
g_return_if_fail (GIMP_IS_IMAGE (gimage)); g_return_if_fail (GIMP_IS_IMAGE (gimage));
drawable = gimp_image_active_drawable (gimage);
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
if (advanced) if (advanced)
proc_rec = procedural_db_lookup (gimage->gimp, proc_rec = procedural_db_lookup (gimage->gimp,
"plug_in_sel2path_advanced"); "plug_in_sel2path_advanced");
@ -323,6 +319,8 @@ vectors_selection_to_vectors (GimpImage *gimage,
return; return;
} }
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
/* plug-in arguments as if called by <Image>/Filters/... */ /* plug-in arguments as if called by <Image>/Filters/... */
args = g_new (Argument, 3); args = g_new (Argument, 3);
@ -331,7 +329,7 @@ vectors_selection_to_vectors (GimpImage *gimage,
args[1].arg_type = GIMP_PDB_IMAGE; args[1].arg_type = GIMP_PDB_IMAGE;
args[1].value.pdb_int = (gint32) gimp_image_get_ID (gimage); args[1].value.pdb_int = (gint32) gimp_image_get_ID (gimage);
args[2].arg_type = GIMP_PDB_DRAWABLE; args[2].arg_type = GIMP_PDB_DRAWABLE;
args[2].value.pdb_int = (gint32) gimp_item_get_ID (GIMP_ITEM (drawable)); args[2].value.pdb_int = -1; /* unused */
plug_in_run (gimage->gimp, plug_in_run (gimage->gimp,
proc_rec, args, 3, FALSE, TRUE, proc_rec, args, 3, FALSE, TRUE,

View File

@ -416,13 +416,14 @@ set_arrow_func(void)
} }
static gboolean static gboolean
fuzzy_select_on_button_press(GtkWidget *widget, GdkEventButton *event, fuzzy_select_on_button_press (GtkWidget *widget,
gpointer data) GdkEventButton *event,
gpointer data)
{ {
if (event->button == 1) { if (event->button == 1) {
gdouble rx = get_real_coord((gint) event->x); gdouble rx = get_real_coord((gint) event->x);
gdouble ry = get_real_coord((gint) event->y); gdouble ry = get_real_coord((gint) event->y);
gint32 image_ID = gimp_drawable_image(_drawable->drawable_id); gint32 image_ID = gimp_drawable_image (_drawable->drawable_id);
gint32 channel_ID; gint32 channel_ID;
/* Save the old selection first */ /* Save the old selection first */
@ -433,16 +434,17 @@ fuzzy_select_on_button_press(GtkWidget *widget, GdkEventButton *event,
GIMP_CHANNEL_OP_REPLACE, GIMP_CHANNEL_OP_REPLACE,
FALSE, FALSE, 0, FALSE)) { FALSE, FALSE, 0, FALSE)) {
GimpParam *return_vals; GimpParam *return_vals;
gint nreturn_vals; gint nreturn_vals;
return_vals = gimp_run_procedure("plug_in_sel2path", return_vals = gimp_run_procedure ("plug_in_sel2path",
&nreturn_vals, &nreturn_vals,
GIMP_PDB_INT32, TRUE, GIMP_PDB_INT32, TRUE,
GIMP_PDB_IMAGE, 0, GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_DRAWABLE, GIMP_PDB_DRAWABLE, -1,
_drawable->drawable_id, GIMP_PDB_END);
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) { if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
gdouble distance; gdouble distance;
gchar *path_name = gimp_path_get_current(image_ID); gchar *path_name = gimp_path_get_current(image_ID);
Object_t *object = create_polygon(NULL); Object_t *object = create_polygon(NULL);

View File

@ -67,8 +67,7 @@ static void sel2path_response (GtkWidget *widget,
gint response_id, gint response_id,
gpointer data); gpointer data);
static void dialog_print_selVals (SELVALS *sels); static void dialog_print_selVals (SELVALS *sels);
gboolean do_sel2path (gint32 drawable_ID, gboolean do_sel2path (gint32 image_ID);
gint32 image_ID);
GimpPlugInInfo PLUG_IN_INFO = GimpPlugInInfo PLUG_IN_INFO =
@ -93,15 +92,15 @@ query (void)
static GimpParamDef args[] = static GimpParamDef args[] =
{ {
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" }, { GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" }, { GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }, { GIMP_PDB_DRAWABLE, "drawable", "Input drawable (unused)" },
}; };
static GimpParamDef advanced_args[] = static GimpParamDef advanced_args[] =
{ {
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" }, { GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" }, { GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }, { GIMP_PDB_DRAWABLE, "drawable", "Input drawable (unused)" },
{ GIMP_PDB_FLOAT, "align_threshold", "align_threshold"}, { GIMP_PDB_FLOAT, "align_threshold", "align_threshold"},
{ GIMP_PDB_FLOAT, "corner_always_threshold", "corner_always_threshold"}, { GIMP_PDB_FLOAT, "corner_always_threshold", "corner_always_threshold"},
{ GIMP_PDB_INT8, "corner_surround", "corner_surround"}, { GIMP_PDB_INT8, "corner_surround", "corner_surround"},
@ -157,8 +156,6 @@ run (const gchar *name,
GimpParam **return_vals) GimpParam **return_vals)
{ {
static GimpParam values[1]; static GimpParam values[1];
GimpDrawable *drawable;
gint32 drawable_ID;
gint32 image_ID; gint32 image_ID;
GimpRunMode run_mode; GimpRunMode run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS; GimpPDBStatusType status = GIMP_PDB_SUCCESS;
@ -176,19 +173,20 @@ run (const gchar *name,
values[0].type = GIMP_PDB_STATUS; values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status; values[0].data.d_status = status;
drawable_ID = param[2].data.d_drawable; image_ID = param[1].data.d_image;
drawable = gimp_drawable_get (drawable_ID); if (image_ID < 0)
{
image_ID = gimp_drawable_image_id (drawable_ID); g_warning ("plug_in_sel2path needs a valid image ID");
return;
}
if (gimp_selection_is_empty (image_ID)) if (gimp_selection_is_empty (image_ID))
{ {
g_message (_("No selection to convert")); g_message (_("No selection to convert"));
gimp_drawable_detach (drawable);
return; return;
} }
fit_set_default_params(&selVals); fit_set_default_params (&selVals);
if (!no_dialog) if (!no_dialog)
{ {
@ -201,10 +199,8 @@ run (const gchar *name,
} }
if (!sel2path_dialog (&selVals)) if (!sel2path_dialog (&selVals))
{ return;
gimp_drawable_detach (drawable);
return;
}
/* Get the current settings */ /* Get the current settings */
fit_set_params (&selVals); fit_set_params (&selVals);
break; break;
@ -254,7 +250,7 @@ run (const gchar *name,
} }
} }
do_sel2path (drawable_ID,image_ID); do_sel2path (image_ID);
values[0].data.d_status = status; values[0].data.d_status = status;
if (status == GIMP_PDB_SUCCESS) if (status == GIMP_PDB_SUCCESS)
@ -263,8 +259,6 @@ run (const gchar *name,
if (run_mode == GIMP_RUN_INTERACTIVE && !no_dialog) if (run_mode == GIMP_RUN_INTERACTIVE && !no_dialog)
gimp_set_data ("plug_in_sel2path_advanced", &selVals, sizeof(SELVALS)); gimp_set_data ("plug_in_sel2path_advanced", &selVals, sizeof(SELVALS));
} }
gimp_drawable_detach (drawable);
} }
static void static void
@ -531,13 +525,12 @@ do_points (spline_list_array_type in_splines,
gboolean gboolean
do_sel2path (gint32 drawable_ID, do_sel2path (gint32 image_ID)
gint32 image_ID)
{ {
gint32 selection_ID; gint32 selection_ID;
GimpDrawable *sel_drawable; GimpDrawable *sel_drawable;
pixel_outline_list_type olt; pixel_outline_list_type olt;
spline_list_array_type splines; spline_list_array_type splines;
gimp_selection_bounds (image_ID, &has_sel, gimp_selection_bounds (image_ID, &has_sel,
&sel_x1, &sel_y1, &sel_x2, &sel_y2); &sel_x1, &sel_y1, &sel_x2, &sel_y2);
@ -547,13 +540,10 @@ do_sel2path (gint32 drawable_ID,
/* Now get the selection channel */ /* Now get the selection channel */
selection_ID = gimp_image_get_selection(image_ID); selection_ID = gimp_image_get_selection (image_ID);
if (selection_ID < 0) if (selection_ID < 0)
{ return FALSE;
g_warning ("gimp_image_get_selection failed");
return FALSE;
}
sel_drawable = gimp_drawable_get (selection_ID); sel_drawable = gimp_drawable_get (selection_ID);
@ -576,6 +566,8 @@ do_sel2path (gint32 drawable_ID,
do_points (splines, image_ID); do_points (splines, image_ID);
gimp_drawable_detach (sel_drawable);
gimp_displays_flush (); gimp_displays_flush ();
return TRUE; return TRUE;