Beispiel #1
0
 def create_statistics_config(self):
     it, page_vbox = self.new_page_box(None, _("Statistics"))
     box, category_vbox = gu.hig_category_vbox(
         _("Statistics from 3.15 and older"))
     page_vbox.pack_start(box, False, False, 0)
     self.g_old_stat_info = Gtk.Label()
     self.g_old_stat_info.set_line_wrap(True)
     self.g_old_stat_info.set_alignment(0.0, 0.5)
     category_vbox.pack_start(self.g_old_stat_info, False, False, 0)
     #
     self.g_delete_old_statistics = Gtk.Button(stock=Gtk.STOCK_DELETE)
     self.g_delete_old_statistics.connect('clicked',
                                          self.delete_obsolete_statistics)
     category_vbox.pack_start(self.g_delete_old_statistics, False, False, 0)
     box, category_vbox = gu.hig_category_vbox(_("Statistics"))
     page_vbox.pack_start(box, False, False, 0)
     self.g_stat_info = Gtk.Label()
     self.g_stat_info.set_line_wrap(True)
     self.g_stat_info.set_alignment(0.0, 0.5)
     category_vbox.pack_start(self.g_stat_info, False, False, 0)
     b = Gtk.Button(stock=Gtk.STOCK_DELETE)
     b.connect('clicked', self.delete_statistics)
     category_vbox.pack_start(b, False, False, 0)
     self.update_statistics_info()
     self.update_old_statistics_info()
Beispiel #2
0
    def create_user_config(self):
        it, page_vbox = self.new_page_box(None, _("User"))
        box, category_vbox = gu.hig_category_vbox(_("User's Vocal Range"))
        page_vbox.pack_start(box, False, False, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        self.g_highest_singable = notenamespinbutton.NotenameSpinButton(
            self.get_string('user/highest_pitch'))
        box = gu.hig_label_widget(_("Highest pitch:"),
                                  self.g_highest_singable,
                                  sizegroup)
        category_vbox.pack_start(box, True, True, 0)

        self.g_lowest_singable = notenamespinbutton.NotenameSpinButton(
            self.get_string('user/lowest_pitch'))
        box = gu.hig_label_widget(_("Lowest pitch:"),
                                  self.g_lowest_singable,
                                  sizegroup)
        category_vbox.pack_start(box, True, True, 0)
        notenamespinbutton.nNotenameRangeController(
                  self.g_lowest_singable, self.g_highest_singable,
                  mpd.LOWEST_NOTENAME, mpd.HIGHEST_NOTENAME,
                  'user', 'lowest_pitch', 'highest_pitch')


        box, category_vbox = gu.hig_category_vbox(_("Sex"))
        page_vbox.pack_start(box, False, False, 0)
        self.g_sex_male = Gtk.RadioButton.new_with_mnemonic(None, _("_Male"))
        self.g_sex_male.connect('toggled', lambda w: self.set_string('user/sex', 'male'))
        category_vbox.pack_start(self.g_sex_male, False, False, 0)
        self.g_sex_female = Gtk.RadioButton.new_with_mnemonic_from_widget(self.g_sex_male, _("_Female or child"))
        self.g_sex_female.connect('toggled', lambda w: self.set_string('user/sex', 'female'))
        category_vbox.pack_start(self.g_sex_female, False, False, 0)
        if self.get_string('user/sex') == 'female':
            self.g_sex_female.set_active(True)
Beispiel #3
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        grid = Gtk.Grid()
        grid.set_row_spacing(gu.hig.SPACE_SMALL)
        grid.set_column_spacing(gu.hig.SPACE_SMALL)
        self.g_buttons = fill_grid(Gtk.Button, grid)
        for key, button in list(self.g_buttons.items()):
            button.connect('clicked', self.on_left_click, key)
        self.practise_box.pack_start(grid, False, False, gu.hig.SPACE_SMALL)
        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda _o, self=self: self.m_t.play_question()),
            ('give_up', self.give_up))
        self.practise_box.show_all()
        ###############
        # config_grid #
        ###############
        # FIXME we need a ComboBox
        # self.g_random = gu.nCheckButton(self.m_exname, 'random_tonic', _("Random transpose"))
        # self.g_config_grid.attach(self.g_random, 0, 0, 1, 1)
        #
        self.g_tones_category, box = gu.hig_category_vbox(_("Tones"))
        self.g_config_grid.attach(self.g_tones_category, 0, 2, 3, 1)
        self.g_tone_selector = nConfigButtons(self.m_exname, 'tones')
        self.g_tone_selector.show_all()
        box.pack_start(self.g_tone_selector, False, False, 0)
        self.g_many_octaves = b = gu.nCheckButton('toneincontext', 'many_octaves',
            _("Many octaves"))
        self.g_config_grid.attach(b, 0, 3, 1, 1)
        # Cadences
        self.g_cadences_category, self.g_cadences = gu.hig_category_vbox(_("Cadences"))
        self.g_cadences.show()
        self.g_config_grid.attach(self.g_cadences_category, 0, 4, 1, 1)
        #

        def _ff(var):
            if self.m_t.m_custom_mode:
                # If we are running in custom mode, then the user can
                # select himself what intervals to practise. And then
                # we have to reset the exercise.
                # self.on_end_practise()
                # self.on_start_practise()
                self.cancel_question()
        self.add_watch('tones', _ff)
        ##############
        # Statistics #
        ##############
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                   _("Tone in cadence"))
        #
        self.g_statview = StatisticsViewer(self.m_t)
        self.g_statview.show()
        self.g_notebook.append_page(self.g_statview, Gtk.Label(label=_("Statistics")))
        self.g_notebook.connect(
            'switch_page', self.g_statview.update)
Beispiel #4
0
    def create_midi_config(self):
        it, page_vbox = self.new_page_box(None, _("Instruments"))
        vbox, category_vbox = gu.hig_category_vbox(_("Tempo"))
        page_vbox.pack_start(vbox, False, False, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        tempo_hbox = Gtk.Box(spacing=6)
        self.g_default_bpm = gu.nSpinButton(
            'config', 'default_bpm',
            Gtk.Adjustment(self.get_int('config/default_bpm'), 10, 500, 1, 10))
        self.g_arpeggio_bpm = gu.nSpinButton(
            'config', 'arpeggio_bpm',
            Gtk.Adjustment(self.get_int('config/arpeggio_bpm'), 10, 500, 1,
                           10))
        for text, widget in [(_("_Default:"), self.g_default_bpm),
                             (_("A_rpeggio:"), self.g_arpeggio_bpm)]:
            label = Gtk.Label(_("BPM"))
            tempo_hbox.pack_start(
                gu.hig_label_widget(text, [widget, label], None), False, False,
                0)
            label.set_tooltip_text(_("Beats per minute"))
        category_vbox.pack_start(tempo_hbox, False, False, 0)

        box, category_vbox = gu.hig_category_vbox(_("Preferred Instrument"))
        page_vbox.pack_start(box, False, False, 0)
        self.g_instrsel = nInstrumentSelector('config', 'preferred_instrument',
                                              None)
        category_vbox.pack_start(self.g_instrsel, False, False, 0)

        box, category_vbox = gu.hig_category_vbox(_("Chord Instruments"))
        page_vbox.pack_start(box, False, False, 0)
        self.g_instrument_configurator  \
              = InstrumentConfigurator("config", 3,
                    _("Use different instruments for chords and harmonic intervals"))
        category_vbox.pack_start(self.g_instrument_configurator, False, False,
                                 0)

        vbox, category_box = gu.hig_category_vbox(_("Percussion Instruments"))
        page_vbox.pack_start(vbox, False, False, 0)
        category_box.pack_start(
            gu.hig_label_widget(
                _("Count in:"),
                gu.PercussionNameButton("config", "countin_perc", "Claves"),
                sizegroup, True, True), True, True, 0)
        category_box.pack_start(
            gu.hig_label_widget(
                _("Rhythm:"),
                gu.PercussionNameButton("config", "rhythm_perc", "Side Stick"),
                sizegroup, True, True), False, False, 0)
Beispiel #5
0
    def create_midi_config(self):
        it, page_vbox = self.new_page_box(None, _("Instruments"))
        vbox, category_vbox = gu.hig_category_vbox(_("Tempo"))
        page_vbox.pack_start(vbox, False)
        sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        tempo_hbox = gtk.HBox(spacing=6)
        self.g_default_bpm = gu.nSpinButton('config', 'default_bpm',
            gtk.Adjustment(self.get_int('config/default_bpm'), 10, 500, 1, 10))
        self.g_arpeggio_bpm = gu.nSpinButton('config', 'arpeggio_bpm',
            gtk.Adjustment(self.get_int('config/arpeggio_bpm'), 10, 500, 1, 10))
        for text, widget in [(_("_Default:") ,self.g_default_bpm),
                             (_("A_rpeggio:") ,self.g_arpeggio_bpm)]:
            label = gtk.Label(text)
            label.set_alignment(0.0, 0.5)
            label.set_use_underline(True)
            tempo_hbox.pack_start(label, expand=False)
            label.set_mnemonic_widget(widget)
            tempo_hbox.pack_start(widget, expand=False)
            label = gtk.Label(_("BPM"))
            label.set_alignment(0.0, 0.5)
            label.set_tooltip_text(_("Beats per minute"))
            tempo_hbox.pack_start(label, expand=True)
        category_vbox.pack_start(tempo_hbox, False)

        box, category_vbox = gu.hig_category_vbox(_("Preferred Instrument"))
        page_vbox.pack_start(box, False)
        self.g_instrsel = nInstrumentSelector('config',
                        'preferred_instrument', sizegroup)
        category_vbox.pack_start(self.g_instrsel, False)

        box, category_vbox = gu.hig_category_vbox(_("Chord Instruments"))
        page_vbox.pack_start(box, False)
        self.g_instrument_configurator  \
              = InstrumentConfigurator("config", 3,
                    _("Use different instruments for chords and harmonic intervals"))
        category_vbox.pack_start(self.g_instrument_configurator, False)

        vbox, category_box = gu.hig_category_vbox(_("Percussion Instruments"))
        page_vbox.pack_start(vbox, False)
        category_box.pack_start(gu.hig_label_widget(
            _("Count in:"),
            gu.PercussionNameButton("config", "countin_perc", "Claves"),
            sizegroup, True, True))
        category_box.pack_start(gu.hig_label_widget(
            _("Rhythm:"),
            gu.PercussionNameButton("config", "rhythm_perc", "Side Stick"),
            sizegroup, True, True))
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        t = gtk.Table()
        self.g_buttons = fill_table(gtk.Button, t)
        for key, button in self.g_buttons.items():
            button.connect('clicked', self.on_left_click, key)
        self.practise_box.pack_start(t, False)
        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False)
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda _o, self=self: self.m_t.play_question()),
            ('give_up', self.give_up))
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.hig_dlg_vbox.spacing)
        self.g_random = gu.nCheckButton(self.m_exname, 'random_tonic',
                                        _("Random transpose"))
        self.config_box.pack_start(self.g_random, False)
        self._add_auto_new_question_gui(self.config_box)
        #
        self.g_tones_category, box = gu.hig_category_vbox(_("Tones"))
        self.config_box.pack_start(self.g_tones_category, False)
        self.g_tone_selector = nConfigButtons(self.m_exname, 'tones')
        self.g_tone_selector.show_all()
        box.pack_start(self.g_tone_selector, False)
        # Cadences
        self.g_cadences_category, self.g_cadences = gu.hig_category_vbox(
            _("Cadences"))
        self.g_cadences.show()
        self.config_box.pack_start(self.g_cadences_category, False)

        #
        def _ff(var):
            if self.m_t.m_custom_mode:
                # If we are running in custom mode, then the user can
                # select himself what intervals to practise. And then
                # we have to reset the exercise.
                #self.on_end_practise()
                #self.on_start_practise()
                self.cancel_question()

        self.add_watch('tones', _ff)
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                    _("Tone in cadence"))
Beispiel #7
0
    def show_path_info(self, w):
        if not self.g_path_info_dlg:
            self.g_path_info_dlg = Gtk.Dialog(_("_File locations").replace("_", ""), self,
                buttons=(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
            sc = Gtk.ScrolledWindow()
            sc.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER)
            self.g_path_info_dlg.vbox.pack_start(sc, True, True, 0)
            #
            vbox = gu.hig_dlg_vbox()
            sc.add_with_viewport(vbox)

            box1, box2 = gu.hig_category_vbox(_("_File locations").replace("_", ""))
            vbox.pack_start(box1, True, True, 0)
            sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
            # statistics.sqlite
            # win32 solfegerc
            # win32 langenviron.txt
            box2.pack_start(gu.hig_label_widget(_("Solfege application data:"), Gtk.Label(label=filesystem.app_data()), sizegroup), False, False, 0)
            box2.pack_start(gu.hig_label_widget(_("Solfege user data:"), Gtk.Label(label=filesystem.user_data()), sizegroup), False, False, 0)
            box2.pack_start(gu.hig_label_widget(_("Solfege config file:"), Gtk.Label(label=filesystem.rcfile()), sizegroup), False, False, 0)
            box2.pack_start(gu.hig_label_widget(_("Solfege installation directory:"), Gtk.Label(label=os.getcwd()), sizegroup), False, False, 0)
            box2.pack_start(gu.hig_label_widget(_("User manual in HTML format:"), Gtk.Label(label=os.path.join(os.getcwd(), "help")), sizegroup), False, False, 0)
            box2.pack_start(gu.hig_label_widget("gtk:", Gtk.Label(label=str(Gtk)), sizegroup), False, False, 0)
            box2.pack_start(gu.hig_label_widget("pyalsa:", Gtk.Label(label=str(alsaseq)), sizegroup), False, False, 0)
            box2.pack_start(gu.hig_label_widget("PYTHONHOME", Gtk.Label(os.environ.get('PYTHONHOME', 'Not defined')), sizegroup), False, False, 0)
            self.g_path_info_dlg.show_all()

            def f(*w):
                self.g_path_info_dlg.hide()
                return True
            self.g_path_info_dlg.connect('response', f)
            self.g_path_info_dlg.connect('delete-event', f)
            sc.set_size_request(min(vbox.size_request().width + gu.hig.SPACE_LARGE * 2,
                                    Gdk.Screen.width() * 0.9),
                                vbox.size_request().height)
Beispiel #8
0
 def __init__(self, teacher):
     abstract.Gui.__init__(self, teacher)
     t = Gtk.Table()
     self.g_buttons = fill_table(Gtk.Button, t)
     for key, button in self.g_buttons.items():
         button.connect('clicked', self.on_left_click, key)
     self.practise_box.pack_start(t, False, False, 0)
     self.g_flashbar = gu.FlashBar()
     self.g_flashbar.show()
     self.practise_box.pack_start(self.g_flashbar, False, False, 0)
     self.std_buttons_add(
         ('new', self.new_question),
         ('repeat', lambda _o, self=self: self.m_t.play_question()),
         ('give_up', self.give_up))
     self.practise_box.show_all()
     ##############
     # config_box #
     ##############
     self.config_box.set_spacing(gu.hig.SPACE_MEDIUM)
     self.g_random = gu.nCheckButton(self.m_exname, 'random_tonic', _("Random transpose"))
     self.config_box.pack_start(self.g_random, False, False, 0)
     self._add_auto_new_question_gui(self.config_box)
     #
     self.g_tones_category, box = gu.hig_category_vbox(_("Tones"))
     self.config_box.pack_start(self.g_tones_category, False, False, 0)
     self.g_tone_selector = nConfigButtons(self.m_exname, 'tones')
     self.g_tone_selector.show_all()
     box.pack_start(self.g_tone_selector, False, False, 0)
     # Cadences
     self.g_cadences_category, self.g_cadences = gu.hig_category_vbox(_("Cadences"))
     self.g_cadences.show()
     self.config_box.pack_start(self.g_cadences_category, False, False, 0)
     #
     def _ff(var):
         if self.m_t.m_custom_mode:
             # If we are running in custom mode, then the user can
             # select himself what intervals to practise. And then
             # we have to reset the exercise.
             #self.on_end_practise()
             #self.on_start_practise()
             self.cancel_question()
     self.add_watch('tones', _ff)
     self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                _("Tone in cadence"))
Beispiel #9
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.g_music_displayer = mpd.MusicDisplayer()
        self.practise_box.pack_start(self.g_music_displayer, False, False, 0)
        self.g_bb = QuestionNameButtonTable(self.m_t.m_exname)
        self.practise_box.pack_start(self.g_bb, False, False, 0)

        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)
        self.practise_box.set_spacing(gu.PAD)

        self.std_buttons_add(
            ('new', self.new_question),
            ('play_music', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
            ('repeat', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
            ('repeat_arpeggio', lambda w: self.run_exception_handled(self.m_t.m_P.play_question_arpeggio)),
            ('repeat_slowly', lambda w: self.run_exception_handled(self.m_t.m_P.play_question_slowly)),
            ('play_tonic', lambda w: self.run_exception_handled(self.m_t.play_tonic)),
            ('display_music', self.show_answer),
            ('show', self.show_answer),
            ('give_up', self.give_up),
        )

        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_border_width(12)
        self.config_box.set_spacing(18)
        self.add_random_transpose_gui()
        # -----------------------------------------
        self.g_select_questions_category_box, category_box= gu.hig_category_vbox(
            _("Questions to ask"))
        self.config_box.pack_start(self.g_select_questions_category_box, False, False, 0)
        self.g_select_questions = QuestionNameCheckButtonTable(self.m_t)
        self.g_select_questions.initialize(4, 0)
        category_box.pack_start(self.g_select_questions, False, False, 0)
        self.g_select_questions.show()
        # ------------------------------------------
        self._add_auto_new_question_gui(self.config_box)
        # ----------------------------------------------
        ##############
        # statistics #
        ##############
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                   _("Identify by name"))
        def _f(varname):
            self.m_t.q_status = self.QSTATUS_NO
            self.setup_action_area_buttons()
        self.add_watch('ask_for_names', _f)
Beispiel #10
0
 def create_statistics_config(self):
     it, page_vbox = self.new_page_box(None, _("Statistics"))
     box, category_vbox = gu.hig_category_vbox(_("Statistics from 3.15 and older"))
     page_vbox.pack_start(box, False, False, 0)
     self.g_old_stat_info = Gtk.Label()
     self.g_old_stat_info.set_line_wrap(True)
     self.g_old_stat_info.set_alignment(0.0, 0.5)
     category_vbox.pack_start(self.g_old_stat_info, False, False, 0)
     #
     self.g_delete_old_statistics = Gtk.Button(stock=Gtk.STOCK_DELETE)
     self.g_delete_old_statistics.connect('clicked', self.delete_obsolete_statistics)
     category_vbox.pack_start(self.g_delete_old_statistics, False, False, 0)
     box, category_vbox = gu.hig_category_vbox(_("Statistics"))
     page_vbox.pack_start(box, False, False, 0)
     self.g_stat_info = Gtk.Label()
     self.g_stat_info.set_line_wrap(True)
     self.g_stat_info.set_alignment(0.0, 0.5)
     category_vbox.pack_start(self.g_stat_info, False, False, 0)
     b = Gtk.Button(stock=Gtk.STOCK_DELETE)
     b.connect('clicked', self.delete_statistics)
     category_vbox.pack_start(b, False, False, 0)
     self.update_statistics_info()
     self.update_old_statistics_info()
Beispiel #11
0
    def create_user_config(self):
        it, page_vbox = self.new_page_box(None, _("User"))
        box, category_vbox = gu.hig_category_vbox(_("User's Vocal Range"))
        page_vbox.pack_start(box, False, False, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        self.g_highest_singable = notenamespinbutton.NotenameSpinButton(
            self.get_string('user/highest_pitch'))
        box = gu.hig_label_widget(_("Highest pitch:"), self.g_highest_singable,
                                  sizegroup)
        category_vbox.pack_start(box, True, True, 0)

        self.g_lowest_singable = notenamespinbutton.NotenameSpinButton(
            self.get_string('user/lowest_pitch'))
        box = gu.hig_label_widget(_("Lowest pitch:"), self.g_lowest_singable,
                                  sizegroup)
        category_vbox.pack_start(box, True, True, 0)
        notenamespinbutton.nNotenameRangeController(self.g_lowest_singable,
                                                    self.g_highest_singable,
                                                    mpd.LOWEST_NOTENAME,
                                                    mpd.HIGHEST_NOTENAME,
                                                    'user', 'lowest_pitch',
                                                    'highest_pitch')

        box, category_vbox = gu.hig_category_vbox(_("Sex"))
        page_vbox.pack_start(box, False, False, 0)
        self.g_sex_male = Gtk.RadioButton.new_with_mnemonic(None, _("_Male"))
        self.g_sex_male.connect('toggled',
                                lambda w: self.set_string('user/sex', 'male'))
        category_vbox.pack_start(self.g_sex_male, False, False, 0)
        self.g_sex_female = Gtk.RadioButton.new_with_mnemonic_from_widget(
            self.g_sex_male, _("_Female or child"))
        self.g_sex_female.connect(
            'toggled', lambda w: self.set_string('user/sex', 'female'))
        category_vbox.pack_start(self.g_sex_female, False, False, 0)
        if self.get_string('user/sex') == 'female':
            self.g_sex_female.set_active(True)
Beispiel #12
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.add_module_is_deprecated_label()
        self.g_hbox = hbox = gu.bHBox(self.practise_box)
        hbox.set_spacing(gu.PAD)
        spacebox = Gtk.HBox()
        hbox.pack_start(spacebox, True, True, 0)

        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.set_size_request(100, -1)
        hbox.pack_start(self.g_music_displayer, False, False, 0)
        spacebox = Gtk.HBox()
        hbox.pack_start(spacebox, True, True, 0)
        self.g_flashbar = gu.FlashBar()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)

        self.g_new = gu.bButton(self.action_area, _("_New chord"),
                                self.new_question)
        self.g_repeat = gu.bButton(
            self.action_area, _("_Repeat"),
            lambda w: self.run_exception_handled(self.m_t.m_P.play_question))
        self.g_repeat_arpeggio = gu.bButton(
            self.action_area, _("Repeat _arpeggio"), lambda w: self.
            run_exception_handled(self.m_t.m_P.play_question_arpeggio))
        self.g_give_up = gu.bButton(self.action_area, _("_Give up"),
                                    self.give_up)
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.PAD_SMALL)
        self.add_random_transpose_gui()
        # -----------------------------------------
        self.g_select_questions_category_box, category_box = gu.hig_category_vbox(
            _("Chord types to ask"))
        self.config_box.pack_start(self.g_select_questions_category_box, True,
                                   True, 0)
        self.g_select_questions = QuestionNameCheckButtonTable(self.m_t)
        self.g_select_questions.initialize(4, 0)
        category_box.pack_start(self.g_select_questions, False, False, 0)
        self.g_select_questions.show()
Beispiel #13
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.add_module_is_deprecated_label()
        self.g_hbox = hbox = gu.bHBox(self.practise_box)
        hbox.set_spacing(gu.PAD)
        spacebox = Gtk.HBox()
        hbox.pack_start(spacebox, True, True, 0)

        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.set_size_request(100, -1)
        hbox.pack_start(self.g_music_displayer, False, False, 0)
        spacebox = Gtk.HBox()
        hbox.pack_start(spacebox, True, True, 0)
        self.g_flashbar = gu.FlashBar()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)

        self.g_new = gu.bButton(self.action_area, _("_New chord"),
                                self.new_question)
        self.g_repeat = gu.bButton(self.action_area, _("_Repeat"),
              lambda w: self.run_exception_handled(self.m_t.m_P.play_question))
        self.g_repeat_arpeggio = gu.bButton(self.action_area,
              _("Repeat _arpeggio"),
              lambda w: self.run_exception_handled(self.m_t.m_P.play_question_arpeggio))
        self.g_give_up = gu.bButton(self.action_area, _("_Give up"),
                                    self.give_up)
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.PAD_SMALL)
        self.add_random_transpose_gui()
        # -----------------------------------------
        self.g_select_questions_category_box, category_box= gu.hig_category_vbox(
            _("Chord types to ask"))
        self.config_box.pack_start(self.g_select_questions_category_box, True, True, 0)
        self.g_select_questions = QuestionNameCheckButtonTable(self.m_t)
        self.g_select_questions.initialize(4, 0)
        category_box.pack_start(self.g_select_questions, False, False, 0)
        self.g_select_questions.show()
Beispiel #14
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.g_contents = Gtk.Table()
        hbox = gu.bHBox(self.practise_box, True, False)
        hbox.pack_start(Gtk.HBox(), True, True, 0)
        hbox.pack_start(self.g_contents, True, True, 0)
        hbox.pack_start(Gtk.HBox(), True, True, 0)
        self.g_contents.set_col_spacings(gu.PAD)
        self.g_contents.set_row_spacings(gu.PAD)

        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.set_size_request(100, -1)
        self.g_contents.attach(self.g_music_displayer, 1, 2, 1, 2)
        self.g_flashbar = gu.FlashBar()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)

        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat',
             lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
            ('repeat_arpeggio', lambda w: self.run_exception_handled(
                self.m_t.m_P.play_question_arpeggio)),
            ('give_up', self.give_up))
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.PAD_SMALL)
        self.add_random_transpose_gui()
        # -----------------------------------------
        self.g_select_questions_category_box, category_box = gu.hig_category_vbox(
            _("Chord types to ask"))
        self.config_box.pack_start(self.g_select_questions_category_box, True,
                                   True, 0)
        self.g_select_questions = QuestionNameCheckButtonTable(self.m_t)
        self.g_select_questions.initialize(4, 0)
        category_box.pack_start(self.g_select_questions, False, False, 0)
        self.g_select_questions.show()
Beispiel #15
0
    def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.g_contents = gtk.Table()
        hbox = gu.bHBox(self.practise_box, True, False)
        hbox.pack_start(gtk.HBox())
        hbox.pack_start(self.g_contents)
        hbox.pack_start(gtk.HBox())
        self.g_contents.set_col_spacings(gu.PAD)
        self.g_contents.set_row_spacings(gu.PAD)

        self.g_music_displayer = mpd.musicdisplayer.MusicDisplayer()
        self.g_music_displayer.set_size_request(100, -1)
        self.g_contents.attach(self.g_music_displayer, 1, 2, 1, 2)
        self.g_flashbar = gu.FlashBar()
        self.practise_box.pack_start(self.g_flashbar, False)

        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
            ('repeat_arpeggio', lambda w: self.run_exception_handled(self.m_t.m_P.play_question_arpeggio)),
            ('give_up', self.give_up))
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.PAD_SMALL)
        self.add_random_transpose_gui()
        # -----------------------------------------
        self.g_select_questions_category_box, category_box= gu.hig_category_vbox(
            _("Chord types to ask"))
        self.config_box.pack_start(self.g_select_questions_category_box, True)
        self.g_select_questions = QuestionNameCheckButtonTable(self.m_t)
        self.g_select_questions.initialize(4, 0)
        category_box.pack_start(self.g_select_questions, False)
        self.g_select_questions.show()
Beispiel #16
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)
Beispiel #17
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)
Beispiel #18
0
    def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        self.g_buttongrid = grid = Gtk.Grid()
        grid.set_row_spacing(gu.hig.SPACE_SMALL)
        grid.set_column_spacing(gu.hig.SPACE_SMALL)
        self.g_buttons = fill_grid(Gtk.Button, grid,
                                   labels[self.get_int("labels")][1])
        for key, button in list(self.g_buttons.items()):
            button.connect('clicked', self.on_left_click, key)
        self.practise_box.pack_start(grid, False, False, gu.hig.SPACE_SMALL)
        #########################################
        # GUI to practise what is answered wrong
        self.g_wgrid = Gtk.Grid()
        self.g_wgrid.set_row_spacing(gu.hig.SPACE_SMALL)
        self.g_wgrid.set_column_spacing(gu.hig.SPACE_SMALL)

        self.g_wgrid.attach(
            Gtk.Label(_("You answered:"), halign=Gtk.Align.END), 0, 1, 1, 1)
        self.g_wrong = Gtk.Label()
        self.g_wgrid.attach(self.g_wrong, 1, 1, 1, 1)
        b = Gtk.Button(_("Play cadence and tone"))
        b.connect('clicked', lambda w: self.m_t.play_wrong_guess())
        self.g_wgrid.attach(b, 2, 1, 1, 1)
        b = Gtk.Button(_("Play tone"))
        b.connect(
            'clicked', lambda w: soundcard.synth.play_track(
                self.m_t.get_track_of_tone(self.m_t.m_guessed)))
        self.g_wgrid.attach(b, 3, 1, 1, 1)
        b = Gtk.Button(_("Play tone with solution"))
        b.connect(
            'clicked', lambda w: soundcard.synth.play_track(
                self.m_t.get_track_of_solution(self.m_t.m_guessed)))
        self.g_wgrid.attach(b, 4, 1, 1, 1)

        self.g_wgrid.attach(
            Gtk.Label(_("Correct answer:"), halign=Gtk.Align.END), 0, 2, 1, 1)
        self.g_correct = Gtk.Label()
        self.g_wgrid.attach(self.g_correct, 1, 2, 1, 1)
        b = Gtk.Button(_("Play cadence and tone"))
        b.connect('clicked', lambda w: self.m_t.play_question())
        self.g_wgrid.attach(b, 2, 2, 1, 1)
        b = Gtk.Button(_("Play tone"))
        b.connect(
            'clicked', lambda w: soundcard.synth.play_track(
                self.m_t.get_track_of_tone(self.m_t.m_tone)))
        self.g_wgrid.attach(b, 3, 2, 1, 1)
        b = Gtk.Button(_("Play tone with solution"))
        b.connect(
            'clicked', lambda w: soundcard.synth.play_track(
                self.m_t.get_track_of_solution(self.m_t.m_tone)))
        self.g_wgrid.attach(b, 4, 2, 1, 1)
        l = Gtk.Label(
            _("You should listen to both tones several times and try to hear the difference and the similarity between the tones."
              ))
        self.g_wgrid.attach(l, 0, 3, 4, 1)
        b = Gtk.Button(_("Play cadence"))

        def play_cadence(*w):
            solfege.soundcard.synth.play_track(self.m_t.get_track_of_cadence())

        b.connect('clicked', play_cadence)
        self.g_wgrid.attach(b, 0, 4, 3, 1)
        b = Gtk.Button(_("Done"))

        def done(*w):
            self.end_practise_wrong_answer()
            self.new_question()

        b.connect('clicked', done)
        self.g_wgrid.attach(b, 3, 4, 2, 1)
        l.set_line_wrap(True)
        l.set_max_width_chars(40)
        self.practise_box.pack_start(self.g_wgrid, False, False, 0)
        ###########
        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda _o, self=self: self.m_t.play_question()))
        self.practise_box.show_all()
        self.g_wgrid.hide()
        ###############
        # config_grid #
        ###############
        # FIXME we need a ComboBox
        # self.g_random = gu.nCheckButton(self.m_exname, 'random_tonic', _("Random transpose"))
        # self.g_config_grid.attach(self.g_random, 0, 0, 1, 1)
        #
        self.g_config_grid.set_column_homogeneous(True)
        # Let us say the grid has 8 columns
        self.g_tones_category, box = gu.hig_category_vbox(_("Tones"))
        self.g_config_grid.attach(self.g_tones_category, 0, 2, 8, 1)
        self.g_tone_selector = nConfigButtons(self.m_exname, 'tones')
        box.pack_start(self.g_tone_selector, False, False, 0)
        self.g_many_octaves = b = gu.nCheckButton('toneincontext',
                                                  'many_octaves',
                                                  _("Many octaves"))
        self.g_config_grid.attach(b, 0, 3, 4, 1)
        # Cadences
        self.g_cadences_category, self.g_cadences = gu.hig_category_vbox(
            _("Cadences"))
        self.g_config_grid.attach(self.g_cadences_category, 0, 4, 4, 1)

        #

        def _ff(var):
            if self.m_t.m_custom_mode:
                # If we are running in custom mode, then the user can
                # select himself what intervals to practise. And then
                # we have to reset the exercise.
                # self.on_end_practise()
                # self.on_start_practise()
                self.cancel_question()

        self.add_watch('tones', _ff)

        # Tempo the music is played
        self.g_config_grid.attach(Gtk.Label("BPM:"), 0, 5, 1, 1)
        min_bpm, max_bpm = 30, 250
        scale = Gtk.Scale.new_with_range(Gtk.Orientation.HORIZONTAL, min_bpm,
                                         max_bpm, 10)
        scale.set_value_pos(Gtk.PositionType.LEFT)
        if not (min_bpm < self.m_t.get_int("bpm") < max_bpm):
            self.m_t.set_int("bpm", 90)
        scale.set_value(self.m_t.get_int("bpm"))

        def scale_value_changed(scale):
            self.m_t.set_int("bpm", int(scale.get_value()))

        scale.connect('value-changed', scale_value_changed)
        self.g_config_grid.attach(scale, 1, 5, 7, 1)

        # Select answer button labels
        combo = gu.nComboBox(self.m_t.m_exname, 'labels', labels[0][0],
                             [n[0] for n in labels])
        self.g_config_grid.attach(combo, 1, 6, 7, 1)
        combo.connect('changed', self.update_tone_button_labels)

        self.g_config_grid.show_all()
        ##############
        # Statistics #
        ##############
        self.g_statview = StatisticsViewer(self.m_t)
        self.g_statview.show()
        self.g_notebook.append_page(self.g_statview,
                                    Gtk.Label(label=_("Statistics")))
        self.g_notebook.connect('switch_page', self.g_statview.update)
Beispiel #19
0
    def __init__(self, initial_value, parent):
        Gtk.Dialog.__init__(self, _("Set transposition"), parent, 0, (
            Gtk.STOCK_CANCEL,
            Gtk.ResponseType.CANCEL,
            Gtk.STOCK_OK,
            Gtk.ResponseType.OK,
        ))
        dlg_vbox = gu.hig_dlg_vbox()
        self.vbox.pack_start(dlg_vbox, True, True, 0)
        xbox, vbox = gu.hig_category_vbox(
            _("Select how to do random transposition"))
        dlg_vbox.pack_start(xbox, True, True, 0)
        label = Gtk.Label(label=_(
            """You can read about the different types of transposition in the lesson file documentation available on the Help menu."""
        ))
        spin_sg = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        label.set_line_wrap(True)
        vbox.pack_start(label, True, True, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        self.m_buttons = {}
        self.m_spins = {}
        self.m_buttons['no'] = b1 = Gtk.RadioButton.new_with_label(
            None, _("No"))
        self.m_spins['no'] = []
        vbox.pack_start(b1, True, True, 0)
        self.m_buttons[
            'yes'] = b2 = Gtk.RadioButton.new_with_label_from_widget(
                b1, _("Yes"))
        self.m_spins['yes'] = []
        hbox = gu.bHBox(vbox)
        label_b = Gtk.Label()
        label_b.set_alignment(0.4, 0.5)
        label_b.set_markup('<span size="xx-large">♭</span>')
        label_x = Gtk.Label()
        label_x.set_alignment(0.4, 0.5)
        label_x.set_markup('<span size="xx-large">♯</span>')
        spin_sg.add_widget(label_b)
        spin_sg.add_widget(label_x)
        hbox.pack_start(b2, True, True, 0)
        hbox.pack_start(label_b, True, True, 0)
        hbox.pack_start(label_x, True, True, 0)

        self.m_buttons[
            'accidentals'] = Gtk.RadioButton.new_with_label_from_widget(
                b1, _("Fifths relative to C major/a minor"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['accidentals'], True, True, 0)
        self.m_spins['accidentals'] = [
            Gtk.SpinButton(
                adjustment=Gtk.Adjustment(0, -7, 7, 1, 1)),  # 0.0, 0),
            Gtk.SpinButton(adjustment=Gtk.Adjustment(0, -7, 7, 1, 1))
        ]  #, 0.0, 0)]
        spin_sg.add_widget(self.m_spins['accidentals'][0])
        spin_sg.add_widget(self.m_spins['accidentals'][1])
        hbox.pack_start(self.m_spins['accidentals'][0], True, True, 0)
        hbox.pack_start(self.m_spins['accidentals'][1], True, True, 0)
        gu.SpinButtonRangeController(self.m_spins['accidentals'][0],
                                     self.m_spins['accidentals'][1], -7, 7)

        self.m_buttons['key'] = Gtk.RadioButton.new_with_label_from_widget(
            b1, _i("Fifths relative to current key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['key'], True, True, 0)
        self.m_spins['key'] = [
            Gtk.SpinButton(
                adjustment=Gtk.Adjustment(0, -10, 10, 1, 1)),  # 0.0, 0),
            Gtk.SpinButton(adjustment=Gtk.Adjustment(0, -10, 10, 1, 1))
        ]  #, 0.0, 0)]
        hbox.pack_start(self.m_spins['key'][0], True, True, 0)
        hbox.pack_start(self.m_spins['key'][1], True, True, 0)
        gu.SpinButtonRangeController(self.m_spins['key'][0],
                                     self.m_spins['key'][1], -10, 10)

        self.m_buttons['atonal'] = Gtk.RadioButton.new_with_label_from_widget(
            b1, _i("Transpose notes without changing key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['atonal'], True, True, 0)
        self.m_spins['atonal'] = [
            Gtk.SpinButton(
                adjustment=Gtk.Adjustment(0, -10, 10, 1, 1)),  # 0.0, 0),
            Gtk.SpinButton(adjustment=Gtk.Adjustment(0, -10, 10, 1, 1))
        ]  #, 0.0, 0)]
        hbox.pack_start(self.m_spins['atonal'][0], True, True, 0)
        hbox.pack_start(self.m_spins['atonal'][1], True, True, 0)
        gu.SpinButtonRangeController(self.m_spins['atonal'][0],
                                     self.m_spins['atonal'][1], -10, 10)

        self.m_buttons[
            'semitones'] = Gtk.RadioButton.new_with_label_from_widget(
                b1, _("Semitones"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['semitones'], True, True, 0)
        self.m_spins['semitones'] = [
            Gtk.SpinButton(
                adjustment=Gtk.Adjustment(0, -100, 100, 1, 1)),  #, 0.0, 0),
            Gtk.SpinButton(adjustment=Gtk.Adjustment(0, -100, 100, 1, 1))
        ]  #, 0.0, 0)]
        hbox.pack_start(self.m_spins['semitones'][0], True, True, 0)
        hbox.pack_start(self.m_spins['semitones'][1], True, True, 0)
        gu.SpinButtonRangeController(self.m_spins['semitones'][0],
                                     self.m_spins['semitones'][1], -100, 100)
        for n, w in self.m_buttons.items():
            sizegroup.add_widget(w)
            for ww in self.m_spins[n]:
                ww.set_sensitive(False)
            w.connect('clicked', self.on_spins_clicked, n)
        if initial_value[0] == False:
            k = 'no'
        elif initial_value[0] == True:
            k = 'yes'
        else:
            k = initial_value[0]
        self.m_buttons[k].set_active(True)
        if k in ('accidentals', 'key', 'semitones', 'atonal'):
            t, v1, v2 = initial_value
            # FIXME Because of the RangeController, we have to do this
            # twice to be sure both values are set properly.
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
        self.show_all()
Beispiel #20
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)
    def __init__(self, initial_value, parent):
        gtk.Dialog.__init__(self, _("Set transposition"), parent, 0,
           (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_OK, gtk.RESPONSE_OK,
            ))
        dlg_vbox = gu.hig_dlg_vbox()
        self.vbox.pack_start(dlg_vbox)
        xbox, vbox = gu.hig_category_vbox(_("Select how to do random transposition"))
        dlg_vbox.pack_start(xbox)
        label = gtk.Label(_("""You can read about the different types of transposition in the lesson file documentation available on the Help menu."""))
        spin_sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        label.set_line_wrap(True)
        vbox.pack_start(label)
        sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        self.m_buttons = {}
        self.m_spins = {}
        self.m_buttons['no'] = b1 = gtk.RadioButton(None, _("No"))
        self.m_spins['no'] = []
        vbox.pack_start(b1)
        self.m_buttons['yes'] = b2 = gtk.RadioButton(b1, _("Yes"))
        self.m_spins['yes'] = []
        hbox = gu.bHBox(vbox)
        label_b = gtk.Label()
        label_b.set_alignment(0.4, 0.5)
        label_b.set_markup('<span size="xx-large">♭</span>')
        label_x = gtk.Label()
        label_x.set_alignment(0.4, 0.5)
        label_x.set_markup('<span size="xx-large">♯</span>')
        spin_sg.add_widget(label_b)
        spin_sg.add_widget(label_x)
        hbox.pack_start(b2)
        hbox.pack_start(label_b)
        hbox.pack_start(label_x)

        self.m_buttons['accidentals'] = gtk.RadioButton(b1, _("Fifths relative to C major/a minor"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['accidentals'])
        self.m_spins['accidentals'] = [
            gtk.SpinButton(gtk.Adjustment(0, -7, 7, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -7, 7, 1, 1), 0.0, 0)]
        spin_sg.add_widget(self.m_spins['accidentals'][0])
        spin_sg.add_widget(self.m_spins['accidentals'][1])
        hbox.pack_start(self.m_spins['accidentals'][0])
        hbox.pack_start(self.m_spins['accidentals'][1])
        gu.SpinButtonRangeController(self.m_spins['accidentals'][0],
                                     self.m_spins['accidentals'][1],
                                     -7, 7)

        self.m_buttons['key'] = gtk.RadioButton(b1, _i("Fifths relative to current key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['key'])
        self.m_spins['key'] = [
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0)]
        hbox.pack_start(self.m_spins['key'][0])
        hbox.pack_start(self.m_spins['key'][1])
        gu.SpinButtonRangeController(self.m_spins['key'][0],
                                     self.m_spins['key'][1],
                                     -10, 10)

        self.m_buttons['atonal'] = gtk.RadioButton(b1, _i("Transpose notes without changing key"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['atonal'])
        self.m_spins['atonal'] = [
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -10, 10, 1, 1), 0.0, 0)]
        hbox.pack_start(self.m_spins['atonal'][0])
        hbox.pack_start(self.m_spins['atonal'][1])
        gu.SpinButtonRangeController(self.m_spins['atonal'][0],
                                     self.m_spins['atonal'][1],
                                     -10, 10)

        self.m_buttons['semitones'] = gtk.RadioButton(b1, _("Semitones"))
        hbox = gu.bHBox(vbox)
        hbox.pack_start(self.m_buttons['semitones'])
        self.m_spins['semitones'] = [
            gtk.SpinButton(gtk.Adjustment(0, -100, 100, 1, 1), 0.0, 0),
            gtk.SpinButton(gtk.Adjustment(0, -100, 100, 1, 1), 0.0, 0)]
        hbox.pack_start(self.m_spins['semitones'][0])
        hbox.pack_start(self.m_spins['semitones'][1])
        hbox.pack_start(self.m_spins['semitones'][0])
        hbox.pack_start(self.m_spins['semitones'][1])
        gu.SpinButtonRangeController(self.m_spins['semitones'][0],
                                     self.m_spins['semitones'][1],
                                     -100, 100)
        for n, w in self.m_buttons.items():
            sizegroup.add_widget(w)
            for ww in self.m_spins[n]:
                ww.set_sensitive(False)
            w.connect('clicked', self.on_spins_clicked, n)
        if initial_value[0] == False:
            k = 'no'
        elif initial_value[0] == True:
            k = 'yes'
        else:
            k = initial_value[0]
        self.m_buttons[k].set_active(True)
        if k in ('accidentals', 'key', 'semitones', 'atonal'):
            t, v1, v2 = initial_value
            # FIXME Because of the RangeController, we have to do this
            # twice to be sure both values are set properly.
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
            self.m_spins[t][1].set_value(v2)
            self.m_spins[t][0].set_value(v1)
        self.show_all()
Beispiel #22
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)
Beispiel #23
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)
Beispiel #24
0
    def show_path_info(self, w):
        if not self.g_path_info_dlg:
            self.g_path_info_dlg = Gtk.Dialog(
                _("_File locations").replace("_", ""),
                self,
                buttons=(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
            sc = Gtk.ScrolledWindow()
            sc.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER)
            self.g_path_info_dlg.vbox.pack_start(sc, True, True, 0)
            #
            vbox = gu.hig_dlg_vbox()
            sc.add_with_viewport(vbox)

            box1, box2 = gu.hig_category_vbox(
                _("_File locations").replace("_", ""))
            vbox.pack_start(box1, True, True, 0)
            sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
            # statistics.sqlite
            # win32 solfegerc
            # win32 langenviron.txt
            box2.pack_start(
                gu.hig_label_widget(_("Solfege application data:"),
                                    Gtk.Label(label=filesystem.app_data()),
                                    sizegroup), False, False, 0)
            box2.pack_start(
                gu.hig_label_widget(_("Solfege user data:"),
                                    Gtk.Label(label=filesystem.user_data()),
                                    sizegroup), False, False, 0)
            box2.pack_start(
                gu.hig_label_widget(_("Solfege config file:"),
                                    Gtk.Label(label=filesystem.rcfile()),
                                    sizegroup), False, False, 0)
            box2.pack_start(
                gu.hig_label_widget(_("Solfege installation directory:"),
                                    Gtk.Label(label=os.getcwd()), sizegroup),
                False, False, 0)
            box2.pack_start(
                gu.hig_label_widget(
                    _("User manual in HTML format:"),
                    Gtk.Label(label=os.path.join(os.getcwd(), "help")),
                    sizegroup), False, False, 0)
            box2.pack_start(
                gu.hig_label_widget("gtk:", Gtk.Label(label=str(Gtk)),
                                    sizegroup), False, False, 0)
            box2.pack_start(
                gu.hig_label_widget("pyalsa:", Gtk.Label(label=str(alsaseq)),
                                    sizegroup), False, False, 0)
            box2.pack_start(
                gu.hig_label_widget(
                    "PYTHONHOME",
                    Gtk.Label(os.environ.get('PYTHONHOME', 'Not defined')),
                    sizegroup), False, False, 0)
            self.g_path_info_dlg.show_all()

            def f(*w):
                self.g_path_info_dlg.hide()
                return True

            self.g_path_info_dlg.connect('response', f)
            self.g_path_info_dlg.connect('delete-event', f)
            sc.set_size_request(
                min(vbox.size_request().width + gu.hig.SPACE_LARGE * 2,
                    Gdk.Screen.width() * 0.9),
                vbox.size_request().height)