diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-01-30 13:11:05 +0530 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2017-01-30 17:50:32 +0530 |
commit | bc713d0670b02c9f267fcf1e5f3373525bcda047 (patch) | |
tree | ff05766c549c5f6e296155849e3e36bb4f6640d5 /libreofficekit | |
parent | 8a7c459f6afb7b8f1f622a61230a0a4411a417ac (diff) |
gtktiledviewer: Can edit comment from comment sidebar now
TODO: Ideal would be to replace these buttons with a popover menu
containing all the actions that can be taken on a comment
Change-Id: Iec19e6c4a934394f84bcf4bb20cc14f207ef95be
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 6ea864bc1581..bfdaea5e760c 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -282,6 +282,30 @@ static void userPromptDialog(GtkWidget* pDocView, const std::string& aTitle, std gtk_widget_destroy(pDialog); } +static void editButtonClicked(GtkWidget* pWidget, gpointer userdata) +{ + TiledWindow& rWindow = lcl_getTiledWindow(pWidget); + std::map<std::string, std::string> aEntries; + aEntries["Text"] = ""; + + userPromptDialog(rWindow.m_pDocView, "Edit comment", aEntries); + + int *commentId = static_cast<int*>(g_object_get_data(G_OBJECT(userdata), "id")); + + boost::property_tree::ptree aTree; + aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "type", nullptr), '/'), "long"); + aTree.put(boost::property_tree::ptree::path_type(g_strconcat("Id", "/", "value", nullptr), '/'), std::to_string(*commentId)); + + 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), '/'), aEntries["Text"]); + + std::stringstream aStream; + boost::property_tree::write_json(aStream, aTree); + std::string aArguments = aStream.str(); + + lok_doc_view_post_command(LOK_DOC_VIEW(rWindow.m_pDocView), ".uno:EditAnnotation", aArguments.c_str(), false); +} + static void replyButtonClicked(GtkWidget* pWidget, gpointer userdata) { TiledWindow& rWindow = lcl_getTiledWindow(pWidget); @@ -334,13 +358,14 @@ GtkWidget* CommentsSidebar::createCommentBox(const boost::property_tree::ptree& GtkWidget* pCommentAuthor = gtk_label_new(aComment.get<std::string>("author").c_str()); GtkWidget* pCommentDate = gtk_label_new(aComment.get<std::string>("dateTime").c_str()); GtkWidget* pControlsHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - GtkWidget* pGotoButton = gtk_button_new_with_label("Goto"); + GtkWidget* pEditButton = gtk_button_new_with_label("Edit"); GtkWidget* pReplyButton = gtk_button_new_with_label("Reply"); GtkWidget* pDeleteButton = gtk_button_new_with_label("Delete"); + g_signal_connect(G_OBJECT(pEditButton), "clicked", G_CALLBACK(editButtonClicked), pCommentVBox); g_signal_connect(G_OBJECT(pReplyButton), "clicked", G_CALLBACK(replyButtonClicked), pCommentVBox); g_signal_connect(G_OBJECT(pDeleteButton), "clicked", G_CALLBACK(deleteCommentButtonClicked), pCommentVBox); - gtk_container_add(GTK_CONTAINER(pControlsHBox), pGotoButton); + gtk_container_add(GTK_CONTAINER(pControlsHBox), pEditButton); gtk_container_add(GTK_CONTAINER(pControlsHBox), pReplyButton); gtk_container_add(GTK_CONTAINER(pControlsHBox), pDeleteButton); GtkWidget* pCommentSeparator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); |