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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon May 31 18:52:27 UTC 2021


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

New commits:
commit 486d3dd4f68dd4f93d2f5c94d5cce3112ddf6d40
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 31 17:32:40 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 31 20:51:45 2021 +0200

    gtk4: reenable Box reorder_child
    
    Change-Id: I5705941e1459a7d2045223eefcfe0a9a09b3648f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116493
    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 53b301748dfb..857c48563260 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -4973,7 +4973,6 @@ std::unique_ptr<weld::Container> GtkInstanceWidget::weld_parent() const
 }
 
 namespace {
-#if !GTK_CHECK_VERSION(4, 0, 0)
 
 struct ButtonOrder
 {
@@ -5069,14 +5068,30 @@ public:
 
     virtual void reorder_child(weld::Widget* pWidget, int nNewPosition) override
     {
-#if !GTK_CHECK_VERSION(4, 0, 0)
         GtkInstanceWidget* pGtkWidget = dynamic_cast<GtkInstanceWidget*>(pWidget);
         assert(pGtkWidget);
         GtkWidget* pChild = pGtkWidget->getWidget();
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gtk_box_reorder_child(m_pBox, pChild, nNewPosition);
 #else
-        (void)pWidget;
-        (void)nNewPosition;
+        if (nNewPosition == 0)
+            gtk_box_reorder_child_after(m_pBox, pChild, nullptr);
+        else
+        {
+            int nNewSiblingPos = nNewPosition - 1;
+            int nChildPosition = 0;
+            for (GtkWidget* pNewSibling = gtk_widget_get_first_child(GTK_WIDGET(m_pBox));
+                 pNewSibling; pNewSibling = gtk_widget_get_next_sibling(pNewSibling))
+            {
+                if (nChildPosition == nNewSiblingPos)
+                {
+                    gtk_box_reorder_child_after(m_pBox, pChild, pNewSibling);
+                    break;
+                }
+                ++nChildPosition;
+            }
+        }
 #endif
     }
 
@@ -5086,7 +5101,6 @@ public:
     }
 };
 
-#endif
 }
 
 namespace
@@ -21879,16 +21893,11 @@ public:
 
     virtual std::unique_ptr<weld::Box> weld_box(const OString &id) override
     {
-#if !GTK_CHECK_VERSION(4, 0, 0)
         GtkBox* pBox = GTK_BOX(gtk_builder_get_object(m_pBuilder, id.getStr()));
         if (!pBox)
             return nullptr;
         auto_add_parentless_widgets_to_container(GTK_WIDGET(pBox));
         return std::make_unique<GtkInstanceBox>(pBox, this, false);
-#else
-        (void)id;
-        return nullptr;
-#endif
     }
 
     virtual std::unique_ptr<weld::Paned> weld_paned(const OString &id) override


More information about the Libreoffice-commits mailing list