include/vcl/builder.hxx       |    1 +
 vcl/source/window/builder.cxx |   10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 625d22600d41a70f5c4a65bc75ef02b17c6cfae2
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Feb 26 14:26:03 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Mon Feb 26 22:38:06 2024 +0100

    tdf#159910 VclBuilder: Add helper to identify toolbar item class
    
    Extract a new helper method `BuilderBase::isToolbarItemClass`
    to identify whether a widget class is one of those used for
    toolbar items.
    
    Related: Gtk's GtkToolItem doc [1].
    (But this commit just moves the existing logic without
    looking into that Gtk doc further.)
    
    [1] https://docs.gtk.org/gtk3/class.ToolItem.html
    
    Change-Id: I1e39e4afb13db374ae77a3cdb6a4dd9eca7ee3ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163957
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 6071b80087a1..37fbfbe97e16 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -75,6 +75,7 @@ protected:
     static void collectAtkRelationAttribute(xmlreader::XmlReader& reader, 
stringmap& rMap);
     static void collectAtkRoleAttribute(xmlreader::XmlReader& reader, 
stringmap& rMap);
     static void collectAccelerator(xmlreader::XmlReader& reader, accelmap& 
rMap);
+    static bool isToolbarItemClass(std::u16string_view sClass);
 };
 
 /// Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, 
sidebar, etc.
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 88e82ac52138..0fcf7d6b65fd 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -2105,8 +2105,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window 
*pParent, const OUString
             NotebookBarAddonsMerger::MergeNotebookBarAddons(pParent, 
pFunction, m_xFrame, *m_pNotebookBarAddonsItem, rMap);
         return nullptr;
     }
-    else if (name == "GtkToolButton" || name == "GtkMenuToolButton" ||
-             name == "GtkToggleToolButton" || name == "GtkRadioToolButton" || 
name == "GtkToolItem")
+    else if (isToolbarItemClass(name))
     {
         if (pToolBox)
         {
@@ -4036,6 +4035,13 @@ void 
BuilderBase::collectAccelerator(xmlreader::XmlReader& reader, accelmap& rMa
     }
 }
 
+bool BuilderBase::isToolbarItemClass(std::u16string_view sClass)
+{
+    return sClass == u"GtkToolButton" || sClass == u"GtkMenuToolButton"
+           || sClass == u"GtkToggleToolButton" || sClass == 
u"GtkRadioToolButton"
+           || sClass == u"GtkToolItem";
+}
+
 vcl::Window *VclBuilder::get_widget_root()
 {
     return m_aChildren.empty() ? nullptr : m_aChildren[0].m_pWindow.get();

Reply via email to