X-Git-Url: https://develop.uap-core.de/gitweb/uwplayer.git/blobdiff_plain/1878419ab30f960612d503f1ed0a29c0047e6fdf..335105ec8330774af60183180c47b14e5aa4e6c1:/application/Sidebar.c diff --git a/application/Sidebar.c b/application/Sidebar.c index 0b96328..733e21a 100644 --- a/application/Sidebar.c +++ b/application/Sidebar.c @@ -161,7 +161,7 @@ static void sidebar_init(Widget request, Widget neww, ArgList args, Cardinal *nu // initialize everything except XftDraw or other stuff that needs a Window - XftColor fg, bg; + XftColor fg, bg, sel2; fg.color.red = 0; fg.color.green = 0; fg.color.blue = 0; @@ -172,8 +172,16 @@ static void sidebar_init(Widget request, Widget neww, ArgList args, Cardinal *nu bg.color.blue = 0xFFFF; bg.color.alpha = 0xFFFF; + sel2.color.red = 0xFFFF; + sel2.color.green = 0xFFFF; + sel2.color.blue = 0; + sel2.color.alpha = 0xFFFF; + sb->sidebar.fg = fg; sb->sidebar.bg = bg; + sb->sidebar.select2_bg = sel2; + + sb->sidebar.select2 = -1; sb->sidebar.font = FontFromName(XtDisplay(neww), "Sans:size=11"); if(!sb->sidebar.font) { @@ -207,6 +215,13 @@ static void sidebar_resize(Widget widget) { printf("resize\n"); } + +static void remove_cb(Widget item, XtPointer index, XtPointer cd) { + printf("test_cb\n"); + fflush(stdout); +} + + static int xdnd_initialized = 0; static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttributes *attributes) { @@ -240,7 +255,15 @@ static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttribut XtVaSetValues(parent, XmNbackground, WhitePixelOfScreen(XtScreen(parent)), NULL); XtMakeResizeRequest(widget, 200, 100, &w, &h); - + + + XmString s1 = XmStringCreateSimple("Remove"); + sb->sidebar.popupMenu = XmVaCreateSimplePopupMenu( + widget, "popup", remove_cb, + //XmNuserData, widget, + XmVaPUSHBUTTON, s1, 'R', NULL, NULL, + NULL); + XmStringFree(s1); } static void sidebar_expose(Widget widget, XEvent *event, Region region) { @@ -280,6 +303,8 @@ static void sidebar_expose(Widget widget, XEvent *event, Region region) { 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; + } else if(i.index == s->sidebar.select2) { + XftDrawRect(s->sidebar.d, &s->sidebar.select2_bg, 0, i.index*height, s->core.width, height); } XftDrawString8(s->sidebar.d, cg, s->sidebar.font->fonts->font, 10, i.index*height + xftFont->ascent, (const FcChar8*)name, strlen(name)); @@ -312,16 +337,32 @@ static void SelectElmAP(Widget w, XEvent *event, String *args, Cardinal *nArgs) int selected = e->y / s->sidebar.elmHeight; PlayListPlayTrack(s->sidebar.window, selected); + s->sidebar.select2 = -1; SidebarRepaint(w); } static void PopupAP(Widget w, XEvent *event, String *args, Cardinal *nArgs) { + XButtonEvent *e = &event->xbutton; + Sidebar s = (Sidebar)w; + + int selected = e->y / s->sidebar.elmHeight; + s->sidebar.select2 = selected; + SidebarRepaint(w); + //printf("btn3\n"); + //fflush(stdout); + + XmMenuPosition(s->sidebar.popupMenu, &event->xbutton); + XtManageChild(s->sidebar.popupMenu); } static void open_uri(Sidebar s, cxstring uri) { + if(uri.length == 0) { + return; + } + const char *urilist = uri.ptr; size_t len = uri.length;