Package elisa :: Package plugins :: Package good :: Package pigment :: Module pigment_view
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.good.pigment.pigment_view

  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  __maintainer__ = 'Philippe Normand <philippe@fluendo.com>' 
 18  __maintainer2__ = 'Florian Boucault <florian@fluendo.com>' 
 19   
 20  from elisa.base_components.view import View 
 21  import pgm 
 22  from pgm.timing import implicit 
 23  from pgm.graph.group import Group 
 24   
 25  from elisa.core.utils.classinit import ClassInitMeta 
 26  from pgm.utils.classinit import GClassInitMeta 
 27   
28 -class ViewClassInitMeta(GClassInitMeta,ClassInitMeta):
29 pass
30
31 -class PigmentView(View):
32 """ 33 DOCME 34 """ 35 36 __metaclass__ = ViewClassInitMeta 37 38 context_path = 'pigment:pigment_context' 39
40 - def __init__(self):
41 super(PigmentView, self).__init__() 42 self.context_handle = Group() 43 self.context_handle.visible = True 44 45 # provide an animated object acting on the view itself 46 self.animated = implicit.AnimatedObject(self.context_handle) 47 self.animated.setup_next_animations(duration=1000, 48 transformation=implicit.DECELERATE) 49 self.animated.mode = implicit.REPLACE
50
51 - def parent__set(self, parent):
52 if self.parent != None and self.context_handle != None: 53 self.parent.context_handle.remove(self.context_handle) 54 55 super(PigmentView, self).parent__set(parent) 56 57 if parent != None and self.context_handle != None: 58 parent.context_handle.add(self.context_handle)
59
60 - def frontend_changed(self, previous_frontend, new_frontend):
61 if previous_frontend != None: 62 previous_frontend.context.canvas_resized.disconnect(self.canvas_resized) 63 64 if new_frontend == None: 65 return 66 67 self.create_widgets() 68 69 viewport = new_frontend.context.viewport_handle 70 canvas = viewport.get_canvas() 71 self.context_handle.canvas = canvas 72 73 # connects to the signals of the new frontend and context 74 new_frontend.context.canvas_resized.connect(self.canvas_resized)
75
76 - def create_widgets(self):
77 """ 78 DOCME 79 """ 80 pass
81
82 - def canvas_resized(self, new_size):
83 """ 84 DOCME 85 """ 86 pass
87
88 - def attribute_set(self, origin, key, old_value, new_value):
89 super(PigmentView, self).attribute_set(origin, key, old_value, new_value) 90 91 if key == 'fullscreen': 92 gtk_window = self.frontend.context.gtk_window 93 if gtk_window is None: 94 self.frontend.context.viewport_handle.fullscreen = new_value 95 else: 96 if new_value: 97 gtk_window.fullscreen() 98 else: 99 gtk_window.unfullscreen()
100
101 - def load_from_theme(self, icon, image):
102 """ 103 Loads an icon from the theme into a Pigment image. 104 105 @param icon: icon to load 106 @type icon: str 107 @param image: drawable into which the icon will be loaded 108 @type image: L{pgm.Image} 109 """ 110 # FIXME: unused masters are never released 111 if not self.frontend.context.master_drawables.has_key(icon): 112 # create a master drawable 113 master = pgm.Image() 114 master.visible = False 115 image_path = self.frontend.theme.get_media(icon) 116 master.set_from_file(image_path) 117 canvas = self.frontend.context.viewport_handle.get_canvas() 118 canvas.add(pgm.DRAWABLE_FAR, master) 119 120 self.frontend.context.master_drawables[icon] = master 121 else: 122 # reuse an existent master drawable 123 master = self.frontend.context.master_drawables[icon] 124 125 image.set_from_image(master)
126