summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx27
1 files changed, 25 insertions, 2 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index aafaa084be9c..39f2281b0c7d 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1397,9 +1397,9 @@ callback (gpointer pData)
case LOK_CALLBACK_CONTENT_CONTROL:
{
- std::stringstream aStream(pCallback->m_aPayload);
+ std::stringstream aPayloadStream(pCallback->m_aPayload);
boost::property_tree::ptree aTree;
- boost::property_tree::read_json(aStream, aTree);
+ boost::property_tree::read_json(aPayloadStream, aTree);
auto aAction = aTree.get<std::string>("action");
if (aAction == "show")
{
@@ -1410,6 +1410,29 @@ callback (gpointer pData)
{
priv->m_aContentControlRectangles.clear();
}
+ else if (aAction == "change-picture")
+ {
+ GtkWidget* pDialog = gtk_file_chooser_dialog_new(
+ "Open File", GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))),
+ GTK_FILE_CHOOSER_ACTION_OPEN, "Cancel", GTK_RESPONSE_CANCEL, "Open",
+ GTK_RESPONSE_ACCEPT, nullptr);
+ gint nRet = gtk_dialog_run(GTK_DIALOG(pDialog));
+ if (nRet == GTK_RESPONSE_ACCEPT)
+ {
+ GtkFileChooser* pChooser = GTK_FILE_CHOOSER(pDialog);
+ char* pFilename = gtk_file_chooser_get_uri(pChooser);
+ boost::property_tree::ptree aValues;
+ aValues.put("type", "picture");
+ aValues.put("changed", pFilename);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aValues);
+ std::string aJson = aStream.str();
+ lok_doc_view_send_content_control_event(pDocView, aJson.c_str());
+
+ g_free(pFilename);
+ }
+ gtk_widget_destroy(pDialog);
+ }
g_signal_emit(pCallback->m_pDocView, doc_view_signals[CONTENT_CONTROL], 0,
pCallback->m_aPayload.c_str());
gtk_widget_queue_draw(GTK_WIDGET(pDocView));