diff --git a/ChangeLog b/ChangeLog index f0628d0519..93f37b9496 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-12-03 Sven Neumann + + * tools/pdbgen/pdb/display.pdb + * tools/pdbgen/pdb/layer.pdb: applied a modified version of a + patch from Wolfgang Hofer that adds two new PDB + functions needed for GAP: gimp_displays_reconnect() and + gimp_layer_new_from_drawable() (bug #77508). + + * app/pdb/display_cmds.c + * app/pdb/internal_procs.c + * app/pdb/layer_cmds.c + * libgimp/gimpdisplay_pdb.[ch] + * libgimp/gimplayer_pdb.[ch]: regenerated. + 2002-12-03 Sven Neumann * app/tools/tool_manager.c (tool_manager_control_active): check diff --git a/app/pdb/display_cmds.c b/app/pdb/display_cmds.c index a5f0c883f1..d501898070 100644 --- a/app/pdb/display_cmds.c +++ b/app/pdb/display_cmds.c @@ -37,6 +37,7 @@ static ProcRecord display_new_proc; static ProcRecord display_delete_proc; static ProcRecord displays_flush_proc; +static ProcRecord displays_reconnect_proc; void register_display_procs (Gimp *gimp) @@ -44,6 +45,7 @@ register_display_procs (Gimp *gimp) procedural_db_register (gimp, &display_new_proc); procedural_db_register (gimp, &display_delete_proc); procedural_db_register (gimp, &displays_flush_proc); + procedural_db_register (gimp, &displays_reconnect_proc); } static Argument * @@ -177,3 +179,55 @@ static ProcRecord displays_flush_proc = NULL, { { displays_flush_invoker } } }; + +static Argument * +displays_reconnect_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + GimpImage *gimage_old; + GimpImage *gimage_new; + + gimage_old = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage_old)) + success = FALSE; + + gimage_new = gimp_image_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage_new)) + success = FALSE; + + if (success) + gdisplays_reconnect(gimage_old, gimage_new); + + return procedural_db_return_args (&displays_reconnect_proc, success); +} + +static ProcArg displays_reconnect_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "old_image", + "The old image (should have at least one display)" + }, + { + GIMP_PDB_IMAGE, + "new_image", + "The new image (must not have a display)" + } +}; + +static ProcRecord displays_reconnect_proc = +{ + "gimp_displays_reconnect", + "Reconnect displays from one image to another image.", + "This procedure connects all displays of the old_image to the new_image. If the new_image already has a display the reconnect is not performed and the procedure returns without success. You should rarely need to use this function.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + displays_reconnect_inargs, + 0, + NULL, + { { displays_reconnect_invoker } } +}; diff --git a/app/pdb/internal_procs.c b/app/pdb/internal_procs.c index 54b19efeb9..32d03bc6db 100644 --- a/app/pdb/internal_procs.c +++ b/app/pdb/internal_procs.c @@ -67,7 +67,7 @@ void register_transform_tools_procs (Gimp *gimp); void register_undo_procs (Gimp *gimp); void register_unit_procs (Gimp *gimp); -/* 336 procedures registered total */ +/* 338 procedures registered total */ void internal_procs_init (Gimp *gimp, @@ -82,91 +82,91 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Brushes"), 0.009); register_brushes_procs (gimp); - (* status_callback) (NULL, _("Channel"), 0.042); + (* status_callback) (NULL, _("Channel"), 0.041); register_channel_procs (gimp); (* status_callback) (NULL, _("Color"), 0.089); register_color_procs (gimp); - (* status_callback) (NULL, _("Convert"), 0.125); + (* status_callback) (NULL, _("Convert"), 0.124); register_convert_procs (gimp); - (* status_callback) (NULL, _("GimpDisplay procedures"), 0.134); + (* status_callback) (NULL, _("GimpDisplay procedures"), 0.133); register_display_procs (gimp); - (* status_callback) (NULL, _("Drawable procedures"), 0.143); + (* status_callback) (NULL, _("Drawable procedures"), 0.145); register_drawable_procs (gimp); - (* status_callback) (NULL, _("Edit procedures"), 0.211); + (* status_callback) (NULL, _("Edit procedures"), 0.213); register_edit_procs (gimp); - (* status_callback) (NULL, _("File Operations"), 0.229); + (* status_callback) (NULL, _("File Operations"), 0.231); register_fileops_procs (gimp); - (* status_callback) (NULL, _("Floating selections"), 0.253); + (* status_callback) (NULL, _("Floating selections"), 0.254); register_floating_sel_procs (gimp); - (* status_callback) (NULL, _("Gimprc procedures"), 0.271); + (* status_callback) (NULL, _("Gimprc procedures"), 0.272); register_gimprc_procs (gimp); - (* status_callback) (NULL, _("Gradient UI"), 0.283); + (* status_callback) (NULL, _("Gradient UI"), 0.284); register_gradient_select_procs (gimp); - (* status_callback) (NULL, _("Gradients"), 0.292); + (* status_callback) (NULL, _("Gradients"), 0.293); register_gradients_procs (gimp); - (* status_callback) (NULL, _("Guide procedures"), 0.312); + (* status_callback) (NULL, _("Guide procedures"), 0.314); register_guides_procs (gimp); - (* status_callback) (NULL, _("Help procedures"), 0.33); + (* status_callback) (NULL, _("Help procedures"), 0.331); register_help_procs (gimp); - (* status_callback) (NULL, _("Image"), 0.333); + (* status_callback) (NULL, _("Image"), 0.334); register_image_procs (gimp); (* status_callback) (NULL, _("Layer"), 0.518); register_layer_procs (gimp); - (* status_callback) (NULL, _("Interface"), 0.61); + (* status_callback) (NULL, _("Interface"), 0.612); register_message_procs (gimp); - (* status_callback) (NULL, _("Miscellaneous"), 0.619); + (* status_callback) (NULL, _("Miscellaneous"), 0.621); register_misc_procs (gimp); - (* status_callback) (NULL, _("Misc Tool procedures"), 0.625); + (* status_callback) (NULL, _("Misc Tool procedures"), 0.627); register_misc_tools_procs (gimp); - (* status_callback) (NULL, _("Paint Tool procedures"), 0.634); + (* status_callback) (NULL, _("Paint Tool procedures"), 0.636); register_paint_tools_procs (gimp); - (* status_callback) (NULL, _("Palette"), 0.679); + (* status_callback) (NULL, _("Palette"), 0.68); register_palette_procs (gimp); - (* status_callback) (NULL, _("Palette UI"), 0.696); + (* status_callback) (NULL, _("Palette UI"), 0.698); register_palette_select_procs (gimp); - (* status_callback) (NULL, _("Palettes"), 0.705); + (* status_callback) (NULL, _("Palettes"), 0.707); register_palettes_procs (gimp); - (* status_callback) (NULL, _("Parasite procedures"), 0.72); + (* status_callback) (NULL, _("Parasite procedures"), 0.722); register_parasite_procs (gimp); - (* status_callback) (NULL, _("Paths"), 0.756); + (* status_callback) (NULL, _("Paths"), 0.757); register_paths_procs (gimp); - (* status_callback) (NULL, _("Pattern UI"), 0.795); + (* status_callback) (NULL, _("Pattern UI"), 0.796); register_pattern_select_procs (gimp); - (* status_callback) (NULL, _("Patterns"), 0.804); + (* status_callback) (NULL, _("Patterns"), 0.805); register_patterns_procs (gimp); - (* status_callback) (NULL, _("Plug-in"), 0.818); + (* status_callback) (NULL, _("Plug-in"), 0.82); register_plug_in_procs (gimp); - (* status_callback) (NULL, _("Procedural database"), 0.836); + (* status_callback) (NULL, _("Procedural database"), 0.837); register_procedural_db_procs (gimp); - (* status_callback) (NULL, _("Image mask"), 0.86); + (* status_callback) (NULL, _("Image mask"), 0.861); register_selection_procs (gimp); (* status_callback) (NULL, _("Selection Tool procedures"), 0.914); @@ -175,10 +175,10 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Text procedures"), 0.929); register_text_tool_procs (gimp); - (* status_callback) (NULL, _("Tool procedures"), 0.94); + (* status_callback) (NULL, _("Tool procedures"), 0.941); register_transform_tools_procs (gimp); - (* status_callback) (NULL, _("Undo"), 0.958); + (* status_callback) (NULL, _("Undo"), 0.959); register_undo_procs (gimp); (* status_callback) (NULL, _("Units"), 0.964); diff --git a/app/pdb/layer_cmds.c b/app/pdb/layer_cmds.c index d2e9dd2af2..fda5409801 100644 --- a/app/pdb/layer_cmds.c +++ b/app/pdb/layer_cmds.c @@ -32,6 +32,7 @@ #include "config/gimpcoreconfig.h" #include "core/core-enums.h" #include "core/gimp.h" +#include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimplayer-floating-sel.h" #include "core/gimplayer.h" @@ -51,6 +52,7 @@ static ProcRecord layer_add_alpha_proc; static ProcRecord layer_set_offsets_proc; static ProcRecord layer_mask_proc; static ProcRecord layer_is_floating_sel_proc; +static ProcRecord layer_new_from_drawable_proc; static ProcRecord layer_get_name_proc; static ProcRecord layer_set_name_proc; static ProcRecord layer_get_visible_proc; @@ -86,6 +88,7 @@ register_layer_procs (Gimp *gimp) procedural_db_register (gimp, &layer_set_offsets_proc); procedural_db_register (gimp, &layer_mask_proc); procedural_db_register (gimp, &layer_is_floating_sel_proc); + procedural_db_register (gimp, &layer_new_from_drawable_proc); procedural_db_register (gimp, &layer_get_name_proc); procedural_db_register (gimp, &layer_set_name_proc); procedural_db_register (gimp, &layer_get_visible_proc); @@ -933,6 +936,75 @@ static ProcRecord layer_is_floating_sel_proc = { { layer_is_floating_sel_invoker } } }; +static Argument * +layer_new_from_drawable_invoker (Gimp *gimp, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpDrawable *drawable; + GimpImage *gimage; + GimpLayer *copy = NULL; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_DRAWABLE (drawable)) + success = FALSE; + + gimage = gimp_image_get_by_ID (gimp, args[1].value.pdb_int); + if (! GIMP_IS_IMAGE (gimage)) + success = FALSE; + + if (success) + success = (copy = gimp_layer_new_from_drawable (drawable, + gimage)) != NULL; + + return_args = procedural_db_return_args (&layer_new_from_drawable_proc, success); + + if (success) + return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (copy)); + + return return_args; +} + +static ProcArg layer_new_from_drawable_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The source drawable from where the new layer is copied" + }, + { + GIMP_PDB_IMAGE, + "dest_image", + "The destination image to which to add the layer" + } +}; + +static ProcArg layer_new_from_drawable_outargs[] = +{ + { + GIMP_PDB_LAYER, + "layer_copy", + "The newly copied layer" + } +}; + +static ProcRecord layer_new_from_drawable_proc = +{ + "gimp_layer_new_from_drawable", + "Create a new layer by copying an existing drawable.", + "This procedure creates a new layer as a copy of the specified drawable. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the 'gimp_image_add_layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + GIMP_INTERNAL, + 2, + layer_new_from_drawable_inargs, + 1, + layer_new_from_drawable_outargs, + { { layer_new_from_drawable_invoker } } +}; + static Argument * layer_get_name_invoker (Gimp *gimp, Argument *args) diff --git a/devel-docs/ChangeLog b/devel-docs/ChangeLog index 15989be496..cf6a54c2ce 100644 --- a/devel-docs/ChangeLog +++ b/devel-docs/ChangeLog @@ -1,3 +1,10 @@ +2002-12-03 Sven Neumann + + * libgimp/libgimp-sections.txt + * libgimp/tmpl/gimpdisplay.sgml + * libgimp/tmpl/gimplayer.sgml: updated after addition of two new + PDB functions. + 2002-12-03 Sven Neumann * libgimp/tmpl/*.sgml: applied a patch from Akkana that adds short diff --git a/devel-docs/libgimp/libgimp-sections.txt b/devel-docs/libgimp/libgimp-sections.txt index f004ed0d94..ca70c76b26 100644 --- a/devel-docs/libgimp/libgimp-sections.txt +++ b/devel-docs/libgimp/libgimp-sections.txt @@ -161,6 +161,7 @@ gimp_convert_indexed gimp_display_new gimp_display_delete gimp_displays_flush +gimp_displays_reconnect
@@ -358,7 +359,7 @@ gimp_layer_translate gimp_layer_add_alpha gimp_layer_set_offsets gimp_layer_mask -gimp_layer_is_floating_sel +gimp_layer_new_from_drawable gimp_layer_get_name gimp_layer_set_name gimp_layer_get_visible @@ -381,6 +382,7 @@ gimp_layer_get_tattoo gimp_layer_set_tattoo gimp_layer_get_mask_id gimp_layer_get_image_id +gimp_layer_is_floating_sel gimp_layer_is_floating_selection gimp_layer_get_preserve_transparency gimp_layer_set_preserve_transparency diff --git a/devel-docs/libgimp/tmpl/gimpdisplay.sgml b/devel-docs/libgimp/tmpl/gimpdisplay.sgml index 4d41b9a83a..cac809fc46 100644 --- a/devel-docs/libgimp/tmpl/gimpdisplay.sgml +++ b/devel-docs/libgimp/tmpl/gimpdisplay.sgml @@ -41,3 +41,13 @@ Functions to create, delete and flush new displays (views) on an image. @Returns: + + + + + +@old_image_ID: +@new_image_ID: +@Returns: + + diff --git a/devel-docs/libgimp/tmpl/gimplayer.sgml b/devel-docs/libgimp/tmpl/gimplayer.sgml index 6bf6ae5773..60f9626396 100644 --- a/devel-docs/libgimp/tmpl/gimplayer.sgml +++ b/devel-docs/libgimp/tmpl/gimplayer.sgml @@ -132,12 +132,13 @@ Operations on single layers. @Returns: - + -@layer_ID: +@drawable_ID: +@dest_image_ID: @Returns: @@ -351,6 +352,15 @@ Operations on single layers. @layer_ID: + + + + + +@layer_ID: +@Returns: + + diff --git a/libgimp/gimpdisplay_pdb.c b/libgimp/gimpdisplay_pdb.c index b9358c86f9..d2c31016b5 100644 --- a/libgimp/gimpdisplay_pdb.c +++ b/libgimp/gimpdisplay_pdb.c @@ -119,3 +119,38 @@ gimp_displays_flush (void) return success; } + +/** + * gimp_displays_reconnect: + * @old_image_ID: The old image (should have at least one display). + * @new_image_ID: The new image (must not have a display). + * + * Reconnect displays from one image to another image. + * + * This procedure connects all displays of the old_image to the + * new_image. If the new_image already has a display the reconnect is + * not performed and the procedure returns without success. You should + * rarely need to use this function. + * + * Returns: TRUE on success. + */ +gboolean +gimp_displays_reconnect (gint32 old_image_ID, + gint32 new_image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_displays_reconnect", + &nreturn_vals, + GIMP_PDB_IMAGE, old_image_ID, + GIMP_PDB_IMAGE, new_image_ID, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} diff --git a/libgimp/gimpdisplay_pdb.h b/libgimp/gimpdisplay_pdb.h index a045791f02..8a17d15e62 100644 --- a/libgimp/gimpdisplay_pdb.h +++ b/libgimp/gimpdisplay_pdb.h @@ -29,9 +29,11 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gint32 gimp_display_new (gint32 image_ID); -gboolean gimp_display_delete (gint32 display_ID); -gboolean gimp_displays_flush (void); +gint32 gimp_display_new (gint32 image_ID); +gboolean gimp_display_delete (gint32 display_ID); +gboolean gimp_displays_flush (void); +gboolean gimp_displays_reconnect (gint32 old_image_ID, + gint32 new_image_ID); G_END_DECLS diff --git a/libgimp/gimplayer_pdb.c b/libgimp/gimplayer_pdb.c index a6b98b1be0..fdabce3874 100644 --- a/libgimp/gimplayer_pdb.c +++ b/libgimp/gimplayer_pdb.c @@ -450,6 +450,43 @@ gimp_layer_is_floating_sel (gint32 layer_ID) return is_floating_sel; } +/** + * gimp_layer_new_from_drawable: + * @drawable_ID: The source drawable from where the new layer is copied. + * @dest_image_ID: The destination image to which to add the layer. + * + * Create a new layer by copying an existing drawable. + * + * This procedure creates a new layer as a copy of the specified + * drawable. The new layer still needs to be added to the image, as + * this is not automatic. Add the new layer with the + * 'gimp_image_add_layer' command. Other attributes such as layer mask + * modes, and offsets should be set with explicit procedure calls. + * + * Returns: The newly copied layer. + */ +gint32 +gimp_layer_new_from_drawable (gint32 drawable_ID, + gint32 dest_image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 layer_copy_ID = -1; + + return_vals = gimp_run_procedure ("gimp_layer_new_from_drawable", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_IMAGE, dest_image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + layer_copy_ID = return_vals[1].data.d_layer; + + gimp_destroy_params (return_vals, nreturn_vals); + + return layer_copy_ID; +} + /** * gimp_layer_get_name: * @layer_ID: The layer. diff --git a/libgimp/gimplayer_pdb.h b/libgimp/gimplayer_pdb.h index a54c064ff2..f6a1d8da4f 100644 --- a/libgimp/gimplayer_pdb.h +++ b/libgimp/gimplayer_pdb.h @@ -59,6 +59,8 @@ gboolean gimp_layer_set_offsets (gint32 layer_ gint offy); gint32 gimp_layer_mask (gint32 layer_ID); gboolean gimp_layer_is_floating_sel (gint32 layer_ID); +gint32 gimp_layer_new_from_drawable (gint32 drawable_ID, + gint32 dest_image_ID); gchar* gimp_layer_get_name (gint32 layer_ID); gboolean gimp_layer_set_name (gint32 layer_ID, gchar *name); diff --git a/tools/pdbgen/pdb/display.pdb b/tools/pdbgen/pdb/display.pdb index e75ee8bc21..ccca1071b2 100644 --- a/tools/pdbgen/pdb/display.pdb +++ b/tools/pdbgen/pdb/display.pdb @@ -86,10 +86,35 @@ HELP %invoke = ( code => 'gimp_displays_flush (gimp);' ); } + +sub displays_reconnect { + $blurb = 'Reconnect displays from one image to another image.'; + + $help = <<'HELP'; +This procedure connects all displays of the old_image to the new_image. +If the new_image already has a display the reconnect is not performed and the +procedure returns without success. You should rarely need to use this +function. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'old_image', type => 'image', + desc => 'The old image (should have at least one display)', + alias => 'gimage_old' }, + { name => 'new_image', type => 'image', + desc => 'The new image (must not have a display)', + alias => 'gimage_new' } + ); + + %invoke = ( code => 'gdisplays_reconnect(gimage_old, gimage_new);' ); +} + @headers = qw("core/gimp.h" "display/display-types.h" "display/gimpdisplay.h" "display/gimpdisplay-foreach.h"); -@procs = qw(display_new display_delete displays_flush); +@procs = qw(display_new display_delete displays_flush displays_reconnect); %exports = (app => [@procs], lib => [@procs]); $desc = 'GimpDisplay procedures'; diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb index aa0e31b0db..be4cea4396 100644 --- a/tools/pdbgen/pdb/layer.pdb +++ b/tools/pdbgen/pdb/layer.pdb @@ -490,6 +490,39 @@ HELP ); } +sub layer_new_from_drawable { + $blurb = 'Create a new layer by copying an existing drawable.'; + + $help = <<'HELP'; +This procedure creates a new layer as a copy of the specified drawable. The +new layer still needs to be added to the image, as this is not automatic. Add +the new layer with the 'gimp_image_add_layer' command. Other attributes such +as layer mask modes, and offsets should be set with explicit procedure calls. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'drawable', type => 'drawable', + desc => 'The source drawable from where the new layer is copied', + alias => 'drawable' }, + { name => 'dest_image', type => 'image', + desc => 'The destination image to which to add the layer', + alias => 'gimage' } + ); + + @outargs = ( + { name => 'layer_copy', type => 'layer', init => 1, + desc => 'The newly copied layer', alias => 'copy' } + ); + + %invoke = ( + code => 'success = (copy = gimp_layer_new_from_drawable (drawable, + gimage)) != NULL;' + ); + +} + &layer_accessors('name', 'string', 'name', 1, 0, undef, 'object', 'GIMP_OBJECT (layer)'); @@ -574,7 +607,8 @@ CODE unshift @procs, qw(layer_new layer_copy layer_create_mask layer_scale layer_resize layer_delete layer_translate layer_add_alpha - layer_set_offsets layer_mask layer_is_floating_sel); + layer_set_offsets layer_mask layer_is_floating_sel + layer_new_from_drawable); %exports = (app => [@procs], lib => [@procs]); $desc = 'Layer';