Index: src/squeezeplay/share/jive/slim/Player.lua =================================================================== --- src/squeezeplay/share/jive/slim/Player.lua (revision 7816) +++ src/squeezeplay/share/jive/slim/Player.lua Thu Oct 01 09:47:01 CDT 2009 @@ -188,6 +188,19 @@ return nil end + +function setLastBrowseIndex(self, key, index) + local lastBrowse = self:getLastBrowse(key) + lastBrowse.index = index +end + + +function getLastBrowseIndex(self, key) + local lastBrowse = self:getLastBrowse(key) + return lastBrowse and lastBrowse.index +end + + function getLastBrowse(self, key) if self.browseHistory[key] then return self.browseHistory[key] @@ -1098,7 +1111,9 @@ iconbar:setRepeat(nil) iconbar:setShuffle(nil) iconbar:setPlaylistMode(nil) - + + self.browseHistory = {} + -- unsubscribe from playerstatus and displaystatus events self.slimServer.comet:startBatch() self.slimServer.comet:unsubscribe('/slim/playerstatus/' .. self.id) Index: src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua =================================================================== --- src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua (revision 7808) +++ src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua Thu Oct 01 10:09:57 CDT 2009 @@ -216,32 +216,27 @@ local commandString = _stringifyJsonRequest(jsonAction) local lastBrowse = _player:getLastBrowse(commandString) + step.commandString = commandString - if not lastBrowse or isContextMenu then - _player.menuAnchor = nil - end - local from = 0 log:debug('Saving this json command to browse history table:') log:debug(commandString) if lastBrowse and not isContextMenu then - from = _getNewStartValue(lastBrowse.index) - _player.menuAnchor = lastBrowse.index + from = _getNewStartValue(_player:getLastBrowseIndex(commandString)) else lastBrowse = { index = 1 } _player:setLastBrowse(commandString, lastBrowse) end log:debug('We\'ve been here before, lastBrowse index was: ', lastBrowse.index) - _player.lastKeyTable = lastBrowse - _player.menuAnchorSet = false + step.lastBrowseIndexUsed = false - --don't use anchor if position is first element, breaks windows that have zero sized menu (textarea, for example), and - -- by default the first item is selected without the need of menuAnchor - if _player.menuAnchor and _player.menuAnchor == 1 then - _player.menuAnchor = nil + --don't use lastBrowse index if position is first element, breaks windows that have zero sized menu (textarea, for example), and + -- by default the first item is selected without the need of lastBrowse + if _player:getLastBrowseIndex(commandString) == 1 then + _player:setLastBrowseIndex(commandString, nil) end return from, qty @@ -1170,20 +1165,23 @@ end elseif step.menu then _stepSetMenuItems(step, data) - if _player and _player.menuAnchor and not _player.menuAnchorSet then - log:debug("Selecting menuAnchor: ", _player.menuAnchor) step.menu:setSelectedIndex(_player.menuAnchor) - step.menu:setSelectedIndex(_player.menuAnchor) - _player.menuAnchorSet = true + if _player then + local lastBrowseIndex = _player:getLastBrowseIndex(step.commandString) + if lastBrowseIndex and not step.lastBrowseIndexUsed then + log:debug("Selecting lastBrowseIndex: ", lastBrowseIndex) + step.menu:setSelectedIndex(lastBrowseIndex) + step.lastBrowseIndexUsed = true - if _player.loadedCallback then - local loadedCallback = _player.loadedCallback - _player.loadedCallback = nil + if _player.loadedCallback then + local loadedCallback = _player.loadedCallback + _player.loadedCallback = nil - loadedCallback(step) - _pushStep(step) - step.window:show() + loadedCallback(step) + _pushStep(step) + step.window:show() - end - end + end + end + end -- update the window properties --step.menu:setStyle(step.db:menuStyle()) @@ -1323,8 +1321,9 @@ end -- what's missing? - local from, qty = step.db:missing(_player and _player.menuAnchor) + local lastBrowseIndex = _player and _player:getLastBrowseIndex(step.commandString) + local from, qty = step.db:missing(lastBrowseIndex) - + if from then _performJSONAction(step.data, from, qty, step, step.sink) end @@ -1965,12 +1964,13 @@ -- figure out the item action... local evtType = event:getType() - local currentlySelectedIndex = _getCurrentStep().menu:getSelectedIndex() - if _player and _player.lastKeyTable and evtType == EVENT_FOCUS_GAINED then + local currentlySelectedIndex =step.menu:getSelectedIndex() + if _player and _player:getLastBrowse(step.commandString) and evtType == EVENT_FOCUS_GAINED then if currentlySelectedIndex then - _player.lastKeyTable.index = currentlySelectedIndex + log:debug("step.commandString: ", step.commandString, " menu: ", step.menu, " currentlySelectedIndex: ", currentlySelectedIndex) + _player:setLastBrowseIndex(step.commandString, currentlySelectedIndex) else - _player.lastKeyTable.index = 1 + _player:setLastBrowseIndex(step.commandString, nil) end end @@ -2702,8 +2702,9 @@ from, qty = _decideFirstChunk(step, jsonAction) step.loaded = function() - --if _player.menuAnchor then defer callback until menuAnchor chunk received. - if not _player.menuAnchor and loadedCallback then + --if lastBrowseIndex then defer callback until lastBrowseIndex chunk received. + local lastBrowseIndex = _player:getLastBrowseIndex(step.commandString) + if not lastBrowseIndex and loadedCallback then loadedCallback(step) _pushStep(step) step.window:show()