Esempio n. 1
0
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)
    {
      GimpLayer *layer;

      layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (buffer),
                                          image,
                                          gimp_image_get_layer_format (image,
                                                                       TRUE),
                                          _("Clipboard"),
                                          GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
      g_object_unref (buffer);

      gimp_image_add_layer (image, layer,
                            GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);

      gimp_image_flush (image);
    }
  else
    {
      gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING,
			    _("There is no image data in the clipboard to paste."));
    }
}
Esempio n. 2
0
void
edit_paste_as_new_cmd_callback (GtkAction *action,
                                gpointer   data)
{
  Gimp       *gimp;
  GimpBuffer *buffer;
  return_if_no_gimp (gimp, data);

  buffer = gimp_clipboard_get_buffer (gimp);

  if (buffer)
    {
      GimpImage *image;

      image = gimp_image_new_from_buffer (gimp, action_data_get_image (data),
                                          buffer);
      g_object_unref (buffer);

      gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
      g_object_unref (image);
    }
  else
    {
      gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING,
			    _("There is no image data in the clipboard to paste."));
    }
}
Esempio n. 3
0
static void
edit_paste (GimpDisplay *display,
            gboolean     paste_into)
{
  GimpImage *image = gimp_display_get_image (display);
  gchar     *svg;
  gsize      svg_size;

  svg = gimp_clipboard_get_svg (display->gimp, &svg_size);

  if (svg)
    {
      if (gimp_vectors_import_buffer (image, svg, svg_size,
                                      TRUE, FALSE,
                                      GIMP_IMAGE_ACTIVE_PARENT, -1,
                                      NULL, NULL))
        {
          gimp_image_flush (image);
        }

      g_free (svg);
    }
  else
    {
      GimpBuffer *buffer;

      buffer = gimp_clipboard_get_buffer (display->gimp);

      if (buffer)
        {
          GimpDisplayShell *shell = gimp_display_get_shell (display);
          gint              x, y;
          gint              width, height;

          gimp_display_shell_untransform_viewport (shell,
                                                   &x, &y, &width, &height);

          if (gimp_edit_paste (image,
                               gimp_image_get_active_drawable (image),
                               buffer, paste_into, x, y, width, height))
            {
              gimp_image_flush (image);
            }

          g_object_unref (buffer);
        }
      else
        {
          gimp_message_literal (display->gimp, G_OBJECT (display),
				GIMP_MESSAGE_WARNING,
				_("There is no image data in the clipboard to paste."));
        }
    }
}
Esempio n. 4
0
/**
 * gimp_seamless_clone_tool_start:
 * @sc: The GimpSeamlessCloneTool to initialize for usage on the given
 *      display
 * @display: The display to initialize the tool for
 *
 * A utility function to initialize a tool for working on a given
 * display. At the beginning of each function, we can check if the event's
 * display is the same as the tool's one, and if not call this. This is
 * not required by the gimptool interface or anything like that, but
 * this is a convenient way to do all the initialization work in one
 * place, and this is how the base class (GimpDrawTool) does that
 */
static void
gimp_seamless_clone_tool_start (GimpSeamlessCloneTool *sc,
                                GimpDisplay           *display)
{
  GimpTool     *tool     = GIMP_TOOL (sc);
  GimpImage    *image    = gimp_display_get_image (display);
  GimpDrawable *drawable = gimp_image_get_active_drawable (image);

  /* First handle the paste - we need to make sure we have one in order
   * to do anything else.
   */
  if (sc->paste == NULL)
    {
      GimpBuffer *buffer = gimp_clipboard_get_buffer (tool->tool_info->gimp);

      if (! buffer)
        {
          gimp_tool_push_status (tool, display,
                                 "%s",
                                 _("There is no image data in the clipboard to paste."));
          return;
        }

      sc->paste = gegl_buffer_dup (gimp_buffer_get_buffer (buffer));
      g_object_unref (buffer);

      sc->width  = gegl_buffer_get_width  (sc->paste);
      sc->height = gegl_buffer_get_height (sc->paste);
    }

  /* Free resources which are relevant only for the previous display */
  gimp_seamless_clone_tool_stop (sc, TRUE);

  tool->display = display;

  gimp_seamless_clone_tool_create_filter (sc, drawable);

  gimp_draw_tool_start (GIMP_DRAW_TOOL (sc), display);

  sc->tool_state = SC_STATE_RENDER_WAIT;
}