hermet pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=2686516f3c46af8ec5339dd00f9d1b42cce66d6c

commit 2686516f3c46af8ec5339dd00f9d1b42cce66d6c
Author: woochan lee <wc0917....@samsung.com>
Date:   Fri Aug 7 16:58:54 2015 +0900

    spinner: Add to support spinner value %d format.
    
    Summary:
    When user set min max as 50, 150 with %d format, then value set as 100.
    The spinner value set as '0'
    Because the sd->val type is double.
    Spinner entry has same problem.
    
    @fix
    
    Test Plan:
    Set spinner format as %d.
    Check the spinner value.
    It's not supported.
    
    Reviewers: Jaehyun_Cho, cedric, Hermet
    
    Reviewed By: Hermet
    
    Differential Revision: https://phab.enlightenment.org/D2898
    
    Conflicts:
    
        src/lib/elm_spinner.c
---
 src/lib/elm_spinner.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/lib/elm_spinner.c b/src/lib/elm_spinner.c
index 255135f..2130ffe 100644
--- a/src/lib/elm_spinner.c
+++ b/src/lib/elm_spinner.c
@@ -50,6 +50,24 @@ static const Elm_Action key_actions[] = {
 static void _access_increment_decrement_info_say(Evas_Object *obj,
                                                  Eina_Bool is_incremented);
 
+static Eina_Bool
+_is_label_format_integer(const char *fmt)
+{
+   const char *start = strchr(fmt, '%');
+   const char *itr;
+
+   for (itr = start + 1; *itr != '\0'; itr++)
+     {
+        if ((*itr == 'd') || (*itr == 'u') || (*itr == 'i') ||
+            (*itr == 'o') || (*itr == 'x') || (*itr == 'X'))
+          return EINA_TRUE;
+        else if ((*itr == 'f'))
+          return EINA_FALSE;
+     }
+
+   return EINA_FALSE;
+}
+
 static void
 _entry_show(Elm_Spinner_Data *sd)
 {
@@ -100,9 +118,13 @@ _entry_show(Elm_Spinner_Data *sd)
                }
           }
      }
-   snprintf(buf, sizeof(buf), fmt, sd->val);
 
 apply:
+   if (_is_label_format_integer(fmt))
+     snprintf(buf, sizeof(buf), fmt, (int)sd->val);
+   else
+     snprintf(buf, sizeof(buf), fmt, sd->val);
+
    elm_object_text_set(sd->ent, buf);
 }
 
@@ -125,7 +147,12 @@ _label_write(Evas_Object *obj)
      }
 
    if (sd->label)
-     snprintf(buf, sizeof(buf), sd->label, sd->val);
+     {
+        if (_is_label_format_integer(sd->label))
+          snprintf(buf, sizeof(buf), sd->label, (int)sd->val);
+        else
+          snprintf(buf, sizeof(buf), sd->label, sd->val);
+     }
    else
      snprintf(buf, sizeof(buf), "%.0f", sd->val);
 

-- 


Reply via email to