2
#Includes the class for status label.
7
class FadeLabel(gtk.Label):
8
""" GTK Label with timed fade out effect """
10
active_duration = 3000 # Fade start after this time
11
fade_duration = 1500.0 # Fade duration
13
def __init__(self, message='', active_color=None, inactive_color=None):
14
gtk.Label.__init__(self, message)
16
active_color = '#ffffff'
17
self.active_color = active_color
18
if not inactive_color:
19
inactive_color = '#000000'
20
self.inactive_color = inactive_color
23
def set_text(self, message, duration=None):
25
duration = self.active_duration
26
self.modify_fg(gtk.STATE_NORMAL,
27
gtk.gdk.color_parse(self.active_color))
28
gtk.Label.set_text(self, message)
30
gobject.source_remove(self.idle)
31
self.idle = gobject.timeout_add(duration, self.fade_start)
36
gobject.source_remove(self.idle)
37
self.idle = gobject.timeout_add(25, self.fade_out)
40
color = gtk.gdk.color_parse(self.inactive_color)
41
(red1, green1, blue1) = (color.red, color.green, color.blue)
42
color = gtk.gdk.color_parse(self.active_color)
43
(red2, green2, blue2) = (color.red, color.green, color.blue)
44
red = red1 + int(self.fade_level * abs(red1 - red2))
45
green = green1 + int(self.fade_level * abs(green1 - green2))
46
blue = blue1 + int(self.fade_level * abs(blue1 - blue2))
47
self.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(red, green, blue))
48
self.fade_level -= 1.0 / (self.fade_duration / 25)
49
if self.fade_level > 0: