diff options
author | woochan lee <wc0917.lee@samsung.com> | 2015-08-07 16:58:54 +0900 |
---|---|---|
committer | ChunEon Park <hermet@hermet.pe.kr> | 2015-08-07 17:02:39 +0900 |
commit | 2686516f3c46af8ec5339dd00f9d1b42cce66d6c (patch) | |
tree | 85791e954148b37779bfc66e7d1ddb8d4c709bdd | |
parent | 6e5c7506c73cc00018eb44096c2c5634b690b165 (diff) | |
download | elementary-2686516f3c46af8ec5339dd00f9d1b42cce66d6c.tar.gz |
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
-rw-r--r-- | src/lib/elm_spinner.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/lib/elm_spinner.c b/src/lib/elm_spinner.c index 255135f25..2130ffe0d 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); |