Package elisa :: Package plugins :: Package good :: Package xmlmenu :: Package xmlmenu_components :: Module activity_node_builder
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.good.xmlmenu.xmlmenu_components.activity_node_builder

 1  # -*- coding: utf-8 -*- 
 2  # Elisa - Home multimedia server 
 3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
 4  # All rights reserved. 
 5  # 
 6  # This file is available under one of two license agreements. 
 7  # 
 8  # This file is licensed under the GPL version 3. 
 9  # See "LICENSE.GPL" in the root of this distribution including a special 
10  # exception to use Elisa with Fluendo's plugins. 
11  # 
12  # The GPL part of Elisa is also available under a commercial licensing 
13  # agreement from Fluendo. 
14  # See "LICENSE.Elisa" in the root directory of this distribution package 
15  # for details on that license. 
16   
17   
18  __maintainer__ = 'Benjamin Kampmann <benjamin@fluendo.com>' 
19   
20  from menu_entry_builder import MenuEntryBuilder 
21  from elisa.core.plugin_registry import PluginNotFound, ComponentNotFound 
22   
23  from elisa.core import common 
24   
25  from twisted.internet import defer 
26   
27 -class ActivityNodeBuilder(MenuEntryBuilder):
28
29 - def menu_entry_identifiers__get(self):
30 return ['activity_node']
31
32 - def build_menu_entry(self, parent, node_xml):
33 registry = common.application.plugin_registry 34 35 a_xml = node_xml.find('Activity') 36 37 if a_xml == None: 38 self.warning("Missing 'Activity'-Tag in %s" % node_xml) 39 return defer.succeed([]) 40 41 activity_path = a_xml.text 42 43 registry = common.application.plugin_registry 44 try: 45 # FIXME: this should be Deferred-Based! 46 activity = registry.create_component(activity_path) 47 except (PluginNotFound, ComponentNotFound), error: 48 self.warning("Could not make activity %s:%s" % (activity_path, 49 error)) 50 return defer.succeed([]) 51 else: 52 # I don't like that! 53 activity.player_model = parent.activity.player_model 54 activity.dvd_player_model = parent.activity.dvd_player_model 55 activity.slideshow_model = parent.activity.slideshow_model 56 57 model_class = registry.get_component_class('base:menu_node_model') 58 59 # works only, if we can be sure, that we get an MenuNode-Model 60 # from the acvtivity! 61 model = activity.get_model() 62 63 if not isinstance(model, model_class): 64 parent_model = registry.create_component('base:menu_node_model') 65 parent_model.text = self._make_label(node_xml.find('Label')) 66 self._set_icon(parent_model, node_xml.find('Icon')) 67 # FIXME: this should better be a action that returns the other 68 # model, but actions do not yet return models. 69 # parent_model.action = model 70 return defer.succeed([parent_model]) 71 else: 72 parent.children.append(model) 73 return defer.succeed([model])
74