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_object_content_part_set(obj, "icon", p->icon);
30 elm_object_text_part_set(obj, "on", p->on);
32 elm_object_text_part_set(obj, "off", p->off);
35 elm_toggle_state_set(obj, p->state);
39 external_toggle_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
41 if (!strcmp(param->name, "label"))
43 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
45 elm_object_text_set(obj, param->s);
49 else if (!strcmp(param->name, "icon"))
51 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
53 Evas_Object *icon = external_common_param_icon_get(obj, param);
54 if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
55 elm_object_content_part_set(obj, "icon", icon);
59 else if (!strcmp(param->name, "label on"))
61 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
63 elm_object_text_part_set(obj, "on", param->s);
67 else if (!strcmp(param->name, "label off"))
69 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
71 elm_object_text_part_set(obj, "off", param->s);
75 else if (!strcmp(param->name, "state"))
77 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
79 elm_toggle_state_set(obj, param->i);
84 ERR("unknown parameter '%s' of type '%s'",
85 param->name, edje_external_param_type_str(param->type));
91 external_toggle_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
93 if (!strcmp(param->name, "label"))
95 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
97 param->s = elm_object_text_get(obj);
101 else if (!strcmp(param->name, "icon"))
103 /* not easy to get icon name back from live object */
106 else if (!strcmp(param->name, "label on"))
108 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
110 param->s = elm_object_text_part_get(obj, "on");
114 else if (!strcmp(param->name, "label off"))
116 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
118 param->s = elm_object_text_part_get(obj, "off");
122 else if (!strcmp(param->name, "state"))
124 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
126 param->i = elm_toggle_state_get(obj);
131 ERR("unknown parameter '%s' of type '%s'",
132 param->name, edje_external_param_type_str(param->type));
138 external_toggle_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
140 Elm_Params_Toggle *mem;
141 Edje_External_Param *param;
144 mem = calloc(1, sizeof(Elm_Params_Toggle));
148 external_common_icon_param_parse(&mem->icon, obj, params);
150 EINA_LIST_FOREACH(params, l, param)
152 if (!strcmp(param->name, "state")) {
153 mem->state = param->i;
154 mem->state_exists = EINA_TRUE;
156 else if (!strcmp(param->name, "label on"))
157 mem->on = eina_stringshare_add(param->s);
158 else if (!strcmp(param->name, "label off"))
159 mem->off = eina_stringshare_add(param->s);
165 static Evas_Object *external_toggle_content_get(void *data __UNUSED__,
166 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
173 external_toggle_params_free(void *params)
175 Elm_Params_Toggle *mem = params;
178 eina_stringshare_del(mem->on);
180 eina_stringshare_del(mem->off);
182 eina_stringshare_del(mem->label);
186 static Edje_External_Param_Info external_toggle_params[] = {
187 DEFINE_EXTERNAL_COMMON_PARAMS,
188 EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
189 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
190 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("label on", "ON"),
191 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("label off", "OFF"),
192 EDJE_EXTERNAL_PARAM_INFO_BOOL("state"),
193 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
196 DEFINE_EXTERNAL_ICON_ADD(toggle, "toggle")
197 DEFINE_EXTERNAL_TYPE_SIMPLE(toggle, "Toggle")