summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-06-05 20:59:54 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-06-06 21:37:43 +0200
commita134845061b16e43d192feaceac3ecb8f4a51cdb (patch)
tree11fac6ea54e75ffb400ac7e8169ebb35f7d3a99c
parente2e89bb4187e08c4b6052f535d80886e198051c8 (diff)
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 <caolanm@redhat.com>
-rw-r--r--vcl/unx/gtk4/convert3to4.cxx47
1 files changed, 40 insertions, 7 deletions
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);