Hello,

I have added an example for the unit format function to the progress bar example. Please see the attached patch.

Regards,
Daniel Willmann
>From 976579166f3328aa7398916d31d700bba6cbab2a Mon Sep 17 00:00:00 2001
From: Daniel Willmann <d.willm...@samsung.com>
Date: Thu, 14 Jun 2012 10:15:49 +0100
Subject: [PATCH] elm_progressbar: Demo the format function in the example


Signed-off-by: Daniel Willmann <d.willm...@samsung.com>
---
 .../elementary/src/examples/progressbar_example.c  |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/trunk/elementary/src/examples/progressbar_example.c b/trunk/elementary/src/examples/progressbar_example.c
index f7341a2..9c166b9 100644
--- a/trunk/elementary/src/examples/progressbar_example.c
+++ b/trunk/elementary/src/examples/progressbar_example.c
@@ -82,6 +82,16 @@ _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 buf;
+   return NULL;
+}
+
 static void
 _on_done(void        *data,
          Evas_Object *obj,
@@ -136,12 +146,12 @@ 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, NULL);
    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);
-- 
1.7.9.5

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to