vcl/unx/gtk3/gtk3gtkinst.cxx | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
New commits: commit a7037b4651a10a220eeae8d9e97dc6b97e506cc5 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Jan 17 17:31:16 2019 +0000 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Jan 25 09:25:08 2019 +0100 Related: tdf#122786 update value when spinbutton text explicitly set Change-Id: Idb6fefe08dc7cbf4d0b73485e0b1471fe0494364 Reviewed-on: https://gerrit.libreoffice.org/66604 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 08fc49de25e5..bdfee6ede884 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -5710,6 +5710,8 @@ private: gulong m_nValueChangedSignalId; gulong m_nOutputSignalId; gulong m_nInputSignalId; + bool m_bFormatting; + bool m_bBlockOutput; static void signalValueChanged(GtkSpinButton*, gpointer widget) { @@ -5718,11 +5720,21 @@ private: pThis->signal_value_changed(); } + bool guarded_signal_output() + { + if (m_bBlockOutput) + return true; + m_bFormatting = true; + bool bRet = signal_output(); + m_bFormatting = false; + return bRet; + } + static gboolean signalOutput(GtkSpinButton*, gpointer widget) { GtkInstanceSpinButton* pThis = static_cast<GtkInstanceSpinButton*>(widget); SolarMutexGuard aGuard; - return pThis->signal_output(); + return pThis->guarded_signal_output(); } static gint signalInput(GtkSpinButton*, gdouble* new_value, gpointer widget) @@ -5758,6 +5770,8 @@ public: , m_nValueChangedSignalId(g_signal_connect(pButton, "value-changed", G_CALLBACK(signalValueChanged), this)) , m_nOutputSignalId(g_signal_connect(pButton, "output", G_CALLBACK(signalOutput), this)) , m_nInputSignalId(g_signal_connect(pButton, "input", G_CALLBACK(signalInput), this)) + , m_bFormatting(false) + , m_bBlockOutput(false) { } @@ -5773,6 +5787,22 @@ public: enable_notify_events(); } + virtual void set_text(const OUString& rText) override + { + disable_notify_events(); + gtk_entry_set_text(GTK_ENTRY(m_pButton), OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr()); + // tdf#122786 if we're just formatting a value, then we're done, + // however if set_text has been called directly we want to update our + // value from this new text, but don't want to reformat with that value + if (!m_bFormatting) + { + m_bBlockOutput = true; + gtk_spin_button_update(m_pButton); + m_bBlockOutput = false; + } + enable_notify_events(); + } + virtual void set_range(int min, int max) override { disable_notify_events(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits