5 typedef struct _Elm_Params_Icon
8 Eina_Bool scale_up_exists;
9 Eina_Bool scale_up : 1;
10 Eina_Bool scale_down_exists;
11 Eina_Bool scale_down : 1;
12 Eina_Bool smooth_exists;
14 Eina_Bool fill_outside_exists;
15 Eina_Bool fill_outside : 1;
16 Eina_Bool no_scale_exists;
17 Eina_Bool no_scale : 1;
18 Eina_Bool prescale_size_exists;
22 static Elm_Params_Icon *param_icon;
25 external_icon_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
27 const Elm_Params_Icon *p;
29 if (to_params) p = to_params;
30 else if (from_params) p = from_params;
35 elm_icon_file_set(obj, p->file, NULL);
36 param_icon->file = p->file;
40 elm_icon_smooth_set(obj, p->smooth);
41 param_icon->smooth = p->smooth;
43 if (p->no_scale_exists)
45 elm_icon_no_scale_set(obj, p->no_scale);
46 param_icon->no_scale = p->no_scale;
48 if (p->scale_up_exists && p->scale_down_exists)
50 elm_icon_scale_set(obj, p->scale_up, p->scale_down);
51 param_icon->scale_up = p->scale_up;
52 param_icon->scale_down = p->scale_down;
54 else if (p->scale_up_exists || p->scale_down_exists)
56 if (p->scale_up_exists)
58 elm_icon_scale_set(obj, p->scale_up, param_icon->scale_down);
59 param_icon->scale_up = p->scale_up;
63 elm_icon_scale_set(obj, param_icon->scale_up, p->scale_down);
64 param_icon->scale_down = p->scale_down;
67 if (p->fill_outside_exists)
69 elm_icon_fill_outside_set(obj, p->fill_outside);
70 param_icon->fill_outside = p->fill_outside;
72 if (p->prescale_size_exists)
74 elm_icon_prescale_set(obj, p->prescale_size);
75 param_icon->prescale_size = p->prescale_size;
80 external_icon_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
82 if (!strcmp(param->name, "file")
83 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
85 Eina_Bool ret = elm_icon_file_set(obj, param->s, NULL);
87 param_icon->file = param->s;
90 else if (!strcmp(param->name, "smooth")
91 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
93 elm_icon_smooth_set(obj, param->i);
94 param_icon->smooth = param->i;
97 else if (!strcmp(param->name, "no scale")
98 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
100 elm_icon_no_scale_set(obj, param->i);
101 param_icon->no_scale = param->i;
104 else if (!strcmp(param->name, "scale up")
105 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
107 elm_icon_scale_set(obj, param->i, param_icon->scale_down);
108 param_icon->scale_up = param->i;
111 else if (!strcmp(param->name, "scale down")
112 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
114 elm_icon_scale_set(obj, param_icon->scale_up, param->i);
115 param_icon->scale_down = param->i;
118 else if (!strcmp(param->name, "fill outside")
119 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
121 elm_icon_fill_outside_set(obj, param->i);
122 param_icon->fill_outside = param->i;
125 else if (!strcmp(param->name, "prescale")
126 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
128 elm_icon_prescale_set(obj, param->d);
129 param_icon->prescale_size = param->d;
133 ERR("unknown parameter '%s' of type '%s'",
134 param->name, edje_external_param_type_str(param->type));
140 external_icon_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
142 if (!strcmp(param->name, "file")
143 && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
145 param->s = param_icon->file;
148 else if (!strcmp(param->name, "smooth")
149 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
151 param->i = param_icon->smooth;
154 else if (!strcmp(param->name, "no scale")
155 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
157 param->i = param_icon->no_scale;
160 else if (!strcmp(param->name, "scale up")
161 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
163 param->i = param_icon->scale_up;
166 else if (!strcmp(param->name, "scale down")
167 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
169 param->i = param_icon->scale_down;
172 else if (!strcmp(param->name, "fill outside")
173 && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
175 param->i = param_icon->fill_outside;
178 else if (!strcmp(param->name, "prescale")
179 && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
181 param->d = param_icon->prescale_size;
185 ERR("unknown parameter '%s' of type '%s'",
186 param->name, edje_external_param_type_str(param->type));
192 external_icon_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
194 Elm_Params_Icon *mem;
195 Edje_External_Param *param;
198 param_icon = calloc(1, sizeof(Elm_Params_Icon));
200 mem = calloc(1, sizeof(Elm_Params_Icon));
204 EINA_LIST_FOREACH(params, l, param)
206 if (!strcmp(param->name, "file"))
207 mem->file = eina_stringshare_add(param->s);
208 else if (!strcmp(param->name, "smooth"))
210 mem->smooth = param->i;
211 mem->smooth_exists = EINA_TRUE;
213 else if (!strcmp(param->name, "no scale"))
215 mem->no_scale = param->i;
216 mem->no_scale_exists = EINA_TRUE;
218 else if (!strcmp(param->name, "scale up"))
220 mem->scale_up = param->i;
221 mem->scale_up_exists = EINA_TRUE;
223 else if (!strcmp(param->name, "scale down"))
225 mem->scale_down = param->i;
226 mem->scale_down_exists = EINA_TRUE;
228 else if (!strcmp(param->name, "fill outside"))
230 mem->fill_outside = param->i;
231 mem->fill_outside_exists = EINA_TRUE;
233 else if (!strcmp(param->name, "prescale"))
235 mem->prescale_size = param->d;
236 mem->prescale_size_exists = EINA_TRUE;
243 static Evas_Object *external_icon_content_get(void *data __UNUSED__,
244 const Evas_Object *obj, const char *content)
251 external_icon_params_free(void *params)
253 Elm_Params_Icon *mem = params;
256 eina_stringshare_del(mem->file);
259 if (param_icon->file)
260 eina_stringshare_del(param_icon->file);
264 static Edje_External_Param_Info external_icon_params[] = {
265 EDJE_EXTERNAL_PARAM_INFO_STRING("file"),
266 EDJE_EXTERNAL_PARAM_INFO_BOOL("smooth"),
267 EDJE_EXTERNAL_PARAM_INFO_BOOL("no scale"),
268 EDJE_EXTERNAL_PARAM_INFO_BOOL("scale up"),
269 EDJE_EXTERNAL_PARAM_INFO_BOOL("scale down"),
270 EDJE_EXTERNAL_PARAM_INFO_BOOL("fill outside"),
271 EDJE_EXTERNAL_PARAM_INFO_INT("prescale"),
272 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
275 DEFINE_EXTERNAL_ICON_ADD(icon, "icon");
276 DEFINE_EXTERNAL_TYPE_SIMPLE(icon, "Icon");