From f5f3103187545952babf7b7efbdebc7d969f0974 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 10 Feb 2017 19:18:24 +0530 Subject: gtktiledviewer: comment id can be a string too now Change-Id: Ia94041884b7fde5f6c104a41c77c6a3aa96b7be1 --- .../qa/gtktiledviewer/gtktiledviewer.cxx | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'libreofficekit') diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 542e63154b38..1bdb2560a172 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -291,11 +291,11 @@ static void editButtonClicked(GtkWidget* pWidget, gpointer userdata) userPromptDialog(rWindow.m_pDocView, "Edit comment", aEntries); - int *commentId = static_cast(g_object_get_data(G_OBJECT(userdata), "id")); + gchar *commentId = static_cast(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("Id", "/", "value", nullptr), '/'), std::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"]); @@ -315,11 +315,11 @@ static void replyButtonClicked(GtkWidget* pWidget, gpointer userdata) userPromptDialog(rWindow.m_pDocView, "Reply comment", aEntries); - int *commentId = static_cast(g_object_get_data(G_OBJECT(userdata), "id")); + gchar *commentId = static_cast(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("Id", "/", "value", nullptr), '/'), std::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"]); @@ -335,11 +335,11 @@ static void deleteCommentButtonClicked(GtkWidget* pWidget, gpointer userdata) { TiledWindow& rWindow = lcl_getTiledWindow(pWidget); - int *commentid = static_cast(g_object_get_data(G_OBJECT(userdata), "id")); + gchar *commentid = static_cast(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("Id", "/", "value", nullptr), '/'), std::string(commentid)); std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); @@ -351,12 +351,11 @@ static void deleteCommentButtonClicked(GtkWidget* pWidget, gpointer userdata) GtkWidget* CommentsSidebar::createCommentBox(const boost::property_tree::ptree& aComment) { GtkWidget* pCommentVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 1); - int *id = g_new(int, 1); - *id = aComment.get("id"); + gchar *id = g_strndup(aComment.get("id").c_str(), 20); g_object_set_data_full(G_OBJECT(pCommentVBox), "id", id, g_free); - // Set left-margin if its a reply comment - if (aComment.get("parent") > 0) + // Set background if its a reply comment + if (aComment.get("parent", -1) > 0) { GtkStyleContext* pStyleContext = gtk_widget_get_style_context(pCommentVBox); GtkCssProvider* pCssProvider = gtk_css_provider_get_default(); @@ -1603,13 +1602,13 @@ static void commentCallback(LOKDocView* pLOKDocView, gchar* pComment, gpointer / GtkWidget* pParent = nullptr; for (GList* l = pChildren; l != nullptr; l = l->next) { - int *id = static_cast(g_object_get_data(G_OBJECT(l->data), "id")); + gchar *id = static_cast(g_object_get_data(G_OBJECT(l->data), "id")); - if (*id == aComment.get("id")) + if (g_strcmp0(id, aComment.get("id").c_str()) == 0) pSelf = GTK_WIDGET(l->data); // There is no 'parent' in Remove callbacks - if (*id == aComment.get("parent", -1)) + if (g_strcmp0(id, aComment.get("parent", std::string("0")).c_str()) == 0) pParent = GTK_WIDGET(l->data); } -- cgit