Package elisa :: Package plugins :: Package bad :: Package raval_frontend :: Module context_controller
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.bad.raval_frontend.context_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  from elisa.core import common 
19  from elisa.core import player 
20  from elisa.core.input_event import * 
21   
22  plugin_registry = common.application.plugin_registry 
23  ListController = plugin_registry.get_component_class('raval:list_controller') 
24   
25 -class ContextController(ListController):
26 """ 27 DOCME 28 """ 29 30 supported_models = ('raval:context_model',) 31
32 - def focused_changed(self, old_focused, new_focused):
33 if new_focused: 34 self.current_index = 0 35 else: 36 self.current_index = -1
37
38 - def previous_item(self, step=1):
39 if self.current_index == 0: 40 self.parent.focus() 41 else: 42 super(ContextController, self).previous_item(step=step)
43
44 - def handle_input(self, input_event):
45 if input_event.action == EventAction.GO_LEFT: 46 self.previous_item() 47 return True 48 49 elif input_event.action == EventAction.GO_RIGHT: 50 self.next_item() 51 return True 52 53 elif input_event.action == EventAction.GO_DOWN: 54 self.current_index = -1 55 self.parent.focus() 56 return True 57 58 elif input_event.action == EventAction.OK: 59 self.fire_activate_action(self.current_index, input_event.origin) 60 return True
61
62 - def fire_activate_action(self, index, origin):
63 if index > -1 and len(self.model) > 0: 64 model = self.model[index] 65 action = model.activate_action 66 if callable(action): 67 action(self, origin)
68