コード例 #1
0
ファイル: MV.py プロジェクト: anchowee/kwplayer
    def first(self):
        if self.first_show:
            return
        self.first_show = True
        app = self.app
        self.buttonbox = Gtk.Box(spacing=5)
        self.pack_start(self.buttonbox, False, False, 0)
        button_home = Gtk.Button(_('MV'))
        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)

        # pic, name, artist, album, rid, artistid, albumid, tooltip
        self.liststore_songs = Gtk.ListStore(GdkPixbuf.Pixbuf,
                str, str, str, int, int, int, str)
        self.mv_control_box = Widgets.MVControlBox(self.liststore_songs,
                self.app)
        self.buttonbox.pack_end(self.mv_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)
        iconview_songs = Widgets.IconView(self.liststore_songs,
                info_pos=2, tooltip=7)
        iconview_songs.connect('item_activated', 
                self.on_iconview_songs_item_activated)
        self.scrolled_songs.add(iconview_songs)

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

        nid = 3
        nodes_wrap = Net.get_index_nodes(nid)
        if not nodes_wrap:
            return
        nodes = nodes_wrap['child']
        self.liststore_nodes.clear()
        i = 0
        for node in nodes:
            self.liststore_nodes.append([
                self.app.theme['anonymous'],
                Widgets.unescape_html(node['disname']),
                int(node['sourceid']),
                Widgets.unescape_html(node['info']),
                Widgets.set_tooltip(node['disname'], node['info']),
                ])
            Net.update_liststore_image(self.liststore_nodes, i, 0,
                    node['pic'])
            i += 1
コード例 #2
0
ファイル: TopCategories.py プロジェクト: anchowee/kwplayer
 def _show_sub1(sub1_args, error=None):
     nodes, self.sub1_total = sub1_args
     if nodes is None or self.sub1_total == 0:
         return
     i = len(self.liststore_sub1)
     for node in nodes:
         _id = 'id' if self.use_sub2 else 'sourceid'
         if 'tips' in node and len(node['tips']) > 5:
             _tooltip = Widgets.set_tooltip_with_song_tips(
                     node['name'], node['tips'])
         else:
             _tooltip = Widgets.set_tooltip(
                     node['name'], node['info'])
         self.liststore_sub1.append([
             self.app.theme['anonymous'],
             Widgets.unescape_html(node['name']),
             int(node[_id]),
             Widgets.unescape_html(node['info']),
             _tooltip,
             ])
         Net.update_liststore_image(self.liststore_sub1, i, 0, 
                 node['pic'])
         i += 1
     self.sub1_page += 1
     if self.sub1_page < self.sub1_total - 1:
         self.show_sub1()
コード例 #3
0
ファイル: Themes.py プロジェクト: anchowee/kwplayer
 def show_sub(self, init=False):
     if init:
         self.scrolled_main.hide()
         self.scrolled_songs.hide()
         self.buttonbox.show_all()
         self.button_sub.hide()
         self.control_box.hide()
         self.scrolled_sub.get_vadjustment().set_value(0)
         self.scrolled_sub.show_all()
         self.nodes_page = 0
         self.liststore_sub.clear()
     nodes, self.nodes_total = Net.get_nodes(self.curr_sub_id,
             self.nodes_page)
     if nodes is None:
         return
     i = len(self.liststore_sub)
     for node in nodes:
         self.liststore_sub.append([
             self.app.theme['anonymous'],
             Widgets.unescape_html(node['name']),
             int(node['sourceid']),
             Widgets.unescape_html(node['info']),
             Widgets.set_tooltip_with_song_tips(node['name'],
                 node['tips']),
             ])
         Net.update_liststore_image(self.liststore_sub, i, 0, 
                 node['pic'])
         i += 1
コード例 #4
0
ファイル: TopList.py プロジェクト: anchowee/kwplayer
    def first(self):
        if self.first_show:
            return
        self.first_show = True
        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
        i = 0
        for node in nodes:
            self.liststore_nodes.append([
                self.app.theme['anonymous'],
                Widgets.unescape_html(node['name']),
                int(node['sourceid']),
                Widgets.unescape_html(node['info']),
                Widgets.set_tooltip_with_song_tips(node['name'],
                    node['tips']),
                ])
            Net.update_toplist_node_logo(self.liststore_nodes, i, 0, 
                    node['pic'])
            i += 1
コード例 #5
0
ファイル: Radio.py プロジェクト: anchowee/kwplayer
    def first(self):
        if self.first_show:
            return
        self.first_show = True
        app = self.app

        # left side panel
        scrolled_myradio = Gtk.ScrolledWindow()
        scrolled_myradio.props.hscrollbar_policy = Gtk.PolicyType.NEVER
        self.pack_start(scrolled_myradio, False, False, 0)

        # radios selected by user.
        self.box_myradio = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.box_myradio.props.margin_left = 10
        scrolled_myradio.add(self.box_myradio)

        self.scrolled_radios = Gtk.ScrolledWindow()
        self.pack_start(self.scrolled_radios, True, True, 0)

        # pic, name, id, num of listeners, pic_url, tooltip
        self.liststore_radios = Gtk.ListStore(GdkPixbuf.Pixbuf,
                str, int, str, str, str)
        iconview_radios = Widgets.IconView(self.liststore_radios, tooltip=5)
        iconview_radios.connect('item_activated',
                self.on_iconview_radios_item_activated)
        self.scrolled_radios.add(iconview_radios)

        self.show_all()

        nid = 8
        page = 0
        radios, total_page = Net.get_nodes(nid, page)
        if total_page == 0:
            return
        i = 0
        for radio in radios:
            self.liststore_radios.append([
                self.app.theme['anonymous'],
                Widgets.unescape_html(radio['disname']), 
                int(radio['sourceid'].split(',')[0]),
                Widgets.unescape_html(radio['info']),
                radio['pic'],
                Widgets.set_tooltip(radio['disname'], radio['info']),
                ])
            Net.update_liststore_image(self.liststore_radios, i, 0,
                    radio['pic']),
            i += 1
        for radio in self.playlists:
            radio_item = RadioItem(radio, self.app)
            self.box_myradio.pack_start(radio_item, False, False, 0)

        GLib.timeout_add(300000, self.dump_playlists)
コード例 #6
0
ファイル: Artists.py プロジェクト: iiccn/kwplayer
    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'],
                Widgets.unescape_html(artist['name']),
                int(artist['id']), 
                artist['music_num'] + _(' songs'), ])
            Net.update_artist_logo(self.artists_liststore, i, 0, 
                    artist['pic'])
            i += 1
コード例 #7
0
ファイル: TopCategories.py プロジェクト: iiccn/kwplayer
 def _show_sub2(sub2_args, error=None):
     nodes, self.sub2_total = sub2_args
     if nodes is None or self.sub2_total == 0:
         return
     i = len(self.liststore_sub2)
     for node in nodes:
         self.liststore_sub2.append([self.app.theme['anonymous'],
             Widgets.unescape_html(node['name']),
             int(node['sourceid']),
             Widgets.unescape_html(node['info']), ])
         Net.update_liststore_image(self.liststore_sub2, i, 0, 
                 node['pic'])
         i += 1
     self.sub2_page += 1
     if self.sub2_page < self.sub2_total - 1:
         self.show_sub2()
コード例 #8
0
ファイル: Themes.py プロジェクト: iiccn/kwplayer
    def first(self):
        if self.first_show:
            return
        self.first_show = True
        app = self.app

        self.buttonbox = Gtk.Box()
        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)
        self.liststore_main = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str)
        iconview_main = Widgets.IconView(self.liststore_main)
        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)
        self.liststore_sub = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str)
        iconview_sub = Widgets.IconView(self.liststore_sub)
        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 nodes is None:
            print('Failed to get nodes, do something!')
            return
        i = 0
        for node in nodes:
            self.liststore_main.append([self.app.theme['anonymous'],
                    Widgets.unescape_html(node['name']),
                    int(node['nid']),
                    Widgets.unescape_html(node['info']), ])
            Net.update_liststore_image(self.liststore_main, i, 0, 
                    node['pic'])
            i += 1
コード例 #9
0
ファイル: TopCategories.py プロジェクト: iiccn/kwplayer
    def first(self):
        if self.first_show:
            return
        self.first_show = True
        app = self.app

        self.buttonbox = Gtk.Box()
        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)
        self.liststore_main = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str)
        iconview_main = Widgets.IconView(self.liststore_main)
        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)
        self.liststore_sub1 = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str)
        iconview_sub1 = Widgets.IconView(self.liststore_sub1, tooltip=1)
        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
        self.liststore_sub2 = Gtk.ListStore(GdkPixbuf.Pixbuf, str, int, str)
        iconview_sub2 = Widgets.IconView(self.liststore_sub2, tooltip=1)
        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 nodes is None:
            print('Failed to get nodes, do something!')
            return
        i = 0
        for node in nodes:
            self.liststore_main.append([self.app.theme['anonymous'],
                Widgets.unescape_html(node['disname']),
                int(node['id']),
                Widgets.unescape_html(node['info']), ])
            Net.update_liststore_image(self.liststore_main, i, 0, 
                    node['pic'])
            i += 1