Beispiel #1
0
def generate_csound_intonation():
    # We don't specify a lessonfile manager since we don't need
    # any of the methods that depend on it.
    page = fp.Page(u"Experimental CSound exercises", fp.Column())
    fileheader = fp.FileHeader(1, page)
    section = fp.LinkList(u"Melodic intervals")
    page[-1].append(section)
    for idx, cname in enumerate(interval_names):
        subpage = fp.Page(Interval(cname).get_cname().title(), fp.Column())
        section.append(subpage)
        sect = fp.LinkList(Interval(cname).get_cname().title())
        subpage[-1].append(sect)
        for cent in cents:
            csound_intonation2(False, cname, cent)
            sect.append("solfege:lesson-files/csound-intonation-%s-%icent" %
                        (iname_to_fn(cname), cent))
    section = fp.LinkList(u"Harmonic intervals")
    col = fp.Column()
    page.append(col)
    page[-1].append(section)
    for idx, cname in enumerate(interval_names):
        subpage = fp.Page(Interval(cname).get_cname().title(), fp.Column())
        section.append(subpage)
        sect = fp.LinkList(Interval(cname).get_cname().title())
        subpage[-1].append(sect)
        for cent in cents:
            csound_intonation2(True, cname, cent)
            sect.append(
                "solfege:lesson-files/csound-intonation-harmonic-%s-%icent" %
                (iname_to_fn(cname), cent))
    f = codecs.open("exercises/standard/csound-tree.txt", "w", "utf-8")
    fileheader.dump(f)
    f.close()
Beispiel #2
0
 def _search(self, substring, C_locale, only_tests):
     """
     substring - the string to search for
     C_locale - True if we should search in the untranslated titles
     only_tests - True if we should only return exercises that have
                  tests
     """
     logging.debug("search: '%s'", substring)
     self.compile_search_pattern(substring)
     page = frontpage.Page(listitems=frontpage.Column())
     cur_topic = None
     # the last topic appended to the page
     last_topic = None
     found = set()
     for child in self.m_page.iterate_flattened():
         if isinstance(child, frontpage.LinkList):
             cur_topic = child
         if isinstance(child, str):
             try:
                 if self.is_match(child, C_locale) and child not in found:
                     if only_tests and not lessonfile.infocache.get(
                             child, 'test'):
                         continue
                     if cur_topic != last_topic:
                         page[0].append(frontpage.LinkList(
                             cur_topic.m_name))
                         last_topic = cur_topic
                     found.add(child)
                     page[0][-1].append(child)
             except lessonfile.infocache.InfoCacheException:
                 # Ignore missing lesson files and files with errors
                 pass
     return page
Beispiel #3
0
    def display_search_result(self,
                              searchfor,
                              result,
                              result_C,
                              display_only_tests=False):
        page = frontpage.Page('', frontpage.Column([]))
        column = page[0]
        location = None
        for rlist in result, result_C:
            if rlist is result:
                column.append(
                    frontpage.Paragraph(
                        _("Search results for “%s”:") % searchfor))
            else:
                column.append(
                    frontpage.Paragraph(
                        _("C-locale search results for “%s”:") % searchfor))

            for r in rlist:
                path, name = os.path.split(r)
                if path != location:
                    linklist = frontpage.LinkList(path,
                                                  C_locale=rlist == result_C)
                    column.append(linklist)
                    location = path
                linklist.append(r)
        column.append(frontpage.LinkList())
        self._display_data(page)
Beispiel #4
0
 def display_search_result(self, searchfor, result, result_C, display_only_tests=False):
     self._display_data(
       frontpage.Page(u'',
         frontpage.Column([
           frontpage.LinkList(
         _(u"Search results for “%s”:") % self.g_searchentry.get_text(),
           result),
           frontpage.LinkList(
         _(u"C-locale search results for “%s”:") % self.g_searchentry.get_text(),
           result_C),
           ])))
Beispiel #5
0
 def display_recent_tests(self, w):
     data = frontpage.Page(
         _('_Recent Tests').replace("_", ""), [
             frontpage.Column([
                 frontpage.LinkList(
                     _('_Recent Tests').replace("_", ""),
                     solfege.db.recent_tests(8))
             ])
         ])
     self.display_testpage(data, show_topics=True)
     self.get_view().g_searchbox.hide()
     self.set_title("GNU Solfege - " + _('_Recent Tests').replace("_", ""))
Beispiel #6
0
 def on_paste(self, btn, idx):
     assert Editor.clipboard, "Paste buttons should be insensitive when the clipboard is empty."
     pobj = Editor.clipboard.pop()
     if isinstance(pobj, pd.LinkList):
         mobj = pd.Page(pobj.m_name, [pd.Column(pobj)])
     else:
         mobj = pobj
     if idx == -1:
         self.m_model.append(mobj)
         self.g_link_box.pack_start(self.create_linkrow(mobj))
     else:
         self.m_model.insert(idx, mobj)
         row = self.create_linkrow(mobj)
         self.g_link_box.pack_start(row)
         self.g_link_box.reorder_child(row, idx)
Beispiel #7
0
 def display_user_exercises(self, w):
     self.set_title("GNU Solfege - " + _("User Exercises"))
     if not self.show_view('userview'):
         self.add_view(UserView(""), 'userview')
         self.get_view().g_searchentry.grab_focus()
         self.get_view().on_search()
     else:
         self.show_view('userview')
     col = frontpage.Column()
     page = frontpage.Page(_('User Exercises'), col)
     curdir = None
     linklist = None
     d = os.path.join(filesystem.user_data(), "exercises/user/lesson-files")
     linklist = frontpage.LinkList(d)
     col.append(linklist)
     for filename in lessonfile.infocache.iter_user_files(
             only_user_collection=True):
         linklist.append(filename)
     self.get_view().display_data(page)
Beispiel #8
0
 def _search(self, substring, C_locale, only_tests):
     """
     substring - the string to search for
     C_locale - True if we should search in the untranslated titles
     only_tests - True if we should only return exercises that have
                  tests
     """
     logging.debug("search: '%s'", substring)
     match_func = {
         False:
         lambda filename: substring in _no_xgettext(
             lessonfile.infocache.get(filename, 'title')).lower(),
         True:
         lambda filename: substring in lessonfile.infocache.get(
             filename, 'title').lower()
     }[C_locale]
     test_filter = {
         False: lambda filename: True,
         True: lambda filename: lessonfile.infocache.get(filename, 'test')
     }[C_locale]
     page = frontpage.Page(listitems=frontpage.Column())
     cur_topic = None
     # the last topic appended to the page
     last_topic = None
     found = set()
     for child in self.m_page.iterate_flattened():
         if isinstance(child, frontpage.LinkList):
             cur_topic = child
         if isinstance(child, unicode):
             try:
                 if (match_func(child)
                         and test_filter(child)) and child not in found:
                     if cur_topic != last_topic:
                         page[0].append(frontpage.LinkList(
                             cur_topic.m_name))
                         last_topic = cur_topic
                     found.add(child)
                     page[0][-1].append(child)
             except lessonfile.infocache.InfoCacheException:
                 # Ignore missing lesson files and files with errors
                 pass
     return page
Beispiel #9
0
 def __init__(self, filename=None):
     gtk.Window.__init__(self)
     logging.debug("fpeditor.Editor.__init__(%s)", filename)
     gu.EditorDialogBase.__init__(self, filename)
     self.set_default_size(800, 600)
     self.g_main_box = gtk.VBox()
     self.add(self.g_main_box)
     self.g_actiongroup.add_actions([
         ('GoBack', gtk.STOCK_GO_BACK, None, None, None, self.go_back),
     ])
     self.setup_toolbar()
     self.g_title_hbox = gtk.HBox()
     self.g_title_hbox.set_spacing(gu.hig.SPACE_SMALL)
     self.g_title_hbox.set_border_width(gu.hig.SPACE_SMALL)
     label = gtk.Label()
     label.set_markup(u"<b>%s</b>" % _("Front page title:"))
     self.g_title_hbox.pack_start(label, False)
     self.g_fptitle = gtk.Entry()
     self.g_title_hbox.pack_start(self.g_fptitle)
     self.g_main_box.pack_start(self.g_title_hbox, False)
     # This dict maps the windows created for all pages belonging to
     # the file.
     self.m_page_mapping = {}
     self.m_model = None
     if filename:
         self.load_file(filename)
     else:
         self.m_model = pd.Page(_("Untitled%s") % self.m_instance_number,
                 pd.Column())
         self.set_not_modified()
     self.add_page(Page(self.m_model, self))
     self.clipboard.update_buttons()
     self.show_all()
     self.add_to_instance_dict()
     self.g_fptitle.set_text(self.m_model.m_name)
     self.g_fptitle.connect('changed', self.on_frontpage_title_changed)
Beispiel #10
0
 def on_add_column(self, *btn):
     column = pd.Column()
     self.m_model.append(column)
     gcol = Column(column, self)
     gcol.show_all()
     self.g_column_box.pack_start(gcol)
Beispiel #11
0
 def on_add_link_to_new_page(self, menuitem):
     page = pd.Page(_("Untitled%s") % "", [pd.Column()])
     self.m_model.append(page)
     self.g_link_box.pack_start(self.create_linkrow(page))