summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/edje_externals/elm_progressbar.c
diff options
context:
space:
mode:
authorTiago Rezende Campos Falcao <developer@tiagofalcao.com>2010-04-01 14:22:36 +0000
committerTiago Rezende Campos Falcao <developer@tiagofalcao.com>2010-04-01 14:22:36 +0000
commiteb475b53bd9dbb84100cebda1862dcb739a7bdee (patch)
treef6d1d15992b30ef02ef7bc445a0ddc605e8422dd /legacy/elementary/src/edje_externals/elm_progressbar.c
parentc00911ee84f6741cca77a9624e54cbea5b841a90 (diff)
Added get functions in elm progressbar and added elm progressbar support in edje externals.By Fidencio
Author: Fabiano FidĂȘncio <fidencio at profusion.mobi> SVN revision: 47647
Diffstat (limited to 'legacy/elementary/src/edje_externals/elm_progressbar.c')
-rw-r--r--legacy/elementary/src/edje_externals/elm_progressbar.c242
1 files changed, 242 insertions, 0 deletions
diff --git a/legacy/elementary/src/edje_externals/elm_progressbar.c b/legacy/elementary/src/edje_externals/elm_progressbar.c
new file mode 100644
index 0000000..9cb0150
--- /dev/null
+++ b/legacy/elementary/src/edje_externals/elm_progressbar.c
@@ -0,0 +1,242 @@
1#include "private.h"
2
3typedef struct _Elm_Params_Progressbar
4{
5 Elm_Params base;
6 Evas_Object *icon;
7 const char *unit;
8 double value;
9 Evas_Coord span;
10 Eina_Bool value_exists:1;
11 Eina_Bool span_exists:1;
12 Eina_Bool inverted:1;
13 Eina_Bool inverted_exists:1;
14 Eina_Bool horizontal:1;
15 Eina_Bool horizontal_exists:1;
16} Elm_Params_Progressbar;
17
18static void
19external_progressbar_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
20{
21 const Elm_Params_Progressbar *p;
22
23 if (to_params) p = to_params;
24 else if (from_params) p = from_params;
25 else return;
26
27 if (p->base.label)
28 elm_progressbar_label_set(obj, p->base.label);
29 if (p->icon)
30 elm_progressbar_icon_set(obj, p->icon);
31 if (p->span_exists)
32 elm_progressbar_span_size_set(obj, p->span);
33 if (p->value_exists)
34 elm_progressbar_value_set(obj, p->value);
35 if (p->inverted_exists)
36 elm_progressbar_inverted_set(obj, p->inverted);
37 if (p->horizontal_exists)
38 elm_progressbar_horizontal_set(obj, p->horizontal);
39 if (p->unit)
40 elm_progressbar_unit_format_set(obj, p->unit);
41}
42
43static Eina_Bool
44external_progressbar_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
45{
46 if (!strcmp(param->name, "label"))
47 {
48 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
49 {
50 elm_progressbar_label_set(obj, param->s);
51 return EINA_TRUE;
52 }
53 }
54 else if (!strcmp(param->name, "icon"))
55 {
56 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
57 {
58 Evas_Object *icon = external_common_param_icon_get(obj, param);
59 if (icon)
60 {
61 elm_progressbar_icon_set(obj, icon);
62 return EINA_TRUE;
63 }
64 }
65 }
66 else if (!strcmp(param->name, "value"))
67 {
68 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
69 {
70 elm_progressbar_value_set(obj, param->d);
71 return EINA_TRUE;
72 }
73 }
74 else if (!strcmp(param->name, "horizontal"))
75 {
76 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
77 {
78 elm_progressbar_horizontal_set(obj, param->i);
79 return EINA_TRUE;
80 }
81 }
82 else if (!strcmp(param->name, "inverted"))
83 {
84 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
85 {
86 elm_progressbar_inverted_set(obj, param->i);
87 return EINA_TRUE;
88 }
89 }
90 else if (!strcmp(param->name, "span"))
91 {
92 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
93 {
94 elm_progressbar_span_size_set(obj, param->i);
95 return EINA_TRUE;
96 }
97 }
98 else if (!strcmp(param->name, "unit format"))
99 {
100 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
101 {
102 elm_progressbar_unit_format_set(obj, param->s);
103 return EINA_TRUE;
104 }
105 }
106
107 ERR("unknown parameter '%s' of type '%s'",
108 param->name, edje_external_param_type_str(param->type));
109
110 return EINA_FALSE;
111}
112
113static Eina_Bool
114external_progressbar_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
115{
116 if (!strcmp(param->name, "label"))
117 {
118 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
119 {
120 param->s = elm_progressbar_label_get(obj);
121 return EINA_TRUE;
122 }
123 }
124 else if (!strcmp(param->name, "icon"))
125 {
126 /* not easy to get icon name back from live object */
127 return EINA_FALSE;
128 }
129 else if (!strcmp(param->name, "value"))
130 {
131 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
132 {
133 param->d = elm_progressbar_value_get(obj);
134 return EINA_TRUE;
135 }
136 }
137 else if (!strcmp(param->name, "horizontal"))
138 {
139 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
140 {
141 param->i = elm_progressbar_horizontal_get(obj);
142 return EINA_TRUE;
143 }
144 }
145 else if (!strcmp(param->name, "inverted"))
146 {
147 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
148 {
149 param->i = elm_progressbar_inverted_get(obj);
150 return EINA_TRUE;
151 }
152 }
153 else if (!strcmp(param->name, "span"))
154 {
155 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
156 {
157 param->i = elm_progressbar_span_size_get(obj);
158 return EINA_TRUE;
159 }
160 }
161 else if (!strcmp(param->name, "unit format"))
162 {
163 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
164 {
165 param->s = elm_progressbar_unit_format_get(obj);
166 return EINA_TRUE;
167 }
168 }
169
170 ERR("unknown parameter '%s' of type '%s'",
171 param->name, edje_external_param_type_str(param->type));
172
173 return EINA_FALSE;
174}
175
176static void *
177external_progressbar_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
178{
179 Elm_Params_Progressbar *mem;
180 Edje_External_Param *param;
181 const Eina_List *l;
182
183 mem = external_common_params_parse(Elm_Params_Progressbar, data, obj, params);
184 if (!mem)
185 return NULL;
186
187 external_common_icon_param_parse(&mem->icon, obj, params);
188
189 EINA_LIST_FOREACH(params, l, param)
190 {
191 if (!strcmp(param->name, "span"))
192 {
193 mem->span = param->i;
194 mem->span_exists = EINA_TRUE;
195 }
196 else if (!strcmp(param->name, "value"))
197 {
198 mem->value = param->d;
199 mem->value_exists = EINA_TRUE;
200 }
201 else if (!strcmp(param->name, "inverted"))
202 {
203 mem->inverted = !!param->i;
204 mem->inverted_exists = EINA_TRUE;
205 }
206 else if (!strcmp(param->name, "horizontal"))
207 {
208 mem->horizontal = !!param->i;
209 mem->horizontal_exists = EINA_TRUE;
210 }
211 else if (!strcmp(param->name, "unit format"))
212 mem->unit = eina_stringshare_add(param->s);
213 }
214
215 return mem;
216}
217
218static void
219external_progressbar_params_free(void *params)
220{
221 Elm_Params_Progressbar *mem = params;
222
223 if (mem->icon)
224 evas_object_del(mem->icon);
225 if (mem->unit)
226 eina_stringshare_del(mem->unit);
227 external_common_params_free(params);
228}
229
230static Edje_External_Param_Info external_progressbar_params[] = {
231 DEFINE_EXTERNAL_COMMON_PARAMS,
232 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
233 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("value"),
234 EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal"),
235 EDJE_EXTERNAL_PARAM_INFO_BOOL("inverted"),
236 EDJE_EXTERNAL_PARAM_INFO_INT("span"),
237 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("unit format", "%1.2f"),
238 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
239};
240
241DEFINE_EXTERNAL_ICON_ADD(progressbar, "progressbar")
242DEFINE_EXTERNAL_TYPE_SIMPLE(progressbar, "Progressbar")