#include "xdnd.h"
#include "utils.h"
#include "playlist.h"
+#include "ucx/string.h"
static void sidebar_class_init(void);
int fontheight = xftFont->ascent;
int height = s->sidebar.elmHeight;
+
int list_height = numTracks * height;
if((list_height > s->core.height) || (w < parent->core.width)) {
- XtMakeResizeRequest(widget, parent->core.width, list_height, &w, &h);
+ XtMakeResizeRequest(widget, parent->core.width, list_height + 5, &w, &h);
}
}
-
-static void sidebar_xdnd_callback(Widget w, XtPointer udata, XtPointer cdata) {
- printf("xdnd\n");
- fflush(stdout);
-
- Sidebar s = (Sidebar)cdata;
-
- char *urilist = udata;
-
- size_t len = strlen(urilist);
+static void open_uri(Sidebar s, sstr_t uri) {
+ char *urilist = uri.ptr;
+ size_t len = uri.length;
size_t start = 0;
if(len > 7 && !memcmp(urilist, "file://", 7)) {
path[k] = '\0';
PlayListAddFile(s->sidebar.window, path);
- SidebarRepaint((Widget)s);
free(path);
}
+static void sidebar_xdnd_callback(Widget w, XtPointer udata, XtPointer cdata) {
+ printf("xdnd\n");
+ fflush(stdout);
+
+ Sidebar s = (Sidebar)cdata;
+
+ scstr_t urlist = scstr(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]);
+ }
+ }
+
+ SidebarRepaint((Widget)s);
+}
+
/* --------------------------- public --------------------------- */