Author: bklaas
Date: Wed Aug 6 09:36:13 2008
New Revision: 2788
URL: http://svn.slimdevices.com?rev=2788&root=Jive&view=rev
Log:
Bug: 8871, 9014
Description: support for sending choice items in SlimBrowse menus
For now, this is only for commands fully described in the menu item
(actions.do.choices) and requires a selectedIndex param also sent so SlimBrowse
knows what it's dealing with
If there's a need for supporting "base" with choice items, this will come in a
future checkin
Modified:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
Modified:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua?rev=2788&root=Jive&r1=2787&r2=2788&view=diff
==============================================================================
---
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
(original)
+++
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
Wed Aug 6 09:36:13 2008
@@ -295,6 +295,26 @@
return item["_jive_button"]
end
+-- _choiceItem
+-- returns a choice set for use on a given item
+local function _choiceItem(item, db)
+ local choiceFlag = tonumber(item["selectedIndex"])
+ local choiceActions = _safeDeref(item, 'actions', 'do', 'choices')
+
+ if choiceFlag and choiceActions and not item["_jive_button"] then
+ item["_jive_button"] = Choice(
+ "choice",
+ item['choiceStrings'],
+ function(_, index)
+ log:info('Callback has been called: ', index)
+ _actionHandler(nil, nil, db, nil, nil, 'do',
item, index)
+ end,
+ choiceFlag
+ )
+ end
+ return item["_jive_button"]
+end
+
-- _radioItem
-- returns a radio button for use on a given item
@@ -337,6 +357,10 @@
if item["radio"] then
group._type = "radio"
group:setWidget("icon", _radioItem(item, db))
+
+ elseif item['selectedIndex'] then
+ group._type = 'choice'
+ group:setWidget('icon', _choiceItem(item, db))
elseif item["checkbox"] then
group._type = "checkbox"
@@ -1177,16 +1201,17 @@
-- _actionHandler
-- sorts out the action business: item action, base action, default action...
-_actionHandler = function(menu, menuItem, db, dbIndex, event, actionName, item)
+_actionHandler = function(menu, menuItem, db, dbIndex, event, actionName,
item, selectedIndex)
log:debug("_actionHandler(", actionName, ")")
if logd:isDebug() then
debug.dump(item, 4)
end
+ local choiceAction
+
-- some actions work (f.e. pause) even with no item around
if item then
-
local chunk = db:chunk()
local bAction
local iAction
@@ -1228,10 +1253,11 @@
onAction = _safeDeref(item, 'actions', 'on')
offAction = _safeDeref(item, 'actions', 'off')
end
-
+
+ choiceAction = _safeDeref(item, 'actions', 'do', 'choices')
-- now check for a run-of-the mill action
- if not (iAction or bAction or onAction or offAction) then
+ if not (iAction or bAction or onAction or offAction or
choiceAction) then
bAction = _safeDeref(chunk, 'base', 'actions',
actionName)
iAction = _safeDeref(item, 'actions', actionName)
else
@@ -1242,13 +1268,15 @@
-- XXX: Fred: After an input box is used, chunk is nil, so base
can't be used
- if iAction or bAction then
-
+ if iAction or bAction or choiceAction then
-- the resulting action, if any
local jsonAction
+ -- special case, handling a choice item action
+ if choiceAction and selectedIndex then
+ jsonAction = _safeDeref(item, 'actions',
actionName, 'choices', selectedIndex)
-- process an item action first
- if iAction then
+ elseif iAction then
log:debug("_actionHandler(", actionName, "):
item action")
-- found a json command
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins