From 9b43115151f3f7a34377ad027450fd1afbb5f738 Mon Sep 17 00:00:00 2001 From: Caolán McNamara <caolanm@redhat.com> Date: Fri, 31 Jan 2020 17:49:56 +0000 Subject: support arbitrary widgets in toolbars via children of GtkToolItem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6dcc146ba3a55f263f71e29a17b5e75de2bbe130 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87784 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> --- vcl/source/window/builder.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'vcl') diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 400073bfda8a..154eaaccd974 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1782,6 +1782,8 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & if (bIsPlaceHolder || name == "GtkTreeSelection") return nullptr; + ToolBox *pToolBox = (pParent && pParent->GetType() == WindowType::TOOLBOX) ? static_cast<ToolBox*>(pParent) : nullptr; + extractButtonImage(id, rMap, name == "GtkRadioButton"); VclPtr<vcl::Window> xWindow; @@ -2316,9 +2318,8 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & return nullptr; } else if (name == "GtkToolButton" || name == "GtkMenuToolButton" || - name == "GtkToggleToolButton" || name == "GtkRadioToolButton") + name == "GtkToggleToolButton" || name == "GtkRadioToolButton" || name == "GtkToolItem") { - ToolBox *pToolBox = dynamic_cast<ToolBox*>(pParent); if (pToolBox) { OUString aCommand(extractActionName(rMap)); @@ -2366,7 +2367,6 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & } else if (name == "GtkSeparatorToolItem") { - ToolBox *pToolBox = dynamic_cast<ToolBox*>(pParent); if (pToolBox) { pToolBox->InsertSeparator(); @@ -2407,6 +2407,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & } } } + SAL_INFO_IF(!xWindow, "vcl.layout", "probably need to implement " << name << " or add a make" << name << " function"); if (xWindow) { @@ -2422,6 +2423,13 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()); m_aChildren.emplace_back(id, xWindow, bVertical); + + // if the parent was a toolbox set it as an itemwindow for the latest itemid + if (pToolBox) + { + pToolBox->SetItemWindow(m_pParserState->m_nLastToolbarId, xWindow); + pToolBox->SetItemExpand(m_pParserState->m_nLastToolbarId, true); + } } return xWindow; } -- cgit