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.
This commit is contained in:
Michael Natterer 2016-09-21 00:11:15 +02:00
parent fa94ab03ca
commit 35588d79c8
4 changed files with 44 additions and 1 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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.

View File

@ -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,