Package elisa :: Package plugins :: Package base :: Package actions :: Module view_image_action
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.base.actions.view_image_action

 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.action import Action 
21  from elisa.core import common 
22   
23  from twisted.internet import defer 
24   
25  # FIXME: code duplicated from PreviewImageAction 
26   
27 -class ViewImageAction(Action):
28 """ 29 DOCME 30 """ 31 32 label = 'view image' 33 supported_file_types = ('image',) 34 35 uri = None 36 parent_uri = None 37 slideshow_model = None 38
39 - def __call__(self, controller, origin):
40 media_manager = common.application.media_manager 41 42 self.debug("Clean the slideshow_model playlist") 43 self.slideshow_model.playlist[:] = [] 44 45 def got_media_type(media_type, uri): 46 self.debug("%s has been identified as a %s" \ 47 % (uri, media_type["file_type"])) 48 # only add images to the playlist 49 if media_type["file_type"] == "image": 50 self.slideshow_model.playlist.append(uri)
51 52 def playlist_ready(result): 53 self.debug("Playlist filled with media from %s" % self.parent_uri) 54 index = self.slideshow_model.playlist.index(self.uri) 55 self.slideshow_model.current_index = index 56 57 self.slideshow_model.preview_mode = False 58 self.slideshow_model.playing = False
59 60 def got_children(children): 61 self.debug("Listed media from the same directory as %s" % self.uri) 62 dfr_list = [] 63 for child_uri, _ in children: 64 dfr = media_manager.get_media_type(child_uri) 65 dfr.addCallback(got_media_type, child_uri) 66 dfr_list.append(dfr) 67 68 dfr2 = defer.DeferredList(dfr_list) 69 dfr2.addCallback(playlist_ready) 70 71 children = [] 72 dfr = media_manager.get_direct_children(self.parent_uri, children) 73 dfr.addCallback(got_children) 74