示例#1
0
    def __init__(self, parent, treeview, export_all=True):
        super().__init__(_('Export Songs'), parent.app.window,
                         Gtk.DialogFlags.MODAL, (
                             Gtk.STOCK_CLOSE,
                             Gtk.ResponseType.OK,
                         ))
        self.parent = parent
        self.treeview = treeview
        self.export_all = export_all
        self.app = parent.app

        self.set_border_width(15)

        box = self.get_content_area()
        box.set_size_request(540, 260)
        box.set_spacing = 5

        folder_label = Widgets.BoldLabel(_('Choose export folder:'))
        box.pack_start(folder_label, False, True, 2)

        self.folder_chooser = Widgets.FolderChooser(self.app.window)
        self.folder_chooser.props.margin_left = 20
        box.pack_start(self.folder_chooser, False, True, 0)

        self.including_lrc = Gtk.CheckButton(_('Including lyrics'))
        self.including_lrc.set_tooltip_text(
            _('Export lyrics to the same folder'))
        self.including_lrc.props.margin_top = 20
        box.pack_start(self.including_lrc, False, False, 0)

        export_box = Gtk.Box(spacing=5)
        export_box.props.margin_top = 20
        box.pack_start(export_box, False, True, 0)

        self.export_prog = Gtk.ProgressBar()
        self.export_prog.props.show_text = True
        self.export_prog.props.text = ''
        export_box.pack_start(self.export_prog, True, True, 0)

        self.export_btn = Gtk.Button(_('Export'))
        self.export_btn.connect('clicked', self.do_export)
        export_box.pack_start(self.export_btn, False, False, 0)

        infobar = Gtk.InfoBar()
        infobar.props.margin_top = 20
        box.pack_start(infobar, False, True, 0)
        info_content = infobar.get_content_area()
        info_label = Gtk.Label(_('Only cached songs will be exported'))
        info_content.pack_start(info_label, False, False, 0)
        box.show_all()
示例#2
0
    def on_export_playlist_button_clicked(self, button):
        def do_export(button):
            num_songs = len(liststore)
            export_dir = folder_chooser.get_filename()
            export_lrc = with_lrc.get_active()
            for i, item in enumerate(liststore):
                song = Widgets.song_row_to_dict(item, start=0)
                song_link, song_path = Net.get_song_link(
                        song, self.app.conf)
                if song_link is not True:
                    continue
                shutil.copy(song_path, export_dir)

                if export_lrc:
                    (lrc_path, lrc_cached) = Net.get_lrc_path(song)
                    if lrc_cached:
                        shutil.copy(lrc_path, export_dir)
                export_prog.set_fraction(i / num_songs)
                Gdk.Window.process_all_updates()
            dialog.destroy()

        selection = self.treeview_left.get_selection()
        model, _iter = selection.get_selected()
        if not _iter:
            return
        path = model.get_path(_iter)
        index = path.get_indices()[0]
        disname, list_name, editable = model[path]
        liststore = self.tabs[list_name].liststore

        dialog = Gtk.Dialog(
                _('Export Songs'), self.app.window, Gtk.DialogFlags.MODAL,
                (Gtk.STOCK_CLOSE, Gtk.ResponseType.OK,))
        box = dialog.get_content_area()
        box.set_size_request(600, 320)
        box.set_border_width(5)

        folder_label = Widgets.BoldLabel(_('Choose export folder'))
        box.pack_start(folder_label, False, True, 0)

        folder_chooser = Widgets.FolderChooser(self.app.window)
        folder_chooser.props.margin_left = 20
        box.pack_start(folder_chooser, False, True, 0)

        with_lrc = Gtk.CheckButton(_('With lyrics'))
        with_lrc.set_tooltip_text(_('Export lyrics to the same folder'))
        with_lrc.props.margin_top = 20
        box.pack_start(with_lrc, False, False, 0)

        export_box = Gtk.Box(spacing=5)
        export_box.props.margin_top = 20
        box.pack_start(export_box, False, True, 0)

        export_prog = Gtk.ProgressBar()
        export_box.pack_start(export_prog, True, True, 0)

        export_btn = Gtk.Button(_('Export'))
        export_btn.connect('clicked', do_export)
        export_box.pack_start(export_btn, False, False, 0)

        infobar = Gtk.InfoBar()
        infobar.props.margin_top = 20
        box.pack_start(infobar, False, True, 0)
        info_content = infobar.get_content_area()
        info_label = Gtk.Label(_('Only cached songs will be exported'))
        info_content.pack_start(info_label, False, False, 0)

        box.show_all()
        dialog.run()
        dialog.destroy()
示例#3
0
    def __init__(self, app):
        self.app = app
        super().__init__(_('Preferences'), app.window, 0, (
            Gtk.STOCK_CLOSE,
            Gtk.ResponseType.CLOSE,
        ))
        self.set_modal(True)
        self.set_transient_for(app.window)
        self.set_default_size(600, 320)
        self.set_border_width(5)
        box = self.get_content_area()
        #box.props.margin_left = MARGIN_LEFT

        notebook = Gtk.Notebook()
        box.pack_start(notebook, True, True, 0)

        # generic tab
        generic_box = NoteTab()
        notebook.append_page(generic_box, Gtk.Label(_('Generic')))

        status_button = Gtk.CheckButton(_('Close to system tray'))
        status_button.set_active(app.conf['use-status-icon'])
        status_button.connect('toggled', self.on_status_button_toggled)
        generic_box.pack_start(status_button, False, False, 0)

        notify_button = Gtk.CheckButton(_('Show kwplayer on lock screen'))
        notify_button.set_tooltip_text(
            _('Only works with gdm3/gnome3.8+\n') +
            _('Please disable it on other desktop environments (like KDE)'))
        notify_button.set_active(app.conf['use-notify'])
        notify_button.connect('toggled', self.on_notify_button_toggled)
        generic_box.pack_start(notify_button, False, False, 0)

        show_pls_button = Gtk.CheckButton(_('Show playlist tab on startup'))
        show_pls_button.set_active(app.conf['show-pls'])
        show_pls_button.connect('toggled', self.on_show_pls_button_toggled)
        generic_box.pack_start(show_pls_button, False, False, 0)

        dark_theme_button = Gtk.CheckButton(_('Use dark theme'))
        dark_theme_button.set_active(app.conf['use-dark-theme'])
        dark_theme_button.connect('toggled', self.on_dark_theme_button_toggled)
        generic_box.pack_start(dark_theme_button, False, False, 0)

        # format tab
        format_box = NoteTab()
        notebook.append_page(format_box, Gtk.Label(_('Format')))

        audio_label = Widgets.BoldLabel(_('Prefered Audio Format'))
        format_box.pack_start(audio_label, False, False, 0)
        radio_mp3 = Gtk.RadioButton(_('MP3 (faster)'))
        radio_mp3.props.margin_left = MARGIN_LEFT
        radio_mp3.connect('toggled', self.on_audio_toggled)
        format_box.pack_start(radio_mp3, False, False, 0)
        radio_ape = Gtk.RadioButton(_('APE (better)'))
        radio_ape.join_group(radio_mp3)
        radio_ape.props.margin_left = MARGIN_LEFT
        radio_ape.set_active(app.conf['use-ape'])
        radio_ape.connect('toggled', self.on_audio_toggled)
        format_box.pack_start(radio_ape, False, False, 0)

        video_label = Widgets.BoldLabel(_('Prefered Video Format'))
        video_label.props.margin_top = MARGIN_TOP
        format_box.pack_start(video_label, False, False, 0)
        radio_mp4 = Gtk.RadioButton(_('MP4 (faster)'))
        radio_mp4.props.margin_left = MARGIN_LEFT
        radio_mp4.connect('toggled', self.on_video_toggled)
        format_box.pack_start(radio_mp4, False, False, 0)
        radio_mkv = Gtk.RadioButton(_('MKV (better)'))
        radio_mkv.props.margin_left = MARGIN_LEFT
        radio_mkv.join_group(radio_mp4)
        radio_mkv.set_active(app.conf['use-mkv'])
        radio_mkv.connect('toggled', self.on_video_toggled)
        radio_mkv.set_tooltip_text(
            _('Please use this format when using Karaoke'))
        format_box.pack_start(radio_mkv, False, False, 0)

        # lyrics tab
        lrc_box = NoteTab()
        notebook.append_page(lrc_box, Gtk.Label(_('Lyrics')))

        lrc_normal_text_label = Widgets.BoldLabel(_('Normal Text'))
        lrc_box.pack_start(lrc_normal_text_label, False, True, 0)

        lrc_normal_text_size = FontBox(_('text size'),
                                       app.conf,
                                       'lrc-text-size',
                                       use_margin=True)
        lrc_box.pack_start(lrc_normal_text_size, False, True, 0)

        lrc_normal_text_color = ColorBox(_('text color'),
                                         app.conf,
                                         'lrc-text-color',
                                         use_margin=True)
        lrc_box.pack_start(lrc_normal_text_color, False, True, 0)
        lrc_normal_text_color.props.margin_bottom = 10

        lrc_highlighted_text_label = Widgets.BoldLabel(_('Highlighted Text'))
        lrc_box.pack_start(lrc_highlighted_text_label, False, True, 0)

        lrc_highlighted_text_size = FontBox(_('text size'),
                                            app.conf,
                                            'lrc-highlighted-text-size',
                                            use_margin=True)
        lrc_box.pack_start(lrc_highlighted_text_size, False, True, 0)

        lrc_highlighted_text_color = ColorBox(_('text color'),
                                              app.conf,
                                              'lrc-highlighted-text-color',
                                              use_margin=True)
        lrc_highlighted_text_color.props.margin_bottom = 10
        lrc_box.pack_start(lrc_highlighted_text_color, False, True, 0)

        lrc_word_back_color = ColorBox(_('Lyrics Text Background color'),
                                       app.conf, 'lrc-back-color')
        lrc_box.pack_start(lrc_word_back_color, False, True, 0)

        # folders tab
        folder_box = NoteTab()
        notebook.append_page(folder_box, Gtk.Label(_('Folders')))

        song_folder_label = Widgets.BoldLabel(_('Place to store sogns'))
        folder_box.pack_start(song_folder_label, False, False, 0)
        song_folder = ChooseFolder(self, 'song-dir',
                                   _('Moving cached songs to new folder'))
        folder_box.pack_start(song_folder, False, False, 0)

        mv_folder_label = Widgets.BoldLabel(_('Place to store MVs'))
        mv_folder_label.props.margin_top = MARGIN_TOP
        folder_box.pack_start(mv_folder_label, False, False, 0)
        mv_folder = ChooseFolder(self, 'mv-dir',
                                 _('Moving cached MVs to new folder'))
        folder_box.pack_start(mv_folder, False, False, 0)

        self.notebook = notebook

        # shortcut tab
        self.init_shortcut_tab()
示例#4
0
    def __init__(self, app):
        self.app = app
        super().__init__(_('Preferences'), app.window, 0, (
            Gtk.STOCK_CLOSE,
            Gtk.ResponseType.CLOSE,
        ))
        self.set_modal(True)
        self.set_transient_for(app.window)
        self.set_default_size(600, 320)
        self.set_border_width(5)
        box = self.get_content_area()

        notebook = Gtk.Notebook()
        box.pack_start(notebook, True, True, 0)

        # generic tab
        generic_box = NoteTab()
        notebook.append_page(generic_box, Gtk.Label(_('Generic')))

        status_button = Gtk.CheckButton(_('Close to system tray'))
        status_button.set_active(app.conf['use-status-icon'])
        status_button.connect('toggled', self.on_status_button_toggled)
        generic_box.pack_start(status_button, False, False, 0)

        notify_button = Gtk.CheckButton(_('Show kwplayer on lock screen'))
        notify_button.set_tooltip_text(
            _('Only works with gdm3/gnome3.8+\n') +
            _('Please disable it on other desktop environments (like KDE)'))
        notify_button.set_active(app.conf['use-notify'])
        notify_button.connect('toggled', self.on_notify_button_toggled)
        generic_box.pack_start(notify_button, False, False, 0)

        dark_theme_button = Gtk.CheckButton(_('Use dark theme'))
        dark_theme_button.set_active(app.conf['use-dark-theme'])
        dark_theme_button.connect('toggled', self.on_dark_theme_button_toggled)
        generic_box.pack_start(dark_theme_button, False, False, 0)

        # format tab
        format_box = NoteTab()
        notebook.append_page(format_box, Gtk.Label(_('Format')))

        audio_label = Widgets.BoldLabel(_('Prefered Audio Format'))
        format_box.pack_start(audio_label, False, False, 0)
        audio_128k = Gtk.RadioButton(_('128K MP3 (Fastest)'))
        audio_128k.order = 0
        audio_128k.props.margin_left = MARGIN_LEFT
        audio_128k.connect('toggled', self.on_audio_toggled)
        format_box.pack_start(audio_128k, False, False, 0)
        audio_192k = Gtk.RadioButton(_('192K MP3'))
        audio_192k.order = 1
        audio_192k.join_group(audio_128k)
        audio_192k.props.margin_left = MARGIN_LEFT
        audio_192k.connect('toggled', self.on_audio_toggled)
        format_box.pack_start(audio_192k, False, False, 0)
        audio_320k = Gtk.RadioButton(_('320K MP3'))
        audio_320k.order = 2
        audio_320k.props.margin_left = MARGIN_LEFT
        audio_320k.connect('toggled', self.on_audio_toggled)
        audio_320k.join_group(audio_128k)
        format_box.pack_start(audio_320k, False, False, 0)
        audio_flac = Gtk.RadioButton(_('Flac Lossless (Best Quality)'))
        audio_flac.order = 3
        audio_flac.props.margin_left = MARGIN_LEFT
        audio_flac.connect('toggled', self.on_audio_toggled)
        audio_flac.join_group(audio_128k)
        format_box.pack_start(audio_flac, False, False, 0)
        for btn in audio_flac.get_group():
            btn.set_active(btn.order == self.app.conf['audio'])

        video_label = Widgets.BoldLabel(_('Prefered Video Format'))
        video_label.props.margin_top = MARGIN_TOP
        format_box.pack_start(video_label, False, False, 0)
        video_mp4l = Gtk.RadioButton(_('MP4L (Faster)'))
        video_mp4l.props.margin_left = MARGIN_LEFT
        video_mp4l.connect('toggled', self.on_video_toggled)
        video_mp4l.order = 0
        format_box.pack_start(video_mp4l, False, False, 0)
        video_mp4 = Gtk.RadioButton(_('MP4 (Better)'))
        video_mp4.props.margin_left = MARGIN_LEFT
        video_mp4.join_group(video_mp4l)
        video_mp4.connect('toggled', self.on_video_toggled)
        video_mp4.order = 1
        format_box.pack_start(video_mp4, False, False, 0)
        video_mp4.set_active(self.app.conf['video'] == video_mp4.order)

        # lyrics tab
        lrc_box = NoteTab()
        notebook.append_page(lrc_box, Gtk.Label(_('Lyrics')))

        lrc_normal_text_label = Widgets.BoldLabel(_('Normal Text'))
        lrc_box.pack_start(lrc_normal_text_label, False, True, 0)

        lrc_normal_text_size = FontBox(_('text size'),
                                       app.conf,
                                       'lrc-text-size',
                                       use_margin=True)
        lrc_box.pack_start(lrc_normal_text_size, False, True, 0)

        lrc_normal_text_color = ColorBox(_('text color'),
                                         app.conf,
                                         'lrc-text-color',
                                         use_margin=True)
        lrc_box.pack_start(lrc_normal_text_color, False, True, 0)
        lrc_normal_text_color.props.margin_bottom = 10

        lrc_highlighted_text_label = Widgets.BoldLabel(_('Highlighted Text'))
        lrc_box.pack_start(lrc_highlighted_text_label, False, True, 0)

        lrc_highlighted_text_size = FontBox(_('text size'),
                                            app.conf,
                                            'lrc-highlighted-text-size',
                                            use_margin=True)
        lrc_box.pack_start(lrc_highlighted_text_size, False, True, 0)

        lrc_highlighted_text_color = ColorBox(_('text color'),
                                              app.conf,
                                              'lrc-highlighted-text-color',
                                              use_margin=True)
        lrc_highlighted_text_color.props.margin_bottom = 10
        lrc_box.pack_start(lrc_highlighted_text_color, False, True, 0)

        lrc_word_back_color = ColorBox(_('Lyrics Text Background color'),
                                       app.conf, 'lrc-back-color')
        lrc_box.pack_start(lrc_word_back_color, False, True, 0)

        # folders tab
        folder_box = NoteTab()
        notebook.append_page(folder_box, Gtk.Label(_('Folders')))

        song_folder_label = Widgets.BoldLabel(_('Place to store sogns'))
        folder_box.pack_start(song_folder_label, False, False, 0)
        song_folder = ChooseFolder(self, 'song-dir',
                                   _('Moving cached songs to new folder'))
        folder_box.pack_start(song_folder, False, False, 0)

        mv_folder_label = Widgets.BoldLabel(_('Place to store MVs'))
        mv_folder_label.props.margin_top = MARGIN_TOP
        folder_box.pack_start(mv_folder_label, False, False, 0)
        mv_folder = ChooseFolder(self, 'mv-dir',
                                 _('Moving cached MVs to new folder'))
        folder_box.pack_start(mv_folder, False, False, 0)

        self.notebook = notebook

        # shortcut tab
        self.init_shortcut_tab()