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 from elisa.core import common 18 from elisa.core.input_event import * 19 from elisa.base_components.controller import Controller 2022 23 supported_models = ('raval:manager_model',) 24 current_path = [] 25 26 bindings = {'location': 'location', 27 'context': 'context', 28 'current_content_type': 'current_content_type'} 29 30 current = None 31 model_loading = None 32 35130 13137 self.context_active = new_focus and len(self.current_path) > 138 4244 if len(self.current_path) <= 1: 45 return 46 47 model = self.current_path[-1].model 48 if hasattr(model, 'content_type') and content_type == model.content_type: 49 return 50 51 model.content_type = content_type 52 self.update_controller()53 5456 if input_event.action == EventAction.MENU: 57 try: 58 self.exit_node() 59 return True 60 except IndexError, exc: 61 # We are at the main menu 62 return False 63 64 elif input_event.action in (EventAction.GO_RIGHT, EventAction.GO_LEFT, 65 EventAction.GO_UP, EventAction.GO_DOWN): 66 self.enter_context_bar() 67 return True 68 69 return False7072 """ 73 @raise IndexError: if there would be no items left after exiting 74 """ 75 self.debug("exiting from %s" % self.current.model) 76 77 self.model_loading = None 78 79 if len(self.current_path) <= 1: 80 raise IndexError("Root node reached") 81 82 old_current = self.current_path.pop(-1) 83 self.current = self.current_path[-1] 84 self.current.focus() 85 try: 86 model = old_current.model 87 model.activity.unload(model) 88 except AttributeError: 89 self.warning("%s is missing an activity. could not unload it", 90 old_current.model) 91 except IndexError, exc: 92 self.warning("The activity '%s' could not unload %r", 93 old_current.model.activity, old_current.model) 94 95 if len(self.model.location): 96 # update the current location 97 self.model.location.pop(-1) 98 99 self.context_visible = len(self.current_path) > 1100102 model = self.current_path[-1].model 103 prev_controller = self.current_path.pop(-1) 104 prev_controller.backend = None 105 prev_controller.parent = None 106 prev_controller.model = None 107 108 if hasattr(model, 'content_type'): 109 content_type = model.content_type 110 else: 111 content_type = None 112 113 controller = self._create_controller(model, content_type) 114 self.current_path.append(controller) 115 self.current = controller 116 self.current.focus()117 119 if content_type == None and hasattr(model, 'content_type'): 120 content_type = model.content_type 121 122 controller_path = self.backend.get_controller_path(model.path, 123 content_type) 124 plugin_registry = common.application.plugin_registry 125 controller = plugin_registry.create_component(controller_path) 126 controller.backend = self.backend 127 controller.parent = self 128 controller.model = model 129 return controller133 if not self.model_loading: 134 self.model_loading = model 135 else: 136 self.debug("Already entering a node: %r", self.model_loading) 137 return 138 139 self.debug("entering: %s" % model) 140 if not model.has_children: 141 self.model_loading = None 142 return 143 144 def model_loaded(model, parent): 145 self.debug("model returned by the activity: %r", model) 146 # create a corresponding controller 147 148 # If the parent is not in the upper list, we suggest, that the 149 # user went somewhere else and so, we do NOT load this 150 # controller 151 if parent != self.model_loading: 152 return 153 154 controller = self._create_controller(model) 155 self.current_path.append(controller) 156 157 self.current = controller 158 self.current.focus() 159 160 # update the current location 161 if len(self.current_path) > 1: 162 if len(self.current_path) == 2: 163 self.context.icon = parent.theme_icon 164 self.context.text = parent.text 165 else: 166 self.model.location.append(parent) 167 168 self.model_loading = None169 170 def got_errback(error): 171 self.model_loading = None 172 # FIXME: we should also do something clever over here ;) 173 return error 174 175 dfr = model.activity.loadmore(model) 176 dfr.addCallback(model_loaded, model).addErrback(got_errback) 177
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Jan 16 19:11:08 2008 | http://epydoc.sourceforge.net |