diff --git a/ChangeLog b/ChangeLog index 97433b4dea..09d531348e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-08-07 Sven Neumann + + * app/actions/edit-commands.[ch] + * app/actions/edit-actions.c: added new action + "edit-paste-as-new-layer". + + * app/widgets/gimphelp-ids.h: added new help-id. + + * menus/image-menu.xml.in: added the new action. + 2008-08-07 Tor Lillqvist * app/config/gimpbaseconfig.c (gimp_base_config_class_init): Use diff --git a/app/actions/edit-actions.c b/app/actions/edit-actions.c index 9b51328257..092f307ad1 100644 --- a/app/actions/edit-actions.c +++ b/app/actions/edit-actions.c @@ -146,6 +146,12 @@ static const GimpActionEntry edit_actions[] = G_CALLBACK (edit_paste_as_new_cmd_callback), GIMP_HELP_EDIT_PASTE_AS_NEW }, + { "edit-paste-as-new-layer", NULL, + N_("New _Layer"), NULL, + N_("Create a new layer from the content of the clipboard"), + G_CALLBACK (edit_paste_as_new_layer_cmd_callback), + GIMP_HELP_EDIT_PASTE_AS_NEW_LAYER }, + { "edit-named-cut", GTK_STOCK_CUT, N_("Cu_t Named..."), "", N_("Move the selected pixels to a named buffer"), @@ -314,21 +320,22 @@ edit_actions_update (GimpActionGroup *group, g_free (redo_name); g_free (fade_name); - SET_SENSITIVE ("edit-cut", drawable); - SET_SENSITIVE ("edit-copy", drawable); - SET_SENSITIVE ("edit-copy-visible", image); + SET_SENSITIVE ("edit-cut", drawable); + SET_SENSITIVE ("edit-copy", drawable); + SET_SENSITIVE ("edit-copy-visible", image); /* "edit-paste" is always enabled */ - SET_SENSITIVE ("edit-paste-into", image); + SET_SENSITIVE ("edit-paste-as-new-layer", image); + SET_SENSITIVE ("edit-paste-into", image); SET_SENSITIVE ("edit-named-cut", drawable); SET_SENSITIVE ("edit-named-copy", drawable); SET_SENSITIVE ("edit-named-copy-visible", drawable); SET_SENSITIVE ("edit-named-paste", image); - SET_SENSITIVE ("edit-clear", drawable); - SET_SENSITIVE ("edit-fill-fg", drawable); - SET_SENSITIVE ("edit-fill-bg", drawable); - SET_SENSITIVE ("edit-fill-pattern", drawable); + SET_SENSITIVE ("edit-clear", drawable); + SET_SENSITIVE ("edit-fill-fg", drawable); + SET_SENSITIVE ("edit-fill-bg", drawable); + SET_SENSITIVE ("edit-fill-pattern", drawable); #undef SET_LABEL #undef SET_SENSITIVE diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c index 58f201d45f..f7393306b7 100644 --- a/app/actions/edit-commands.c +++ b/app/actions/edit-commands.c @@ -34,6 +34,7 @@ #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimpimage-undo.h" +#include "core/gimpprojection.h" #include "vectors/gimpvectors-import.h" @@ -300,14 +301,48 @@ edit_paste_as_new_cmd_callback (GtkAction *action, image = gimp_edit_paste_as_new (gimp, action_data_get_image (data), buffer); + g_object_unref (buffer); if (image) { gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0); g_object_unref (image); } + } + else + { + gimp_message (gimp, NULL, GIMP_MESSAGE_WARNING, + _("There is no image data in the clipboard to paste.")); + } +} +void +edit_paste_as_new_layer_cmd_callback (GtkAction *action, + gpointer data) +{ + Gimp *gimp; + GimpImage *image; + GimpBuffer *buffer; + return_if_no_gimp (gimp, data); + return_if_no_image (image, data); + + buffer = gimp_clipboard_get_buffer (gimp); + + if (buffer) + { + GimpProjection *projection = gimp_image_get_projection (image); + GimpImage *layer; + + layer = gimp_layer_new_from_tiles (gimp_projection_get_tiles (projection), + image, + gimp_projection_get_image_type (projection), + _("Clibboard"), + GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE); g_object_unref (buffer); + + gimp_image_add_layer (image, layer, -1); + + gimp_image_flush (image); } else { diff --git a/app/actions/edit-commands.h b/app/actions/edit-commands.h index 6715009f7a..82094fc519 100644 --- a/app/actions/edit-commands.h +++ b/app/actions/edit-commands.h @@ -44,6 +44,8 @@ void edit_paste_into_cmd_callback (GtkAction *action, gpointer data); void edit_paste_as_new_cmd_callback (GtkAction *action, gpointer data); +void edit_paste_as_new_layer_cmd_callback (GtkAction *action, + gpointer data); void edit_named_cut_cmd_callback (GtkAction *action, gpointer data); void edit_named_copy_cmd_callback (GtkAction *action, diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h index 9ec7c8dacb..68179ed590 100644 --- a/app/widgets/gimphelp-ids.h +++ b/app/widgets/gimphelp-ids.h @@ -53,6 +53,7 @@ #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" +#define GIMP_HELP_EDIT_PASTE_AS_NEW_LAYER "gimp-edit-paste-as-new-layer" #define GIMP_HELP_EDIT_CLEAR "gimp-edit-clear" #define GIMP_HELP_EDIT_FILL_FG "gimp-edit-fill-fg" #define GIMP_HELP_EDIT_FILL_BG "gimp-edit-fill-bg" diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in index 3608ef3920..cd60d95ee2 100644 --- a/menus/image-menu.xml.in +++ b/menus/image-menu.xml.in @@ -178,6 +178,7 @@ +