def _set_document(self, document): """ Replace the current document (if any) with a new one. Positional arguments: document -- The new Document object. """ self.document = document for child in self.scrolledwindow.get_children(): self.scrolledwindow.remove(child) self.layout = Layout(self.document) self.scrolledwindow.add(self.layout) self.scrolledwindow.show_all() self.last_filename = None self.statusbar_pagenum.set_sensitive(True) self.statusbar_pagenum_entry.set_sensitive(True) self.actiongroup_document_specific.set_sensitive(True) if self.document.num_of_pages > 1: self.button_next_page.set_sensitive(True) # at this point we always start at page 1. If the feature to resume last page is included # remove this and start the method show_page_numbers() with adjustment self.statusbar_pagenum.set_text( _(" of {:3}").format(self.document.num_of_pages)) self.curr_page = 1 self.statusbar_pagenum_entry.set_text(str(self.curr_page)) # Hide the disconnection overlay dialog when the user opens a new doc if self.overlaybox: self.overlaybox.destroy()