Author: duncan
Date: Wed Jan 17 22:04:48 2007
New Revision: 8988
Modified:
branches/rel-1/freevo/share/skins/main/basic_BB.fxd
branches/rel-1/freevo/share/skins/main/bluestar_BB.fxd
branches/rel-1/freevo/share/skins/main/blurr_BB.fxd
branches/rel-1/freevo/share/skins/main/crystal_BB.fxd
branches/rel-1/freevo/share/skins/main/dark_BB.fxd
branches/rel-1/freevo/share/skins/main/info_BB.fxd
branches/rel-1/freevo/share/skins/main/mediaportal_BB.fxd
branches/rel-1/freevo/share/skins/main/noia_BB.fxd
branches/rel-1/freevo/share/skins/main/rain_BB.fxd
branches/rel-1/freevo/src/plugins/buttonbar.py
Log:
[ 1638053 ] Crash in ButtonBar when selecting AudioItems
Patch from Adam Charrett applied
Modified: branches/rel-1/freevo/share/skins/main/basic_BB.fxd
==============================================================================
--- branches/rel-1/freevo/share/skins/main/basic_BB.fxd (original)
+++ branches/rel-1/freevo/share/skins/main/basic_BB.fxd Wed Jan 17 22:04:48 2007
@@ -381,10 +381,34 @@
</if>
<newline/>
</if>
+ <if expression="stream_name">
+ <text width="140" align="right" font="player
info">Name:</text>
+ <goto_pos x="10" mode="relative"/>
+ <text font="player info" expression="stream_name"/>
+ <newline/>
+ </if>
+ <if expression="genre">
+ <text width="140" align="right" font="player
info">Genre:</text>
+ <goto_pos x="10" mode="relative"/>
+ <text font="player info" expression="genre"/>
+ <newline/>
+ </if>
<if expression="trackno">
<text width="140" align="right" font="player
info">Track:</text>
<goto_pos x="10" mode="relative"/>
<text font="player info" expression="trackno"/>
+ <if expression="trackof">
+ <text font="player info">/</text>
+ <text font="player info" expression="trackof"/>
+ </if>
+ <newline/>
+ </if>
+ <if expression="bitrate">
+ <text width="140" align="right" font="player
info">Bitrate:</text>
+ <goto_pos x="10" mode="relative"/>
+ <text font="player info" expression="bitrate"/>
+ <text width="130" font="player info">kb/s</text>
+
<newline/>
</if>
<goto_pos y="15" mode="relative"/>
@@ -501,6 +525,19 @@
y="-5" width="max+10" height="max+10"/>
</item>
+ <item type="overlap" font="tv">
+ <rectangle bgcolor="0xeb8123" size="1" color="0x000000"
x="-5"
+ y="-5" width="max+10" height="max+10"/>
+ </item>
+
+ <item type="current" font="tv highlight">
+ <rectangle bgcolor="0xff000000" color="0x000000" size="1"
x="-5" y="-5" width="max+10" height="max+10"/>
+ </item>
+
+ <item type="past" font="tv grey">
+ <rectangle bgcolor="0xff000000" color="0x000000" size="1"
x="-5" y="-5" width="max+10" height="max+10"/>
+ </item>
+
</content>
</layout>
@@ -637,6 +674,8 @@
<font label="tv selected" name="VeraBd.ttf" size="16" color="0xffff66">
<shadow visible="yes" color="0x000000" x="1" y="1"/>
</font>
+ <font label="tv grey" name="VeraBd.ttf" size="16" color="0xa0bbbbbb"/>
+ <font label="tv highlight" name="VeraBd.ttf" size="16"
color="0xa0eeee00"/>
<font label="tv time" name="VeraBd.ttf" size="14" color="0xffffaa"/>
<font label="tv title" name="VeraBd.ttf" size="24" color="0xffffff">
<shadow x="2" y="2" color="0x000000" visible="yes"/>
@@ -684,7 +723,20 @@
width="780" height="80"/>
<info layout="info" x="10" y="110" width="780" height="480"/>
</headlines>
+ <!--
+ *******************************************************
+ ** Button Bar TVGuide Info
+ ******************************************************* -->
+ <tvguideinfo>
+ <screen layout="screen" x="0" y="0" width="800" height="600"/>
+ <title layout="tvguideinfo title" x="10" y="70" width="780"
height="80"/>
+ <info layout="info" x="10" y="130" width="780" height="460"/>
+ </tvguideinfo>
+
+ <layout label="tvguideinfo title">
+ <content x="0" y="0" type="menu" font="title area" align="left"
valign="center"/>
+ </layout>
</skin>
</freevo>
<!-- Keep this comment at the end of the file
Modified: branches/rel-1/freevo/share/skins/main/bluestar_BB.fxd
==============================================================================
--- branches/rel-1/freevo/share/skins/main/bluestar_BB.fxd (original)
+++ branches/rel-1/freevo/share/skins/main/bluestar_BB.fxd Wed Jan 17
22:04:48 2007
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<freevo>
- <skin include="info (BB)" geometry="800x600">
+ <skin include="info_BB" geometry="800x600">
<iconset theme="bluestar"/>
<main>
Modified: branches/rel-1/freevo/share/skins/main/blurr_BB.fxd
==============================================================================
--- branches/rel-1/freevo/share/skins/main/blurr_BB.fxd (original)
+++ branches/rel-1/freevo/share/skins/main/blurr_BB.fxd Wed Jan 17 22:04:48 2007
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<freevo>
- <skin include="basic (BB)" geometry="800x600">
+ <skin include="basic_BB" geometry="800x600">
<!--
*******************************************************
Modified: branches/rel-1/freevo/share/skins/main/crystal_BB.fxd
==============================================================================
--- branches/rel-1/freevo/share/skins/main/crystal_BB.fxd (original)
+++ branches/rel-1/freevo/share/skins/main/crystal_BB.fxd Wed Jan 17
22:04:48 2007
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<freevo>
- <skin include="info (BB)" geometry="800x600">
+ <skin include="info_BB" geometry="800x600">
<iconset theme="Crystal"/>
<main>
Modified: branches/rel-1/freevo/share/skins/main/dark_BB.fxd
==============================================================================
--- branches/rel-1/freevo/share/skins/main/dark_BB.fxd (original)
+++ branches/rel-1/freevo/share/skins/main/dark_BB.fxd Wed Jan 17 22:04:48 2007
@@ -1,6 +1,6 @@
<?xml version="1.0" ?>
<freevo>
- <skin geometry="800x600" include="info (BB)">
+ <skin geometry="800x600" include="info_BB">
<iconset theme="tuxntosh"/>
<!--
TODO:
Modified: branches/rel-1/freevo/share/skins/main/info_BB.fxd
==============================================================================
--- branches/rel-1/freevo/share/skins/main/info_BB.fxd (original)
+++ branches/rel-1/freevo/share/skins/main/info_BB.fxd Wed Jan 17 22:04:48 2007
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<freevo>
- <skin include="basic (BB)" geometry="800x600">
+ <skin include="basic_BB" geometry="800x600">
<!--
*******************************************************
Modified: branches/rel-1/freevo/share/skins/main/mediaportal_BB.fxd
==============================================================================
--- branches/rel-1/freevo/share/skins/main/mediaportal_BB.fxd (original)
+++ branches/rel-1/freevo/share/skins/main/mediaportal_BB.fxd Wed Jan 17
22:04:48 2007
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<freevo>
- <skin include="basic" geometry="800x600">
+ <skin include="basic_BB" geometry="800x600">
<!--
*******************************************************
Modified: branches/rel-1/freevo/share/skins/main/noia_BB.fxd
==============================================================================
--- branches/rel-1/freevo/share/skins/main/noia_BB.fxd (original)
+++ branches/rel-1/freevo/share/skins/main/noia_BB.fxd Wed Jan 17 22:04:48 2007
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<freevo>
- <skin include="info (BB)" geometry="800x600">
+ <skin include="info_BB" geometry="800x600">
<iconset theme="Noia"/>
<image label="background" filename="blurr_naxos"/>
Modified: branches/rel-1/freevo/share/skins/main/rain_BB.fxd
==============================================================================
--- branches/rel-1/freevo/share/skins/main/rain_BB.fxd (original)
+++ branches/rel-1/freevo/share/skins/main/rain_BB.fxd Wed Jan 17 22:04:48 2007
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<freevo>
- <skin include="info (BB)" geometry="800x600">
+ <skin include="info_BB" geometry="800x600">
<iconset theme="Rain"/>
<main>
Modified: branches/rel-1/freevo/src/plugins/buttonbar.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/buttonbar.py (original)
+++ branches/rel-1/freevo/src/plugins/buttonbar.py Wed Jan 17 22:04:48 2007
@@ -36,13 +36,18 @@
import skin
import osd
import event
+import rc
from tv.tvguide import TVGuide
+from item import Item
from menu import MenuItem, Menu
from pygame import image,transform, Surface
-# Create the OSD object
-OSD = osd.get_singleton()
+DEBUG = config.DEBUG
+
+# Create the skin object
+skin = skin.get_singleton()
+skin.register('tvguideinfo', ('screen', 'title', 'info', 'plugin'))
# Create the events and assign them to the menus.
BUTTONBAR_RED = event.Event('BUTTONBAR_RED')
@@ -60,18 +65,69 @@
event.TVMENU_EVENTS['YELLOW'] = BUTTONBAR_YELLOW
event.TVMENU_EVENTS['BLUE'] = BUTTONBAR_BLUE
+# Action functions used to perform special actions for the button bar
def advance_tv_guide(arg=0, menuw=None):
"""
action to advance the tv guide by a number of hours passed in arg.
"""
tvguide = menuw.menustack[-1]
- new_start_time = tvguide.start_time+(arg * 60 * 60)
- new_end_time = tvguide.stop_time+(arg * 60 * 60)
+ new_start_time = tvguide.start_time + (arg * 60 * 60)
+ new_end_time = tvguide.stop_time + (arg * 60 * 60)
programs = tvguide.guide.GetPrograms(new_start_time+1, new_end_time-1, [
tvguide.start_channel])
- new_selected_program = programs[0].programs[0]
+ if (len(programs) > 0) and (len(programs[0].programs) > 0):
+ new_selected_program = programs[0].programs[0]
+ else:
+ new_selected_program = None
tvguide.rebuild(new_start_time,new_end_time, tvguide.start_channel,
new_selected_program)
menuw.refresh()
+
+def send_event_to_menu(arg=None, menuw=None):
+ """
+ send the event specified in arg to menuw's eventhandler.
+ """
+ menuw.eventhandler(arg)
+
+
+# Program Info screen
+class ShowProgramDetails:
+ """
+ Screen to show the details of the TV program
+ """
+ def __init__(self, menuw):
+ tvguide = menuw.menustack[-1]
+ prg = tvguide.selected
+ if prg is None:
+ name = _('No Information Available')
+ description = ''
+ else:
+ name = prg.title
+ description = prg.getattr('time') + u'\n' + prg.desc
+ item = MenuItem(name=name)
+ item.description = description
+ self.menuw = menuw
+ self.menuw.hide(clear=False)
+ rc.app(self)
+ skin.draw('tvguideinfo', item)
+
+
+ def eventhandler(self, event, menuw=None):
+ """
+ eventhandler
+ """
+ if event in ('MENU_SELECT', 'MENU_BACK_ONE_MENU'):
+ rc.app(None)
+ self.menuw.show()
+ return True
+
+ return False
+
+
+def show_program_info(arg=None, menuw =None):
+ ShowProgramDetails(menuw)
+
+
+ # Plugin interface
class PluginInterface(plugin.DaemonPlugin):
"""
global button bar plugin.
@@ -82,40 +138,75 @@
"""
plugin.DaemonPlugin.__init__(self)
plugin.register(self, 'buttonbar')
- self.poll_interval = 10
self.visible = True
self.bar = None
self.barfile = ''
self.surface = None
- self.colors = ('red', 'green', 'yellow', 'blue')
+ self.colors = ['red', 'green', 'yellow', 'blue']
self.actions = [None, None, None, None]
- self.tvguide_actions = (MenuItem('-1 Day', action= advance_tv_guide,
arg= -24),
- MenuItem('-6 Hours', action=
advance_tv_guide, arg= -6),
- MenuItem('+6 Hours', action=
advance_tv_guide, arg= 6),
- MenuItem('+1 Day', action=
advance_tv_guide, arg= 24))
-
+ if not hasattr(config, 'BUTTONBAR_TVGUIDE_ACTIONS'):
+ self.tvguide_actions = [MenuItem('-1 Day', action=
advance_tv_guide, arg= -24),
+ MenuItem('-6 Hours', action=
advance_tv_guide, arg= -6),
+ MenuItem('+6 Hours', action=
advance_tv_guide, arg= 6),
+ MenuItem('+1 Day', action=
advance_tv_guide, arg= 24)]
+ else:
+ # Process TV Guide buttons
+ self.tvguide_actions = [None, None, None, None]
+ for index in range(0, len(self.colors)):
+ if
config.BUTTONBAR_TVGUIDE_ACTIONS.has_key(self.colors[index]):
+ actionstr =
config.BUTTONBAR_TVGUIDE_ACTIONS[self.colors[index]]
+ if actionstr == 'record':
+ self.tvguide_actions[index] = MenuItem(_('Record'),
+
action=send_event_to_menu,
+
arg= event.TV_START_RECORDING)
+ elif actionstr == 'info':
+ self.tvguide_actions[index] = MenuItem(_('Info'),
+
action=show_program_info)
+ elif actionstr.startswith('adv:'):
+ hours = eval(actionstr[4:])
+ self.tvguide_actions[index] = MenuItem('Advance %d
hours' % hours,
+
action= advance_tv_guide,
+
arg= hours)
# Getting current LOCALE
try:
locale.resetlocale()
except:
pass
+
+ def config(self):
+ """
+ Configuration options for the button bar.
+ """
+ # Available actions for use in the TVGuide are:
+ # adv:<hours> - Advance the tv guide <hours> hours.
+ # record - Set the selected program to record.
+ # info - Display more information on the selected
program.
+ return [('BUTTONBAR_TVGUIDE_ACTIONS',
+ { 'red':'adv:-24',
+ 'green':'adv:-6',
+ 'yellow':'adv:6',
+ 'blue':'adv:24'
+ },
+ 'actions to display in the button bar when the TV Guide is
visible.')]
+
def draw(self, (type, object), osd):
"""
- draw a background and color buttons
+ Draw a background and color buttons
"""
+ BUTTON_BAR_HEIGHT = 60
menu = osd.menu
- if (isinstance(menu, Menu) and \
- ((menu.item_types == 'main') or (menu.heading == 'Skin
Selector'))) or \
- isinstance(menu, MenuItem) :
+ actions = self.get_actions(menu)
+
+ if actions is None: # No actions, don't draw the bar.
return
-
+
# draw Button bar
- w = osd.width+(2 * osd.x)
- h = osd.y+60
- y = ((osd.y * 2)+osd.height)-h
+ w = osd.width + (2 * osd.x)
+ h = osd.y + BUTTON_BAR_HEIGHT
+ y = ((osd.y * 2) + osd.height) - h
f = skin.get_image('idlebar')
@@ -130,64 +221,46 @@
# draw the cached barimage
if self.bar:
osd.drawimage(self.bar, (0, y, w, h), background=True)
-
- if isinstance(menu, TVGuide):
- actions = self.tvguide_actions
- else:
- # Determine the available actions
- if hasattr(menu, 'is_submenu'):
- return
-
- actions = menu.selected.actions()
- if not actions:
- actions = []
-
- 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)
- elif len(a) == 2 or a[2] != 'MENU_SUBMENU':
- actions.append(a[:2])
-
- if len(actions) == 0:
- return
-
+
# Buttons modified from
http://openclipart.org/cchost/media/files/kuba/1988
# draw the buttons
- buttonwidth = w / 4
- x = 0
- index = 0
- while (index < len(self.colors)):
- if index < len(actions):
- self.drawbutton(osd, x, y, buttonwidth, h, self.colors[index],
actions[index])
+ buttonwidth = osd.width / 4
+ x = osd.x
+
+ for index in range(0, len(self.colors)):
+ if actions[index] is not None:
+ self.draw_button(osd, x, y, buttonwidth, BUTTON_BAR_HEIGHT,
self.colors[index], actions[index])
self.actions[index] = actions[index]
else:
self.actions[index] = None
- index += 1
x += buttonwidth
- def drawbutton(self, osd, x, y, w, h, color, action):
- iw,ih = osd.drawimage(os.path.join(config.ICON_DIR,
'misc/'+color+'button.png' ) , (x+5, y+7, -1, -1))
+ def draw_button(self, osd, x, y, w, h, color, action):
+ """
+ Draw a color button and associated text.
+ """
+ iconfilename = os.path.join(config.ICON_DIR, 'misc/' + color +
'button.png' )
+ iw,ih = osd.drawimage(iconfilename, (x + 5, y + 7, -1, -1))
if isinstance(action, MenuItem):
string = action.name
else:
string = action[1]
- font = osd.get_font('small0')
- osd.drawstring(string, font, None, x = x+5+iw, y = y+5, width = w-iw,
height = h-10, mode = 'soft', align_v='center')
+ font = osd.get_font('small0')
+ osd.drawstring(string, font, None,
+ x = x + 5 + iw, y = y + 5, width = w - iw,
height = h - 10,
+ mode = 'soft', align_v='center')
+
def eventhandler(self, event, menuw=None):
- action = None
+ """
+ Handle color button events.
+ """
+ action = None
result = False
+
if event == BUTTONBAR_RED:
action = self.actions[0]
result = True
@@ -200,12 +273,94 @@
elif event == BUTTONBAR_BLUE:
action = self.actions[3]
result = True
+
- if not action:
+ if action is None:
return result
+
if isinstance(action, MenuItem):
action.select(menuw=menuw)
else:
action[0](menuw=menuw)
-
+
+ return result
+
+ def get_actions(self, menu):
+ """
+ Retrieve the Red/Green/Yellow/Blue actions for supplied menu.
+ The actions are returned in an array in the order:
+ [red,green,yellow,blue].
+ None is returned if no actions are available and the bar should not
+ be drawn.
+ """
+
+ if ((isinstance(menu, Menu) and (menu.item_types == 'main')) or
+ isinstance(menu, MenuItem)):
+ return None
+
+ if isinstance(menu, TVGuide):
+ dateformat = config.TV_DATEFORMAT
+ timeformat = config.TV_TIMEFORMAT
+ if not timeformat:
+ timeformat = '%H:%M'
+ if not dateformat:
+ dateformat = '%d-%b'
+
+ for action in self.tvguide_actions:
+ if action.function == advance_tv_guide:
+ newtime = menu.start_time + (action.arg * 60 *60)
+ action.name = Unicode(time.strftime('%s %s' % (dateformat,
timeformat),
+
time.localtime(newtime)))
+ return self.tvguide_actions
+ else:
+ # Determine the available actions
+ if hasattr(menu, 'is_submenu') or (not hasattr(menu, 'selected')):
+ return None
+
+ result = [None, None, None, None]
+ found_color_actions = False
+
+ for index in range(0, len(self.colors)):
+ if hasattr(menu, self.colors[index] + '_action'):
+ found_color_actions = True
+ result[index] = eval('menu.' + color + '_action')
+
+ if found_color_actions:
+ return result
+
+ actions = menu.selected.actions()
+ if not actions:
+ actions = []
+
+ 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)
+ elif len(a) == 2 or a[2] != 'MENU_SUBMENU':
+ actions.append(a[:2])
+
+ if len(actions) == 0:
+ result = None
+
+ if len(actions) >= 1:
+ result[0] = actions[0]
+ if len(actions) >= 2:
+ result[1] = actions[1]
+ if len(actions) >= 3:
+ result[2] = actions[2]
+ if len(actions) == 4:
+ result[3] = actions[3]
+
+ # Special case for when there are more than 4 possible actions the
last button will 'Enter' the submenu
+ if len(actions) > 4:
+ result[3] = MenuItem(_("More Options"),
action=send_event_to_menu, arg= event.MENU_SUBMENU)
return result
+
+
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog