5 typedef struct _Elm_Params_Photocam
10 const char *zoom_mode;
12 Eina_Bool paused_exists:1;
13 Eina_Bool zoom_exists:1;
14 } Elm_Params_Photocam;
16 static const char* choices[] = {"manual", "auto fit", "auto fill", NULL};
18 static Elm_Photocam_Zoom_Mode
19 _zoom_mode_setting_get(const char *zoom_mode_str)
23 assert(sizeof(choices)/sizeof(choices[0]) == ELM_PHOTOCAM_ZOOM_MODE_LAST + 1);
25 for (i = 0; i < ELM_PHOTOCAM_ZOOM_MODE_LAST; i++)
27 if (!strcmp(zoom_mode_str, choices[i]))
30 return ELM_PHOTOCAM_ZOOM_MODE_LAST;
34 external_photocam_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
36 const Elm_Params_Photocam *p;
38 if (to_params) p = to_params;
39 else if (from_params) p = from_params;
43 elm_photocam_file_set(obj, p->file);
45 elm_photocam_zoom_set(obj, p->zoom);
48 Elm_Photocam_Zoom_Mode set = _zoom_mode_setting_get(p->zoom_mode);
49 if (set == ELM_PHOTOCAM_ZOOM_MODE_LAST) return;
50 elm_photocam_zoom_mode_set(obj, set);
53 elm_photocam_paused_set(obj, p->paused);
57 external_photocam_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
59 if (!strcmp(param->name, "file"))
61 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
63 elm_photocam_file_set(obj, param->s);
67 else if (!strcmp(param->name, "zoom"))
69 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
71 elm_photocam_zoom_set(obj, param->d);
75 else if (!strcmp(param->name, "zoom mode"))
77 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
79 Elm_Photocam_Zoom_Mode set = _zoom_mode_setting_get(param->s);
80 if (set == ELM_PHOTOCAM_ZOOM_MODE_LAST) return EINA_FALSE;
81 elm_photocam_zoom_mode_set(obj, set);
85 else if (!strcmp(param->name, "paused"))
87 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
89 elm_photocam_paused_set(obj, param->i);
94 ERR("unknown parameter '%s' of type '%s'",
95 param->name, edje_external_param_type_str(param->type));
101 external_photocam_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
103 if (!strcmp(param->name, "file"))
105 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
107 param->s = elm_photocam_file_get(obj);
111 else if (!strcmp(param->name, "zoom"))
113 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
115 param->d = elm_photocam_zoom_get(obj);
119 else if (!strcmp(param->name, "zoom mode"))
121 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
123 Elm_Photocam_Zoom_Mode zoom_mode_set = elm_photocam_zoom_mode_get(obj);
125 if (zoom_mode_set == ELM_PHOTOCAM_ZOOM_MODE_LAST)
128 param->s = choices[zoom_mode_set];
132 else if (!strcmp(param->name, "paused"))
134 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
136 param->i = elm_photocam_paused_get(obj);
141 ERR("unknown parameter '%s' of type '%s'",
142 param->name, edje_external_param_type_str(param->type));
148 external_photocam_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
150 Elm_Params_Photocam *mem;
151 Edje_External_Param *param;
154 mem = calloc(1, sizeof(Elm_Params_Photocam));
158 EINA_LIST_FOREACH(params, l, param)
160 if (!strcmp(param->name, "file"))
161 mem->file = eina_stringshare_add(param->s);
162 else if (!strcmp(param->name, "zoom"))
164 mem->zoom = param->d;
165 mem->zoom_exists = EINA_TRUE;
167 else if (!strcmp(param->name, "zoom mode"))
168 mem->zoom_mode = eina_stringshare_add(param->s);
169 else if (!strcmp(param->name, "paused"))
171 mem->paused = !!param->i;
172 mem->paused_exists = EINA_TRUE;
179 static Evas_Object *external_photocam_content_get(void *data __UNUSED__,
180 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
187 external_photocam_params_free(void *params)
189 Elm_Params_Photocam *mem = params;
192 eina_stringshare_del(mem->file);
194 eina_stringshare_del(mem->zoom_mode);
198 static Edje_External_Param_Info external_photocam_params[] = {
199 DEFINE_EXTERNAL_COMMON_PARAMS,
200 EDJE_EXTERNAL_PARAM_INFO_STRING("file"),
201 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("zoom"),
202 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("zoom mode", "manual", choices),
203 EDJE_EXTERNAL_PARAM_INFO_BOOL("paused"),
204 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
207 DEFINE_EXTERNAL_ICON_ADD(photocam, "photocam");
208 DEFINE_EXTERNAL_TYPE_SIMPLE(photocam, "Photocam");