コード例 #1
0
    def first(self):
        app = self.app

        self.buttonbox = Gtk.Box(spacing=5)
        self.pack_start(self.buttonbox, False, False, 0)
        button_home = Gtk.Button(_('TopList'))
        button_home.connect('clicked', self.on_button_home_clicked)
        self.buttonbox.pack_start(button_home, False, False, 0)
        self.label = Gtk.Label('')
        self.buttonbox.pack_start(self.label, False, False, 0)

        # checked, name, artist, album, rid, artistid, albumid
        self.liststore_songs = Gtk.ListStore(bool, str, str, str, int, int,
                                             int)
        control_box = Widgets.ControlBox(self.liststore_songs, app)
        self.buttonbox.pack_end(control_box, False, False, 0)

        self.scrolled_nodes = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_nodes, True, True, 0)
        # logo, name, nid, info, tooltip
        self.liststore_nodes = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                             str)
        iconview_nodes = Widgets.IconView(self.liststore_nodes, tooltip=4)
        iconview_nodes.connect('item_activated',
                               self.on_iconview_nodes_item_activated)
        self.scrolled_nodes.add(iconview_nodes)

        self.scrolled_songs = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_songs, True, True, 0)
        treeview_songs = Widgets.TreeViewSongs(self.liststore_songs, app)
        self.scrolled_songs.add(treeview_songs)

        self.show_all()
        self.buttonbox.hide()
        self.scrolled_songs.hide()

        nid = 2
        page = 0
        nodes, total_pages = Net.get_nodes(nid, page)
        if total_pages == 0:
            return
        urls = []
        tree_iters = []
        for node in nodes:
            tree_iter = self.liststore_nodes.append([
                self.app.theme['anonymous'],
                Widgets.unescape(node['name']),
                int(node['sourceid']),
                Widgets.unescape(node['info']),
                Widgets.set_tooltip_with_song_tips(node['name'], node['tips']),
            ])
            urls.append(node['pic'])
            tree_iters.append(tree_iter)
        self.liststore_nodes.timestamp = time.time()
        Net.update_liststore_images(self.liststore_nodes, 0, tree_iters, urls)
コード例 #2
0
    def first(self):
        app = self.app

        self.buttonbox = Gtk.Box(spacing=5)
        self.pack_start(self.buttonbox, False, False, 0)

        self.button_main = Gtk.Button(_('Themes'))
        self.button_main.connect('clicked', self.on_button_main_clicked)
        self.buttonbox.pack_start(self.button_main, False, False, 0)

        self.button_sub = Gtk.Button('')
        self.button_sub.connect('clicked', self.on_button_sub_clicked)
        self.buttonbox.pack_start(self.button_sub, False, False, 0)

        self.label = Gtk.Label('')
        self.buttonbox.pack_start(self.label, False, False, 0)

        # checked, name, artist, album, rid, artistid, albumid
        treeview_songs = Widgets.TreeViewSongs(app)
        self.liststore_songs = treeview_songs.liststore
        self.control_box = Widgets.ControlBox(self.liststore_songs, app)
        self.buttonbox.pack_end(self.control_box, False, False, 0)

        self.scrolled_main = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_main, True, True, 0)
        # pic, name, id, info(num of lists), tooltip
        self.liststore_main = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                            str)
        iconview_main = Widgets.IconView(self.liststore_main, tooltip=4)
        iconview_main.connect('item_activated',
                              self.on_iconview_main_item_activated)
        self.scrolled_main.add(iconview_main)

        self.scrolled_sub = Gtk.ScrolledWindow()
        self.scrolled_sub.get_vadjustment().connect(
            'value-changed', self.on_scrolled_sub_scrolled)
        self.pack_start(self.scrolled_sub, True, True, 0)
        # pic, name, sourceid, info(num of lists), tooltip
        self.liststore_sub = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                           str)
        iconview_sub = Widgets.IconView(self.liststore_sub, tooltip=4)
        iconview_sub.connect('item_activated',
                             self.on_iconview_sub_item_activated)
        self.scrolled_sub.add(iconview_sub)

        self.scrolled_songs = Gtk.ScrolledWindow()
        self.scrolled_songs.get_vadjustment().connect(
            'value-changed', self.on_scrolled_songs_scrolled)
        self.pack_start(self.scrolled_songs, True, True, 0)
        self.scrolled_songs.add(treeview_songs)

        self.show_all()
        self.buttonbox.hide()
        self.scrolled_sub.hide()
        self.scrolled_songs.hide()

        def _on_get_themes(nodes, error):
            if not nodes:
                logger.warn('_on_get_themes(): %s, %s' % (nodes, error))
                return
            urls = []
            tree_iters = []
            for node in nodes:
                tree_iter = self.liststore_main.append([
                    Config.ANONYMOUS_PIXBUF,
                    Widgets.unescape(node['name']),
                    int(node['nid']),
                    Widgets.unescape(node['info']),
                    Widgets.set_tooltip(node['name'], node['info']),
                ])
                urls.append(node['pic'])
                tree_iters.append(tree_iter)
            self.liststore_main.timestamp = time.time()
            Net.async_call(Net.update_liststore_images, self.liststore_main, 0,
                           tree_iters, urls)

        Net.async_call(Net.get_themes_main, callback=_on_get_themes)
コード例 #3
0
    def first(self):
        app = self.app

        self.buttonbox = Gtk.Box(spacing=5)
        self.pack_start(self.buttonbox, False, False, 0)

        self.button_main = Gtk.Button(_('Themes'))
        self.button_main.connect('clicked', self.on_button_main_clicked)
        self.buttonbox.pack_start(self.button_main, False, False, 0)

        self.button_sub = Gtk.Button('')
        self.button_sub.connect('clicked', self.on_button_sub_clicked)
        self.buttonbox.pack_start(self.button_sub, False, False, 0)

        self.label = Gtk.Label('')
        self.buttonbox.pack_start(self.label, False, False, 0)

        # checked, name, artist, album, rid, artistid, albumid
        self.liststore_songs = Gtk.ListStore(bool, str, str, str, int, int,
                                             int)
        self.control_box = Widgets.ControlBox(self.liststore_songs, app)
        self.buttonbox.pack_end(self.control_box, False, False, 0)

        self.scrolled_main = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_main, True, True, 0)
        # pic, name, id, info(num of lists), tooltip
        self.liststore_main = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                            str)
        iconview_main = Widgets.IconView(self.liststore_main, tooltip=4)
        iconview_main.connect('item_activated',
                              self.on_iconview_main_item_activated)
        self.scrolled_main.add(iconview_main)

        self.scrolled_sub = Gtk.ScrolledWindow()
        self.scrolled_sub.get_vadjustment().connect(
            'value-changed', self.on_scrolled_sub_scrolled)
        self.pack_start(self.scrolled_sub, True, True, 0)
        # pic, name, sourceid, info(num of lists), tooltip
        self.liststore_sub = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                           str)
        iconview_sub = Widgets.IconView(self.liststore_sub, tooltip=4)
        iconview_sub.connect('item_activated',
                             self.on_iconview_sub_item_activated)
        self.scrolled_sub.add(iconview_sub)

        self.scrolled_songs = Gtk.ScrolledWindow()
        self.scrolled_songs.get_vadjustment().connect(
            'value-changed', self.on_scrolled_songs_scrolled)
        self.pack_start(self.scrolled_songs, True, True, 0)
        treeview_songs = Widgets.TreeViewSongs(self.liststore_songs, app)
        self.scrolled_songs.add(treeview_songs)

        self.show_all()
        self.buttonbox.hide()
        self.scrolled_sub.hide()
        self.scrolled_songs.hide()

        nodes = Net.get_themes_main()
        if not nodes:
            print('Failed to get nodes, do something!')
            return
        for i, node in enumerate(nodes):
            self.liststore_main.append([
                self.app.theme['anonymous'],
                Widgets.unescape(node['name']),
                int(node['nid']),
                Widgets.unescape(node['info']),
                Widgets.set_tooltip(node['name'], node['info']),
            ])
            Net.update_liststore_image(self.liststore_main, i, 0, node['pic'])
コード例 #4
0
    def first(self):
        app = self.app

        self.buttonbox = Gtk.Box(spacing=5)
        self.pack_start(self.buttonbox, False, False, 0)

        self.button_main = Gtk.Button(_('Top Categories'))
        self.button_main.connect('clicked', self.on_button_main_clicked)
        self.buttonbox.pack_start(self.button_main, False, False, 0)

        self.button_sub1 = Gtk.Button('')
        self.button_sub1.connect('clicked', self.on_button_sub1_clicked)
        self.buttonbox.pack_start(self.button_sub1, False, False, 0)

        self.button_sub2 = Gtk.Button('')
        self.button_sub2.connect('clicked', self.on_button_sub2_clicked)
        self.buttonbox.pack_start(self.button_sub2, False, False, 0)

        self.label = Gtk.Label('')
        self.buttonbox.pack_start(self.label, False, False, 0)

        # checked, name, artist, album, rid, artistid, albumid
        self.liststore_songs = Gtk.ListStore(bool, str, str, str, int, int,
                                             int)
        self.control_box = Widgets.ControlBox(self.liststore_songs, app)
        self.buttonbox.pack_end(self.control_box, False, False, 0)

        self.scrolled_main = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_main, True, True, 0)
        # logo, name, nid, num of lists(info), tooltip
        self.liststore_main = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                            str)
        iconview_main = Widgets.IconView(self.liststore_main, tooltip=4)
        iconview_main.connect('item_activated',
                              self.on_iconview_main_item_activated)
        self.scrolled_main.add(iconview_main)

        self.scrolled_sub1 = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_sub1, True, True, 0)
        # logo, name, nid, num of lists(info), tooltip
        self.liststore_sub1 = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                            str)
        iconview_sub1 = Widgets.IconView(self.liststore_sub1, tooltip=4)
        iconview_sub1.connect('item_activated',
                              self.on_iconview_sub1_item_activated)
        self.scrolled_sub1.add(iconview_sub1)

        self.scrolled_sub2 = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_sub2, True, True, 0)
        # logo, name, nid, info, tooltip
        self.liststore_sub2 = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                            str)
        iconview_sub2 = Widgets.IconView(self.liststore_sub2, tooltip=4)
        iconview_sub2.connect('item_activated',
                              self.on_iconview_sub2_item_activated)
        self.scrolled_sub2.add(iconview_sub2)

        self.scrolled_songs = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_songs, True, True, 0)
        treeview_songs = Widgets.TreeViewSongs(self.liststore_songs, app)
        self.scrolled_songs.add(treeview_songs)

        self.show_all()
        self.buttonbox.hide()
        self.scrolled_sub1.hide()
        self.scrolled_sub2.hide()
        self.scrolled_songs.hide()

        nid = 5
        page = 0
        nodes, total_page = Net.get_nodes(nid, page)
        if not nodes:
            print('Failed to get nodes, do something!')
            return
        for i, node in enumerate(nodes):
            self.liststore_main.append([
                self.app.theme['anonymous'],
                Widgets.unescape(node['disname']),
                int(node['id']),
                Widgets.unescape(node['info']),
                Widgets.set_tooltip(node['disname'], node['info']),
            ])
            Net.update_liststore_image(self.liststore_main, i, 0, node['pic'])
コード例 #5
0
ファイル: Artists.py プロジェクト: zihua/kwplayer
    def first(self):
        if not self.first_run:
            return
        self.first_run = False

        app = self.app

        home_button = Gtk.Button(_('Artists'))
        home_button.connect('clicked', self.on_home_button_clicked)
        self.buttonbox.pack_start(home_button, False, False, 0)
        self.artist_button = Gtk.Button('')
        self.artist_button.connect('clicked', self.on_artist_button_clicked)
        self.buttonbox.pack_start(self.artist_button, False, False, 0)
        # to show artist name or album name
        self.label = Gtk.Label('')
        self.buttonbox.pack_start(self.label, False, False, 20)

        # control_box for artist's songs
        artist_songs_treeview = Widgets.TreeViewSongs(app)
        self.artist_songs_liststore = artist_songs_treeview.liststore
        self.artist_control_box = Widgets.ControlBox(
            self.artist_songs_liststore, app)
        self.buttonbox.pack_end(self.artist_control_box, False, False, 0)

        # control box for artist's mv
        # pic, name, artist, album, rid, artistid, albumid, tooltip
        # FIXME: check formats column
        self.artist_mv_liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str,
                                                 str, int, int, int, str)
        self.artist_mv_control_box = Widgets.MVControlBox(
            self.artist_mv_liststore, app)
        self.buttonbox.pack_end(self.artist_mv_control_box, False, False, 0)

        # control box for artist's albums
        album_songs_treeview = Widgets.TreeViewSongs(app)
        self.album_songs_liststore = album_songs_treeview.liststore
        self.album_control_box = Widgets.ControlBox(self.album_songs_liststore,
                                                    app)
        self.buttonbox.pack_end(self.album_control_box, False, False, 0)

        # main notebook
        self.notebook = Gtk.Notebook()
        self.notebook.set_show_tabs(False)
        self.pack_start(self.notebook, True, True, 0)

        # Artists tab (tab 0)
        self.artists_tab = Gtk.Box()
        self.notebook.append_page(self.artists_tab, Gtk.Label(_('Artists')))
        #self.pack_start(self.box_artists, True, True, 0)

        # left panel of artists tab
        artists_left_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.artists_tab.pack_start(artists_left_box, False, False, 0)
        # artists categories
        # name, id
        self.cate_liststore = Gtk.ListStore(str, int)
        self.cate_treeview = Gtk.TreeView(model=self.cate_liststore)
        self.cate_treeview.props.headers_visible = False
        name = Gtk.CellRendererText()
        col_name = Gtk.TreeViewColumn('Name', name, text=0)
        self.cate_treeview.append_column(col_name)
        artists_left_box.pack_start(self.cate_treeview, False, False, 0)

        # artists prefix
        # disname, prefix
        self.pref_liststore = Gtk.ListStore(str, str)
        self.pref_combo = Gtk.ComboBox(model=self.pref_liststore)
        cell_name = Gtk.CellRendererText()
        self.pref_combo.pack_start(cell_name, True)
        self.pref_combo.add_attribute(cell_name, 'text', 0)
        self.pref_combo.props.margin_top = 15
        artists_left_box.pack_start(self.pref_combo, False, False, 0)

        # favirote artists
        self.fav_yes_img = Gtk.Image.new_from_icon_name(
            'favorite', Gtk.IconSize.BUTTON)
        self.fav_no_img = Gtk.Image.new_from_icon_name(
            'emblem-favorite-symbolic', Gtk.IconSize.BUTTON)
        fav_artists_btn = Gtk.Button(_('Favorite'))
        fav_artists_btn.props.margin_top = 20
        fav_artists_btn.props.image = self.fav_yes_img
        if not Config.GTK_LE_36:
            fav_artists_btn.props.always_show_image = True
        fav_artists_btn.connect('clicked', self.on_fav_artists_btn_clicked)
        artists_left_box.pack_start(fav_artists_btn, False, False, 0)

        # main window of artists
        self.artists_win = Gtk.ScrolledWindow()
        adjustment = self.artists_win.get_vadjustment()
        adjustment.connect('value-changed', self.on_artists_win_scrolled)
        self.artists_tab.pack_start(self.artists_win, True, True, 0)
        # icon, artist name, artist id, num of songs, tooltip
        self.artists_liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                               str)
        artists_iconview = Widgets.IconView(self.artists_liststore, tooltip=4)
        artists_iconview.connect('item_activated',
                                 self.on_artists_iconview_item_activated)
        self.artists_win.add(artists_iconview)

        # Artist tab (tab 1)
        self.artist_tab = Gtk.Box()
        self.notebook.append_page(self.artist_tab, Gtk.Label(_('Artist')))

        # left panel of artist
        self.artist_buttons = Gtk.Box(spacing=5,
                                      orientation=Gtk.Orientation.VERTICAL)
        self.artist_buttons.props.margin_top = 15
        self.artist_tab.pack_start(self.artist_buttons, False, False, 0)

        self.artist_songs_button = ArtistButton(self, _('Songs'), None, 0)
        self.artist_albums_button = ArtistButton(self, _('Albums'),
                                                 self.artist_songs_button, 1)
        self.artist_mv_button = ArtistButton(self, _('MV'),
                                             self.artist_songs_button, 2)
        self.artist_similar_button = ArtistButton(self, _('Similar'),
                                                  self.artist_songs_button, 3)
        self.artist_info_button = ArtistButton(self, _('Info'),
                                               self.artist_songs_button, 4)

        # Add fav_btn to artist_tab
        fav_curr_artist_btn = Gtk.Button()
        fav_curr_artist_btn.props.margin_top = 15
        fav_curr_artist_btn.props.halign = Gtk.Align.CENTER
        fav_curr_artist_btn.props.image = self.fav_no_img
        if not Config.GTK_LE_36:
            fav_curr_artist_btn.props.always_show_image = True
        fav_curr_artist_btn.set_tooltip_text(_('Add to favorite artists list'))
        fav_curr_artist_btn.connect('clicked',
                                    self.on_fav_curr_artist_btn_clicked)
        self.artist_buttons.pack_start(fav_curr_artist_btn, False, False, 0)
        self.fav_curr_artist_btn = fav_curr_artist_btn

        # main window of artist tab
        self.artist_notebook = Gtk.Notebook()
        self.artist_notebook.set_show_tabs(False)
        self.artist_tab.pack_start(self.artist_notebook, True, True, 0)

        # songs tab for artist (tab 0)
        self.artist_songs_tab = Gtk.ScrolledWindow()
        self.artist_notebook.append_page(self.artist_songs_tab,
                                         Gtk.Label(_('Songs')))
        self.artist_songs_tab.add(artist_songs_treeview)

        # albums tab for artist (tab 1)
        self.artist_albums_tab = Gtk.ScrolledWindow()
        self.artist_notebook.append_page(self.artist_albums_tab,
                                         Gtk.Label(_('Albums')))
        # pic, album, albumid, artist, artistid, info/tooltip
        self.artist_albums_liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str,
                                                     int, str, int, str)
        artist_albums_iconview = Widgets.IconView(self.artist_albums_liststore,
                                                  tooltip=5)
        artist_albums_iconview.connect(
            'item_activated', self.on_artist_albums_iconview_item_activated)
        self.artist_albums_tab.add(artist_albums_iconview)

        # MVs tab for artist (tab 2)
        self.artist_mv_tab = Gtk.ScrolledWindow()
        self.artist_notebook.append_page(self.artist_mv_tab,
                                         Gtk.Label(_('MV')))
        artist_mv_iconview = Widgets.IconView(self.artist_mv_liststore,
                                              info_pos=2,
                                              tooltip=7)
        artist_mv_iconview.connect('item_activated',
                                   self.on_artist_mv_iconview_item_activated)
        self.artist_mv_tab.add(artist_mv_iconview)

        # Similar tab for artist (tab 3)
        self.artist_similar_tab = Gtk.ScrolledWindow()
        self.artist_notebook.append_page(self.artist_similar_tab,
                                         Gtk.Label(_('Similar')))
        # pic, artist name, artist id, num of songs, tooltip
        self.artist_similar_liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str,
                                                      int, str, str)
        artist_similar_iconview = Widgets.IconView(
            self.artist_similar_liststore, tooltip=4)
        artist_similar_iconview.connect(
            'item_activated', self.on_artist_similar_iconview_item_activated)
        self.artist_similar_tab.add(artist_similar_iconview)

        # Info tab for artist (tab 4)
        artist_info_tab = Gtk.ScrolledWindow()
        artist_info_tab_vp = Gtk.Viewport()
        artist_info_tab.add(artist_info_tab_vp)
        artist_info_tab.props.margin_left = 20
        artist_info_tab.props.margin_top = 5
        self.artist_notebook.append_page(artist_info_tab, Gtk.Label(_('Info')))
        artist_info_box = Gtk.Box(spacing=10,
                                  orientation=Gtk.Orientation.VERTICAL)
        artist_info_box.props.margin_right = 10
        artist_info_box.props.margin_bottom = 10
        artist_info_tab_vp.add(artist_info_box)

        artist_info_hbox = Gtk.Box(spacing=20)
        artist_info_box.pack_start(artist_info_hbox, False, False, 0)

        self.artist_info_pic = Gtk.Image()
        self.artist_info_pic.set_from_pixbuf(Config.ANONYMOUS_PIXBUF)
        self.artist_info_pic.props.xalign = 0
        self.artist_info_pic.props.yalign = 0
        artist_info_hbox.pack_start(self.artist_info_pic, False, False, 0)
        artist_info_grid = Gtk.Grid()
        artist_info_grid.props.row_spacing = 10
        artist_info_grid.props.column_spacing = 30
        self.artist_info_name = InfoLabel(artist_info_grid, _('Name'), 0, 0)
        self.artist_info_birthday = InfoLabel(artist_info_grid, _('Birthday'),
                                              0, 1)
        self.artist_info_birthplace = InfoLabel(artist_info_grid,
                                                _('Birthplace'), 1, 1)
        self.artist_info_height = InfoLabel(artist_info_grid, _('Height'), 0,
                                            2)
        self.artist_info_weight = InfoLabel(artist_info_grid, _('Weight'), 1,
                                            2)
        self.artist_info_country = InfoLabel(artist_info_grid, _('Country'), 0,
                                             3)
        self.artist_info_language = InfoLabel(artist_info_grid, _('Language'),
                                              1, 3)
        self.artist_info_gender = InfoLabel(artist_info_grid, _('Gender'), 0,
                                            4)
        self.artist_info_constellation = InfoLabel(artist_info_grid,
                                                   _('Constellation'), 1, 4)
        artist_info_hbox.pack_start(artist_info_grid, False, False, 0)

        artist_info_textview = Gtk.TextView()
        self.artist_info_textbuffer = Gtk.TextBuffer()
        artist_info_textview.props.editable = False
        artist_info_textview.props.cursor_visible = False
        artist_info_textview.props.wrap_mode = Gtk.WrapMode.CHAR
        artist_info_textview.set_buffer(self.artist_info_textbuffer)
        artist_info_box.pack_start(artist_info_textview, True, True, 0)

        # Album tab (tab 2)
        album_songs_tab = Gtk.ScrolledWindow()
        self.notebook.append_page(album_songs_tab, Gtk.Label(_('Album')))
        album_songs_tab.add(album_songs_treeview)

        # Favorite artists tab (tab 3)
        fav_artists_tab = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.notebook.append_page(fav_artists_tab, Gtk.Label(_('Favorite')))
        fav_buttons = Gtk.Box(spacing=5)
        fav_artists_tab.pack_start(fav_buttons, False, False, 0)
        fav_main_btn = Gtk.Button(_('Artists'))
        fav_main_btn.connect('clicked', self.on_fav_main_btn_clicked)
        fav_buttons.pack_start(fav_main_btn, False, False, 0)
        fav_label = Gtk.Label(_('Favorite Artists'))
        fav_buttons.pack_start(fav_label, False, False, 0)
        fav_win = Gtk.ScrolledWindow()
        fav_artists_tab.pack_start(fav_win, True, True, 0)
        # icon, artist name, artist id, tooltip
        self.fav_artists_liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int,
                                                   str)
        fav_artists_iconview = Widgets.IconView(self.fav_artists_liststore,
                                                info_pos=None,
                                                tooltip=3)
        fav_artists_iconview.connect(
            'item_activated', self.on_fav_artists_iconview_item_activated)
        fav_win.add(fav_artists_iconview)

        prefs = (
            (_('All'), ''),
            ('A', 'a'),
            ('B', 'b'),
            ('C', 'c'),
            ('D', 'd'),
            ('E', 'e'),
            ('F', 'f'),
            ('G', 'g'),
            ('H', 'h'),
            ('I', 'i'),
            ('J', 'j'),
            ('K', 'k'),
            ('L', 'l'),
            ('M', 'm'),
            ('N', 'n'),
            ('O', 'o'),
            ('P', 'p'),
            ('Q', 'q'),
            ('R', 'r'),
            ('S', 's'),
            ('T', 't'),
            ('U', 'u'),
            ('V', 'v'),
            ('W', 'w'),
            ('X', 'x'),
            ('Y', 'y'),
            ('Z', 'z'),
            ('#', '%26'),
        )
        for pref in prefs:
            self.pref_liststore.append(pref)
        self.pref_combo.set_active(0)
        self.pref_combo.connect('changed', self.on_cate_changed)

        cates = (
            (_('Hot Artists'), 0),
            (_('Chinese Male'), 1),
            (_('Chinese Female'), 2),
            (_('Chinese Band'), 3),
            (_('Japanese Male'), 4),
            (_('Japanese Female'), 5),
            (_('Japanese Band'), 6),
            (_('European Male'), 7),
            (_('European Female'), 8),
            (_('European Band'), 9),
            (_('Others'), 10),
        )
        for cate in cates:
            self.cate_liststore.append(cate)
        selection = self.cate_treeview.get_selection()
        self.cate_treeview.connect('row_activated', self.on_cate_changed)
        selection.connect('changed', self.on_cate_changed)
        selection.select_path(0)

        # load current favorite artists list
        self.load_fav_artists()
        self.show_all()
        self.buttonbox.hide()
コード例 #6
0
    def __init__(self, app):
        super().__init__(orientation=Gtk.Orientation.VERTICAL, spacing=5)
        self.app = app

        self.search_count = 0
        self.keyword = ''

        #Initialize page counter
        self.songs_page = 0
        self.songs_total = 0
        self.artists_page = 0
        self.artists_total = 0
        self.albums_page = 0
        self.albums_total = 0

        box_top = Gtk.Box(spacing=5)
        self.pack_start(box_top, False, False, 0)

        if Config.GTK_LE_36:
            self.search_entry = Gtk.Entry()
        else:
            self.search_entry = Gtk.SearchEntry()
        self.search_entry.set_placeholder_text(_('Search Songs, Artists..'))
        self.search_entry.props.width_chars = 30
        self.search_entry.connect('activate', self.on_search_entry_activate)
        box_top.pack_start(self.search_entry, False, False, 20)

        self.songs_button = Widgets.ListRadioButton(_('Songs'))
        self.songs_button.connect('toggled', self.switch_notebook_page, 0)
        self.songs_button.search_count = 0
        box_top.pack_start(self.songs_button, False, False, 0)

        self.artists_button = Widgets.ListRadioButton(_('Artists'),
                                                      self.songs_button)
        self.artists_button.connect('toggled', self.switch_notebook_page, 1)
        self.artists_button.search_count = 0
        box_top.pack_start(self.artists_button, False, False, 0)

        self.albums_button = Widgets.ListRadioButton(_('Albums'),
                                                     self.songs_button)
        self.albums_button.connect('toggled', self.switch_notebook_page, 2)
        self.albums_button.search_count = 0
        box_top.pack_start(self.albums_button, False, False, 0)

        # checked, name, artist, album, rid, artistid, albumid
        self.liststore_songs = Gtk.ListStore(bool, str, str, str, int, int,
                                             int)
        self.control_box = Widgets.ControlBox(self.liststore_songs,
                                              app,
                                              select_all=False)
        box_top.pack_end(self.control_box, False, False, 0)

        self.notebook = Gtk.Notebook()
        self.notebook.set_show_tabs(False)
        self.pack_start(self.notebook, True, True, 0)

        songs_tab = Gtk.ScrolledWindow()
        songs_tab.get_vadjustment().connect('value-changed',
                                            self.on_songs_tab_scrolled)
        self.notebook.append_page(songs_tab, Gtk.Label(_('Songs')))
        treeview_songs = Widgets.TreeViewSongs(self.liststore_songs, app)
        songs_tab.add(treeview_songs)

        artists_tab = Gtk.ScrolledWindow()
        artists_tab.get_vadjustment().connect('value-changed',
                                              self.on_artists_tab_scrolled)
        self.notebook.append_page(artists_tab, Gtk.Label(_('Artists')))

        # pic, artist, artistid, country
        self.liststore_artists = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str)
        iconview_artists = Widgets.IconView(self.liststore_artists)
        iconview_artists.connect('item_activated',
                                 self.on_iconview_artists_item_activated)
        artists_tab.add(iconview_artists)

        albums_tab = Gtk.ScrolledWindow()
        albums_tab.get_vadjustment().connect('value-changed',
                                             self.on_albums_tab_scrolled)
        self.notebook.append_page(albums_tab, Gtk.Label(_('Albums')))
        albums_tab.search_count = 0

        # logo, album, albumid, artist, artistid, info
        self.liststore_albums = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                              int, str)
        iconview_albums = Widgets.IconView(self.liststore_albums, tooltip=5)
        iconview_albums.connect('item_activated',
                                self.on_iconview_albums_item_activated)
        albums_tab.add(iconview_albums)
コード例 #7
0
ファイル: TopList.py プロジェクト: zhcj/kwplayer
    def first(self):
        app = self.app

        self.buttonbox = Gtk.Box(spacing=5)
        self.pack_start(self.buttonbox, False, False, 0)
        button_home = Gtk.Button(_('TopList'))
        button_home.connect('clicked', self.on_button_home_clicked)
        self.buttonbox.pack_start(button_home, False, False, 0)
        self.label = Gtk.Label('')
        self.buttonbox.pack_start(self.label, False, False, 0)

        # checked, name, artist, album, rid, artistid, albumid
        treeview_songs = Widgets.TreeViewSongs(app)
        self.liststore_songs = treeview_songs.liststore
        control_box = Widgets.ControlBox(self.liststore_songs, app)
        self.buttonbox.pack_end(control_box, False, False, 0)

        self.scrolled_nodes = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_nodes, True, True, 0)
        # logo, name, nid, info, tooltip
        self.liststore_nodes = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int,
                                             str, str)
        iconview_nodes = Widgets.IconView(self.liststore_nodes, tooltip=4)
        iconview_nodes.connect('item_activated',
                               self.on_iconview_nodes_item_activated)
        self.scrolled_nodes.add(iconview_nodes)

        self.scrolled_songs = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_songs, True, True, 0)
        self.scrolled_songs.add(treeview_songs)

        self.show_all()
        self.buttonbox.hide()
        self.scrolled_songs.hide()

        def _on_get_nodes(info, error):
            if error or not info or not info[0] or not info[1]:
                logger.errror('_on_get_nodes(), info: %s, error: %s' %
                              (info, error))
                return
            nodes, total_pages = info
            urls = []
            tree_iters = []
            for node in nodes:
                tree_iter = self.liststore_nodes.append([
                    Config.ANONYMOUS_PIXBUF,
                    Widgets.unescape(node['name']),
                    int(node['sourceid']),
                    Widgets.unescape(node['info']),
                    Widgets.set_tooltip_with_song_tips(node['name'],
                                                       node['tips']),
                ])
                urls.append(node['pic'])
                tree_iters.append(tree_iter)
            self.liststore_nodes.timestamp = time.time()
            Net.async_call(Net.update_liststore_images, self.liststore_nodes, 0,
                           tree_iters, urls)

        nid = 2
        page = 0
        Net.async_call(Net.get_nodes, nid, page, callback=_on_get_nodes)
コード例 #8
0
ファイル: TopCategories.py プロジェクト: zihua/kwplayer
    def first(self):
        app = self.app

        self.buttonbox = Gtk.Box(spacing=5)
        self.pack_start(self.buttonbox, False, False, 0)

        self.button_main = Gtk.Button(_('Top Categories'))
        self.button_main.connect('clicked', self.on_button_main_clicked)
        self.buttonbox.pack_start(self.button_main, False, False, 0)

        self.button_sub1 = Gtk.Button('')
        self.button_sub1.connect('clicked', self.on_button_sub1_clicked)
        self.buttonbox.pack_start(self.button_sub1, False, False, 0)

        self.button_sub2 = Gtk.Button('')
        self.button_sub2.connect('clicked', self.on_button_sub2_clicked)
        self.buttonbox.pack_start(self.button_sub2, False, False, 0)

        self.label = Gtk.Label('')
        self.buttonbox.pack_start(self.label, False, False, 0)

        treeview_songs = Widgets.TreeViewSongs(app)
        self.liststore_songs = treeview_songs.liststore
        self.control_box = Widgets.ControlBox(self.liststore_songs, app)
        self.buttonbox.pack_end(self.control_box, False, False, 0)

        self.scrolled_main = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_main, True, True, 0)
        # logo, name, nid, num of lists(info), tooltip
        self.liststore_main = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                            str)
        iconview_main = Widgets.IconView(self.liststore_main, tooltip=4)
        iconview_main.connect('item_activated',
                              self.on_iconview_main_item_activated)
        self.scrolled_main.add(iconview_main)

        self.scrolled_sub1 = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_sub1, True, True, 0)
        # logo, name, nid, num of lists(info), tooltip
        self.liststore_sub1 = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                            str)
        iconview_sub1 = Widgets.IconView(self.liststore_sub1, tooltip=4)
        iconview_sub1.connect('item_activated',
                              self.on_iconview_sub1_item_activated)
        self.scrolled_sub1.add(iconview_sub1)

        self.scrolled_sub2 = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_sub2, True, True, 0)
        # logo, name, nid, info, tooltip
        self.liststore_sub2 = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str,
                                            str)
        iconview_sub2 = Widgets.IconView(self.liststore_sub2, tooltip=4)
        iconview_sub2.connect('item_activated',
                              self.on_iconview_sub2_item_activated)
        self.scrolled_sub2.add(iconview_sub2)

        self.scrolled_songs = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_songs, True, True, 0)
        self.scrolled_songs.add(treeview_songs)

        self.show_all()
        self.buttonbox.hide()
        self.scrolled_sub1.hide()
        self.scrolled_sub2.hide()
        self.scrolled_songs.hide()

        def _on_get_nodes(info, error):
            if not info or not info[0] or not info[1] or error:
                logger.error('TopCategories._on_get_nodes(): %s, %s' %
                             (info, error))
                return
            nodes, total_pages = info
            urls = []
            tree_iters = []
            for node in nodes:
                # skip 'xx专区'
                if node['disname'].endswith('专区'):
                    continue
                tree_iter = self.liststore_main.append([
                    Config.ANONYMOUS_PIXBUF,
                    Widgets.unescape(node['disname']),
                    int(node['id']),
                    Widgets.unescape(node['info']),
                    Widgets.set_tooltip(node['disname'], node['info']),
                ])
                tree_iters.append(tree_iter)
                urls.append(node['pic'])
            self.liststore_main.timestamp = time.time()
            Net.async_call(Net.update_liststore_images, self.liststore_main, 0,
                           tree_iters, urls)

        nid = 5
        page = 0
        Net.async_call(Net.get_nodes, nid, page, callback=_on_get_nodes)