? app/core/stqAGfGF ? tools/authorsgen/Makefile ? tools/authorsgen/Makefile.in ? tools/authorsgen/stamp-authors Index: app/actions/edit-actions.c =================================================================== RCS file: /cvs/gnome/gimp/app/actions/edit-actions.c,v retrieving revision 1.18 diff -u -p -r1.18 edit-actions.c --- app/actions/edit-actions.c 18 Nov 2004 16:04:41 -0000 1.18 +++ app/actions/edit-actions.c 12 Dec 2004 00:34:22 -0000 @@ -89,6 +89,11 @@ static GimpActionEntry edit_actions[] = G_CALLBACK (edit_copy_cmd_callback), GIMP_HELP_EDIT_COPY }, + { "edit-copy-visible", NULL, /* GIMP_STOCK_COPY_VISIBLE, */ + N_("Copy _Visible"), "", NULL, + G_CALLBACK (edit_copy_visible_cmd_callback), + GIMP_HELP_EDIT_COPY_VISIBLE }, + { "edit-paste", GTK_STOCK_PASTE, N_("_Paste"), "V", NULL, G_CALLBACK (edit_paste_cmd_callback), @@ -234,6 +239,7 @@ edit_actions_update (GimpActionGroup *gr SET_SENSITIVE ("edit-cut", drawable); SET_SENSITIVE ("edit-copy", drawable); + SET_SENSITIVE ("edit-copy-visible", gimage); SET_SENSITIVE ("edit-paste", gimage); SET_SENSITIVE ("edit-paste-into", gimage); Index: app/actions/edit-commands.c =================================================================== RCS file: /cvs/gnome/gimp/app/actions/edit-commands.c,v retrieving revision 1.57 diff -u -p -r1.57 edit-commands.c --- app/actions/edit-commands.c 19 Oct 2004 14:08:44 -0000 1.57 +++ app/actions/edit-commands.c 12 Dec 2004 00:34:22 -0000 @@ -149,6 +149,17 @@ edit_copy_cmd_callback (GtkAction *actio } void +edit_copy_visible_cmd_callback (GtkAction *action, + gpointer data) +{ + GimpImage *gimage; + return_if_no_image (gimage, data); + + if (gimp_edit_copy_visible (gimage, action_data_get_context (data))) + gimp_image_flush (gimage); +} + +void edit_paste_cmd_callback (GtkAction *action, gpointer data) { Index: app/actions/edit-commands.h =================================================================== RCS file: /cvs/gnome/gimp/app/actions/edit-commands.h,v retrieving revision 1.7 diff -u -p -r1.7 edit-commands.h --- app/actions/edit-commands.h 12 May 2004 18:36:33 -0000 1.7 +++ app/actions/edit-commands.h 12 Dec 2004 00:34:22 -0000 @@ -30,6 +30,8 @@ void edit_cut_cmd_callback (G gpointer data); void edit_copy_cmd_callback (GtkAction *action, gpointer data); +void edit_copy_visible_cmd_callback (GtkAction *action, + gpointer data); void edit_paste_cmd_callback (GtkAction *action, gpointer data); void edit_paste_into_cmd_callback (GtkAction *action, Index: app/core/gimp-edit.c =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimp-edit.c,v retrieving revision 1.124 diff -u -p -r1.124 gimp-edit.c --- app/core/gimp-edit.c 11 Nov 2004 14:05:33 -0000 1.124 +++ app/core/gimp-edit.c 12 Dec 2004 00:34:26 -0000 @@ -43,6 +43,7 @@ #include "gimplayer-floating-sel.h" #include "gimplist.h" #include "gimppattern.h" +#include "gimpprojection.h" #include "gimpselection.h" #include "gimp-intl.h" @@ -87,6 +88,67 @@ gimp_edit_copy (GimpImage *gimage, g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); return gimp_edit_extract (gimage, drawable, context, FALSE); +} + +const GimpBuffer * +gimp_edit_copy_visible (GimpImage *gimage, + GimpContext *context) +{ + PixelRegion srcPR, destPR; + TileManager *tiles; + gboolean non_empty; + gint x1, y1, x2, y2; + + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); + g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); + + non_empty = gimp_channel_bounds (gimp_image_get_mask (gimage), + &x1, &y1, &x2, &y2); + if ((x1 == x2) || (y1 == y2)) + { + g_message (_("Unable to cut or copy because the " + "selected region is empty.")); + return NULL; + } + + tiles = tile_manager_new (x2 - x1, y2 - y1, + gimp_projection_get_bytes (gimage->projection)); + tile_manager_set_offsets (tiles, x1, y1); + + pixel_region_init (&srcPR, gimp_projection_get_tiles (gimage->projection), + x1, y1, + x2 - x1, y2 - y1, + FALSE); + pixel_region_init (&destPR, tiles, + 0, 0, + x2 - x1, y2 - y1, + TRUE); + + copy_region (&srcPR, &destPR); + + /* Only crop if the gimage mask wasn't empty */ + if (non_empty) + { + TileManager *crop = tile_manager_crop (tiles, 0); + + if (crop != tiles) + { + tile_manager_unref (tiles); + tiles = crop; + } + } + + if (tiles) + { + GimpBuffer *buffer = gimp_buffer_new (tiles, "Global Buffer", FALSE); + + gimp_set_global_buffer (gimage->gimp, buffer); + g_object_unref (buffer); + + return gimage->gimp->global_buffer; + } + + return NULL; } GimpLayer * Index: app/core/gimp-edit.h =================================================================== RCS file: /cvs/gnome/gimp/app/core/gimp-edit.h,v retrieving revision 1.17 diff -u -p -r1.17 gimp-edit.h --- app/core/gimp-edit.h 14 Apr 2004 23:32:43 -0000 1.17 +++ app/core/gimp-edit.h 12 Dec 2004 00:34:26 -0000 @@ -26,6 +26,8 @@ const GimpBuffer * gimp_edit_cut const GimpBuffer * gimp_edit_copy (GimpImage *gimage, GimpDrawable *drawable, GimpContext *context); +const GimpBuffer * gimp_edit_copy_visible (GimpImage *gimage, + GimpContext *context); GimpLayer * gimp_edit_paste (GimpImage *gimage, GimpDrawable *drawable, GimpBuffer *paste, Index: app/pdb/edit_cmds.c =================================================================== RCS file: /cvs/gnome/gimp/app/pdb/edit_cmds.c,v retrieving revision 1.47 diff -u -p -r1.47 edit_cmds.c --- app/pdb/edit_cmds.c 11 Nov 2004 14:05:33 -0000 1.47 +++ app/pdb/edit_cmds.c 12 Dec 2004 00:34:31 -0000 @@ -40,6 +40,7 @@ static ProcRecord edit_cut_proc; static ProcRecord edit_copy_proc; +static ProcRecord edit_copy_visible_proc; static ProcRecord edit_paste_proc; static ProcRecord edit_clear_proc; static ProcRecord edit_fill_proc; @@ -52,6 +53,7 @@ register_edit_procs (Gimp *gimp) { procedural_db_register (gimp, &edit_cut_proc); procedural_db_register (gimp, &edit_copy_proc); + procedural_db_register (gimp, &edit_copy_visible_proc); procedural_db_register (gimp, &edit_paste_proc); procedural_db_register (gimp, &edit_clear_proc); procedural_db_register (gimp, &edit_fill_proc); @@ -198,6 +200,69 @@ static ProcRecord edit_copy_proc = 1, edit_copy_outargs, { { edit_copy_invoker } } +}; + +static Argument * +edit_copy_visible_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + GimpImage *image; + gboolean non_empty = FALSE; + + image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); + if (! GIMP_IS_IMAGE (image)) + success = FALSE; + + if (success) + { + non_empty = gimp_edit_copy_visible (image, context) != NULL; + } + + return_args = procedural_db_return_args (&edit_copy_visible_proc, success); + + if (success) + return_args[1].value.pdb_int = non_empty; + + return return_args; +} + +static ProcArg edit_copy_visible_inargs[] = +{ + { + GIMP_PDB_IMAGE, + "image", + "The image to copy from" + } +}; + +static ProcArg edit_copy_visible_outargs[] = +{ + { + GIMP_PDB_INT32, + "non_empty", + "TRUE if the copy was successful, FALSE if the selection contained only transparent pixels" + } +}; + +static ProcRecord edit_copy_visible_proc = +{ + "gimp_edit_copy_visible", + "Copy from the projection.", + "If there is a selection in the image, then the area specified by the selection is copied from the projection and placed in an internal GIMP edit buffer. It can subsequently be retrieved using the 'gimp-edit-paste' command. If there is no selection, then the projection's contents will be stored in the internal GIMP edit buffer.", + "Michael Natterer ", + "Michael Natterer ", + "2004", + NULL, + GIMP_INTERNAL, + 1, + edit_copy_visible_inargs, + 1, + edit_copy_visible_outargs, + { { edit_copy_visible_invoker } } }; static Argument * Index: app/pdb/internal_procs.c =================================================================== RCS file: /cvs/gnome/gimp/app/pdb/internal_procs.c,v retrieving revision 1.70 diff -u -p -r1.70 internal_procs.c --- app/pdb/internal_procs.c 16 Nov 2004 14:34:34 -0000 1.70 +++ app/pdb/internal_procs.c 12 Dec 2004 00:34:31 -0000 @@ -74,7 +74,7 @@ void register_transform_tools_procs ( void register_undo_procs (Gimp *gimp); void register_unit_procs (Gimp *gimp); -/* 431 procedures registered total */ +/* 432 procedures registered total */ void internal_procs_init (Gimp *gimp, @@ -89,7 +89,7 @@ internal_procs_init (Gimp (* status_callback) (NULL, _("Brush UI"), 0.019); register_brush_select_procs (gimp); - (* status_callback) (NULL, _("Brushes"), 0.026); + (* status_callback) (NULL, _("Brushes"), 0.025); register_brushes_procs (gimp); (* status_callback) (NULL, _("Channel"), 0.039); @@ -110,58 +110,58 @@ internal_procs_init (Gimp (* status_callback) (NULL, _("Drawable procedures"), 0.162); register_drawable_procs (gimp); - (* status_callback) (NULL, _("Transformation procedures"), 0.239); + (* status_callback) (NULL, _("Transformation procedures"), 0.238); register_drawable_transform_procs (gimp); - (* status_callback) (NULL, _("Edit procedures"), 0.276); + (* status_callback) (NULL, _("Edit procedures"), 0.275); register_edit_procs (gimp); - (* status_callback) (NULL, _("File Operations"), 0.295); + (* status_callback) (NULL, _("File Operations"), 0.296); register_fileops_procs (gimp); - (* status_callback) (NULL, _("Floating selections"), 0.318); + (* status_callback) (NULL, _("Floating selections"), 0.319); register_floating_sel_procs (gimp); - (* status_callback) (NULL, _("Font UI"), 0.332); + (* status_callback) (NULL, _("Font UI"), 0.333); register_font_select_procs (gimp); - (* status_callback) (NULL, _("Fonts"), 0.339); + (* status_callback) (NULL, _("Fonts"), 0.34); register_fonts_procs (gimp); - (* status_callback) (NULL, _("Gimprc procedures"), 0.343); + (* status_callback) (NULL, _("Gimprc procedures"), 0.345); register_gimprc_procs (gimp); - (* status_callback) (NULL, _("Gradient"), 0.357); + (* status_callback) (NULL, _("Gradient"), 0.359); register_gradient_procs (gimp); - (* status_callback) (NULL, _("Gradient UI"), 0.425); + (* status_callback) (NULL, _("Gradient UI"), 0.426); register_gradient_select_procs (gimp); - (* status_callback) (NULL, _("Gradients"), 0.432); + (* status_callback) (NULL, _("Gradients"), 0.433); register_gradients_procs (gimp); - (* status_callback) (NULL, _("Guide procedures"), 0.443); + (* status_callback) (NULL, _("Guide procedures"), 0.444); register_guides_procs (gimp); - (* status_callback) (NULL, _("Help procedures"), 0.457); + (* status_callback) (NULL, _("Help procedures"), 0.458); register_help_procs (gimp); - (* status_callback) (NULL, _("Image"), 0.459); + (* status_callback) (NULL, _("Image"), 0.461); register_image_procs (gimp); - (* status_callback) (NULL, _("Layer"), 0.603); + (* status_callback) (NULL, _("Layer"), 0.604); register_layer_procs (gimp); - (* status_callback) (NULL, _("Message procedures"), 0.666); + (* status_callback) (NULL, _("Message procedures"), 0.667); register_message_procs (gimp); - (* status_callback) (NULL, _("Miscellaneous"), 0.673); + (* status_callback) (NULL, _("Miscellaneous"), 0.674); register_misc_procs (gimp); - (* status_callback) (NULL, _("Paint Tool procedures"), 0.677); + (* status_callback) (NULL, _("Paint Tool procedures"), 0.678); register_paint_tools_procs (gimp); - (* status_callback) (NULL, _("Palette"), 0.712); + (* status_callback) (NULL, _("Palette"), 0.713); register_palette_procs (gimp); (* status_callback) (NULL, _("Palette UI"), 0.738); @@ -170,7 +170,7 @@ internal_procs_init (Gimp (* status_callback) (NULL, _("Palettes"), 0.745); register_palettes_procs (gimp); - (* status_callback) (NULL, _("Parasite procedures"), 0.754); + (* status_callback) (NULL, _("Parasite procedures"), 0.755); register_parasite_procs (gimp); (* status_callback) (NULL, _("Paths"), 0.782); @@ -179,16 +179,16 @@ internal_procs_init (Gimp (* status_callback) (NULL, _("Pattern"), 0.817); register_pattern_procs (gimp); - (* status_callback) (NULL, _("Pattern UI"), 0.821); + (* status_callback) (NULL, _("Pattern UI"), 0.822); register_pattern_select_procs (gimp); - (* status_callback) (NULL, _("Patterns"), 0.828); + (* status_callback) (NULL, _("Patterns"), 0.829); register_patterns_procs (gimp); (* status_callback) (NULL, _("Plug-in"), 0.838); register_plug_in_procs (gimp); - (* status_callback) (NULL, _("Procedural database"), 0.849); + (* status_callback) (NULL, _("Procedural database"), 0.85); register_procedural_db_procs (gimp); (* status_callback) (NULL, _("Progress"), 0.87); Index: app/widgets/gimphelp-ids.h =================================================================== RCS file: /cvs/gnome/gimp/app/widgets/gimphelp-ids.h,v retrieving revision 1.48 diff -u -p -r1.48 gimphelp-ids.h --- app/widgets/gimphelp-ids.h 24 Nov 2004 02:17:12 -0000 1.48 +++ app/widgets/gimphelp-ids.h 12 Dec 2004 00:34:33 -0000 @@ -45,6 +45,7 @@ #define GIMP_HELP_EDIT_UNDO_CLEAR "gimp-edit-undo-clear" #define GIMP_HELP_EDIT_CUT "gimp-edit-cut" #define GIMP_HELP_EDIT_COPY "gimp-edit-copy" +#define GIMP_HELP_EDIT_COPY_VISIBLE "gimp-edit-copy-visible" #define GIMP_HELP_EDIT_PASTE "gimp-edit-paste" #define GIMP_HELP_EDIT_PASTE_INTO "gimp-edit-paste-into" #define GIMP_HELP_EDIT_PASTE_AS_NEW "gimp-edit-paste-as-new" Index: libgimp/gimpedit_pdb.c =================================================================== RCS file: /cvs/gnome/gimp/libgimp/gimpedit_pdb.c,v retrieving revision 1.10 diff -u -p -r1.10 gimpedit_pdb.c --- libgimp/gimpedit_pdb.c 29 Oct 2004 00:06:41 -0000 1.10 +++ libgimp/gimpedit_pdb.c 12 Dec 2004 00:34:34 -0000 @@ -96,6 +96,43 @@ gimp_edit_copy (gint32 drawable_ID) } /** + * gimp_edit_copy_visible: + * @image_ID: The image to copy from. + * + * Copy from the projection. + * + * If there is a selection in the image, then the area specified by the + * selection is copied from the projection and placed in an internal + * GIMP edit buffer. It can subsequently be retrieved using the + * 'gimp-edit-paste' command. If there is no selection, then the + * projection's contents will be stored in the internal GIMP edit + * buffer. + * + * Returns: TRUE if the copy was successful, FALSE if the selection contained only transparent pixels. + * + * Since: GIMP 2.2 + */ +gboolean +gimp_edit_copy_visible (gint32 image_ID) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean non_empty = FALSE; + + return_vals = gimp_run_procedure ("gimp_edit_copy_visible", + &nreturn_vals, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + non_empty = return_vals[1].data.d_int32; + + gimp_destroy_params (return_vals, nreturn_vals); + + return non_empty; +} + +/** * gimp_edit_paste: * @drawable_ID: The drawable to paste to. * @paste_into: Clear selection, or paste behind it? Index: libgimp/gimpedit_pdb.h =================================================================== RCS file: /cvs/gnome/gimp/libgimp/gimpedit_pdb.h,v retrieving revision 1.5 diff -u -p -r1.5 gimpedit_pdb.h --- libgimp/gimpedit_pdb.h 5 Jan 2004 14:35:14 -0000 1.5 +++ libgimp/gimpedit_pdb.h 12 Dec 2004 00:34:34 -0000 @@ -29,38 +29,39 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gboolean gimp_edit_cut (gint32 drawable_ID); -gboolean gimp_edit_copy (gint32 drawable_ID); -gint32 gimp_edit_paste (gint32 drawable_ID, - gboolean paste_into); -gboolean gimp_edit_clear (gint32 drawable_ID); -gboolean gimp_edit_fill (gint32 drawable_ID, - GimpFillType fill_type); -gboolean gimp_edit_bucket_fill (gint32 drawable_ID, - GimpBucketFillMode fill_mode, - GimpLayerModeEffects paint_mode, - gdouble opacity, - gdouble threshold, - gboolean sample_merged, - gdouble x, - gdouble y); -gboolean gimp_edit_blend (gint32 drawable_ID, - GimpBlendMode blend_mode, - GimpLayerModeEffects paint_mode, - GimpGradientType gradient_type, - gdouble opacity, - gdouble offset, - GimpRepeatMode repeat, - gboolean reverse, - gboolean supersample, - gint max_depth, - gdouble threshold, - gboolean dither, - gdouble x1, - gdouble y1, - gdouble x2, - gdouble y2); -gboolean gimp_edit_stroke (gint32 drawable_ID); +gboolean gimp_edit_cut (gint32 drawable_ID); +gboolean gimp_edit_copy (gint32 drawable_ID); +gboolean gimp_edit_copy_visible (gint32 image_ID); +gint32 gimp_edit_paste (gint32 drawable_ID, + gboolean paste_into); +gboolean gimp_edit_clear (gint32 drawable_ID); +gboolean gimp_edit_fill (gint32 drawable_ID, + GimpFillType fill_type); +gboolean gimp_edit_bucket_fill (gint32 drawable_ID, + GimpBucketFillMode fill_mode, + GimpLayerModeEffects paint_mode, + gdouble opacity, + gdouble threshold, + gboolean sample_merged, + gdouble x, + gdouble y); +gboolean gimp_edit_blend (gint32 drawable_ID, + GimpBlendMode blend_mode, + GimpLayerModeEffects paint_mode, + GimpGradientType gradient_type, + gdouble opacity, + gdouble offset, + GimpRepeatMode repeat, + gboolean reverse, + gboolean supersample, + gint max_depth, + gdouble threshold, + gboolean dither, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2); +gboolean gimp_edit_stroke (gint32 drawable_ID); G_END_DECLS Index: menus/image-menu.xml.in =================================================================== RCS file: /cvs/gnome/gimp/menus/image-menu.xml.in,v retrieving revision 1.33 diff -u -p -r1.33 image-menu.xml.in --- menus/image-menu.xml.in 23 Nov 2004 09:32:54 -0000 1.33 +++ menus/image-menu.xml.in 12 Dec 2004 00:34:35 -0000 @@ -154,6 +154,7 @@ + Index: tools/pdbgen/pdb/edit.pdb =================================================================== RCS file: /cvs/gnome/gimp/tools/pdbgen/pdb/edit.pdb,v retrieving revision 1.37 diff -u -p -r1.37 edit.pdb --- tools/pdbgen/pdb/edit.pdb 11 Nov 2004 14:05:34 -0000 1.37 +++ tools/pdbgen/pdb/edit.pdb 12 Dec 2004 00:34:36 -0000 @@ -98,6 +98,36 @@ HELP &invoke('non_empty = gimp_edit_copy (gimage, drawable, context) != NULL'); } +sub edit_copy_visible { + $blurb = 'Copy from the projection.'; + + $help = <<'HELP'; +If there is a selection in the image, then the area specified by the +selection is copied from the projection and placed in an internal GIMP +edit buffer. It can subsequently be retrieved using the +'gimp-edit-paste' command. If there is no selection, then the +projection's contents will be stored in the internal GIMP edit buffer. +HELP + + $author = $copyright = 'Michael Natterer '; + $date = '2004'; + $since = '2.2'; + + @inargs = ( + { name => 'image', type => 'image', + desc => "The image to copy from" } + ); + &outargs('copy'); + + %invoke = ( + code => < [@procs], lib => [@procs]);