def set_book(self, book): self.book = book self.bookinfo_notebook.set_current_page(0) #self.binary_treeview.get_selection().unselect_all() self.file_name_label.set_text(fix_filename(self.book.filename)) self.author_entry.set_text(self.book.author) self.name_entry.set_text(self.book.name) self.description_buffer.set_text(self.book.description) self.update_bookmarks() self.file_type_label.set_text(self.book.file_type) # update categories model = self.categories_model def set_check(model, path, iter, book): if model.get_value(iter, self.COLUMN_CATEGORY) in book.categories: model.set(iter, self.COLUMN_CHECK, True) else: model.set(iter, self.COLUMN_CHECK, False) model.foreach(set_check, book) #self.window.set_title('odin - Info') self.binary_image.set_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_DND) #gtk.STOCK_NEW self.book_buffer = None
def timeout_cb(self): title = self.properties.title_format title = title.replace('%f', '%(filename)s') title = title.replace('%a', '%(authors)s') title = title.replace('%b', '%(book_title)s') title = title.replace('%p', '%(position)d%%') title = title.replace('%t', '%(time)s') authors = self.text_widget.content.authors #authors = authors[:64] book_title = self.text_widget.content.title try: title = title % {'filename' : fix_filename(self.filename), 'authors' : authors, 'book_title': book_title, 'position' : int(self.text_widget.calc_position()*100), 'time' : time.strftime('%H:%M', time.localtime()), } except: title = PROGRAM_NAME + ' [invalid format]' self.window.set_title(title) #self.text_widget.draw_status() self.text_widget.drawStatus() return True
def update_recent_files_menu(self): menu = gtk.Menu() menu.show() rf = self.properties.recent_files[:] rf.reverse() for f in rf: #self.properties.recent_files: menuitem = gtk.MenuItem(fix_filename(f[0])) menuitem.get_child().set_use_underline(False) menuitem.connect('activate', self.recent_files_activate_cb, f[0]) menu.add(menuitem) menuitem.show() self.open_recent_file_menu.set_submenu(menu)
def open_file(self, filename): #print 'open_file', filename try: open(filename) except IOError, err: #sys.stderr.write('ERROR: can\'t open file: %s: %s\n' # % (filename, err[1])) error_dialog(self.window, "Can't open file %s: %s" % (fix_filename(filename), err[1])) self.update_recent_files_menu() return