コード例 #1
0
ファイル: playlist.py プロジェクト: thammi/nymp
    def _actual_search(self, needle, start, end, step, cb):
        playlist = self.playlist
        xc = self.xc

        search_fields = get_config("search_fields")

        cur = start
        first = True

        # TODO: this loop is ugly
        while True:
            # the end?
            if cur == start and not first:
                # we cycled through
                cb(False)
                return

            # not the first anymore?
            first = False

            # check the playlist item
            item = playlist[cur]
            meta = item.meta

            if meta != None:
                # let's compare
                for key in search_fields:
                    if key in meta:
                        value = meta[key]

                        if isinstance(value, basestring) and needle.search(value):
                            # found one
                            self._focus = cur
                            self.modified()

                            update()

                            cb(True)
                            return
            else:
                # we have to request the meta information
                def request_cb(meta):
                    self._actual_search(needle, cur, end, step, cb)

                item.request(xc, request_cb)

                # prefetch next items
                pre = cur
                for i in range(self.PRE_CACHING):
                    pre = step(pre)

                    if pre != None:
                        playlist[pre].request(xc, None)
                    else:
                        break

                # the callback of the request will continue our work
                return

            cur = step(cur)
コード例 #2
0
ファイル: current.py プロジェクト: thammi/nymp
    def _update(self, meta):
        if meta:
            rm = reduce_meta(meta)
        else:
            rm = {}
 
        if 'title' in rm:
            if 'tracknr' in rm:
                # use title and track number
                title = "%i. %s" % (rm['tracknr'], rm['title']) 
            else:
                # use the title only
                title = rm['title']
        else:
            if 'url' in rm:
                # fall back to the url
                url = rm['url']
                title = url[url.rfind('/')+1:]
            elif rm == {}:
                # nothing loaded
                title = ""
            else:
                # tag your library :P
                title = "Unknown"

        album = rm['album'] if 'album' in rm else ""
        artist = rm['artist'] if 'artist' in rm else ""

        self.title.set_text(title)
        self.album.set_text(album)
        self.artist.set_text(artist)

        self.bar.set_done(rm['duration'] if 'duration' in rm else 0)
 
        update()
コード例 #3
0
ファイル: current.py プロジェクト: thammi/nymp
    def _progress(self, progress):
        # handle the progress
        self.bar.set_completion(progress)
        update()

        # request next signal later
        deferred_call(0.25, self.request_playtime_signal)

        # don't get next signal immediately
        return False
コード例 #4
0
ファイル: playlist.py プロジェクト: thammi/nymp
 def modified(self):
     self._modified()
     update()
コード例 #5
0
ファイル: status.py プロジェクト: thammi/nymp
 def withdraw(self, old_id):
     if old_id == self.msg_id:
         self.set_edit_text("")
         update()
コード例 #6
0
ファイル: status.py プロジェクト: thammi/nymp
    def flash(self, msg):
        self.msg_id += 1
        deferred_call(2, self.withdraw, self.msg_id)

        self.set_edit_text(msg)
        update()