5 typedef struct _Elm_Params_Toggle
12 Eina_Bool state_exists:1;
16 external_toggle_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
18 const Elm_Params_Toggle *p;
20 if (to_params) p = to_params;
21 else if (from_params) p = from_params;
25 elm_object_text_set(obj, p->label);
27 elm_toggle_icon_set(obj, p->icon);
29 if ((p->on) && (p->off))
30 elm_toggle_states_labels_set(obj, p->on, p->off);
31 else if ((p->on) || (p->off))
34 elm_toggle_states_labels_get(obj, &on, &off);
36 elm_toggle_states_labels_set(obj, p->on, off);
38 elm_toggle_states_labels_set(obj, on, p->off);
42 elm_toggle_state_set(obj, p->state);
46 external_toggle_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
48 if (!strcmp(param->name, "label"))
50 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
52 elm_object_text_set(obj, param->s);
56 else if (!strcmp(param->name, "icon"))
58 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
60 Evas_Object *icon = external_common_param_icon_get(obj, param);
61 if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
62 elm_toggle_icon_set(obj, icon);
66 else if (!strcmp(param->name, "label on"))
68 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
71 elm_toggle_states_labels_get(obj, &on, &off);
72 elm_toggle_states_labels_set(obj, param->s, off);
76 else if (!strcmp(param->name, "label off"))
78 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
81 elm_toggle_states_labels_get(obj, &on, &off);
82 elm_toggle_states_labels_set(obj, on, param->s);
86 else if (!strcmp(param->name, "state"))
88 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
90 elm_toggle_state_set(obj, param->i);
95 ERR("unknown parameter '%s' of type '%s'",
96 param->name, edje_external_param_type_str(param->type));
102 external_toggle_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
104 if (!strcmp(param->name, "label"))
106 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
108 param->s = elm_object_text_get(obj);
112 else if (!strcmp(param->name, "icon"))
114 /* not easy to get icon name back from live object */
117 else if (!strcmp(param->name, "label on"))
119 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
121 const char *on, *off;
122 elm_toggle_states_labels_get(obj, &on, &off);
127 else if (!strcmp(param->name, "label off"))
129 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
131 const char *on, *off;
132 elm_toggle_states_labels_get(obj, &on, &off);
137 else if (!strcmp(param->name, "state"))
139 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
141 param->i = elm_toggle_state_get(obj);
146 ERR("unknown parameter '%s' of type '%s'",
147 param->name, edje_external_param_type_str(param->type));
153 external_toggle_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
155 Elm_Params_Toggle *mem;
156 Edje_External_Param *param;
159 mem = calloc(1, sizeof(Elm_Params_Toggle));
163 external_common_icon_param_parse(&mem->icon, obj, params);
165 EINA_LIST_FOREACH(params, l, param)
167 if (!strcmp(param->name, "state")) {
168 mem->state = param->i;
169 mem->state_exists = EINA_TRUE;
171 else if (!strcmp(param->name, "label on"))
172 mem->on = eina_stringshare_add(param->s);
173 else if (!strcmp(param->name, "label off"))
174 mem->off = eina_stringshare_add(param->s);
180 static Evas_Object *external_toggle_content_get(void *data __UNUSED__,
181 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
188 external_toggle_params_free(void *params)
190 Elm_Params_Toggle *mem = params;
193 eina_stringshare_del(mem->on);
195 eina_stringshare_del(mem->off);
197 eina_stringshare_del(mem->label);
201 static Edje_External_Param_Info external_toggle_params[] = {
202 DEFINE_EXTERNAL_COMMON_PARAMS,
203 EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
204 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
205 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("label on", "ON"),
206 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("label off", "OFF"),
207 EDJE_EXTERNAL_PARAM_INFO_BOOL("state"),
208 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
211 DEFINE_EXTERNAL_ICON_ADD(toggle, "toggle")
212 DEFINE_EXTERNAL_TYPE_SIMPLE(toggle, "Toggle")