vcl/unx/gtk4/convert3to4.cxx | 47 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-)
New commits: commit a134845061b16e43d192feaceac3ecb8f4a51cdb Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sat Jun 5 20:59:54 2021 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun Jun 6 21:37:43 2021 +0200 gtk4: convert MenuButton "image" to "icon-name" Change-Id: Ic290b6008739a729b786562affb72d26da2191d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116754 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/unx/gtk4/convert3to4.cxx b/vcl/unx/gtk4/convert3to4.cxx index 88d3de723d39..51649c981503 100644 --- a/vcl/unx/gtk4/convert3to4.cxx +++ b/vcl/unx/gtk4/convert3to4.cxx @@ -570,8 +570,7 @@ ConvertResult Convert3To4(const css::uno::Reference<css::xml::dom::XNode>& xNode || GetParentObjectType(xChild) == "GtkMenuButton" || GetParentObjectType(xChild) == "GtkToggleButton") { - // find the image object, expected to be a child of "interface" and relocate - // it to be a child of this GtkButton + // find the image object, expected to be a child of "interface" auto xObjectCandidate = xChild->getParentNode(); if (xObjectCandidate->getNodeName() == "object") { @@ -606,11 +605,45 @@ ConvertResult Convert3To4(const css::uno::Reference<css::xml::dom::XNode>& xNode } auto xDoc = xChild->getOwnerDocument(); - css::uno::Reference<css::xml::dom::XElement> xImageChild - = xDoc->createElement("child"); - xImageChild->appendChild( - xImageNode->getParentNode()->removeChild(xImageNode)); - xObjectCandidate->appendChild(xImageChild); + + if (GetParentObjectType(xChild) == "GtkButton" + || GetParentObjectType(xChild) == "GtkToggleButton") + { + // relocate it to be a child of this GtkButton + css::uno::Reference<css::xml::dom::XElement> xImageChild + = xDoc->createElement("child"); + xImageChild->appendChild( + xImageNode->getParentNode()->removeChild(xImageNode)); + xObjectCandidate->appendChild(xImageChild); + } + else if (GetParentObjectType(xChild) == "GtkMenuButton") + { + auto xProp = xImageNode->getFirstChild(); + while (xProp.is()) + { + if (xProp->getNodeName() == "property") + { + css::uno::Reference<css::xml::dom::XNamedNodeMap> xPropMap + = xProp->getAttributes(); + css::uno::Reference<css::xml::dom::XNode> xPropName + = xPropMap->getNamedItem("name"); + OUString sPropName(xPropName->getNodeValue().replace('_', '-')); + if (sPropName == "icon-name") + { + OUString sIconName(xProp->getFirstChild()->getNodeValue()); + fprintf(stderr, "icon name is %s\n", + sIconName.toUtf8().getStr()); + auto xIconName + = CreateProperty(xDoc, "icon-name", sIconName); + xObjectCandidate->insertBefore(xIconName, xChild); + break; + } + } + + xProp = xProp->getNextSibling(); + } + xImageNode->getParentNode()->removeChild(xImageNode); + } } xRemoveList.push_back(xChild); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits