[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu May 13 19:01:52 UTC 2021


 vcl/unx/gtk3/gtkinst.cxx |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

New commits:
commit 5846f376b7e2fecc6b7fc5315095234b7aeed6c5
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu May 13 15:53:16 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu May 13 21:01:11 2021 +0200

    gtk4: add default spacing in GtkBox GtkButtonBox replacement
    
    except for message dialog which are left at whatever default they
    want
    
    Change-Id: I0e5a63a909f3e4bf1800868e8c14dcc71147f5b7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115561
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 09b4807a0126..7c8caee2a4d6 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -17527,6 +17527,20 @@ bool IsAllowedBuiltInIcon(std::u16string_view iconName)
 namespace {
 
 #if GTK_CHECK_VERSION(4, 0, 0)
+
+// <property name="spacing">6</property>
+Reference<css::xml::dom::XNode> CreateProperty(const css::uno::Reference<css::xml::dom::XDocument>& xDoc,
+                                               const OUString& rPropName, const OUString& rValue)
+{
+    css::uno::Reference<css::xml::dom::XElement> xProperty = xDoc->createElement("property");
+    css::uno::Reference<css::xml::dom::XAttr> xPropName = xDoc->createAttribute("name");
+    xPropName->setValue(rPropName);
+    xProperty->setAttributeNode(xPropName);
+    css::uno::Reference<css::xml::dom::XText> xValue = xDoc->createTextNode(rValue);
+    xProperty->appendChild(xValue);
+    return xProperty;
+}
+
 void ConvertTree(const Reference<css::xml::dom::XNode>& xNode)
 {
     css::uno::Reference<css::xml::dom::XNodeList> xNodeList = xNode->getChildNodes();
@@ -17581,7 +17595,21 @@ void ConvertTree(const Reference<css::xml::dom::XNode>& xNode)
             css::uno::Reference<css::xml::dom::XNode> xClass = xMap->getNamedItem("class");
             OUString sClass(xClass->getNodeValue());
             if (sClass == "GtkButtonBox")
+            {
                 xClass->setNodeValue("GtkBox");
+
+                css::uno::Reference<css::xml::dom::XNode> xId = xMap->getNamedItem("id");
+                if (!xId->getNodeValue().startsWith("messagedialog-action_area"))
+                {
+                    auto xDoc = xChild->getOwnerDocument();
+                    auto xSpacingNode = CreateProperty(xDoc, "spacing", "6");
+                    auto xFirstChild = xChild->getFirstChild();
+                    if (xFirstChild.is())
+                        xChild->insertBefore(xSpacingNode, xFirstChild);
+                    else
+                        xChild->appendChild(xSpacingNode);
+                }
+            }
         }
         else if (xChild->getNodeName() == "packing")
         {
@@ -17682,6 +17710,7 @@ void load_ui_file(GtkBuilder* pBuilder, const OUString& rUri)
         sal_Int32 nRead = xInput->readBytes(bytes, std::max<sal_Int32>(nToRead, 4096));
         if (!nRead)
             break;
+        // fprintf(stderr, "text is %s\n", reinterpret_cast<const gchar*>(bytes.getArray()));
         auto rc = gtk_builder_add_from_string(pBuilder, reinterpret_cast<const gchar*>(bytes.getArray()), nRead, &err);
         if (!rc)
         {


More information about the Libreoffice-commits mailing list