From: Olaf Wintermann Date: Mon, 5 Sep 2022 12:05:11 +0000 (+0200) Subject: support multiple uris in playlist dnd X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=b911d3cfc927a9cec333d08409bee25721de25ae;p=uwplayer.git support multiple uris in playlist dnd --- diff --git a/application/Sidebar.c b/application/Sidebar.c index 3a2c29b..cf67fa0 100644 --- a/application/Sidebar.c +++ b/application/Sidebar.c @@ -31,6 +31,7 @@ #include "xdnd.h" #include "utils.h" #include "playlist.h" +#include "ucx/string.h" static void sidebar_class_init(void); @@ -261,9 +262,10 @@ static void sidebar_expose(Widget widget, XEvent *event, Region region) { 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); } @@ -322,16 +324,9 @@ static void PopupAP(Widget w, XEvent *event, String *args, Cardinal *nArgs) { } - -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)) { @@ -377,11 +372,30 @@ static void sidebar_xdnd_callback(Widget w, XtPointer udata, XtPointer cdata) { 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 0) { + open_uri(s, uris[i]); + } + } + + SidebarRepaint((Widget)s); +} + /* --------------------------- public --------------------------- */