diff src/audacious/widgets/playlist_list.c @ 2356:4b2c7d9523e7 trunk

[svn] right-clicking on playlist entry automatically selects the entry if it was unselected before, closes #728
author mf0102
date Wed, 17 Jan 2007 12:11:16 -0800
parents 3149d4b1a9a9
children f24ae4f40e29
line wrap: on
line diff
--- a/src/audacious/widgets/playlist_list.c	Wed Jan 17 08:13:07 2007 -0800
+++ b/src/audacious/widgets/playlist_list.c	Wed Jan 17 12:11:16 2007 -0800
@@ -316,18 +316,24 @@
                               GdkEventButton * event,
                               PlayList_List * pl)
 {
-    gint nr, y;
+    gint nr;
     Playlist *playlist = playlist_get_active();
 
-    if (event->button == 1 && pl->pl_fheight &&
-        widget_contains(&pl->pl_widget, event->x, event->y)) {
+	nr = playlist_list_get_playlist_position(pl, event->x, event->y);
+	if (nr == -1)
+		return;
 
-        y = event->y - pl->pl_widget.y;
-        nr = (y / pl->pl_fheight) + pl->pl_first;
-
-        if (nr >= playlist_get_length(playlist))
-            nr = playlist_get_length(playlist) - 1;
-
+	if (event->button == 3)
+	{
+		GList* selection = playlist_get_selected(playlist);
+		if (g_list_find(selection, GINT_TO_POINTER(nr)) == NULL)
+		{
+			playlist_select_all(playlist, FALSE);
+			playlist_select_range(playlist, nr, nr, TRUE);
+		}
+	}
+	else if (event->button == 1)
+	{
         if (!(event->state & GDK_CONTROL_MASK))
             playlist_select_all(playlist, FALSE);
 
@@ -369,8 +375,9 @@
         }
 
         pl->pl_dragging = TRUE;
-        playlistwin_update_list(playlist);
     }
+
+	playlistwin_update_list(playlist);
 }
 
 gint
@@ -391,7 +398,7 @@
 
     ret = (iy / pl->pl_fheight) + pl->pl_first;
 
-    if(ret > length-1)
+    if (ret > length - 1)
 	    ret = -1;
 
     return ret;