def __init__(self, library, player=None, update=False): super(SongList, self).__init__() self._register_instance(SongList) self.set_model(PlaylistModel()) self.set_size_request(200, 150) self.set_rules_hint(True) self.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.set_fixed_height_mode(True) self.__csig = self.connect('columns-changed', self.__columns_changed) self.set_column_headers(self.headers) librarian = library.librarian or library sigs = [] # The player needs to be called first so it can ge the next song # in case the current one gets deleted and the order gets reset. if player: s = librarian.connect_object('removed', map, player.remove) sigs.append(s) sigs.extend([librarian.connect('changed', self.__song_updated), librarian.connect('removed', self.__song_removed)]) if update: sigs.append(librarian.connect('added', self.__song_added)) for sig in sigs: self.connect_object('destroy', librarian.disconnect, sig) if player: sigs = [player.connect('paused', self.__redraw_current), player.connect('unpaused', self.__redraw_current)] for sig in sigs: self.connect_object('destroy', player.disconnect, sig) self.connect('button-press-event', self.__button_press, librarian) self.connect('key-press-event', self.__key_press, librarian) self.disable_drop() self.connect('drag-motion', self.__drag_motion) self.connect('drag-leave', self.__drag_leave) self.connect('drag-data-get', self.__drag_data_get) self.connect('drag-data-received', self.__drag_data_received, library) self.set_search_equal_func(self.__search_func) self.accelerators = gtk.AccelGroup() key, mod = gtk.accelerator_parse("<alt>Return") self.accelerators.connect_group( key, mod, 0, lambda *args: self.__song_properties(librarian)) key, mod = gtk.accelerator_parse("<control>I") self.accelerators.connect_group( key, mod, 0, lambda *args: self.__information(librarian)) self.connect('destroy', self.__destroy)
def __init__(self, parent, player, library): super(TopBar, self).__init__(spacing=3) # play controls t = PlayControls(player, library.librarian) self.volume = t.volume self.pack_start(t, expand=False, fill=False) # song text text = SongInfo(library.librarian, player) self.pack_start(Alignment(text, border=3)) # cover image self.image = CoverImage(resize=True) player.connect('song-started', lambda x, s: self.image.set_song(s)) parent.connect('artwork-changed', self.__song_art_changed, library) self.pack_start(self.image, expand=False)
def __init__(self, player, library): try: self.library = library bus = dbus.SessionBus() name = dbus.service.BusName('net.sacredchao.QuodLibet', bus=bus) path = '/net/sacredchao/QuodLibet' super(DBusHandler, self).__init__(name, path) except DBusException: pass else: player.connect('song-started', self.__song_started) player.connect('song-ended', self.__song_ended) player.connect('paused', lambda player: self.Paused()) player.connect('unpaused', lambda player: self.Unpaused())