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

Source Code for Module elisa.plugins.bad.raval_frontend.raval_widgets.mini_player

  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  import pgm 
 18  from pgm.graph.group import Group 
 19  from pgm.graph.image import Image 
 20  from pgm.graph.text import Text 
 21   
22 -class MiniPlayer(Group):
23
24 - def __init__(self, background=None, play_icon=None, pause_icon=None):
25 Group.__init__(self) 26 27 self._background = Image() 28 self._background.layout = pgm.IMAGE_SCALED 29 #self._background.interp = pgm.IMAGE_NEAREST 30 self.background.bg_color = (0, 0, 0, 0) 31 32 self._play_icon = Image() 33 self._play_icon.layout = pgm.IMAGE_SCALED 34 self._play_icon.bg_color = (0, 0, 0, 0) 35 self._play_icon.connect("clicked", self.play_clicked) 36 37 self._pause_icon = Image() 38 self._pause_icon.layout = pgm.IMAGE_SCALED 39 self._pause_icon.bg_color = (0, 0, 0, 0) 40 self._pause_icon.connect("clicked", self.pause_clicked) 41 42 self.add(self._background) 43 self.add(self._play_icon) 44 self.add(self._pause_icon) 45 46 self.background = background 47 self.play_icon = play_icon 48 self.pause_icon = pause_icon
49
50 - def pause_clicked(self, widget, x, y, z, time, button_type):
51 pass
52
53 - def play_clicked(self, widget, x, y, z, time, button_type):
54 pass
55
56 - def background__set(self, background_file):
57 if background_file: 58 self._background.set_from_file(background_file)
59
60 - def background__get(self):
61 return self._background
62
63 - def play_icon__set(self, icon_file):
64 if icon_file: 65 self._play_icon.set_from_file(icon_file)
66
67 - def play_icon__get(self):
68 return self._play_icon
69
70 - def pause_icon__set(self, icon_file):
71 if icon_file: 72 self._pause_icon.set_from_file(icon_file)
73
74 - def pause_icon__get(self):
75 return self._pause_icon
76
77 - def bg_color__set(self, color):
78 self.pause_icon.bg_color = color 79 self.play_icon.bg_color = color
80
81 - def border_width__set(self, value):
84
85 - def border_inner_color__set(self, color):
86 self.pause_icon.border_inner_color = color 87 self.play_icon.border_inner_color = color
88
89 - def border_outer_color__set(self, color):
90 self.pause_icon.border_outer_color = color 91 self.play_icon.border_outer_color = color
92 93 94 95 if __name__ == "__main__": 96 import os 97 import gobject 98 import gst 99 from pgm.timing import implicit 100 from pgm.graph.text import Text 101 102
103 - def on_key_press(viewport, event, widget):
104 # quit on q or ESC 105 if event.keyval in (pgm.keysyms.q, pgm.keysyms.Escape): 106 pgm.main_quit() 107 elif event.keyval == pgm.keysyms.t: 108 widget.play_icon.visible = not widget.play_icon.visible 109 widget.pause_icon.visible = not widget.pause_icon.visible
110
111 - def on_delete(viewport, event):
112 pgm.main_quit()
113 114 # OpenGL viewport creation 115 factory = pgm.ViewportFactory('opengl') 116 gl = factory.create() 117 gl.title = 'Context bar widget' 118 119 # Canvas and image drawable creation 120 canvas = pgm.Canvas() 121 122 # Bind the canvas to the OpenGL viewport 123 gl.set_canvas(canvas) 124 gl.show() 125 126 player = MiniPlayer() 127 #context.icon = "../poblenou_frontend/tango_theme/music.png" 128 player.canvas = canvas 129 player.position = (0.0, 0.0, 0.0) 130 player.width = canvas.width / 20. 131 player.height = 0.2 132 player.visible = True 133 134 #player.background = "theme/context_bar_bg.png" 135 player.play_icon = "theme/mini_player_play.png" 136 player.pause_icon = "theme/mini_player_pause.png" 137 138 player.play_icon.visible = True 139 player.pause_icon.visible = False 140 141 # Let's start a mainloop 142 gl.connect('key-press-event', on_key_press, player) 143 gl.connect('delete-event', on_delete) 144 pgm.main() 145