[Libreoffice-commits] core.git: vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 18 15:00:27 UTC 2021
vcl/unx/gtk3/gtkinst.cxx | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
New commits:
commit 95a327846aa12474cc982b275a9ad7dec16841b5
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 16:59:45 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/+/117437
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 d36cb3f0ff80..78177ac4b1f8 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -8915,7 +8915,6 @@ class GtkInstanceToggleButton : public GtkInstanceButton, public virtual weld::T
{
protected:
GtkToggleButton* m_pToggleButton;
-private:
gulong m_nToggledSignalId;
static void signalToggled(GtkToggleButton*, gpointer widget)
@@ -9235,7 +9234,9 @@ private:
SolarMutexGuard aGuard;
pThis->signal_toggled();
}
-#else
+#endif
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
static void signalMenuButtonToggled(GtkWidget*, gpointer widget)
{
GtkInstanceMenuButton* pThis = static_cast<GtkInstanceMenuButton*>(widget);
@@ -9499,6 +9500,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)
@@ -9520,6 +9532,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