Hi fellow monks.
I am writing a Gtk2-perl based mp3 player which utilizes a Gtk2::SimpleList for its playlist. The Gtk2::SimpleList (for those who don't know) is a module that simplify the use of TreeView's in Gtk2. It work by giving you a tied array as your only interface the data (in the TreeView).
I also use the "drag and drop reorder" feature of the Gtk2 TreeView which enables the user to just drag and drop the items in the list to reorder / sort there playlist. This is all nice and all but it give me a problem, The program have way of knowing when the playlist is being reordered (To my knowledge there is no Gtk2 signal for this). So when the player wants the next song in the playlist is does not know that the current song have changed place. (Hope you understand, I am having a hard time explaining this)
example:
Playlist looks like this:
0: song 1
1: song 2
3: song 4
4: song 5
a. the player plays "song 4" (currentitem = 3)
b. the user reorder the list so that "song 4" is the first entry.
c. when the player wants the next song it does (currentitem +1) = (3 +1)
but this is wrong since the currently playing song is now in the top of the list.
I can only figure out two ways of solving this, and none of them seems very good:
1. the currentitem points to the item it self and not the position in the list. Then when the next song is requested it searches through the playlist finding the item and then get the next in the list.
2. Use some tie / perl magic to notify the program when the list is reordered ( don't know is this would work, just an idea)
Martin A -- Just Another Perl Hooker
"We did not inherit the earth from our parents. We are borrowing it from our children." -- Unknown.