Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/test


Modified Files:
        ewl_media_test.c 


Log Message:
- add a time display to the media test. the formatting and figuring out of
  the values for the time are taken from benr's envision

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/test/ewl_media_test.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_media_test.c    16 Jul 2004 23:48:48 -0000      1.5
+++ ewl_media_test.c    17 Jul 2004 04:08:35 -0000      1.6
@@ -68,8 +68,20 @@
 }
 
 void video_change_cb(Ewl_Widget *w, void *event, void *data) {
-    double val = ewl_media_position_get(EWL_MEDIA(video));
-    ewl_seeker_set_value(EWL_SEEKER(seeker), val);
+    char buf[512];
+    int h, m;
+    double s;
+    Ewl_Text *t = (Ewl_Text *)data;
+    double pos = ewl_media_position_get(EWL_MEDIA(video));
+
+    ewl_seeker_set_value(EWL_SEEKER(seeker), pos);
+
+    /* stolen from envision by benr */
+    h = (int)pos / (60 * 60);
+    m = ((int)pos / 60) - (h * 60);
+    s = pos - (h * 60 * 60) - (m * 60);
+    snprintf(buf, sizeof(buf), "%02i:%02i:%02.0f", h, m, s);
+    ewl_text_text_set(t, buf);
 
     return;
     w = NULL;
@@ -152,7 +164,7 @@
 
 int main(int argc, char ** argv) {
     Ewl_Widget *win = NULL, *o = NULL, *b = NULL;
-    Ewl_Widget *controls = NULL;
+    Ewl_Widget *controls = NULL, *time = NULL;
     char * file = NULL;
 
     if (!ewl_init(&argc, argv)) {
@@ -179,12 +191,15 @@
     ewl_object_set_fill_policy(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("00:00:00");
+
     /* the video */
     video = ewl_media_new(file);
     ewl_container_append_child(EWL_CONTAINER(b), video);
     ewl_object_set_fill_policy(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, NULL);
+    ewl_callback_append(video, EWL_CALLBACK_VALUE_CHANGED, video_change_cb, time);
     ewl_widget_show(video);
 
     /* box to contain contols and scrollers */
@@ -223,6 +238,7 @@
     ewl_container_append_child(EWL_CONTAINER(controls), b);
     ewl_widget_show(b);
 
+    /* the video seeker */
     seeker = ewl_seeker_new(EWL_ORIENTATION_HORIZONTAL);
     ewl_container_append_child(EWL_CONTAINER(b), seeker);
     ewl_object_set_fill_policy(EWL_OBJECT(seeker), 
@@ -233,6 +249,12 @@
     ewl_callback_append(seeker, EWL_CALLBACK_VALUE_CHANGED, seeker_move_cb, NULL);
     ewl_widget_show(seeker);
 
+    /* the time text spot */
+    ewl_container_append_child(EWL_CONTAINER(b), time);
+    ewl_object_set_insets(EWL_OBJECT(time), 0, 3, 0, 0);
+    ewl_object_set_fill_policy(EWL_OBJECT(time), EWL_FLAG_FILL_SHRINK);
+    ewl_widget_show(time);
+
     ewl_main();
     return 0;
 }




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to