Blame SOURCES/0371-tdf-96384-Add-a-new-signal-text-selection-to-lokdocv.patch

135360
From 8d11e5ab0f7d7fb882086a626c69bfb218c9ab3e Mon Sep 17 00:00:00 2001
135360
From: Pranav Kant <pranavk@libreoffice.org>
135360
Date: Thu, 10 Dec 2015 21:10:16 +0530
135360
Subject: [PATCH 371/398] tdf#96384: Add a new signal 'text-selection' to
135360
 lokdocview
135360
135360
To help client know when the user has selected a non-null text.
135360
135360
Change-Id: Ie939612fc5f38e2e50e9ad9792e04e89ae918886
135360
Reviewed-on: https://gerrit.libreoffice.org/20621
135360
Tested-by: Jenkins <ci@libreoffice.org>
135360
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
135360
(cherry picked from commit ea5c99428f56e1d3a3e782505aa2f56f905038a4)
135360
Signed-off-by: David Tardon <dtardon@redhat.com>
135360
(cherry picked from commit 3f13961c45ea9a6f90c0bc268a2274634d9b8033)
135360
---
135360
 libreofficekit/source/gtk/lokdocview.cxx | 21 ++++++++++++++++++++-
135360
 1 file changed, 20 insertions(+), 1 deletion(-)
135360
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
135360
index 99ad819f6e5c..012c75f29e1b 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
135360
@@ -186,6 +186,7 @@ enum
135360
     SEARCH_RESULT_COUNT,
135360
     COMMAND_RESULT,
135360
     FORMULA_CHANGED,
135360
+    TEXT_SELECTION,
135360
 
135360
     LAST_SIGNAL
135360
 };
135360
@@ -925,8 +926,9 @@ callback (gpointer pData)
135360
     case LOK_CALLBACK_TEXT_SELECTION:
135360
     {
135360
         priv->m_aTextSelectionRectangles = payloadToRectangles(pDocView, pCallback->m_aPayload.c_str());
135360
+        gboolean bIsTextSelected = !priv->m_aTextSelectionRectangles.empty();
135360
         // In case the selection is empty, then we get no LOK_CALLBACK_TEXT_SELECTION_START/END events.
135360
-        if (priv->m_aTextSelectionRectangles.empty())
135360
+        if (!bIsTextSelected)
135360
         {
135360
             memset(&priv->m_aTextSelectionStart, 0, sizeof(priv->m_aTextSelectionStart));
135360
             memset(&priv->m_aHandleStartRect, 0, sizeof(priv->m_aHandleStartRect));
135360
@@ -935,6 +937,8 @@ callback (gpointer pData)
135360
         }
135360
         else
135360
             memset(&priv->m_aHandleMiddleRect, 0, sizeof(priv->m_aHandleMiddleRect));
135360
+
135360
+        g_signal_emit(pDocView, doc_view_signals[TEXT_SELECTION], 0, bIsTextSelected);
135360
         gtk_widget_queue_draw(GTK_WIDGET(pDocView));
135360
     }
135360
     break;
135360
@@ -2380,6 +2384,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
135360
                      g_cclosure_marshal_VOID__STRING,
135360
                      G_TYPE_NONE, 1,
135360
                      G_TYPE_STRING);
135360
+
135360
+    /**
135360
+     * LOKDocView::text-selection:
135360
+     * @pDocView: the #LOKDocView on which the signal is emitted
135360
+     * @bIsTextSelected: whether text selected is non-null
135360
+     */
135360
+    doc_view_signals[TEXT_SELECTION] =
135360
+        g_signal_new("text-selection",
135360
+                     G_TYPE_FROM_CLASS(pGObjectClass),
135360
+                     G_SIGNAL_RUN_FIRST,
135360
+                     0,
135360
+                     nullptr, nullptr,
135360
+                     g_cclosure_marshal_VOID__BOOLEAN,
135360
+                     G_TYPE_NONE, 1,
135360
+                     G_TYPE_BOOLEAN);
135360
 }
135360
 
135360
 SAL_DLLPUBLIC_EXPORT GtkWidget*
135360
-- 
135360
2.12.0
135360