gloss-mc/SplashScr.py

101 lines
3.3 KiB
Python
Raw Normal View History

import pygtk
import gtk
import pygst
import gst
import gobject
import pango
import clutter
from Spinner import Spinner
2008-02-15 02:48:03 -08:00
class SplashScr(clutter.Group):
font = "Lucida Grande "
message_font_size = 30
detail_font_size = 22
def __init__(self, stage):
2008-02-15 02:48:03 -08:00
clutter.Group.__init__ (self)
self.stage = stage
self.backdrop = clutter.Rectangle()
self.backdrop.set_color(clutter.color_parse('Black'))
self.backdrop.set_width(self.stage.get_width())
self.backdrop.set_height(self.stage.get_height())
2008-02-15 02:48:03 -08:00
self.add(self.backdrop)
self.centre_group = clutter.Group()
self.add(self.centre_group)
pixbuf = gtk.gdk.pixbuf_new_from_file("ui/splash_box.png")
self.box = clutter.Texture()
self.box.set_pixbuf(pixbuf)
self.box.set_opacity(int(255 * 0.75))
self.box.set_height(int(self.stage.get_height()* 0.15))
2008-02-15 02:48:03 -08:00
self.centre_group.add(self.box)
self.spinner = Spinner()
height = int(self.box.get_height() * 0.90)
height = height + (height % 2) # Make sure that the dimension is even
self.spinner.set_height(height)
self.spinner.set_width(height)
self.spinner.set_position(5, int(self.box.get_height() * 0.05 ) )
2008-02-15 02:48:03 -08:00
self.centre_group.add(self.spinner)
self.message = clutter.Label()
self.message.set_font_name(self.font + str(self.message_font_size))
self.message.set_color(clutter.color_parse('White'))
pos_x = self.spinner.get_x()
pos_x = pos_x + int (self.spinner.get_width() * 1.1)
self.message.set_position(pos_x, 0)
2007-11-13 05:15:47 -08:00
self.message.set_text("Loading...")
2008-02-15 02:48:03 -08:00
self.centre_group.add(self.message)
self.detail = clutter.Label()
self.detail.set_font_name(self.font + str(self.detail_font_size))
self.detail.set_color(clutter.color_parse('White'))
2008-02-15 02:48:03 -08:00
self.centre_group.add(self.detail)
def display(self):
2008-02-15 02:48:03 -08:00
self.stage.add(self)
self.backdrop.show()
2008-02-15 02:48:03 -08:00
group_x = (self.stage.get_width()/2) - (self.box.get_width()/2)
group_y = (self.stage.get_height()/2) - (self.box.get_height()/2)
self.centre_group.set_position(group_x, group_y)
self.centre_group.show_all()
self.centre_group.show()
self.show()
self.spinner.start()
def display_elegant(self):
self.set_opacity(0)
self.stage.add(self)
self.show_all()
group_x = (self.stage.get_width()/2) - (self.box.get_width()/2)
group_y = (self.stage.get_height()/2) - (self.box.get_height()/2)
2008-02-15 02:48:03 -08:00
self.centre_group.set_position(group_x, group_y)
self.show()
2008-02-15 02:48:03 -08:00
timeline_opacity = clutter.Timeline(20, 25)
alpha_opacity = clutter.Alpha(timeline_opacity, clutter.ramp_inc_func)
self.behaviour_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha_opacity)
self.behaviour_opacity.apply(self)
timeline_opacity.start()
self.spinner.start()
def remove(self):
2008-02-15 02:48:03 -08:00
self.stage.remove(self)
2007-11-13 05:15:47 -08:00
self.spinner.stop()
def set_msg(self, msg):
self.message.set_text(msg)
def set_details(self, detail):
self.detail.set_test(detail)