hermet pushed a commit to branch elementary-1.15. http://git.enlightenment.org/core/elementary.git/commit/?id=093765d1e8bb7402e2ee96a619a687c97ab5ad7a
commit 093765d1e8bb7402e2ee96a619a687c97ab5ad7a 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 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 9fc90a2..1903cf9 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) { @@ -90,7 +108,11 @@ _entry_show(Elm_Spinner_Data *sd) } } } - snprintf(buf, sizeof(buf), fmt, sd->val); + 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); } @@ -113,7 +135,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); --