def __init__(self): super(Footer, self).__init__(clutter.BoxLayout()) self.set_color(clutter.Color(0, 0, 0, 0)) layout = self.get_layout_manager() layout.set_vertical(True) layout.set_spacing(20) self.set_width(settings.SCREEN_WIDTH) self.now_playing = now_playing() self.now_playing_box = clutter.Box(clutter.BoxLayout()) tmplayout = self.now_playing_box.get_layout_manager() tmplayout.set_vertical(False) tmplayout.set_spacing(20) self.now_playing_box.set_width(settings.SCREEN_WIDTH) self.next_song_box = clutter.Box(clutter.BoxLayout()) tmplayout = self.next_song_box.get_layout_manager() tmplayout.set_vertical(False) tmplayout.set_spacing(20) self.next_song_box.set_width(settings.SCREEN_WIDTH) layout.pack(self.now_playing_box, True, False, False, clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER) layout.pack(self.next_song_box, True, False, False, clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER)
def display(self): if is_now_playing(): self.set_color(clutter.Color(0, 0, 0, 250)) self.set_opacity(250) # Remove existing text. for actor in self.now_playing_box.get_children(): self.now_playing_box.remove(actor) song = now_playing() text = clutter.Text(settings.FOOTER_FONT, 'Now playing:') text.set_color(clutter.Color(200, 200, 200)) self.now_playing_box.add(text) text = clutter.Text(settings.FOOTER_SONG_FONT, song) text.set_color(clutter.Color(240, 240, 40)) self.now_playing_box.add(text) try: text = clutter.Text(settings.FOOTER_ARTIST_FONT, "by %s" % song.artist) text.set_color(clutter.Color(240, 240, 40)) self.now_playing_box.add(text) except Exception: pass if has_next_song(): song = next_song() # Remove existing text. for actor in self.next_song_box.get_children(): self.next_song_box.remove(actor) text = clutter.Text(settings.FOOTER_FONT, 'Next song:') text.set_color(clutter.Color(200, 200, 200)) self.next_song_box.add(text) text = clutter.Text(settings.FOOTER_SONG_FONT, song) text.set_color(clutter.Color(240, 240, 40)) self.next_song_box.add(text) try: text = clutter.Text(settings.FOOTER_ARTIST_FONT, "by %s" % song.artist) text.set_color(clutter.Color(240, 240, 40)) self.next_song_box.add(text) except Exception: pass self.animation = self.animate(clutter.EASE_IN_CUBIC, settings.FOOTER_FADE_RATE, 'opacity', 0)
def update(self): if is_now_playing() and self.now_playing != now_playing(): self.display() self.now_playing = now_playing()