forked from enlightenment/efl
elementary: add a test and an example for the unit format function in progressbar
SVN revision: 72293
This commit is contained in:
parent
17e30e1dea
commit
a44d411430
|
@ -68,6 +68,18 @@ my_progressbar_destroy(void *data __UNUSED__, Evas_Object *obj, void *event_info
|
|||
evas_object_del(obj);
|
||||
}
|
||||
|
||||
static char *
|
||||
my_progressbar_format_cb(double val)
|
||||
{
|
||||
char buf[1024];
|
||||
int files;
|
||||
|
||||
files = (1-val)*14000;
|
||||
if(snprintf(buf, 30, "%i files left", files) > 0)
|
||||
return strdup(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
test_progressbar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
|
@ -89,7 +101,8 @@ test_progressbar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event
|
|||
elm_box_pack_end(bx, pb);
|
||||
// elm_progressbar_horizontal_set(pb, EINA_TRUE);
|
||||
// elm_object_text_set(pb, "Progression %");
|
||||
// elm_progressbar_unit_format_set(pb, NULL);
|
||||
elm_progressbar_unit_format_function_set(pb, my_progressbar_format_cb,
|
||||
(void (*)(char *)) free);
|
||||
evas_object_show(pb);
|
||||
_test_progressbar.pb1 = pb;
|
||||
|
||||
|
|
|
@ -82,6 +82,22 @@ _progressbar_example_stop(void *data,
|
|||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
_progress_format_cb(double val)
|
||||
{
|
||||
static char buf[30];
|
||||
int files = (1-val)*14000;
|
||||
if (snprintf(buf, 30, "%i files left", files) > 0)
|
||||
return strdup(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_progress_format_free(char *str)
|
||||
{
|
||||
free(fstr);
|
||||
}
|
||||
|
||||
static void
|
||||
_on_done(void *data,
|
||||
Evas_Object *obj,
|
||||
|
@ -136,12 +152,13 @@ elm_main(int argc,
|
|||
elm_icon_file_set(ic1, buf, NULL);
|
||||
evas_object_size_hint_aspect_set(ic1, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
|
||||
/* pb with label, icon, custom unit label and span size set */
|
||||
/* pb with label, icon, custom unit label function and span size set */
|
||||
pb = elm_progressbar_add(win);
|
||||
elm_object_text_set(pb, "Label");
|
||||
elm_object_part_content_set(pb, "icon", ic1);
|
||||
elm_progressbar_inverted_set(pb, EINA_TRUE);
|
||||
elm_progressbar_unit_format_set(pb, "%1.1f units");
|
||||
elm_progressbar_unit_format_function_set(pb, _progress_format_cb,
|
||||
_progress_format_free);
|
||||
elm_progressbar_span_size_set(pb, 200);
|
||||
evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5);
|
||||
evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
|
Loading…
Reference in New Issue