135360
From 82c4891ec0e285b1cdf767dea54b877a16177374 Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Thu, 18 Jun 2015 09:18:18 +0200
135360
Subject: [PATCH 053/398] gtktiledviewer: add copy button
135360
135360
Change-Id: I56ed5047da118eac01d7dea150597133215278e2
135360
(cherry picked from commit 437210d58f32177ef1829d704f7f4d2f1bbfbfdd)
135360
---
135360
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 21 +++++++++++++++++++++
135360
 1 file changed, 21 insertions(+)
135360
135360
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
135360
index 8b006797c226..9496ba5ea180 100644
135360
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
135360
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
135360
@@ -125,6 +125,19 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/)
135360
     }
135360
 }
135360
 
135360
+/// Handler for the copy button: write clipboard.
135360
+static void doCopy(GtkWidget* /*pButton*/, gpointer /*pItem*/)
135360
+{
135360
+    LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
135360
+    LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView);
135360
+    char* pSelection = pDocument->pClass->getTextSelection(pDocument, "text/plain;charset=utf-8");
135360
+
135360
+    GtkClipboard* pClipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(pDocView), GDK_SELECTION_CLIPBOARD);
135360
+    gtk_clipboard_set_text(pClipboard, pSelection, -1);
135360
+
135360
+    free(pSelection);
135360
+}
135360
+
135360
 /// Get the visible area of the scrolled window
135360
 static void getVisibleAreaTwips(GdkRectangle* pArea)
135360
 {
135360
@@ -394,6 +407,14 @@ int main( int argc, char* argv[] )
135360
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartModeSelectorToolItem, -1 );
135360
 
135360
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
135360
+
135360
+    // Cut, copy & paste.
135360
+    GtkToolItem* pCopyButton = gtk_tool_button_new( NULL, NULL);
135360
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(pCopyButton), "edit-copy-symbolic");
135360
+    gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pCopyButton, -1);
135360
+    g_signal_connect(G_OBJECT(pCopyButton), "clicked", G_CALLBACK(doCopy), NULL);
135360
+    gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
135360
+
135360
     pEnableEditing = gtk_toggle_tool_button_new();
135360
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pEnableEditing), "insert-text-symbolic");
135360
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pEnableEditing, -1);
135360
-- 
135360
2.12.0
135360