Exemplo n.º 1
0
    def append_artists(self, init=False):
        if init:
            self.artists_liststore.clear()
            self.artists_page = 0
            self.artists_win.get_vadjustment().set_value(0)
        selection = self.cate_treeview.get_selection()
        result = selection.get_selected()
        if result is None or len(result) != 2:
            return
        model, _iter = result
        pref_index = self.pref_combo.get_active()
        catid = model[_iter][1]
        prefix = self.pref_liststore[pref_index][1]
        # TODO: use async_call()
        artists, self.artists_total = Net.get_artists(catid, 
                self.artists_page, prefix)
        if self.artists_total == 0:
            return

        i = len(self.artists_liststore)
        for artist in artists:
            self.artists_liststore.append([self.app.theme['anonymous'],
                artist['name'], int(artist['id']), 
                artist['music_num'] + _(' songs'), ])
            Net.update_artist_logo(self.artists_liststore, i, 0, 
                    artist['pic'])
            i += 1
Exemplo n.º 2
0
    def append_artists(self, init=False):
        if init:
            self.artists_liststore.clear()
            self.artists_page = 0
            self.artists_win.get_vadjustment().set_value(0)
        selection = self.cate_treeview.get_selection()
        result = selection.get_selected()
        if result is None or len(result) != 2:
            return
        model, _iter = result
        pref_index = self.pref_combo.get_active()
        catid = model[_iter][1]
        prefix = self.pref_liststore[pref_index][1]
        # TODO: use async_call()
        artists, self.artists_total = Net.get_artists(catid, self.artists_page,
                                                      prefix)
        if self.artists_total == 0:
            return

        i = len(self.artists_liststore)
        for artist in artists:
            _info = ' '.join([
                artist['music_num'],
                _(' songs'),
            ])
            self.artists_liststore.append([
                self.app.theme['anonymous'],
                Widgets.unescape(artist['name']),
                int(artist['id']),
                _info,
                Widgets.set_tooltip(artist['name'], _info),
            ])
            Net.update_artist_logo(self.artists_liststore, i, 0, artist['pic'])
            i += 1