示例#1
0
    def current_update(self, prevstatus_playlist, new_playlist_length):
        if self.connected():
            self.view.freeze_child_notify()
            self.unbold_boldrow(self.prev_boldrow)

            if not self.update_skip:
                save_model = self.view.get_model()
                self.view.set_model(None)
                if prevstatus_playlist:
                    changed_songs = self.mpd.plchanges(prevstatus_playlist)
                else:
                    changed_songs = self.mpd.plchanges(0)


                newlen = int(new_playlist_length)
                currlen = len(self.store)

                for track in changed_songs:
                    pos = track.pos

                    items = [formatting.parse(part, track, True)
                             for part in self.columnformat]

                    if pos < currlen:
                        # Update attributes for item:
                        i = self.store.get_iter((pos, ))
                        if track.id != self.store.get_value(i, 0).id:
                            self.store.set_value(i, 0, track)
                        for index in range(len(items)):
                            if items[index] != self.store.get_value(i, index+1):
                                self.store.set_value(i, index + 1, items[index])
                    else:
                        # Add new item:
                        self.store.append(
                            [track] + items + [Pango.Weight.NORMAL])

                if newlen == 0:
                    self.store.clear()
                else:
                    # Remove excess songs:
                    for i in range(currlen - newlen):
                        it = self.store.get_iter((currlen - 1 - i,))
                        self.store.remove(it)

                self.view.set_model(save_model)
            self.update_skip = False

            # Update statusbar time:
            self.total_time = sum(item[0].time for item in self.store)

            if 'pos' in self.songinfo():
                currsong = self.songinfo().pos
                self.boldrow(currsong)
                self.prev_boldrow = currsong

            self.view.thaw_child_notify()
            self.header_update_column_indicators()
            self.update_statusbar()
            ui.change_cursor(None)
示例#2
0
    def update_format(self, tracks):
        for i, track in enumerate(tracks):
            items = [formatting.parse(part, track, True)
                     for part in self.columnformat]

            if self.songinfo().pos == i:
                weight = [Pango.Weight.BOLD]
            else:
                weight = [Pango.Weight.NORMAL]

            self.store.append([track] + items + weight)
示例#3
0
    def update_format(self, tracks):
        for i, track in enumerate(tracks):
            items = [
                formatting.parse(part, track, True)
                for part in self.columnformat
            ]

            if self.songinfo().pos == i:
                weight = [Pango.Weight.BOLD]
            else:
                weight = [Pango.Weight.NORMAL]

            self.store.append([track] + items + weight)
示例#4
0
    def update_format(self):
        position = self.current.get_visible_rect()

        for i, track in enumerate(self.current_songs):
            items = [formatting.parse(part, track, True)
                     for part in self.columnformat]

            if mpdh.get(self.songinfo(), 'pos', 0, True) == i:
                weight = [Pango.Weight.BOLD]
            else:
                weight = [Pango.Weight.NORMAL]

            self.currentdata.append([track.id] + items + weight)

        self.playlist_retain_view(self.current, position.y)
示例#5
0
    def current_update(self, prevstatus_playlist, new_playlist_length):
        if self.connected():

            if self.sonata_loaded():
                playlistposition = self.current.get_visible_rect().height

            self.current.freeze_child_notify()

            if not self.current_update_skip:

                if not self.filterbox_visible:
                    self.current.set_model(None)

                if prevstatus_playlist:
                    changed_songs = self.mpd.plchanges(prevstatus_playlist)
                else:
                    changed_songs = self.mpd.plchanges(0)
                    self.current_songs = []

                newlen = int(new_playlist_length)
                currlen = len(self.currentdata)

                for track in changed_songs:
                    pos = track.pos

                    items = [formatting.parse(part, track,
                                  True)
                         for part in self.columnformat]

                    if pos < currlen:
                        # Update attributes for item:
                        i = self.currentdata.get_iter((pos, ))
                        if track.id != self.currentdata.get_value(i, 0):
                            self.currentdata.set_value(i, 0, track.id)
                        for index in range(len(items)):
                            if items[index] != self.currentdata.get_value(i,
                                                                    index + 1):
                                self.currentdata.set_value(i, index + 1,
                                                           items[index])
                        self.current_songs[pos] = track
                    else:
                        # Add new item:
                        self.currentdata.append([track.id] + items +
                                                [Pango.Weight.NORMAL])
                        self.current_songs.append(track)

                if newlen == 0:
                    self.currentdata.clear()
                    self.current_songs = []
                else:
                    # Remove excess songs:
                    for i in range(currlen - newlen):
                        it = self.currentdata.get_iter((currlen - 1 - i,))
                        self.currentdata.remove(it)
                    self.current_songs = self.current_songs[:newlen]

                if not self.filterbox_visible:
                    self.current.set_model(self.currentdata)

            self.current_update_skip = False

            # Update statusbar time:
            self.total_time = sum(t.time for t in self.current_songs)

            if 'pos' in self.songinfo():
                currsong = self.songinfo().pos
                self.boldrow(currsong)
                self.prev_boldrow = currsong

            if self.filterbox_visible:
                # Refresh filtered results:
                # Hacky, but this ensures we retain the
                # self.current position/selection
                self.prevtodo = "RETAIN_POS_AND_SEL"
                self.plpos = playlistposition
                self.searchfilter_feed_loop(self.filterpattern)
            elif self.sonata_loaded():
                self.playlist_retain_view(self.current, playlistposition)
                self.current.thaw_child_notify()

            self.header_update_column_indicators()
            self.update_statusbar()
            ui.change_cursor(None)
示例#6
0
    def current_update(self, prevstatus_playlist, new_playlist_length):
        if self.connected():
            self.view.freeze_child_notify()
            self.unbold_boldrow(self.prev_boldrow)

            if not self.update_skip:
                save_model = self.view.get_model()
                self.view.set_model(None)
                if prevstatus_playlist:
                    changed_songs = self.mpd.plchanges(prevstatus_playlist)
                else:
                    changed_songs = self.mpd.plchanges(0)

                newlen = int(new_playlist_length)
                currlen = len(self.store)

                for track in changed_songs:
                    pos = track.pos

                    items = [
                        formatting.parse(part, track, True)
                        for part in self.columnformat
                    ]

                    if pos < currlen:
                        # Update attributes for item:
                        i = self.store.get_iter((pos, ))
                        if track.id != self.store.get_value(i, 0).id:
                            self.store.set_value(i, 0, track)
                        for index in range(len(items)):
                            if items[index] != self.store.get_value(
                                    i, index + 1):
                                self.store.set_value(i, index + 1,
                                                     items[index])
                    else:
                        # Add new item:
                        self.store.append([track] + items +
                                          [Pango.Weight.NORMAL])

                if newlen == 0:
                    self.store.clear()
                else:
                    # Remove excess songs:
                    for i in range(currlen - newlen):
                        it = self.store.get_iter((currlen - 1 - i, ))
                        self.store.remove(it)

                self.view.set_model(save_model)
            self.update_skip = False

            # Update statusbar time:
            self.total_time = sum(item[0].time for item in self.store)

            if 'pos' in self.songinfo():
                currsong = self.songinfo().pos
                self.boldrow(currsong)
                self.prev_boldrow = currsong

            self.view.thaw_child_notify()
            self.header_update_column_indicators()
            self.update_statusbar()
            ui.change_cursor(None)