Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/bin/tests/progressbar Modified Files: ewl_progressbar_test.c Log Message: - change tabs to spaces (Ewl uses 8 space indent now instead of a tab) =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/progressbar/ewl_progressbar_test.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ewl_progressbar_test.c 4 Dec 2007 05:28:03 -0000 1.1 +++ ewl_progressbar_test.c 6 May 2008 20:18:56 -0000 1.2 @@ -1,4 +1,4 @@ -/* vim: set sw=8 ts=8 sts=8 noexpandtab: */ +/* vim: set sw=8 ts=8 sts=8 expandtab: */ #include "Ewl_Test.h" #include "ewl_test_private.h" #include "ewl_button.h" @@ -11,7 +11,7 @@ static void cb_rerun_progressbars(Ewl_Widget *w, void *ev, void *data); static void cb_set_new_range(Ewl_Widget *w, void *ev, void *data); static void cb_destroy_progressbar_test(Ewl_Widget *w, void *ev, - void *data); + void *data); static int cb_increment_progress(void *data); static Ecore_Timer *progress_timer[3]; @@ -20,199 +20,199 @@ void test_info(Ewl_Test *test) { - test->name = "Progressbar"; - test->tip = "Provides a progress bar from a given value."; - test->filename = __FILE__; - test->func = create_test; - test->type = EWL_TEST_TYPE_SIMPLE; + test->name = "Progressbar"; + test->tip = "Provides a progress bar from a given value."; + test->filename = __FILE__; + test->func = create_test; + test->type = EWL_TEST_TYPE_SIMPLE; } static int create_test(Ewl_Container *box) { - Ewl_Widget *progressbar_vbox, *button, *progressbar_box; - int i; + Ewl_Widget *progressbar_vbox, *button, *progressbar_box; + int i; - progressbar_vbox = ewl_vbox_new(); - ewl_container_child_append(EWL_CONTAINER(box), progressbar_vbox); - ewl_box_spacing_set(EWL_BOX(progressbar_vbox), 0); - ewl_callback_prepend(EWL_WIDGET(progressbar_vbox), EWL_CALLBACK_DESTROY, - cb_destroy_progressbar_test, NULL); - ewl_widget_show(progressbar_vbox); - - - progressbar_box = ewl_hbox_new(); - ewl_container_child_append(EWL_CONTAINER(progressbar_vbox), - progressbar_box); - ewl_box_spacing_set(EWL_BOX(progressbar_box), 0); - ewl_widget_show(progressbar_box); - - /* - * First and second progressbar - */ - for (i = 0; i < 2; i++) { - progressbar[i] = ewl_progressbar_new(); - if (i == 0) - ewl_range_invert_set(EWL_RANGE(progressbar[0]), TRUE); - ewl_range_value_set(EWL_RANGE(progressbar[i]), 0); - ewl_widget_show(progressbar[i]); - - progress_timer[i] = ecore_timer_add(0.1, cb_increment_progress, - (Ewl_Progressbar *) progressbar[i]); - - ewl_container_child_append(EWL_CONTAINER(progressbar_box), - progressbar[i]); - } - - /* - * Third big progressbar - */ - progressbar[2] = ewl_progressbar_new(); - ewl_range_value_set(EWL_RANGE(progressbar[2]), 0); - ewl_widget_show(progressbar[2]); - - progress_timer[2] = ecore_timer_add(0.1, cb_increment_progress, - (Ewl_Progressbar *) progressbar[2]); - - ewl_container_child_append(EWL_CONTAINER(progressbar_vbox), progressbar[2]); - - /* - * A bouncy progressbar - */ - progressbar[3] = ewl_progressbar_new(); - ewl_range_unknown_set(EWL_RANGE(progressbar[3]), TRUE); - ewl_container_child_append(EWL_CONTAINER(progressbar_vbox), progressbar[3]); - ewl_widget_show(progressbar[3]); - - /* - * Add buttons at the bottom - */ - progressbar_box = ewl_hbox_new(); - ewl_container_child_append(EWL_CONTAINER(progressbar_vbox), - progressbar_box); - ewl_box_spacing_set(EWL_BOX(progressbar_box), 0); - ewl_widget_show(progressbar_box); - - button = ewl_button_new(); - ewl_button_label_set(EWL_BUTTON(button), "Rerun"); - ewl_container_child_append(EWL_CONTAINER(progressbar_box), button); - ewl_callback_prepend(button, EWL_CALLBACK_CLICKED, - cb_rerun_progressbars, NULL); - - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); - ewl_widget_show (button); - - button = ewl_button_new(); - ewl_button_label_set(EWL_BUTTON(button), "Set a random range from 0-500"); - ewl_container_child_append(EWL_CONTAINER(progressbar_box), button); - ewl_callback_prepend(button, EWL_CALLBACK_CLICKED, - cb_set_new_range, NULL); - ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); - ewl_widget_show (button); + progressbar_vbox = ewl_vbox_new(); + ewl_container_child_append(EWL_CONTAINER(box), progressbar_vbox); + ewl_box_spacing_set(EWL_BOX(progressbar_vbox), 0); + ewl_callback_prepend(EWL_WIDGET(progressbar_vbox), EWL_CALLBACK_DESTROY, + cb_destroy_progressbar_test, NULL); + ewl_widget_show(progressbar_vbox); + + + progressbar_box = ewl_hbox_new(); + ewl_container_child_append(EWL_CONTAINER(progressbar_vbox), + progressbar_box); + ewl_box_spacing_set(EWL_BOX(progressbar_box), 0); + ewl_widget_show(progressbar_box); + + /* + * First and second progressbar + */ + for (i = 0; i < 2; i++) { + progressbar[i] = ewl_progressbar_new(); + if (i == 0) + ewl_range_invert_set(EWL_RANGE(progressbar[0]), TRUE); + ewl_range_value_set(EWL_RANGE(progressbar[i]), 0); + ewl_widget_show(progressbar[i]); + + progress_timer[i] = ecore_timer_add(0.1, cb_increment_progress, + (Ewl_Progressbar *) progressbar[i]); + + ewl_container_child_append(EWL_CONTAINER(progressbar_box), + progressbar[i]); + } + + /* + * Third big progressbar + */ + progressbar[2] = ewl_progressbar_new(); + ewl_range_value_set(EWL_RANGE(progressbar[2]), 0); + ewl_widget_show(progressbar[2]); + + progress_timer[2] = ecore_timer_add(0.1, cb_increment_progress, + (Ewl_Progressbar *) progressbar[2]); + + ewl_container_child_append(EWL_CONTAINER(progressbar_vbox), progressbar[2]); + + /* + * A bouncy progressbar + */ + progressbar[3] = ewl_progressbar_new(); + ewl_range_unknown_set(EWL_RANGE(progressbar[3]), TRUE); + ewl_container_child_append(EWL_CONTAINER(progressbar_vbox), progressbar[3]); + ewl_widget_show(progressbar[3]); + + /* + * Add buttons at the bottom + */ + progressbar_box = ewl_hbox_new(); + ewl_container_child_append(EWL_CONTAINER(progressbar_vbox), + progressbar_box); + ewl_box_spacing_set(EWL_BOX(progressbar_box), 0); + ewl_widget_show(progressbar_box); + + button = ewl_button_new(); + ewl_button_label_set(EWL_BUTTON(button), "Rerun"); + ewl_container_child_append(EWL_CONTAINER(progressbar_box), button); + ewl_callback_prepend(button, EWL_CALLBACK_CLICKED, + cb_rerun_progressbars, NULL); + + ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); + ewl_widget_show (button); + + button = ewl_button_new(); + ewl_button_label_set(EWL_BUTTON(button), "Set a random range from 0-500"); + ewl_container_child_append(EWL_CONTAINER(progressbar_box), button); + ewl_callback_prepend(button, EWL_CALLBACK_CLICKED, + cb_set_new_range, NULL); + ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_SHRINK); + ewl_widget_show (button); - return 1; + return 1; } static int cb_increment_progress(void *data) { - double val, value, range; - char c[30]; - int i; - Ewl_Range *r; - - r = EWL_RANGE(data); - val = ewl_range_value_get(r); - - if (val >= r->max_val) { - for (i = 0; i < 3; i++) { - if (progress_timer[i]) { - ecore_timer_del(progress_timer[i]); - progress_timer[i] = NULL; - } - } - return 0; - } - - val += 1; - ewl_range_value_set(r, val); - - if (val >= 20 && val < 35 ) { - ewl_progressbar_custom_label_set(EWL_PROGRESSBAR(r), - "%.0lf / %.0lf kbytes"); - } - - if (val >= 35 && val < 60) { - value = ewl_range_value_get(r); - range = ewl_range_maximum_value_get(r); - - snprintf(c, sizeof (c), "%.0lf of %.0lf beers", value, range); - ewl_progressbar_label_set(EWL_PROGRESSBAR(r), c); - } + double val, value, range; + char c[30]; + int i; + Ewl_Range *r; + + r = EWL_RANGE(data); + val = ewl_range_value_get(r); + + if (val >= r->max_val) { + for (i = 0; i < 3; i++) { + if (progress_timer[i]) { + ecore_timer_del(progress_timer[i]); + progress_timer[i] = NULL; + } + } + return 0; + } + + val += 1; + ewl_range_value_set(r, val); + + if (val >= 20 && val < 35 ) { + ewl_progressbar_custom_label_set(EWL_PROGRESSBAR(r), + "%.0lf / %.0lf kbytes"); + } + + if (val >= 35 && val < 60) { + value = ewl_range_value_get(r); + range = ewl_range_maximum_value_get(r); + + snprintf(c, sizeof (c), "%.0lf of %.0lf beers", value, range); + ewl_progressbar_label_set(EWL_PROGRESSBAR(r), c); + } - if (val == 60) - ewl_progressbar_label_hide(EWL_PROGRESSBAR(r)); + if (val == 60) + ewl_progressbar_label_hide(EWL_PROGRESSBAR(r)); - if (val == 70) - ewl_progressbar_label_show(EWL_PROGRESSBAR(r)); + if (val == 70) + ewl_progressbar_label_show(EWL_PROGRESSBAR(r)); - return 1; + return 1; } static void cb_destroy_progressbar_test(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - int i; + int i; - for (i = 0; i < 3; i++) { - if (progress_timer[i]) { - ecore_timer_del(progress_timer[i]); - progress_timer[i] = NULL; - } - } + for (i = 0; i < 3; i++) { + if (progress_timer[i]) { + ecore_timer_del(progress_timer[i]); + progress_timer[i] = NULL; + } + } } static void cb_set_new_range(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - int i, j; + int i, j; - j = rand() % 500; - printf ("New random value: %d\n", j); + j = rand() % 500; + printf ("New random value: %d\n", j); - for (i = 0; i < 3; i++) { - ewl_range_maximum_value_set(EWL_RANGE(progressbar[i]), j); + for (i = 0; i < 3; i++) { + ewl_range_maximum_value_set(EWL_RANGE(progressbar[i]), j); - if (ewl_range_value_get(EWL_RANGE(progressbar[i])) >= j) - cb_rerun_progressbars(EWL_WIDGET (progressbar[i]), - NULL, NULL); - } + if (ewl_range_value_get(EWL_RANGE(progressbar[i])) >= j) + cb_rerun_progressbars(EWL_WIDGET (progressbar[i]), + NULL, NULL); + } } static void cb_rerun_progressbars (Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, - void *data __UNUSED__) + void *data __UNUSED__) { - int i; + int i; - for (i = 0; i < 3; i++) { - /* - * Make sure to autolabel the bar on start again, - * if we stop a place where it labels manually. - * (since the auto label is turned off when you label manually) - */ - ewl_progressbar_label_show (EWL_PROGRESSBAR (progressbar[i])); - ewl_range_value_set(EWL_RANGE(progressbar[i]), 0); - - if (progress_timer[i]) { - ecore_timer_del(progress_timer[i]); - progress_timer[i] = NULL; - } - - progress_timer[i] = ecore_timer_add(0.1, cb_increment_progress, - progressbar[i]); - } + for (i = 0; i < 3; i++) { + /* + * Make sure to autolabel the bar on start again, + * if we stop a place where it labels manually. + * (since the auto label is turned off when you label manually) + */ + ewl_progressbar_label_show (EWL_PROGRESSBAR (progressbar[i])); + ewl_range_value_set(EWL_RANGE(progressbar[i]), 0); + + if (progress_timer[i]) { + ecore_timer_del(progress_timer[i]); + progress_timer[i] = NULL; + } + + progress_timer[i] = ecore_timer_add(0.1, cb_increment_progress, + progressbar[i]); + } } ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs