diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-08-10 17:24:40 +0530 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2017-10-02 11:01:43 +0530 |
commit | a0f36b458c00f2e6fc79b8c4a71e8b0b7cc6b6e0 (patch) | |
tree | 897d4c4532b808ee6dcb302674334d6ef98f604f /libreofficekit/qa/gtktiledviewer | |
parent | 3ebaaebf544be4f7f39b7fcbbbc377418a897442 (diff) |
lokdialog: Emit dialog close callback upon dialog close
Change-Id: I4ccef76cc3b2926dd8916f825671bb732e101027
Diffstat (limited to 'libreofficekit/qa/gtktiledviewer')
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx | 73 | ||||
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx | 12 |
2 files changed, 51 insertions, 34 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index 9fe49aaf350e..8ad25f42a98c 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -291,8 +291,8 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint //std::string aDialogId = aRoot.get<std::string>("dialogId"); std::string aAction = aRoot.get<std::string>("action"); - // we only understand 'invalidate' as of now - if (aAction != "invalidate") + // we only understand 'invalidate' and 'close' as of now + if (aAction != "invalidate" && aAction != "close") return; // temporary hack to invalidate all open dialogs @@ -300,43 +300,48 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint GList* pIt = nullptr; for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next) { - gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(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)); } } void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, gpointer) { - GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); - - std::stringstream aStream(pPayload); - boost::property_tree::ptree aRoot; - boost::property_tree::read_json(aStream, aRoot); - //std::string aDialogId = aRoot.get<std::string>("dialogId"); - std::string aAction = aRoot.get<std::string>("action"); - std::string aPos = aRoot.get<std::string>("position"); - gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2); - gchar** ppCoordinate = ppCoordinates; - int nX = 0; - int nY = 0; - - if (*ppCoordinate) - nX = atoi(*ppCoordinate); - ++ppCoordinate; - if (*ppCoordinate) - nY = atoi(*ppCoordinate); - - 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)); - } + GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); + + std::stringstream aStream(pPayload); + boost::property_tree::ptree aRoot; + boost::property_tree::read_json(aStream, aRoot); + //std::string aDialogId = aRoot.get<std::string>("dialogId"); + std::string aAction = aRoot.get<std::string>("action"); + std::string aPos = aRoot.get<std::string>("position"); + gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2); + gchar** ppCoordinate = ppCoordinates; + int nX = 0; + int nY = 0; + + if (*ppCoordinate) + nX = atoi(*ppCoordinate); + ++ppCoordinate; + if (*ppCoordinate) + nY = atoi(*ppCoordinate); + + 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)); + } } gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/) diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx index b871d93667f9..6ca78a61a2b2 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx @@ -293,6 +293,16 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ ) static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata) { GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata); + g_info("deletLokDialog"); + gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget)); + + return FALSE; +} + +static gboolean destroyLokDialog(GtkWidget* pWidget, gpointer userdata) +{ + GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata); + g_info("destroyLokDialog"); gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget)); return FALSE; @@ -304,9 +314,11 @@ void openLokDialog( GtkWidget* pSelector, gpointer /*pItem*/ ) gchar* pDialogId = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(pSelector)); GtkWidget* pDialog = gtv_lok_dialog_new(LOK_DOC_VIEW(window->lokdocview), pDialogId); gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog)); + g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window); g_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window); g_free(pDialogId); + g_info("openLokDialog"); gtk_window_set_resizable(GTK_WINDOW(pDialog), false); gtk_widget_show_all(GTK_WIDGET(pDialog)); gtk_window_present(GTK_WINDOW(pDialog)); |