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

Source Code for Module elisa.plugins.bad.raval_frontend.preview

 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   
19  import pgm 
20  from pgm.graph.group import Group 
21  from pgm.graph.image import Image 
22  from pgm.utils import image as image_utils 
23   
24  plugin_registry = common.application.plugin_registry 
25  BaseListView = plugin_registry.get_component_class('raval:list_view') 
26   
27 -class Preview(BaseListView, Group):
28
29 - def create_widgets(self):
30 super(Preview, self).create_widgets() 31 32 viewport = self.frontend.context.viewport_handle 33 canvas = viewport.get_canvas() 34 35 # preview drawable 36 self.image = Image() 37 self.add(self.image) 38 self.image.bg_a = 0 39 self.image.layout = pgm.IMAGE_SCALED 40 self.image.alignment = pgm.IMAGE_BOTTOM 41 self.image.visible = True 42 43 # reflection drawable 44 self.reflection = Image() 45 self.add(self.reflection) 46 self.reflection.bg_a = 0 47 self.reflection.layout = pgm.IMAGE_SCALED 48 self.reflection.alignment = pgm.IMAGE_TOP 49 self.reflection.opacity = 150 50 self.reflection.visible = True 51 52 self._image_path = None 53 self.image.connect('pixbuf-loaded', lambda x: self._update_reflection()) 54 55 # 2px spacing 56 spacing = (canvas.height / viewport.height) * 2. 57 self.reflection.y += self.image.height + spacing 58 59 self.reflection.z = 0.01 60 61 flip_matrix = pgm.mat4x4_new_predefined(pgm.MAT4X4_FLIP_VERTICAL) 62 self.reflection.mapping_matrix = flip_matrix
63
64 - def _update_image_path(self, image_path):
65 self._image_path = image_path
66
67 - def _update_reflection(self):
68 if self._image_path != None: 69 image_utils.cairo_gradient(self._image_path, self.reflection, 0.4)
70
71 - def update(self):
72 # FIXME: this view should be connected to the same controller as its 73 # parent 74 model = self.parent.controller.model[self.parent.selected_item] 75 76 if model.thumbnail_source: 77 # white borders 78 self.image.border_outer_color = (255, 255, 255, 255) 79 self.image.border_inner_color = (255, 255, 255, 220) 80 # self.image.border_width = self.image * 0.005 81 82 uri = model.thumbnail_source 83 dfr = self._thumbnail_source_to_image(uri, self.image) 84 dfr.addBoth(self._update_image_path) 85 else: 86 path = self.frontend.theme.get_media(model.theme_icon) 87 self._update_image_path(path) 88 self.image.set_from_file(path)
89