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 21 from elisa.base_components.view import View 22 23 import pgm 24 from pgm.graph.group import Group 25 from pgm.graph.image import Image 26 from pgm.timing import implicit 27 from elisa.core import player, common 28 29 from twisted.internet import defer, reactor 30 31 from elisa.core import plugin_registry 32 NodeControllerClass = plugin_registry.get_component_class('base:node_controller') 33 34 35 import os 36 import gtk.gdk, gobject 37 3840 41 supported_controllers = ('base:elisa_controller',) 42 bindings = {'player': 'player', 43 'dvd_player': 'dvd_player', 44 'slideshow': 'slideshow', 45 'menu': 'menu'} 4619948 super(ElisaView, self).__init__() 49 self.context_path = 'pigment:pigment_context' 50 self.context_handle = None 51 self._background = None 52 self._animated_player = None 53 self._animated_dvd_player = None 54 self._animated_slideshow = None 55 self._animated_fade = None5658 if new_frontend == None: 59 return 60 61 canvas = new_frontend.context.canvas 62 group = Group(canvas, pgm.DRAWABLE_MIDDLE) 63 group.opacity = 255 64 group.visible = True 65 self.context_handle = group 66 67 # FIXME: is this the right place to do that? 68 icon_path = self.frontend.theme.get_media("elisa_icon", 69 "poblenou:theme/elisa.png") 70 try: 71 icon = gtk.gdk.pixbuf_new_from_file(icon_path) 72 except gobject.GError: 73 self.warning("Icon file not found: %r", icon_path) 74 else: 75 self.frontend.context.viewport_handle.icon = icon76 7779 self._create_fade() 80 self._create_background() 81 self._create_menu() 82 self._create_player() 83 self._create_dvd_player() 84 self._create_slideshow() 85 86 #self.menu.player_image = self.player.background 87 # FIXME: next two lines useless ? 88 self._animated_player.opacity = 255 89 self._animated_dvd_player.opacity = 255 90 self._animated_slideshow.opacity = 255 91 92 self.menu.controller.focus() 93 self.menu.controller.selected = True 94 95 self.frontend.context.viewport_handle.fullscreen = self.controller.fullscreen 96 97 # FIXME: this is not the nicest solution; the fade in should start 98 # exactly when all the children views are ready (pictures loaded, etc.) 99 reactor.callLater(1.0, self._fade_in)100102 self.context_handle.add(self.player.context_handle) 103 self._unzoom_widget(self.player.context_handle) 104 105 self._animated_player = implicit.AnimatedObject(self.player.context_handle) 106 self._animated_player.mode = implicit.REPLACE 107 self._animated_player.setup_next_animations(duration = 500, 108 transformation = implicit.DECELERATE)109111 self.context_handle.add(self.dvd_player.context_handle) 112 self._unzoom_widget(self.dvd_player.context_handle) 113 114 self._animated_dvd_player = implicit.AnimatedObject(self.dvd_player.context_handle) 115 self._animated_dvd_player.mode = implicit.REPLACE 116 self._animated_dvd_player.setup_next_animations(duration = 500, 117 transformation = implicit.DECELERATE)118120 self.context_handle.add(self.slideshow.context_handle) 121 self._unzoom_widget(self.slideshow.context_handle) 122 123 self._animated_slideshow = implicit.AnimatedObject(self.slideshow.context_handle) 124 self._animated_slideshow.mode = implicit.REPLACE 125 self._animated_slideshow.setup_next_animations(duration = 500, 126 transformation = implicit.DECELERATE)127 137 138140 canvas = self.frontend.context.canvas 141 142 background_path = self.frontend.theme.get_media("background", 143 "poblenou:theme/background.png") 144 self._background = Image() 145 self._background.bg_a = 0 146 self._background.size = canvas.size 147 self._background.layout = pgm.IMAGE_ZOOMED 148 self._background.set_from_file(background_path) 149 self._background.set_name('background') 150 151 canvas.add(pgm.DRAWABLE_FAR, self._background) 152 153 self._background.visible = True154156 background_path = self.frontend.theme.get_media("shade", 157 "poblenou:theme/shade.png") 158 self._fade = Image() 159 self._fade.bg_a = 0 160 self._fade.size = (4.0, 3.0) 161 self._fade.set_from_file(background_path) 162 self._fade.set_name(background_path) 163 164 canvas = self.frontend.context.canvas 165 166 self._fade.opacity = 255 167 self._fade.visible = True 168 self._fade.bg_color = (0, 0, 0, 0) 169 self._fade.position = (0.0, 0.0, 20.0) 170 self._fade.width = canvas.width 171 self._fade.height = canvas.height*2.0 172 self._fade.layout = pgm.IMAGE_FILLED 173 self._animated_fade = implicit.AnimatedObject(self._fade) 174 self.context_handle.add(self._fade)175 176178 self.debug("Fading in") 179 canvas = self.frontend.context.viewport_handle.get_canvas() 180 self._animated_fade.setup_next_animations(duration = 1000, 181 transformation = implicit.DECELERATE) 182 self._animated_fade.position = (0.0, -canvas.height*2.0, 20.0)183185 # fading out that takes 1 second 186 self.debug("Fading out") 187 self._animated_fade.setup_next_animations(duration = 1000) 188 self._animated_fade.position = (0.0, 0.0, 20.0) 189 190 dfr = defer.Deferred() 191 192 def finish(dfr): 193 dfr.callback(None)194 195 # FIXME: would be better with triggers in the animation framework 196 reactor.callLater(1, finish, dfr) 197 198 return dfr201 canvas = self.frontend.context.canvas 202 203 widget.size = (canvas.width/2.0, canvas.height/2.0) 204 widget.position = (canvas.width/4.0, canvas.height/30.0, 1.0) 205 206 self._animated_menu.opacity = 255207209 self._unzoom_widget(widget) 210 widget.opacity = 0 211 212 widget.size = self.frontend.context.canvas.size 213 widget.position = (0.0, 0.0, 1.0) 214 215 self._animated_menu.opacity = 0 216 widget.opacity = 255217 218220 activity_name = self.controller.last_panel_focused.model.activity.name 221 if activity_name == 'dvd_player_activity': 222 return self._animated_dvd_player 223 if activity_name == 'slideshow_activity': 224 return self._animated_slideshow 225 226 return self._animated_player227 228230 View.attribute_set(self, origin, key, old_value, new_value) 231 if key == 'focused': 232 last_panel = self.last_animated_panel_widget_selected 233 if self.menu.controller.focused: 234 self._unzoom_widget(last_panel) 235 236 # FIXME: big hack to hide the dock 237 if last_panel == self._animated_player: 238 self.player.osd_hide() 239 elif last_panel == self._animated_dvd_player: 240 self.dvd_player.player_dock.hide() 241 else: 242 self._zoom_widget(last_panel) 243 244 elif key == 'fullscreen': 245 self.frontend.context.viewport_handle.fullscreen = new_value 246 247 elif key == 'menu_controller_focused': 248 last_panel = self.last_animated_panel_widget_selected 249 250 if self._is_root_menu(new_value): 251 focused_model = self.controller.last_panel_focused.model 252 activity_name = focused_model.activity.name 253 last_panel.opacity = 0 254 if activity_name == 'player_activity': 255 if self.controller.player.model.media_type != 'audio': 256 focused_model.state = player.STATES.PAUSED 257 self.player.osd_hide() 258 elif activity_name == 'dvd_player_activity': 259 if focused_model.state == player.STATES.PLAYING: 260 focused_model.state = player.STATES.PAUSED 261 self.player.player_dock.hide() 262 elif activity_name == 'slideshow_activity': 263 focused_model.playing = False 264 else: 265 # retrieve the menu activity we're currently browsing. 266 if len(self.menu.controller) > 0: 267 index = self.menu.controller.current_index 268 menu_activity = self.menu.controller[index].model.activity 269 270 # we want no preview in audio & service activities 271 if menu_activity.name in ('video_activity', 272 'dvd_activity', 273 'image_activity', 274 'player_activity' 275 ): 276 277 last_panel.opacity = 255 278 279 elif key == 'theme_path': 280 try: 281 application = common.application 282 theme = application.plugin_registry.create_component(new_value) 283 application.config.set_option('theme', 284 new_value, 285 section=self.name) 286 self.frontend.theme = theme 287 except: 288 self.warning("Cannot create theme %r for frontend %r", new_value, 289 self.name) 290 raise291 292 293 295 if isinstance(controller, NodeControllerClass) and isinstance(controller.parent, NodeControllerClass): 296 return False 297 return True 298
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Jan 16 19:10:50 2008 | http://epydoc.sourceforge.net |