native gtk3 message dialogs

Caolán McNamara caolanm at redhat.com
Thu Mar 1 11:24:55 UTC 2018


I've converted our Info/Query/Warning/Error message boxes to the scheme
I demoed at the last LibreOffice conference and FOSDEM that makes it
possible to have our dialogs be native gtk3 dialogs when our backend is
gtk3. When the backend is not gtk3 they remain as the vcl widgetery.

changes of use look like, from...

ScopedVclPtrInstance<QueryBox> xBox(
  pWindow, MessBoxStyle::OkCancel, "Message");
xBox->Execute();

to...

std::unique_ptr<weld::MessageDialog> xBox(
  Application::CreateMessageDialog(pParent,
  VclMessageType::Question, VclButtonsType::OkCancel,
  "Message");
xBox->run();

The old pParent argument was a vcl::Window, the new pParent argument is
now a weld::Window. You get a weld::Window from a vcl::Window with
Window::GetFrameWeld()

Where the message dialogs were loaded from .ui files, the loader in the
gtk3 case is gtk's builtin gtkbuilder and the translations are sucked
out of our .mo gettext format translations by the native gtk3 gettext
support. In the non-gtk3 case its "as it was", i.e. our own .ui loader
backed by vcl widgets and translations coming from our boost::gettext
based translation infrastructure.

FWIW: a weld::Widget is approximately equivalent to a
vcl::Window/GtkWidget, while a weld::Window is equivalent to
vcl::SystemWindow/GtkWindow.

Numbers:
89 message dialog are loaded from .ui files
474 message dialogs are directly instantiated


More information about the LibreOffice mailing list