From 1a1ee7803d8f17532fb2149fcc386cc70720eef0 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Thu, 26 Oct 2017 13:39:06 -0700 Subject: lokdialog: Use UNO name as dialog id when invoking lok callbacks ... not the frame id from the .ui file Remove temporary hacks introduced earlier in GTV also. Change-Id: I71290a5fac6547a5584094da21e2301ef8fbce0c Reviewed-on: https://gerrit.libreoffice.org/43957 Tested-by: Jenkins Reviewed-by: pranavk --- .../gtv-lokdocview-signal-handlers.cxx | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'libreofficekit') diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index 95a462a79593..415c3d6526c4 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -288,24 +288,27 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint std::stringstream aStream(pPayload); boost::property_tree::ptree aRoot; boost::property_tree::read_json(aStream, aRoot); - //std::string aDialogId = aRoot.get("dialogId"); + std::string aDialogId = aRoot.get("dialogId"); std::string aAction = aRoot.get("action"); // we only understand 'invalidate' and 'close' as of now if (aAction != "invalidate" && aAction != "close") return; - // temporary hack to invalidate all open dialogs GList* pChildWins = gtv_application_window_get_all_child_windows(window); GList* pIt = nullptr; for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next) { - if (aAction == "close") + gchar* pChildDialogId = nullptr; + g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr); + if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0) { - gtk_widget_destroy(GTK_WIDGET(pIt->data)); + if (aAction == "close") + gtk_widget_destroy(GTK_WIDGET(pIt->data)); + else if (aAction == "invalidate") + gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data)); } - else if (aAction == "invalidate") - gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data)); + g_free(pChildDialogId); } } @@ -316,7 +319,7 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g std::stringstream aStream(pPayload); boost::property_tree::ptree aRoot; boost::property_tree::read_json(aStream, aRoot); - //std::string aDialogId = aRoot.get("dialogId"); + std::string aDialogId = aRoot.get("dialogId"); std::string aAction = aRoot.get("action"); std::string aPos = aRoot.get("position"); gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2); @@ -332,15 +335,20 @@ void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, g g_strfreev(ppCoordinates); - // temporary hack to invalidate/close floating window of all opened dialogs GList* pChildWins = gtv_application_window_get_all_child_windows(window); GList* pIt = nullptr; for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next) { - if (aAction == "invalidate") - gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY); - else if (aAction == "close") - gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data)); + gchar* pChildDialogId = nullptr; + g_object_get(pIt->data, "dialogid", &pChildDialogId, nullptr); + if (g_strcmp0(pChildDialogId, aDialogId.c_str()) == 0) + { + if (aAction == "invalidate") + gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY); + else if (aAction == "close") + gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data)); + } + g_free(pChildDialogId); } } -- cgit