Author: bklaas
Date: Wed Sep 17 14:59:03 2008
New Revision: 2926

URL: http://svn.slimdevices.com?rev=2926&root=Jive&view=rev
Log:
Bug: 9345
Description: create new HomeMenu methods disableItem() and convenience method 
disableItemById()
disableItem() works differently than removeItem() in that it would prevent GC 
by keeping the menu item in memory.
This is important for applets that need to stay in memory so jnt notifications 
can be received and actions taken accordingly

change removeItem() back to a method that will allow GC

dispense with the 'removed' node. the already existing 'hidden' will work just 
as well for this.

Modified:
    
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/ChooseMusicSource/ChooseMusicSourceMeta.lua
    7.3/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua
    7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua

Modified: 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/ChooseMusicSource/ChooseMusicSourceMeta.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/applets/ChooseMusicSource/ChooseMusicSourceMeta.lua?rev=2926&root=Jive&r1=2925&r2=2926&view=diff
==============================================================================
--- 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/ChooseMusicSource/ChooseMusicSourceMeta.lua
 (original)
+++ 
7.3/trunk/squeezeplay/src/squeezeplay/share/applets/ChooseMusicSource/ChooseMusicSourceMeta.lua
 Wed Sep 17 14:59:03 2008
@@ -49,19 +49,19 @@
        -- set the poll list for discovery of slimservers based on our settings
        if appletManager:hasService("setPollList") then
                appletManager:callService("setPollList", 
meta:getSettings().poll)
-               jiveMain:addItem(
-                       meta:menuItem(
-                               'appletSlimservers', 
-                               'settings', 
-                               "SLIMSERVER_SERVERS", 
-                               function(applet, ...) 
-                                       applet:settingsShow(...) 
-                               end, 
-                               60
-                       )
+       end
+
+       -- add item, then immediately disable it. Music Source should only show 
up when playerCurrent notification comes through
+       jiveMain:addItem(
+               meta:menuItem(
+                       'appletSlimservers', 
+                       'settings', 
+                       "SLIMSERVER_SERVERS", 
+                       nil,
+                       60
                )
-
-       end
+       )
+       jiveMain:disableItemById('appletSlimservers')
 
        jnt:subscribe(meta)
 
@@ -69,7 +69,7 @@
 
 function notify_playerCurrent(meta, player)
        if player == nil then
-               jiveMain:removeItemById('appletSlimservers')
+               jiveMain:disableItemById('appletSlimservers')
        else
                jiveMain:addItem(
                        meta:menuItem(
@@ -88,7 +88,7 @@
 
 function notify_playerDelete(self, player)
        if player == _player then
-               jiveMain:removeItemById('appletSlimservers')
+               jiveMain:disableItemById('appletSlimservers')
        end
 end
 

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua?rev=2926&root=Jive&r1=2925&r2=2926&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua Wed Sep 17 
14:59:03 2008
@@ -225,7 +225,6 @@
        end
 
        jiveMain:addNode( { id = 'hidden', node = 'nowhere' } )
-       jiveMain:addNode( { id = 'removed', node = 'nowhere' } )
        jiveMain:addNode( { id = 'extras', node = 'home', text = 
_globalStrings:str("EXTRAS"), weight = 50  } )
        jiveMain:addNode( { id = 'games', node = 'extras', text = 
_globalStrings:str("GAMES"), weight = 70  } )
        jiveMain:addNode( { id = 'settings', node = 'home', noCustom = 1, text 
= _globalStrings:str("SETTINGS"), weight = 70, titleStyle = 'settings' })

Modified: 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua
URL: 
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua?rev=2926&root=Jive&r1=2925&r2=2926&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/ui/HomeMenu.lua Wed Sep 17 
14:59:03 2008
@@ -364,14 +364,42 @@
 
        self:removeItemFromNode(item)
 
-       -- add this item to 'removed' node
-       -- this will allow an item to be removed without garbage collection 
-       -- killing the ability of some applet's meta files to get notification 
events
-       item.node = 'removed'
-       self:addItem(item)
-
        -- if this item is co-located in home, get rid of it there too
        self:removeItemFromNode(item, 'home')
+
+end
+
+function enableItem(self, item)
+       
+end
+
+--  disableItem differs from removeItem in that it drops the item into a 
removed node rather than eliminating it completely
+--  this is useful for situations where you would not want GC, e.g., a meta 
file that needs to continue to be in memory
+--  to handle jnt notification events
+
+function disableItem(self, item)
+       assert(item)
+       assert(item.node)
+
+       if self.menuTable[item.id] then
+               self.menuTable[item.id] = nil
+       end
+
+       self:removeItemFromNode(item)
+
+       item.node = 'hidden'
+       self:addItem(item)
+
+       -- if this item is co-located in home, get rid of it there too
+       self:removeItemFromNode(item, 'home')
+
+end
+
+function disableItemById(self, id)
+       if self.menuTable[id] then
+               local item = self.menuTable[id]
+               self:disableItem(item)
+       end
 
 end
 

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to