summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-12-14 20:28:39 +0530
committerJan Holesovsky <kendy@collabora.com>2017-12-15 11:02:01 +0100
commit4efd08f57e0d0a68f9c9786aa5f4729c42b77e26 (patch)
treef2d97057883d6e7129710a0b19c990beb7561cb0
parent915d27cd6654208d55373f52b06c411865b106b2 (diff)
lokdialog: If we already have the title, emit it during creation
Some dialogs load the UI before we "Execute()" the dialog, or before the dialog fires the InitShow event. In those cases, the title event has already been fired and won't be fired after dialog is created. Make sure that we send the title for such dialogs. While at it, remove the superfluous std::make_pair calls to emplace_back. And consistently use emplace_back everywhere, not push_back Change-Id: Ib66238298ad9b0dc85bd269aff37aeadf1fc82e4 Reviewed-on: https://gerrit.libreoffice.org/46461 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx4
-rw-r--r--sfx2/source/dialog/basedlgs.cxx18
-rw-r--r--sfx2/source/dialog/tabdlg.cxx6
-rw-r--r--vcl/source/window/dialog.cxx4
-rw-r--r--vcl/source/window/floatwin.cxx10
5 files changed, 27 insertions, 15 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 8fe9c5074951..73ee25d852ab 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -315,6 +315,7 @@ void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpoint
{
const std::string aType = aRoot.get<std::string>("type");
const std::string aSize = aRoot.get<std::string>("size");
+ const std::string aTitle = aRoot.get<std::string>("title", "");
std::vector<int> aSizePoints = GtvHelpers::split<int>(aSize, ", ", 2);
if (aType == "dialog")
@@ -326,6 +327,9 @@ void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpoint
g_signal_connect(pDialog, "destroy", G_CALLBACK(destroyLokDialog), window);
g_signal_connect(pDialog, "delete-event", G_CALLBACK(deleteLokDialog), window);
+ if (!aTitle.empty())
+ gtk_window_set_title(GTK_WINDOW(pDialog), aTitle.c_str());
+
gtk_window_set_resizable(GTK_WINDOW(pDialog), false);
gtk_widget_show_all(GTK_WIDGET(pDialog));
gtk_window_present(GTK_WINDOW(pDialog));
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 77486632c91d..710afd49b565 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -184,8 +184,10 @@ short SfxModalDialog::Execute()
SetLOKNotifier(pViewShell);
const Size aSize = GetOptimalSize();
std::vector<vcl::LOKPayloadItem> aItems;
- aItems.emplace_back(std::make_pair("type", "dialog"));
- aItems.emplace_back(std::make_pair("size", aSize.toString()));
+ aItems.emplace_back("type", "dialog");
+ aItems.emplace_back("size", aSize.toString());
+ if (!GetText().isEmpty())
+ aItems.emplace_back("title", GetText().toUtf8());
pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
}
@@ -223,8 +225,10 @@ void SfxModalDialog::StateChanged( StateChangedType nType )
SetLOKNotifier(SfxViewShell::Current());
const Size aSize = GetOptimalSize();
std::vector<vcl::LOKPayloadItem> aItems;
- aItems.emplace_back(std::make_pair("type", "dialog"));
- aItems.emplace_back(std::make_pair("size", aSize.toString()));
+ aItems.emplace_back("type", "dialog");
+ aItems.emplace_back("size", aSize.toString());
+ if (!GetText().isEmpty())
+ aItems.emplace_back("title", GetText().toUtf8());
SfxViewShell::Current()->notifyWindow(GetLOKWindowId(), "created", aItems);
}
else if (nType == StateChangedType::Visible &&
@@ -284,8 +288,10 @@ void SfxModelessDialog::StateChanged( StateChangedType nStateChange )
{
SetLOKNotifier(pViewShell);
std::vector<vcl::LOKPayloadItem> aItems;
- aItems.emplace_back(std::make_pair("type", "dialog"));
- aItems.emplace_back(std::make_pair("size", GetOptimalSize().toString()));
+ aItems.emplace_back("type", "dialog");
+ aItems.emplace_back("size", GetOptimalSize().toString());
+ if (!GetText().isEmpty())
+ aItems.emplace_back("title", GetText().toUtf8());
pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
}
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index db07a8ff380d..13033266ba47 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -526,8 +526,10 @@ short SfxTabDialog::Execute()
SetLOKNotifier(pViewShell);
const Size aSize = GetOptimalSize();
std::vector<vcl::LOKPayloadItem> aItems;
- aItems.emplace_back(std::make_pair("type", "dialog"));
- aItems.emplace_back(std::make_pair("size", aSize.toString()));
+ aItems.emplace_back("type", "dialog");
+ aItems.emplace_back("size", aSize.toString());
+ if (!GetText().isEmpty())
+ aItems.emplace_back("title", GetText().toUtf8());
pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
}
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 77cb242f22db..8c352218d798 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -697,7 +697,7 @@ void Dialog::StateChanged( StateChangedType nType )
if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
{
std::vector<vcl::LOKPayloadItem> aPayload;
- aPayload.push_back(std::make_pair(OString("title"), GetText().toUtf8()));
+ aPayload.emplace_back("title", GetText().toUtf8());
pNotifier->notifyWindow(GetLOKWindowId(), "title_changed", aPayload);
}
}
@@ -1212,7 +1212,7 @@ void Dialog::Resize()
if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
{
std::vector<vcl::LOKPayloadItem> aItems;
- aItems.emplace_back(std::make_pair("size", GetOptimalSize().toString()));
+ aItems.emplace_back("size", GetOptimalSize().toString());
pNotifier->notifyWindow(GetLOKWindowId(), "size_changed", aItems);
}
}
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index e1b7d76638fe..7a03108495b1 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -619,16 +619,16 @@ void FloatingWindow::StateChanged( StateChangedType nType )
// we are a toplevel window, let's so far pretend to be a
// dialog - but maybe we'll need a separate type for this
// later
- aItems.emplace_back(std::make_pair("type", "dialog"));
+ aItems.emplace_back("type", "dialog");
}
else
{
SetLOKNotifier(pParent->GetLOKNotifier());
- aItems.emplace_back(std::make_pair("type", "child"));
- aItems.emplace_back(std::make_pair("parentId", OString::number(pParent->GetLOKWindowId())));
+ aItems.emplace_back("type", "child");
+ aItems.emplace_back("parentId", OString::number(pParent->GetLOKWindowId()));
}
- aItems.emplace_back(std::make_pair("size", GetSizePixel().toString()));
- aItems.emplace_back(std::make_pair("position", mpImplData->maPos.toString()));
+ aItems.emplace_back("size", GetSizePixel().toString());
+ aItems.emplace_back("position", mpImplData->maPos.toString());
GetLOKNotifier()->notifyWindow(GetLOKWindowId(), "created", aItems);
}
else if (!IsVisible() && nType == StateChangedType::Visible)