diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/progressbar.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util/progressbar.c b/src/util/progressbar.c index ed0a28f..3623016 100644 --- a/src/util/progressbar.c +++ b/src/util/progressbar.c @@ -26,6 +26,8 @@ #define SLIDER_STEP 0.03 #define PROGRESSBAR_INTERVAL 0.1 +#define COMPLETE_INTERVAL 1.0 +#define COMPLETE_BUFFER 500 struct progressbar { Evas_Object *base; @@ -41,6 +43,7 @@ struct progressbar { char *str_separator; enum progressbar_time_format fmt; + int duration; }; static void _update_progress_info(struct progressbar *m, int position) @@ -64,6 +67,21 @@ static void _update_time_info(struct progressbar *m, int position, int duration) _update_progress_info(m, position); } +static Eina_Bool _complete_cb(void *data) +{ + struct progressbar *m; + + if (!data) + return ECORE_CALLBACK_CANCEL; + + m = data; + + if (m->ops->complete_cb) + m->ops->complete_cb(m->ops_data); + + return ECORE_CALLBACK_CANCEL; +} + static Eina_Bool _timer_cb(void *data) { struct progressbar *m; @@ -79,6 +97,13 @@ static Eina_Bool _timer_cb(void *data) elm_slider_value_set(m->slider, position); _update_progress_info(m, position); + if (position + COMPLETE_BUFFER > m->duration) { + ecore_timer_add(COMPLETE_INTERVAL, _complete_cb, m); + m->timer = NULL; + + return ECORE_CALLBACK_CANCEL; + } + return ECORE_CALLBACK_RENEW; } @@ -167,6 +192,8 @@ void progressbar_reset(struct progressbar *m, int position, int duration) return; } + m->duration = duration; + elm_slider_min_max_set(m->slider, 0, duration); elm_slider_step_set(m->slider, SLIDER_STEP); elm_slider_value_set(m->slider, position); |