diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/edje/src/bin/edje_inspector.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to 'libraries/edje/src/bin/edje_inspector.c')
-rw-r--r-- | libraries/edje/src/bin/edje_inspector.c | 1633 |
1 files changed, 0 insertions, 1633 deletions
diff --git a/libraries/edje/src/bin/edje_inspector.c b/libraries/edje/src/bin/edje_inspector.c deleted file mode 100644 index 676c829..0000000 --- a/libraries/edje/src/bin/edje_inspector.c +++ /dev/null | |||
@@ -1,1633 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include "Edje.h" | ||
6 | #define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT 1 | ||
7 | #include "Edje_Edit.h" | ||
8 | |||
9 | #include <Ecore.h> | ||
10 | #include <Ecore_Evas.h> | ||
11 | #include <Ecore_Getopt.h> | ||
12 | #include <locale.h> | ||
13 | #include <fnmatch.h> | ||
14 | #include <unistd.h> | ||
15 | |||
16 | static int _log_dom; | ||
17 | #define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__) | ||
18 | #define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__) | ||
19 | #define WRN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__) | ||
20 | #define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__) | ||
21 | #define CRIT(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__) | ||
22 | |||
23 | #define INDENT " " | ||
24 | #define INDENT2 INDENT INDENT | ||
25 | #define INDENT3 INDENT2 INDENT | ||
26 | #define INDENT4 INDENT3 INDENT | ||
27 | #define INDENT5 INDENT4 INDENT | ||
28 | #define INDENT6 INDENT5 INDENT | ||
29 | #define INDENT7 INDENT6 INDENT | ||
30 | |||
31 | #define FLOAT_PRECISION 0.0001 | ||
32 | #define FDIFF(a, b) (fabs((a) - (b)) > FLOAT_PRECISION) | ||
33 | |||
34 | /* context */ | ||
35 | static Eina_List *groups; | ||
36 | static Ecore_Evas *ee; | ||
37 | |||
38 | /* options */ | ||
39 | static const char *file; | ||
40 | static char *group = NULL; | ||
41 | static char *part = NULL; | ||
42 | static char *program = NULL; | ||
43 | static int detail = 1; | ||
44 | static Eina_Bool api_only = EINA_FALSE; | ||
45 | static Eina_Bool api_fix = EINA_FALSE; | ||
46 | static Eina_Bool machine = EINA_FALSE; | ||
47 | |||
48 | static const char *mode_choices[] = { | ||
49 | "groups", | ||
50 | "parts", | ||
51 | "programs", | ||
52 | "groups-names", | ||
53 | "part-names", | ||
54 | "global-data", | ||
55 | "images", | ||
56 | "fonts", | ||
57 | "externals", | ||
58 | NULL, | ||
59 | }; | ||
60 | |||
61 | static const char *detail_choices[] = { | ||
62 | "none", | ||
63 | "terse", | ||
64 | "all", | ||
65 | NULL | ||
66 | }; | ||
67 | |||
68 | const Ecore_Getopt optdesc = { | ||
69 | "edje_inspector", | ||
70 | "%prog [options] <file.edj>", | ||
71 | PACKAGE_VERSION, | ||
72 | "(C) 2010 - The Enlightenment Project", | ||
73 | "BSD", | ||
74 | "Edje file inspector, let one see groups, parts, programs and other details " | ||
75 | "of a compiled (binary) edje file.\n", | ||
76 | 0, | ||
77 | { | ||
78 | ECORE_GETOPT_CHOICE('m', "mode", "Choose which mode to operate on file.", | ||
79 | mode_choices), | ||
80 | ECORE_GETOPT_CHOICE('d', "detail", "Choose detail level (default=terse)", | ||
81 | detail_choices), | ||
82 | ECORE_GETOPT_STORE_STR('g', "group", "Limit output to group (or glob)."), | ||
83 | ECORE_GETOPT_STORE_STR('p', "part", "Limit output to part (or glob)."), | ||
84 | ECORE_GETOPT_STORE_STR('r', "program", | ||
85 | "Limit output to program (or glob)."), | ||
86 | ECORE_GETOPT_STORE_TRUE('a', "api-only", "Limit to just api parts or " | ||
87 | "programs."), | ||
88 | ECORE_GETOPT_STORE_TRUE('A', "api-fix", "Fix API names to be C compliant."), | ||
89 | ECORE_GETOPT_STORE_TRUE('M', "machine", "Produce machine readable output."), | ||
90 | ECORE_GETOPT_LICENSE('L', "license"), | ||
91 | ECORE_GETOPT_COPYRIGHT('C', "copyright"), | ||
92 | ECORE_GETOPT_VERSION('V', "version"), | ||
93 | ECORE_GETOPT_HELP('h', "help"), | ||
94 | ECORE_GETOPT_SENTINEL | ||
95 | } | ||
96 | }; | ||
97 | |||
98 | static inline Eina_Bool | ||
99 | matches(const char *name, const char *pattern) | ||
100 | { | ||
101 | if (!pattern) return EINA_TRUE; | ||
102 | return fnmatch(pattern, name, 0) == 0; | ||
103 | } | ||
104 | |||
105 | static void | ||
106 | group_begin(const char *name) | ||
107 | { | ||
108 | if (machine) printf("GROUP-BEGIN\nNAME: %s\n", name); | ||
109 | else printf("group { name: '%s';\n", name); | ||
110 | } | ||
111 | |||
112 | static void | ||
113 | group_end(void) | ||
114 | { | ||
115 | if (machine) puts("GROUP-END"); | ||
116 | else puts("}"); | ||
117 | } | ||
118 | |||
119 | static void | ||
120 | group_details(Evas_Object *ed) | ||
121 | { | ||
122 | int w, h; | ||
123 | |||
124 | if (detail < 1) return; | ||
125 | |||
126 | if (machine) puts("GROUP-DETAILS-BEGIN"); | ||
127 | |||
128 | w = edje_edit_group_min_w_get(ed); | ||
129 | h = edje_edit_group_min_h_get(ed); | ||
130 | if (machine) printf("MIN-W: %d\nMIN-H: %d\n", w, h); | ||
131 | else if ((w > 0) || (h > 0)) printf(INDENT "min: %d %d;\n", w, h); | ||
132 | |||
133 | w = edje_edit_group_max_w_get(ed); | ||
134 | h = edje_edit_group_max_h_get(ed); | ||
135 | if (machine) printf("MAX-W: %d\nMAX-H: %d\n", w, h); | ||
136 | else if ((w > 0) || (h > 0)) printf(INDENT "max: %d %d;\n", w, h); | ||
137 | |||
138 | if (detail > 1) | ||
139 | { | ||
140 | Eina_List *dl; | ||
141 | dl = edje_edit_group_data_list_get(ed); | ||
142 | if (dl) | ||
143 | { | ||
144 | Eina_List *l; | ||
145 | const char *k; | ||
146 | if (machine) puts(INDENT "GROUP-DETAILS-DATA-BEGIN"); | ||
147 | else puts(INDENT "data {"); | ||
148 | |||
149 | EINA_LIST_FOREACH(dl, l, k) | ||
150 | { | ||
151 | const char *v = edje_edit_group_data_value_get(ed, k); | ||
152 | if (machine) printf("ITEM: \"%s\" \"%s\"\n", k, v); | ||
153 | else printf(INDENT2 "item: \"%s\" \"%s\";\n", k, v); | ||
154 | } | ||
155 | |||
156 | edje_edit_string_list_free(dl); | ||
157 | |||
158 | if (machine) puts(INDENT "GROUP-DETAILS-DATA-END"); | ||
159 | else puts(INDENT "}"); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | if (machine) puts("GROUP-DETAILS-END"); | ||
164 | } | ||
165 | |||
166 | static void | ||
167 | parts_begin(void) | ||
168 | { | ||
169 | if (machine) puts("PARTS-BEGIN"); | ||
170 | else puts(INDENT "parts {"); | ||
171 | } | ||
172 | |||
173 | static void | ||
174 | parts_end(void) | ||
175 | { | ||
176 | if (machine) puts("PARTS-END"); | ||
177 | else puts(INDENT "}"); | ||
178 | } | ||
179 | |||
180 | static const char * | ||
181 | part_type_name_get(Edje_Part_Type t) | ||
182 | { | ||
183 | switch (t) | ||
184 | { | ||
185 | case EDJE_PART_TYPE_RECTANGLE: | ||
186 | return "RECT"; | ||
187 | case EDJE_PART_TYPE_TEXT: | ||
188 | return "TEXT"; | ||
189 | case EDJE_PART_TYPE_IMAGE: | ||
190 | return "IMAGE"; | ||
191 | case EDJE_PART_TYPE_PROXY: | ||
192 | return "PROXY"; | ||
193 | case EDJE_PART_TYPE_SWALLOW: | ||
194 | return "SWALLOW"; | ||
195 | case EDJE_PART_TYPE_TEXTBLOCK: | ||
196 | return "TEXTBLOCK"; | ||
197 | case EDJE_PART_TYPE_GRADIENT: | ||
198 | return "GRADIENT"; | ||
199 | case EDJE_PART_TYPE_GROUP: | ||
200 | return "GROUP"; | ||
201 | case EDJE_PART_TYPE_BOX: | ||
202 | return "BOX"; | ||
203 | case EDJE_PART_TYPE_TABLE: | ||
204 | return "TABLE"; | ||
205 | case EDJE_PART_TYPE_EXTERNAL: | ||
206 | return "EXTERNAL"; | ||
207 | |||
208 | case EDJE_PART_TYPE_NONE: | ||
209 | case EDJE_PART_TYPE_LAST: | ||
210 | ERR("Invalid part type %d", t); | ||
211 | return "???"; | ||
212 | default: | ||
213 | ERR("Unknown part type %d", t); | ||
214 | return "???"; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | static void | ||
219 | state_begin(const char *state, double value) | ||
220 | { | ||
221 | if (machine) | ||
222 | printf("PART-STATE-BEGIN\nNAME: %s\nVALUE: %2.1f\n", state, value); | ||
223 | else | ||
224 | { | ||
225 | printf(INDENT3 "description { state: \"%s\" %2.1f;", state, value); | ||
226 | if (detail > 0) putchar('\n'); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | static const char * | ||
231 | aspect_pref_name_get(int id) | ||
232 | { | ||
233 | switch (id) | ||
234 | { | ||
235 | case 0: return "NONE"; | ||
236 | case 1: return "VERTICAL"; | ||
237 | case 2: return "HORIZONTAL"; | ||
238 | case 3: return "BOTH"; | ||
239 | default: | ||
240 | ERR("Unknown aspect preference %d", id); | ||
241 | return "???"; | ||
242 | } | ||
243 | } | ||
244 | |||
245 | static const char * | ||
246 | border_fill_name_get(int id) | ||
247 | { | ||
248 | switch (id) | ||
249 | { | ||
250 | case 0: return "NONE"; | ||
251 | case 1: return "DEFAULT"; | ||
252 | case 2: return "SOLID"; | ||
253 | default: | ||
254 | ERR("Unknown border fill %d", id); | ||
255 | return "???"; | ||
256 | } | ||
257 | } | ||
258 | |||
259 | static void | ||
260 | state_details(Evas_Object *ed, const char *ppart, const char *state, double value) | ||
261 | { | ||
262 | Edje_Part_Type t = edje_edit_part_type_get(ed, ppart); | ||
263 | double dx, dy; | ||
264 | const char *str, *str2; | ||
265 | int x, y, r, g, b, a; | ||
266 | |||
267 | if (detail < 1) return; | ||
268 | |||
269 | b = edje_edit_state_visible_get(ed, ppart, state, value); | ||
270 | if (machine) printf("VISIBLE: %d\n", b); | ||
271 | else if (!b) puts(INDENT4 "visible: 0;"); | ||
272 | |||
273 | edje_edit_state_color_get(ed, ppart, state, value, &r, &g, &b, &a); | ||
274 | if (machine) | ||
275 | printf("COLOR-R: %d\nCOLOR-G: %d\nCOLOR-B: %d\nCOLOR-A: %d\n", r, g, b, a); | ||
276 | else if ((r != 255) || (g != 255) || (b != 255) || (a != 255)) | ||
277 | printf(INDENT4 "color: %d %d %d %d;\n", r, g, b, a); | ||
278 | |||
279 | if (detail > 1) | ||
280 | { | ||
281 | edje_edit_state_color2_get(ed, ppart, state, value, &r, &g, &b, &a); | ||
282 | if (machine) | ||
283 | printf("COLOR2-R: %d\nCOLOR2-G: %d\nCOLOR2-B: %d\nCOLOR2-A: %d\n", | ||
284 | r, g, b, a); | ||
285 | else if ((r != 255) || (g != 255) || (b != 255) || (a != 255)) | ||
286 | printf(INDENT4 "color2: %d %d %d %d;\n", r, g, b, a); | ||
287 | |||
288 | edje_edit_state_color3_get(ed, ppart, state, value, &r, &g, &b, &a); | ||
289 | if (machine) | ||
290 | printf("COLOR3-R: %d\nCOLOR3-G: %d\nCOLOR3-B: %d\nCOLOR3-A: %d\n", | ||
291 | r, g, b, a); | ||
292 | else if ((r != 255) || (g != 255) || (b != 255) || (a != 255)) | ||
293 | printf(INDENT4 "color3: %d %d %d %d;\n", r, g, b, a); | ||
294 | } | ||
295 | |||
296 | dx = edje_edit_state_align_x_get(ed, ppart, state, value); | ||
297 | dy = edje_edit_state_align_y_get(ed, ppart, state, value); | ||
298 | if (machine) printf("ALIGN-X: %g\nALIGN-Y: %g\n", dx, dy); | ||
299 | else if (FDIFF(dx, 0.5) || FDIFF(dy, 0.5)) | ||
300 | printf(INDENT4 "align: %g %g;\n", dx, dy); | ||
301 | |||
302 | x = edje_edit_state_min_w_get(ed, ppart, state, value); | ||
303 | y = edje_edit_state_min_h_get(ed, ppart, state, value); | ||
304 | if (machine) printf("MIN-W: %d\nMIN-H: %d\n", x, y); | ||
305 | else if ((x) || (y)) printf(INDENT4 "min: %d %d;\n", x, y); | ||
306 | |||
307 | x = edje_edit_state_max_w_get(ed, ppart, state, value); | ||
308 | y = edje_edit_state_max_h_get(ed, ppart, state, value); | ||
309 | if (machine) printf("MAX-W: %d\nMAX-H: %d\n", x, y); | ||
310 | else if ((x != -1) || (y != -1)) printf(INDENT4 "max: %d %d;\n", x, y); | ||
311 | |||
312 | //TODO Support fixed | ||
313 | //TODO Support step | ||
314 | |||
315 | if (detail > 1) | ||
316 | { | ||
317 | dx = edje_edit_state_aspect_min_get(ed, ppart, state, value); | ||
318 | dy = edje_edit_state_aspect_max_get(ed, ppart, state, value); | ||
319 | if (machine) printf("ASPECT-MIN: %g\nASPECT-MAX: %g\n", dx, dy); | ||
320 | else if (FDIFF(dx, 0.0) || FDIFF(dy, 0.0)) | ||
321 | printf(INDENT4 "aspect: %g %g;\n", dx, dy); | ||
322 | |||
323 | x = edje_edit_state_aspect_pref_get(ed, ppart, state, value); | ||
324 | str = aspect_pref_name_get(x); | ||
325 | if (machine) printf("ASPECT-PREFERENCE: %s\n", str); | ||
326 | else if (x) printf(INDENT4 "aspect_preference: %s;\n", str); | ||
327 | /* do not free this str! */ | ||
328 | |||
329 | str = edje_edit_state_color_class_get(ed, ppart, state, value); | ||
330 | if (machine) printf("COLOR_CLASS: %s\n", str ? str : ""); | ||
331 | else if (str) printf(INDENT4 "color_class: \"%s\";\n", str); | ||
332 | edje_edit_string_free(str); | ||
333 | } | ||
334 | |||
335 | dx = edje_edit_state_rel1_relative_x_get(ed, ppart, state, value); | ||
336 | dy = edje_edit_state_rel1_relative_y_get(ed, ppart, state, value); | ||
337 | x = edje_edit_state_rel1_offset_x_get(ed, ppart, state, value); | ||
338 | y = edje_edit_state_rel1_offset_y_get(ed, ppart, state, value); | ||
339 | str = edje_edit_state_rel1_to_x_get(ed, ppart, state, value); | ||
340 | str2 = edje_edit_state_rel1_to_y_get(ed, ppart, state, value); | ||
341 | if (FDIFF(dx, 0.0) || FDIFF(dy, 0.0) || (x) || (y) || (str) || (str2)) | ||
342 | { | ||
343 | if (machine) puts("REL1-BEGIN"); | ||
344 | else puts(INDENT4 "rel1 {"); | ||
345 | |||
346 | if (machine) printf("RELATIVE-X: %g\nRELATIVE-Y: %g\n", dx, dy); | ||
347 | else if (FDIFF(dx, 0.0) || FDIFF(dy, 0.0)) | ||
348 | printf(INDENT5 "relative: %g %g;\n", dx, dy); | ||
349 | |||
350 | if (machine) printf("OFFSET-X: %d\nOFFSET-Y: %d\n", x, y); | ||
351 | else if ((x) || (y)) printf(INDENT5 "offset: %d %d;\n", x, y); | ||
352 | |||
353 | if (machine) | ||
354 | printf("TO-X: %s\nTO-Y: %s\n", str ? str : "", str2 ? str2 : ""); | ||
355 | else if (((str) && (str2)) && (!strcmp(str, str2))) | ||
356 | printf(INDENT5 "to: \"%s\";\n", str); | ||
357 | else | ||
358 | { | ||
359 | if (str) printf(INDENT5 "to_x: \"%s\";\n", str); | ||
360 | if (str2) printf(INDENT5 "to_y: \"%s\";\n", str2); | ||
361 | } | ||
362 | |||
363 | if (machine) puts("REL1-END"); | ||
364 | else puts(INDENT4 "}"); | ||
365 | } | ||
366 | edje_edit_string_free(str); | ||
367 | edje_edit_string_free(str2); | ||
368 | |||
369 | dx = edje_edit_state_rel2_relative_x_get(ed, ppart, state, value); | ||
370 | dy = edje_edit_state_rel2_relative_y_get(ed, ppart, state, value); | ||
371 | x = edje_edit_state_rel2_offset_x_get(ed, ppart, state, value); | ||
372 | y = edje_edit_state_rel2_offset_y_get(ed, ppart, state, value); | ||
373 | str = edje_edit_state_rel2_to_x_get(ed, ppart, state, value); | ||
374 | str2 = edje_edit_state_rel2_to_y_get(ed, ppart, state, value); | ||
375 | if (FDIFF(dx, 1.0) || FDIFF(dy, 1.0) || (x != -1) || (y != -1) || | ||
376 | (str) || (str2)) | ||
377 | { | ||
378 | if (machine) puts("REL2-BEGIN"); | ||
379 | else puts(INDENT4 "rel2 {"); | ||
380 | |||
381 | if (machine) printf("RELATIVE-X: %g\nRELATIVE-Y: %g\n", dx, dy); | ||
382 | else if (FDIFF(dx, 1.0) || FDIFF(dy, 1.0)) | ||
383 | printf(INDENT5 "relative: %g %g;\n", dx, dy); | ||
384 | |||
385 | if (machine) printf("OFFSET-X: %d\nOFFSET-Y: %d\n", x, y); | ||
386 | else if ((x != -1) || (y != -1)) | ||
387 | printf(INDENT5 "offset: %d %d;\n", x, y); | ||
388 | |||
389 | if (machine) | ||
390 | printf("TO-X: %s\nTO-Y: %s\n", str ? str : "", str2 ? str2 : ""); | ||
391 | else if (((str) && (str2)) && (!strcmp(str, str2))) | ||
392 | printf(INDENT5 "to: \"%s\";\n", str); | ||
393 | else | ||
394 | { | ||
395 | if (str) printf(INDENT5 "to_x: \"%s\";\n", str); | ||
396 | if (str2) printf(INDENT5 "to_y: \"%s\";\n", str2); | ||
397 | } | ||
398 | |||
399 | if (machine) puts("REL2-END"); | ||
400 | else puts(INDENT4 "}"); | ||
401 | } | ||
402 | edje_edit_string_free(str); | ||
403 | edje_edit_string_free(str2); | ||
404 | |||
405 | if (t == EDJE_PART_TYPE_IMAGE) | ||
406 | { | ||
407 | str = edje_edit_state_image_get(ed, ppart, state, value); | ||
408 | |||
409 | if (machine) printf("IMAGE-BEGIN\nNORMAL: %s\n", str ? str : ""); | ||
410 | else if (detail > 1) | ||
411 | { | ||
412 | puts(INDENT4 "image {"); | ||
413 | if (str) printf(INDENT5 "normal: \"%s\";\n", str); | ||
414 | } | ||
415 | else if (str) printf(INDENT4 "image.normal: \"%s\";\n", str); | ||
416 | |||
417 | edje_edit_string_free(str); | ||
418 | |||
419 | if (detail > 1) | ||
420 | { | ||
421 | Eina_List *tweens, *l; | ||
422 | int bl, br, bt, bb, x2, y2; | ||
423 | double dx2, dy2; | ||
424 | Eina_Bool has_orgin, has_size; | ||
425 | |||
426 | tweens = edje_edit_state_tweens_list_get(ed, ppart, state, value); | ||
427 | EINA_LIST_FOREACH(tweens, l, str) | ||
428 | { | ||
429 | if (machine) printf("TWEEN: %s\n", str); | ||
430 | else printf(INDENT5 "tween: \"%s\";\n", str); | ||
431 | } | ||
432 | edje_edit_string_list_free(tweens); | ||
433 | |||
434 | edje_edit_state_image_border_get | ||
435 | (ed, ppart, state, value, &bl, &br, &bt, &bb); | ||
436 | if (machine) | ||
437 | printf("BORDER-LEFT: %d\nBORDER-RIGHT: %d\n" | ||
438 | "BORDER-TOP: %d\nBORDER-BOTTOM: %d\n", bl, br, bt, bb); | ||
439 | else if ((bl) || (br) || (bt) || (bb)) | ||
440 | printf(INDENT5 "border: %d %d %d %d;\n", bl, br, bt, bb); | ||
441 | |||
442 | x = edje_edit_state_image_border_fill_get(ed, ppart, state, value); | ||
443 | str = border_fill_name_get(x); | ||
444 | if (machine) printf("BORDER-FILL: %s\n", str); | ||
445 | else if (x != 1) printf(INDENT5 "middle: %s;\n", str); | ||
446 | /* do not free str! */ | ||
447 | |||
448 | // TODO support image.fill.smooth | ||
449 | |||
450 | dx = edje_edit_state_fill_origin_relative_x_get | ||
451 | (ed, ppart, state, value); | ||
452 | dy = edje_edit_state_fill_origin_relative_y_get | ||
453 | (ed, ppart, state, value); | ||
454 | x = edje_edit_state_fill_origin_offset_x_get | ||
455 | (ed, ppart, state, value); | ||
456 | y = edje_edit_state_fill_origin_offset_y_get | ||
457 | (ed, ppart, state, value); | ||
458 | |||
459 | dx2 = edje_edit_state_fill_size_relative_x_get | ||
460 | (ed, ppart, state, value); | ||
461 | dy2 = edje_edit_state_fill_size_relative_y_get | ||
462 | (ed, ppart, state, value); | ||
463 | x2 = edje_edit_state_fill_size_offset_x_get | ||
464 | (ed, ppart, state, value); | ||
465 | y2 = edje_edit_state_fill_size_offset_y_get | ||
466 | (ed, ppart, state, value); | ||
467 | |||
468 | has_orgin = (FDIFF(dx, 0.0) || FDIFF(dy, 0.0) || (x) || (y)); | ||
469 | has_size = (FDIFF(dx2, 1.0) || FDIFF(dy2, 1.0) || (x2) || (y2)); | ||
470 | |||
471 | if ((has_orgin) || (has_size)) | ||
472 | { | ||
473 | if (machine) puts("IMAGE-FILL-BEGIN"); | ||
474 | else puts(INDENT5 "fill {"); | ||
475 | |||
476 | if (has_orgin) | ||
477 | { | ||
478 | if (machine) | ||
479 | printf("ORIGIN-RELATIVE-X: %g\n" | ||
480 | "ORIGIN-RELATIVE-Y: %g\n" | ||
481 | "ORIGIN-OFFSET-X: %d\n" | ||
482 | "ORIGIN-OFFSET-Y: %d\n", | ||
483 | dx, dy, x, y); | ||
484 | else | ||
485 | printf(INDENT6 "origin {\n" | ||
486 | INDENT7 "relative: %g %g;\n" | ||
487 | INDENT7 "offset: %d %d;\n" | ||
488 | INDENT6 "}\n", | ||
489 | dx, dy, x, y); | ||
490 | } | ||
491 | |||
492 | if (has_size) | ||
493 | { | ||
494 | if (machine) | ||
495 | printf("SIZE-RELATIVE-X: %g\n" | ||
496 | "SIZE-RELATIVE-Y: %g\n" | ||
497 | "SIZE-OFFSET-X: %d\n" | ||
498 | "SIZE-OFFSET-Y: %d\n", | ||
499 | dx2, dy2, x2, y2); | ||
500 | else | ||
501 | printf(INDENT6 "size {\n" | ||
502 | INDENT7 "relative: %g %g;\n" | ||
503 | INDENT7 "offset: %d %d;\n" | ||
504 | INDENT6 "}\n", | ||
505 | dx2, dy2, x2, y2); | ||
506 | } | ||
507 | |||
508 | if (machine) puts("IMAGE-FILL-END"); | ||
509 | else puts(INDENT5 "}"); | ||
510 | } | ||
511 | } | ||
512 | |||
513 | if (machine) puts("IMAGE-END"); | ||
514 | else if (detail > 1) puts(INDENT4 "}"); | ||
515 | } | ||
516 | else if (t == EDJE_PART_TYPE_PROXY) | ||
517 | { | ||
518 | int x2, y2; | ||
519 | double dx2, dy2; | ||
520 | Eina_Bool has_orgin, has_size; | ||
521 | |||
522 | if (machine) puts("PROXY-BEGIN"); | ||
523 | else puts(INDENT4 "proxy {"); | ||
524 | // TODO Support source | ||
525 | // TODO support proxy.fill.smooth | ||
526 | |||
527 | dx = edje_edit_state_fill_origin_relative_x_get | ||
528 | (ed, ppart, state, value); | ||
529 | dy = edje_edit_state_fill_origin_relative_y_get | ||
530 | (ed, ppart, state, value); | ||
531 | x = edje_edit_state_fill_origin_offset_x_get | ||
532 | (ed, ppart, state, value); | ||
533 | y = edje_edit_state_fill_origin_offset_y_get | ||
534 | (ed, ppart, state, value); | ||
535 | |||
536 | dx2 = edje_edit_state_fill_size_relative_x_get | ||
537 | (ed, ppart, state, value); | ||
538 | dy2 = edje_edit_state_fill_size_relative_y_get | ||
539 | (ed, ppart, state, value); | ||
540 | x2 = edje_edit_state_fill_size_offset_x_get | ||
541 | (ed, ppart, state, value); | ||
542 | y2 = edje_edit_state_fill_size_offset_y_get | ||
543 | (ed, ppart, state, value); | ||
544 | |||
545 | has_orgin = (FDIFF(dx, 0.0) || FDIFF(dy, 0.0) || (x) || (y)); | ||
546 | has_size = (FDIFF(dx2, 1.0) || FDIFF(dy2, 1.0) || (x2) || (y2)); | ||
547 | |||
548 | if ((has_orgin) || (has_size)) | ||
549 | { | ||
550 | if (machine) puts("PROXY-FILL-BEGIN"); | ||
551 | else puts(INDENT5 "fill {"); | ||
552 | |||
553 | if (has_orgin) | ||
554 | { | ||
555 | if (machine) | ||
556 | printf("ORIGIN-RELATIVE-X: %g\n" | ||
557 | "ORIGIN-RELATIVE-Y: %g\n" | ||
558 | "ORIGIN-OFFSET-X: %d\n" | ||
559 | "ORIGIN-OFFSET-Y: %d\n", | ||
560 | dx, dy, x, y); | ||
561 | else | ||
562 | printf(INDENT6 "origin {\n" | ||
563 | INDENT7 "relative: %g %g;\n" | ||
564 | INDENT7 "offset: %d %d;\n" | ||
565 | INDENT6 "}\n", | ||
566 | dx, dy, x, y); | ||
567 | } | ||
568 | |||
569 | if (has_size) | ||
570 | { | ||
571 | if (machine) | ||
572 | printf("SIZE-RELATIVE-X: %g\n" | ||
573 | "SIZE-RELATIVE-Y: %g\n" | ||
574 | "SIZE-OFFSET-X: %d\n" | ||
575 | "SIZE-OFFSET-Y: %d\n", | ||
576 | dx2, dy2, x2, y2); | ||
577 | else | ||
578 | printf(INDENT6 "size {\n" | ||
579 | INDENT7 "relative: %g %g;\n" | ||
580 | INDENT7 "offset: %d %d;\n" | ||
581 | INDENT6 "}\n", | ||
582 | dx2, dy2, x2, y2); | ||
583 | } | ||
584 | |||
585 | if (machine) puts("PROXY-FILL-END"); | ||
586 | else puts(INDENT5 "}"); | ||
587 | } | ||
588 | |||
589 | if (machine) puts("PROXY-END"); | ||
590 | else puts(INDENT4 "}"); | ||
591 | } | ||
592 | else if ((t == EDJE_PART_TYPE_TEXTBLOCK) || (t == EDJE_PART_TYPE_TEXT)) | ||
593 | { | ||
594 | if (machine) puts("TEXT-BEGIN"); | ||
595 | else puts(INDENT4 "text {"); | ||
596 | |||
597 | str = edje_edit_state_text_get(ed, ppart, state, value); | ||
598 | if (machine) printf("TEXT: %s\n", str ? str : ""); | ||
599 | else if (str) printf(INDENT5 "text: \"%s\";\n", str); | ||
600 | edje_edit_string_free(str); | ||
601 | |||
602 | str = edje_edit_state_font_get(ed, ppart, state, value); | ||
603 | if (machine) printf("FONT: %s\n", str ? str : ""); | ||
604 | else if (str) printf(INDENT5 "font: \"%s\";\n", str); | ||
605 | edje_edit_string_free(str); | ||
606 | |||
607 | x = edje_edit_state_text_size_get(ed, ppart, state, value); | ||
608 | if (machine) printf("SIZE: %d\n", x); | ||
609 | else if (x > 0) printf(INDENT5 "size: %d;\n", x); | ||
610 | |||
611 | // TODO text_class | ||
612 | |||
613 | dx = edje_edit_state_text_align_x_get(ed, ppart, state, value); | ||
614 | dy = edje_edit_state_text_align_y_get(ed, ppart, state, value); | ||
615 | if (machine) printf("TEXT-ALIGN-X: %g\nTEXT-ALIGN-Y: %g\n", dx, dy); | ||
616 | else if (FDIFF(dx, 0.5) || FDIFF(dy, 0.5)) | ||
617 | printf(INDENT5 "align: %g %g;\n", dx, dy); | ||
618 | |||
619 | x = edje_edit_state_text_fit_x_get(ed, ppart, state, value); | ||
620 | y = edje_edit_state_text_fit_y_get(ed, ppart, state, value); | ||
621 | if (machine) printf("TEXT-FIT-X: %d\nTEXT-FIT-Y: %d\n", x, y); | ||
622 | else if ((x) || (y)) printf(INDENT5 "fit: %d %d;\n", x, y); | ||
623 | |||
624 | dx = edje_edit_state_text_elipsis_get(ed, ppart, state, value); | ||
625 | if (machine) printf("TEXT-ELIPSIS: %g\n", dx); | ||
626 | else if (FDIFF(dx, 0.5)) printf(INDENT5 "elipsis: %g;\n", dx); | ||
627 | |||
628 | if (machine) puts("TEXT-END"); | ||
629 | else puts(INDENT4 "}"); | ||
630 | } | ||
631 | else if (t == EDJE_PART_TYPE_EXTERNAL) | ||
632 | { | ||
633 | const Eina_List *params, *l; | ||
634 | const Edje_External_Param *p; | ||
635 | |||
636 | params = edje_edit_state_external_params_list_get | ||
637 | (ed, ppart, state, value); | ||
638 | |||
639 | if (params) | ||
640 | { | ||
641 | if (machine) puts("PARAMS-BEGIN"); | ||
642 | else puts(INDENT4 "params {"); | ||
643 | |||
644 | EINA_LIST_FOREACH(params, l, p) | ||
645 | switch (p->type) | ||
646 | { | ||
647 | case EDJE_EXTERNAL_PARAM_TYPE_INT: | ||
648 | printf(INDENT5 "int: \"%s\" \"%d\";\n", p->name, p->i); | ||
649 | break; | ||
650 | case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: | ||
651 | printf(INDENT5 "double: \"%s\" \"%g\";\n", p->name, p->d); | ||
652 | break; | ||
653 | case EDJE_EXTERNAL_PARAM_TYPE_STRING: | ||
654 | if (p->s) | ||
655 | printf(INDENT5 "string: \"%s\" \"%s\";\n", | ||
656 | p->name, p->s); | ||
657 | break; | ||
658 | case EDJE_EXTERNAL_PARAM_TYPE_BOOL: | ||
659 | printf(INDENT5 "bool: \"%s\" \"%d\";\n", p->name, p->i); | ||
660 | break; | ||
661 | case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: | ||
662 | if (p->s) | ||
663 | printf(INDENT5 "choice: \"%s\" \"%s\";\n", | ||
664 | p->name, p->s); | ||
665 | break; | ||
666 | default: | ||
667 | break; | ||
668 | } | ||
669 | |||
670 | if (machine) puts("PARAMS-END"); | ||
671 | else puts(INDENT4 "}"); | ||
672 | } | ||
673 | } | ||
674 | } | ||
675 | |||
676 | static void | ||
677 | state_end(void) | ||
678 | { | ||
679 | if (machine) puts("PART-STATE-END"); | ||
680 | else if (detail > 0) puts(INDENT3 "}"); | ||
681 | else puts(" }"); | ||
682 | } | ||
683 | |||
684 | static void | ||
685 | part_begin(Evas_Object *ed, const char *name) | ||
686 | { | ||
687 | const char *type = part_type_name_get(edje_edit_part_type_get(ed, name)); | ||
688 | if (machine) printf("PART-BEGIN\nNAME: %s\nTYPE: %s\n", name, type); | ||
689 | else | ||
690 | { | ||
691 | printf(INDENT2 "part { name: '%s'; type: %s;", name, type); | ||
692 | if (detail > 0) putchar('\n'); | ||
693 | } | ||
694 | } | ||
695 | |||
696 | static const char * | ||
697 | text_effect_name_get(Edje_Text_Effect effect) | ||
698 | { | ||
699 | switch (effect) | ||
700 | { | ||
701 | case EDJE_TEXT_EFFECT_NONE: | ||
702 | return "NONE"; | ||
703 | case EDJE_TEXT_EFFECT_PLAIN: | ||
704 | return "PLAIN"; | ||
705 | case EDJE_TEXT_EFFECT_OUTLINE: | ||
706 | return "OUTLINE"; | ||
707 | case EDJE_TEXT_EFFECT_SOFT_OUTLINE: | ||
708 | return "SOFT_OUTLINE"; | ||
709 | case EDJE_TEXT_EFFECT_SHADOW: | ||
710 | return "SHADOW"; | ||
711 | case EDJE_TEXT_EFFECT_SOFT_SHADOW: | ||
712 | return "SOFT_SHADOW"; | ||
713 | case EDJE_TEXT_EFFECT_OUTLINE_SHADOW: | ||
714 | return "OUTLINE_SHADOW"; | ||
715 | case EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW: | ||
716 | return "OUTLINE_SOFT_SHADOW"; | ||
717 | case EDJE_TEXT_EFFECT_FAR_SHADOW: | ||
718 | return "FAR_SHADOW"; | ||
719 | case EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW: | ||
720 | return "FAR_SOFT_SHADOW"; | ||
721 | case EDJE_TEXT_EFFECT_GLOW: | ||
722 | return "GLOW"; | ||
723 | |||
724 | case EDJE_TEXT_EFFECT_LAST: | ||
725 | ERR("Invalid part type %d", effect); | ||
726 | return "???"; | ||
727 | default: | ||
728 | ERR("Unknown effect type %d", effect); | ||
729 | return "???"; | ||
730 | } | ||
731 | } | ||
732 | |||
733 | static inline Eina_Bool | ||
734 | _c_id_allowed(char c) | ||
735 | { | ||
736 | if ((c >= '0') && (c <= '9')) return EINA_TRUE; | ||
737 | if ((c >= 'a') && (c <= 'z')) return EINA_TRUE; | ||
738 | if ((c >= 'A') && (c <= 'Z')) return EINA_TRUE; | ||
739 | return EINA_FALSE; | ||
740 | } | ||
741 | |||
742 | static char * | ||
743 | _api_name_fix(const char *orig) | ||
744 | { | ||
745 | char *d, *d_end, buf[256]; | ||
746 | const char *s; | ||
747 | |||
748 | if (!orig) return NULL; | ||
749 | if (!api_fix) return strdup(orig); | ||
750 | |||
751 | s = orig; | ||
752 | d = buf; | ||
753 | d_end = d + sizeof(buf) - 1; | ||
754 | for (; (*s != '\0') && (d < d_end); s++, d++) | ||
755 | if (_c_id_allowed(*s)) *d = *s; | ||
756 | else *d = '_'; | ||
757 | *d = '\0'; | ||
758 | |||
759 | return strdup(buf); | ||
760 | } | ||
761 | |||
762 | static char * | ||
763 | _part_api_name_get(Evas_Object *ed, const char *ppart) | ||
764 | { | ||
765 | const char *orig = edje_edit_part_api_name_get(ed, ppart); | ||
766 | char *fix = _api_name_fix(orig); | ||
767 | edje_edit_string_free(orig); | ||
768 | return fix; | ||
769 | } | ||
770 | |||
771 | static void | ||
772 | part_details(Evas_Object *ed, const char *ppart) | ||
773 | { | ||
774 | Eina_List *states, *l; | ||
775 | Eina_Bool b; | ||
776 | const char *str, *str2; | ||
777 | char *api; | ||
778 | |||
779 | if (detail < 1) return; | ||
780 | |||
781 | if (machine) puts("PART-DETAILS-BEGIN"); | ||
782 | |||
783 | str = api =_part_api_name_get(ed, ppart); | ||
784 | str2 = edje_edit_part_api_description_get(ed, ppart); | ||
785 | if (machine) | ||
786 | { | ||
787 | printf("API-NAME: %s\n", str ? str : ""); | ||
788 | printf("API-DESCRIPTION: %s\n", str2 ? str2 : ""); | ||
789 | } | ||
790 | else if ((str) || (str2)) | ||
791 | printf(INDENT3 "api: \"%s\" \"%s\";\n", str ? str : "", str2 ? str2 : ""); | ||
792 | free(api); | ||
793 | edje_edit_string_free(str2); | ||
794 | |||
795 | b = edje_edit_part_mouse_events_get(ed, ppart); | ||
796 | if (machine) printf("MOUSE_EVENTS: %d\n", b); | ||
797 | else if (!b) puts(INDENT3 "mouse_events: 0;"); | ||
798 | |||
799 | if (detail > 1) | ||
800 | { | ||
801 | b = edje_edit_part_repeat_events_get(ed, ppart); | ||
802 | if (machine) printf("REPEAT_EVENTS: %d\n", b); | ||
803 | else if (b) puts(INDENT3 "repeat_events: 1;"); | ||
804 | |||
805 | b = edje_edit_part_scale_get(ed, ppart); | ||
806 | if (machine) printf("SCALE: %d\n", b); | ||
807 | else if (b) puts(INDENT3 "scale: 1;"); | ||
808 | } | ||
809 | |||
810 | str = edje_edit_part_clip_to_get(ed, ppart); | ||
811 | if (machine) printf("CLIP_TO: %s\n", str ? str : ""); | ||
812 | else if (str) printf(INDENT3 "clip_to: \"%s\";\n", str); | ||
813 | edje_edit_string_free(str); | ||
814 | |||
815 | str = edje_edit_part_source_get(ed, ppart); | ||
816 | if (machine) printf("SOURCE: %s\n", str ? str : ""); | ||
817 | else if (str) printf(INDENT3 "source: \"%s\";\n", str); | ||
818 | edje_edit_string_free(str); | ||
819 | |||
820 | if (detail > 1) | ||
821 | { | ||
822 | if (edje_edit_part_type_get(ed, ppart) == EDJE_PART_TYPE_TEXT) | ||
823 | { | ||
824 | str = text_effect_name_get(edje_edit_part_effect_get(ed, ppart)); | ||
825 | if (machine) printf("EFFECT: %s\n", str ? str : ""); | ||
826 | else if (str) printf(INDENT3 "effect: %s;\n", str); | ||
827 | /* do not free this str! */ | ||
828 | } | ||
829 | |||
830 | if (edje_edit_part_drag_x_get(ed, ppart) || | ||
831 | edje_edit_part_drag_y_get(ed, ppart)) | ||
832 | { | ||
833 | int dir, step, count; | ||
834 | |||
835 | if (machine) puts("DRAGABLE-BEGIN"); | ||
836 | else puts(INDENT3 "dragable {"); | ||
837 | |||
838 | dir = edje_edit_part_drag_x_get(ed, ppart); | ||
839 | step = edje_edit_part_drag_step_x_get(ed, ppart); | ||
840 | count = edje_edit_part_drag_count_x_get(ed, ppart); | ||
841 | if (machine) printf("DRAG-X: %d %d %d\n", dir, step, count); | ||
842 | else printf(INDENT4 "x: %d %d %d;\n", dir, step, count); | ||
843 | |||
844 | dir = edje_edit_part_drag_y_get(ed, ppart); | ||
845 | step = edje_edit_part_drag_step_y_get(ed, ppart); | ||
846 | count = edje_edit_part_drag_count_y_get(ed, ppart); | ||
847 | if (machine) printf("DRAG-Y: %d %d %d\n", dir, step, count); | ||
848 | else printf(INDENT4 "y: %d %d %d;\n", dir, step, count); | ||
849 | |||
850 | str = edje_edit_part_drag_confine_get(ed, ppart); | ||
851 | if (machine) printf("DRAG-CONFINE: %s\n", str ? str : ""); | ||
852 | else if (str) printf(INDENT4 "confine: \"%s\";\n", str); | ||
853 | edje_edit_string_free(str); | ||
854 | |||
855 | str = edje_edit_part_drag_event_get(ed, ppart); | ||
856 | if (machine) printf("DRAG-EVENTS: %s\n", str ? str : ""); | ||
857 | else if (str) printf(INDENT4 "events: \"%s\";\n", str); | ||
858 | edje_edit_string_free(str); | ||
859 | |||
860 | if (machine) puts("DRAGABLE-END"); | ||
861 | else puts(INDENT3 "}"); | ||
862 | } | ||
863 | } | ||
864 | |||
865 | states = edje_edit_part_states_list_get(ed, ppart); | ||
866 | EINA_LIST_FOREACH(states, l, str) | ||
867 | { | ||
868 | char state[512], *delim; | ||
869 | double value; | ||
870 | eina_strlcpy(state, str, sizeof(state)); /* bad states_list! :-( */ | ||
871 | delim = strchr(state, ' '); | ||
872 | *delim = '\0'; | ||
873 | delim++; | ||
874 | value = strtod(delim, NULL); | ||
875 | state_begin(state, value); | ||
876 | state_details(ed, ppart, state, value); | ||
877 | state_end(); | ||
878 | } | ||
879 | edje_edit_string_list_free(states); | ||
880 | |||
881 | if (machine) puts("PART-DETAILS-END"); | ||
882 | } | ||
883 | |||
884 | static void | ||
885 | part_end(void) | ||
886 | { | ||
887 | if (machine) puts("PART-END"); | ||
888 | else if (detail > 0) puts(INDENT2 "}"); | ||
889 | else puts(" }"); | ||
890 | } | ||
891 | |||
892 | static int | ||
893 | _groups_names_list(void) | ||
894 | { | ||
895 | Eina_List *l; | ||
896 | const char *name; | ||
897 | Eina_Bool found = EINA_FALSE; | ||
898 | |||
899 | EINA_LIST_FOREACH(groups, l, name) | ||
900 | { | ||
901 | if (!matches(name, group)) | ||
902 | { | ||
903 | DBG("filter out group '%s': does not match '%s'", name, group); | ||
904 | continue; | ||
905 | } | ||
906 | found = EINA_TRUE; | ||
907 | puts(name); | ||
908 | } | ||
909 | |||
910 | if (!found) WRN("no groups match '%s'", group); | ||
911 | return !found; | ||
912 | } | ||
913 | |||
914 | static int | ||
915 | _parts_names_list(void) | ||
916 | { | ||
917 | Eina_List *gl, *pl, *parts; | ||
918 | const char *gname, *pname; | ||
919 | Eina_Bool found_group = EINA_FALSE, found_part = EINA_FALSE; | ||
920 | |||
921 | EINA_LIST_FOREACH(groups, gl, gname) | ||
922 | { | ||
923 | Evas_Object *ed; | ||
924 | |||
925 | if (!matches(gname, group)) | ||
926 | { | ||
927 | DBG("filter out group '%s': does not match '%s'", gname, group); | ||
928 | continue; | ||
929 | } | ||
930 | |||
931 | ed = edje_edit_object_add(ecore_evas_get(ee)); | ||
932 | if (!edje_object_file_set(ed, file, gname)) | ||
933 | { | ||
934 | Edje_Load_Error err = edje_object_load_error_get(ed); | ||
935 | const char *errmsg = edje_load_error_str(err); | ||
936 | ERR("could not load group '%s' from file '%s': %s", | ||
937 | gname, file, errmsg); | ||
938 | evas_object_del(ed); | ||
939 | continue; | ||
940 | } | ||
941 | |||
942 | found_group = EINA_TRUE; | ||
943 | group_begin(gname); | ||
944 | |||
945 | parts = edje_edit_parts_list_get(ed); | ||
946 | EINA_LIST_FOREACH(parts, pl, pname) | ||
947 | { | ||
948 | if (!matches(pname, part)) | ||
949 | { | ||
950 | DBG("filter out part '%s': does not match '%s'", pname, part); | ||
951 | continue; | ||
952 | } | ||
953 | if (api_only) | ||
954 | { | ||
955 | if (!edje_edit_part_api_name_get(ed, pname)) | ||
956 | { | ||
957 | DBG("filter out part '%s': not API.", pname); | ||
958 | continue; | ||
959 | } | ||
960 | } | ||
961 | if (machine) printf("PART: %s\n", pname); | ||
962 | else printf(INDENT "part: %s\n", pname); | ||
963 | } | ||
964 | edje_edit_string_list_free(parts); | ||
965 | |||
966 | group_end(); | ||
967 | evas_object_del(ed); | ||
968 | } | ||
969 | |||
970 | if (!found_group) WRN("no groups match '%s'", group); | ||
971 | if (!found_part) WRN("no parts match '%s'", part); | ||
972 | return (!found_group) || (!found_part); | ||
973 | } | ||
974 | |||
975 | static Eina_Bool | ||
976 | _group_parts_list(Evas_Object *ed) | ||
977 | { | ||
978 | Eina_Bool found = EINA_FALSE; | ||
979 | Eina_List *parts, *l; | ||
980 | const char *name; | ||
981 | |||
982 | parts_begin(); | ||
983 | |||
984 | parts = edje_edit_parts_list_get(ed); | ||
985 | EINA_LIST_FOREACH(parts, l, name) | ||
986 | { | ||
987 | if (!matches(name, part)) | ||
988 | { | ||
989 | DBG("filter out part '%s': does not match '%s'", name, part); | ||
990 | continue; | ||
991 | } | ||
992 | if (api_only) | ||
993 | { | ||
994 | if (!edje_edit_part_api_name_get(ed, name)) | ||
995 | { | ||
996 | DBG("filter out part '%s': not API.", name); | ||
997 | continue; | ||
998 | } | ||
999 | } | ||
1000 | |||
1001 | found = EINA_TRUE; | ||
1002 | part_begin(ed, name); | ||
1003 | part_details(ed, name); | ||
1004 | part_end(); | ||
1005 | } | ||
1006 | |||
1007 | parts_end(); | ||
1008 | return found; | ||
1009 | } | ||
1010 | |||
1011 | static void | ||
1012 | programs_begin(void) | ||
1013 | { | ||
1014 | if (machine) puts("PROGRAMS-BEGIN"); | ||
1015 | else puts(INDENT "programs {"); | ||
1016 | } | ||
1017 | |||
1018 | static void | ||
1019 | programs_end(void) | ||
1020 | { | ||
1021 | if (machine) puts("PROGRAMS-END"); | ||
1022 | else puts(INDENT "}"); | ||
1023 | } | ||
1024 | |||
1025 | static void | ||
1026 | program_begin(const char *name) | ||
1027 | { | ||
1028 | if (machine) printf("PROGRAM-BEGIN\nNAME: %s\n", name ? name : ""); | ||
1029 | else | ||
1030 | { | ||
1031 | printf(INDENT2 "program { name: '%s';\n", name ? name : ""); | ||
1032 | } | ||
1033 | } | ||
1034 | |||
1035 | static void | ||
1036 | program_end(void) | ||
1037 | { | ||
1038 | if (machine) puts("PROGRAM-END"); | ||
1039 | else puts(INDENT2 "}"); | ||
1040 | } | ||
1041 | |||
1042 | |||
1043 | static char * | ||
1044 | _program_api_name_get(Evas_Object *ed, const char *pprogram) | ||
1045 | { | ||
1046 | const char *orig = edje_edit_program_api_name_get(ed, pprogram); | ||
1047 | char *fix = _api_name_fix(orig); | ||
1048 | edje_edit_string_free(orig); | ||
1049 | return fix; | ||
1050 | } | ||
1051 | |||
1052 | static const char * | ||
1053 | _transition_name_get(Edje_Tween_Mode mode) | ||
1054 | { | ||
1055 | switch (mode) | ||
1056 | { | ||
1057 | case EDJE_TWEEN_MODE_LINEAR: return "LINEAR"; | ||
1058 | case EDJE_TWEEN_MODE_ACCELERATE: return "ACCELERATE"; | ||
1059 | case EDJE_TWEEN_MODE_DECELERATE: return "DECELERATE"; | ||
1060 | case EDJE_TWEEN_MODE_SINUSOIDAL: return "SINUSOIDAL"; | ||
1061 | default: | ||
1062 | ERR("Unknown transition mode %d", mode); | ||
1063 | return "???"; | ||
1064 | } | ||
1065 | } | ||
1066 | |||
1067 | static void | ||
1068 | program_details(Evas_Object *ed, const char *pprogram) | ||
1069 | { | ||
1070 | const char *str, *str2; | ||
1071 | char *api; | ||
1072 | |||
1073 | if (detail < 1) return; | ||
1074 | |||
1075 | if (machine) puts("PROGRAM-DETAILS-BEGIN"); | ||
1076 | |||
1077 | str = api =_program_api_name_get(ed, pprogram); | ||
1078 | str2 = edje_edit_program_api_description_get(ed, pprogram); | ||
1079 | if (machine) | ||
1080 | { | ||
1081 | printf("API-NAME: %s\n", str ? str : ""); | ||
1082 | printf("API-DESCRIPTION: %s\n", str2 ? str2 : ""); | ||
1083 | } | ||
1084 | else if ((str) || (str2)) | ||
1085 | printf(INDENT3 "api: \"%s\" \"%s\";\n", str ? str : "", str2 ? str2 : ""); | ||
1086 | free(api); | ||
1087 | edje_edit_string_free(str2); | ||
1088 | |||
1089 | str = edje_edit_program_signal_get(ed, pprogram); | ||
1090 | if (machine) printf("SIGNAL: %s\n", str ? str : ""); | ||
1091 | else if (str) printf(INDENT3 "signal: \"%s\";\n", str); | ||
1092 | edje_edit_string_free(str); | ||
1093 | |||
1094 | str = edje_edit_program_source_get(ed, pprogram); | ||
1095 | if (machine) printf("SOURCE: %s\n", str ? str : ""); | ||
1096 | else if (str) printf(INDENT3 "source: \"%s\";\n", str); | ||
1097 | edje_edit_string_free(str); | ||
1098 | |||
1099 | if (detail >= 1) | ||
1100 | { | ||
1101 | Eina_List *lst, *l; | ||
1102 | Edje_Action_Type type = edje_edit_program_action_get(ed, pprogram); | ||
1103 | switch (type) | ||
1104 | { | ||
1105 | case EDJE_ACTION_TYPE_ACTION_STOP: | ||
1106 | if (machine) puts("ACTION: ACTION_STOP"); | ||
1107 | else puts(INDENT3 "action: ACTION_STOP;"); | ||
1108 | break; | ||
1109 | case EDJE_ACTION_TYPE_STATE_SET: | ||
1110 | str = edje_edit_program_state_get(ed, pprogram); | ||
1111 | if (machine) | ||
1112 | printf("ACTION: STATE_SET\nACTION-STATE: %s %g\n", | ||
1113 | str, edje_edit_program_value_get(ed, pprogram)); | ||
1114 | else | ||
1115 | printf(INDENT3 "action: STATE_SET \"%s\" %2.1f;\n", | ||
1116 | str, edje_edit_program_value_get(ed, pprogram)); | ||
1117 | edje_edit_string_free(str); | ||
1118 | break; | ||
1119 | case EDJE_ACTION_TYPE_SIGNAL_EMIT: | ||
1120 | str = edje_edit_program_state_get(ed, pprogram); | ||
1121 | str2 = edje_edit_program_state2_get(ed, pprogram); | ||
1122 | if (machine) | ||
1123 | printf("ACTION: SIGNAL_EMIT\nACTION-SIGNAL: %s\n" | ||
1124 | "ACTION-SOURCE: %s\n", | ||
1125 | str ? str : "", str2 ? str2 : ""); | ||
1126 | else if ((str) || (str2)) | ||
1127 | printf(INDENT3 "action: SIGNAL_EMIT \"%s\" \"%s\";\n", | ||
1128 | str ? str : "", str2 ? str2 : ""); | ||
1129 | edje_edit_string_free(str); | ||
1130 | edje_edit_string_free(str2); | ||
1131 | break; | ||
1132 | //TODO Support Drag | ||
1133 | //~ case EDJE_ACTION_TYPE_DRAG_VAL_SET: | ||
1134 | //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_SET TODO;\n"); | ||
1135 | //~ break; | ||
1136 | //~ case EDJE_ACTION_TYPE_DRAG_VAL_STEP: | ||
1137 | //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_STEP TODO;\n"); | ||
1138 | //~ break; | ||
1139 | //~ case EDJE_ACTION_TYPE_DRAG_VAL_PAGE: | ||
1140 | //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_PAGE TODO;\n"); | ||
1141 | //~ break; | ||
1142 | default: | ||
1143 | ERR("Unhandled pprogram action type %d", type); | ||
1144 | break; | ||
1145 | } | ||
1146 | |||
1147 | if (detail > 1) | ||
1148 | { | ||
1149 | double from, range; | ||
1150 | |||
1151 | from = edje_edit_program_transition_time_get(ed, pprogram); | ||
1152 | if (from > 0.0) | ||
1153 | { | ||
1154 | str = _transition_name_get | ||
1155 | (edje_edit_program_transition_get(ed, pprogram)); | ||
1156 | if (machine) | ||
1157 | printf("TRANSITION-NAME: %s\nTRANSITION-DURATION: %g\n", | ||
1158 | str, from); | ||
1159 | else printf(INDENT3 "transition: %s %g;\n", str, from); | ||
1160 | /* do not free str! */ | ||
1161 | } | ||
1162 | |||
1163 | from = edje_edit_program_in_from_get(ed, pprogram); | ||
1164 | range = edje_edit_program_in_range_get(ed, pprogram); | ||
1165 | if (FDIFF(from, 0.0) || FDIFF(range, 0.0)) | ||
1166 | { | ||
1167 | if (machine) | ||
1168 | printf("IN-FROM: %g\nIN-RANGE: %g\n", from, range); | ||
1169 | else printf(INDENT3 "in: %g %g;\n", from, range); | ||
1170 | } | ||
1171 | } | ||
1172 | |||
1173 | lst = edje_edit_program_targets_get(ed, pprogram); | ||
1174 | EINA_LIST_FOREACH(lst, l, str) | ||
1175 | if (machine) printf("TARGET: %s\n", str); | ||
1176 | else printf(INDENT3 "target: \"%s\";\n", str); | ||
1177 | edje_edit_string_list_free(lst); | ||
1178 | |||
1179 | lst = edje_edit_program_afters_get(ed, pprogram); | ||
1180 | EINA_LIST_FOREACH(lst, l, str) | ||
1181 | if (machine) printf("AFTER: %s\n", str); | ||
1182 | else printf(INDENT3 "after: \"%s\";\n", str); | ||
1183 | edje_edit_string_list_free(lst); | ||
1184 | |||
1185 | // TODO Support script {} | ||
1186 | } | ||
1187 | |||
1188 | if (machine) puts("PROGRAM-DETAILS-END"); | ||
1189 | } | ||
1190 | |||
1191 | static Eina_Bool | ||
1192 | _group_programs_list(Evas_Object *ed) | ||
1193 | { | ||
1194 | Eina_Bool found = EINA_FALSE; | ||
1195 | Eina_List *programs, *l; | ||
1196 | const char *name; | ||
1197 | |||
1198 | programs_begin(); | ||
1199 | |||
1200 | /* TODO: change programs to operate on their ID instead of names! | ||
1201 | * needs huge change in Edje_Edit.h | ||
1202 | */ | ||
1203 | WRN("listing only programs with names!"); | ||
1204 | programs = edje_edit_programs_list_get(ed); | ||
1205 | EINA_LIST_FOREACH(programs, l, name) | ||
1206 | { | ||
1207 | if (!matches(name, program)) | ||
1208 | { | ||
1209 | DBG("filter out program '%s': does not match '%s'", name, program); | ||
1210 | continue; | ||
1211 | } | ||
1212 | if (api_only) | ||
1213 | { | ||
1214 | if (!edje_edit_program_api_name_get(ed, name)) | ||
1215 | { | ||
1216 | DBG("filter out program '%s': not API.", name); | ||
1217 | continue; | ||
1218 | } | ||
1219 | } | ||
1220 | |||
1221 | found = EINA_TRUE; | ||
1222 | program_begin(name); | ||
1223 | program_details(ed, name); | ||
1224 | program_end(); | ||
1225 | } | ||
1226 | |||
1227 | programs_end(); | ||
1228 | return found; | ||
1229 | } | ||
1230 | |||
1231 | static int | ||
1232 | _list(const char *mode) | ||
1233 | { | ||
1234 | Eina_List *l; | ||
1235 | const char *name; | ||
1236 | int ret = 0; | ||
1237 | Eina_Bool found_group = EINA_FALSE; | ||
1238 | Eina_Bool req_part, found_part, req_prog, found_prog; | ||
1239 | |||
1240 | if ((!strcmp(mode, "parts")) || (!strcmp(mode, "groups"))) | ||
1241 | { | ||
1242 | req_part = EINA_TRUE; | ||
1243 | found_part = EINA_FALSE; | ||
1244 | } | ||
1245 | else | ||
1246 | { | ||
1247 | req_part = EINA_FALSE; | ||
1248 | found_part = EINA_TRUE; | ||
1249 | } | ||
1250 | |||
1251 | if ((!strcmp(mode, "programs")) || (!strcmp(mode, "groups"))) | ||
1252 | { | ||
1253 | req_prog = EINA_TRUE; | ||
1254 | found_prog = EINA_FALSE; | ||
1255 | } | ||
1256 | else | ||
1257 | { | ||
1258 | req_prog = EINA_FALSE; | ||
1259 | found_prog = EINA_TRUE; | ||
1260 | } | ||
1261 | |||
1262 | EINA_LIST_FOREACH(groups, l, name) | ||
1263 | { | ||
1264 | Evas_Object *ed; | ||
1265 | |||
1266 | if (!matches(name, group)) | ||
1267 | { | ||
1268 | DBG("filter out group '%s': does not match '%s'", name, group); | ||
1269 | continue; | ||
1270 | } | ||
1271 | |||
1272 | ed = edje_edit_object_add(ecore_evas_get(ee)); | ||
1273 | if (!edje_object_file_set(ed, file, name)) | ||
1274 | { | ||
1275 | Edje_Load_Error err = edje_object_load_error_get(ed); | ||
1276 | const char *errmsg = edje_load_error_str(err); | ||
1277 | ERR("could not load group '%s' from file '%s': %s", | ||
1278 | name, file, errmsg); | ||
1279 | evas_object_del(ed); | ||
1280 | continue; | ||
1281 | } | ||
1282 | |||
1283 | found_group = EINA_TRUE; | ||
1284 | group_begin(name); | ||
1285 | group_details(ed); | ||
1286 | |||
1287 | if (req_part) found_part |= _group_parts_list(ed); | ||
1288 | if (req_prog) found_prog |= _group_programs_list(ed); | ||
1289 | |||
1290 | group_end(); | ||
1291 | evas_object_del(ed); | ||
1292 | } | ||
1293 | |||
1294 | /* no hard requirement for parts or programs for group listing */ | ||
1295 | if (!strcmp(mode, "groups")) req_part = req_prog = EINA_FALSE; | ||
1296 | |||
1297 | if (!found_group) | ||
1298 | { | ||
1299 | WRN("no groups match '%s'", group); | ||
1300 | ret = 1; | ||
1301 | } | ||
1302 | if ((req_part) && (!found_part)) | ||
1303 | { | ||
1304 | WRN("no parts match '%s'", part); | ||
1305 | ret = 1; | ||
1306 | } | ||
1307 | if ((req_prog) && (!found_prog)) | ||
1308 | { | ||
1309 | WRN("no programs match '%s'", program); | ||
1310 | ret = 1; | ||
1311 | } | ||
1312 | return ret; | ||
1313 | } | ||
1314 | |||
1315 | static Evas_Object * | ||
1316 | _edje_object_any_get(void) | ||
1317 | { | ||
1318 | Evas_Object *ed = edje_edit_object_add(ecore_evas_get(ee)); | ||
1319 | Eina_List *l; | ||
1320 | const char *name; | ||
1321 | if (!ed) return NULL; | ||
1322 | EINA_LIST_FOREACH(groups, l, name) | ||
1323 | if (edje_object_file_set(ed, file, name)) return ed; | ||
1324 | evas_object_del(ed); | ||
1325 | return NULL; | ||
1326 | } | ||
1327 | |||
1328 | static Eina_Bool | ||
1329 | _gdata_list(void) | ||
1330 | { | ||
1331 | Evas_Object *ed = _edje_object_any_get(); | ||
1332 | Eina_List *l, *data; | ||
1333 | const char *key; | ||
1334 | |||
1335 | if (!ed) return EINA_FALSE; | ||
1336 | |||
1337 | data = edje_edit_data_list_get(ed); | ||
1338 | |||
1339 | if (machine) puts("DATA-BEGIN"); | ||
1340 | else puts("data {"); | ||
1341 | |||
1342 | EINA_LIST_FOREACH(data, l, key) | ||
1343 | { | ||
1344 | const char *value = edje_edit_data_value_get(ed, key); | ||
1345 | if (machine) printf("ITEM: \"%s\" \"%s\"\n", key, value); | ||
1346 | else printf(INDENT "item: \"%s\" \"%s\";\n", key, value); | ||
1347 | } | ||
1348 | |||
1349 | if (machine) puts("DATA-END"); | ||
1350 | else puts("}"); | ||
1351 | |||
1352 | edje_edit_string_list_free(data); | ||
1353 | evas_object_del(ed); | ||
1354 | return EINA_TRUE; | ||
1355 | } | ||
1356 | |||
1357 | static const char * | ||
1358 | _comp_str_get(Evas_Object *ed, const char *img) | ||
1359 | { | ||
1360 | static char buf[128]; | ||
1361 | Edje_Edit_Image_Comp type = edje_edit_image_compression_type_get(ed, img); | ||
1362 | int rate; | ||
1363 | |||
1364 | switch (type) | ||
1365 | { | ||
1366 | case EDJE_EDIT_IMAGE_COMP_RAW: | ||
1367 | return "RAW"; | ||
1368 | case EDJE_EDIT_IMAGE_COMP_USER: | ||
1369 | return "USER"; | ||
1370 | case EDJE_EDIT_IMAGE_COMP_COMP: | ||
1371 | return "COMP"; | ||
1372 | case EDJE_EDIT_IMAGE_COMP_LOSSY: | ||
1373 | rate = edje_edit_image_compression_rate_get(ed, img); | ||
1374 | snprintf(buf, sizeof(buf), "LOSSY %d", rate); | ||
1375 | return buf; | ||
1376 | default: | ||
1377 | ERR("Unknown compression type %d", type); | ||
1378 | return "???"; | ||
1379 | } | ||
1380 | } | ||
1381 | |||
1382 | static Eina_Bool | ||
1383 | _images_list(void) | ||
1384 | { | ||
1385 | Evas_Object *ed = _edje_object_any_get(); | ||
1386 | Eina_List *l, *images; | ||
1387 | const char *img; | ||
1388 | |||
1389 | if (!ed) return EINA_FALSE; | ||
1390 | |||
1391 | images = edje_edit_images_list_get(ed); | ||
1392 | |||
1393 | if (machine) puts("IMAGES-BEGIN"); | ||
1394 | else puts("images {"); | ||
1395 | |||
1396 | EINA_LIST_FOREACH(images, l, img) | ||
1397 | { | ||
1398 | int id = edje_edit_image_id_get(ed, img); | ||
1399 | const char *comp = _comp_str_get(ed, img); | ||
1400 | |||
1401 | if (detail < 1) | ||
1402 | { | ||
1403 | if (machine) printf("IMAGE: %s\n", img); | ||
1404 | else printf(INDENT "image: \"%s\" %s;\n", img, comp); | ||
1405 | } | ||
1406 | else if (detail == 1) | ||
1407 | { | ||
1408 | if (machine) printf("IMAGE: \"%s\" \"%s\"\n", img, comp); | ||
1409 | else printf(INDENT "image: \"%s\" %s;\n", img, comp); | ||
1410 | } | ||
1411 | else | ||
1412 | { | ||
1413 | if (machine) | ||
1414 | printf("IMAGE: \"edje/images/%d\" \"%s\" \"%s\"\n", | ||
1415 | id, img, comp); | ||
1416 | else | ||
1417 | printf(INDENT "image: \"%s\" %s; /* id: \"edje/images/%d\" */\n", | ||
1418 | img, comp, id); | ||
1419 | } | ||
1420 | } | ||
1421 | |||
1422 | if (machine) puts("IMAGES-END"); | ||
1423 | else puts("}"); | ||
1424 | |||
1425 | edje_edit_string_list_free(images); | ||
1426 | evas_object_del(ed); | ||
1427 | return EINA_TRUE; | ||
1428 | } | ||
1429 | |||
1430 | static Eina_Bool | ||
1431 | _fonts_list(void) | ||
1432 | { | ||
1433 | Evas_Object *ed = _edje_object_any_get(); | ||
1434 | Eina_List *l, *fonts; | ||
1435 | const char *alias; | ||
1436 | |||
1437 | if (!ed) return EINA_FALSE; | ||
1438 | |||
1439 | fonts = edje_edit_fonts_list_get(ed); | ||
1440 | |||
1441 | if (machine) puts("FONTS-BEGIN"); | ||
1442 | else puts("fonts {"); | ||
1443 | |||
1444 | EINA_LIST_FOREACH(fonts, l, alias) | ||
1445 | { | ||
1446 | const char *path = edje_edit_font_path_get(ed, alias); | ||
1447 | |||
1448 | if (detail < 1) | ||
1449 | { | ||
1450 | if (machine) printf("FONT: %s\n", alias); | ||
1451 | else printf(INDENT "font: \"%s\" \"%s\";\n", path, alias); | ||
1452 | } | ||
1453 | else if (detail == 1) | ||
1454 | { | ||
1455 | if (machine) printf("FONT: \"%s\" \"%s\"\n", path, alias); | ||
1456 | else printf(INDENT "font: \"%s\" \"%s\";\n", path, alias); | ||
1457 | } | ||
1458 | else | ||
1459 | { | ||
1460 | if (machine) | ||
1461 | printf("FONT: \"edje/fonts/%s\" \"%s\" \"%s\"\n", | ||
1462 | alias, path, alias); | ||
1463 | else | ||
1464 | printf(INDENT | ||
1465 | "font: \"%s\" \"%s\"; /* id: \"edje/fonts/%s\" */\n", | ||
1466 | path, alias, alias); | ||
1467 | } | ||
1468 | |||
1469 | edje_edit_string_free(path); | ||
1470 | } | ||
1471 | |||
1472 | if (machine) puts("FONTS-END"); | ||
1473 | else puts("}"); | ||
1474 | |||
1475 | edje_edit_string_list_free(fonts); | ||
1476 | evas_object_del(ed); | ||
1477 | return EINA_TRUE; | ||
1478 | } | ||
1479 | |||
1480 | static Eina_Bool | ||
1481 | _externals_list(void) | ||
1482 | { | ||
1483 | Evas_Object *ed = _edje_object_any_get(); | ||
1484 | Eina_List *l, *externals; | ||
1485 | const char *key; | ||
1486 | |||
1487 | if (!ed) return EINA_FALSE; | ||
1488 | |||
1489 | externals = edje_edit_externals_list_get(ed); | ||
1490 | |||
1491 | if (machine) puts("EXTERNALS-BEGIN"); | ||
1492 | else puts("externals {"); | ||
1493 | |||
1494 | EINA_LIST_FOREACH(externals, l, key) | ||
1495 | { | ||
1496 | if (machine) printf("EXTERNAL: %s\n", key); | ||
1497 | else printf(INDENT "external: \"%s\";\n", key); | ||
1498 | } | ||
1499 | |||
1500 | if (machine) puts("EXTERNALS-END"); | ||
1501 | else puts("}"); | ||
1502 | |||
1503 | edje_edit_string_list_free(externals); | ||
1504 | evas_object_del(ed); | ||
1505 | return EINA_TRUE; | ||
1506 | } | ||
1507 | |||
1508 | |||
1509 | int | ||
1510 | main(int argc, char **argv) | ||
1511 | { | ||
1512 | Eina_Bool quit_option = EINA_FALSE; | ||
1513 | char *mode = NULL; | ||
1514 | char *detail_name = NULL; | ||
1515 | int arg_index; | ||
1516 | int ret = 0; | ||
1517 | Ecore_Getopt_Value values[] = { | ||
1518 | ECORE_GETOPT_VALUE_STR(mode), | ||
1519 | ECORE_GETOPT_VALUE_STR(detail_name), | ||
1520 | ECORE_GETOPT_VALUE_STR(group), | ||
1521 | ECORE_GETOPT_VALUE_STR(part), | ||
1522 | ECORE_GETOPT_VALUE_STR(program), | ||
1523 | ECORE_GETOPT_VALUE_BOOL(api_only), | ||
1524 | ECORE_GETOPT_VALUE_BOOL(api_fix), | ||
1525 | ECORE_GETOPT_VALUE_BOOL(machine), | ||
1526 | ECORE_GETOPT_VALUE_BOOL(quit_option), | ||
1527 | ECORE_GETOPT_VALUE_BOOL(quit_option), | ||
1528 | ECORE_GETOPT_VALUE_BOOL(quit_option), | ||
1529 | ECORE_GETOPT_VALUE_BOOL(quit_option), | ||
1530 | ECORE_GETOPT_VALUE_NONE | ||
1531 | }; | ||
1532 | |||
1533 | setlocale(LC_NUMERIC, "C"); | ||
1534 | |||
1535 | ecore_init(); | ||
1536 | ecore_evas_init(); | ||
1537 | eina_init(); | ||
1538 | edje_init(); | ||
1539 | |||
1540 | _log_dom = eina_log_domain_register("edje_inspector", EINA_COLOR_YELLOW); | ||
1541 | if (_log_dom < 0) | ||
1542 | { | ||
1543 | EINA_LOG_CRIT("could not register log domain 'edje_inspector'"); | ||
1544 | ret = 1; | ||
1545 | goto error_log; | ||
1546 | } | ||
1547 | |||
1548 | arg_index = ecore_getopt_parse(&optdesc, values, argc, argv); | ||
1549 | if (arg_index < 0) | ||
1550 | { | ||
1551 | ERR("could not parse arguments."); | ||
1552 | ret = 1; | ||
1553 | goto error_getopt; | ||
1554 | } | ||
1555 | else if (quit_option) goto error_getopt; | ||
1556 | else if (arg_index != argc - 1) | ||
1557 | { | ||
1558 | ERR("incorrect number of parameters. Requires one single file."); | ||
1559 | ret = 1; | ||
1560 | goto error_getopt; | ||
1561 | } | ||
1562 | |||
1563 | if (!mode) mode = (char *)mode_choices[0]; | ||
1564 | |||
1565 | if (detail_name) | ||
1566 | { | ||
1567 | if (!strcmp(detail_name, "none")) detail = 0; | ||
1568 | else if (!strcmp(detail_name, "terse")) detail = 1; | ||
1569 | else if (!strcmp(detail_name, "all")) detail = 2; | ||
1570 | else ERR("Unknown detail level: '%s'", detail_name); | ||
1571 | } | ||
1572 | |||
1573 | file = argv[arg_index]; | ||
1574 | |||
1575 | // check if the file is accessible | ||
1576 | if (access(file, R_OK) == -1) | ||
1577 | { | ||
1578 | int e = errno; | ||
1579 | ERR("File '%s' not accessible, error %d (%s).\n", | ||
1580 | file, e, strerror(e)); | ||
1581 | ret = 1; | ||
1582 | goto error_getopt; | ||
1583 | } | ||
1584 | |||
1585 | DBG("mode=%s, detail=%d(%s), group=%s, part=%s, program=%s, api-only=%hhu" | ||
1586 | ", api-fix=%hhu, machine=%hhu, file=%s", | ||
1587 | mode, detail, detail_name, | ||
1588 | group ? group : "", | ||
1589 | part ? part : "", | ||
1590 | program ? program : "", | ||
1591 | api_only, api_fix, machine, file); | ||
1592 | |||
1593 | |||
1594 | groups = edje_file_collection_list(file); | ||
1595 | if (!groups) | ||
1596 | { | ||
1597 | ERR("no groups in edje file '%s'", file); | ||
1598 | ret = 1; | ||
1599 | goto error_getopt; | ||
1600 | } | ||
1601 | |||
1602 | if (!strcmp(mode, "groups-names")) ret = _groups_names_list(); | ||
1603 | else | ||
1604 | { | ||
1605 | ee = ecore_evas_buffer_new(1, 1); | ||
1606 | if (!ee) | ||
1607 | { | ||
1608 | ERR("could not create ecore_evas_buffer"); | ||
1609 | ret = 1; | ||
1610 | } | ||
1611 | else | ||
1612 | { | ||
1613 | if (!strcmp(mode, "parts-names")) ret = _parts_names_list(); | ||
1614 | else if (!strcmp(mode, "global-data")) ret = _gdata_list(); | ||
1615 | else if (!strcmp(mode, "images")) ret = _images_list(); | ||
1616 | else if (!strcmp(mode, "fonts")) ret = _fonts_list(); | ||
1617 | else if (!strcmp(mode, "externals")) ret = _externals_list(); | ||
1618 | else ret = _list(mode); | ||
1619 | ecore_evas_free(ee); | ||
1620 | } | ||
1621 | } | ||
1622 | |||
1623 | edje_file_collection_list_free(groups); | ||
1624 | error_getopt: | ||
1625 | eina_log_domain_unregister(_log_dom); | ||
1626 | error_log: | ||
1627 | edje_shutdown(); | ||
1628 | ecore_evas_shutdown(); | ||
1629 | ecore_shutdown(); | ||
1630 | eina_shutdown(); | ||
1631 | |||
1632 | return ret; | ||
1633 | } | ||