summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwoochan lee <wc0917.lee@samsung.com>2015-08-07 16:58:54 +0900
committerChunEon Park <hermet@hermet.pe.kr>2015-08-07 17:02:39 +0900
commit2686516f3c46af8ec5339dd00f9d1b42cce66d6c (patch)
tree85791e954148b37779bfc66e7d1ddb8d4c709bdd
parent6e5c7506c73cc00018eb44096c2c5634b690b165 (diff)
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.c31
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[] = {
50static void _access_increment_decrement_info_say(Evas_Object *obj, 50static void _access_increment_decrement_info_say(Evas_Object *obj,
51 Eina_Bool is_incremented); 51 Eina_Bool is_incremented);
52 52
53static Eina_Bool
54_is_label_format_integer(const char *fmt)
55{
56 const char *start = strchr(fmt, '%');
57 const char *itr;
58
59 for (itr = start + 1; *itr != '\0'; itr++)
60 {
61 if ((*itr == 'd') || (*itr == 'u') || (*itr == 'i') ||
62 (*itr == 'o') || (*itr == 'x') || (*itr == 'X'))
63 return EINA_TRUE;
64 else if ((*itr == 'f'))
65 return EINA_FALSE;
66 }
67
68 return EINA_FALSE;
69}
70
53static void 71static void
54_entry_show(Elm_Spinner_Data *sd) 72_entry_show(Elm_Spinner_Data *sd)
55{ 73{
@@ -100,9 +118,13 @@ _entry_show(Elm_Spinner_Data *sd)
100 } 118 }
101 } 119 }
102 } 120 }
103 snprintf(buf, sizeof(buf), fmt, sd->val);
104 121
105apply: 122apply:
123 if (_is_label_format_integer(fmt))
124 snprintf(buf, sizeof(buf), fmt, (int)sd->val);
125 else
126 snprintf(buf, sizeof(buf), fmt, sd->val);
127
106 elm_object_text_set(sd->ent, buf); 128 elm_object_text_set(sd->ent, buf);
107} 129}
108 130
@@ -125,7 +147,12 @@ _label_write(Evas_Object *obj)
125 } 147 }
126 148
127 if (sd->label) 149 if (sd->label)
128 snprintf(buf, sizeof(buf), sd->label, sd->val); 150 {
151 if (_is_label_format_integer(sd->label))
152 snprintf(buf, sizeof(buf), sd->label, (int)sd->val);
153 else
154 snprintf(buf, sizeof(buf), sd->label, sd->val);
155 }
129 else 156 else
130 snprintf(buf, sizeof(buf), "%.0f", sd->val); 157 snprintf(buf, sizeof(buf), "%.0f", sd->val);
131 158