[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 18 13:06:58 UTC 2021


 vcl/unx/gtk3/gtkinst.cxx |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 4895e825b9fb40c2df272f910a9fe14e545a7c99
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Jun 18 10:58:13 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jun 18 15:06:25 2021 +0200

    tdf#142924 "toggled" is too late to use to populate changes to the menu
    
    so use "state-flag-changed" on GTK_STATE_FLAG_CHECKED instead which
    happens before "toggled"
    
    Change-Id: I3a68212ce4bec2cda49d8bcaf3db864cb34013cc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117441
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index f50d98a5fb05..3c4e3136a0f9 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -8912,7 +8912,6 @@ class GtkInstanceToggleButton : public GtkInstanceButton, public virtual weld::T
 {
 protected:
     GtkToggleButton* m_pToggleButton;
-private:
     gulong m_nToggledSignalId;
 
     static void signalToggled(GtkToggleButton*, gpointer widget)
@@ -9472,6 +9471,17 @@ private:
     }
 #endif
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
+    static void signalFlagsChanged(GtkToggleButton* pToggleButton, GtkStateFlags flags, gpointer widget)
+    {
+        bool bOldChecked = flags & GTK_STATE_FLAG_CHECKED;
+        bool bNewChecked = gtk_widget_get_state_flags(GTK_WIDGET(pToggleButton)) & GTK_STATE_FLAG_CHECKED;
+        if (bOldChecked == bNewChecked)
+            return;
+        signalToggled(pToggleButton, widget);
+    }
+#endif
+
 public:
 #if !GTK_CHECK_VERSION(4, 0, 0)
     GtkInstanceMenuButton(GtkMenuButton* pMenuButton, GtkWidget* pMenuAlign, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
@@ -9493,6 +9503,14 @@ public:
         , m_aCustomBackground(GTK_WIDGET(pMenuButton))
 #endif
     {
+#if !GTK_CHECK_VERSION(4, 0, 0)
+        // tdf#142924 "toggled" is to late to use to populate changes to the menu,
+        // so use "state-flag-changed" on GTK_STATE_FLAG_CHECKED instead which
+        // happens before "toggled"
+        g_signal_handler_disconnect(m_pToggleButton, m_nToggledSignalId);
+        m_nToggledSignalId = g_signal_connect(m_pToggleButton, "state-flags-changed", G_CALLBACK(signalFlagsChanged), this);
+#endif
+
 #if !GTK_CHECK_VERSION(4, 0, 0)
         m_pLabel = gtk_bin_get_child(GTK_BIN(m_pMenuButton));
         find_image(GTK_WIDGET(m_pMenuButton), &m_pImage);


More information about the Libreoffice-commits mailing list