summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-01-24 18:35:42 +0530
committerPranav Kant <pranavk@collabora.co.uk>2017-01-27 21:57:01 +0530
commit8b3ea2ad62fd781e2fe253ee0c2bb0ce143912f4 (patch)
tree27825b00e717b7949810db55f29d701d214ebf73 /libreofficekit
parent7c2e96a4e7733e315bf948dd89a5d804cef5e67e (diff)
gtktiledviewer: Comment dialog when tiled annotations are off
Change-Id: I6762baac6c387d968dc6ee94d3494907c817214c
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx45
1 files changed, 44 insertions, 1 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index c2faacd6a00a..7bac0eb2fc37 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -1438,7 +1438,50 @@ static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
LOKDocView* pLOKDocView = LOK_DOC_VIEW(rWindow.m_pDocView);
GtkToolItem* pItem = GTK_TOOL_ITEM(pWidget);
const std::string& rString = rWindow.m_aToolItemCommandNames[pItem];
- const std::string& rArguments = rWindow.m_aToolItemCommandArgs[pItem];
+ std::string& rArguments = rWindow.m_aToolItemCommandArgs[pItem];
+
+ if (rString == ".uno:InsertAnnotation")
+ {
+ LOKDocView* pDocView = LOK_DOC_VIEW(rWindow.m_pDocView);
+
+ GtkWidget* pAnnotationDialog = gtk_dialog_new_with_buttons ("Insert Comment",
+ GTK_WINDOW (gtk_widget_get_toplevel(GTK_WIDGET(pDocView))),
+ GTK_DIALOG_MODAL,
+ "Insert",
+ GTK_RESPONSE_OK,
+ nullptr);
+
+ GtkWidget* pDialogMessageArea = gtk_dialog_get_content_area (GTK_DIALOG (pAnnotationDialog));
+ GtkWidget* pHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_start(GTK_BOX(pDialogMessageArea), pHBox, TRUE, TRUE, 2);
+
+ GtkWidget* pCommentLabel = gtk_label_new("Comment text");
+ gtk_box_pack_start(GTK_BOX(pHBox), pCommentLabel, TRUE, TRUE, 2);
+
+ GtkWidget* pCommentText = gtk_entry_new();
+ gtk_box_pack_start(GTK_BOX(pHBox), pCommentText, TRUE, TRUE, 2);
+
+ gtk_widget_show_all(pAnnotationDialog);
+
+ gint res = gtk_dialog_run(GTK_DIALOG(pAnnotationDialog));
+ switch(res)
+ {
+ case GTK_RESPONSE_OK:
+ const gchar* sText = gtk_entry_get_text(GTK_ENTRY(pCommentText));
+ boost::property_tree::ptree aTree;
+ aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "type", nullptr), '/'), "string");
+ aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Text", "/", "value", nullptr), '/'), sText);
+
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ rArguments = aStream.str();
+
+ break;
+ }
+
+ gtk_widget_destroy(pAnnotationDialog);
+ }
+
g_info("toggleToolItem: lok_doc_view_post_command('%s %s')", rString.c_str(), rArguments.c_str());
// notify about the finished Save