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

Source Code for Module elisa.plugins.good.xmlmenu.xmlmenu_components.playlist_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 elisa.core import common 
21   
22  from menu_entry_builder import MenuEntryBuilder 
23   
24  from twisted.internet import defer 
25   
26 -class PlaylistNodeBuilder(MenuEntryBuilder):
27 """ 28 Build MenuEntries for the type 'menu_node'. this is meant to be temporaly 29 """ 30
31 - def __init__(self):
32 registry = common.application.plugin_registry 33 self._clear_model = registry.create_component('base:menu_node_model') 34 self._clear_model.text = "Clear Playlist" 35 self._clear_model.theme_icon = "clear_playlist_icon" 36 37 clear_action = registry.create_component('xmlmenu:clearplaylist_action') 38 39 # FIXME: cross-referencing is bad! 40 clear_action.clearing_model = self._clear_model 41 42 # FIXME: cross-referencing is bad! 43 self._clear_model.activate_action = clear_action
44 45 46
47 - def menu_entry_identifiers__get(self):
48 return ['playlist_node']
49
50 - def build_menu_entry(self, parent, node):
51 # Label-Making 52 label_tag = node.find('Label') 53 label = self._make_label(label_tag) 54 55 default_config = self.model_configs[parent] 56 config = self._make_config(node.find('Configuration'), 57 default_config) 58 59 registry = common.application.plugin_registry 60 menu_model = registry.create_component('base:menu_node_model') 61 menu_model.children = parent.activity.player_model.playlist 62 menu_model.activity = self 63 menu_model.text = label 64 menu_model.has_children = True 65 self._set_icon(menu_model, node.find('Icon'), 66 fallback=config['DefaultDirsIcon']) 67 68 self.model_configs[menu_model] = config 69 70 # FIXME: wrong place to do that! 71 self._clear_model.activate_action.player_model = parent.activity.player_model 72 73 parent.children.append(menu_model) 74 return defer.succeed([menu_model])
75
76 - def loadmore(self, model):
77 if not self._clear_model in model.children: 78 model.children.insert(0, self._clear_model) 79 return defer.succeed(model.children)
80
81 - def unload(self, model):
82 if len(model.children): 83 model.children.remove(self._clear_model)
84