ucx update
[uwplayer.git] / application / Sidebar.c
index cf67fa0..0b96328 100644 (file)
@@ -31,7 +31,7 @@
 #include "xdnd.h"
 #include "utils.h"
 #include "playlist.h"
-#include "ucx/string.h"
+#include <cx/string.h>
 
 
 static void sidebar_class_init(void);
@@ -240,8 +240,7 @@ static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttribut
     XtVaSetValues(parent, XmNbackground, WhitePixelOfScreen(XtScreen(parent)), NULL);
     
     XtMakeResizeRequest(widget, 200, 100, &w, &h);
-    
-    
+     
 }
 
 static void sidebar_expose(Widget widget, XEvent *event, Region        region) {
@@ -256,8 +255,8 @@ static void sidebar_expose(Widget widget, XEvent *event, Region     region) {
     
     Sidebar s = (Sidebar)widget;
     XftFont *xftFont = s->sidebar.font->fonts->font;
-    UcxList *tracks = s->sidebar.window->playlist.tracks;
-    size_t numTracks = ucx_list_size(tracks);
+    CxList *tracks = s->sidebar.window->playlist.tracks;
+    size_t numTracks = tracks->size;
     
     int fontheight = xftFont->ascent;
     int height = s->sidebar.elmHeight;
@@ -274,18 +273,16 @@ static void sidebar_expose(Widget widget, XEvent *event, Region   region) {
     
     //printf("current track: %d\n", s->sidebar.window->playlist.current_track);
     
-    int i = 0;
-    UCX_FOREACH(elm, s->sidebar.window->playlist.tracks) {
-        char *name = util_resource_name(elm->data);
+    CxIterator i = cxListIterator(s->sidebar.window->playlist.tracks);
+    cx_foreach(const char *, elm, i) {
+        const char *name = util_resource_name(elm);
         XftColor *cg = &s->sidebar.fg;
-        if(i == s->sidebar.window->playlist.current_track) {
-            XftDrawRect(s->sidebar.d, &s->sidebar.fg, 0, i*height, s->core.width, height);
+        if(i.index == s->sidebar.window->playlist.current_track) {
+            XftDrawRect(s->sidebar.d, &s->sidebar.fg, 0, i.index*height, s->core.width, height);
             cg = &s->sidebar.bg;
         }
         
-        XftDrawString8(s->sidebar.d, cg, s->sidebar.font->fonts->font, 10, i*height + xftFont->ascent, (const FcChar8*)name, strlen(name));
-        
-        i++;
+        XftDrawString8(s->sidebar.d, cg, s->sidebar.font->fonts->font, 10, i.index*height + xftFont->ascent, (const FcChar8*)name, strlen(name));
     }
 }
 
@@ -324,8 +321,8 @@ static void PopupAP(Widget w, XEvent *event, String *args, Cardinal *nArgs) {
 }
 
 
-static void open_uri(Sidebar s, sstr_t uri) {
-    char *urilist = uri.ptr;
+static void open_uri(Sidebar s, cxstring uri) {
+    const char *urilist = uri.ptr;
     size_t len = uri.length;
     
     size_t start = 0;
@@ -382,15 +379,12 @@ static void sidebar_xdnd_callback(Widget w, XtPointer udata, XtPointer cdata) {
     
     Sidebar s = (Sidebar)cdata;
     
-    scstr_t urlist = scstr(udata);
+    cxstring urllist = cx_str(udata);
     
-    ssize_t nuris;
-    sstr_t *uris = scstrsplit(urlist, scstr("\r\n"), &nuris);
-    
-    for(int i=0;i<nuris;i++) {
-        if(uris[i].length > 0) {
-            open_uri(s, uris[i]);
-        }
+    CxStrtokCtx tk = cx_strtok(urllist, cx_str("\r\n"), INT_MAX);
+    cxstring uri;
+    while(cx_strtok_next(&tk, &uri)) {
+        open_uri(s, uri);
     }
     
     SidebarRepaint((Widget)s);