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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 15 13:01:08 UTC 2021


 vcl/unx/gtk3/gtkinst.cxx |   25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

New commits:
commit f1f431b9884dd50353e12af8759b160d70e418dc
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jun 15 11:49:02 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jun 15 15:00:23 2021 +0200

    gtk4: support moving between containers
    
    just GtkBoxes for now
    
    Change-Id: I2247661649c67944290451de98e80db7faf41648
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117238
    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 16bf7320d618..028ff623ecd9 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -5061,7 +5061,9 @@ public:
         weld::Container::connect_container_focus_changed(rLink);
     }
 
-#if !GTK_CHECK_VERSION(4, 0, 0)
+#if GTK_CHECK_VERSION(4, 0, 0)
+    GtkWidget* getContainer() { return m_pContainer; }
+#else
     GtkContainer* getContainer() { return m_pContainer; }
 #endif
 
@@ -5088,22 +5090,31 @@ public:
 
     virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) override
     {
-#if !GTK_CHECK_VERSION(4, 0, 0)
         GtkInstanceWidget* pGtkWidget = dynamic_cast<GtkInstanceWidget*>(pWidget);
         assert(pGtkWidget);
         GtkWidget* pChild = pGtkWidget->getWidget();
         g_object_ref(pChild);
-        gtk_container_remove(getContainer(), pChild);
+        auto pOldContainer = getContainer();
+#if !GTK_CHECK_VERSION(4, 0, 0)
+        gtk_container_remove(pOldContainer, pChild);
+#else
+        assert(GTK_IS_BOX(pOldContainer));
+        gtk_box_remove(GTK_BOX(pOldContainer), pChild);
+#endif
 
         GtkInstanceContainer* pNewGtkParent = dynamic_cast<GtkInstanceContainer*>(pNewParent);
         assert(!pNewParent || pNewGtkParent);
         if (pNewGtkParent)
-            gtk_container_add(pNewGtkParent->getContainer(), pChild);
-        g_object_unref(pChild);
+        {
+            auto pNewContainer = pNewGtkParent->getContainer();
+#if !GTK_CHECK_VERSION(4, 0, 0)
+            gtk_container_add(pNewContainer, pChild);
 #else
-        (void)pWidget;
-        (void)pNewParent;
+            assert(GTK_IS_BOX(pNewContainer));
+            gtk_box_append(GTK_BOX(pNewContainer), pChild);
 #endif
+        }
+        g_object_unref(pChild);
     }
 
     virtual void recursively_unset_default_buttons() override


More information about the Libreoffice-commits mailing list