diff options
author | Vincent Torri <vincent.torri@gmail.com> | 2010-10-23 14:03:30 +0000 |
---|---|---|
committer | Vincent Torri <vincent.torri@gmail.com> | 2010-10-23 14:03:30 +0000 |
commit | 1090b2430392749bc544edb42e86682ac1c0a457 (patch) | |
tree | fb6e87d4b809a8370a274c6a0ea9c775607ed0b6 /legacy/emotion | |
parent | c7c886ea2c861a251921417d41a8f4ec1a0c9de7 (diff) |
[emotion] use ecore_getopt
SVN revision: 53813
Diffstat (limited to 'legacy/emotion')
-rw-r--r-- | legacy/emotion/src/bin/emotion_test_main.c | 283 |
1 files changed, 127 insertions, 156 deletions
diff --git a/legacy/emotion/src/bin/emotion_test_main.c b/legacy/emotion/src/bin/emotion_test_main.c index 80b0438cd3..7e799e6929 100644 --- a/legacy/emotion/src/bin/emotion_test_main.c +++ b/legacy/emotion/src/bin/emotion_test_main.c | |||
@@ -5,11 +5,39 @@ | |||
5 | 5 | ||
6 | #include <Evas.h> | 6 | #include <Evas.h> |
7 | #include <Ecore.h> | 7 | #include <Ecore.h> |
8 | #include <Ecore_Getopt.h> | ||
8 | #include <Ecore_Evas.h> | 9 | #include <Ecore_Evas.h> |
9 | #include <Edje.h> | 10 | #include <Edje.h> |
10 | 11 | ||
11 | #include "Emotion.h" | 12 | #include "Emotion.h" |
12 | 13 | ||
14 | static const Ecore_Getopt options = { | ||
15 | "emotion_test", | ||
16 | "%prog [options]", | ||
17 | "1.0.0", | ||
18 | "(C) 2010 Enlightenment", | ||
19 | "BSD\nThis is a 3 clause bsd bla bla", | ||
20 | "a simple test program for emotion using enlightenment foundation libraries.\n" | ||
21 | "Here is the text of the licence", | ||
22 | 1, | ||
23 | { | ||
24 | ECORE_GETOPT_STORE_STR('e', "engine", "ecore-evas engine to use"), | ||
25 | ECORE_GETOPT_CALLBACK_NOARGS('E', "list-engines", "list ecore-evas engines", | ||
26 | ecore_getopt_callback_ecore_evas_list_engines, NULL), | ||
27 | ECORE_GETOPT_CALLBACK_ARGS('g', "geometry", "geometry to use in x:y:w:h form.", "X:Y:W:H", | ||
28 | ecore_getopt_callback_geometry_parse, NULL), | ||
29 | ECORE_GETOPT_STORE_STR('b', "backend", "backend to use"), | ||
30 | ECORE_GETOPT_STORE_STR('f', "filename", "file to playback"), | ||
31 | ECORE_GETOPT_STORE_INT('v', "vis", "visualization type"), | ||
32 | ECORE_GETOPT_COUNT('v', "verbose", "be more verbose"), | ||
33 | ECORE_GETOPT_VERSION('V', "version"), | ||
34 | ECORE_GETOPT_COPYRIGHT('R', "copyright"), | ||
35 | ECORE_GETOPT_LICENSE('L', "license"), | ||
36 | ECORE_GETOPT_HELP('h', "help"), | ||
37 | ECORE_GETOPT_SENTINEL | ||
38 | } | ||
39 | }; | ||
40 | |||
13 | typedef struct _Frame_Data Frame_Data; | 41 | typedef struct _Frame_Data Frame_Data; |
14 | 42 | ||
15 | struct _Frame_Data | 43 | struct _Frame_Data |
@@ -20,8 +48,6 @@ struct _Frame_Data | |||
20 | Evas_Coord x, y; | 48 | Evas_Coord x, y; |
21 | }; | 49 | }; |
22 | 50 | ||
23 | static int main_start(int argc, char **argv); | ||
24 | static void main_stop(void); | ||
25 | static void main_resize(Ecore_Evas *ee); | 51 | static void main_resize(Ecore_Evas *ee); |
26 | static Eina_Bool main_signal_exit(void *data, int ev_type, void *ev); | 52 | static Eina_Bool main_signal_exit(void *data, int ev_type, void *ev); |
27 | static void main_delete_request(Ecore_Evas *ee); | 53 | static void main_delete_request(Ecore_Evas *ee); |
@@ -41,106 +67,6 @@ static int starth = 600; | |||
41 | static Eina_List *video_objs = NULL; | 67 | static Eina_List *video_objs = NULL; |
42 | static Emotion_Vis vis = EMOTION_VIS_NONE; | 68 | static Emotion_Vis vis = EMOTION_VIS_NONE; |
43 | 69 | ||
44 | static int | ||
45 | main_start(int argc, char **argv) | ||
46 | { | ||
47 | int mode = 0; | ||
48 | |||
49 | eina_init(); | ||
50 | |||
51 | start_time = ecore_time_get(); | ||
52 | if (!ecore_init()) return -1; | ||
53 | ecore_app_args_set(argc, (const char **)argv); | ||
54 | ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, NULL); | ||
55 | |||
56 | edje_init(); | ||
57 | edje_frametime_set(1.0 / 30.0); | ||
58 | |||
59 | if (!ecore_evas_init()) return -1; | ||
60 | { | ||
61 | int i; | ||
62 | |||
63 | for (i = 1; i < argc; i++) | ||
64 | { | ||
65 | if (((!strcmp(argv[i], "-g")) || | ||
66 | (!strcmp(argv[i], "-geometry")) || | ||
67 | (!strcmp(argv[i], "--geometry"))) && (i < (argc - 1))) | ||
68 | { | ||
69 | int n, w, h; | ||
70 | char buf[16], buf2[16]; | ||
71 | |||
72 | n = sscanf(argv[i +1], "%10[^x]x%10s", buf, buf2); | ||
73 | if (n == 2) | ||
74 | { | ||
75 | w = atoi(buf); | ||
76 | h = atoi(buf2); | ||
77 | startw = w; | ||
78 | starth = h; | ||
79 | } | ||
80 | i++; | ||
81 | } | ||
82 | else if (!strcmp(argv[i], "-gl")) | ||
83 | { | ||
84 | mode = 1; | ||
85 | } | ||
86 | else if (!strcmp(argv[i], "-fb")) | ||
87 | { | ||
88 | mode = 2; | ||
89 | } | ||
90 | else if (!strcmp(argv[i], "-xr")) | ||
91 | { | ||
92 | mode = 3; | ||
93 | } | ||
94 | else if (!strcmp(argv[i], "-auto")) | ||
95 | { | ||
96 | mode = 4; | ||
97 | } | ||
98 | else if ((!strcmp(argv[i], "-vis")) && (i < (argc - 1))) | ||
99 | { | ||
100 | vis = atoi(argv[i + 1]); | ||
101 | i++; | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | if (mode == 4) | ||
106 | ecore_evas = ecore_evas_new(NULL, 0, 0, startw, starth, NULL); | ||
107 | if (mode == 0) | ||
108 | ecore_evas = ecore_evas_software_x11_new(NULL, 0, 0, 0, startw, starth); | ||
109 | if (mode == 1) | ||
110 | ecore_evas = ecore_evas_gl_x11_new(NULL, 0, 0, 0, startw, starth); | ||
111 | if (mode == 2) | ||
112 | ecore_evas = ecore_evas_fb_new(NULL, 0, startw, starth); | ||
113 | if (mode == 3) | ||
114 | ecore_evas = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, startw, starth); | ||
115 | |||
116 | |||
117 | if (!ecore_evas) return -1; | ||
118 | ecore_evas_callback_delete_request_set(ecore_evas, main_delete_request); | ||
119 | ecore_evas_callback_resize_set(ecore_evas, main_resize); | ||
120 | ecore_evas_title_set(ecore_evas, "Evas Media Test Program"); | ||
121 | ecore_evas_name_class_set(ecore_evas, "evas_media_test", "main"); | ||
122 | ecore_evas_show(ecore_evas); | ||
123 | evas = ecore_evas_get(ecore_evas); | ||
124 | evas_image_cache_set(evas, 8 * 1024 * 1024); | ||
125 | evas_font_cache_set(evas, 1 * 1024 * 1024); | ||
126 | evas_font_path_append(evas, PACKAGE_DATA_DIR"/data/fonts"); | ||
127 | |||
128 | return 1; | ||
129 | } | ||
130 | |||
131 | static void | ||
132 | main_stop(void) | ||
133 | { | ||
134 | main_signal_exit(NULL, 0, NULL); | ||
135 | |||
136 | ecore_evas_free(ecore_evas); | ||
137 | |||
138 | ecore_evas_shutdown(); | ||
139 | edje_shutdown(); | ||
140 | ecore_shutdown(); | ||
141 | eina_shutdown(); | ||
142 | } | ||
143 | |||
144 | static void | 70 | static void |
145 | main_resize(Ecore_Evas *ee) | 71 | main_resize(Ecore_Evas *ee) |
146 | { | 72 | { |
@@ -796,68 +722,113 @@ check_positions(void *data) | |||
796 | int | 722 | int |
797 | main(int argc, char **argv) | 723 | main(int argc, char **argv) |
798 | { | 724 | { |
799 | char *module_filename; | 725 | int args; |
800 | int i; | 726 | Eina_Rectangle geometry = {0, 0, startw, starth}; |
801 | 727 | char *engine = NULL; | |
802 | if (main_start(argc, argv) < 1) return -1; | 728 | char *backend = "xine"; |
803 | bg_setup(); | 729 | char *filename = NULL; |
730 | int verbose = 0; | ||
731 | int visual = EMOTION_VIS_NONE; | ||
732 | unsigned char help = 0; | ||
733 | unsigned char engines_listed = 0; | ||
734 | Ecore_Getopt_Value values[] = { | ||
735 | ECORE_GETOPT_VALUE_STR(engine), | ||
736 | ECORE_GETOPT_VALUE_BOOL(engines_listed), | ||
737 | ECORE_GETOPT_VALUE_PTR_CAST(geometry), | ||
738 | ECORE_GETOPT_VALUE_STR(backend), | ||
739 | ECORE_GETOPT_VALUE_STR(filename), | ||
740 | ECORE_GETOPT_VALUE_INT(visual), | ||
741 | ECORE_GETOPT_VALUE_INT(verbose), | ||
742 | ECORE_GETOPT_VALUE_NONE, | ||
743 | ECORE_GETOPT_VALUE_NONE, | ||
744 | ECORE_GETOPT_VALUE_NONE, | ||
745 | ECORE_GETOPT_VALUE_BOOL(help), | ||
746 | ECORE_GETOPT_VALUE_NONE | ||
747 | }; | ||
748 | |||
749 | |||
750 | if (!ecore_evas_init()) | ||
751 | return -1; | ||
752 | if (!edje_init()) | ||
753 | goto shutdown_ecore_evas; | ||
804 | 754 | ||
805 | module_filename = "xine"; | 755 | start_time = ecore_time_get(); |
756 | ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, NULL); | ||
757 | edje_frametime_set(1.0 / 30.0); | ||
806 | 758 | ||
807 | for (i = 1; i < argc; i++) | 759 | ecore_app_args_set(argc, (const char **)argv); |
760 | args = ecore_getopt_parse(&options, values, argc, argv); | ||
761 | if (args < 0) | ||
762 | goto shutdown_edje; | ||
763 | |||
764 | if (help) | ||
765 | goto shutdown_edje; | ||
766 | if (engines_listed) | ||
767 | goto shutdown_edje; | ||
768 | if (!engine) | ||
808 | { | 769 | { |
809 | if (((!strcmp(argv[i], "-g")) || | 770 | printf ("select engine\n"); |
810 | (!strcmp(argv[i], "-geometry")) || | 771 | goto shutdown_edje; |
811 | (!strcmp(argv[i], "--geometry"))) && (i < (argc - 1))) | 772 | } |
812 | i++; | 773 | if (!filename) |
813 | else if (((!strcmp(argv[i], "-h")) || | 774 | { |
814 | (!strcmp(argv[i], "-help")) || | 775 | printf ("select engine\n"); |
815 | (!strcmp(argv[i], "--help")))) | 776 | goto shutdown_edje; |
816 | { | 777 | } |
817 | printf("Usage:\n"); | 778 | if (!backend) |
818 | printf(" %s [-gl] [-g WxH] [-vis NUMBER] [-xine] [-gstreamer] [-vlc] filename\n", argv[0]); | 779 | { |
819 | exit(-1); | 780 | backend = "xine"; |
820 | } | 781 | printf ("selected backend: %s\n", backend); |
821 | else if (!strcmp(argv[i], "-gl")) | 782 | goto shutdown_edje; |
822 | { | ||
823 | } | ||
824 | else if (!strcmp(argv[i], "-fb")) | ||
825 | { | ||
826 | } | ||
827 | else if (!strcmp(argv[i], "-xr")) | ||
828 | { | ||
829 | } | ||
830 | else if (!strcmp(argv[i], "-auto")) | ||
831 | { | ||
832 | module_filename = NULL; | ||
833 | } | ||
834 | else if (!strcmp(argv[i], "-xine")) | ||
835 | { | ||
836 | module_filename = "xine"; | ||
837 | } | ||
838 | else if (!strcmp(argv[i], "-gstreamer")) | ||
839 | { | ||
840 | module_filename = "gstreamer"; | ||
841 | } | ||
842 | else if (!strcmp(argv[i], "-vlc")) | ||
843 | { | ||
844 | module_filename = "vlc"; | ||
845 | } | ||
846 | else if ((!strcmp(argv[i], "-vis")) && (i < (argc - 1))) | ||
847 | { | ||
848 | i++; | ||
849 | } | ||
850 | else | ||
851 | { | ||
852 | printf ("module : %s\n", module_filename); | ||
853 | init_video_object(module_filename, argv[i]); | ||
854 | } | ||
855 | } | 783 | } |
784 | if ((geometry.w == 0) || (geometry.h == 0)) | ||
785 | { | ||
786 | printf("size nulle\n"); | ||
787 | goto shutdown_edje; | ||
788 | } | ||
789 | |||
790 | printf ("backend: %s\n", backend); | ||
791 | printf ("filename: %s\n", filename); | ||
792 | printf ("vis: %d\n", vis); | ||
793 | printf ("engine: %s\n", engine); | ||
794 | printf ("geometry: %d %d %dx%d\n", geometry.x, geometry.y, geometry.w, geometry.h); | ||
795 | |||
796 | ecore_evas = ecore_evas_new(engine, | ||
797 | geometry.x, geometry.y, geometry.w, geometry.h, | ||
798 | NULL); | ||
799 | if (!ecore_evas) | ||
800 | goto shutdown_edje; | ||
801 | |||
802 | ecore_evas_callback_delete_request_set(ecore_evas, main_delete_request); | ||
803 | ecore_evas_callback_resize_set(ecore_evas, main_resize); | ||
804 | ecore_evas_title_set(ecore_evas, "Evas Media Test Program"); | ||
805 | ecore_evas_name_class_set(ecore_evas, "evas_media_test", "main"); | ||
806 | ecore_evas_show(ecore_evas); | ||
807 | evas = ecore_evas_get(ecore_evas); | ||
808 | evas_image_cache_set(evas, 8 * 1024 * 1024); | ||
809 | evas_font_cache_set(evas, 1 * 1024 * 1024); | ||
810 | evas_font_path_append(evas, PACKAGE_DATA_DIR"/data/fonts"); | ||
811 | |||
812 | bg_setup(); | ||
813 | |||
814 | init_video_object(backend, filename); | ||
856 | 815 | ||
857 | ecore_idle_enterer_add(enter_idle, NULL); | 816 | ecore_idle_enterer_add(enter_idle, NULL); |
858 | ecore_animator_add(check_positions, NULL); | 817 | ecore_animator_add(check_positions, NULL); |
859 | 818 | ||
860 | ecore_main_loop_begin(); | 819 | ecore_main_loop_begin(); |
861 | main_stop(); | 820 | |
821 | main_signal_exit(NULL, 0, NULL); | ||
822 | ecore_evas_free(ecore_evas); | ||
823 | ecore_evas_shutdown(); | ||
824 | edje_shutdown(); | ||
825 | |||
862 | return 0; | 826 | return 0; |
827 | |||
828 | shutdown_edje: | ||
829 | edje_shutdown(); | ||
830 | shutdown_ecore_evas: | ||
831 | ecore_evas_shutdown(); | ||
832 | |||
833 | return -1; | ||
863 | } | 834 | } |