示例#1
0
 def on_advice_menu_item_activated(self, advice_item):
     list_name = str(time.time())
     tooltip = Widgets.escape(self.playlist_advice_disname)
     self.liststore_left.append([self.playlist_advice_disname, list_name, True, tooltip])
     self.init_tab(list_name, [])
     advice_item.list_name = list_name
     self.on_menu_item_activated(advice_item)
示例#2
0
    def load_playlists(self):
        filepath = Config.PLS_JSON
        _default = {
                '_names_': [
                    [_('Caching'), 'Caching', False],
                    [_('Default'), 'Default', False],
                    [_('Favorite'), 'Favorite', False],
                    ],
                'Caching': [],
                'Default': [],
                'Favorite': [],
                }
        if os.path.exists(filepath):
            with open(filepath) as fh:
                playlists = json.loads(fh.read())
        else:
            playlists = _default

        for playlist in playlists['_names_']:
            disname, list_name, editable = playlist
            tooltip = Widgets.escape(disname)
            self.liststore_left.append(
                    [disname, list_name, editable, tooltip])
            songs = playlists[list_name]
            self.init_tab(list_name, songs)
示例#3
0
文件: Artists.py 项目: zihua/kwplayer
 def _append_artist_info(info, error=None):
     if error or not info:
         logger.error('appen_artist_info(): %s, %s' % (info, error))
         return
     if info.get('pic', None):
         self.artist_info_pic.set_from_file(info['pic'])
     self.artist_info_name.set(info, 'name')
     self.artist_info_birthday.set(info, 'birthday')
     self.artist_info_birthplace.set(info, 'birthplace')
     self.artist_info_height.set(info, 'tall')
     self.artist_info_weight.set(
         info,
         'weight',
     )
     self.artist_info_country.set(info, 'country')
     self.artist_info_language.set(info, 'language')
     self.artist_info_gender.set(
         info,
         'gender',
     )
     self.artist_info_constellation.set(info, 'constellation')
     if info and 'info' in info:
         if html2text_imported:
             self.artist_info_textbuffer.set_text(
                 html2text.html2text(info['info']))
         else:
             self.artist_info_textbuffer.set_text(
                 Widgets.escape(info['info']))
     else:
         self.artist_info_textbuffer.set_text('')
示例#4
0
    def load_playlists(self):
        filepath = Config.PLS_JSON
        _default = {
                '_names_': [
                    [_('Caching'), 'Caching', False],
                    [_('Default'), 'Default', False],
                    [_('Favorite'), 'Favorite', False],
                    ],
                'Caching': [],
                'Default': [],
                'Favorite': [],
                }
        if os.path.exists(filepath):
            with open(filepath) as fh:
                playlists = json.loads(fh.read())
        else:
            playlists = _default

        for playlist in playlists['_names_']:
            disname, list_name, editable = playlist
            tooltip = Widgets.escape(disname)
            self.liststore_left.append(
                    [disname, list_name, editable, tooltip])
            songs = playlists[list_name]
            self.init_tab(list_name, songs)
示例#5
0
 def _append_albums(albums_args, error=None):
     albums, hit, self.albums_total = albums_args
     if hit == 0:
         if reset_status:
             self.albums_button.set_label(
                     '{0} (0)'.format(_('Albums')))
         return
     self.albums_button.set_label(
             '{0} ({1})'.format(_('Albums'), hit))
     i = len(self.liststore_albums)
     for album in albums:
         if 'info' in album and album['info']:
             tooltip = Widgets.set_tooltip(album['name'], album['info'])
         else:
             tooltip = Widgets.escape(album['name'])
         self.liststore_albums.append([
             self.app.theme['anonymous'],
             Widgets.unescape(album['name']),
             int(album['albumid']), 
             Widgets.unescape(album['artist']),
             int(album['artistid']),
             tooltip,
             ])
         Net.update_album_covers(
                 self.liststore_albums, i, 0, album['pic'])
         i += 1
示例#6
0
 def on_advice_menu_item_activated(self, advice_item):
     list_name = str(time.time())
     tooltip = Widgets.escape(self.playlist_advice_disname)
     self.liststore_left.append(
             [self.playlist_advice_disname, list_name, True, tooltip])
     self.init_tab(list_name, [])
     advice_item.list_name = list_name
     self.on_menu_item_activated(advice_item)
示例#7
0
 def on_add_playlist_button_clicked(self, button):
     list_name = str(time.time())
     disname = _("Playlist")
     editable = True
     tooltip = Widgets.escape(disname)
     _iter = self.liststore_left.append([disname, list_name, editable, tooltip])
     selection = self.treeview_left.get_selection()
     selection.select_iter(_iter)
     self.init_tab(list_name, [])
示例#8
0
 def on_add_playlist_button_clicked(self, button):
     list_name = str(time.time())
     disname = _('Playlist')
     editable = True
     tooltip = Widgets.escape(disname)
     _iter = self.liststore_left.append(
         [disname, list_name, editable, tooltip])
     selection = self.treeview_left.get_selection()
     selection.select_iter(_iter)
     self.init_tab(list_name, [])
示例#9
0
 def _append_fav_artist(info, error=None):
     if error or not info:
         return
     if info.get('pic', None):
         pix = GdkPixbuf.Pixbuf.new_from_file_at_size(
                 info['pic'], 100, 100)
     else:
         pix = self.app.theme['anonymous']
     tip = Widgets.escape(info.get('info', ''))
     self.fav_artists_liststore.append(
             [pix, info['name'], artist_id, tip])
示例#10
0
 def _append_fav_artist(info, error=None):
     if error or not info:
         return
     if info.get('pic', None):
         pix = GdkPixbuf.Pixbuf.new_from_file_at_size(
             info['pic'], 100, 100)
     else:
         pix = self.app.theme['anonymous']
     tip = Widgets.escape(info.get('info', ''))
     self.fav_artists_liststore.append(
         [pix, info['name'], artist_id, tip])
示例#11
0
文件: Artists.py 项目: zihua/kwplayer
 def _append_fav_artist(info, error=None):
     if error or not info:
         logger.error('add_to_fav_artists(): %s, %s' % (info, error))
         return
     if info.get('pic', None):
         pix = GdkPixbuf.Pixbuf.new_from_file_at_size(
             info['pic'], 100, 100)
     else:
         pix = Config.ANONYMOUS_PIXBUF,
     tip = Widgets.escape(info.get('info', ''))
     self.fav_artists_liststore.append(
         [pix, info['name'], artist_id, tip])
示例#12
0
 def _append_fav_artist(info, error=None):
     if info and info['pic'] and len(info['pic']) > 0:
         pix = GdkPixbuf.Pixbuf.new_from_file_at_size(
             info['pic'], 100, 100)
     else:
         pix = self.app.theme['anonymous']
     if 'info' in info:
         tip = Widgets.escape(info['info'])
     else:
         tip = ''
     self.fav_artists_liststore.append(
         [pix, info['name'], artist_id, tip])
示例#13
0
 def _append_fav_artist(info, error=None):
     if error or not info:
         logger.error('add_to_fav_artists(): %s, %s' % (info, error))
         return
     if info.get('pic', None):
         pix = GdkPixbuf.Pixbuf.new_from_file_at_size(info['pic'],
                                                      100, 100)
     else:
         pix = Config.ANONYMOUS_PIXBUF,
     tip = Widgets.escape(info.get('info', ''))
     self.fav_artists_liststore.append([pix, info['name'],
                                        artist_id, tip])
示例#14
0
 def _append_fav_artist(info, error=None):
     if info and info['pic'] and len(info['pic']) > 0:
         pix = GdkPixbuf.Pixbuf.new_from_file_at_size(
                 info['pic'], 100, 100)
     else:
         pix = self.app.theme['anonymous']
     if 'info' in info:
         tip = Widgets.escape(info['info'])
     else:
         tip = ''
     self.fav_artists_liststore.append(
             [pix, info['name'], artist_id, tip])
示例#15
0
 def _append_artist_info(info, error=None):
     if info and info['pic'] and len(info['pic']) > 0:
         self.artist_info_pic.set_from_file(info['pic'])
     self.artist_info_name.set(info, 'name')
     self.artist_info_birthday.set(info, 'birthday')
     self.artist_info_birthplace.set(info, 'birthplace')
     self.artist_info_height.set(info, 'tall')
     self.artist_info_weight.set(info, 'weight',)
     self.artist_info_country.set(info, 'country')
     self.artist_info_language.set(info, 'language')
     self.artist_info_gender.set(info, 'gender',)
     self.artist_info_constellation.set(info, 'constellation')
     if info and 'info' in info:
         self.artist_info_textbuffer.set_text(
                 Widgets.escape(info['info']))
     else:
         self.artist_info_textbuffer.set_text('')
示例#16
0
        def _append_albums(albums_args, error=None):
            albums, hit, self.albums_total = albums_args
            if not error and albums and hit:
                urls, tree_iters = [], []
                for album in albums:
                    tooltip = Widgets.escape(album.get('info', album['name']))
                    tree_iter = self.liststore_albums.append([
                        self.app.theme['anonymous'],
                        Widgets.unescape(album['name']),
                        int(album['albumid']),
                        Widgets.unescape(album['artist']),
                        int(album['artistid']),
                        tooltip,
                    ])
                    tree_iters.append(tree_iter)
                    urls.append(album['pic'])
                Net.update_album_covers(self.liststore_albums, 0, tree_iters,
                                        urls)

            self.albums_button.set_label('{0} ({1})'.format(
                _('Albums'), len(self.liststore_albums)))
示例#17
0
        def _append_albums(albums_args, error=None):
            albums, hit, self.albums_total = albums_args
            if not error and albums and hit:
                urls,tree_iters = [], []
                for album in albums:
                    tooltip = Widgets.escape(album.get('info',
                                             album['name']))
                    tree_iter = self.liststore_albums.append([
                        self.app.theme['anonymous'],
                        Widgets.unescape(album['name']),
                        int(album['albumid']),
                        Widgets.unescape(album['artist']),
                        int(album['artistid']),
                        tooltip,
                        ])
                    tree_iters.append(tree_iter)
                    urls.append(album['pic'])
                Net.update_album_covers(self.liststore_albums, 0,
                                        tree_iters, urls)

            self.albums_button.set_label('{0} ({1})'.format(
                    _('Albums'), len(self.liststore_albums)))
示例#18
0
 def _append_artist_info(info, error=None):
     if info and info['pic'] and len(info['pic']) > 0:
         self.artist_info_pic.set_from_file(info['pic'])
     self.artist_info_name.set(info, 'name')
     self.artist_info_birthday.set(info, 'birthday')
     self.artist_info_birthplace.set(info, 'birthplace')
     self.artist_info_height.set(info, 'tall')
     self.artist_info_weight.set(
         info,
         'weight',
     )
     self.artist_info_country.set(info, 'country')
     self.artist_info_language.set(info, 'language')
     self.artist_info_gender.set(
         info,
         'gender',
     )
     self.artist_info_constellation.set(info, 'constellation')
     if info and 'info' in info:
         self.artist_info_textbuffer.set_text(
             Widgets.escape(info['info']))
     else:
         self.artist_info_textbuffer.set_text('')
示例#19
0
 def _append_artist_info(info, error=None):
     if error or not info:
         logger.error('appen_artist_info(): %s, %s' % (info, error))
         return
     if info.get('pic', None):
         self.artist_info_pic.set_from_file(info['pic'])
     self.artist_info_name.set(info, 'name')
     self.artist_info_birthday.set(info, 'birthday')
     self.artist_info_birthplace.set(info, 'birthplace')
     self.artist_info_height.set(info, 'tall')
     self.artist_info_weight.set(info, 'weight',)
     self.artist_info_country.set(info, 'country')
     self.artist_info_language.set(info, 'language')
     self.artist_info_gender.set(info, 'gender',)
     self.artist_info_constellation.set(info, 'constellation')
     if info and 'info' in info:
         if html2text_imported:
             self.artist_info_textbuffer.set_text(
                     html2text.html2text(info['info']))
         else:
             self.artist_info_textbuffer.set_text(
                     Widgets.escape(info['info']))
     else:
         self.artist_info_textbuffer.set_text('')
示例#20
0
        def _append_albums(albums_args, error=None):
            albums, hit, self.albums_total = albums_args
            if not error and albums and hit:
                urls,tree_iters = [], []
                for album in albums:
                    tooltip = Widgets.escape(album.get('info',
                                             album['name']))
                    tree_iter = self.liststore_albums.append([
                        Config.ANONYMOUS_PIXBUF,
                        Widgets.unescape(album['name']),
                        int(album['albumid']),
                        Widgets.unescape(album['artist']),
                        int(album['artistid']),
                        tooltip,
                    ])
                    tree_iters.append(tree_iter)
                    urls.append(album['pic'])
                Net.async_call(Net.update_album_covers, self.liststore_albums,
                               0, tree_iters, urls)
            else:
                logger.error('show_albums: %s, %s' % (self.albums_total, error))

            self.albums_button.set_label('{0} ({1})'.format(_('Albums'),
                                         len(self.liststore_albums)))
示例#21
0
    def load_playlists(self):
        filepath = Config.PLS_JSON
        _default = {
            "_names_": [
                [_("Caching"), "Caching", False],
                [_("Default"), "Default", False],
                [_("Favorite"), "Favorite", False],
            ],
            "Caching": [],
            "Default": [],
            "Favorite": [],
        }
        if os.path.exists(filepath):
            with open(filepath) as fh:
                playlists = json.loads(fh.read())
        else:
            playlists = _default

        for playlist in playlists["_names_"]:
            disname, list_name, editable = playlist
            tooltip = Widgets.escape(disname)
            self.liststore_left.append([disname, list_name, editable, tooltip])
            songs = playlists[list_name]
            self.init_tab(list_name, songs)
示例#22
0
 def _append_albums(albums_args, error=None):
     albums, hit, self.albums_total = albums_args
     if hit == 0:
         if reset_status:
             self.albums_button.set_label(
                     '{0} (0)'.format(_('Albums')))
         return
     self.albums_button.set_label(
             '{0} ({1})'.format(_('Albums'), hit))
     for i, album in enumerate(albums):
         if 'info' in album and album['info']:
             tooltip = Widgets.set_tooltip(album['name'], album['info'])
         else:
             tooltip = Widgets.escape(album['name'])
         self.liststore_albums.append([
             self.app.theme['anonymous'],
             Widgets.unescape(album['name']),
             int(album['albumid']), 
             Widgets.unescape(album['artist']),
             int(album['artistid']),
             tooltip,
             ])
         Net.update_album_covers(
                 self.liststore_albums, i, 0, album['pic'])