Home | Trees | Indices | Help |
---|
|
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.base_components.controller import Controller 21 from elisa.core.observers.list import ListObserver 22 from elisa.core.input_event import * 23 24 from twisted.internet import reactor 2527 """ 28 DOCME 29 30 @ivar current_index: index of the currently selected item in the list 31 @type current_index: int 32 """ 33 34 supported_models = ('base:list_model',) 35 36 action_called = False 3715039 super(ListController, self).__init__() 40 self.current_index = 0 41 self._moves = 0 42 self._set_current_index_call = None4345 return "<%s current_index=%r %s items>" % (self.__class__.__name__, 46 self.current_index, 47 len(self.model))4850 model = self.model[int(self.current_index)] 51 if callable(model.activate_action): 52 # Hack to look, if we are going to do something with media 53 if hasattr(model.activate_action, 'player_model') or \ 54 hasattr(model.activate_action, 'uri'): 55 56 self.action_called = True 57 model.activate_action(self, origin) 58 self.action_called = False 59 else: 60 self.parent.enter_node(model)61 62 # compress the number of next_item and previous_items so that we don't 63 # destroy the cpu65 result = self.current_index + self._moves + step 66 if result >= len(self.model): 67 return 68 69 self._moves += step 70 71 if self._set_current_index_call is None: 72 self._set_current_index_call = \ 73 reactor.callLater(0.05, self.set_current_index)7476 result = self.current_index + self._moves - step 77 if result < 0: 78 return 79 80 self._moves -= step 81 if self._set_current_index_call is None: 82 self._set_current_index_call = \ 83 reactor.callLater(0.05, self.set_current_index)8486 self._set_current_index_call = None 87 moves = self._moves 88 self._moves = 0 89 self.current_index = self.current_index + moves9092 if input_event.action == EventAction.GO_UP: 93 self.previous_item() 94 return True 95 96 elif input_event.action == EventAction.GO_DOWN: 97 self.next_item() 98 return True 99 100 elif input_event.action == EventAction.GO_LEFT: 101 # We don't want, that the parent is doing something 102 return True 103 104 elif input_event.action == EventAction.OK: 105 self.activate_item(input_event.origin) 106 return True 107 108 return False109 110 # FIXME: should be abstracted away112 for weak_view in self._observers: 113 view = weak_view() 114 if view == None: 115 continue 116 else: 117 view.inserted(elements, position)118120 for weak_view in self._observers: 121 view = weak_view() 122 if view == None: 123 continue 124 else: 125 view.removed(elements, position)126128 for weak_view in self._observers: 129 view = weak_view() 130 if view == None: 131 continue 132 else: 133 view.modified(position, value)134136 for weak_view in self._observers: 137 view = weak_view() 138 if view == None: 139 continue 140 else: 141 view.dirtied()142144 for weak_view in self._observers: 145 view = weak_view() 146 if view == None: 147 continue 148 else: 149 view.element_attribute_set(position, key, old_value, new_value)
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Jan 16 19:10:29 2008 | http://epydoc.sourceforge.net |