include/vcl/weld.hxx | 5 sfx2/source/appl/sfxhelp.cxx | 34 ++---- vcl/source/app/salvtables.cxx | 236 ++++++++++++++++++++++++------------------ vcl/unx/gtk3/gtk3gtkinst.cxx | 225 +++++++++++++++++++++++----------------- 4 files changed, 292 insertions(+), 208 deletions(-)
New commits: commit 77a0cb2839c7770346bf97a273a36715a6cc0be4 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Feb 18 13:50:15 2019 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Feb 18 18:20:26 2019 +0100 Resolves: tdf#122355 search help for active notebook page before checking for the dialog, to get more specific help results. Change-Id: I2d6128fa39d3f7ebf15e194354307dd924590009 Reviewed-on: https://gerrit.libreoffice.org/67973 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 4fb71ca77bf1..dcbf59cd5453 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -171,6 +171,11 @@ public: virtual Container* weld_parent() const = 0; + //iterate upwards through the hierarchy sarting at this widgets parent, + //calling func with their helpid until func returns true or we run out of + //parents + virtual void help_hierarchy_foreach(const std::function<bool(const OString&)>& func) = 0; + virtual ~Widget() {} }; diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index ce484741909d..80d521b39a47 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -1231,26 +1231,22 @@ bool SfxHelp::Start_Impl(const OUString& rURL, weld::Widget* pWidget, const OUSt if ( impl_hasHelpInstalled() && pWidget && SfxContentHelper::IsHelpErrorDocument( aHelpURL ) ) { - // no help found -> try with parent help id. - std::unique_ptr<weld::Widget> xParent(pWidget->weld_parent()); - while (xParent) + bool bUseFinalFallback = true; + // no help found -> try ids of parents. + pWidget->help_hierarchy_foreach([&aHelpModuleName, &aHelpURL, &bUseFinalFallback](const OString& rHelpId){ + if (rHelpId.isEmpty()) + return false; + aHelpURL = CreateHelpURL( OStringToOUString(rHelpId, RTL_TEXTENCODING_UTF8), aHelpModuleName); + bool bFinished = !SfxContentHelper::IsHelpErrorDocument(aHelpURL); + if (bFinished) + bUseFinalFallback = false; + return bFinished; + }); + + if (bUseFinalFallback) { - OString aHelpId = xParent->get_help_id(); - aHelpURL = CreateHelpURL( OStringToOUString(aHelpId, RTL_TEXTENCODING_UTF8), aHelpModuleName ); - - if ( !SfxContentHelper::IsHelpErrorDocument( aHelpURL ) ) - { - break; - } - else - { - xParent.reset(xParent->weld_parent()); - if (!xParent) - { - // create help url of start page ( helpid == 0 -> start page) - aHelpURL = CreateHelpURL( OUString(), aHelpModuleName ); - } - } + // create help url of start page ( helpid == 0 -> start page) + aHelpURL = CreateHelpURL( OUString(), aHelpModuleName ); } } break; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 55a6e36077c3..c7ca128fd818 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -230,11 +230,15 @@ SalMenuItem::~SalMenuItem() { } +class SalInstanceBuilder; + class SalInstanceWidget : public virtual weld::Widget { -private: +protected: VclPtr<vcl::Window> m_xWidget; + SalInstanceBuilder* m_pBuilder; +private: DECL_LINK(EventListener, VclWindowEvent&, void); DECL_LINK(KeyEventListener, VclWindowEvent&, bool); @@ -269,8 +273,9 @@ protected: virtual bool HandleKeyEventListener(VclWindowEvent& rEvent); public: - SalInstanceWidget(vcl::Window* pWidget, bool bTakeOwnership) + SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : m_xWidget(pWidget) + , m_pBuilder(pBuilder) , m_bTakeOwnership(bTakeOwnership) , m_bEventListener(false) , m_bKeyEventListener(false) @@ -578,6 +583,8 @@ public: --m_nBlockNotify; } + virtual void help_hierarchy_foreach(const std::function<bool(const OString&)>& func) override; + SystemWindow* getSystemWindow() { return m_xWidget->GetSystemWindow(); @@ -736,8 +743,8 @@ class SalInstanceContainer : public SalInstanceWidget, public virtual weld::Cont private: VclPtr<vcl::Window> m_xContainer; public: - SalInstanceContainer(vcl::Window* pContainer, bool bTakeOwnership) - : SalInstanceWidget(pContainer, bTakeOwnership) + SalInstanceContainer(vcl::Window* pContainer, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pContainer, pBuilder, bTakeOwnership) , m_xContainer(pContainer) { } @@ -754,7 +761,7 @@ public: weld::Container* SalInstanceWidget::weld_parent() const { vcl::Window* pParent = m_xWidget->GetParent(); - return pParent ? new SalInstanceContainer(pParent, false) : nullptr; + return pParent ? new SalInstanceContainer(pParent, m_pBuilder, false) : nullptr; } class SalInstanceWindow : public SalInstanceContainer, public virtual weld::Window @@ -779,8 +786,8 @@ private: } public: - SalInstanceWindow(vcl::Window* pWindow, bool bTakeOwnership) - : SalInstanceContainer(pWindow, bTakeOwnership) + SalInstanceWindow(vcl::Window* pWindow, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pWindow, pBuilder, bTakeOwnership) , m_xWindow(pWindow) { override_child_help(m_xWindow); @@ -810,7 +817,7 @@ public: break; sHelpId = pWidget->GetHelpId(); } - std::unique_ptr<weld::Widget> xTemp(pWidget != m_xWindow ? new SalInstanceWidget(pWidget, false) : nullptr); + std::unique_ptr<weld::Widget> xTemp(pWidget != m_xWindow ? new SalInstanceWidget(pWidget, m_pBuilder, false) : nullptr); weld::Widget* pSource = xTemp ? xTemp.get() : this; bool bRunNormalHelpRequest = !m_aHelpRequestHdl.IsSet() || m_aHelpRequestHdl.Call(*pSource); Help* pHelp = bRunNormalHelpRequest ? Application::GetHelp() : nullptr; @@ -923,8 +930,8 @@ private: VclPtr<::Dialog> m_xDialog; public: - SalInstanceDialog(::Dialog* pDialog, bool bTakeOwnership) - : SalInstanceWindow(pDialog, bTakeOwnership) + SalInstanceDialog(::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWindow(pDialog, pBuilder, bTakeOwnership) , m_xDialog(pDialog) { } @@ -982,7 +989,7 @@ public: virtual Container* weld_content_area() override { - return new SalInstanceContainer(m_xDialog->get_content_area(), false); + return new SalInstanceContainer(m_xDialog->get_content_area(), m_pBuilder, false); } }; @@ -991,8 +998,8 @@ class SalInstanceMessageDialog : public SalInstanceDialog, public virtual weld:: private: VclPtr<::MessageDialog> m_xMessageDialog; public: - SalInstanceMessageDialog(::MessageDialog* pDialog, bool bTakeOwnership) - : SalInstanceDialog(pDialog, bTakeOwnership) + SalInstanceMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceDialog(pDialog, pBuilder, bTakeOwnership) , m_xMessageDialog(pDialog) { } @@ -1019,7 +1026,7 @@ public: virtual Container* weld_message_area() override { - return new SalInstanceContainer(m_xMessageDialog->get_message_area(), false); + return new SalInstanceContainer(m_xMessageDialog->get_message_area(), m_pBuilder, false); } }; @@ -1028,8 +1035,8 @@ class SalInstanceFrame : public SalInstanceContainer, public virtual weld::Frame private: VclPtr<VclFrame> m_xFrame; public: - SalInstanceFrame(VclFrame* pFrame, bool bTakeOwnership) - : SalInstanceContainer(pFrame, bTakeOwnership) + SalInstanceFrame(VclFrame* pFrame, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pFrame, pBuilder, bTakeOwnership) , m_xFrame(pFrame) { } @@ -1057,8 +1064,8 @@ private: DECL_LINK(HscrollHdl, ScrollBar*, void); public: - SalInstanceScrolledWindow(VclScrolledWindow* pScrolledWindow, bool bTakeOwnership) - : SalInstanceContainer(pScrolledWindow, bTakeOwnership) + SalInstanceScrolledWindow(VclScrolledWindow* pScrolledWindow, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pScrolledWindow, pBuilder, bTakeOwnership) , m_xScrolledWindow(pScrolledWindow) , m_bUserManagedScrolling(false) { @@ -1263,8 +1270,8 @@ private: DECL_LINK(ActivatePageHdl, TabControl*, void); public: - SalInstanceNotebook(TabControl* pNotebook, bool bTakeOwnership) - : SalInstanceContainer(pNotebook, bTakeOwnership) + SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pNotebook, pBuilder, bTakeOwnership) , m_xNotebook(pNotebook) { m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceNotebook, ActivatePageHdl)); @@ -1292,7 +1299,7 @@ public: if (m_aPages.size() < nPageIndex + 1U) m_aPages.resize(nPageIndex + 1U); if (!m_aPages[nPageIndex]) - m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, false)); + m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false)); return m_aPages[nPageIndex].get(); } @@ -1367,8 +1374,8 @@ private: DECL_LINK(ClickHdl, ::Button*, void); public: - SalInstanceButton(::Button* pButton, bool bTakeOwnership) - : SalInstanceContainer(pButton, bTakeOwnership) + SalInstanceButton(::Button* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pButton, pBuilder, bTakeOwnership) , m_xButton(pButton) , m_aOldClickHdl(pButton->GetClickHdl()) { @@ -1436,7 +1443,7 @@ IMPL_LINK(SalInstanceButton, ClickHdl, ::Button*, pButton, void) weld::Button* SalInstanceDialog::get_widget_for_response(int nResponse) { PushButton* pButton = dynamic_cast<PushButton*>(m_xDialog->get_widget_for_response(nResponse)); - return pButton ? new SalInstanceButton(pButton, false) : nullptr; + return pButton ? new SalInstanceButton(pButton, nullptr, false) : nullptr; } class SalInstanceMenuButton : public SalInstanceButton, public virtual weld::MenuButton @@ -1448,8 +1455,8 @@ private: DECL_LINK(ActivateHdl, ::MenuButton*, void); public: - SalInstanceMenuButton(::MenuButton* pButton, bool bTakeOwnership) - : SalInstanceButton(pButton, bTakeOwnership) + SalInstanceMenuButton(::MenuButton* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceButton(pButton, pBuilder, bTakeOwnership) , m_xMenuButton(pButton) { m_xMenuButton->SetActivateHdl(LINK(this, SalInstanceMenuButton, ActivateHdl)); @@ -1549,8 +1556,8 @@ private: DECL_LINK(ClickHdl, FixedHyperlink&, void); public: - SalInstanceLinkButton(FixedHyperlink* pButton, bool bTakeOwnership) - : SalInstanceContainer(pButton, bTakeOwnership) + SalInstanceLinkButton(FixedHyperlink* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pButton, pBuilder, bTakeOwnership) , m_xButton(pButton) { m_xButton->SetClickHdl(LINK(this, SalInstanceLinkButton, ClickHdl)); @@ -1595,8 +1602,8 @@ private: DECL_LINK(ToggleHdl, ::RadioButton&, void); public: - SalInstanceRadioButton(::RadioButton* pButton, bool bTakeOwnership) - : SalInstanceButton(pButton, bTakeOwnership) + SalInstanceRadioButton(::RadioButton* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceButton(pButton, pBuilder, bTakeOwnership) , m_xRadioButton(pButton) { m_xRadioButton->SetToggleHdl(LINK(this, SalInstanceRadioButton, ToggleHdl)); @@ -1650,8 +1657,8 @@ private: DECL_LINK(ToggleListener, VclWindowEvent&, void); public: - SalInstanceToggleButton(PushButton* pButton, bool bTakeOwnership) - : SalInstanceButton(pButton, bTakeOwnership) + SalInstanceToggleButton(PushButton* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceButton(pButton, pBuilder, bTakeOwnership) , m_xToggleButton(pButton) { } @@ -1709,8 +1716,8 @@ private: DECL_LINK(ToggleHdl, CheckBox&, void); public: - SalInstanceCheckButton(CheckBox* pButton, bool bTakeOwnership) - : SalInstanceButton(pButton, bTakeOwnership) + SalInstanceCheckButton(CheckBox* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceButton(pButton, pBuilder, bTakeOwnership) , m_xCheckButton(pButton) { m_xCheckButton->SetToggleHdl(LINK(this, SalInstanceCheckButton, ToggleHdl)); @@ -1763,8 +1770,8 @@ private: DECL_LINK(SlideHdl, Slider*, void); public: - SalInstanceScale(Slider* pScale, bool bTakeOwnership) - : SalInstanceWidget(pScale, bTakeOwnership) + SalInstanceScale(Slider* pScale, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pScale, pBuilder, bTakeOwnership) , m_xScale(pScale) { m_xScale->SetSlideHdl(LINK(this, SalInstanceScale, SlideHdl)); @@ -1803,8 +1810,8 @@ private: VclPtr<::ProgressBar> m_xProgressBar; public: - SalInstanceProgressBar(::ProgressBar* pProgressBar, bool bTakeOwnership) - : SalInstanceWidget(pProgressBar, bTakeOwnership) + SalInstanceProgressBar(::ProgressBar* pProgressBar, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pProgressBar, pBuilder, bTakeOwnership) , m_xProgressBar(pProgressBar) { } @@ -1821,8 +1828,8 @@ private: VclPtr<FixedImage> m_xImage; public: - SalInstanceImage(FixedImage* pImage, bool bTakeOwnership) - : SalInstanceWidget(pImage, bTakeOwnership) + SalInstanceImage(FixedImage* pImage, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pImage, pBuilder, bTakeOwnership) , m_xImage(pImage) { } @@ -1842,8 +1849,8 @@ private: DECL_LINK(ActivateHdl, ::Calendar*, void); public: - SalInstanceCalendar(::Calendar* pCalendar, bool bTakeOwnership) - : SalInstanceWidget(pCalendar, bTakeOwnership) + SalInstanceCalendar(::Calendar* pCalendar, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pCalendar, pBuilder, bTakeOwnership) , m_xCalendar(pCalendar) { m_xCalendar->SetSelectHdl(LINK(this, SalInstanceCalendar, SelectHdl)); @@ -1918,8 +1925,8 @@ private: WeldTextFilter m_aTextFilter; public: - SalInstanceEntry(Edit* pEntry, bool bTakeOwnership) - : SalInstanceWidget(pEntry, bTakeOwnership) + SalInstanceEntry(Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pEntry, pBuilder, bTakeOwnership) , m_xEntry(pEntry) , m_aTextFilter(m_aInsertTextHdl) { @@ -2089,8 +2096,8 @@ private: DECL_LINK(ToggleHdl, SvLBoxButtonData*, void); DECL_LINK(VisibleRangeChangedHdl, SvTreeListBox*, void); public: - SalInstanceTreeView(SvTabListBox* pTreeView, bool bTakeOwnership) - : SalInstanceContainer(pTreeView, bTakeOwnership) + SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pTreeView, pBuilder, bTakeOwnership) , m_xTreeView(pTreeView) , m_aCheckButtonData(pTreeView, false) , m_aRadioButtonData(pTreeView, true) @@ -2866,8 +2873,8 @@ private: } public: - SalInstanceSpinButton(FormattedField* pButton, bool bTakeOwnership) - : SalInstanceEntry(pButton, bTakeOwnership) + SalInstanceSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceEntry(pButton, pBuilder, bTakeOwnership) , m_xButton(pButton) { m_xButton->SetThousandsSep(false); //off by default, MetricSpinButton enables it @@ -2983,8 +2990,8 @@ private: VclPtr<FormattedField> m_xButton; public: - SalInstanceFormattedSpinButton(FormattedField* pButton, bool bTakeOwnership) - : SalInstanceEntry(pButton, bTakeOwnership) + SalInstanceFormattedSpinButton(FormattedField* pButton, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceEntry(pButton, pBuilder, bTakeOwnership) , m_xButton(pButton) { // #i6278# allow more decimal places than the output format. As @@ -3037,8 +3044,8 @@ class SalInstanceLabel : public SalInstanceWidget, public virtual weld::Label private: VclPtr<FixedText> m_xLabel; public: - SalInstanceLabel(FixedText* pLabel, bool bTakeOwnership) - : SalInstanceWidget(pLabel, bTakeOwnership) + SalInstanceLabel(FixedText* pLabel, SalInstanceBuilder *pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pLabel, pBuilder, bTakeOwnership) , m_xLabel(pLabel) { } @@ -3067,8 +3074,8 @@ private: DECL_LINK(ChangeHdl, Edit&, void); public: - SalInstanceTextView(VclMultiLineEdit* pTextView, bool bTakeOwnership) - : SalInstanceContainer(pTextView, bTakeOwnership) + SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pTextView, pBuilder, bTakeOwnership) , m_xTextView(pTextView) { m_xTextView->SetModifyHdl(LINK(this, SalInstanceTextView, ChangeHdl)); @@ -3141,8 +3148,8 @@ private: DECL_LINK(ExpandedHdl, VclExpander&, void); public: - SalInstanceExpander(VclExpander* pExpander, bool bTakeOwnership) - : SalInstanceContainer(pExpander, bTakeOwnership) + SalInstanceExpander(VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pExpander, pBuilder, bTakeOwnership) , m_xExpander(pExpander) { m_xExpander->SetExpandedHdl(LINK(this, SalInstanceExpander, ExpandedHdl)); @@ -3204,9 +3211,9 @@ private: } public: - SalInstanceDrawingArea(VclDrawingArea* pDrawingArea, const a11yref& rAlly, + SalInstanceDrawingArea(VclDrawingArea* pDrawingArea, SalInstanceBuilder* pBuilder, const a11yref& rAlly, FactoryFunction pUITestFactoryFunction, void* pUserData, bool bTakeOwnership) - : SalInstanceWidget(pDrawingArea, bTakeOwnership) + : SalInstanceWidget(pDrawingArea, pBuilder, bTakeOwnership) , m_xDrawingArea(pDrawingArea) { m_xDrawingArea->SetAccessible(rAlly); @@ -3373,8 +3380,8 @@ protected: VclPtr<vcl_type> m_xComboBox; public: - SalInstanceComboBox(vcl_type* pComboBox, bool bTakeOwnership) - : SalInstanceContainer(pComboBox, bTakeOwnership) + SalInstanceComboBox(vcl_type* pComboBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pComboBox, pBuilder, bTakeOwnership) , m_xComboBox(pComboBox) { } @@ -3503,8 +3510,8 @@ private: DECL_LINK(SelectHdl, ListBox&, void); public: - SalInstanceComboBoxWithoutEdit(ListBox* pListBox, bool bTakeOwnership) - : SalInstanceComboBox<ListBox>(pListBox, bTakeOwnership) + SalInstanceComboBoxWithoutEdit(ListBox* pListBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceComboBox<ListBox>(pListBox, pBuilder, bTakeOwnership) { m_xComboBox->SetSelectHdl(LINK(this, SalInstanceComboBoxWithoutEdit, SelectHdl)); } @@ -3601,8 +3608,8 @@ private: DECL_LINK(EntryActivateHdl, Edit&, bool); WeldTextFilter m_aTextFilter; public: - SalInstanceComboBoxWithEdit(::ComboBox* pComboBox, bool bTakeOwnership) - : SalInstanceComboBox<::ComboBox>(pComboBox, bTakeOwnership) + SalInstanceComboBoxWithEdit(::ComboBox* pComboBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceComboBox<::ComboBox>(pComboBox, pBuilder, bTakeOwnership) , m_aTextFilter(m_aEntryInsertTextHdl) { m_xComboBox->SetModifyHdl(LINK(this, SalInstanceComboBoxWithEdit, ChangeHdl)); @@ -3715,9 +3722,10 @@ private: SalInstanceEntry* m_pEntry; SalInstanceTreeView* m_pTreeView; public: - SalInstanceEntryTreeView(vcl::Window *pContainer, bool bTakeOwnership, std::unique_ptr<weld::Entry> xEntry, std::unique_ptr<weld::TreeView> xTreeView) + SalInstanceEntryTreeView(vcl::Window *pContainer, SalInstanceBuilder* pBuilder, bool bTakeOwnership, + std::unique_ptr<weld::Entry> xEntry, std::unique_ptr<weld::TreeView> xTreeView) : EntryTreeView(std::move(xEntry), std::move(xTreeView)) - , SalInstanceContainer(pContainer, bTakeOwnership) + , SalInstanceContainer(pContainer, pBuilder, bTakeOwnership) , m_pEntry(dynamic_cast<SalInstanceEntry*>(m_xEntry.get())) , m_pTreeView(dynamic_cast<SalInstanceTreeView*>(m_xTreeView.get())) { @@ -3827,10 +3835,15 @@ public: { } + VclBuilder& get_builder() const + { + return *m_xBuilder; + } + virtual std::unique_ptr<weld::MessageDialog> weld_message_dialog(const OString &id, bool bTakeOwnership) override { MessageDialog* pMessageDialog = m_xBuilder->get<MessageDialog>(id); - std::unique_ptr<weld::MessageDialog> pRet(pMessageDialog ? new SalInstanceMessageDialog(pMessageDialog, false) : nullptr); + std::unique_ptr<weld::MessageDialog> pRet(pMessageDialog ? new SalInstanceMessageDialog(pMessageDialog, this, false) : nullptr); if (bTakeOwnership && pMessageDialog) { assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); @@ -3843,7 +3856,7 @@ public: virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString &id, bool bTakeOwnership) override { Dialog* pDialog = m_xBuilder->get<Dialog>(id); - std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, false) : nullptr); + std::unique_ptr<weld::Dialog> pRet(pDialog ? new SalInstanceDialog(pDialog, this, false) : nullptr); if (bTakeOwnership && pDialog) { assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); @@ -3856,25 +3869,25 @@ public: virtual std::unique_ptr<weld::Window> weld_window(const OString &id, bool bTakeOwnership) override { SystemWindow* pWindow = m_xBuilder->get<SystemWindow>(id); - return pWindow ? std::make_unique<SalInstanceWindow>(pWindow, bTakeOwnership) : nullptr; + return pWindow ? std::make_unique<SalInstanceWindow>(pWindow, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Widget> weld_widget(const OString &id, bool bTakeOwnership) override { vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id); - return pWidget ? std::make_unique<SalInstanceWidget>(pWidget, bTakeOwnership) : nullptr; + return pWidget ? std::make_unique<SalInstanceWidget>(pWidget, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Container> weld_container(const OString &id, bool bTakeOwnership) override { vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(id); - return pContainer ? std::make_unique<SalInstanceContainer>(pContainer, bTakeOwnership) : nullptr; + return pContainer ? std::make_unique<SalInstanceContainer>(pContainer, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Frame> weld_frame(const OString &id, bool bTakeOwnership) override { VclFrame* pFrame = m_xBuilder->get<VclFrame>(id); - std::unique_ptr<weld::Frame> pRet(pFrame ? new SalInstanceFrame(pFrame, false) : nullptr); + std::unique_ptr<weld::Frame> pRet(pFrame ? new SalInstanceFrame(pFrame, this, false) : nullptr); if (bTakeOwnership && pFrame) { assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed"); @@ -3887,85 +3900,85 @@ public: virtual std::unique_ptr<weld::ScrolledWindow> weld_scrolled_window(const OString &id, bool bTakeOwnership) override { VclScrolledWindow* pScrolledWindow = m_xBuilder->get<VclScrolledWindow>(id); - return pScrolledWindow ? std::make_unique<SalInstanceScrolledWindow>(pScrolledWindow, bTakeOwnership) : nullptr; + return pScrolledWindow ? std::make_unique<SalInstanceScrolledWindow>(pScrolledWindow, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString &id, bool bTakeOwnership) override { TabControl* pNotebook = m_xBuilder->get<TabControl>(id); - return pNotebook ? std::make_unique<SalInstanceNotebook>(pNotebook, bTakeOwnership) : nullptr; + return pNotebook ? std::make_unique<SalInstanceNotebook>(pNotebook, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Button> weld_button(const OString &id, bool bTakeOwnership) override { Button* pButton = m_xBuilder->get<Button>(id); - return pButton ? std::make_unique<SalInstanceButton>(pButton, bTakeOwnership) : nullptr; + return pButton ? std::make_unique<SalInstanceButton>(pButton, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OString &id, bool bTakeOwnership) override { MenuButton* pButton = m_xBuilder->get<MenuButton>(id); - return pButton ? std::make_unique<SalInstanceMenuButton>(pButton, bTakeOwnership) : nullptr; + return pButton ? std::make_unique<SalInstanceMenuButton>(pButton, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::LinkButton> weld_link_button(const OString &id, bool bTakeOwnership) override { FixedHyperlink* pButton = m_xBuilder->get<FixedHyperlink>(id); - return pButton ? std::make_unique<SalInstanceLinkButton>(pButton, bTakeOwnership) : nullptr; + return pButton ? std::make_unique<SalInstanceLinkButton>(pButton, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::ToggleButton> weld_toggle_button(const OString &id, bool bTakeOwnership) override { PushButton* pToggleButton = m_xBuilder->get<PushButton>(id); - return pToggleButton ? std::make_unique<SalInstanceToggleButton>(pToggleButton, bTakeOwnership) : nullptr; + return pToggleButton ? std::make_unique<SalInstanceToggleButton>(pToggleButton, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OString &id, bool bTakeOwnership) override { RadioButton* pRadioButton = m_xBuilder->get<RadioButton>(id); - return pRadioButton ? std::make_unique<SalInstanceRadioButton>(pRadioButton, bTakeOwnership) : nullptr; + return pRadioButton ? std::make_unique<SalInstanceRadioButton>(pRadioButton, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::CheckButton> weld_check_button(const OString &id, bool bTakeOwnership) override { CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id); - return pCheckButton ? std::make_unique<SalInstanceCheckButton>(pCheckButton, bTakeOwnership) : nullptr; + return pCheckButton ? std::make_unique<SalInstanceCheckButton>(pCheckButton, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Scale> weld_scale(const OString &id, bool bTakeOwnership) override { Slider* pSlider = m_xBuilder->get<Slider>(id); - return pSlider ? std::make_unique<SalInstanceScale>(pSlider, bTakeOwnership) : nullptr; + return pSlider ? std::make_unique<SalInstanceScale>(pSlider, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::ProgressBar> weld_progress_bar(const OString &id, bool bTakeOwnership) override { ::ProgressBar* pProgress = m_xBuilder->get<::ProgressBar>(id); - return pProgress ? std::make_unique<SalInstanceProgressBar>(pProgress, bTakeOwnership) : nullptr; + return pProgress ? std::make_unique<SalInstanceProgressBar>(pProgress, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Image> weld_image(const OString &id, bool bTakeOwnership) override { FixedImage* pImage = m_xBuilder->get<FixedImage>(id); - return pImage ? std::make_unique<SalInstanceImage>(pImage, bTakeOwnership) : nullptr; + return pImage ? std::make_unique<SalInstanceImage>(pImage, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Calendar> weld_calendar(const OString &id, bool bTakeOwnership) override { Calendar* pCalendar = m_xBuilder->get<Calendar>(id); - return pCalendar ? std::make_unique<SalInstanceCalendar>(pCalendar, bTakeOwnership) : nullptr; + return pCalendar ? std::make_unique<SalInstanceCalendar>(pCalendar, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Entry> weld_entry(const OString &id, bool bTakeOwnership) override { Edit* pEntry = m_xBuilder->get<Edit>(id); - return pEntry ? std::make_unique<SalInstanceEntry>(pEntry, bTakeOwnership) : nullptr; + return pEntry ? std::make_unique<SalInstanceEntry>(pEntry, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OString &id, bool bTakeOwnership) override { FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); - return pSpinButton ? std::make_unique<SalInstanceSpinButton>(pSpinButton, bTakeOwnership) : nullptr; + return pSpinButton ? std::make_unique<SalInstanceSpinButton>(pSpinButton, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::MetricSpinButton> weld_metric_spin_button(const OString& id, FieldUnit eUnit, @@ -3984,7 +3997,7 @@ public: bool bTakeOwnership) override { FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); - return pSpinButton ? std::make_unique<SalInstanceFormattedSpinButton>(pSpinButton, bTakeOwnership) : nullptr; + return pSpinButton ? std::make_unique<SalInstanceFormattedSpinButton>(pSpinButton, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::TimeSpinButton> weld_time_spin_button(const OString& id, TimeFieldFormat eFormat, @@ -4001,47 +4014,48 @@ public: vcl::Window* pWidget = m_xBuilder->get<vcl::Window>(id); ::ComboBox* pComboBox = dynamic_cast<::ComboBox*>(pWidget); if (pComboBox) - return std::make_unique<SalInstanceComboBoxWithEdit>(pComboBox, bTakeOwnership); + return std::make_unique<SalInstanceComboBoxWithEdit>(pComboBox, this, bTakeOwnership); ListBox* pListBox = dynamic_cast<ListBox*>(pWidget); - return pListBox ? std::make_unique<SalInstanceComboBoxWithoutEdit>(pListBox, bTakeOwnership) : nullptr; + return pListBox ? std::make_unique<SalInstanceComboBoxWithoutEdit>(pListBox, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::EntryTreeView> weld_entry_tree_view(const OString& containerid, const OString& entryid, const OString& treeviewid, bool bTakeOwnership) override { vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(containerid); - return pContainer ? std::make_unique<SalInstanceEntryTreeView>(pContainer, bTakeOwnership, weld_entry(entryid, bTakeOwnership), - weld_tree_view(treeviewid, bTakeOwnership)) : nullptr; + return pContainer ? std::make_unique<SalInstanceEntryTreeView>(pContainer, this, bTakeOwnership, + weld_entry(entryid, bTakeOwnership), + weld_tree_view(treeviewid, bTakeOwnership)) : nullptr; } virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString &id, bool bTakeOwnership) override { SvTabListBox* pTreeView = m_xBuilder->get<SvTabListBox>(id); - return pTreeView ? std::make_unique<SalInstanceTreeView>(pTreeView, bTakeOwnership) : nullptr; + return pTreeView ? std::make_unique<SalInstanceTreeView>(pTreeView, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Label> weld_label(const OString &id, bool bTakeOwnership) override { FixedText* pLabel = m_xBuilder->get<FixedText>(id); - return pLabel ? std::make_unique<SalInstanceLabel>(pLabel, bTakeOwnership) : nullptr; + return pLabel ? std::make_unique<SalInstanceLabel>(pLabel, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::TextView> weld_text_view(const OString &id, bool bTakeOwnership) override { VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id); - return pTextView ? std::make_unique<SalInstanceTextView>(pTextView, bTakeOwnership) : nullptr; + return pTextView ? std::make_unique<SalInstanceTextView>(pTextView, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Expander> weld_expander(const OString &id, bool bTakeOwnership) override { VclExpander* pExpander = m_xBuilder->get<VclExpander>(id); - return pExpander ? std::make_unique<SalInstanceExpander>(pExpander, bTakeOwnership) : nullptr; + return pExpander ? std::make_unique<SalInstanceExpander>(pExpander, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::DrawingArea> weld_drawing_area(const OString &id, const a11yref& rA11yImpl, FactoryFunction pUITestFactoryFunction, void* pUserData, bool bTakeOwnership) override { VclDrawingArea* pDrawingArea = m_xBuilder->get<VclDrawingArea>(id); - return pDrawingArea ? std::make_unique<SalInstanceDrawingArea>(pDrawingArea, rA11yImpl, + return pDrawingArea ? std::make_unique<SalInstanceDrawingArea>(pDrawingArea, this, rA11yImpl, pUITestFactoryFunction, pUserData, bTakeOwnership) : nullptr; } @@ -4085,12 +4099,38 @@ weld::Builder* Application::CreateInterimBuilder(weld::Widget* pParent, const OU return Application::CreateInterimBuilder(pParentWidget, rUIFile); } +//iterate upwards through the hierarchy from this widgets through its parents +//calling func with their helpid until func returns true or we run out of parents +void SalInstanceWidget::help_hierarchy_foreach(const std::function<bool(const OString&)>& func) +{ + vcl::Window* pParent = m_xWidget; + while ((pParent = pParent->GetParent())) + { + if (m_pBuilder && pParent->IsDialog()) + { + // tdf#122355 During help fallback, before we ask a dialog for its help + // see if it has a TabControl and ask the active tab of that for help + TabControl *pCtrl = m_pBuilder->get_builder().get<TabControl>("tabcontrol"); + TabPage* pTabPage = pCtrl ? pCtrl->GetTabPage(pCtrl->GetCurPageId()) : nullptr; + vcl::Window *pTabChild = pTabPage ? pTabPage->GetWindow(GetWindowType::FirstChild) : nullptr; + pTabChild = pTabChild ? pTabChild->GetWindow(GetWindowType::FirstChild) : nullptr; + if (pTabChild) + { + if (func(pTabChild->GetHelpId())) + return; + } + } + if (func(pParent->GetHelpId())) + return; + } +} + weld::MessageDialog* SalInstance::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonsType, const OUString& rPrimaryMessage) { SalInstanceWidget* pParentInstance = dynamic_cast<SalInstanceWidget*>(pParent); SystemWindow* pParentWidget = pParentInstance ? pParentInstance->getSystemWindow() : nullptr; VclPtrInstance<MessageDialog> xMessageDialog(pParentWidget, rPrimaryMessage, eMessageType, eButtonsType); - return new SalInstanceMessageDialog(xMessageDialog, true); + return new SalInstanceMessageDialog(xMessageDialog, nullptr, true); } weld::Window* SalInstance::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) @@ -4112,7 +4152,7 @@ weld::Window* SalFrame::GetFrameWeld() const pWindow = pWindow ? pWindow->ImplGetWindow() : nullptr; assert(!pWindow || (pWindow->IsSystemWindow() || pWindow->IsDockingWindow())); if (pWindow) - m_xFrameWeld.reset(new SalInstanceWindow(pWindow, false)); + m_xFrameWeld.reset(new SalInstanceWindow(pWindow, nullptr, false)); } return m_xFrameWeld.get(); } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index baf0d649cc9a..84295d62f64d 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1223,6 +1223,7 @@ class GtkInstanceWidget : public virtual weld::Widget { protected: GtkWidget* m_pWidget; + GtkInstanceBuilder* m_pBuilder; static void signalFocusIn(GtkWidget*, GdkEvent*, gpointer widget) { @@ -1278,8 +1279,9 @@ private: } public: - GtkInstanceWidget(GtkWidget* pWidget, bool bTakeOwnership) + GtkInstanceWidget(GtkWidget* pWidget, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : m_pWidget(pWidget) + , m_pBuilder(pBuilder) , m_bTakeOwnership(bTakeOwnership) , m_bFrozen(false) , m_nFocusInSignalId(0) @@ -1672,6 +1674,8 @@ public: if (m_nFocusInSignalId) g_signal_handler_unblock(m_pWidget, m_nFocusInSignalId); } + + virtual void help_hierarchy_foreach(const std::function<bool(const OString&)>& func) override; }; namespace @@ -2009,8 +2013,8 @@ class GtkInstanceContainer : public GtkInstanceWidget, public virtual weld::Cont private: GtkContainer* m_pContainer; public: - GtkInstanceContainer(GtkContainer* pContainer, bool bTakeOwnership) - : GtkInstanceWidget(GTK_WIDGET(pContainer), bTakeOwnership) + GtkInstanceContainer(GtkContainer* pContainer, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pContainer), pBuilder, bTakeOwnership) , m_pContainer(pContainer) { } @@ -2036,7 +2040,7 @@ public: weld::Container* GtkInstanceWidget::weld_parent() const { GtkWidget* pParent = gtk_widget_get_parent(m_pWidget); - return pParent ? new GtkInstanceContainer(GTK_CONTAINER(pParent), false) : nullptr; + return pParent ? new GtkInstanceContainer(GTK_CONTAINER(pParent), m_pBuilder, false) : nullptr; } class GtkInstanceWindow : public GtkInstanceContainer, public virtual weld::Window @@ -2053,8 +2057,8 @@ private: protected: void help(); public: - GtkInstanceWindow(GtkWindow* pWindow, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pWindow), bTakeOwnership) + GtkInstanceWindow(GtkWindow* pWindow, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pWindow), pBuilder, bTakeOwnership) , m_pWindow(pWindow) { //hook up F1 to show help @@ -2452,8 +2456,8 @@ private: } public: - GtkInstanceDialog(GtkDialog* pDialog, bool bTakeOwnership) - : GtkInstanceWindow(GTK_WINDOW(pDialog), bTakeOwnership) + GtkInstanceDialog(GtkDialog* pDialog, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceWindow(GTK_WINDOW(pDialog), pBuilder, bTakeOwnership) , m_pDialog(pDialog) , m_aDialogRun(pDialog) , m_nCloseSignalId(g_signal_connect(m_pDialog, "close", G_CALLBACK(signalClose), this)) @@ -2575,7 +2579,7 @@ public: virtual Container* weld_content_area() override { - return new GtkInstanceContainer(GTK_CONTAINER(gtk_dialog_get_content_area(m_pDialog)), false); + return new GtkInstanceContainer(GTK_CONTAINER(gtk_dialog_get_content_area(m_pDialog)), m_pBuilder, false); } virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>&) override @@ -2596,8 +2600,8 @@ class GtkInstanceMessageDialog : public GtkInstanceDialog, public virtual weld:: private: GtkMessageDialog* m_pMessageDialog; public: - GtkInstanceMessageDialog(GtkMessageDialog* pMessageDialog, bool bTakeOwnership) - : GtkInstanceDialog(GTK_DIALOG(pMessageDialog), bTakeOwnership) + GtkInstanceMessageDialog(GtkMessageDialog* pMessageDialog, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceDialog(GTK_DIALOG(pMessageDialog), pBuilder, bTakeOwnership) , m_pMessageDialog(pMessageDialog) { } @@ -2624,7 +2628,7 @@ public: virtual Container* weld_message_area() override { - return new GtkInstanceContainer(GTK_CONTAINER(gtk_message_dialog_get_message_area(m_pMessageDialog)), false); + return new GtkInstanceContainer(GTK_CONTAINER(gtk_message_dialog_get_message_area(m_pMessageDialog)), m_pBuilder, false); } }; @@ -2633,8 +2637,8 @@ class GtkInstanceFrame : public GtkInstanceContainer, public virtual weld::Frame private: GtkFrame* m_pFrame; public: - GtkInstanceFrame(GtkFrame* pFrame, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pFrame), bTakeOwnership) + GtkInstanceFrame(GtkFrame* pFrame, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pFrame), pBuilder, bTakeOwnership) , m_pFrame(pFrame) { } @@ -2926,8 +2930,8 @@ private: } public: - GtkInstanceScrolledWindow(GtkScrolledWindow* pScrolledWindow, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pScrolledWindow), bTakeOwnership) + GtkInstanceScrolledWindow(GtkScrolledWindow* pScrolledWindow, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pScrolledWindow), pBuilder, bTakeOwnership) , m_pScrolledWindow(pScrolledWindow) , m_pOrigViewport(nullptr) , m_pVAdjustment(gtk_scrolled_window_get_vadjustment(m_pScrolledWindow)) @@ -3554,8 +3558,8 @@ private: } public: - GtkInstanceNotebook(GtkNotebook* pNotebook, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pNotebook), bTakeOwnership) + GtkInstanceNotebook(GtkNotebook* pNotebook, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pNotebook), pBuilder, bTakeOwnership) , m_pNotebook(pNotebook) , m_pOverFlowBox(nullptr) , m_pOverFlowNotebook(GTK_NOTEBOOK(gtk_notebook_new())) @@ -3640,7 +3644,7 @@ public: if (m_aPages.size() < nPageIndex + 1) m_aPages.resize(nPageIndex + 1); if (!m_aPages[nPageIndex]) - m_aPages[nPageIndex].reset(new GtkInstanceContainer(pChild, false)); + m_aPages[nPageIndex].reset(new GtkInstanceContainer(pChild, m_pBuilder, false)); return m_aPages[nPageIndex].get(); } @@ -3777,8 +3781,8 @@ private: } public: - GtkInstanceButton(GtkButton* pButton, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pButton), bTakeOwnership) + GtkInstanceButton(GtkButton* pButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pButton), pBuilder, bTakeOwnership) , m_pButton(pButton) , m_nSignalId(g_signal_connect(pButton, "clicked", G_CALLBACK(signalClicked), this)) { @@ -3855,7 +3859,7 @@ weld::Button* GtkInstanceDialog::get_widget_for_response(int nResponse) GtkButton* pButton = GTK_BUTTON(gtk_dialog_get_widget_for_response(m_pDialog, VclToGtk(nResponse))); if (!pButton) return nullptr; - return new GtkInstanceButton(pButton, false); + return new GtkInstanceButton(pButton, m_pBuilder, false); } void GtkInstanceDialog::response(int nResponse) @@ -3895,8 +3899,8 @@ private: pThis->signal_toggled(); } public: - GtkInstanceToggleButton(GtkToggleButton* pButton, bool bTakeOwnership) - : GtkInstanceButton(GTK_BUTTON(pButton), bTakeOwnership) + GtkInstanceToggleButton(GtkToggleButton* pButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceButton(GTK_BUTTON(pButton), pBuilder, bTakeOwnership) , m_pToggleButton(pButton) , m_nSignalId(g_signal_connect(m_pToggleButton, "toggled", G_CALLBACK(signalToggled), this)) { @@ -4118,8 +4122,8 @@ private: } public: - GtkInstanceMenuButton(GtkMenuButton* pMenuButton, bool bTakeOwnership) - : GtkInstanceToggleButton(GTK_TOGGLE_BUTTON(pMenuButton), bTakeOwnership) + GtkInstanceMenuButton(GtkMenuButton* pMenuButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceToggleButton(GTK_TOGGLE_BUTTON(pMenuButton), pBuilder, bTakeOwnership) , MenuHelper(gtk_menu_button_get_popup(pMenuButton), false) , m_pMenuButton(pMenuButton) , m_pImage(nullptr) @@ -4461,8 +4465,8 @@ private: } public: - GtkInstanceLinkButton(GtkLinkButton* pButton, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pButton), bTakeOwnership) + GtkInstanceLinkButton(GtkLinkButton* pButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pButton), pBuilder, bTakeOwnership) , m_pButton(pButton) , m_nSignalId(g_signal_connect(pButton, "clicked", G_CALLBACK(signalClicked), this)) { @@ -4510,8 +4514,8 @@ public: class GtkInstanceRadioButton : public GtkInstanceToggleButton, public virtual weld::RadioButton { public: - GtkInstanceRadioButton(GtkRadioButton* pButton, bool bTakeOwnership) - : GtkInstanceToggleButton(GTK_TOGGLE_BUTTON(pButton), bTakeOwnership) + GtkInstanceRadioButton(GtkRadioButton* pButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceToggleButton(GTK_TOGGLE_BUTTON(pButton), pBuilder, bTakeOwnership) { } }; @@ -4519,8 +4523,8 @@ public: class GtkInstanceCheckButton : public GtkInstanceToggleButton, public virtual weld::CheckButton { public: - GtkInstanceCheckButton(GtkCheckButton* pButton, bool bTakeOwnership) - : GtkInstanceToggleButton(GTK_TOGGLE_BUTTON(pButton), bTakeOwnership) + GtkInstanceCheckButton(GtkCheckButton* pButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceToggleButton(GTK_TOGGLE_BUTTON(pButton), pBuilder, bTakeOwnership) { } }; @@ -4539,8 +4543,8 @@ private: } public: - GtkInstanceScale(GtkScale* pScale, bool bTakeOwnership) - : GtkInstanceWidget(GTK_WIDGET(pScale), bTakeOwnership) + GtkInstanceScale(GtkScale* pScale, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pScale), pBuilder, bTakeOwnership) , m_pScale(pScale) , m_nValueChangedSignalId(g_signal_connect(m_pScale, "value-changed", G_CALLBACK(signalValueChanged), this)) { @@ -4589,8 +4593,8 @@ private: GtkProgressBar* m_pProgressBar; public: - GtkInstanceProgressBar(GtkProgressBar* pProgressBar, bool bTakeOwnership) - : GtkInstanceWidget(GTK_WIDGET(pProgressBar), bTakeOwnership) + GtkInstanceProgressBar(GtkProgressBar* pProgressBar, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pProgressBar), pBuilder, bTakeOwnership) , m_pProgressBar(pProgressBar) { } @@ -4607,8 +4611,8 @@ private: GtkImage* m_pImage; public: - GtkInstanceImage(GtkImage* pImage, bool bTakeOwnership) - : GtkInstanceWidget(GTK_WIDGET(pImage), bTakeOwnership) + GtkInstanceImage(GtkImage* pImage, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pImage), pBuilder, bTakeOwnership) , m_pImage(pImage) { } @@ -4660,8 +4664,8 @@ private: } public: - GtkInstanceCalendar(GtkCalendar* pCalendar, bool bTakeOwnership) - : GtkInstanceWidget(GTK_WIDGET(pCalendar), bTakeOwnership) + GtkInstanceCalendar(GtkCalendar* pCalendar, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pCalendar), pBuilder, bTakeOwnership) , m_pCalendar(pCalendar) , m_nDaySelectedSignalId(g_signal_connect(pCalendar, "day-selected", G_CALLBACK(signalDaySelected), this)) , m_nDaySelectedDoubleClickSignalId(g_signal_connect(pCalendar, "day-selected-double-click", G_CALLBACK(signalDaySelectedDoubleClick), this)) @@ -4768,8 +4772,8 @@ private: } public: - GtkInstanceEntry(GtkEntry* pEntry, bool bTakeOwnership) - : GtkInstanceWidget(GTK_WIDGET(pEntry), bTakeOwnership) + GtkInstanceEntry(GtkEntry* pEntry, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pEntry), pBuilder, bTakeOwnership) , m_pEntry(pEntry) , m_nChangedSignalId(g_signal_connect(pEntry, "changed", G_CALLBACK(signalChanged), this)) , m_nInsertTextSignalId(g_signal_connect(pEntry, "insert-text", G_CALLBACK(signalInsertText), this)) @@ -5376,8 +5380,8 @@ private: } public: - GtkInstanceTreeView(GtkTreeView* pTreeView, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pTreeView), bTakeOwnership) + GtkInstanceTreeView(GtkTreeView* pTreeView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership) , m_pTreeView(pTreeView) , m_pTreeStore(GTK_TREE_STORE(gtk_tree_view_get_model(m_pTreeView))) , m_nTextCol(-1) @@ -6220,8 +6224,8 @@ private: } public: - GtkInstanceSpinButton(GtkSpinButton* pButton, bool bTakeOwnership) - : GtkInstanceEntry(GTK_ENTRY(pButton), bTakeOwnership) + GtkInstanceSpinButton(GtkSpinButton* pButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceEntry(GTK_ENTRY(pButton), pBuilder, bTakeOwnership) , m_pButton(pButton) , m_nValueChangedSignalId(g_signal_connect(pButton, "value-changed", G_CALLBACK(signalValueChanged), this)) , m_nOutputSignalId(g_signal_connect(pButton, "output", G_CALLBACK(signalOutput), this)) @@ -6413,8 +6417,8 @@ private: } public: - GtkInstanceFormattedSpinButton(GtkSpinButton* pButton, bool bTakeOwnership) - : GtkInstanceEntry(GTK_ENTRY(pButton), bTakeOwnership) + GtkInstanceFormattedSpinButton(GtkSpinButton* pButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceEntry(GTK_ENTRY(pButton), pBuilder, bTakeOwnership) , m_pButton(pButton) , m_pFormatter(nullptr) , m_pLastOutputColor(nullptr) @@ -6489,8 +6493,8 @@ class GtkInstanceLabel : public GtkInstanceWidget, public virtual weld::Label private: GtkLabel* m_pLabel; public: - GtkInstanceLabel(GtkLabel* pLabel, bool bTakeOwnership) - : GtkInstanceWidget(GTK_WIDGET(pLabel), bTakeOwnership) + GtkInstanceLabel(GtkLabel* pLabel, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pLabel), pBuilder, bTakeOwnership) , m_pLabel(pLabel) { } @@ -6527,8 +6531,8 @@ private: } public: - GtkInstanceTextView(GtkTextView* pTextView, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pTextView), bTakeOwnership) + GtkInstanceTextView(GtkTextView* pTextView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pTextView), pBuilder, bTakeOwnership) , m_pTextView(pTextView) , m_pTextBuffer(gtk_text_view_get_buffer(pTextView)) , m_nChangedSignalId(g_signal_connect(m_pTextBuffer, "changed", G_CALLBACK(signalChanged), this)) @@ -6845,8 +6849,8 @@ private: return true; } public: - GtkInstanceDrawingArea(GtkDrawingArea* pDrawingArea, const a11yref& rA11y, bool bTakeOwnership) - : GtkInstanceWidget(GTK_WIDGET(pDrawingArea), bTakeOwnership) + GtkInstanceDrawingArea(GtkDrawingArea* pDrawingArea, GtkInstanceBuilder* pBuilder, const a11yref& rA11y, bool bTakeOwnership) + : GtkInstanceWidget(GTK_WIDGET(pDrawingArea), pBuilder, bTakeOwnership) , m_pDrawingArea(pDrawingArea) , m_xAccessible(rA11y) , m_pAccessible(nullptr) @@ -7340,8 +7344,8 @@ private: } public: - GtkInstanceComboBox(GtkComboBox* pComboBox, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pComboBox), bTakeOwnership) + GtkInstanceComboBox(GtkComboBox* pComboBox, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pComboBox), pBuilder, bTakeOwnership) , m_pComboBox(pComboBox) , m_pTreeModel(gtk_combo_box_get_model(m_pComboBox)) , m_pMenu(nullptr) @@ -7866,9 +7870,10 @@ private: public: - GtkInstanceEntryTreeView(GtkContainer* pContainer, bool bTakeOwnership, std::unique_ptr<weld::Entry> xEntry, std::unique_ptr<weld::TreeView> xTreeView) + GtkInstanceEntryTreeView(GtkContainer* pContainer, GtkInstanceBuilder* pBuilder, bool bTakeOwnership, + std::unique_ptr<weld::Entry> xEntry, std::unique_ptr<weld::TreeView> xTreeView) : EntryTreeView(std::move(xEntry), std::move(xTreeView)) - , GtkInstanceContainer(pContainer, bTakeOwnership) + , GtkInstanceContainer(pContainer, pBuilder, bTakeOwnership) , m_pEntry(dynamic_cast<GtkInstanceEntry*>(m_xEntry.get())) , m_pTreeView(dynamic_cast<GtkInstanceTreeView*>(m_xTreeView.get())) , m_nAutoCompleteIdleId(0) @@ -7971,8 +7976,8 @@ private: } public: - GtkInstanceExpander(GtkExpander* pExpander, bool bTakeOwnership) - : GtkInstanceContainer(GTK_CONTAINER(pExpander), bTakeOwnership) + GtkInstanceExpander(GtkExpander* pExpander, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pExpander), pBuilder, bTakeOwnership) , m_pExpander(pExpander) , m_nSignalId(g_signal_connect(m_pExpander, "notify::expanded", G_CALLBACK(signalExpanded), this)) { @@ -8273,7 +8278,7 @@ public: if (!pMessageDialog) return nullptr; gtk_window_set_transient_for(GTK_WINDOW(pMessageDialog), GTK_WINDOW(gtk_widget_get_toplevel(m_pParentWidget))); - return std::make_unique<GtkInstanceMessageDialog>(pMessageDialog, bTakeOwnership); + return std::make_unique<GtkInstanceMessageDialog>(pMessageDialog, this, bTakeOwnership); } virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString &id, bool bTakeOwnership) override @@ -8283,13 +8288,13 @@ public: return nullptr; if (m_pParentWidget) gtk_window_set_transient_for(GTK_WINDOW(pDialog), GTK_WINDOW(gtk_widget_get_toplevel(m_pParentWidget))); - return std::make_unique<GtkInstanceDialog>(pDialog, bTakeOwnership); + return std::make_unique<GtkInstanceDialog>(pDialog, this, bTakeOwnership); } virtual std::unique_ptr<weld::Window> weld_window(const OString &id, bool bTakeOwnership) override { GtkWindow* pWindow = GTK_WINDOW(gtk_builder_get_object(m_pBuilder, id.getStr())); - return pWindow ? std::make_unique<GtkInstanceWindow>(pWindow, bTakeOwnership) : nullptr; + return pWindow ? std::make_unique<GtkInstanceWindow>(pWindow, this, bTakeOwnership) : nullptr; } virtual std::unique_ptr<weld::Widget> weld_widget(const OString &id, bool bTakeOwnership) override @@ -8298,7 +8303,7 @@ public: if (!pWidget) return nullptr; auto_add_parentless_widgets_to_container(pWidget); - return std::make_unique<GtkInstanceWidget>(pWidget, bTakeOwnership); + return std::make_unique<GtkInstanceWidget>(pWidget, this, bTakeOwnership); } virtual std::unique_ptr<weld::Container> weld_container(const OString &id, bool bTakeOwnership) override @@ -8307,7 +8312,7 @@ public: if (!pContainer) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pContainer)); - return std::make_unique<GtkInstanceContainer>(pContainer, bTakeOwnership); + return std::make_unique<GtkInstanceContainer>(pContainer, this, bTakeOwnership); } virtual std::unique_ptr<weld::Frame> weld_frame(const OString &id, bool bTakeOwnership) override @@ -8316,7 +8321,7 @@ public: if (!pFrame) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pFrame)); - return std::make_unique<GtkInstanceFrame>(pFrame, bTakeOwnership); + return std::make_unique<GtkInstanceFrame>(pFrame, this, bTakeOwnership); } virtual std::unique_ptr<weld::ScrolledWindow> weld_scrolled_window(const OString &id, bool bTakeOwnership) override @@ -8325,7 +8330,7 @@ public: if (!pScrolledWindow) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pScrolledWindow)); - return std::make_unique<GtkInstanceScrolledWindow>(pScrolledWindow, bTakeOwnership); + return std::make_unique<GtkInstanceScrolledWindow>(pScrolledWindow, this, bTakeOwnership); } virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString &id, bool bTakeOwnership) override @@ -8334,7 +8339,7 @@ public: if (!pNotebook) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pNotebook)); - return std::make_unique<GtkInstanceNotebook>(pNotebook, bTakeOwnership); + return std::make_unique<GtkInstanceNotebook>(pNotebook, this, bTakeOwnership); } virtual std::unique_ptr<weld::Button> weld_button(const OString &id, bool bTakeOwnership) override @@ -8343,7 +8348,7 @@ public: if (!pButton) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pButton)); - return std::make_unique<GtkInstanceButton>(pButton, bTakeOwnership); + return std::make_unique<GtkInstanceButton>(pButton, this, bTakeOwnership); } virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OString &id, bool bTakeOwnership) override @@ -8352,7 +8357,7 @@ public: if (!pButton) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pButton)); - return std::make_unique<GtkInstanceMenuButton>(pButton, bTakeOwnership); + return std::make_unique<GtkInstanceMenuButton>(pButton, this, bTakeOwnership); } virtual std::unique_ptr<weld::LinkButton> weld_link_button(const OString &id, bool bTakeOwnership) override @@ -8361,7 +8366,7 @@ public: if (!pButton) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pButton)); - return std::make_unique<GtkInstanceLinkButton>(pButton, bTakeOwnership); + return std::make_unique<GtkInstanceLinkButton>(pButton, this, bTakeOwnership); } virtual std::unique_ptr<weld::ToggleButton> weld_toggle_button(const OString &id, bool bTakeOwnership) override @@ -8370,7 +8375,7 @@ public: if (!pToggleButton) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pToggleButton)); - return std::make_unique<GtkInstanceToggleButton>(pToggleButton, bTakeOwnership); + return std::make_unique<GtkInstanceToggleButton>(pToggleButton, this, bTakeOwnership); } virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OString &id, bool bTakeOwnership) override @@ -8379,7 +8384,7 @@ public: if (!pRadioButton) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pRadioButton)); - return std::make_unique<GtkInstanceRadioButton>(pRadioButton, bTakeOwnership); + return std::make_unique<GtkInstanceRadioButton>(pRadioButton, this, bTakeOwnership); } virtual std::unique_ptr<weld::CheckButton> weld_check_button(const OString &id, bool bTakeOwnership) override @@ -8388,7 +8393,7 @@ public: if (!pCheckButton) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pCheckButton)); - return std::make_unique<GtkInstanceCheckButton>(pCheckButton, bTakeOwnership); + return std::make_unique<GtkInstanceCheckButton>(pCheckButton, this, bTakeOwnership); } virtual std::unique_ptr<weld::Scale> weld_scale(const OString &id, bool bTakeOwnership) override @@ -8397,7 +8402,7 @@ public: if (!pScale) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pScale)); - return std::make_unique<GtkInstanceScale>(pScale, bTakeOwnership); + return std::make_unique<GtkInstanceScale>(pScale, this, bTakeOwnership); } virtual std::unique_ptr<weld::ProgressBar> weld_progress_bar(const OString &id, bool bTakeOwnership) override @@ -8406,7 +8411,7 @@ public: if (!pProgressBar) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pProgressBar)); - return std::make_unique<GtkInstanceProgressBar>(pProgressBar, bTakeOwnership); + return std::make_unique<GtkInstanceProgressBar>(pProgressBar, this, bTakeOwnership); } virtual std::unique_ptr<weld::Image> weld_image(const OString &id, bool bTakeOwnership) override @@ -8415,7 +8420,7 @@ public: if (!pImage) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pImage)); - return std::make_unique<GtkInstanceImage>(pImage, bTakeOwnership); + return std::make_unique<GtkInstanceImage>(pImage, this, bTakeOwnership); } virtual std::unique_ptr<weld::Calendar> weld_calendar(const OString &id, bool bTakeOwnership) override @@ -8424,7 +8429,7 @@ public: if (!pCalendar) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pCalendar)); - return std::make_unique<GtkInstanceCalendar>(pCalendar, bTakeOwnership); + return std::make_unique<GtkInstanceCalendar>(pCalendar, this, bTakeOwnership); } virtual std::unique_ptr<weld::Entry> weld_entry(const OString &id, bool bTakeOwnership) override @@ -8433,7 +8438,7 @@ public: if (!pEntry) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pEntry)); - return std::make_unique<GtkInstanceEntry>(pEntry, bTakeOwnership); + return std::make_unique<GtkInstanceEntry>(pEntry, this, bTakeOwnership); } virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OString &id, bool bTakeOwnership) override @@ -8442,7 +8447,7 @@ public: if (!pSpinButton) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pSpinButton)); - return std::make_unique<GtkInstanceSpinButton>(pSpinButton, bTakeOwnership); + return std::make_unique<GtkInstanceSpinButton>(pSpinButton, this, bTakeOwnership); } virtual std::unique_ptr<weld::MetricSpinButton> weld_metric_spin_button(const OString& id, FieldUnit eUnit, @@ -8457,7 +8462,7 @@ public: if (!pSpinButton) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pSpinButton)); - return std::make_unique<GtkInstanceFormattedSpinButton>(pSpinButton, bTakeOwnership); + return std::make_unique<GtkInstanceFormattedSpinButton>(pSpinButton, this, bTakeOwnership); } virtual std::unique_ptr<weld::TimeSpinButton> weld_time_spin_button(const OString& id, TimeFieldFormat eFormat, @@ -8472,7 +8477,7 @@ public: if (!pComboBox) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pComboBox)); - return std::make_unique<GtkInstanceComboBox>(pComboBox, bTakeOwnership); + return std::make_unique<GtkInstanceComboBox>(pComboBox, this, bTakeOwnership); } virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString &id, bool bTakeOwnership) override @@ -8481,7 +8486,7 @@ public: if (!pTreeView) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pTreeView)); - return std::make_unique<GtkInstanceTreeView>(pTreeView, bTakeOwnership); + return std::make_unique<GtkInstanceTreeView>(pTreeView, this, bTakeOwnership); } virtual std::unique_ptr<weld::EntryTreeView> weld_entry_tree_view(const OString& containerid, const OString& entryid, const OString& treeviewid, bool bTakeOwnership) override @@ -8490,7 +8495,9 @@ public: if (!pContainer) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pContainer)); - return std::make_unique<GtkInstanceEntryTreeView>(pContainer, bTakeOwnership, weld_entry(entryid, bTakeOwnership), weld_tree_view(treeviewid, bTakeOwnership)); + return std::make_unique<GtkInstanceEntryTreeView>(pContainer, this, bTakeOwnership, + weld_entry(entryid, bTakeOwnership), + weld_tree_view(treeviewid, bTakeOwnership)); } virtual std::unique_ptr<weld::Label> weld_label(const OString &id, bool bTakeOwnership) override @@ -8499,7 +8506,7 @@ public: if (!pLabel) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pLabel)); - return std::make_unique<GtkInstanceLabel>(pLabel, bTakeOwnership); + return std::make_unique<GtkInstanceLabel>(pLabel, this, bTakeOwnership); } virtual std::unique_ptr<weld::TextView> weld_text_view(const OString &id, bool bTakeOwnership) override @@ -8508,7 +8515,7 @@ public: if (!pTextView) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pTextView)); - return std::make_unique<GtkInstanceTextView>(pTextView, bTakeOwnership); + return std::make_unique<GtkInstanceTextView>(pTextView, this, bTakeOwnership); } virtual std::unique_ptr<weld::Expander> weld_expander(const OString &id, bool bTakeOwnership) override @@ -8517,7 +8524,7 @@ public: if (!pExpander) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pExpander)); - return std::make_unique<GtkInstanceExpander>(pExpander, bTakeOwnership); + return std::make_unique<GtkInstanceExpander>(pExpander, this, bTakeOwnership); } virtual std::unique_ptr<weld::DrawingArea> weld_drawing_area(const OString &id, const a11yref& rA11y, @@ -8527,7 +8534,7 @@ public: if (!pDrawingArea) return nullptr; auto_add_parentless_widgets_to_container(GTK_WIDGET(pDrawingArea)); - return std::make_unique<GtkInstanceDrawingArea>(pDrawingArea, rA11y, bTakeOwnership); + return std::make_unique<GtkInstanceDrawingArea>(pDrawingArea, this, rA11y, bTakeOwnership); } virtual std::unique_ptr<weld::Menu> weld_menu(const OString &id, bool bTakeOwnership) override @@ -8558,7 +8565,7 @@ void GtkInstanceWindow::help() break; sHelpId = ::get_help_id(pWidget); } - std::unique_ptr<weld::Widget> xTemp(pWidget != m_pWidget ? new GtkInstanceWidget(pWidget, false) : nullptr); + std::unique_ptr<weld::Widget> xTemp(pWidget != m_pWidget ? new GtkInstanceWidget(pWidget, m_pBuilder, false) : nullptr); weld::Widget* pSource = xTemp ? xTemp.get() : this; bool bRunNormalHelpRequest = !m_aHelpRequestHdl.IsSet() || m_aHelpRequestHdl.Call(*pSource); Help* pHelp = bRunNormalHelpRequest ? Application::GetHelp() : nullptr; @@ -8566,6 +8573,42 @@ void GtkInstanceWindow::help() pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), pSource); } +//iterate upwards through the hierarchy from this widgets through its parents +//calling func with their helpid until func returns true or we run out of parents +void GtkInstanceWidget::help_hierarchy_foreach(const std::function<bool(const OString&)>& func) +{ + GtkWidget* pParent = m_pWidget; + while ((pParent = gtk_widget_get_parent(pParent))) + { + // tdf#122355 before trying dialog help, check to see if there is a notebook + // called tabcontrol, and try the help for the current page of that first + if (m_pBuilder && GTK_IS_DIALOG(pParent)) + { + std::unique_ptr<weld::Notebook> xNotebook(m_pBuilder->weld_notebook("tabcontrol", false)); + if (xNotebook) + { + if (GtkInstanceContainer* pPage = dynamic_cast<GtkInstanceContainer*>(xNotebook->get_page(xNotebook->get_current_page_ident()))) + { + bool bFinished = false; + GtkWidget* pContainer = pPage->getWidget(); + GList* pChildren = gtk_container_get_children(GTK_CONTAINER(pContainer)); + GList* pChild = g_list_first(pChildren); + if (pChild) + { + GtkWidget* pPageWidget = static_cast<GtkWidget*>(pChild->data); + bFinished = func(::get_help_id(pPageWidget)); + } + g_list_free(pChildren); + if (bFinished) + return; + } + } + } + if (func(::get_help_id(pParent))) + return; + } +} + weld::Builder* GtkInstance::CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile) { GtkInstanceWidget* pParentWidget = dynamic_cast<GtkInstanceWidget*>(pParent); @@ -8582,7 +8625,7 @@ weld::MessageDialog* GtkInstance::CreateMessageDialog(weld::Widget* pParent, Vcl GtkMessageDialog* pMessageDialog = GTK_MESSAGE_DIALOG(gtk_message_dialog_new(pParentWindow, GTK_DIALOG_MODAL, VclToGtk(eMessageType), VclToGtk(eButtonsType), "%s", OUStringToOString(rPrimaryMessage, RTL_TEXTENCODING_UTF8).getStr())); - return new GtkInstanceMessageDialog(pMessageDialog, true); + return new GtkInstanceMessageDialog(pMessageDialog, nullptr, true); } weld::Window* GtkInstance::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) @@ -8595,7 +8638,7 @@ weld::Window* GtkInstance::GetFrameWeld(const css::uno::Reference<css::awt::XWin weld::Window* GtkSalFrame::GetFrameWeld() const { if (!m_xFrameWeld) - m_xFrameWeld.reset(new GtkInstanceWindow(GTK_WINDOW(getWindow()), false)); + m_xFrameWeld.reset(new GtkInstanceWindow(GTK_WINDOW(getWindow()), nullptr, false)); return m_xFrameWeld.get(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits