def on_report_bug(self, event): open_url(u"https://bugs.launchpad.net/whyteboard")
def convert(self): """ If the filetype is PDF/PS, convert to a (temporary) series of images and loads them. Find out the directory length before/after the conversion to know how many 'pages' were converted - used then to create a new Whyteboard tabs for each page. The PDF's file location, convert quality and converted images are written into a "library" file, effectively caching the conversion. An attempt at randomising the temp. file name is made using alphanumeric characters to help minimise conflict. """ if not self.im_location: self.prompt_for_im() if not self.im_location: # above will have changed this if IM exists return _file = self.temp_file logger.info("Converting [%s]", os.path.basename(_file)) quality = Config().convert_quality() cached = self.library.lookup(_file, quality) if cached: logger.debug("PDF is cached") self.display_converted(_file, cached) else: path = get_home_dir(u"wtbd-tmp") # directory to store the images tmp_file = make_filename() before = os.walk(path).next()[2] # file count before convert full_path = path + tmp_file + u".png" logger.debug("Writing PDF images as [%s]", full_path) cmd = convert_quality(quality, self.im_location, _file, full_path) logger.info("Starting to convert PDF") self.gui.convert_dialog(cmd) # show progress bar, kick off convert if self.gui.convert_cancelled: logger.info("Convert process cancelled by user") return after = os.walk(path).next()[2] count = len(after) - len(before) images = [] ignore = False logger.info("Convert process complete. %i images were created", count) if not count: logger.warning("Failed to convert.") wx.MessageBox( _("Failed to convert file. Ensure GhostScript is installed\nhttp://pages.cs.wisc.edu/~ghost/"), _("Conversion Failed"), ) open_url(u"http://pages.cs.wisc.edu/~ghost/") return if count == 1: images.append(path + tmp_file + u".png") ignore = True else: for x in range(count): # store the temp file path for this file in the dictionary images.append(u"%s%s-%i.png" % (path, tmp_file, x)) self.display_converted(_file, images, ignore) self.library.write(_file, images, quality) # Just in case it's a file with many pages self.gui.show_progress_dialog(_("Loading...")) self.gui.on_done_load()
def on_translate(self, event): open_url(u"https://translations.launchpad.net/whyteboard")