Skip to content

Commit 1fbd2ac

Browse files
author
Jehan
committed
app, pdb, plug-ins: get rid of (plug-in-rotate).
It can be reimplemented with (gimp-image-rotate) and (gimp-item-transform-rotate-simple), with even more capabilities for the latter. The item rotate procedure is a bit more tricky though, since it takes into account the selection. It means that either you want to just remove the selection before (that's what I did here, because this script was already losing the selection anyway), or you want to store the selection (with (gimp-channel-copy)), then reapply it (very likely with (gimp-channel-combine-masks)) at the end, after also rotating it appropriately the same way as the image if needed.
1 parent c26b2cd commit 1fbd2ac

File tree

4 files changed

+7
-159
lines changed

4 files changed

+7
-159
lines changed

app/pdb/internal-procs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "internal-procs.h"
3131

3232

33-
/* 721 procedures registered total */
33+
/* 720 procedures registered total */
3434

3535
void
3636
internal_procs_init (GimpPDB *pdb)

app/pdb/plug-in-compat-cmds.c

-98
Original file line numberDiff line numberDiff line change
@@ -564,56 +564,6 @@ plug_in_displace_invoker (GimpProcedure *procedure,
564564
error ? *error : NULL);
565565
}
566566

567-
static GimpValueArray *
568-
plug_in_rotate_invoker (GimpProcedure *procedure,
569-
Gimp *gimp,
570-
GimpContext *context,
571-
GimpProgress *progress,
572-
const GimpValueArray *args,
573-
GError **error)
574-
{
575-
gboolean success = TRUE;
576-
GimpImage *image;
577-
GimpDrawable *drawable;
578-
gint angle;
579-
gboolean everything;
580-
581-
image = g_value_get_object (gimp_value_array_index (args, 1));
582-
drawable = g_value_get_object (gimp_value_array_index (args, 2));
583-
angle = g_value_get_int (gimp_value_array_index (args, 3));
584-
everything = g_value_get_boolean (gimp_value_array_index (args, 4));
585-
586-
if (success)
587-
{
588-
GimpRotationType rotate_type = angle - 1;
589-
590-
if (everything)
591-
{
592-
gimp_image_rotate (image, context, rotate_type, progress);
593-
}
594-
else if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
595-
GIMP_PDB_ITEM_CONTENT, error))
596-
{
597-
GimpItem *item = GIMP_ITEM (drawable);
598-
gint off_x, off_y;
599-
gdouble center_x, center_y;
600-
601-
gimp_item_get_offset (item, &off_x, &off_y);
602-
603-
center_x = ((gdouble) off_x + (gdouble) gimp_item_get_width (item) / 2.0);
604-
center_y = ((gdouble) off_y + (gdouble) gimp_item_get_height (item) / 2.0);
605-
606-
gimp_item_rotate (item, context, rotate_type, center_x, center_y,
607-
GIMP_IS_CHANNEL (drawable));
608-
}
609-
else
610-
success = FALSE;
611-
}
612-
613-
return gimp_procedure_get_return_values (procedure, success,
614-
error ? *error : NULL);
615-
}
616-
617567
void
618568
register_plug_in_compat_procs (GimpPDB *pdb)
619569
{
@@ -870,52 +820,4 @@ register_plug_in_compat_procs (GimpPDB *pdb)
870820
GIMP_PARAM_READWRITE));
871821
gimp_pdb_register_procedure (pdb, procedure);
872822
g_object_unref (procedure);
873-
874-
/*
875-
* gimp-plug-in-rotate
876-
*/
877-
procedure = gimp_procedure_new (plug_in_rotate_invoker);
878-
gimp_object_set_static_name (GIMP_OBJECT (procedure),
879-
"plug-in-rotate");
880-
gimp_procedure_set_static_help (procedure,
881-
"Rotates a layer or the whole image by 90, 180 or 270 degrees",
882-
"This plug-in does rotate the active layer or the whole image clockwise by multiples of 90 degrees. When the whole image is chosen, the image is resized if necessary.",
883-
NULL);
884-
gimp_procedure_set_static_attribution (procedure,
885-
"Sven Neumann <[email protected]>",
886-
"Sven Neumann",
887-
"2014");
888-
gimp_procedure_add_argument (procedure,
889-
g_param_spec_enum ("run-mode",
890-
"run mode",
891-
"The run mode",
892-
GIMP_TYPE_RUN_MODE,
893-
GIMP_RUN_INTERACTIVE,
894-
GIMP_PARAM_READWRITE));
895-
gimp_procedure_add_argument (procedure,
896-
gimp_param_spec_image ("image",
897-
"image",
898-
"Input image (unused)",
899-
FALSE,
900-
GIMP_PARAM_READWRITE));
901-
gimp_procedure_add_argument (procedure,
902-
gimp_param_spec_drawable ("drawable",
903-
"drawable",
904-
"Input drawable",
905-
FALSE,
906-
GIMP_PARAM_READWRITE));
907-
gimp_procedure_add_argument (procedure,
908-
g_param_spec_int ("angle",
909-
"angle",
910-
"Angle { 90 (1), 180 (2), 270 (3) } degrees",
911-
1, 3, 1,
912-
GIMP_PARAM_READWRITE));
913-
gimp_procedure_add_argument (procedure,
914-
g_param_spec_boolean ("everything",
915-
"everything",
916-
"Rotate the whole image",
917-
FALSE,
918-
GIMP_PARAM_READWRITE));
919-
gimp_pdb_register_procedure (pdb, procedure);
920-
g_object_unref (procedure);
921823
}

pdb/groups/plug_in_compat.pdb

+1-58
Original file line numberDiff line numberDiff line change
@@ -281,62 +281,6 @@ CODE
281281

282282
# We simplify the GEGL signature, reducing tile width and height to just size
283283

284-
sub plug_in_rotate {
285-
$blurb = 'Rotates a layer or the whole image by 90, 180 or 270 degrees';
286-
287-
$help = <<'HELP';
288-
This plug-in does rotate the active layer or the whole image clockwise
289-
by multiples of 90 degrees. When the whole image is chosen, the image
290-
is resized if necessary.
291-
HELP
292-
293-
&neo_pdb_misc;
294-
$date = '2014';
295-
296-
@inargs = (
297-
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
298-
desc => 'The run mode' },
299-
{ name => 'image', type => 'image',
300-
desc => 'Input image (unused)' },
301-
{ name => 'drawable', type => 'drawable',
302-
desc => 'Input drawable' },
303-
{ name => 'angle', type => '1 <= int32 <= 3',
304-
desc => 'Angle { 90 (1), 180 (2), 270 (3) } degrees' },
305-
{ name => 'everything', type => 'boolean',
306-
desc => 'Rotate the whole image' }
307-
);
308-
309-
%invoke = (
310-
code => <<'CODE'
311-
{
312-
GimpRotationType rotate_type = angle - 1;
313-
314-
if (everything)
315-
{
316-
gimp_image_rotate (image, context, rotate_type, progress);
317-
}
318-
else if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
319-
GIMP_PDB_ITEM_CONTENT, error))
320-
{
321-
GimpItem *item = GIMP_ITEM (drawable);
322-
gint off_x, off_y;
323-
gdouble center_x, center_y;
324-
325-
gimp_item_get_offset (item, &off_x, &off_y);
326-
327-
center_x = ((gdouble) off_x + (gdouble) gimp_item_get_width (item) / 2.0);
328-
center_y = ((gdouble) off_y + (gdouble) gimp_item_get_height (item) / 2.0);
329-
330-
gimp_item_rotate (item, context, rotate_type, center_x, center_y,
331-
GIMP_IS_CHANNEL (drawable));
332-
}
333-
else
334-
success = FALSE;
335-
}
336-
CODE
337-
);
338-
}
339-
340284
$extra{app}->{code} = <<'CODE';
341285
static GeglNode *
342286
wrap_in_graph (GeglNode *node)
@@ -636,8 +580,7 @@ CODE
636580
@procs = qw(plug_in_autocrop
637581
plug_in_autocrop_layer
638582
plug_in_bump_map
639-
plug_in_displace
640-
plug_in_rotate);
583+
plug_in_displace);
641584

642585
%exports = (app => [@procs], lib => []);
643586

plug-ins/script-fu/scripts/slide.scm

+5-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@
121121
(/ (- width crop-width) 2)
122122
(/ (- height crop-height) 2))
123123
(if (< ratio 1)
124-
(plug-in-rotate RUN-NONINTERACTIVE image pic-layer 1 FALSE)
124+
(begin
125+
(gimp-selection-none image)
126+
(gimp-item-transform-rotate-simple pic-layer ROTATE-DEGREES90 TRUE 0 0)
127+
)
125128
)
126129

127130
; add the background layer
@@ -230,7 +233,7 @@
230233

231234
; eventually rotate the whole thing back
232235
(if (< ratio 1)
233-
(plug-in-rotate RUN-NONINTERACTIVE image pic-layer 3 TRUE)
236+
(gimp-image-rotate image ROTATE-DEGREES270)
234237
)
235238

236239
; clean up after the script

0 commit comments

Comments
 (0)