Author: duncan
Date: Thu Aug 16 04:33:49 2007
New Revision: 9822
Log:
[ 1773418 ] Plugin for adding eject drive submenu option
New plug-in from Gorka Olaizola added
Added:
branches/rel-1/freevo/src/plugins/ejectromdrives.py (contents, props
changed)
Modified:
branches/rel-1/freevo/ChangeLog
branches/rel-1/freevo/freevo_config.py
branches/rel-1/freevo/src/menu.py
Modified: branches/rel-1/freevo/ChangeLog
==============================================================================
--- branches/rel-1/freevo/ChangeLog (original)
+++ branches/rel-1/freevo/ChangeLog Thu Aug 16 04:33:49 2007
@@ -17,6 +17,7 @@
--------------------------------
* Updated German translation (F#1770195)
+ * New Eject CD-ROM plug-in, adding a menu item to the drive menu (F#1773418)
* New Text Entry and Program Search (F#1768790)
* 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)
Modified: branches/rel-1/freevo/freevo_config.py
==============================================================================
--- branches/rel-1/freevo/freevo_config.py (original)
+++ branches/rel-1/freevo/freevo_config.py Thu Aug 16 04:33:49 2007
@@ -290,7 +290,8 @@
(5.21,
'''Added OS_STATICDIR, FREEVO_STATICDIR, OS_LOGDIR and FREEVO_LOGDIR
Change static data to use /var/lib/freevo or ~/.freevo, including
TV_RECORD_SCHEDULE, TV_LOGOS,
- XMLTV_FILE, you may also prefer OVERLAY_DIR to be
FREEVO_STATICDIR+'/overlay'
+ XMLTV_FILE, you may also prefer OVERLAY_DIR to be
FREEVO_STATICDIR+'/overlay',
+ Added a plugin that adds a submenu entry for ejecting rom drives and
binds the default action of an empty drive to the eject action
'''),
]
@@ -684,6 +685,7 @@
# autostarter when inserting roms while Freevo is in the MAIN MENU
plugin.activate('rom_drives.autostart')
+plugin.activate('ejectromdrives')
# add the rom drives to each sub main menu
rom_plugins = {}
Modified: branches/rel-1/freevo/src/menu.py
==============================================================================
--- branches/rel-1/freevo/src/menu.py (original)
+++ branches/rel-1/freevo/src/menu.py Thu Aug 16 04:33:49 2007
@@ -665,9 +665,38 @@
try:
action = menu.selected.action
except AttributeError:
- action = menu.selected.actions()
- if action:
- action = action[0]
+ actions = menu.selected.actions()
+ if not actions:
+ actions = []
+
+ # Add the actions of the plugins to the list of actions.
+ # This is needed when a Item class has no actions but plugins
+ # provides them. This case happens with an empty disc.
+ #
+ # FIXME The event MENU_SELECT is called when selecting
+ # a submenu entry too. The item passed to the plugin is then
+ # the submenu entry instead its parent item. So if we are in
+ # a submenu we don't want to call the actions of the plugins.
+ # because we'll break some (or all) plugins behavior.
+ # Does that sound correct?
+ #
+ if not hasattr(menu, 'is_submenu'):
+ plugins = plugin.get('item') + plugin.get('item_%s' %
menu.selected.type)
+
+ if hasattr(menu.selected, 'display_type'):
+ plugins += plugin.get('item_%s' %
menu.selected.display_type)
+
+ plugins.sort(lambda l, o: cmp(l._level, o._level))
+
+ for p in plugins:
+ for a in p.actions(menu.selected):
+ if isinstance(a, MenuItem):
+ actions.append(a)
+ else:
+ actions.append(a[:2])
+
+ if actions:
+ action = actions[0]
if isinstance(action, MenuItem):
action = action.function
arg = action.arg
Added: branches/rel-1/freevo/src/plugins/ejectromdrives.py
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/plugins/ejectromdrives.py Thu Aug 16 04:33:49 2007
@@ -0,0 +1,93 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# ejectromdrives.py - Adds and eject entry to the submenu of items
+# -----------------------------------------------------------------------
+# $Id
+#
+# Notes: This plugin adds an entry to the submenu for ejecting the drive
+#
+# Version: 0.2
+#
+# Activate:
+# plugin.activate('ejectromdrives')
+#
+# Bugs:
+#
+# -----------------------------------------------------------------------
+# 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 plugin
+import rc
+import event as em
+import menu
+
+class PluginInterface(plugin.ItemPlugin):
+ """
+ This plugin ejects/close the tray of rom drives.
+
+ plugin.activate('ejectromdrives')
+
+ """
+ __author__ = 'Gorka Olaizola'
+ __author_email__ = '[EMAIL PROTECTED]'
+ __maintainer__ = __author__
+ __maintainer_email__ = __author_email__
+ __version__ = '$Revision'
+
+ def __init__(self):
+ plugin.ItemPlugin.__init__(self)
+ self.item = None
+
+ def actions(self, item):
+ self.item = item
+ myactions = []
+
+ if item.media and hasattr(item.media, 'id'):
+ if item.media.is_mounted():
+ item.media.umount()
+
+ if item.media.is_tray_open():
+ str = _('Close drive')
+ else:
+ str = _('Eject drive')
+
+ myactions.append((self.eject, str))
+
+ return myactions
+
+
+ def eject(self, arg=None, menuw=None):
+ """
+ ejects or closes tray
+ """
+ if self.item and self.item.media and hasattr(self.item.media, 'id'):
+ _debug_('Item is a CD-ROM drive')
+
+ # Stop the running video or music in detached mode
+ rc.post_event(em.Event(em.BUTTON, arg=em.STOP))
+
+ self.item.media.move_tray(dir='toggle')
+
+ if isinstance(menuw.menustack[-1].selected, menu.MenuItem):
+ rc.post_event(em.MENU_BACK_ONE_MENU)
+ else:
+ _debug_('Item is not a CD-ROM drive')
-------------------------------------------------------------------------
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