aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/edje_externals/elm_photocam.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-04-22 09:20:32 +1000
committerDavid Walter Seikel2012-04-22 09:20:32 +1000
commit3ad3455551be0d7859ecb02290376206d5e66498 (patch)
tree497917e12b4d7f458dff9765d9b53f64c4e03fc3 /libraries/elementary/src/edje_externals/elm_photocam.c
parentUpdate EFL to latest beta. (diff)
downloadSledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.zip
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.gz
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.bz2
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.xz
And actually include new files, plus elementary libraries.
Diffstat (limited to 'libraries/elementary/src/edje_externals/elm_photocam.c')
-rw-r--r--libraries/elementary/src/edje_externals/elm_photocam.c208
1 files changed, 208 insertions, 0 deletions
diff --git a/libraries/elementary/src/edje_externals/elm_photocam.c b/libraries/elementary/src/edje_externals/elm_photocam.c
new file mode 100644
index 0000000..b4711c7
--- /dev/null
+++ b/libraries/elementary/src/edje_externals/elm_photocam.c
@@ -0,0 +1,208 @@
1#include <assert.h>
2
3#include "private.h"
4
5typedef struct _Elm_Params_Photocam
6{
7 Elm_Params base;
8 const char *file;
9 double zoom;
10 const char *zoom_mode;
11 Eina_Bool paused:1;
12 Eina_Bool paused_exists:1;
13 Eina_Bool zoom_exists:1;
14} Elm_Params_Photocam;
15
16static const char* choices[] = {"manual", "auto fit", "auto fill", NULL};
17
18static Elm_Photocam_Zoom_Mode
19_zoom_mode_setting_get(const char *zoom_mode_str)
20{
21 unsigned int i;
22
23 assert(sizeof(choices)/sizeof(choices[0]) == ELM_PHOTOCAM_ZOOM_MODE_LAST + 1);
24
25 for (i = 0; i < ELM_PHOTOCAM_ZOOM_MODE_LAST; i++)
26 {
27 if (!strcmp(zoom_mode_str, choices[i]))
28 return i;
29 }
30 return ELM_PHOTOCAM_ZOOM_MODE_LAST;
31}
32
33static void
34external_photocam_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
35{
36 const Elm_Params_Photocam *p;
37
38 if (to_params) p = to_params;
39 else if (from_params) p = from_params;
40 else return;
41
42 if (p->file)
43 elm_photocam_file_set(obj, p->file);
44 if (p->zoom_exists)
45 elm_photocam_zoom_set(obj, p->zoom);
46 if (p->zoom_mode)
47 {
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);
51 }
52 if (p->paused_exists)
53 elm_photocam_paused_set(obj, p->paused);
54}
55
56static Eina_Bool
57external_photocam_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
58{
59 if (!strcmp(param->name, "file"))
60 {
61 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
62 {
63 elm_photocam_file_set(obj, param->s);
64 return EINA_TRUE;
65 }
66 }
67 else if (!strcmp(param->name, "zoom"))
68 {
69 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
70 {
71 elm_photocam_zoom_set(obj, param->d);
72 return EINA_TRUE;
73 }
74 }
75 else if (!strcmp(param->name, "zoom mode"))
76 {
77 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
78 {
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);
82 return EINA_TRUE;
83 }
84 }
85 else if (!strcmp(param->name, "paused"))
86 {
87 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
88 {
89 elm_photocam_paused_set(obj, param->i);
90 return EINA_TRUE;
91 }
92 }
93
94 ERR("unknown parameter '%s' of type '%s'",
95 param->name, edje_external_param_type_str(param->type));
96
97 return EINA_FALSE;
98}
99
100static Eina_Bool
101external_photocam_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
102{
103 if (!strcmp(param->name, "file"))
104 {
105 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
106 {
107 param->s = elm_photocam_file_get(obj);
108 return EINA_TRUE;
109 }
110 }
111 else if (!strcmp(param->name, "zoom"))
112 {
113 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
114 {
115 param->d = elm_photocam_zoom_get(obj);
116 return EINA_TRUE;
117 }
118 }
119 else if (!strcmp(param->name, "zoom mode"))
120 {
121 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
122 {
123 Elm_Photocam_Zoom_Mode zoom_mode_set = elm_photocam_zoom_mode_get(obj);
124
125 if (zoom_mode_set == ELM_PHOTOCAM_ZOOM_MODE_LAST)
126 return EINA_FALSE;
127
128 param->s = choices[zoom_mode_set];
129 return EINA_TRUE;
130 }
131 }
132 else if (!strcmp(param->name, "paused"))
133 {
134 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
135 {
136 param->i = elm_photocam_paused_get(obj);
137 return EINA_TRUE;
138 }
139 }
140
141 ERR("unknown parameter '%s' of type '%s'",
142 param->name, edje_external_param_type_str(param->type));
143
144 return EINA_FALSE;
145}
146
147static void *
148external_photocam_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
149{
150 Elm_Params_Photocam *mem;
151 Edje_External_Param *param;
152 const Eina_List *l;
153
154 mem = calloc(1, sizeof(Elm_Params_Photocam));
155 if (!mem)
156 return NULL;
157
158 EINA_LIST_FOREACH(params, l, param)
159 {
160 if (!strcmp(param->name, "file"))
161 mem->file = eina_stringshare_add(param->s);
162 else if (!strcmp(param->name, "zoom"))
163 {
164 mem->zoom = param->d;
165 mem->zoom_exists = EINA_TRUE;
166 }
167 else if (!strcmp(param->name, "zoom mode"))
168 mem->zoom_mode = eina_stringshare_add(param->s);
169 else if (!strcmp(param->name, "paused"))
170 {
171 mem->paused = !!param->i;
172 mem->paused_exists = EINA_TRUE;
173 }
174 }
175
176 return mem;
177}
178
179static Evas_Object *external_photocam_content_get(void *data __UNUSED__,
180 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
181{
182 ERR("No content.");
183 return NULL;
184}
185
186static void
187external_photocam_params_free(void *params)
188{
189 Elm_Params_Photocam *mem = params;
190
191 if (mem->file)
192 eina_stringshare_del(mem->file);
193 if (mem->zoom_mode)
194 eina_stringshare_del(mem->zoom_mode);
195 free(mem);
196}
197
198static 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
205};
206
207DEFINE_EXTERNAL_ICON_ADD(photocam, "photocam");
208DEFINE_EXTERNAL_TYPE_SIMPLE(photocam, "Photocam");