From 727c2303cb70a62a35f2e7ff7cd47cdb3ccd556d Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Sat, 2 Dec 2017 02:47:38 +0530 Subject: lokdialog: multiview: Do not mix one view with other In GTV, use correct application window object to fetch the dialog object. Use correct view shell to notify window (dialogs, etc.) callbacks. Change-Id: I7d82b39d4522a4b4904e156757a032c342c71efb --- .../qa/gtktiledviewer/gtv-application-window.cxx | 23 +++++++++------------- .../qa/gtktiledviewer/gtv-application-window.hxx | 2 -- .../gtv-lokdocview-signal-handlers.cxx | 9 ++++----- 3 files changed, 13 insertions(+), 21 deletions(-) (limited to 'libreofficekit') diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx index f58884c79207..d9c709604a28 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx @@ -315,7 +315,7 @@ static void setupDocView(GtvApplicationWindow* window) g_signal_connect(window->lokdocview, "formula-changed", G_CALLBACK(LOKDocViewSigHandlers::formulaChanged), nullptr); g_signal_connect(window->lokdocview, "password-required", G_CALLBACK(LOKDocViewSigHandlers::passwordRequired), nullptr); g_signal_connect(window->lokdocview, "comment", G_CALLBACK(LOKDocViewSigHandlers::comment), nullptr); - g_signal_connect(window->lokdocview, "window", G_CALLBACK(LOKDocViewSigHandlers::window), nullptr); + g_signal_connect(window->lokdocview, "window", G_CALLBACK(LOKDocViewSigHandlers::window), window); g_signal_connect(window->lokdocview, "configure-event", G_CALLBACK(LOKDocViewSigHandlers::configureEvent), nullptr); } @@ -402,6 +402,9 @@ gtv_application_window_get_part_broadcast(GtvApplicationWindow* window) void gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin) { + guint dialogid = 0; + g_object_get(G_OBJECT(pChildWin), "dialogid", &dialogid, nullptr); + g_debug("Register child window: dialogid [%d] in window[%p]", dialogid, window); GtvApplicationWindowPrivate* priv = getPrivate(window); if (pChildWin) priv->m_pChildWindows = g_list_append(priv->m_pChildWindows, pChildWin); @@ -410,6 +413,9 @@ gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWi void gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin) { + guint dialogid = 0; + g_object_get(G_OBJECT(pChildWin), "dialogid", &dialogid, nullptr); + g_debug("Unregister child window: dialogid [%d] in window[%p]", dialogid, window); GtvApplicationWindowPrivate* priv = getPrivate(window); if (pChildWin) { @@ -432,7 +438,6 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guin { guint dialogId = 0; g_object_get(G_OBJECT(pIt->data), "dialogid", &dialogId, nullptr); - if (dialogId == nWinId) { ret = GTK_WINDOW(pIt->data); @@ -443,7 +448,8 @@ gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guin return ret; } -GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint nWinId) +GtkWidget* +gtv_application_window_get_parent(GtvApplicationWindow* window, guint nWinId) { GtvApplicationWindowPrivate* priv = getPrivate(window); GList* pIt = nullptr; @@ -455,17 +461,6 @@ GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint return nullptr; } - -// temporary function to invalidate all opened dialogs -// because currently the dialog id returned in dialog invalidation payload -// doesn't match our hard-coded list of dialog ids (uno commands) for some dialogs -GList* -gtv_application_window_get_all_child_windows(GtvApplicationWindow* window) -{ - GtvApplicationWindowPrivate* priv = getPrivate(window); - return priv->m_pChildWindows; -} - GtvApplicationWindow* gtv_application_window_new(GtkApplication* app) { diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx index 78e9bae3e97f..748195c5aff0 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx @@ -105,8 +105,6 @@ void gtv_application_window_unregister_child_window(GtvApplicationWindow* window GtkWindow* gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, guint nWinId); -GList* gtv_application_window_get_all_child_windows(GtvApplicationWindow* window); - GtkWidget* gtv_application_window_get_parent(GtvApplicationWindow* window, guint nWinId); G_END_DECLS diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index aa15a03a83e1..78f940cb33c7 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -301,9 +301,9 @@ void LOKDocViewSigHandlers::comment(LOKDocView* pDocView, gchar* pComment, gpoin } } -void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpointer) +void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpointer pData) { - GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); + GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(pData); std::stringstream aStream(pPayload); boost::property_tree::ptree aRoot; @@ -350,9 +350,8 @@ void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpoint else if (aAction == "close") gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pParent)); } - else // it's the dialog window itself - { - GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, nWinId); + else if (GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, nWinId)) + { // it's the dialog window itself if (aAction == "close") gtk_widget_destroy(GTK_WIDGET(pDialog)); else if (aAction == "size_changed") -- cgit