Esempio n. 1
0
 def update(self, dlg):
     fn = dlg.get_preview_filename()
     if fn:
         fn = gu.decode_filename(fn)
         for child in self.g_topic_box.get_children():
             child.destroy()
         fn = lessonfile.mk_uri(fn)
         try:
             self.set_sensitive(True)
             self.g_title.set_text(lessonfile.infocache.get(fn, 'title'))
             self.g_module.set_text(lessonfile.infocache.get(fn, 'module'))
             self.g_ok_button.set_sensitive(True)
             for x in self.m_model.iterate_topics_for_file(fn):
                 l = gtk.Label(x)
                 l.set_alignment(0.0, 0.5)
                 self.g_topic_box.pack_start(l, False)
             if not self.g_topic_box.get_children():
                 l = gtk.Label(u"-")
                 l.set_alignment(0.0, 0.5)
                 self.g_topic_box.pack_start(l, False)
         except (lessonfile.InfoCache.FileNotFound,
                 lessonfile.InfoCache.FileNotLessonfile), e:
             self.g_title.set_text(u'')
             self.g_module.set_text(u'')
             self.g_ok_button.set_sensitive(False)
             self.set_sensitive(False)
Esempio n. 2
0
 def update(self, dlg):
     fn = dlg.get_preview_filename()
     if fn:
         fn = gu.decode_filename(fn)
         for child in self.g_topic_box.get_children():
             child.destroy()
         fn = lessonfile.mk_uri(fn)
         try:
             self.set_sensitive(True)
             self.g_title.set_text(lessonfile.infocache.get(fn, 'title'))
             self.g_module.set_text(lessonfile.infocache.get(fn, 'module'))
             self.g_ok_button.set_sensitive(True)
             for x in self.m_model.iterate_topics_for_file(fn):
                 l = gtk.Label(x)
                 l.set_alignment(0.0, 0.5)
                 self.g_topic_box.pack_start(l, False)
             if not self.g_topic_box.get_children():
                 l = gtk.Label(u"-")
                 l.set_alignment(0.0, 0.5)
                 self.g_topic_box.pack_start(l, False)
         except (lessonfile.InfoCache.FileNotFound,
                 lessonfile.InfoCache.FileNotLessonfile), e:
             self.g_title.set_text(u'')
             self.g_module.set_text(u'')
             self.g_ok_button.set_sensitive(False)
             self.set_sensitive(False)
Esempio n. 3
0
 def _add_filenames(self, filenames):
     for filename in filenames:
         fn = gu.decode_filename(filename)
         assert os.path.isabs(fn)
         # If the file name is a file in a subdirectory below
         # lessonfile.exercises_dir in the current working directory,
         # then the file is a standard lesson file, and it will be
         # converted to a uri scheme with:
         fn = lessonfile.mk_uri(fn)
         # Small test to check that the file actually is a lesson file.
         try:
             lessonfile.infocache.get(fn, 'title')
         except lessonfile.infocache.FileNotLessonfile:
             continue
         self.m_model.append(fn)
         self.g_link_box.pack_start(self.create_linkrow(fn), False)
Esempio n. 4
0
 def _add_filenames(self, filenames):
     for filename in filenames:
         fn = gu.decode_filename(filename)
         assert os.path.isabs(fn)
         # If the file name is a file in a subdirectory below
         # lessonfile.exercises_dir in the current working directory,
         # then the file is a standard lesson file, and it will be
         # converted to a uri scheme with:
         fn = lessonfile.mk_uri(fn)
         # Small test to check that the file actually is a lesson file.
         try:
             lessonfile.infocache.get(fn, 'title')
         except lessonfile.infocache.FileNotLessonfile:
             continue
         self.m_model.append(fn)
         self.g_link_box.pack_start(self.create_linkrow(fn), False)