diff options
Diffstat (limited to 'libreofficekit/qa')
7 files changed, 92 insertions, 3 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx index fbe5746ddf1e..ab28f23578ec 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx @@ -36,6 +36,8 @@ struct GtvApplicationWindowPrivate gboolean toolbarBroadcast; gboolean partSelectorBroadcast; + GList* m_pChildWindows; + // Rendering args; options with which lokdocview was rendered in this window GtvRenderingArgs* m_pRenderingArgs; }; @@ -105,6 +107,7 @@ gtv_application_window_init(GtvApplicationWindow* win) gtk_container_add(GTK_CONTAINER(win), priv->container); + priv->m_pChildWindows = nullptr; priv->m_pRenderingArgs = new GtvRenderingArgs(); } @@ -311,6 +314,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, "dialog-invalidate", G_CALLBACK(LOKDocViewSigHandlers::dialogInvalidate), nullptr); g_signal_connect(window->lokdocview, "configure-event", G_CALLBACK(LOKDocViewSigHandlers::configureEvent), nullptr); } @@ -394,6 +398,50 @@ gtv_application_window_get_part_broadcast(GtvApplicationWindow* window) return priv->partSelectorBroadcast; } +void +gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin) +{ + GtvApplicationWindowPrivate* priv = getPrivate(window); + if (pChildWin) + priv->m_pChildWindows = g_list_append(priv->m_pChildWindows, pChildWin); +} + +void +gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin) +{ + GtvApplicationWindowPrivate* priv = getPrivate(window); + if (pChildWin) + priv->m_pChildWindows = g_list_remove(priv->m_pChildWindows, pChildWin); +} + +GtkWindow* +gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, const gchar* pWinId) +{ + GtvApplicationWindowPrivate* priv = getPrivate(window); + GList* pIt = nullptr; + GtkWindow* ret = nullptr; + // For now, only dialogs are registered as child window + for (pIt = priv->m_pChildWindows; pIt != nullptr; pIt = pIt->next) + { + gchar* dialogId = nullptr; + g_object_get(G_OBJECT(pIt->data), "dialogid", &dialogId, nullptr); + + // prepend .uno: + gchar* completeWinId = nullptr; + if (pWinId != nullptr) + { + completeWinId = g_strconcat(".uno:", pWinId, nullptr); + } + + if (dialogId != nullptr && g_str_equal(dialogId, completeWinId)) + { + ret = GTK_WINDOW(pIt->data); + break; + } + } + return ret; +} + 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 ec3b0666d76d..c16425566967 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.hxx @@ -99,6 +99,12 @@ void gtv_application_window_set_part_broadcast(GtvApplicationWindow* window, boo gboolean gtv_application_window_get_part_broadcast(GtvApplicationWindow* window); +void gtv_application_window_register_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin); + +void gtv_application_window_unregister_child_window(GtvApplicationWindow* window, GtkWindow* pChildWin); + +GtkWindow* gtv_application_window_get_child_window_by_id(GtvApplicationWindow* window, const gchar* pWinId); + G_END_DECLS #endif /* GTV_APPLICATION_WINDOW_H */ diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx index 5b48bd1b9ed7..a073198e5db3 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.cxx @@ -23,6 +23,7 @@ struct GtvLokDialogPrivate { LOKDocView* lokdocview; + GtkWidget* pDialogDrawingArea; gchar* dialogid; }; @@ -68,11 +69,13 @@ gtv_lok_dialog_draw(GtkWidget* pDialogDrawingArea, cairo_t* pCairo, gpointer) static void gtv_lok_dialog_init(GtvLokDialog* dialog) { + GtvLokDialogPrivate* priv = getPrivate(dialog); + GtkWidget* pContentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - GtkWidget* pDialogDrawingArea = gtk_drawing_area_new(); + priv->pDialogDrawingArea = gtk_drawing_area_new(); - g_signal_connect(G_OBJECT(pDialogDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_draw), nullptr); - gtk_container_add(GTK_CONTAINER(pContentArea), pDialogDrawingArea); + g_signal_connect(G_OBJECT(priv->pDialogDrawingArea), "draw", G_CALLBACK(gtv_lok_dialog_draw), nullptr); + gtk_container_add(GTK_CONTAINER(pContentArea), priv->pDialogDrawingArea); } static void @@ -150,6 +153,14 @@ gtv_lok_dialog_class_init(GtvLokDialogClass* klass) g_object_class_install_properties (G_OBJECT_CLASS(klass), PROP_LAST, properties); } +void +gtv_lok_dialog_invalidate(GtvLokDialog* dialog) +{ + // trigger a draw on the drawing area + GtvLokDialogPrivate* priv = getPrivate(dialog); + gtk_widget_queue_draw(priv->pDialogDrawingArea); +} + GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId) { diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx index 650d816e7e4a..0205f2ede3f4 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lok-dialog.hxx @@ -37,6 +37,8 @@ GType gtv_lok_dialog_get_type (void) G_GNUC_CONST; GtkWidget* gtv_lok_dialog_new(LOKDocView* pDocView, const gchar* dialogId); +void gtv_lok_dialog_invalidate(GtvLokDialog* dialog); + G_END_DECLS #endif /* GTV_LOK_DIALOG_H */ diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index 33f705262808..a549d852c786 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -15,6 +15,7 @@ #include <gtv-calc-header-bar.hxx> #include <gtv-comments-sidebar.hxx> #include <gtv-lokdocview-signal-handlers.hxx> +#include <gtv-lok-dialog.hxx> #include <boost/property_tree/json_parser.hpp> #include <boost/optional.hpp> @@ -280,6 +281,16 @@ void LOKDocViewSigHandlers::comment(LOKDocView* pDocView, gchar* pComment, gpoin } } +void LOKDocViewSigHandlers::dialogInvalidate(LOKDocView* pDocView, gchar* pDialogId, gpointer) +{ + GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); + GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, pDialogId); + if (pDialog) + { + gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pDialog)); + } +} + gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/) { GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pWidget))); diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx index 724f2031d4f5..73bf9c2860ad 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.hxx @@ -25,6 +25,7 @@ namespace LOKDocViewSigHandlers { void formulaChanged(LOKDocView* pDocView, char* pPayload, gpointer); void passwordRequired(LOKDocView* pDocView, char* pUrl, gboolean bModify, gpointer); void comment(LOKDocView* pDocView, gchar* pComment, gpointer); + void dialogInvalidate(LOKDocView* pDocView, gchar* pDialogId, gpointer); gboolean 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 e009fe215ce7..b871d93667f9 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx @@ -290,11 +290,21 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ ) } } +static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata) +{ + GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata); + gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget)); + + return FALSE; +} + void openLokDialog( GtkWidget* pSelector, gpointer /*pItem*/ ) { GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(pSelector)); 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, "delete-event", G_CALLBACK(deleteLokDialog), window); g_free(pDialogId); gtk_window_set_resizable(GTK_WINDOW(pDialog), false); |