예제 #1
0
 def _changed(widget, formatid):
     if widget.get_active() != -1:
         model = widget.opts.get_model()
         model.clear()
         format = format_info[formatid]
         for player_options in format['players'][widget.get_active()][1:]:
             model.append([player_options])
         widget.opts.get_child().set_text(format['players'][widget.get_active()][1])
     widget.testbutton.set_sensitive(bool(
         osutils.find_progs((widget.get_child().get_text().decode("utf-8"),))))
예제 #2
0
 def _changed(widget, formatid):
     if widget.get_active() != -1:
         widget.opts.get_model().clear()
         format = format_info[formatid]
         for player_options in format['players'][widget.get_active()][1:]:
             widget.opts.append_text(player_options)
         widget.opts.child.set_text(format['players'][widget.get_active()][1])
     self.set_string('sound/%s_player' % formatid,
                     widget.child.get_text())
     widget.testbutton.set_sensitive(bool(
         osutils.find_progs((widget.child.get_text(),))))
예제 #3
0
 def _changed(widget, formatid):
     if widget.get_active() != -1:
         model = widget.opts.get_model()
         model.clear()
         format = format_info[formatid]
         for player_options in format['players'][
                 widget.get_active()][1:]:
             model.append([player_options])
         widget.opts.get_child().set_text(
             format['players'][widget.get_active()][1])
     widget.testbutton.set_sensitive(
         bool(osutils.find_progs(
             (widget.get_child().get_text(), ))))
예제 #4
0
    def add_gui_for_external_programs(self, page_vbox):
        box, category_vbox = gu.hig_category_vbox(_("Audio File Players"))
        page_vbox.pack_start(box, False, False, 0)
        format_info = {}
        if sys.platform != 'win32':
            format_info = {'wav': {
                 # testfile is a file in lesson-files/share
                 'testfile': 'fifth-small-220.00.wav',
                 'label': _("WAV:"),
                 # players is a list of tuples. The tuple has to or more
                 # items. The first is the binary, and the rest is possible
                 # sets of command line options that might work.
                 # '/path/to/player', 'comandline', '
                 'players': [
                        ('gst-launch', 'playbin uri=file://%s',
                                       'filesrc location=%s ! wavparse ! alsasink'),
                        ('play', ''),
                        ('aplay', ''),
                        ('esdplay', ''),
                 ],
                }
            }
        format_info['midi'] = {
             'testfile': 'fanfare.midi',
             'label': _("MIDI:"),
             'players': [
                         ('gst-launch', 'playbin uri=file://%s',
                                        'filesrc location=exercises/standard/lesson-files/share/fanfare.midi ! wildmidi ! alsasink'),
                         ('timidity', '-idqq %s'),
                         ('drvmidi', ''),
                         ('playmidi', ''),
             ],
            }
        format_info['mp3'] = {
             'testfile': 'fanfare.mp3',
             'label': _("MP3:"),
             'players': [
                        ('gst-launch', 'playbin uri=file://%s',
                                       'filesrc location=%s ! mad ! alsasink'),
                        ('mpg123', ''),
                        ('alsaplayer', ''),
             ],
            }
        format_info['ogg'] = {
             'testfile': 'fanfare.ogg',
             'label': _("OGG:"),
             'players': [
                        ('gst-launch', 'playbin uri=file://%s',
                                       'filesrc location=%s ! oggdemux ! vorbisdec ! audioconvert ! alsasink'),
                        ('ogg123', ''),
                        ('alsaplayer', ''),
             ],
            }
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        for formatid, format in format_info.items():
            combo = gu.sComboBox('sound', '%s_player' % formatid, [p[0] for p in format['players']])
            combo.set_tooltip_text(_("Enter the name of the program. An absolute path is required only if the executable is not found on the PATH."))
            combo.opts = gu.sComboBox('sound', '%s_player_options' % formatid, 'NOT YET!')
            combo.opts.set_tooltip_text(_("The command line options required. Write %s where you want the name of the file to be played. Or omit it to have it added to the end of the string."))

            def _changed(widget, formatid):
                if widget.get_active() != -1:
                    model = widget.opts.get_model()
                    model.clear()
                    format = format_info[formatid]
                    for player_options in format['players'][widget.get_active()][1:]:
                        model.append([player_options])
                    widget.opts.get_child().set_text(format['players'][widget.get_active()][1])
                widget.testbutton.set_sensitive(bool(
                    osutils.find_progs((widget.get_child().get_text().decode("utf-8"),))))

            combo.connect('changed', _changed, formatid)
            testbutton = Gtk.Button(_("_Test").replace("_", ""))
            testbutton.set_tooltip_text(_("This button is clickable only if the binary is found."))
            combo.testbutton = testbutton
            testbutton.connect('clicked', self.test_XXX_player,
                           formatid, format['testfile'])
            testbutton.set_sensitive(bool(
                    osutils.find_progs((combo.get_child().get_text().decode("utf-8"),))))
            box = gu.hig_label_widget(format['label'],
                                      [combo, combo.opts, testbutton],
                                      sizegroup, True, True)
            category_vbox.pack_start(box, True, True, 0)
예제 #5
0
 def binary_changed_cb(widget, binary):
     widget.warning.props.visible = not bool(
         osutils.find_progs((cfg.get_string('programs/%s' % binary),)))
예제 #6
0
    def create_external_programs_config(self):
        it, page_vbox = self.new_page_box(None, _("External Programs"))
        box, category_vbox = gu.hig_category_vbox(_("Converters"))
        page_vbox.pack_start(box, False, False, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        # midi_to_wav
        self.g_wav_convertor = gu.sComboBox(
            'app', 'midi_to_wav_cmd', ['timidity'])
        self.g_wav_convertor_options = gu.sComboBox(
            'app', 'midi_to_wav_cmd_options', ["-Ow %(in)s -o %(out)s"])
        self.g_wav_convertor_options.set_entry_text_column(0)
        category_vbox.pack_start(
            gu.hig_label_widget(_("MIDI to WAV:"),
                (self.g_wav_convertor, self.g_wav_convertor_options),
                 sizegroup),
            False, False, 0)

        # wav_to_mp3
        self.g_mp3_convertor = gu.sComboBox(
            'app', 'wav_to_mp3_cmd', ["lame"])
        self.g_mp3_convertor_options = gu.sComboBox(
            'app', 'wav_to_mp3_cmd_options', ["%(in)s %(out)s"])
        category_vbox.pack_start(
            gu.hig_label_widget(_("WAV to MP3:"),
                (self.g_mp3_convertor, self.g_mp3_convertor_options),
                sizegroup),
            False, False, 0)

        # wav_to_ogg
        self.g_ogg_convertor = gu.sComboBox(
            "app", "wav_to_ogg_cmd", ["oggenc"])
        self.g_ogg_convertor_options = gu.sComboBox(
            "app", "wav_to_ogg_cmd_options", ["%(in)s"])
        category_vbox.pack_start(
            gu.hig_label_widget(_("WAV to OGG:"),
                (self.g_ogg_convertor, self.g_ogg_convertor_options),
                sizegroup),
            False, False, 0)

        self.add_gui_for_external_programs(page_vbox)
        ########
        # Misc #
        ########
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        box, category_vbox = gu.hig_category_vbox(_("Miscellaneous"))
        page_vbox.pack_start(box, False, False, 0)

        # CSound_("Musical MIDI Accompaniment:")
        for binary, label, bins in (
            ("csound", _("CSound:"), osutils.find_csound_executables()),
            ("mma", "MMA:", osutils.find_mma_executables(
                cfg.get_list("app/win32_ignore_drives"))),
            ("lilypond-book", _("Lilypond-book:"),
             osutils.find_progs(("lilypond-book", "lilypond-book.py"))),
            ("latex", "Latex:", osutils.find_progs(("latex",))),
            ("text-editor", _("Text editor:"), osutils.find_progs(("sensible-editor", "gvim", "gedit", "emacs", "notepad.exe"))),
            ):
            combo = gu.sComboBox("programs", binary, bins)
            def binary_changed_cb(widget, binary):
                widget.warning.props.visible = not bool(
                    osutils.find_progs((cfg.get_string('programs/%s' % binary),)))
            combo.warning = Gtk.Image()
            combo.warning.set_tooltip_text(_("Not found. Much of GNU Solfege will run fine without this program. You will get a message when the program is required, and the user manual will explain what you need it for."))
            combo.warning.set_from_stock(Gtk.STOCK_DIALOG_WARNING,
                                              Gtk.IconSize.SMALL_TOOLBAR)
            box = gu.hig_label_widget(label,
                                      [combo, combo.warning],
                                      sizegroup, True, True)
            category_vbox.pack_start(box, True, True, 0)
            combo.warning.props.no_show_all = True
            binary_changed_cb(combo, binary)
            combo.connect('changed', binary_changed_cb, binary)
예제 #7
0
 def csound_changed_cb(widget, bin):
     self.set_string('programs/%s' % bin, widget.child.get_text())
     widget.warning.props.visible = not bool(
         osutils.find_progs((cfg.get_string('programs/%s' % bin),)))
예제 #8
0
    def create_external_programs_config(self):
        it, page_vbox = self.new_page_box(None, _("External Programs"))
        box, category_vbox = gu.hig_category_vbox(_("Converters"))
        page_vbox.pack_start(box, False)
        sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        # midi_to_wav
        self.g_wav_convertor = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_wav_convertor.get_model().append(("timidity",))
        #
        self.g_wav_convertor_options = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_wav_convertor_options.get_model().append(("-Ow %(in)s -o %(out)s",))
        #
        category_vbox.pack_start(
            gu.hig_label_widget(_("MIDI to WAV:"),
               (self.g_wav_convertor, self.g_wav_convertor_options),
               sizegroup, True, True))
        #
        self.g_wav_convertor.child.set_text(
            self.get_string("app/midi_to_wav_cmd"))
        self.g_wav_convertor_options.child.set_text(
            self.get_string("app/midi_to_wav_cmd_options"))
        self.g_wav_convertor.connect('changed',
            lambda w: self.set_string('app/midi_to_wav_cmd',
                w.child.get_text()))
        self.g_wav_convertor_options.connect('changed',
            lambda w: self.set_string('app/midi_to_wav_cmd_options',
                w.child.get_text()))
        # wav_to_mp3
        self.g_mp3_convertor = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_mp3_convertor.get_model().append(("lame",))
        #
        self.g_mp3_convertor_options = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_mp3_convertor_options.get_model().append(("%(in)s %(out)s",))
        #
        category_vbox.pack_start(
            gu.hig_label_widget(_("WAV to MP3:"),
            (self.g_mp3_convertor, self.g_mp3_convertor_options),
            sizegroup, True, True))
        #
        self.g_mp3_convertor.child.set_text(
            self.get_string("app/wav_to_mp3_cmd"))
        self.g_mp3_convertor_options.child.set_text(
            self.get_string("app/wav_to_mp3_cmd_options"))
        self.g_mp3_convertor.connect('changed',
            lambda w: self.set_string('app/wav_to_mp3_cmd',
                w.child.get_text()))
        self.g_mp3_convertor_options.connect('changed',
            lambda w: self.set_string('app/wav_to_mp3_cmd_options',
                w.child.get_text()))
        # wav_to_ogg
        self.g_ogg_convertor = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_ogg_convertor.get_model().append(("oggenc",))
        #
        self.g_ogg_convertor_options = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_ogg_convertor_options.get_model().append(("%(in)s",))
        #
        category_vbox.pack_start(
            gu.hig_label_widget(_("WAV to OGG:"),
            (self.g_ogg_convertor, self.g_ogg_convertor_options),
            sizegroup, True, True))
        #
        self.g_ogg_convertor.child.set_text(
            self.get_string("app/wav_to_ogg_cmd"))
        self.g_ogg_convertor_options.child.set_text(
            self.get_string("app/wav_to_ogg_cmd_options"))
        self.g_ogg_convertor.connect('changed',
            lambda w: self.set_string('app/wav_to_ogg_cmd',
                w.child.get_text()))
        self.g_ogg_convertor_options.connect('changed',
            lambda w: self.set_string('app/wav_to_ogg_cmd_options',
                w.child.get_text()))

        self.add_gui_for_external_programs(page_vbox)
        ########
        # Misc #
        ########
        sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        box, category_vbox = gu.hig_category_vbox(_("Miscellaneous"))
        page_vbox.pack_start(box, False)

        # CSound_("Musical MIDI Accompaniment:")
        for bin, label, bins in (
            ("csound", _("CSound:"), osutils.find_csound_executables()),
            ("mma", "MMA:", osutils.find_mma_executables(
                cfg.get_list("app/win32_ignore_drives"))),
            ("lilypond-book", _("Lilypond-book:"),
             osutils.find_progs(("lilypond-book", "lilypond-book.py"))),
            ("latex", "Latex:", osutils.find_progs(("latex",))),
            ("text-editor", "Text editor:", osutils.find_progs(("sensible-editor", "gvim", "gedit", "emacs", "notepad.exe"))),
            ):
            liststore = gtk.ListStore(gobject.TYPE_STRING)
            for p in bins:
                liststore.append((p,))
            cbox_entry = gtk.ComboBoxEntry(liststore)
            cbox_entry.child.set_text(self.get_string("programs/%(bin)s" % locals()))
            def csound_changed_cb(widget, bin):
                self.set_string('programs/%s' % bin, widget.child.get_text())
                widget.warning.props.visible = not bool(
                    osutils.find_progs((cfg.get_string('programs/%s' % bin),)))
            cbox_entry.warning = gtk.Image()
            cbox_entry.warning.set_tooltip_text(_("Not found. Much of GNU Solfege will run fine without this program. You will get a message when the program is required, and the user manual will explain what you need it for."))
            cbox_entry.warning.set_from_stock(gtk.STOCK_DIALOG_WARNING,
                                              gtk.ICON_SIZE_SMALL_TOOLBAR)
            box = gu.hig_label_widget(label,
                                      [cbox_entry, cbox_entry.warning],
                                      sizegroup, True, True)
            category_vbox.pack_start(box)
            cbox_entry.warning.props.no_show_all = True
            csound_changed_cb(cbox_entry, bin)
            cbox_entry.connect('changed', csound_changed_cb, bin)
예제 #9
0
    def add_gui_for_external_programs(self, page_vbox):
        box, category_vbox = gu.hig_category_vbox(_("Audio File Players"))
        page_vbox.pack_start(box, False, False, 0)
        format_info = {}
        if sys.platform != 'win32':
            format_info = {
                'wav': {
                    # testfile is a file in lesson-files/share
                    'testfile':
                    'fifth-small-220.00.wav',
                    'label':
                    _("WAV:"),
                    # players is a list of tuples. The tuple has to or more
                    # items. The first is the binary, and the rest is possible
                    # sets of command line options that might work.
                    # '/path/to/player', 'comandline', '
                    'players': [
                        ('gst-launch', 'playbin uri=file://%s',
                         'filesrc location=%s ! wavparse ! alsasink'),
                        ('play', ''),
                        ('aplay', ''),
                        ('esdplay', ''),
                    ],
                }
            }
        format_info['midi'] = {
            'testfile':
            'fanfare.midi',
            'label':
            _("MIDI:"),
            'players': [
                ('gst-launch', 'playbin uri=file://%s',
                 'filesrc location=exercises/standard/lesson-files/share/fanfare.midi ! wildmidi ! alsasink'
                 ),
                ('timidity', '-idqq %s'),
                ('drvmidi', ''),
                ('playmidi', ''),
            ],
        }
        format_info['mp3'] = {
            'testfile':
            'fanfare.mp3',
            'label':
            _("MP3:"),
            'players': [
                ('gst-launch', 'playbin uri=file://%s',
                 'filesrc location=%s ! mad ! alsasink'),
                ('mpg123', ''),
                ('alsaplayer', ''),
            ],
        }
        format_info['ogg'] = {
            'testfile':
            'fanfare.ogg',
            'label':
            _("OGG:"),
            'players': [
                ('gst-launch', 'playbin uri=file://%s',
                 'filesrc location=%s ! oggdemux ! vorbisdec ! audioconvert ! alsasink'
                 ),
                ('ogg123', ''),
                ('alsaplayer', ''),
            ],
        }
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        for formatid, format in format_info.items():
            combo = gu.sComboBox('sound', '%s_player' % formatid,
                                 [p[0] for p in format['players']])
            combo.set_tooltip_text(
                _("Enter the name of the program. An absolute path is required only if the executable is not found on the PATH."
                  ))
            combo.opts = gu.sComboBox('sound', '%s_player_options' % formatid,
                                      'NOT YET!')
            combo.opts.set_tooltip_text(
                _("The command line options required. Write %s where you want the name of the file to be played. Or omit it to have it added to the end of the string."
                  ))

            def _changed(widget, formatid):
                if widget.get_active() != -1:
                    model = widget.opts.get_model()
                    model.clear()
                    format = format_info[formatid]
                    for player_options in format['players'][
                            widget.get_active()][1:]:
                        model.append([player_options])
                    widget.opts.get_child().set_text(
                        format['players'][widget.get_active()][1])
                widget.testbutton.set_sensitive(
                    bool(
                        osutils.find_progs((
                            widget.get_child().get_text().decode("utf-8"), ))))

            combo.connect('changed', _changed, formatid)
            testbutton = Gtk.Button(_("_Test").replace("_", ""))
            testbutton.set_tooltip_text(
                _("This button is clickable only if the binary is found."))
            combo.testbutton = testbutton
            testbutton.connect('clicked', self.test_XXX_player, formatid,
                               format['testfile'])
            testbutton.set_sensitive(
                bool(
                    osutils.find_progs(
                        (combo.get_child().get_text().decode("utf-8"), ))))
            box = gu.hig_label_widget(format['label'],
                                      [combo, combo.opts, testbutton],
                                      sizegroup, True, True)
            category_vbox.pack_start(box, True, True, 0)
예제 #10
0
 def binary_changed_cb(widget, binary):
     widget.warning.props.visible = not bool(
         osutils.find_progs(
             (cfg.get_string('programs/%s' % binary), )))
예제 #11
0
    def create_external_programs_config(self):
        it, page_vbox = self.new_page_box(None, _("External Programs"))
        box, category_vbox = gu.hig_category_vbox(_("Converters"))
        page_vbox.pack_start(box, False, False, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        # midi_to_wav
        self.g_wav_convertor = gu.sComboBox('app', 'midi_to_wav_cmd',
                                            ['timidity'])
        self.g_wav_convertor_options = gu.sComboBox('app',
                                                    'midi_to_wav_cmd_options',
                                                    ["-Ow %(in)s -o %(out)s"])
        self.g_wav_convertor_options.set_entry_text_column(0)
        category_vbox.pack_start(
            gu.hig_label_widget(
                _("MIDI to WAV:"),
                (self.g_wav_convertor, self.g_wav_convertor_options),
                sizegroup), False, False, 0)

        # wav_to_mp3
        self.g_mp3_convertor = gu.sComboBox('app', 'wav_to_mp3_cmd', ["lame"])
        self.g_mp3_convertor_options = gu.sComboBox('app',
                                                    'wav_to_mp3_cmd_options',
                                                    ["%(in)s %(out)s"])
        category_vbox.pack_start(
            gu.hig_label_widget(
                _("WAV to MP3:"),
                (self.g_mp3_convertor, self.g_mp3_convertor_options),
                sizegroup), False, False, 0)

        # wav_to_ogg
        self.g_ogg_convertor = gu.sComboBox("app", "wav_to_ogg_cmd",
                                            ["oggenc"])
        self.g_ogg_convertor_options = gu.sComboBox("app",
                                                    "wav_to_ogg_cmd_options",
                                                    ["%(in)s"])
        category_vbox.pack_start(
            gu.hig_label_widget(
                _("WAV to OGG:"),
                (self.g_ogg_convertor, self.g_ogg_convertor_options),
                sizegroup), False, False, 0)

        self.add_gui_for_external_programs(page_vbox)
        ########
        # Misc #
        ########
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        box, category_vbox = gu.hig_category_vbox(_("Miscellaneous"))
        page_vbox.pack_start(box, False, False, 0)

        # CSound_("Musical MIDI Accompaniment:")
        for binary, label, bins in (
            ("csound", _("CSound:"), osutils.find_csound_executables()),
            ("mma", "MMA:",
             osutils.find_mma_executables(
                 cfg.get_list("app/win32_ignore_drives"))),
            ("lilypond-book", _("Lilypond-book:"),
             osutils.find_progs(("lilypond-book", "lilypond-book.py"))),
            ("latex", "Latex:", osutils.find_progs(("latex", ))),
            ("text-editor", _("Text editor:"),
             osutils.find_progs(("sensible-editor", "gvim", "gedit", "emacs",
                                 "notepad.exe"))),
        ):
            combo = gu.sComboBox("programs", binary, bins)

            def binary_changed_cb(widget, binary):
                widget.warning.props.visible = not bool(
                    osutils.find_progs(
                        (cfg.get_string('programs/%s' % binary), )))

            combo.warning = Gtk.Image()
            combo.warning.set_tooltip_text(
                _("Not found. Much of GNU Solfege will run fine without this program. You will get a message when the program is required, and the user manual will explain what you need it for."
                  ))
            combo.warning.set_from_stock(Gtk.STOCK_DIALOG_WARNING,
                                         Gtk.IconSize.SMALL_TOOLBAR)
            box = gu.hig_label_widget(label, [combo, combo.warning], sizegroup,
                                      True, True)
            category_vbox.pack_start(box, True, True, 0)
            combo.warning.props.no_show_all = True
            binary_changed_cb(combo, binary)
            combo.connect('changed', binary_changed_cb, binary)