diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-11-23 21:07:07 +0530 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-11-29 10:16:53 +0100 |
commit | 2798e1aae5311094c30d8e667c1e8be4e4314f8d (patch) | |
tree | 004547849b68813d3b60e5f0fdfa645c1e1f5317 /libreofficekit/qa | |
parent | 91b7c8bb605dfc8090922d765b9ac4cffef973fe (diff) |
lokdialog: Create dialog when callback is received
With this, we do away with initial approach of rendering the dialog on a
large surface. We now create the cairo surface with dimensions of the
dialog.
Change-Id: Icb034693c7f1c656b7daae7f5c711b5bd4d8e880
Diffstat (limited to 'libreofficekit/qa')
4 files changed, 34 insertions, 40 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index dfdbc3bc6ca6..03e54afd1d22 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -22,6 +22,24 @@ #include <iostream> +static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata) +{ + GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata); + g_info("deleteLokDialog"); + 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; +} + void LOKDocViewSigHandlers::editChanged(LOKDocView* pDocView, gboolean bWasEdit, gpointer) { GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); @@ -293,9 +311,23 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint const std::string aDialogId = aRoot.get<std::string>("dialogId"); const std::string aAction = aRoot.get<std::string>("action"); - // we only understand 'invalidate' and 'close' as of now - if (aAction != "invalidate" && aAction != "close") + if (aAction == "created") + { + const std::string aSize = aRoot.get<std::string>("size"); + std::vector<int> aPoints = GtvHelpers::splitIntoIntegers(aSize, ", ", 2); + GtkWidget* pDialog = gtv_lok_dialog_new(pDocView, aDialogId.c_str(), aPoints[0], aPoints[1]); + g_info("created dialog, for dialogid: %s with size: %s", aDialogId.c_str(), aSize.c_str()); + + 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); + + gtk_window_set_resizable(GTK_WINDOW(pDialog), false); + gtk_widget_show_all(GTK_WIDGET(pDialog)); + gtk_window_present(GTK_WINDOW(pDialog)); + return; + } GList* pChildWins = gtv_application_window_get_all_child_windows(window); GList* pIt = nullptr; diff --git a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx index d18482447a7e..33e454808ed2 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx @@ -119,7 +119,6 @@ gtv_main_toolbar_init(GtvMainToolbar* toolbar) gtk_builder_add_callback_symbol(builder.get(), "documentRepair", G_CALLBACK(documentRepair)); gtk_builder_add_callback_symbol(builder.get(), "signalAddressbar", G_CALLBACK(signalAddressbar)); gtk_builder_add_callback_symbol(builder.get(), "signalFormulabar", G_CALLBACK(signalFormulabar)); - gtk_builder_add_callback_symbol(builder.get(), "openLokDialog", G_CALLBACK(openLokDialog)); // find toolbar // Note: These buttons are not the part of GtvMainToolbar diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx index 521c49ea3eb2..fe7d33210ce1 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx @@ -290,42 +290,6 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ ) } } -static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata) -{ - GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(userdata); - g_info("deleteLokDialog"); - 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; -} - -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)); - // Set the width, height of the dialog to something large enough to be able - // to render any dialog - GtkWidget* pDialog = gtv_lok_dialog_new(LOK_DOC_VIEW(window->lokdocview), pDialogId, 1024, 768); - 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)); -} - void changeZoom( GtkWidget* pButton, gpointer /* pItem */ ) { static const float fZooms[] = { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0 }; diff --git a/libreofficekit/qa/gtktiledviewer/gtv.ui b/libreofficekit/qa/gtktiledviewer/gtv.ui index 7030ecaead5b..c8699b33cd5e 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv.ui +++ b/libreofficekit/qa/gtktiledviewer/gtv.ui @@ -452,7 +452,6 @@ <object class="GtkComboBoxText" id="combo_dialogselector"> <property name="visible">True</property> <property name="can_focus">False</property> - <signal name="changed" handler="openLokDialog" swapped="no"/> </object> </child> </object> |