예제 #1
0
    def draw(self, num=None, mode="ratingweek", page=1, tag="all"):
        # Checking if next / prev page are available
        self.check_next_possible(page, num)
        self.check_prev_possible(page)
        # Got to be fixed: Setting CBs in History- Mode
        # causes "changed" event, which destroys the
        # current history- session
        # Switched off HistoryForward- Deletion,
        # as this seems to be the smaller issue
        self.pyjama.layouts.toolbars['top'].cbOrder.set_item(mode)
        show_tag = tag
        if tag == "all": show_tag = _("--all--")
        if not tag in self.pyjama.layouts.toolbars['top'].cbTags.modelist and tag != "all": 
            self.pyjama.layouts.toolbars['top'].cbTags.entry.set_text(tag.replace("+", " "))
        else:
            self.pyjama.layouts.toolbars['top'].cbTags.set_item(show_tag)            
        self.pyjama.layouts.toolbars['top'].cbResultsPerPage.set_item(num)
        # Setting the label
        if tag == "all":
#            markup = self.pyjama.window.markuplbCaption.replace("TEXT", _("Show top %i albums in '%s'") % (int(num), mode))
            txt = _("Showing top %i albums in '%s'") % (int(num), mode)
            self.pyjama.layouts.toolbars['top'].lCurPage.set_text(_("Page %i of %i") % (page, (self.pyjama.db.albums // num)))
        else:
#            markup = self.pyjama.window.markuplbCaption.replace("TEXT", _("Show %i albums tagged '%s' ordered by '%s'") % (int(num), tag.replace("+", " "), mode))
            txt = _("Showing %i albums tagged '%s' ordered by '%s'") % (int(num), tag.replace("+", " "), mode)
            self.pyjama.layouts.toolbars['top'].lCurPage.set_text(_("Page %i") % page)

        self.cur_page = page
#        self.pyjama.window.lbCaption.set_markup(markup)
        self.pyjama.window.LayoutInfo.set_text(txt)
        self.pyjama.window.LayoutInfo.set_image("folder_06.png")

        if num==None:num=self.results_per_page
        for albuminfo in self.albuminfos:
            self.albuminfos[albuminfo].destroy()
        
        self.albuminfos = {}

        top = self.pyjama.jamendo.top(num, mode, page, tag)
        if top == None:
            clWidgets.tofast(self.pyjama.window)
            return None
        elif top == -1:
            return None
        ## Again:
        ## 2 loops in order to
        ## first burst download
        ## and then create AlbumInfo
        counter = 0
        threads = {}
#        hidden = []
#        shown = []

        for album in top:
#            if "+" in tag:
#                count = tag.count("+")+1
#                if top.count(album) != count:
#                    hidden.append(album)
#                    continue
            if self.pyjama.debug:
                print "(%i/%i)" % (counter + 1, len(top))
            # if more than 10 threads...
            if clThreadedDownload.threadLimiter(threads):
                print ("Waiting for threads (%i seconds)") % self.pyjama.settings.get_value("PERFORMANCE", "THREAD_WAIT")
                sleep(self.pyjama.settings.get_value("PERFORMANCE", "THREAD_WAIT"))
#           album['album_image']
            threads[counter] = clThreadedDownload.Download(self.pyjama, ("album", album['album_id']), counter)
            threads[counter].start()
            counter += 1
        counter = 0
                
        for album in top:
#            if not album in hidden and not album in shown:
#                shown.append(album)
            self.albuminfos[counter] = clWidgets.AlbumInfo(self.pyjama, album)
            self.albuminfos[counter].show()
            self.put(self.albuminfos[counter], counter, counter)
            counter += 1

        self.arrange_topoftheweek()

        self.show()
        self.pyjama.window.toolbar.lbMoreAlbumsFromThisArtist2.hide()
        self.pyjama.window.toolbar.lbArtistsAlbumsToPlaylist.hide()
        self.pyjama.window.toolbar.lbAppendAlbum.hide()
        self.pyjama.window.toolbar.Separator2.hide()
예제 #2
0
    def draw(self, num=None, mode="data", page=1, tag="all"):
#    def draw(self, data, data2, data3, data4):
#        num=data['num'], mode = data['mode'], page = data['page'], tag=data['tag']
        ids = self.pyjama.settings.get_value("STAR PLUGIN", "STARED ALBUMS", -1)
        if ids == -1: ids = 0
        # Checking if next / prev page are available
        self.check_next_possible(page, num)
        self.check_prev_possible(page)
        # Got to be fixed: Setting CBs in History- Mode
        # causes "changed" event, which destroys the
        # current history- session
        # Switched off HistoryForwart- Deletion,
        # as this seems to be the smaller issue
        self.pyjama.layouts.toolbars['star'].cbOrder.set_item(mode)
        show_tag = tag
        if tag == "all": show_tag = _("--all--")
        if not tag in self.pyjama.layouts.toolbars['star'].cbTags.modelist and tag != "all": 
            self.pyjama.layouts.toolbars['star'].cbTags.entry.set_text(tag.replace("+", " "))
        else:
            self.pyjama.layouts.toolbars['star'].cbTags.set_item(show_tag)            
        self.pyjama.layouts.toolbars['star'].cbResultsPerPage.set_item(num)
        # Setting the label
        if tag == "all":
            ids = self.pyjama.settings.get_value("STAR PLUGIN", "STARED ALBUMS", -1)
            if ids == -1:
                count = 0
            else:
                count = ids.count("+")*1.0
#            markup = self.pyjama.window.markuplbCaption.replace("TEXT", _("Show %i stared albums in '%s'") % (int(num), mode))
            txt = _("Show %i stared albums in '%s'") % (int(num), mode)
            self.pyjama.layouts.toolbars['star'].lCurPage.set_text(_("Page %i of %i") % (page, ceil(count/num)))
        else:
#            markup = self.pyjama.window.markuplbCaption.replace("TEXT", _("Show %i stared albums tagged '%s' ordered by '%s'") % (int(num), tag, mode))
            txt = _("Show %i stared albums tagged '%s' ordered by '%s'") % (int(num), tag, mode)
            self.pyjama.layouts.toolbars['star'].lCurPage.set_text(_("Page %i") % page)

        self.cur_page = page
#        self.pyjama.window.lbCaption.set_markup(markup)
        self.pyjama.window.LayoutInfo.set_text(txt)
        self.pyjama.window.LayoutInfo.set_image(os.path.join(functions.install_dir(), "images", "star.png"))

        if ids == 0 or ids == "": return

        if num==None:num=self.results_per_page
        for albuminfo in self.albuminfos:
            self.albuminfos[albuminfo].destroy()
        
        self.albuminfos = {}
        

        top = self.top(ids, num, mode, page, tag)
        if top == None:
            clWidgets.tofast(self.pyjama.window)
            return None
        elif top == -1:
            return None
        ## Again:
        ## 2 loops in order to
        ## first burst download
        ## and then create AlbumInfo
        counter = 0
        threads = {}
        for album in top:
            if self.pyjama.debug:
                print "(%i/%i)" % (counter + 1, len(top))
            # if more than 10 threads...
            if clThreadedDownload.threadLimiter(threads):
                print ("Waiting for threads (%i seconds)") % self.pyjama.settings.get_value("PERFORMANCE", "THREAD_WAIT")
                sleep(self.pyjama.settings.get_value("PERFORMANCE", "THREAD_WAIT"))
            threads[counter] = clThreadedDownload.Download(self.pyjama, album['album_image'], counter)
            threads[counter].start()
            counter += 1
        counter = 0
        for album in top:
            self.albuminfos[counter] = clWidgets.AlbumInfo(self.pyjama, album)
            self.albuminfos[counter].show()
            self.put(self.albuminfos[counter], counter, counter)
            counter += 1

        self.arrange_topoftheweek()
        self.show()