vcl/unx/gtk3/gtk3gtkinst.cxx | 131 ++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 62 deletions(-)
New commits: commit 8550e6699d783be295fc2078fbb96ee8e0ea953b Author: Caolán McNamara <[email protected]> AuthorDate: Thu Apr 9 15:15:19 2020 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Apr 9 20:34:53 2020 +0200 split out insertParent code Change-Id: Ideee16b57548df5f6fd1561d68729968edc42e76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91989 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 88d751bdf7a0..d4a65c9ce53f 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1710,6 +1710,74 @@ namespace } #endif + void insertParent(GtkWidget* pWidget, GtkWidget* pReplacement) + { + // remove the widget and replace it with pReplacement + GtkWidget* pParent = gtk_widget_get_parent(pWidget); + + g_object_ref(pWidget); + + gint nTopAttach(0), nLeftAttach(0), nHeight(1), nWidth(1); + if (GTK_IS_GRID(pParent)) + { + gtk_container_child_get(GTK_CONTAINER(pParent), pWidget, + "left-attach", &nTopAttach, + "top-attach", &nLeftAttach, + "width", &nWidth, + "height", &nHeight, + nullptr); + } + + gboolean bExpand(false), bFill(false); + GtkPackType ePackType(GTK_PACK_START); + guint nPadding(0); + gint nPosition(0); + if (GTK_IS_BOX(pParent)) + { + gtk_container_child_get(GTK_CONTAINER(pParent), pWidget, + "expand", &bExpand, + "fill", &bFill, + "pack-type", &ePackType, + "padding", &nPadding, + "position", &nPosition, + nullptr); + } + + gtk_container_remove(GTK_CONTAINER(pParent), pWidget); + + gtk_widget_set_visible(pReplacement, gtk_widget_get_visible(pWidget)); + + gtk_container_add(GTK_CONTAINER(pParent), pReplacement); + + if (GTK_IS_GRID(pParent)) + { + gtk_container_child_set(GTK_CONTAINER(pParent), pReplacement, + "left-attach", nTopAttach, + "top-attach", nLeftAttach, + "width", nWidth, + "height", nHeight, + nullptr); + } + + if (GTK_IS_BOX(pParent)) + { + gtk_container_child_set(GTK_CONTAINER(pParent), pReplacement, + "expand", bExpand, + "fill", bFill, + "pack-type", ePackType, + "padding", nPadding, + "position", nPosition, + nullptr); + } + + gtk_widget_set_hexpand(pReplacement, gtk_widget_get_hexpand(pWidget)); + gtk_widget_set_vexpand(pReplacement, gtk_widget_get_vexpand(pWidget)); + + gtk_container_add(GTK_CONTAINER(pReplacement), pWidget); + + g_object_unref(pWidget); + } + GtkWidget* ensureEventWidget(GtkWidget* pWidget) { if (!pWidget) @@ -1725,71 +1793,10 @@ namespace { // remove the widget and replace it with an eventbox and put the old // widget into it - GtkWidget* pParent = gtk_widget_get_parent(pWidget); - - g_object_ref(pWidget); - - gint nTopAttach(0), nLeftAttach(0), nHeight(1), nWidth(1); - if (GTK_IS_GRID(pParent)) - { - gtk_container_child_get(GTK_CONTAINER(pParent), pWidget, - "left-attach", &nTopAttach, - "top-attach", &nLeftAttach, - "width", &nWidth, - "height", &nHeight, - nullptr); - } - - gboolean bExpand(false), bFill(false); - GtkPackType ePackType(GTK_PACK_START); - guint nPadding(0); - gint nPosition(0); - if (GTK_IS_BOX(pParent)) - { - gtk_container_child_get(GTK_CONTAINER(pParent), pWidget, - "expand", &bExpand, - "fill", &bFill, - "pack-type", &ePackType, - "padding", &nPadding, - "position", &nPosition, - nullptr); - } - - gtk_container_remove(GTK_CONTAINER(pParent), pWidget); - pMouseEventBox = gtk_event_box_new(); gtk_event_box_set_above_child(GTK_EVENT_BOX(pMouseEventBox), false); gtk_event_box_set_visible_window(GTK_EVENT_BOX(pMouseEventBox), false); - gtk_widget_set_visible(pMouseEventBox, gtk_widget_get_visible(pWidget)); - - gtk_container_add(GTK_CONTAINER(pParent), pMouseEventBox); - - if (GTK_IS_GRID(pParent)) - { - gtk_container_child_set(GTK_CONTAINER(pParent), pMouseEventBox, - "left-attach", nTopAttach, - "top-attach", nLeftAttach, - "width", nWidth, - "height", nHeight, - nullptr); - } - - if (GTK_IS_BOX(pParent)) - { - gtk_container_child_set(GTK_CONTAINER(pParent), pMouseEventBox, - "expand", bExpand, - "fill", bFill, - "pack-type", ePackType, - "padding", nPadding, - "position", nPosition, - nullptr); - } - - gtk_container_add(GTK_CONTAINER(pMouseEventBox), pWidget); - g_object_unref(pWidget); - - gtk_widget_set_hexpand(pMouseEventBox, gtk_widget_get_hexpand(pWidget)); - gtk_widget_set_vexpand(pMouseEventBox, gtk_widget_get_vexpand(pWidget)); + insertParent(pWidget, pMouseEventBox); } return pMouseEventBox; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
