Example #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()
Example #2
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)
Example #3
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),
           ])))
Example #4
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
Example #5
0
 def on_add_section(self, btn):
     # We write "Untitled%s" % "" instead of just "Untitled" here
     # since "Untitled%s" is already translated in many languages.
     section = pd.LinkList(_("Untitled%s" % ""))
     self.m_model.append(section)
     gui_section = Section(section, self)
     self.g_section_box.pack_start(gui_section, False)
     gui_section.show_all()
Example #6
0
 def ff(btn, page):
     if id(page) in editor_of(self).m_page_mapping:
         editor_of(self).show_page_id(id(page))
     else:
         if not page[0]:
             page[0].append(pd.LinkList(link_this.m_name))
         p = Page(page, parent_page(self))
         p.show()
         editor_of(self).add_page(p)
Example #7
0
 def on_search(self, *button):
     search_for = decode_entry_string(self.g_searchentry.get_text().lower())
     page = self._search(search_for, False, True)
     page_C = self._search(search_for, True, True)
     page_C.m_name = u'Search exercises without translating them'
     if not page_C.is_empty():
         page[0].append(frontpage.LinkList(_('Too few matches?'),
             listitems=[page_C]))
     self.display_data(page, is_search_result=True)
Example #8
0
 def on_search(self, *button):
     search_for = decode_entry_string(self.g_searchentry.get_text().lower())
     logging.debug(u"FrontPage.on_search '%s'", search_for)
     page = self._search(search_for, False, False)
     page_C = self._search(search_for, True, False)
     page_C.m_name = _('Search untranslated lesson titles')
     if not page_C.is_empty():
         page[0].append(frontpage.LinkList(_('Too few matches?'),
             listitems=[page_C]))
     self.display_data(page, is_search_result=True)
Example #9
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("_", ""))
Example #10
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)
Example #11
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