[ocrfeeder] studioBuilder: Make PDF importation paralel
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ocrfeeder] studioBuilder: Make PDF importation paralel
- Date: Mon, 5 Jul 2010 10:04:57 +0000 (UTC)
commit f97da24e7d95809d45977ba3396da4f998db4546
Author: Joaquim Rocha <jrocha igalia com>
Date: Mon Jul 5 10:49:27 2010 +0200
studioBuilder: Make PDF importation paralel
Use a different thread to import the PDF so the
GUI will not be blocked.
studio/studioBuilder.py | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/studio/studioBuilder.py b/studio/studioBuilder.py
index e0d8593..6c2cbb5 100644
--- a/studio/studioBuilder.py
+++ b/studio/studioBuilder.py
@@ -30,6 +30,7 @@ from studio.dataHolder import create_images_dict_from_liststore, DataBox, TextDa
from studio.customWidgets import SelectableBoxesArea
from feeder.ocrEngines import Engine, OcrEnginesManager
from configuration import ConfigurationManager
+from util.asyncworker import AsyncItem
import gettext
import locale
_ = gettext.gettext
@@ -170,11 +171,25 @@ class Studio:
def importPdf(self, widget):
file_open_dialog = widgetPresenter.FileDialog('open', file_filters = [(_('PDF'), ['application/pdf'], [])])
response = file_open_dialog.run()
+ files = []
if response == gtk.RESPONSE_OK:
- for file_name in file_open_dialog.get_filenames():
- folder = lib.convertPdfToImages(file_name, self.configuration_manager.getTemporaryDir())
- self.__addImagesToReviewer(lib.getImagesFromFolder(folder))
+ files = file_open_dialog.get_filenames()
file_open_dialog.destroy()
+ for file_name in files:
+ dialog = widgetPresenter.QueuedEventsProgressDialog(
+ self.main_window.window)
+ item = AsyncItem(lib.convertPdfToImages,
+ (file_name,
+ self.configuration_manager.getTemporaryDir()),
+ self.__loadPdfFinishedCb,
+ (dialog,))
+ info = (_('Loading PDF'), _('Please waitâ?¦'))
+ dialog.setItemsList([(info, item)])
+ dialog.run()
+
+ def __loadPdfFinishedCb(self, dialog, folder, error):
+ self.__addImagesToReviewer(lib.getImagesFromFolder(folder))
+ dialog.destroy()
def addFolder(self, widget):
file_open_dialog = widgetPresenter.FileDialog('select-folder')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]