def do_response_ok(self): if not self.imagefile \ or self.textview.get_buffer().get_modified(): self.generate_image() if not (self.imagefile and self.imagefile.exists()): dialog = QuestionDialog(self, _('An error occured while generating the image.\nDo you want to save the source text anyway?')) # T: Question prompt when e.g. equation editor encountered an error genrating the image to insert if not dialog.run(): return False if self._existing_file: textfile = self._existing_file else: page = self.ui.page dir = self.ui.notebook.get_attachments_dir(page) textfile = dir.new_file(self.generator.basename) imgfile = self._stitch_fileextension(textfile, self.imagefile.basename) textfile.write( self.get_text() ) self.imagefile.rename(imgfile) if self._existing_file: self.ui.reload_page() else: pageview = self.ui.mainwindow.pageview pageview.insert_image(imgfile, type=self.generator.type, interactive=False) if self.logfile and self.logfile.exists(): self.logfile.remove() return True
def do_response_ok(self): buffer = self.textview.get_buffer() if buffer.get_modified(): self.update_image() if not (self.image_file and self.image_file.exists()): dialog = QuestionDialog(self, _('An error occurred while generating the image.\nDo you want to save the source text anyway?')) # T: Question prompt when e.g. equation editor encountered an error generating the image to insert if not dialog.run(): return False self.result = (self.get_text(), self.image_file) return True
def do_response_ok(self): if not self.imagefile \ or self.textview.get_buffer().get_modified(): self.generate_image() if not (self.imagefile and self.imagefile.exists()): dialog = QuestionDialog( self, _('An error occurred while generating the image.\nDo you want to save the source text anyway?' )) # T: Question prompt when e.g. equation editor encountered an error generating the image to insert if not dialog.run(): return False if self._existing_file: textfile = self._existing_file else: page = self.app_window.ui.page # XXX dir = self.app_window.ui.notebook.get_attachments_dir(page) # XXX textfile = dir.new_file(self.generator.scriptname) textfile.write(self.generator.process_input(self.get_text())) imgfile = self._stitch_fileextension(textfile, self.generator.imagename) if self.imagefile and self.imagefile.exists(): self.imagefile.rename(imgfile) elif imgfile.exists(): imgfile.remove() if self._existing_file: self.app_window.ui.reload_page() # XXX else: pageview = self.app_window.pageview pageview.insert_image(imgfile, type=self.generator.object_type, interactive=False, force=True) if self.logfile and self.logfile.exists(): self.logfile.remove() return True
def delete_file(widget, file): '''Delete a file @param widget: parent for new dialogs, C{Gtk.Widget} or C{None} @param file: a L{File} object @raises FileNotFoundError: if C{file} does not exist ''' logger.debug('delete_file(%s)', file) file = localFileOrFolder(file) assert isinstance(file, LocalFile) and not isinstance(file, LocalFolder) if not file.exists(): raise FileNotFoundError(file) dialog = QuestionDialog(widget, _('Are you sure you want to delete the file \'%s\'?') % file.basename) # T: text in confirmation dialog on deleting a file if dialog.run(): TrashHelper().trash(file)
def run(self): if QuestionDialog.run(self): return self.combobox.get_active_text() else: return None
def run(self): if QuestionDialog.run(self): return self.combobox.get_active_text() else: return None
def run(self): active = self.combobox.get_active_text() if active and QuestionDialog.run(self): return active else: return None