5 typedef struct _Elm_Params_Toggle
11 Eina_Bool state_exists:1;
15 external_toggle_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
17 const Elm_Params_Toggle *p;
19 if (to_params) p = to_params;
20 else if (from_params) p = from_params;
24 elm_toggle_label_set(obj, p->base.label);
26 elm_toggle_icon_set(obj, p->icon);
28 if ((p->on) && (p->off))
29 elm_toggle_states_labels_set(obj, p->on, p->off);
30 else if ((p->on) || (p->off))
33 elm_toggle_states_labels_get(obj, &on, &off);
35 elm_toggle_states_labels_set(obj, p->on, off);
37 elm_toggle_states_labels_set(obj, on, p->off);
41 elm_toggle_state_set(obj, p->state);
45 external_toggle_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
47 if (!strcmp(param->name, "label"))
49 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
51 elm_toggle_label_set(obj, param->s);
55 else if (!strcmp(param->name, "icon"))
57 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
59 Evas_Object *icon = external_common_param_icon_get(obj, param);
60 if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
61 elm_toggle_icon_set(obj, icon);
65 else if (!strcmp(param->name, "label on"))
67 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
70 elm_toggle_states_labels_get(obj, &on, &off);
71 elm_toggle_states_labels_set(obj, param->s, off);
75 else if (!strcmp(param->name, "label off"))
77 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
80 elm_toggle_states_labels_get(obj, &on, &off);
81 elm_toggle_states_labels_set(obj, on, param->s);
85 else if (!strcmp(param->name, "state"))
87 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
89 elm_toggle_state_set(obj, param->i);
94 ERR("unknown parameter '%s' of type '%s'",
95 param->name, edje_external_param_type_str(param->type));
101 external_toggle_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
103 if (!strcmp(param->name, "label"))
105 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
107 param->s = elm_toggle_label_get(obj);
111 else if (!strcmp(param->name, "icon"))
113 /* not easy to get icon name back from live object */
116 else if (!strcmp(param->name, "label on"))
118 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
120 const char *on, *off;
121 elm_toggle_states_labels_get(obj, &on, &off);
126 else if (!strcmp(param->name, "label off"))
128 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
130 const char *on, *off;
131 elm_toggle_states_labels_get(obj, &on, &off);
136 else if (!strcmp(param->name, "state"))
138 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
140 param->i = elm_toggle_state_get(obj);
145 ERR("unknown parameter '%s' of type '%s'",
146 param->name, edje_external_param_type_str(param->type));
152 external_toggle_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
154 Elm_Params_Toggle *mem;
155 Edje_External_Param *param;
158 mem = external_common_params_parse(Elm_Params_Toggle, data, obj, params);
162 external_common_icon_param_parse(&mem->icon, obj, params);
164 EINA_LIST_FOREACH(params, l, param)
166 if (!strcmp(param->name, "state")) {
167 mem->state = param->i;
168 mem->state_exists = EINA_TRUE;
170 else if (!strcmp(param->name, "label on"))
171 mem->on = eina_stringshare_add(param->s);
172 else if (!strcmp(param->name, "label off"))
173 mem->off = eina_stringshare_add(param->s);
179 static Evas_Object *external_toggle_content_get(void *data __UNUSED__,
180 const Evas_Object *obj, const char *content)
187 external_toggle_params_free(void *params)
189 Elm_Params_Toggle *mem = params;
192 eina_stringshare_del(mem->on);
194 eina_stringshare_del(mem->off);
195 external_common_params_free(params);
198 static Edje_External_Param_Info external_toggle_params[] = {
199 DEFINE_EXTERNAL_COMMON_PARAMS,
200 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
201 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("label on", "ON"),
202 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("label off", "OFF"),
203 EDJE_EXTERNAL_PARAM_INFO_BOOL("state"),
204 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
207 DEFINE_EXTERNAL_ICON_ADD(toggle, "toggle")
208 DEFINE_EXTERNAL_TYPE_SIMPLE(toggle, "Toggle")