Kaydet (Commit) a0f36b45 authored tarafından Pranav Kant's avatar Pranav Kant

lokdialog: Emit dialog close callback upon dialog close

Change-Id: I4ccef76cc3b2926dd8916f825671bb732e101027
üst 3ebaaebf
...@@ -291,8 +291,8 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint ...@@ -291,8 +291,8 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
//std::string aDialogId = aRoot.get<std::string>("dialogId"); //std::string aDialogId = aRoot.get<std::string>("dialogId");
std::string aAction = aRoot.get<std::string>("action"); std::string aAction = aRoot.get<std::string>("action");
// we only understand 'invalidate' as of now // we only understand 'invalidate' and 'close' as of now
if (aAction != "invalidate") if (aAction != "invalidate" && aAction != "close")
return; return;
// temporary hack to invalidate all open dialogs // temporary hack to invalidate all open dialogs
...@@ -300,43 +300,48 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint ...@@ -300,43 +300,48 @@ void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpoint
GList* pIt = nullptr; GList* pIt = nullptr;
for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next) 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) void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, gpointer)
{ {
GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView))); GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
std::stringstream aStream(pPayload); std::stringstream aStream(pPayload);
boost::property_tree::ptree aRoot; boost::property_tree::ptree aRoot;
boost::property_tree::read_json(aStream, aRoot); boost::property_tree::read_json(aStream, aRoot);
//std::string aDialogId = aRoot.get<std::string>("dialogId"); //std::string aDialogId = aRoot.get<std::string>("dialogId");
std::string aAction = aRoot.get<std::string>("action"); std::string aAction = aRoot.get<std::string>("action");
std::string aPos = aRoot.get<std::string>("position"); std::string aPos = aRoot.get<std::string>("position");
gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2); gchar** ppCoordinates = g_strsplit(aPos.c_str(), ", ", 2);
gchar** ppCoordinate = ppCoordinates; gchar** ppCoordinate = ppCoordinates;
int nX = 0; int nX = 0;
int nY = 0; int nY = 0;
if (*ppCoordinate) if (*ppCoordinate)
nX = atoi(*ppCoordinate); nX = atoi(*ppCoordinate);
++ppCoordinate; ++ppCoordinate;
if (*ppCoordinate) if (*ppCoordinate)
nY = atoi(*ppCoordinate); nY = atoi(*ppCoordinate);
g_strfreev(ppCoordinates); g_strfreev(ppCoordinates);
// temporary hack to invalidate/close floating window of all opened dialogs // temporary hack to invalidate/close floating window of all opened dialogs
GList* pChildWins = gtv_application_window_get_all_child_windows(window); GList* pChildWins = gtv_application_window_get_all_child_windows(window);
GList* pIt = nullptr; GList* pIt = nullptr;
for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next) for (pIt = pChildWins; pIt != nullptr; pIt = pIt->next)
{ {
if (aAction == "invalidate") if (aAction == "invalidate")
gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY); gtv_lok_dialog_child_invalidate(GTV_LOK_DIALOG(pIt->data), nX, nY);
else if (aAction == "close") else if (aAction == "close")
gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data)); gtv_lok_dialog_child_close(GTV_LOK_DIALOG(pIt->data));
} }
} }
gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/) gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/)
......
...@@ -293,6 +293,16 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ ) ...@@ -293,6 +293,16 @@ void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ )
static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata) static gboolean deleteLokDialog(GtkWidget* pWidget, GdkEvent* /*event*/, gpointer userdata)
{ {
GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(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)); gtv_application_window_unregister_child_window(window, GTK_WINDOW(pWidget));
return FALSE; return FALSE;
...@@ -304,9 +314,11 @@ void openLokDialog( GtkWidget* pSelector, gpointer /*pItem*/ ) ...@@ -304,9 +314,11 @@ void openLokDialog( GtkWidget* pSelector, gpointer /*pItem*/ )
gchar* pDialogId = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(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); GtkWidget* pDialog = gtv_lok_dialog_new(LOK_DOC_VIEW(window->lokdocview), pDialogId);
gtv_application_window_register_child_window(window, GTK_WINDOW(pDialog)); 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_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window);
g_free(pDialogId); g_free(pDialogId);
g_info("openLokDialog");
gtk_window_set_resizable(GTK_WINDOW(pDialog), false); gtk_window_set_resizable(GTK_WINDOW(pDialog), false);
gtk_widget_show_all(GTK_WIDGET(pDialog)); gtk_widget_show_all(GTK_WIDGET(pDialog));
gtk_window_present(GTK_WINDOW(pDialog)); gtk_window_present(GTK_WINDOW(pDialog));
......
...@@ -588,6 +588,11 @@ void Dialog::dispose() ...@@ -588,6 +588,11 @@ void Dialog::dispose()
xEventBroadcaster->documentEventOccured(aObject); xEventBroadcaster->documentEventOccured(aObject);
UITestLogger::getInstance().log("DialogClosed"); UITestLogger::getInstance().log("DialogClosed");
if (comphelper::LibreOfficeKit::isActive() && mpDialogRenderable)
{
mpDialogRenderable->notifyDialog(maID, "close");
}
SystemWindow::dispose(); SystemWindow::dispose();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment