diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-10-22 13:32:31 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-10-22 13:34:21 +0200 |
commit | 173fc95b3551c1e69c49626211be8422cb29fb3e (patch) | |
tree | e83d3381b2af4d6cbad2c9c82a5183ff03ee6aea /libreofficekit/qa | |
parent | 6552767aa5ed61215eb64dac0cc026a5f7a9aad1 (diff) |
gtktiledviewer: initial paste support
Change-Id: I50b4dfa456d3518f5ef7faf5f634642973441a3e
Diffstat (limited to 'libreofficekit/qa')
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 289a999a59c5..f7c4d5c8d743 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -12,6 +12,7 @@ #include <string.h> #include <string> #include <map> +#include <iostream> #include <boost/property_tree/json_parser.hpp> #include <gdk/gdkkeysyms.h> @@ -280,6 +281,17 @@ static void doCopy(GtkWidget* pButton, gpointer /*pItem*/) free(pUsedFormat); } +static void doPaste(GtkWidget* pButton, gpointer /*pItem*/) +{ + TiledWindow& rWindow = lcl_getTiledWindow(pButton); + LOKDocView* pLOKDocView = LOK_DOC_VIEW(rWindow.m_pDocView); + LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView); + + GtkClipboard* pClipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(rWindow.m_pDocView), GDK_SELECTION_CLIPBOARD); + gchar* pText = gtk_clipboard_wait_for_text(pClipboard); + if (pText) + pDocument->pClass->paste(pDocument, "text/plain;charset=utf-8", pText, strlen(pText)); +} /// Searches for the next or previous text of TiledWindow::m_pFindbarEntry. static void doSearch(GtkWidget* pButton, bool bBackwards) @@ -662,6 +674,12 @@ static GtkWidget* createWindow(TiledWindow& rWindow) gtk_tool_item_set_tooltip_text(pCopyButton, "Copy"); gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pCopyButton, -1); g_signal_connect(G_OBJECT(pCopyButton), "clicked", G_CALLBACK(doCopy), NULL); + + GtkToolItem* pPasteButton = gtk_tool_button_new( NULL, NULL); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(pPasteButton), "edit-paste-symbolic"); + gtk_tool_item_set_tooltip_text(pPasteButton, "Paste"); + gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pPasteButton, -1); + g_signal_connect(G_OBJECT(pPasteButton), "clicked", G_CALLBACK(doPaste), NULL); gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1); GtkToolItem* pEnableEditing = gtk_toggle_tool_button_new(); |