Package elisa :: Package plugins :: Package bad :: Package poblenou_frontend :: Module tree_controller
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.bad.poblenou_frontend.tree_controller

 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__ = 'Florian Boucault <florian@fluendo.com>' 
19   
20  from elisa.core import plugin_registry 
21  TreeControllerClass = plugin_registry.get_component_class('base:tree_controller') 
22   
23  from elisa.core.input_event import * 
24   
25  from twisted.internet import reactor 
26   
27 -class TreeController(TreeControllerClass):
28
29 - def handle_input(self, input_event):
30 31 if input_event.action == EventAction.GO_DOWN: 32 self.enter_node() 33 return True 34 35 elif input_event.action == EventAction.GO_LEFT: 36 self._go_left() 37 return True 38 39 elif input_event.action == EventAction.GO_RIGHT: 40 self._go_right() 41 return True 42 43 elif input_event.action == EventAction.OK: 44 if self.current_index >= 0 and self.current_index < len(self): 45 child_controller = self[self.current_index] 46 if callable(child_controller.model.activate_action): 47 child_controller.model.activate_action(self, 48 input_event.origin) 49 else: 50 self.enter_node() 51 return True 52 53 return False
54 55
56 - def _go_left(self):
57 if len(self) > 0: 58 self.current_index = (self.current_index - 1) % len(self)
59 60
61 - def _go_right(self):
62 if len(self) > 0: 63 self.current_index = (self.current_index + 1) % len(self)
64
65 - def enter_node(self):
66 if len(self) == 0: 67 return 68 69 child_controller = self[self.current_index] 70 if child_controller.model.has_children: 71 child_controller.loadmore() 72 child_controller.focus() 73 child_controller.selected = True 74 75 if self.loadmore_on_selection == True and len(child_controller) > 0: 76 grand_child_controller = child_controller[child_controller.current_index] 77 if grand_child_controller.model.has_children: 78 grand_child_controller.loadmore()
79