summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-17 15:40:14 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-17 14:59:37 +0000
commit087b71f423cf6c047137fb1316527132bb47fc05 (patch)
tree5737058d8db999eb20fa2b9c4674fe627954925d /libreofficekit
parentf2033c28f4ddb5984fc9b2374486f229f296d5f6 (diff)
sw: allow accept/reject of redline by index
Previously .uno:AcceptTrackedChange / .uno:RejectTrackedChange always worked by cursor position, but redlines are stored in the redline table, so they have a unique index. Allow specifying that index when invoking the command, and in that case ignore the cursor position. The index is not stable after an insertion / deletion. Change-Id: I493a22e84800ded224fb6b9c61261744dc0fb64f Reviewed-on: https://gerrit.libreoffice.org/28192 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx41
1 files changed, 37 insertions, 4 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 9351b61b0ea1..e9753816a086 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -466,8 +466,10 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/)
GtkWidget* pDialog = gtk_dialog_new_with_buttons("Manage Changes",
GTK_WINDOW (gtk_widget_get_toplevel(GTK_WIDGET(pDocView))),
GTK_DIALOG_MODAL,
- "Close",
- GTK_RESPONSE_OK,
+ "Accept",
+ GTK_RESPONSE_YES,
+ "Reject",
+ GTK_RESPONSE_NO,
nullptr);
GtkWidget* pContentArea = gtk_dialog_get_content_area(GTK_DIALOG (pDialog));
@@ -486,7 +488,7 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/)
-1);
}
GtkWidget* pTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pTreeStore));
- std::vector<std::string> aColumns = {"Index", "Type", "Comment", "Author", "Timestamp"};
+ std::vector<std::string> aColumns = {"Index", "Author", "Type", "Comment", "Timestamp"};
for (size_t nColumn = 0; nColumn < aColumns.size(); ++nColumn)
{
GtkCellRenderer* pRenderer = gtk_cell_renderer_text_new();
@@ -500,7 +502,38 @@ static void documentRedline(GtkWidget* pButton, gpointer /*pItem*/)
// Show the dialog.
gtk_widget_show_all(pDialog);
- gtk_dialog_run(GTK_DIALOG(pDialog));
+ gint res = gtk_dialog_run(GTK_DIALOG(pDialog));
+
+ // Dispatch the matching command, if necessary.
+ if (res == GTK_RESPONSE_YES || res == GTK_RESPONSE_NO)
+ {
+ GtkTreeSelection* pSelection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pTreeView));
+ GtkTreeIter aTreeIter;
+ GtkTreeModel* pTreeModel;
+ if (gtk_tree_selection_get_selected(pSelection, &pTreeModel, &aTreeIter))
+ {
+ gint nIndex = 0;
+ // 0: index
+ gtk_tree_model_get(pTreeModel, &aTreeIter, 0, &nIndex, -1);
+ std::string aCommand;
+ if (res == GTK_RESPONSE_YES)
+ aCommand = ".uno:AcceptTrackedChange";
+ else
+ aCommand = ".uno:RejectTrackedChange";
+ // Without the '.uno:' prefix.
+ std::string aKey = aCommand.substr(strlen(".uno:"));
+
+ // Post the command.
+ boost::property_tree::ptree aCommandTree;
+ aCommandTree.put(boost::property_tree::ptree::path_type(aKey + "/type", '/'), "unsigned short");
+ aCommandTree.put(boost::property_tree::ptree::path_type(aKey + "/value", '/'), nIndex);
+
+ aStream.str(std::string());
+ boost::property_tree::write_json(aStream, aCommandTree);
+ std::string aArguments = aStream.str();
+ lok_doc_view_post_command(pDocView, aCommand.c_str(), aArguments.c_str(), false);
+ }
+ }
gtk_widget_destroy(pDialog);
}