Пример #1
0
void
vectors_paste_cmd_callback (GtkAction *action,
                            gpointer   data)
{
  GimpImage *image;
  GtkWidget *widget;
  gchar     *svg;
  gsize      svg_size;
  return_if_no_image (image, data);
  return_if_no_widget (widget, data);

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

  if (svg)
    {
      GError *error = NULL;

      if (! gimp_vectors_import_buffer (image, svg, svg_size,
                                        TRUE, FALSE,
                                        GIMP_IMAGE_ACTIVE_PARENT, -1,
                                        NULL, &error))
        {
          gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR,
                        "%s", error->message);
          g_clear_error (&error);
        }
      else
        {
          gimp_image_flush (image);
        }

      g_free (svg);
    }
}
Пример #2
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."));
        }
    }
}