4 typedef struct _Elm_Params_Icon
7 Eina_Bool scale_up_exists;
8 Eina_Bool scale_up : 1;
9 Eina_Bool scale_down_exists;
10 Eina_Bool scale_down : 1;
11 Eina_Bool smooth_exists;
13 Eina_Bool fill_outside_exists;
14 Eina_Bool fill_outside : 1;
15 Eina_Bool no_scale_exists;
16 Eina_Bool no_scale : 1;
17 Eina_Bool prescale_size_exists;
23 static Elm_Params_Icon *param_icon;
26 external_icon_state_set(void *data __UNUSED__, Evas_Object *obj,
27 const void *from_params, const void *to_params,
30 const Elm_Params_Icon *p;
34 if (to_params) p = to_params;
35 else if (from_params) p = from_params;
40 elm_icon_file_set(obj, p->file, NULL);
41 param_icon->file = p->file;
45 elm_icon_smooth_set(obj, p->smooth);
46 param_icon->smooth = p->smooth;
48 if (p->no_scale_exists)
50 elm_icon_no_scale_set(obj, p->no_scale);
51 param_icon->no_scale = p->no_scale;
53 if (p->scale_up_exists && p->scale_down_exists)
55 elm_icon_resizable_set(obj, p->scale_up, p->scale_down);
56 param_icon->scale_up = p->scale_up;
57 param_icon->scale_down = p->scale_down;
59 else if (p->scale_up_exists || p->scale_down_exists)
61 if (p->scale_up_exists)
63 elm_icon_resizable_set(obj, p->scale_up, param_icon->scale_down);
64 param_icon->scale_up = p->scale_up;
68 elm_icon_resizable_set(obj, param_icon->scale_up, p->scale_down);
69 param_icon->scale_down = p->scale_down;
72 if (p->fill_outside_exists)
74 elm_icon_fill_outside_set(obj, p->fill_outside);
75 param_icon->fill_outside = p->fill_outside;
77 if (p->prescale_size_exists)
79 elm_icon_prescale_set(obj, p->prescale_size);
80 param_icon->prescale_size = p->prescale_size;
84 edje = evas_object_smart_parent_get(obj);
85 edje_object_file_get(edje, &file, NULL);
87 if (!elm_icon_file_set(obj, file, p->icon))
88 elm_icon_standard_set(obj, p->icon);
93 external_icon_param_set(void *data __UNUSED__, Evas_Object *obj,
94 const Edje_External_Param *param)
99 if (!strcmp(param->name, "file")
100 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
102 Eina_Bool ret = elm_icon_file_set(obj, param->s, NULL);
104 param_icon->file = param->s;
107 else if (!strcmp(param->name, "smooth")
108 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
110 elm_icon_smooth_set(obj, param->i);
111 param_icon->smooth = param->i;
114 else if (!strcmp(param->name, "no scale")
115 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
117 elm_icon_no_scale_set(obj, param->i);
118 param_icon->no_scale = param->i;
121 else if (!strcmp(param->name, "scale up")
122 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
124 elm_icon_resizable_set(obj, param->i, param_icon->scale_down);
125 param_icon->scale_up = param->i;
128 else if (!strcmp(param->name, "scale down")
129 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
131 elm_icon_resizable_set(obj, param_icon->scale_up, param->i);
132 param_icon->scale_down = param->i;
135 else if (!strcmp(param->name, "fill outside")
136 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
138 elm_icon_fill_outside_set(obj, param->i);
139 param_icon->fill_outside = param->i;
142 else if (!strcmp(param->name, "prescale")
143 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
145 elm_icon_prescale_set(obj, param->i);
146 param_icon->prescale_size = param->i;
149 else if (!strcmp(param->name, "icon"))
151 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
153 edje = evas_object_smart_parent_get(obj);
154 edje_object_file_get(edje, &file, NULL);
156 if (!elm_icon_file_set(obj, file, param->s))
157 elm_icon_standard_set(obj, param->s);
162 ERR("unknown parameter '%s' of type '%s'",
163 param->name, edje_external_param_type_str(param->type));
169 external_icon_param_get(void *data __UNUSED__,
170 const Evas_Object *obj __UNUSED__,
171 Edje_External_Param *param)
173 if (!strcmp(param->name, "file")
174 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
176 param->s = param_icon->file;
179 else if (!strcmp(param->name, "smooth")
180 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
182 param->i = param_icon->smooth;
185 else if (!strcmp(param->name, "no scale")
186 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
188 param->i = param_icon->no_scale;
191 else if (!strcmp(param->name, "scale up")
192 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
194 param->i = param_icon->scale_up;
197 else if (!strcmp(param->name, "scale down")
198 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
200 param->i = param_icon->scale_down;
203 else if (!strcmp(param->name, "fill outside")
204 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
206 param->i = param_icon->fill_outside;
209 else if (!strcmp(param->name, "prescale")
210 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
212 param->i = param_icon->prescale_size;
215 else if (!strcmp(param->name, "icon"))
217 /* not easy to get icon name back from live object */
221 ERR("unknown parameter '%s' of type '%s'",
222 param->name, edje_external_param_type_str(param->type));
228 external_icon_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
229 const Eina_List *params)
231 Elm_Params_Icon *mem;
232 Edje_External_Param *param;
234 param_icon = calloc(1, sizeof(Elm_Params_Icon));
235 mem = ELM_NEW(Elm_Params_Icon);
239 EINA_LIST_FOREACH(params, l, param)
241 if (!strcmp(param->name, "file"))
242 mem->file = eina_stringshare_add(param->s);
243 else if (!strcmp(param->name, "smooth"))
245 mem->smooth = param->i;
246 mem->smooth_exists = EINA_TRUE;
248 else if (!strcmp(param->name, "no scale"))
250 mem->no_scale = param->i;
251 mem->no_scale_exists = EINA_TRUE;
253 else if (!strcmp(param->name, "scale up"))
255 mem->scale_up = param->i;
256 mem->scale_up_exists = EINA_TRUE;
258 else if (!strcmp(param->name, "scale down"))
260 mem->scale_down = param->i;
261 mem->scale_down_exists = EINA_TRUE;
263 else if (!strcmp(param->name, "fill outside"))
265 mem->fill_outside = param->i;
266 mem->fill_outside_exists = EINA_TRUE;
268 else if (!strcmp(param->name, "prescale"))
270 mem->prescale_size = param->i;
271 mem->prescale_size_exists = EINA_TRUE;
273 else if (!strcmp(param->name, "icon"))
275 mem->icon = eina_stringshare_add(param->s);
283 external_icon_content_get(void *data __UNUSED__,
284 const Evas_Object *obj __UNUSED__,
285 const char *content __UNUSED__)
292 external_icon_params_free(void *params)
294 Elm_Params_Icon *mem = params;
297 eina_stringshare_del(mem->file);
299 if (param_icon->file)
300 eina_stringshare_del(param_icon->file);
304 eina_stringshare_del(mem->icon);
308 static Edje_External_Param_Info external_icon_params[] = {
309 DEFINE_EXTERNAL_COMMON_PARAMS,
310 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
311 EDJE_EXTERNAL_PARAM_INFO_STRING("file"),
312 EDJE_EXTERNAL_PARAM_INFO_BOOL("smooth"),
313 EDJE_EXTERNAL_PARAM_INFO_BOOL("no scale"),
314 EDJE_EXTERNAL_PARAM_INFO_BOOL("scale up"),
315 EDJE_EXTERNAL_PARAM_INFO_BOOL("scale down"),
316 EDJE_EXTERNAL_PARAM_INFO_BOOL("fill outside"),
317 EDJE_EXTERNAL_PARAM_INFO_INT("prescale"),
318 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
321 DEFINE_EXTERNAL_ICON_ADD(icon, "icon");
322 DEFINE_EXTERNAL_TYPE_SIMPLE(icon, "Icon");