]> uap-core.de Git - uwplayer.git/commitdiff
implement playlist remove
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 7 Apr 2023 13:37:20 +0000 (15:37 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 7 Apr 2023 13:37:20 +0000 (15:37 +0200)
application/Sidebar.c

index 733e21a5a9ffbaf2f24c4ef38de7b1996d2bfb3d..145bea674eed1bfefb0036b04ab282b34aea678a 100644 (file)
@@ -217,8 +217,17 @@ static void sidebar_resize(Widget widget) {
 
 
 static void remove_cb(Widget item, XtPointer index, XtPointer cd) {
-    printf("test_cb\n");
-    fflush(stdout);
+    Widget parent = XtParent(item);
+    Sidebar sb = NULL;
+    XtVaGetValues(parent, XmNuserData, &sb, NULL);
+    
+    int currentTrack = sb->sidebar.window->playlist.current_track;
+    cxListRemove(sb->sidebar.window->playlist.tracks, sb->sidebar.select2);
+    if(sb->sidebar.select2 == currentTrack) {
+        PlayListPlayNext(sb->sidebar.window, true);
+    }
+    sb->sidebar.select2 = -1;
+    SidebarRepaint((Widget)sb);
 }
 
 
@@ -260,9 +269,9 @@ static void sidebar_realize(Widget widget, XtValueMask *mask, XSetWindowAttribut
     XmString s1 = XmStringCreateSimple("Remove");
     sb->sidebar.popupMenu = XmVaCreateSimplePopupMenu(
             widget, "popup", remove_cb,
-            //XmNuserData, widget,
             XmVaPUSHBUTTON, s1, 'R', NULL, NULL,
             NULL);
+    XtVaSetValues(sb->sidebar.popupMenu, XmNuserData, sb, NULL);
     XmStringFree(s1);
 }