upwawet / vision
NB: the active repository for Vision is now http://bitbucket.org/upwawet/vision-cur. Vision (for the Voice) is an X-platform Music Multiplexing System 2 (http://xmms2.xmms.se) client aiming to eventually fit its author's views on listening to music, managing a music library etc. Only the time can tell what will come of that :]
| commit 700: | 46499568aa31 |
| parent 699: | 2ee8c9bf2fb9 |
| branch: | no-info-in-playlist-store |
playlist: request mediainfo for visible tracks only
Changed (Δ385 bytes):
raw changeset »
src/Playlist/Model.hs (13 lines added, 3 lines removed)
src/Playlist/View.hs (7 lines added, 4 lines removed)
Up to file-list src/Playlist/Model.hs:
| … | … | @@ -47,6 +47,7 @@ module Playlist.Model |
47 |
47 |
, getCurrentName |
48 |
48 |
, setCurrentName |
49 |
49 |
, getTrackInfo |
50 |
, getTrackInfo2 |
|
50 |
51 |
) where |
51 |
52 |
|
52 |
53 |
import Control.Applicative |
| … | … | @@ -107,16 +108,25 @@ modifyIndex_ = modifyMVar_ (mIndex ?p |
107 |
108 |
tryModifyIndex_ = tryModifyMVar_ (mIndex ?playlistModel) |
108 |
109 |
clearIndex = swapMVar (mIndex ?playlistModel) emptyIndex |
109 |
110 |
|
111 |
||
112 |
getTrackInfo2 _ ([], []) = return Nothing |
|
113 |
getTrackInfo2 iter ([f], [t]) = do |
|
114 |
[n] <- treeModelGetPath playlistStore iter |
|
115 |
getTrackInfo' n (n >= f && t >= n) |
|
116 |
||
110 |
117 |
getTrackInfo iter = do |
111 |
[n] <- treeModelGetPath playlistStore iter |
|
112 |
id <- playlistStoreGet n |
|
118 |
[n] <- treeModelGetPath playlistStore iter |
|
119 |
getTrackInfo' n True |
|
120 |
||
121 |
getTrackInfo' n force = do |
|
122 |
id <- playlistStoreGet n |
|
113 |
123 |
modifyIndex $ \index -> |
114 |
124 |
case IntMap.lookup (fromIntegral id) index of |
115 |
125 |
Just (IEReady _ ti, _) -> |
116 |
126 |
return (index, Just ti) |
117 |
127 |
Just (IERetrieving, _) -> |
118 |
128 |
return (index, Nothing) |
119 |
Just (IENone, list) |
|
129 |
Just (IENone, list) | force -> do |
|
120 |
130 |
info <- getOrRequestInfo id |
121 |
131 |
case info of |
122 |
132 |
Just (mi, stamp) -> do |
Up to file-list src/Playlist/View.hs:
| … | … | @@ -23,6 +23,7 @@ module Playlist.View |
23 |
23 |
) where |
24 |
24 |
|
25 |
25 |
import Control.Monad |
26 |
import Data.Maybe |
|
26 |
27 |
|
27 |
28 |
import Graphics.UI.Gtk |
28 |
29 |
|
| … | … | @@ -96,13 +97,15 @@ initView = do |
96 |
97 |
cell <- cellRendererTextNew |
97 |
98 |
treeViewColumnPackStart column cell True |
98 |
99 |
cellLayoutSetAttributeFunc column cell playlistStore $ \iter -> do |
99 |
info <- getTrackInfo iter |
|
100 |
cell `set` trackInfoAttrs info |
|
100 |
vr <- treeViewGetVisibleRange playlistView |
|
101 |
info <- getTrackInfo2 iter vr |
|
102 |
when (isJust info) $ cell `set` trackInfoAttrs info |
|
101 |
103 |
|
102 |
104 |
cell <- cellRendererTextNew |
103 |
105 |
treeViewColumnPackStart column cell False |
104 |
106 |
cellLayoutSetAttributeFunc column cell playlistStore $ \iter -> do |
105 |
info <- getTrackInfo iter |
|
106 |
cell `set` [ cellText := trackInfoDuration info ] |
|
107 |
vr <- treeViewGetVisibleRange playlistView |
|
108 |
info <- getTrackInfo2 iter vr |
|
109 |
when (isJust info) $ cell `set` [ cellText := trackInfoDuration info ] |
|
107 |
110 |
|
108 |
111 |
return ?playlistView |
