[gimp] app: add gimp->clipboard_image and API to set/get it
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp->clipboard_image and API to set/get it
- Date: Mon, 19 Sep 2016 18:16:21 +0000 (UTC)
commit 7130ba95e19f82d8f839e0f67c380dc91a666ea3
Author: Michael Natterer <mitch gimp org>
Date: Mon Sep 19 20:13:39 2016 +0200
app: add gimp->clipboard_image and API to set/get it
app/core/gimp.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++----
app/core/gimp.h | 5 ++++
2 files changed, 59 insertions(+), 5 deletions(-)
---
diff --git a/app/core/gimp.c b/app/core/gimp.c
index e70b100..d431d51 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -432,6 +432,12 @@ gimp_finalize (GObject *object)
gimp->clipboard_buffer = NULL;
}
+ if (gimp->clipboard_image)
+ {
+ g_object_unref (gimp->clipboard_image);
+ gimp->clipboard_image = NULL;
+ }
+
if (gimp->displays)
{
g_object_unref (gimp->displays);
@@ -536,8 +542,12 @@ gimp_get_memsize (GimpObject *object,
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->displays), gui_size);
+ memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->clipboard_image),
+ gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->clipboard_buffer),
gui_size);
+ memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->named_buffers),
+ gui_size);
memsize += gimp_data_factories_get_memsize (gimp, gui_size);
@@ -966,23 +976,62 @@ gimp_get_tool_info_iter (Gimp *gimp)
}
void
+gimp_set_clipboard_image (Gimp *gimp,
+ GimpImage *image)
+{
+ g_return_if_fail (GIMP_IS_GIMP (gimp));
+ g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
+
+ /* ref first, it could be the same as gimp->clipboard_image, but
+ * don't bail if equal because always we want the signal emission
+ */
+ if (image)
+ g_object_ref (image);
+
+ if (gimp->clipboard_buffer)
+ {
+ g_object_unref (gimp->clipboard_buffer);
+ gimp->clipboard_buffer = NULL;
+ }
+
+ if (gimp->clipboard_image)
+ g_object_unref (gimp->clipboard_image);
+
+ gimp->clipboard_image = image;
+
+ g_signal_emit (gimp, gimp_signals[CLIPBOARD_CHANGED], 0);
+}
+
+GimpImage *
+gimp_get_clipboard_image (Gimp *gimp)
+{
+ g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
+
+ return gimp->clipboard_image;
+}
+
+void
gimp_set_clipboard_buffer (Gimp *gimp,
GimpBuffer *buffer)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (buffer == NULL || GIMP_IS_BUFFER (buffer));
- if (buffer == gimp->clipboard_buffer)
- return;
+ /* see above */
+ if (buffer)
+ g_object_ref (buffer);
+
+ if (gimp->clipboard_image)
+ {
+ g_object_unref (gimp->clipboard_image);
+ gimp->clipboard_image = NULL;
+ }
if (gimp->clipboard_buffer)
g_object_unref (gimp->clipboard_buffer);
gimp->clipboard_buffer = buffer;
- if (gimp->clipboard_buffer)
- g_object_ref (gimp->clipboard_buffer);
-
g_signal_emit (gimp, gimp_signals[CLIPBOARD_CHANGED], 0);
}
diff --git a/app/core/gimp.h b/app/core/gimp.h
index 538cc7a..0012c6a 100644
--- a/app/core/gimp.h
+++ b/app/core/gimp.h
@@ -89,6 +89,7 @@ struct _Gimp
GList *image_windows;
+ GimpImage *clipboard_image;
GimpBuffer *clipboard_buffer;
GimpContainer *named_buffers;
@@ -184,6 +185,10 @@ GList * gimp_get_image_windows (Gimp *gimp);
GList * gimp_get_paint_info_iter (Gimp *gimp);
GList * gimp_get_tool_info_iter (Gimp *gimp);
+void gimp_set_clipboard_image (Gimp *gimp,
+ GimpImage *image);
+GimpImage * gimp_get_clipboard_image (Gimp *gimp);
+
void gimp_set_clipboard_buffer (Gimp *gimp,
GimpBuffer *buffer);
GimpBuffer * gimp_get_clipboard_buffer (Gimp *gimp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]