vcl/unx/gtk3/gtk3gtkinst.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
New commits: commit ac513ca0e0731753823a8a2b27d692b01b804d01 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Jan 17 17:31:16 2019 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Jan 18 13:31:30 2019 +0100 Related: tdf#122786 update value when spinbutton text explicitly set Change-Id: Idb6fefe08dc7cbf4d0b73485e0b1471fe0494364 Reviewed-on: https://gerrit.libreoffice.org/66544 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 8895d1184739..ccbd44ce7ad6 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -5748,6 +5748,7 @@ private: gulong m_nValueChangedSignalId; gulong m_nOutputSignalId; gulong m_nInputSignalId; + bool m_bFormatting; static void signalValueChanged(GtkSpinButton*, gpointer widget) { @@ -5756,11 +5757,19 @@ private: pThis->signal_value_changed(); } + bool guarded_signal_output() + { + 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) @@ -5796,6 +5805,7 @@ 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) { } @@ -5811,6 +5821,18 @@ 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 + if (!m_bFormatting) + gtk_spin_button_update(m_pButton); + enable_notify_events(); + } + virtual void set_range(int min, int max) override { disable_notify_events(); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
