Package elisa :: Package plugins :: Package base :: Package activities :: Module service_activity
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.base.activities.service_activity

 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__ = 'Lionel Martin <lionel@fluendo.com>' 
19   
20   
21  from elisa.core import common 
22  from elisa.core.plugin_registry import PluginNotFound, ComponentNotFound 
23  from elisa.core import plugin_registry 
24   
25  from elisa.extern.translation import gettexter, N_ 
26  T_ = gettexter('elisa-service') 
27   
28  MenuActivityClass = plugin_registry.get_component_class('base:menu_activity') 
29   
30 -class ServiceActivity(MenuActivityClass):
31 """ 32 This class provides and manages the Service Activities 33 """ 34 config_doc = {'service_activities': 'a list of activites, which should' 35 'appear in the service_menu'} 36 default_config = {'service_activities': []} 37 38 menu_name = T_(N_("Services")) 39 menu_icon_name = "service" 40 media_types = [] 41
42 - def get_model(self):
43 """ 44 Returns a menu_node_model for the Service Menu 45 """ 46 registry = common.application.plugin_registry 47 main_node = MenuActivityClass.get_model(self) 48 main_node.children = registry.create_component('base:list_model') 49 50 for activity in self.config.get("service_activities" , []): 51 try: 52 component = registry.create_component(activity) 53 except (PluginNotFound, ComponentNotFound), error: 54 self.warning(error) 55 else: 56 menu_model = component.get_model() 57 self.log("Component %r with menu model %r", component, 58 menu_model) 59 60 if menu_model != None: 61 self.log("menu model: %r", menu_model) 62 main_node.children.append(menu_model) 63 64 main_node.has_children = len(main_node.children) > 0 65 66 return main_node
67