[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 29 07:41:31 UTC 2019


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

New commits:
commit b29764bab932d1a5a2912c87342b743968360206
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Aug 19 16:36:51 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Aug 29 09:40:55 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/77744
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index ded420efe39d..b044152e9355 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -8198,11 +8198,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();
     }
 
@@ -8258,6 +8260,7 @@ public:
         , m_nInputSignalId(g_signal_connect(pButton, "input", G_CALLBACK(signalInput), this))
         , m_bFormatting(false)
         , m_bBlockOutput(false)
+        , m_bBlank(false)
     {
     }
 
@@ -8269,6 +8272,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();
     }
@@ -8276,16 +8280,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