def init(self): pane = gtk.Notebook() self.widget.pack_start(pane) pane.set_tab_pos(gtk.POS_TOP) self.list = LibraryList() label = gtk.Label('Books') #label.set_angle(90) pane.append_page(self.list, tab_label=label) self.list.connect('clicked', self.cb_booklist_clicked) self.list.connect('double-clicked', self.cb_contents_clicked) self.list.set_property('markup_format_string', '%(title)s') self.__contents = tree.Tree() label = gtk.Label('Contents') #label.set_angle(90) pane.append_page(self.__contents, tab_label=label) self.__contents.set_property('markup_format_string', '%(name)s') self.__contents.connect('double-clicked', self.cb_contents_clicked) self.long_title = 'Loading books...' self.paned = pane add_item = self.list.add_item self._load_books_task = GeneratorTask(self._load_books, add_item)
def set_current_document(self, document): self._current = document if self._current is not None: task = GeneratorTask(self.check_current, self.add_todo_item) task.start()
class bookmark_view(contentview.content_view): ICON_NAME = 'library' LONG_TITLE = 'Documentation Library' SHORT_TITLE = 'Docs' HAS_CONTROL_BOX = True HAS_CLOSE_BUTTON = True def init(self): pane = gtk.Notebook() self.widget.pack_start(pane) pane.set_tab_pos(gtk.POS_TOP) self.list = LibraryList() label = gtk.Label('Books') #label.set_angle(90) pane.append_page(self.list, tab_label=label) self.list.connect('clicked', self.cb_booklist_clicked) self.list.connect('double-clicked', self.cb_contents_clicked) self.list.set_property('markup_format_string', '%(title)s') self.__contents = tree.Tree() label = gtk.Label('Contents') #label.set_angle(90) pane.append_page(self.__contents, tab_label=label) self.__contents.set_property('markup_format_string', '%(name)s') self.__contents.connect('double-clicked', self.cb_contents_clicked) self.long_title = 'Loading books...' self.paned = pane add_item = self.list.add_item self._load_books_task = GeneratorTask(self._load_books, add_item) def load_books(self, books): self._load_books_task.start(books) def _load_books(self, books): for item in books: if item.bookmarks is None: item.load() if item.bookmarks is not None: yield item gobject.idle_add(self.on_finished) def on_finished(self): self.long_title = 'Documentation library' def set_contents(self, book): self.__contents.clear() for item in book.subs: self._add_item(item) def _add_item(self, item, parent=None): niter = self.__contents.add_item(item, parent=parent) for child in item.subs: try: self._add_item(child, niter) except KeyError: pass def cb_booklist_clicked(self, treeview, item): if item.value.bookmarks is None: item.value.load() self.set_contents(item.value.bookmarks) self.paned.set_current_page(1) def cb_contents_clicked(self, treeview, item): book = item.value if book.path: self.service.boss.call_command('webbrowse', 'browse', url=book.path) else: self.service.log.info('Bad document book "%s"', book.name)
def refresh_view(self): self._view.clear_items() if self.svc.is_current_python(): task = GeneratorTask(self.check_current, self.add_view_node) task.start()