On Wed, Aug 01, 2007 at 11:38:01AM +0200, Duncan Webb wrote: > > Not sure if this helps but hasattr(self.item.media, 'id') may be only > true when the item is a cd drive. > Yes. It has helped, thank you. There are some lines in the actual code that check 'label' instead of 'id' but I think both variables are available for CDs
The attached patch against revision 9797 of the SVN should add the option "Eject drive" in the submenu when a video/audio/image cdrom is inserted in the drive. When the drive is empty I have created a new CdromEmptyItem class that appends the action "eject/close" to the submenu. As it is the only menu entry it binds the ENTER event to the eject/close action. The drive eject/close logic was already in Freevo so the patch is quite small.
Index: src/cdromemptyitem.py
===================================================================
--- src/cdromemptyitem.py (revisión: 0)
+++ src/cdromemptyitem.py (revisión: 0)
@@ -0,0 +1,70 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# cdromemptyitem.py - Item for an empty cdrom
+# -----------------------------------------------------------------------
+# $Id
+#
+# Notes:
+#
+# Todo:
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
+
+import rc
+
+from item import Item
+from event import *
+
+class CdromEmptyItem(Item):
+
+ def __init__(self, parent=None):
+ Item.__init__(self, parent)
+
+ self.type = 'empty_cdrom'
+
+
+ # ------------------------------------------------------------------------
+ # actions:
+
+
+ def actions(self):
+ """
+ return a list of possible actions on this item.
+ """
+
+ items = []
+ if hasattr(self.media, 'id'):
+ if self.media.is_tray_open():
+ str = _('Close drive')
+ else:
+ str = _('Eject drive')
+
+ items.append((self.eject, str))
+
+ return items
+
+
+ def eject(self, arg=None, menuw=None):
+ """
+ ejects or closes tray
+ """
+ self.media.move_tray(dir='toggle')
Index: src/directory.py
===================================================================
--- src/directory.py (revisión: 9797)
+++ src/directory.py (copia de trabajo)
@@ -469,10 +469,20 @@
if self.media:
self.media.umount()
+ if hasattr(self.media, 'id'):
+ items.append((self.eject, _('Eject drive')))
+
return items
+ def eject(self, arg=None, menuw=None):
+ """
+ ejects or closes tray
+ """
+ self.media.move_tray(dir='toggle')
+ rc.post_event(MENU_BACK_ONE_MENU)
+
def cwd(self, arg=None, menuw=None):
"""
browse directory
Index: src/plugins/rom_drives.py
===================================================================
--- src/plugins/rom_drives.py (revisión: 9797)
+++ src/plugins/rom_drives.py (copia de trabajo)
@@ -80,6 +80,7 @@
from item import Item
from audio import AudioDiskItem
from video import VideoItem
+from cdromemptyitem import CdromEmptyItem
LABEL_REGEXP = re.compile("^(.*[^ ]) *$").match
@@ -221,7 +222,7 @@
m = media.item
else:
- m = Item(parent)
+ m = CdromEmptyItem(parent)
m.name = _('Drive %s (no disc)') % media.drivename
m.type = media.type
m.media = media
signature.asc
Description: Digital signature
------------------------------------------------------------------------- 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-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freevo-users
