diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-08-19 16:36:51 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-08-19 21:21:04 +0200 |
commit | 7390c3d4509ccb77f44da5e0eee8e9169026e7d9 (patch) | |
tree | d0c0acc395e0a15ac8b701ad21072d486ad0401a | |
parent | 91b431f88e7abaa3a088b8caf1bdd7e5fe0bf120 (diff) |
Resolves: tdf#127029 keep spinbuttons blank if explicit set_text("")
and the value isn't changed by the user
Change-Id: Ib45360c0a1b057c4a31fe399aada143d758615d1
Reviewed-on: https://gerrit.libreoffice.org/77739
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 97069acbb568..67bdae8b32f1 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -8275,11 +8275,13 @@ private: gulong m_nInputSignalId; bool m_bFormatting; bool m_bBlockOutput; + bool m_bBlank; static void signalValueChanged(GtkSpinButton*, gpointer widget) { GtkInstanceSpinButton* pThis = static_cast<GtkInstanceSpinButton*>(widget); SolarMutexGuard aGuard; + pThis->m_bBlank = false; pThis->signal_value_changed(); } @@ -8335,6 +8337,7 @@ public: , m_nInputSignalId(g_signal_connect(pButton, "input", G_CALLBACK(signalInput), this)) , m_bFormatting(false) , m_bBlockOutput(false) + , m_bBlank(false) { } @@ -8346,6 +8349,7 @@ public: virtual void set_value(int value) override { disable_notify_events(); + m_bBlank = false; gtk_spin_button_set_value(m_pButton, toGtk(value)); enable_notify_events(); } @@ -8353,16 +8357,27 @@ public: 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) { + gtk_entry_set_text(GTK_ENTRY(m_pButton), OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr()); + m_bBlockOutput = true; gtk_spin_button_update(m_pButton); + m_bBlank = rText.isEmpty(); m_bBlockOutput = false; } + else + { + bool bKeepBlank = m_bBlank && get_value() == 0; + if (!bKeepBlank) + { + gtk_entry_set_text(GTK_ENTRY(m_pButton), OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr()); + m_bBlank = false; + } + } enable_notify_events(); } |