Author: tom
Date: Mon Jan 19 12:42:28 2009
New Revision: 3879

URL: http://svn.slimdevices.com?rev=3879&root=Jive&view=rev
Log:
Bug: N/A
Description:
Action framework:
- whitespace only changes, fixing my space->tab issues for the action code

Modified:
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua?rev=3879&root=Jive&r1=3878&r2=3879&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua Mon Jan 19 
12:42:28 2009
@@ -130,20 +130,20 @@
 
 local charActionMappings = {}
 charActionMappings.press = {
-    ["/"] = "go_search"
+       ["/"] = "go_search"
 }
 
 
 local keyActionMappings = {}
 keyActionMappings.press = {
-    [KEY_HOME] = "go_home"
+       [KEY_HOME] = "go_home"
 }
 
 
 keyActionMappings.hold = {
-    [KEY_BACK] = "disconnect_player",
-    [KEY_LEFT] = "go_home",
-    [KEY_REW | KEY_PAUSE] = "take_screenshot"  -- a stab at how to handle 
multi-press
+       [KEY_BACK] = "disconnect_player",
+       [KEY_LEFT] = "go_home",
+       [KEY_REW | KEY_PAUSE] = "take_screenshot"  -- a stab at how to handle 
multi-press
 }
 
 local _defaultSkin
@@ -162,8 +162,8 @@
 end
 
 local function _disconnectPlayer(self, event) --self, event not used in our 
case, could be left out
-    appletManager:callService("setCurrentPlayer", nil)
-    _goHome()
+       appletManager:callService("setCurrentPlayer", nil)
+       _goHome()
 end
 
 -- bring us to the home menu
@@ -186,11 +186,11 @@
 
        elseif ( type == EVENT_KEY_PRESS and event:getKeycode() == KEY_HOME) 
then
 
-        _goHome()
-        
+               _goHome()
+               
                return EVENT_CONSUME
-      end
-      return EVENT_UNUSED
+         end
+         return EVENT_UNUSED
 end
 
 local function _addUserPathToLuaPath()
@@ -201,33 +201,33 @@
 
 -- transform user input events (key, etc) to a matching action name
 local function getAction(event)
-    --naive implementation for demonstration - will be more involved later
-
-    local eventType = event:getType()
-    local action = nil
-    
-    if eventType == EVENT_KEY_PRESS then
-        action = keyActionMappings.press[event:getKeycode()]
-    elseif eventType == EVENT_KEY_HOLD then
-        action = keyActionMappings.hold[event:getKeycode()]
-    elseif eventType == EVENT_CHAR_PRESS then
-        action = charActionMappings.press[string.char(event:getUnicode())]
-    end
-    
-    return action
-    
+       --naive implementation for demonstration - will be more involved later
+
+       local eventType = event:getType()
+       local action = nil
+       
+       if eventType == EVENT_KEY_PRESS then
+               action = keyActionMappings.press[event:getKeycode()]
+       elseif eventType == EVENT_KEY_HOLD then
+               action = keyActionMappings.hold[event:getKeycode()]
+       elseif eventType == EVENT_CHAR_PRESS then
+               action = 
charActionMappings.press[string.char(event:getUnicode())]
+       end
+       
+       return action
+       
 end
 
 function registerDefaultActions()
-    for key, action in pairs(keyActionMappings.press) do 
-        Framework:registerAction(action)
-    end
-    for key, action in pairs(keyActionMappings.hold) do 
-        Framework:registerAction(action)
-    end
-    for key, action in pairs(charActionMappings.press) do 
-        Framework:registerAction(action)
-    end
+       for key, action in pairs(keyActionMappings.press) do 
+               Framework:registerAction(action)
+       end
+       for key, action in pairs(keyActionMappings.hold) do 
+               Framework:registerAction(action)
+       end
+       for key, action in pairs(charActionMappings.press) do 
+               Framework:registerAction(action)
+       end
 
 end
 

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua?rev=3879&root=Jive&r1=3878&r2=3879&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua Mon Jan 
19 12:42:28 2009
@@ -544,28 +544,28 @@
 end
 
 function dumpActions(self)
-    local result = "Available Actions: " 
-    for action in table.pairsByKeys(self.actions.byName) do
-        result = result .. " " .. action
-    end
-    return result
+       local result = "Available Actions: " 
+       for action in table.pairsByKeys(self.actions.byName) do
+               result = result .. " " .. action
+       end
+       return result
 end
 
 function _getActionEventIndexByName(self, name)
-    if (self.actions.byName[name] == nil) then
-        return nil   
-    end
-    
-    return self.actions.byName[name].index
+       if (self.actions.byName[name] == nil) then
+               return nil   
+       end
+       
+       return self.actions.byName[name].index
 end
 
 function getActionEventNameByIndex(self, index)
-    if (index > #self.actions.byIndex) then
-        log:error("action event index out of bounds: " , index)
-        return nil   
-    end
-    
-    return self.actions.byIndex[index].name
+       if (index > #self.actions.byIndex) then
+               log:error("action event index out of bounds: " , index)
+               return nil   
+       end
+       
+       return self.actions.byIndex[index].name
 end
 
 --[[
@@ -577,14 +577,14 @@
 =cut
 --]]
 function newActionEvent(self, action)
-    local actionIndex = self:_getActionEventIndexByName(action)
-    if not actionIndex then
-        log:error("action name not registered: (" , action, "). Available 
actions: ", self:dumpActions() )
-        return nil
-    end
-    
-    return Event:new(ACTION, actionIndex)
-    
+       local actionIndex = self:_getActionEventIndexByName(action)
+       if not actionIndex then
+               log:error("action name not registered: (" , action, "). 
Available actions: ", self:dumpActions() )
+               return nil
+       end
+       
+       return Event:new(ACTION, actionIndex)
+       
 end
 
 --[[
@@ -597,17 +597,17 @@
 =cut
 --]]
 function registerAction(self, actionName)
-    if (self.actions.byName[actionName]) then
-        log:error("Action already registered, doing nothing: ", actionName)
-        return
-    end
-    
-    local actionEventDefinition = { name = actionName, index = 
#self.actions.byIndex + 1 }
-
-    log:debug("Registering action: ", actionEventDefinition.name, " with 
index: ", actionEventDefinition.index)
-    self.actions.byName[actionName] = actionEventDefinition
-    table.insert(self.actions.byIndex, actionEventDefinition)
-    
+       if (self.actions.byName[actionName]) then
+               log:error("Action already registered, doing nothing: ", 
actionName)
+               return
+       end
+       
+       local actionEventDefinition = { name = actionName, index = 
#self.actions.byIndex + 1 }
+
+       log:debug("Registering action: ", actionEventDefinition.name, " with 
index: ", actionEventDefinition.index)
+       self.actions.byName[actionName] = actionEventDefinition
+       table.insert(self.actions.byIndex, actionEventDefinition)
+       
 end
 
 
@@ -616,26 +616,26 @@
        _assert(type(listener) == "function")
 
 
-    if not self:_getActionEventIndexByName(action) then
-        log:error("action name not registered:(" , action, "). Available 
actions: ", self:dumpActions() )
-        return 
-    end
-    log:debug("Creating action listener for action: (" , action, ") from 
source: ", sourceBreadCrumb)
-    
+       if not self:_getActionEventIndexByName(action) then
+               log:error("action name not registered:(" , action, "). 
Available actions: ", self:dumpActions() )
+               return 
+       end
+       log:debug("Creating action listener for action: (" , action, ") from 
source: ", sourceBreadCrumb)
+       
        self:addListener(ACTION,
                function(event)
-                   local eventAction = event:getAction()
-                   if eventAction != action then
-                       return EVENT_UNUSED
-                   end
-           log:debug("Calling action listener for action: (" , action, ") from 
source: ", sourceBreadCrumb)
+                       local eventAction = event:getAction()
+                       if eventAction != action then
+                               return EVENT_UNUSED
+                       end
+                       log:debug("Calling action listener for action: (" , 
action, ") from source: ", sourceBreadCrumb)
                
-            local listenerResult = listener(obj, event)
-            --default to consume unless the listener specifically wants to set 
a specific event return
-            return listenerResult and listenerResult or EVENT_CONSUME
+                       local listenerResult = listener(obj, event)
+                       --default to consume unless the listener specifically 
wants to set a specific event return
+                       return listenerResult and listenerResult or 
EVENT_CONSUME
                end
        )
-    
+       
 end
 
 --[[

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

Reply via email to