[Libreoffice-commits] core.git: libreofficekit/qa

Miklos Vajna vmiklos at collabora.co.uk
Thu Jun 18 00:20:18 PDT 2015


 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)

New commits:
commit 437210d58f32177ef1829d704f7f4d2f1bbfbfdd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jun 18 09:18:18 2015 +0200

    gtktiledviewer: add copy button
    
    Change-Id: I56ed5047da118eac01d7dea150597133215278e2

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 8b00679..9496ba5 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -125,6 +125,19 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/)
     }
 }
 
+/// Handler for the copy button: write clipboard.
+static void doCopy(GtkWidget* /*pButton*/, gpointer /*pItem*/)
+{
+    LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
+    LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView);
+    char* pSelection = pDocument->pClass->getTextSelection(pDocument, "text/plain;charset=utf-8");
+
+    GtkClipboard* pClipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(pDocView), GDK_SELECTION_CLIPBOARD);
+    gtk_clipboard_set_text(pClipboard, pSelection, -1);
+
+    free(pSelection);
+}
+
 /// Get the visible area of the scrolled window
 static void getVisibleAreaTwips(GdkRectangle* pArea)
 {
@@ -394,6 +407,14 @@ int main( int argc, char* argv[] )
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartModeSelectorToolItem, -1 );
 
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
+
+    // Cut, copy & paste.
+    GtkToolItem* pCopyButton = gtk_tool_button_new( NULL, NULL);
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(pCopyButton), "edit-copy-symbolic");
+    gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pCopyButton, -1);
+    g_signal_connect(G_OBJECT(pCopyButton), "clicked", G_CALLBACK(doCopy), NULL);
+    gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
+
     pEnableEditing = gtk_toggle_tool_button_new();
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pEnableEditing), "insert-text-symbolic");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pEnableEditing, -1);


More information about the Libreoffice-commits mailing list