Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/bin Modified Files: ewl_filedialog_multi_test.c ewl_filedialog_test.c ewl_image_test.c ewl_media_test.c Log Message: - make the filedialog return a struct instead of a int coerced into a void * - a bit of reformatting on the tests using the filedialog =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/ewl_filedialog_multi_test.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- ewl_filedialog_multi_test.c 10 Oct 2005 15:27:10 -0000 1.3 +++ ewl_filedialog_multi_test.c 21 Oct 2005 04:13:03 -0000 1.4 @@ -5,15 +5,15 @@ static void __destroy_filedialog_multi_test_window(Ewl_Widget *w, void *ev_data __UNUSED__, - void *user_data __UNUSED__) + void *user_data __UNUSED__) { ewl_widget_destroy(w); } void __create_filedialog_multi_test_window(Ewl_Widget *w __UNUSED__, - void *ev_data __UNUSED__, - void *user_data __UNUSED__) + void *ev_data __UNUSED__, + void *user_data __UNUSED__) { Ewl_Widget *fd = NULL, *win = NULL; @@ -24,15 +24,15 @@ if (w) ewl_callback_append (win, EWL_CALLBACK_DELETE_WINDOW, - __destroy_filedialog_multi_test_window, NULL); + __destroy_filedialog_multi_test_window, NULL); else ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, - __close_main_window, NULL); + __close_main_window, NULL); ewl_widget_show(win); fd = ewl_filedialog_multiselect_new(); ewl_callback_append (fd, EWL_CALLBACK_VALUE_CHANGED, - __create_fdm_window_response, NULL); + __create_fdm_window_response, NULL); ewl_container_child_append(EWL_CONTAINER(win), fd); ewl_widget_show(fd); } @@ -41,24 +41,18 @@ __create_fdm_window_response (Ewl_Widget *w __UNUSED__, void *ev, void *data __UNUSED__) { - int *response; - - response = (int *)ev; - switch (*response) { - case EWL_STOCK_OPEN: - { - Ecore_List *list; - list = ewl_filedialog_select_list_get(EWL_FILEDIALOG(w)); - - ecore_list_for_each(list, __fdm_print, NULL); - break; - } - case EWL_STOCK_CANCEL: - { - printf("Test program says bugger off.\n"); - break; - } - } + Ewl_Filedialog_Event *e; + + e = EWL_FILEDIALOG_EVENT(ev); + if (e->response == EWL_STOCK_OPEN) + { + Ecore_List *list; + list = ewl_filedialog_select_list_get(EWL_FILEDIALOG(w)); + + ecore_list_for_each(list, __fdm_print, NULL); + } + else if (e->response == EWL_STOCK_CANCEL) + printf("Test program says bugger off.\n"); } static void =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/ewl_filedialog_test.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ewl_filedialog_test.c 10 Oct 2005 15:27:10 -0000 1.5 +++ ewl_filedialog_test.c 21 Oct 2005 04:13:03 -0000 1.6 @@ -4,14 +4,14 @@ static void __destroy_filedialog_test_window(Ewl_Widget * w, void *ev_data __UNUSED__, - void *user_data __UNUSED__) + void *user_data __UNUSED__) { ewl_widget_destroy(w); } void __create_filedialog_test_window(Ewl_Widget *w, void *ev_data __UNUSED__, - void *user_data __UNUSED__) + void *user_data __UNUSED__) { Ewl_Widget *fd = NULL, *win = NULL; @@ -22,16 +22,16 @@ if (w) ewl_callback_append (win, EWL_CALLBACK_DELETE_WINDOW, - __destroy_filedialog_test_window, NULL); + __destroy_filedialog_test_window, NULL); else ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, - __close_main_window, NULL); + __close_main_window, NULL); ewl_widget_show(win); fd = ewl_filedialog_new(); ewl_filedialog_type_set(EWL_FILEDIALOG(fd), EWL_FILEDIALOG_TYPE_OPEN); ewl_callback_append (fd, EWL_CALLBACK_VALUE_CHANGED, - __create_fd_window_response, NULL); + __create_fd_window_response, NULL); ewl_container_child_append(EWL_CONTAINER(win), fd); ewl_widget_show(fd); } @@ -39,22 +39,13 @@ static void __create_fd_window_response (Ewl_Widget *w, void *ev, void *data __UNUSED__) { - int *response; - - response = (int *)ev; - switch (*response) - { - case EWL_STOCK_OPEN: - { - printf("file open from test program: %s\n", - ewl_filedialog_file_get (EWL_FILEDIALOG (w))); - break; - } - case EWL_STOCK_CANCEL: - { - printf("Test program says bugger off.\n"); - break; - } - } + Ewl_Filedialog_Event *e; + + e = EWL_FILEDIALOG_EVENT(ev); + if (e->response == EWL_STOCK_OPEN) + printf("file open from test program: %s\n", + ewl_filedialog_file_get (EWL_FILEDIALOG (w))); + else if (e->response == EWL_STOCK_CANCEL) + printf("Test program says bugger off.\n"); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/ewl_image_test.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_image_test.c 10 Oct 2005 15:27:10 -0000 1.6 +++ ewl_image_test.c 21 Oct 2005 04:13:03 -0000 1.7 @@ -256,12 +256,12 @@ static void __create_image_fd_window_response (Ewl_Widget *w, void *ev, void *data) { - int *response; + Ewl_Filedialog_Event *e; Ewl_Widget *entry = data; - response = (int *)ev; + e = EWL_FILEDIALOG_EVENT(ev); - if (*response == EWL_STOCK_OPEN) { + if (e->response == EWL_STOCK_OPEN) { char *path; printf("File open from image test: %s\n", =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/ewl_media_test.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- ewl_media_test.c 10 Oct 2005 15:27:10 -0000 1.8 +++ ewl_media_test.c 21 Oct 2005 04:13:03 -0000 1.9 @@ -17,260 +17,258 @@ static Ewl_Widget *seeker; typedef struct { - Ewl_Stock_Type name; - Ewl_Callback_Function func; + Ewl_Stock_Type name; + Ewl_Callback_Function func; } Control; static void del_cb(Ewl_Widget *w, void *event __UNUSED__, void *data __UNUSED__) { - ewl_widget_hide(w); - ewl_widget_destroy(w); - ewl_main_quit(); + ewl_widget_hide(w); + ewl_widget_destroy(w); + ewl_main_quit(); } static void play_cb(Ewl_Widget *w __UNUSED__, void *event __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - ewl_media_play_set(EWL_MEDIA(video), 1); + ewl_media_play_set(EWL_MEDIA(video), 1); } static void stop_cb(Ewl_Widget *w __UNUSED__, void *event __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - ewl_media_play_set(EWL_MEDIA(video), 0); + ewl_media_play_set(EWL_MEDIA(video), 0); } static void ff_cb(Ewl_Widget *w __UNUSED__, void *event __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - double p; - - p = ewl_media_position_get(EWL_MEDIA(video)); - ewl_media_position_set(EWL_MEDIA(video), p + 10.0); + double p; + + p = ewl_media_position_get(EWL_MEDIA(video)); + ewl_media_position_set(EWL_MEDIA(video), p + 10.0); } static void rew_cb(Ewl_Widget *w __UNUSED__, void *event __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - double p; - - p = ewl_media_position_get(EWL_MEDIA(video)); - ewl_media_position_set(EWL_MEDIA(video), p - 10.0); + double p; + + p = ewl_media_position_get(EWL_MEDIA(video)); + ewl_media_position_set(EWL_MEDIA(video), p - 10.0); } static void video_realize_cb(Ewl_Widget *w __UNUSED__, void *event __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - double len; - - len = ewl_media_length_get(EWL_MEDIA(video)); - ewl_seeker_range_set(EWL_SEEKER(seeker), len); + double len; + + len = ewl_media_length_get(EWL_MEDIA(video)); + ewl_seeker_range_set(EWL_SEEKER(seeker), len); } static void video_change_cb(Ewl_Widget *w __UNUSED__, void *event __UNUSED__, void *data) { - char buf[512]; - int h, m; - double s; - Ewl_Text *t; - double pos; - - t = data; - pos = ewl_media_position_get(EWL_MEDIA(video)); - - ewl_seeker_value_set(EWL_SEEKER(seeker), pos); - ewl_media_position_time_get(EWL_MEDIA(video), &h, &m, &s); - snprintf(buf, sizeof(buf), "%02i:%02i:%02.0f", h, m, s); - ewl_text_text_set(t, buf); + char buf[512]; + int h, m; + double s; + Ewl_Text *t; + double pos; + + t = data; + pos = ewl_media_position_get(EWL_MEDIA(video)); + + ewl_seeker_value_set(EWL_SEEKER(seeker), pos); + ewl_media_position_time_get(EWL_MEDIA(video), &h, &m, &s); + snprintf(buf, sizeof(buf), "%02i:%02i:%02.0f", h, m, s); + ewl_text_text_set(t, buf); } static void seeker_move_cb(Ewl_Widget *w __UNUSED__, void *event __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - double val; - - val = ewl_seeker_value_get(EWL_SEEKER(seeker)); - if (ewl_media_seekable_get(EWL_MEDIA(video))) - ewl_media_position_set(EWL_MEDIA(video), val); + double val; + + val = ewl_seeker_value_get(EWL_SEEKER(seeker)); + if (ewl_media_seekable_get(EWL_MEDIA(video))) + ewl_media_position_set(EWL_MEDIA(video), val); } static void fd_win_del_cb(Ewl_Widget *w, void *event __UNUSED__, void *data __UNUSED__) { - ewl_widget_hide(w); - ewl_widget_destroy(w); + ewl_widget_hide(w); + ewl_widget_destroy(w); } static void open_file_cb(Ewl_Widget *w, void *event, void *data __UNUSED__) { - int *response = (int *)event; - char *file = NULL; + Ewl_Filedialog_Event *e; + char *file = NULL; - ewl_widget_hide(fd_win); + ewl_widget_hide(fd_win); - switch (*response) { - case EWL_STOCK_OPEN: - file = ewl_filedialog_file_get(EWL_FILEDIALOG(w)); - break; - } + e = EWL_FILEDIALOG_EVENT(event); + if (e->response == EWL_STOCK_OPEN) + file = ewl_filedialog_file_get(EWL_FILEDIALOG(w)); - if (file) - ewl_media_media_set(EWL_MEDIA(video), file); + if (file) + ewl_media_media_set(EWL_MEDIA(video), file); } static void open_cb(Ewl_Widget *w __UNUSED__, void *event __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - Ewl_Widget *fd = NULL; + Ewl_Widget *fd = NULL; + + if (fd_win) { + ewl_widget_show(fd_win); + return; + } - if (fd_win) { + fd_win = ewl_window_new(); + ewl_window_title_set(EWL_WINDOW(fd_win), "EWL Media Open"); + ewl_window_class_set(EWL_WINDOW(fd_win), "EWL_Media_Open"); + ewl_window_name_set(EWL_WINDOW(fd_win), "EWL_Media_Open"); + ewl_callback_append(fd_win, EWL_CALLBACK_DELETE_WINDOW, + fd_win_del_cb, NULL); ewl_widget_show(fd_win); - return; - } - fd_win = ewl_window_new(); - ewl_window_title_set(EWL_WINDOW(fd_win), "EWL Media Open"); - ewl_window_class_set(EWL_WINDOW(fd_win), "EWL_Media_Open"); - ewl_window_name_set(EWL_WINDOW(fd_win), "EWL_Media_Open"); - ewl_callback_append(fd_win, EWL_CALLBACK_DELETE_WINDOW, - fd_win_del_cb, NULL); - ewl_widget_show(fd_win); - - fd = ewl_filedialog_new(); - ewl_filedialog_type_set(EWL_FILEDIALOG(fd), EWL_FILEDIALOG_TYPE_OPEN); - ewl_container_child_append(EWL_CONTAINER(fd_win), fd); - ewl_callback_append(fd, EWL_CALLBACK_VALUE_CHANGED, open_file_cb, NULL); - ewl_widget_show(fd); + fd = ewl_filedialog_new(); + ewl_filedialog_type_set(EWL_FILEDIALOG(fd), EWL_FILEDIALOG_TYPE_OPEN); + ewl_container_child_append(EWL_CONTAINER(fd_win), fd); + ewl_callback_append(fd, EWL_CALLBACK_VALUE_CHANGED, open_file_cb, NULL); + ewl_widget_show(fd); } static void key_up_cb(Ewl_Widget *w, void *event, void *data) { - Ewl_Event_Key_Up *e = (Ewl_Event_Key_Up *)event; + Ewl_Event_Key_Up *e = (Ewl_Event_Key_Up *)event; - if (!strcmp(e->keyname, "p")) - ewl_media_play_set(EWL_MEDIA(video), 1); + if (!strcmp(e->keyname, "p")) + ewl_media_play_set(EWL_MEDIA(video), 1); - else if (!strcmp(e->keyname, "s")) - ewl_media_play_set(EWL_MEDIA(video), 0); + else if (!strcmp(e->keyname, "s")) + ewl_media_play_set(EWL_MEDIA(video), 0); - else if (!strcmp(e->keyname, "q")) - del_cb(w, event, data); + else if (!strcmp(e->keyname, "q")) + del_cb(w, event, data); } int main(int argc, char ** argv) { - Ewl_Widget *win = NULL, *o = NULL, *b = NULL; - Ewl_Widget *controls = NULL, *time = NULL; - char * module = NULL; - char * file = NULL; - - if (!ewl_init(&argc, argv)) { - printf("Can't init ewl"); - return 1; - } - - if (argc > 1) { - module = argv[1]; - if (argc > 2) - file = argv[2]; - } - - win = ewl_window_new(); - ewl_window_title_set(EWL_WINDOW(win), "EWL Media test"); - ewl_window_name_set(EWL_WINDOW(win), "EWL_Media_test"); - ewl_window_class_set(EWL_WINDOW(win), "EWL_Media_test"); - ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, del_cb, NULL); - ewl_callback_append(win, EWL_CALLBACK_KEY_UP, key_up_cb, NULL); - ewl_object_size_request(EWL_OBJECT(win), 320, 280); - ewl_object_fill_policy_set(EWL_OBJECT(win), EWL_FLAG_FILL_ALL); - ewl_widget_show(win); - - /* box to contain everything */ - b = ewl_vbox_new(); - ewl_container_child_append(EWL_CONTAINER(win), b); - ewl_object_fill_policy_set(EWL_OBJECT(b), EWL_FLAG_FILL_ALL); - ewl_widget_show(b); - - /* create the time widget now so we can pass it to the video as data */ - time = ewl_text_new(); - ewl_text_text_set(EWL_TEXT(time), "00:00:00"); - - /* the video */ - video = ewl_media_new(module, file); - ewl_container_child_append(EWL_CONTAINER(b), video); - ewl_object_fill_policy_set(EWL_OBJECT(video), EWL_FLAG_FILL_ALL); - ewl_callback_append(video, EWL_CALLBACK_REALIZE, video_realize_cb, NULL); - ewl_callback_append(video, EWL_CALLBACK_VALUE_CHANGED, video_change_cb, time); - ewl_widget_show(video); - - /* box to contain contols and scrollers */ - controls = ewl_vbox_new(); - ewl_object_fill_policy_set(EWL_OBJECT(controls), - EWL_FLAG_FILL_VSHRINK | EWL_FLAG_FILL_HFILL); - ewl_container_child_append(EWL_CONTAINER(b), controls); - ewl_widget_show(controls); - - /* hold he controls */ - b = ewl_hbox_new(); - ewl_container_child_append(EWL_CONTAINER(controls), b); - ewl_widget_show(b); - - { - Control controls [] = { - { EWL_STOCK_PLAY, play_cb }, - { EWL_STOCK_STOP, stop_cb }, - { EWL_STOCK_REWIND, rew_cb }, - { EWL_STOCK_FASTFORWARD, ff_cb }, - { EWL_STOCK_OPEN, open_cb }, - { EWL_STOCK_NONE, NULL } + Ewl_Widget *win = NULL, *o = NULL, *b = NULL; + Ewl_Widget *controls = NULL, *time = NULL; + char * module = NULL; + char * file = NULL; + + if (!ewl_init(&argc, argv)) { + printf("Can't init ewl"); + return 1; + } + + if (argc > 1) { + module = argv[1]; + if (argc > 2) + file = argv[2]; + } + + win = ewl_window_new(); + ewl_window_title_set(EWL_WINDOW(win), "EWL Media test"); + ewl_window_name_set(EWL_WINDOW(win), "EWL_Media_test"); + ewl_window_class_set(EWL_WINDOW(win), "EWL_Media_test"); + ewl_callback_append(win, EWL_CALLBACK_DELETE_WINDOW, del_cb, NULL); + ewl_callback_append(win, EWL_CALLBACK_KEY_UP, key_up_cb, NULL); + ewl_object_size_request(EWL_OBJECT(win), 320, 280); + ewl_object_fill_policy_set(EWL_OBJECT(win), EWL_FLAG_FILL_ALL); + ewl_widget_show(win); + + /* box to contain everything */ + b = ewl_vbox_new(); + ewl_container_child_append(EWL_CONTAINER(win), b); + ewl_object_fill_policy_set(EWL_OBJECT(b), EWL_FLAG_FILL_ALL); + ewl_widget_show(b); + + /* create the time widget now so we can pass it to the video as data */ + time = ewl_text_new(); + ewl_text_text_set(EWL_TEXT(time), "00:00:00"); + + /* the video */ + video = ewl_media_new(module, file); + ewl_container_child_append(EWL_CONTAINER(b), video); + ewl_object_fill_policy_set(EWL_OBJECT(video), EWL_FLAG_FILL_ALL); + ewl_callback_append(video, EWL_CALLBACK_REALIZE, video_realize_cb, NULL); + ewl_callback_append(video, EWL_CALLBACK_VALUE_CHANGED, video_change_cb, time); + ewl_widget_show(video); + + /* box to contain contols and scrollers */ + controls = ewl_vbox_new(); + ewl_object_fill_policy_set(EWL_OBJECT(controls), + EWL_FLAG_FILL_VSHRINK | EWL_FLAG_FILL_HFILL); + ewl_container_child_append(EWL_CONTAINER(b), controls); + ewl_widget_show(controls); + + /* hold he controls */ + b = ewl_hbox_new(); + ewl_container_child_append(EWL_CONTAINER(controls), b); + ewl_widget_show(b); + + { + Control controls [] = { + { EWL_STOCK_PLAY, play_cb }, + { EWL_STOCK_STOP, stop_cb }, + { EWL_STOCK_REWIND, rew_cb }, + { EWL_STOCK_FASTFORWARD, ff_cb }, + { EWL_STOCK_OPEN, open_cb }, + { EWL_STOCK_NONE, NULL } }; - int i; + int i; - for(i = 0; controls[i].name != EWL_STOCK_NONE; i++) { - o = ewl_button_new(); - ewl_button_stock_type_set(EWL_BUTTON(o), controls[i].name); - ewl_container_child_append(EWL_CONTAINER(b), o); - ewl_callback_append(o, EWL_CALLBACK_CLICKED, + for(i = 0; controls[i].name != EWL_STOCK_NONE; i++) { + o = ewl_button_new(); + ewl_button_stock_type_set(EWL_BUTTON(o), controls[i].name); + ewl_container_child_append(EWL_CONTAINER(b), o); + ewl_callback_append(o, EWL_CALLBACK_CLICKED, controls[i].func, NULL); - ewl_widget_show(o); + ewl_widget_show(o); + } } - } - b = ewl_hbox_new(); - ewl_container_child_append(EWL_CONTAINER(controls), b); - ewl_widget_show(b); - - /* the video seeker */ - seeker = ewl_seeker_new(EWL_ORIENTATION_HORIZONTAL); - ewl_container_child_append(EWL_CONTAINER(b), seeker); - ewl_object_fill_policy_set(EWL_OBJECT(seeker), - EWL_FLAG_FILL_VSHRINK | EWL_FLAG_FILL_HFILL); - ewl_seeker_value_set(EWL_SEEKER(seeker), 0.0); - ewl_seeker_range_set(EWL_SEEKER(seeker), 0.0); - ewl_seeker_step_set(EWL_SEEKER(seeker), 1.0); - ewl_callback_append(seeker, EWL_CALLBACK_VALUE_CHANGED, seeker_move_cb, video); - ewl_widget_show(seeker); - - /* the time text spot */ - ewl_container_child_append(EWL_CONTAINER(b), time); - ewl_object_insets_set(EWL_OBJECT(time), 0, 3, 0, 0); - ewl_object_fill_policy_set(EWL_OBJECT(time), EWL_FLAG_FILL_SHRINK); - ewl_widget_show(time); + b = ewl_hbox_new(); + ewl_container_child_append(EWL_CONTAINER(controls), b); + ewl_widget_show(b); + + /* the video seeker */ + seeker = ewl_seeker_new(EWL_ORIENTATION_HORIZONTAL); + ewl_container_child_append(EWL_CONTAINER(b), seeker); + ewl_object_fill_policy_set(EWL_OBJECT(seeker), + EWL_FLAG_FILL_VSHRINK | EWL_FLAG_FILL_HFILL); + ewl_seeker_value_set(EWL_SEEKER(seeker), 0.0); + ewl_seeker_range_set(EWL_SEEKER(seeker), 0.0); + ewl_seeker_step_set(EWL_SEEKER(seeker), 1.0); + ewl_callback_append(seeker, EWL_CALLBACK_VALUE_CHANGED, seeker_move_cb, video); + ewl_widget_show(seeker); + + /* the time text spot */ + ewl_container_child_append(EWL_CONTAINER(b), time); + ewl_object_insets_set(EWL_OBJECT(time), 0, 3, 0, 0); + ewl_object_fill_policy_set(EWL_OBJECT(time), EWL_FLAG_FILL_SHRINK); + ewl_widget_show(time); - ewl_main(); - return 0; + ewl_main(); + return 0; } ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs