Author: duncan
Date: Sat Oct 6 12:26:28 2007
New Revision: 9932
Log:
[ 1807315 ] shoppingcart.py: add REMOVE feature
Patch not applied, but fixed this correctly to change the menu text too
Modified:
branches/rel-1/freevo/ChangeLog
branches/rel-1/freevo/src/image/viewer.py
branches/rel-1/freevo/src/plugins/shoppingcart.py
Modified: branches/rel-1/freevo/ChangeLog
==============================================================================
--- branches/rel-1/freevo/ChangeLog (original)
+++ branches/rel-1/freevo/ChangeLog Sat Oct 6 12:26:28 2007
@@ -27,6 +27,7 @@
* Updated alsamixer with event args and synchronous mixer control (F#1767928)
* Updated a submenu selection when there is only one action to execute the
action (F#1774569)
* Updated osd overscan to allow different margins for all sides (F#1791026)
+ * Updated shopping cart plug-in at allow items to removed as well (F#1807315)
* Updated tv favourite handling and programme item to provide a consistant
interface (F#1776909)
* Updated video item to include the full description (F#1777187)
* Fixed audio plug-in albumtree navigating back to the main menu (B#1798462)
Modified: branches/rel-1/freevo/src/image/viewer.py
==============================================================================
--- branches/rel-1/freevo/src/image/viewer.py (original)
+++ branches/rel-1/freevo/src/image/viewer.py Sat Oct 6 12:26:28 2007
@@ -409,7 +409,7 @@
elif event == IMAGE_TAG:
if plugin.is_active('shoppingcart'):
try:
- plugin.get('item')[0].addItemToCart(self.fileitem)
+ plugin.get('item')[0].shuntItemInCart(self.fileitem)
return True
except Exception, e:
print 'getbyname(\'shoppingcart\')', e
Modified: branches/rel-1/freevo/src/plugins/shoppingcart.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/shoppingcart.py (original)
+++ branches/rel-1/freevo/src/plugins/shoppingcart.py Sat Oct 6 12:26:28 2007
@@ -98,13 +98,28 @@
rc.post_event(em.Event(em.OSD_MESSAGE, arg=_('Added to Cart')))
- def addItemToCart(self, item):
- if hasattr(item, 'subitems') and item.subitems:
- for s in item.subitems:
- self.cart.append(s)
+ def removeFromCart(self, arg=None, menuw=None):
+ if hasattr(self.item, 'subitems') and self.item.subitems:
+ for s in self.item.subitems:
+ self.cart.remove(s)
+ else:
+ self.cart.remove(self.item)
+
+ if isinstance(menuw.menustack[-1].selected, menu.MenuItem):
+ rc.post_event(em.MENU_BACK_ONE_MENU)
+ else:
+ rc.post_event(em.Event(em.OSD_MESSAGE, arg=_('Removed Item from
Cart')))
+
+
+ def shuntItemInCart(self, item):
+ ''' Move an image item into or out of the shopping cart
+ '''
+ if self.cart != [] and item in self.cart:
+ self.cart.remove(item)
+ rc.post_event(em.Event(em.OSD_MESSAGE, arg=_('Removed Item from
Cart')))
else:
self.cart.append(item)
- rc.post_event(em.Event(em.OSD_MESSAGE, arg=_('Added Item to Cart')))
+ rc.post_event(em.Event(em.OSD_MESSAGE, arg=_('Added Item to
Cart')))
def deleteCart(self, arg=None, menuw=None):
@@ -120,6 +135,7 @@
# only activate this for directory items
return []
+ _debug_('item=%s, type=%s, cart=%s' % (item, item.type, self.cart), 2)
if item.type == 'dir':
if len(self.cart) > 0:
for c in self.cart:
@@ -129,13 +145,17 @@
myactions.append((self.moveHere, _('Cart: Move Files
Here')))
myactions.append((self.copyHere, _('Cart: Copy Files Here')))
- if not item in self.cart:
- if self.item.parent and self.item.parent.type == 'dir':
+ if self.item.parent and self.item.parent.type == 'dir':
+ if item not in self.cart:
myactions.append((self.addToCart, _('Add Directory to
Cart'), 'cart:add'))
+ elif item in self.cart:
+ myactions.append((self.removeFromCart, _('Remove Directory
from Cart'), 'cart:remove'))
- elif hasattr(item, 'files') and item.files and
item.files.copy_possible() and \
- not item in self.cart:
- myactions.append((self.addToCart, _('Add File to Cart'),
'cart:add'))
+ elif hasattr(item, 'files') and item.files:
+ if item not in self.cart and item.files.copy_possible():
+ myactions.append((self.addToCart, _('Add to Cart'),
'cart:add'))
+ elif item in self.cart:
+ myactions.append((self.removeFromCart, _('Remove from Cart'),
'cart:remove'))
if self.cart:
myactions.append((self.deleteCart, _('Delete Cart')))
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog