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

Source Code for Module elisa.plugins.bad.raval_frontend.elisa_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 player 
 19  from elisa.core import common 
 20  from elisa.core.input_event import * 
 21  from elisa.base_components.controller import Controller 
 22   
23 -class ElisaController(Controller):
24 supported_models = ('base:elisa_model',) 25 bindings = {'player': 'player', 26 'dvd_player': 'dvd_player', 27 'slideshow': 'slideshow', 28 'manager': 'manager'} 29 30 default_config = {'start_fullscreen': '1'} 31 config_doc = {'start_fullscreen': 'whether or not Elisa should start fullscreen'} 32
33 - def initialize(self):
34 dfr = Controller.initialize(self) 35 self.fullscreen = bool(int(self.config.get('start_fullscreen', '0'))) 36 self._last_player = None 37 return dfr
38
39 - def attribute_set(self, origin, key, old_value, new_value):
40 super(ElisaController, self).attribute_set(origin, key, old_value, new_value) 41 if key == 'menu_visible': 42 if new_value == True: 43 if self.slideshow.focused: 44 self._last_player = self.slideshow 45 elif self.player.focused: 46 self._last_player = self.player 47 self.focus() 48 else: 49 if self._last_player == None: 50 self._last_player = self.player 51 self._last_player.focus() 52 53 elif key == 'stop_player' and new_value == True: 54 if self._last_player == self.slideshow: 55 self.slideshow.model.playing = False 56 self.slideshow.model.current_index = -1 57 else: 58 self.player.stopped = True 59 self.player.model.state = player.STATES.STOPPED
60
61 - def handle_input(self, input_event):
62 if input_event.action == EventAction.TOGGLE_FULLSCREEN: 63 self.fullscreen = not self.fullscreen 64 return True 65 elif input_event.action == EventAction.EXIT: 66 common.application.stop() 67 return True 68 69 elif input_event.action == EventAction.MENU: 70 if self.slideshow.focused or self.player.focused: 71 self.model.menu_visible = True 72 else: 73 self.model.menu_visible = False 74 return True 75 76 return False
77
78 - def model_changed(self, old_model, new_model):
79 self.manager.enter_node(self.model.menu)
80
81 - def focus(self):
82 self.manager.focus()
83
84 - def focused_changed(self, old_focused, new_focused):
85 # FIXME: this relies on the fact that the actions system somehow 86 # make the controllers (player, slideshow, etc.) to focus and that the 87 # focus notification is going up to their parent (ElisaController) 88 89 for key, value in self.bindings.iteritems(): 90 child_controller = getattr(self, key) 91 if child_controller.focused: 92 self.focused_window = value 93 break 94 if self.focused_window == 'slideshow': 95 # Pause the video player if a picture is diplayed fullscreen 96 # or a slideshow started. 97 player_model = self.player.model 98 if player_model.media_type == "video" and \ 99 player_model.state == player.STATES.PLAYING: 100 player_model.state = player.STATES.PAUSED
101