Exemple #1
0
    def set_track_playing(self, iter, playing):
        if not iter:
            return
        track = self.tree.getTrack(iter)
        if not track:
            return

        for parent in self.tree.get_all_parents(iter):
            parent_label = self.tree.getLabel(parent)
            parent_label = tools.htmlUnescape(parent_label)
            is_bold = parent_label.startswith('<b>') and parent_label.endswith('</b>')
            if playing and not is_bold:
                parent_label = tools.htmlEscape(parent_label)
                self.tree.setLabel(parent, '<b>%s</b>' % parent_label)
            elif not playing and is_bold:
                parent_label = tools.htmlEscape(parent_label[3:-4])
                self.tree.setLabel(parent, parent_label)

        parent = self.tree.store.iter_parent(iter)
        parent_label = self.tree.getLabel(parent) if parent else None
        label = track.get_label(parent_label=parent_label, playing=playing)
        if playing:
            self.tree.setLabel(iter, label)
            self.tree.setItem(iter, ROW_ICO, icons.playMenuIcon())
            self.tree.expand(iter)
        else:
            self.tree.setLabel(iter, label)
            icon = self.tree.getItem(iter, ROW_ICO)
            has_error = (icon == icons.errorMenuIcon())
            is_dir = (icon == icons.mediaDirMenuIcon())
            if not is_dir and not has_error:
                self.tree.setItem(iter, ROW_ICO, icons.nullMenuIcon())
Exemple #2
0
    def set_track_playing(self, iter, playing):
        if not iter:
            return
        track = self.tree.getTrack(iter)
        if not track:
            return

        for parent in self.tree.get_all_parents(iter):
            parent_label = self.tree.getLabel(parent)
            parent_label = tools.htmlUnescape(parent_label)
            is_bold = parent_label.startswith('<b>') and parent_label.endswith('</b>')
            if playing and not is_bold:
                parent_label = tools.htmlEscape(parent_label)
                self.tree.setLabel(parent, '<b>%s</b>' % parent_label)
            elif not playing and is_bold:
                parent_label = tools.htmlEscape(parent_label[3:-4])
                self.tree.setLabel(parent, parent_label)

        parent = self.tree.store.iter_parent(iter)
        parent_label = self.tree.getLabel(parent) if parent else None
        label = track.get_label(parent_label=parent_label, playing=playing)
        if playing:
            self.tree.setLabel(iter, label)
            self.tree.setItem(iter, ROW_ICO, icons.playMenuIcon())
            self.tree.expand(iter)
        else:
            self.tree.setLabel(iter, label)
            icon = self.tree.getItem(iter, ROW_ICO)
            has_error = (icon == icons.errorMenuIcon())
            is_dir = (icon == icons.mediaDirMenuIcon())
            if not is_dir and not has_error:
                self.tree.setItem(iter, ROW_ICO, icons.nullMenuIcon())
    def jumpTo(self, trackIdx, sendPlayMsg = True, forced = True):
        """ Jump to the track located at the given index """
        if self.list.hasMark() and self.list.getItem(self.list.getMark(), ROW_ICO) != icons.errorMenuIcon():
            self.list.setItem(self.list.getMark(), ROW_ICO, icons.nullMenuIcon())
        self.list.setMark(trackIdx)
        self.list.scroll_to_cell(trackIdx)
        self.list.setItem(trackIdx, ROW_ICO, icons.playMenuIcon())

        if sendPlayMsg:
            modules.postMsg(consts.MSG_CMD_PLAY, {'uri': self.list.getItem(trackIdx, ROW_TRK).getURI(), 'forced': forced})

        modules.postMsg(consts.MSG_EVT_NEW_TRACK,   {'track': self.list.getRow(trackIdx)[ROW_TRK]})
        modules.postMsg(consts.MSG_EVT_TRACK_MOVED, {'hasPrevious': self.__hasPreviousTrack(), 'hasNext': self.__hasNextTrack()})
Exemple #4
0
 def onUnPaused(self):
     self.paused = False
     self.onPausedToggled(icons.playMenuIcon())
Exemple #5
0
 def onUnPaused(self):
     self.paused = False
     self.onPausedToggled(icons.playMenuIcon())
    def __init__(self):
        """ Constructor """
        handlers = {
                        consts.MSG_CMD_NEXT:                 self.jumpToNext,
                        consts.MSG_EVT_PAUSED:               lambda: self.onPausedToggled(icons.pauseMenuIcon()),
                        consts.MSG_EVT_STOPPED:              self.onStopped,
                        consts.MSG_EVT_UNPAUSED:             lambda: self.onPausedToggled(icons.playMenuIcon()),
                        consts.MSG_CMD_PREVIOUS:             self.jumpToPrevious,
                        consts.MSG_EVT_NEED_BUFFER:          self.onBufferingNeeded,
                        consts.MSG_EVT_APP_STARTED:          self.onAppStarted,
                        consts.MSG_CMD_TOGGLE_PAUSE:         self.togglePause,
                        consts.MSG_CMD_TRACKLIST_DEL:        self.remove,
                        consts.MSG_CMD_TRACKLIST_ADD:        self.insert,
                        consts.MSG_CMD_TRACKLIST_SET:        self.set,
                        consts.MSG_CMD_TRACKLIST_CLR:        lambda: self.set(None, False, False),
                        consts.MSG_CMD_TRACKLIST_PLAY:       self.onTracklistPlay,
                        consts.MSG_EVT_TRACK_ENDED_OK:       lambda: self.onTrackEnded(False),
                        consts.MSG_CMD_TRACKLIST_REPEAT:     self.setRepeat,
                        consts.MSG_EVT_TRACK_ENDED_ERROR:    lambda: self.onTrackEnded(True),
                        consts.MSG_CMD_TRACKLIST_SHUFFLE:    self.shuffleTracklist,
                        consts.MSG_CMD_TRACKLIST_PLAY_PAUSE: self.onTracklistPlayPause,
                   }

        modules.Module.__init__(self, handlers)