diff options
author | David Walter Seikel | 2012-04-22 09:20:32 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-04-22 09:20:32 +1000 |
commit | 3ad3455551be0d7859ecb02290376206d5e66498 (patch) | |
tree | 497917e12b4d7f458dff9765d9b53f64c4e03fc3 /libraries/elementary/src/edje_externals/elm_fileselector_entry.c | |
parent | Update EFL to latest beta. (diff) | |
download | SledjHamr-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_fileselector_entry.c')
-rw-r--r-- | libraries/elementary/src/edje_externals/elm_fileselector_entry.c | 252 |
1 files changed, 252 insertions, 0 deletions
diff --git a/libraries/elementary/src/edje_externals/elm_fileselector_entry.c b/libraries/elementary/src/edje_externals/elm_fileselector_entry.c new file mode 100644 index 0000000..11bd1fe --- /dev/null +++ b/libraries/elementary/src/edje_externals/elm_fileselector_entry.c | |||
@@ -0,0 +1,252 @@ | |||
1 | #include "private.h" | ||
2 | |||
3 | typedef struct _Elm_Params_fileselector_entry | ||
4 | { | ||
5 | Elm_Params base; | ||
6 | const char *label; | ||
7 | Evas_Object *icon; | ||
8 | |||
9 | struct { | ||
10 | const char *path; | ||
11 | Eina_Bool is_save:1; | ||
12 | Eina_Bool is_save_set:1; | ||
13 | Eina_Bool folder_only:1; | ||
14 | Eina_Bool folder_only_set:1; | ||
15 | Eina_Bool expandable:1; | ||
16 | Eina_Bool expandable_set:1; | ||
17 | Eina_Bool inwin_mode:1; | ||
18 | Eina_Bool inwin_mode_set:1; | ||
19 | } fs; | ||
20 | } Elm_Params_fileselector_entry; | ||
21 | |||
22 | static void | ||
23 | external_fileselector_entry_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__) | ||
24 | { | ||
25 | const Elm_Params_fileselector_entry *p; | ||
26 | |||
27 | if (to_params) p = to_params; | ||
28 | else if (from_params) p = from_params; | ||
29 | else return; | ||
30 | |||
31 | if (p->label) | ||
32 | elm_object_text_set(obj, p->label); | ||
33 | if (p->icon) elm_object_part_content_set(obj, "button icon", p->icon); | ||
34 | if (p->fs.path) elm_fileselector_entry_selected_set(obj, p->fs.path); | ||
35 | if (p->fs.is_save_set) | ||
36 | elm_fileselector_entry_is_save_set(obj, p->fs.is_save); | ||
37 | if (p->fs.folder_only_set) | ||
38 | elm_fileselector_entry_folder_only_set(obj, p->fs.folder_only); | ||
39 | if (p->fs.expandable_set) | ||
40 | elm_fileselector_entry_expandable_set(obj, p->fs.expandable); | ||
41 | if (p->fs.inwin_mode_set) | ||
42 | elm_fileselector_entry_inwin_mode_set(obj, p->fs.inwin_mode); | ||
43 | } | ||
44 | |||
45 | static Eina_Bool | ||
46 | external_fileselector_entry_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param) | ||
47 | { | ||
48 | if (!strcmp(param->name, "label")) | ||
49 | { | ||
50 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) | ||
51 | { | ||
52 | elm_object_text_set(obj, param->s); | ||
53 | return EINA_TRUE; | ||
54 | } | ||
55 | } | ||
56 | else if (!strcmp(param->name, "icon")) | ||
57 | { | ||
58 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) | ||
59 | { | ||
60 | Evas_Object *icon = external_common_param_icon_get(obj, param); | ||
61 | if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE; | ||
62 | elm_object_part_content_set(obj, "button icon", icon); | ||
63 | return EINA_TRUE; | ||
64 | } | ||
65 | } | ||
66 | else if (!strcmp(param->name, "path")) | ||
67 | { | ||
68 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) | ||
69 | { | ||
70 | elm_fileselector_entry_selected_set(obj, param->s); | ||
71 | return EINA_TRUE; | ||
72 | } | ||
73 | } | ||
74 | else if (!strcmp(param->name, "save")) | ||
75 | { | ||
76 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) | ||
77 | { | ||
78 | elm_fileselector_entry_is_save_set(obj, param->i); | ||
79 | return EINA_TRUE; | ||
80 | } | ||
81 | } | ||
82 | else if (!strcmp(param->name, "folder only")) | ||
83 | { | ||
84 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) | ||
85 | { | ||
86 | elm_fileselector_entry_folder_only_set(obj, param->i); | ||
87 | return EINA_TRUE; | ||
88 | } | ||
89 | } | ||
90 | else if (!strcmp(param->name, "expandable")) | ||
91 | { | ||
92 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) | ||
93 | { | ||
94 | elm_fileselector_entry_expandable_set(obj, param->i); | ||
95 | return EINA_TRUE; | ||
96 | } | ||
97 | } | ||
98 | else if (!strcmp(param->name, "inwin mode")) | ||
99 | { | ||
100 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) | ||
101 | { | ||
102 | elm_fileselector_entry_inwin_mode_set(obj, param->i); | ||
103 | return EINA_TRUE; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | ERR("unknown parameter '%s' of type '%s'", | ||
108 | param->name, edje_external_param_type_str(param->type)); | ||
109 | |||
110 | return EINA_FALSE; | ||
111 | } | ||
112 | |||
113 | static Eina_Bool | ||
114 | external_fileselector_entry_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param) | ||
115 | { | ||
116 | if (!strcmp(param->name, "label")) | ||
117 | { | ||
118 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) | ||
119 | { | ||
120 | param->s = elm_object_text_get(obj); | ||
121 | return EINA_TRUE; | ||
122 | } | ||
123 | } | ||
124 | else if (!strcmp(param->name, "icon")) | ||
125 | { | ||
126 | /* not easy to get icon name back from live object */ | ||
127 | return EINA_FALSE; | ||
128 | } | ||
129 | else if (!strcmp(param->name, "path")) | ||
130 | { | ||
131 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) | ||
132 | { | ||
133 | param->s = elm_fileselector_entry_selected_get(obj); | ||
134 | return EINA_TRUE; | ||
135 | } | ||
136 | } | ||
137 | else if (!strcmp(param->name, "save")) | ||
138 | { | ||
139 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) | ||
140 | { | ||
141 | param->i = elm_fileselector_entry_is_save_get(obj); | ||
142 | return EINA_TRUE; | ||
143 | } | ||
144 | } | ||
145 | else if (!strcmp(param->name, "folder only")) | ||
146 | { | ||
147 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) | ||
148 | { | ||
149 | param->i = elm_fileselector_entry_folder_only_get(obj); | ||
150 | return EINA_TRUE; | ||
151 | } | ||
152 | } | ||
153 | else if (!strcmp(param->name, "expandable")) | ||
154 | { | ||
155 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) | ||
156 | { | ||
157 | param->i = elm_fileselector_entry_expandable_get(obj); | ||
158 | return EINA_TRUE; | ||
159 | } | ||
160 | } | ||
161 | else if (!strcmp(param->name, "inwin mode")) | ||
162 | { | ||
163 | if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) | ||
164 | { | ||
165 | param->i = elm_fileselector_entry_inwin_mode_get(obj); | ||
166 | return EINA_TRUE; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | ERR("unknown parameter '%s' of type '%s'", | ||
171 | param->name, edje_external_param_type_str(param->type)); | ||
172 | |||
173 | return EINA_FALSE; | ||
174 | } | ||
175 | |||
176 | static void * | ||
177 | external_fileselector_entry_params_parse(void *data __UNUSED__, Evas_Object *obj, const Eina_List *params) | ||
178 | { | ||
179 | Elm_Params_fileselector_entry *mem; | ||
180 | Edje_External_Param *param; | ||
181 | const Eina_List *l; | ||
182 | |||
183 | mem = calloc(1, sizeof(Elm_Params_fileselector_entry)); | ||
184 | if (!mem) | ||
185 | return NULL; | ||
186 | |||
187 | external_common_icon_param_parse(&mem->icon, obj, params); | ||
188 | |||
189 | EINA_LIST_FOREACH(params, l, param) | ||
190 | { | ||
191 | if (!strcmp(param->name, "path")) | ||
192 | mem->fs.path = eina_stringshare_add(param->s); | ||
193 | else if (!strcmp(param->name, "save")) | ||
194 | { | ||
195 | mem->fs.is_save = !!param->i; | ||
196 | mem->fs.is_save_set = EINA_TRUE; | ||
197 | } | ||
198 | else if (!strcmp(param->name, "folder only")) | ||
199 | { | ||
200 | mem->fs.folder_only = !!param->i; | ||
201 | mem->fs.folder_only_set = EINA_TRUE; | ||
202 | } | ||
203 | else if (!strcmp(param->name, "expandable")) | ||
204 | { | ||
205 | mem->fs.expandable = !!param->i; | ||
206 | mem->fs.expandable_set = EINA_TRUE; | ||
207 | } | ||
208 | else if (!strcmp(param->name, "inwin mode")) | ||
209 | { | ||
210 | mem->fs.inwin_mode = !!param->i; | ||
211 | mem->fs.inwin_mode_set = EINA_TRUE; | ||
212 | } | ||
213 | else if (!strcmp(param->name, "label")) | ||
214 | mem->label = eina_stringshare_add(param->s); | ||
215 | } | ||
216 | |||
217 | return mem; | ||
218 | } | ||
219 | |||
220 | static Evas_Object *external_fileselector_entry_content_get(void *data __UNUSED__, | ||
221 | const Evas_Object *obj __UNUSED__, const char *content __UNUSED__) | ||
222 | { | ||
223 | ERR("No content."); | ||
224 | return NULL; | ||
225 | } | ||
226 | |||
227 | static void | ||
228 | external_fileselector_entry_params_free(void *params) | ||
229 | { | ||
230 | Elm_Params_fileselector_entry *mem = params; | ||
231 | |||
232 | if (mem->fs.path) | ||
233 | eina_stringshare_del(mem->fs.path); | ||
234 | if (mem->label) | ||
235 | eina_stringshare_del(mem->label); | ||
236 | free(params); | ||
237 | } | ||
238 | |||
239 | static Edje_External_Param_Info external_fileselector_entry_params[] = { | ||
240 | DEFINE_EXTERNAL_COMMON_PARAMS, | ||
241 | EDJE_EXTERNAL_PARAM_INFO_STRING("label"), | ||
242 | EDJE_EXTERNAL_PARAM_INFO_STRING("icon"), | ||
243 | EDJE_EXTERNAL_PARAM_INFO_STRING("path"), | ||
244 | EDJE_EXTERNAL_PARAM_INFO_BOOL("save"), | ||
245 | EDJE_EXTERNAL_PARAM_INFO_BOOL("folder only"), | ||
246 | EDJE_EXTERNAL_PARAM_INFO_BOOL("expandable"), | ||
247 | EDJE_EXTERNAL_PARAM_INFO_BOOL("inwin mode"), | ||
248 | EDJE_EXTERNAL_PARAM_INFO_SENTINEL | ||
249 | }; | ||
250 | |||
251 | DEFINE_EXTERNAL_ICON_ADD(fileselector_entry, "fileselector_entry"); | ||
252 | DEFINE_EXTERNAL_TYPE_SIMPLE(fileselector_entry, "File Selector Entry"); | ||