1
0
mirror of https://github.com/dguglielmi/sunny-overlay.git synced 2025-12-06 22:32:37 +01:00
Files
sunny-overlay/x11-misc/gpaste/files/gpaste-3.32.0-detect-when-images-are-growing.patch

84 lines
3.7 KiB
Diff

From d195bf0ebc2ed82b49cb83ce9cbad8a7fa492c34 Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Date: Tue, 7 May 2019 15:58:46 +0200
Subject: [PATCH] detect when images are growing
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
---
src/libgpaste/core/gpaste-history.c | 3 +++
src/libgpaste/core/gpaste-image-item.c | 18 ++++++++++++++++++
src/libgpaste/core/gpaste-image-item.h | 3 +++
src/libgpaste/libgpaste.sym | 5 +++++
4 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/src/libgpaste/core/gpaste-history.c b/src/libgpaste/core/gpaste-history.c
index 7936fab1..02f2b4fa 100644
--- a/src/libgpaste/core/gpaste-history.c
+++ b/src/libgpaste/core/gpaste-history.c
@@ -214,6 +214,9 @@ g_paste_history_private_is_growing_line (GPasteHistoryPrivate *priv,
GPasteItem *old,
GPasteItem *new)
{
+ if (_G_PASTE_IS_IMAGE_ITEM (old) && _G_PASTE_IS_IMAGE_ITEM (new))
+ return g_paste_image_item_is_growing (_G_PASTE_IMAGE_ITEM (new), _G_PASTE_IMAGE_ITEM (old));
+
if (!(g_paste_settings_get_growing_lines (priv->settings) &&
_G_PASTE_IS_TEXT_ITEM (old) && _G_PASTE_IS_TEXT_ITEM (new) &&
!_G_PASTE_IS_PASSWORD_ITEM (old) && !_G_PASTE_IS_PASSWORD_ITEM (new)))
diff --git a/src/libgpaste/core/gpaste-image-item.c b/src/libgpaste/core/gpaste-image-item.c
index 7b3a3244..2b30a6c6 100644
--- a/src/libgpaste/core/gpaste-image-item.c
+++ b/src/libgpaste/core/gpaste-image-item.c
@@ -80,6 +80,24 @@ g_paste_image_item_get_image (const GPasteImageItem *self)
return priv->image;
}
+G_PASTE_VISIBLE gboolean
+g_paste_image_item_is_growing (const GPasteImageItem *self,
+ const GPasteImageItem *other)
+{
+ g_return_val_if_fail (_G_PASTE_IS_IMAGE_ITEM (self), FALSE);
+ g_return_val_if_fail (_G_PASTE_IS_IMAGE_ITEM (other), FALSE);
+
+ const GPasteImageItemPrivate *priv = _g_paste_image_item_get_instance_private (self);
+ const GPasteImageItemPrivate *_priv = _g_paste_image_item_get_instance_private (other);
+
+ if (!priv->image || !_priv->image)
+ return FALSE;
+
+ gsize len = MIN (gdk_pixbuf_get_byte_length (priv->image), gdk_pixbuf_get_byte_length (_priv->image));
+
+ return !memcmp (gdk_pixbuf_read_pixels (priv->image), gdk_pixbuf_read_pixels (_priv->image), len);
+}
+
static gboolean
g_paste_image_item_equals (const GPasteItem *self,
const GPasteItem *other)
diff --git a/src/libgpaste/core/gpaste-image-item.h b/src/libgpaste/core/gpaste-image-item.h
index bfc74896..b658109b 100644
--- a/src/libgpaste/core/gpaste-image-item.h
+++ b/src/libgpaste/core/gpaste-image-item.h
@@ -23,6 +23,9 @@ const gchar *g_paste_image_item_get_checksum (const GPasteImageItem *self);
const GDateTime *g_paste_image_item_get_date (const GPasteImageItem *self);
GdkPixbuf *g_paste_image_item_get_image (const GPasteImageItem *self);
+gboolean g_paste_image_item_is_growing (const GPasteImageItem *self,
+ const GPasteImageItem *other);
+
GPasteItem *g_paste_image_item_new (GdkPixbuf *img);
GPasteItem *g_paste_image_item_new_from_file (const gchar *path,
GDateTime *date);
diff --git a/src/libgpaste/libgpaste.sym b/src/libgpaste/libgpaste.sym
index daf6329e..650d2a26 100644
--- a/src/libgpaste/libgpaste.sym
+++ b/src/libgpaste/libgpaste.sym
@@ -505,3 +505,8 @@ global:
g_paste_util_empty_with_confirmation;
g_paste_util_empty_with_confirmation_sync;
} LIBGPASTE_3_28_1;
+
+LIBGPASTE_3_32_1 {
+global:
+ g_paste_iimage_item_is_growing;
+} LIBGPASTE_3_28_3;