Commit 35588d79 authored by Michael Natterer's avatar Michael Natterer 😴

app: add utility functions to get a generic paste GimpObject

to Gimp and GimpClipboard. The object is either an image or a buffer
or NULL.
parent fa94ab03
......@@ -975,6 +975,17 @@ gimp_get_tool_info_iter (Gimp *gimp)
return GIMP_LIST (gimp->tool_info_list)->queue->head;
}
GimpObject *
gimp_get_clipboard_object (Gimp *gimp)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
if (gimp->clipboard_image)
return GIMP_OBJECT (gimp->clipboard_image);
return GIMP_OBJECT (gimp->clipboard_buffer);
}
void
gimp_set_clipboard_image (Gimp *gimp,
GimpImage *image)
......
......@@ -185,6 +185,8 @@ GList * gimp_get_image_windows (Gimp *gimp);
GList * gimp_get_paint_info_iter (Gimp *gimp);
GList * gimp_get_tool_info_iter (Gimp *gimp);
GimpObject * gimp_get_clipboard_object (Gimp *gimp);
void gimp_set_clipboard_image (Gimp *gimp,
GimpImage *image);
GimpImage * gimp_get_clipboard_image (Gimp *gimp);
......
......@@ -357,11 +357,39 @@ gimp_clipboard_has_curve (Gimp *gimp)
return (gimp_clip->curve != NULL);
}
/**
* gimp_clipboard_get_object:
* @gimp: pointer to #Gimp
*
* Retrieves either an image or a buffer from the global image cut
* buffer of @gimp.
*
* The returned #GimpObject needs to be unref'ed when it's no longer
* needed.
*
* Return value: a reference to a #GimpObject or %NULL if there's no
* image or buffer in the clipboard
**/
GimpObject *
gimp_clipboard_get_object (Gimp *gimp)
{
GimpObject *object;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
object = GIMP_OBJECT (gimp_clipboard_get_image (gimp));
if (! object)
object = GIMP_OBJECT (gimp_clipboard_get_buffer (gimp));
return object;
}
/**
* gimp_clipboard_get_image:
* @gimp: pointer to #Gimp
*
* Retrieves either an image from the global image cut buffer of @gimp.
* Retrieves an image from the global image cut buffer of @gimp.
*
* The returned #GimpImage needs to be unref'ed when it's no longer
* needed.
......
......@@ -27,6 +27,8 @@ gboolean gimp_clipboard_has_buffer (Gimp *gimp);
gboolean gimp_clipboard_has_svg (Gimp *gimp);
gboolean gimp_clipboard_has_curve (Gimp *gimp);
GimpObject * gimp_clipboard_get_object (Gimp *gimp);
GimpImage * gimp_clipboard_get_image (Gimp *gimp);
GimpBuffer * gimp_clipboard_get_buffer (Gimp *gimp);
gchar * gimp_clipboard_get_svg (Gimp *gimp,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment