[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 19 19:21:55 UTC 2019


 vcl/unx/gtk3/gtk3gtkinst.cxx |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 7390c3d4509ccb77f44da5e0eee8e9169026e7d9
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Aug 19 16:36:51 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Aug 19 21:21:04 2019 +0200

    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 at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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();
     }
 


More information about the Libreoffice-commits mailing list