[ocrfeeder/introspection] Fix updating the OCR engines in the BoxEditor



commit 2a404da221e08aa4b4c29688774511e99ef7909d
Author: Joaquim Rocha <me joaquimrocha com>
Date:   Sun Jul 20 20:46:55 2014 +0200

    Fix updating the OCR engines in the BoxEditor
    
    The engines weren't being updated in the BoxEditor after they
    were changed from the OcrManager dialog.

 src/ocrfeeder/studio/studioBuilder.py   |    3 +++
 src/ocrfeeder/studio/widgetModeler.py   |   11 +++++++++++
 src/ocrfeeder/studio/widgetPresenter.py |    8 +++++++-
 3 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/ocrfeeder/studio/studioBuilder.py b/src/ocrfeeder/studio/studioBuilder.py
index dab06a9..0baaf59 100644
--- a/src/ocrfeeder/studio/studioBuilder.py
+++ b/src/ocrfeeder/studio/studioBuilder.py
@@ -376,6 +376,9 @@ class Studio:
     def ocrEngines(self, widget = None):
         ocr_dialog = widgetPresenter.OcrManagerDialog(self.ocr_engines_manager)
         ocr_dialog.run()
+        if ocr_dialog.modified:
+            ocr_engines = self.ocr_engines_manager.ocr_engines
+            self.source_images_controler.updateOcrEngines(ocr_engines)
         ocr_dialog.destroy()
 
     def enginesTool(self, widget = None):
diff --git a/src/ocrfeeder/studio/widgetModeler.py b/src/ocrfeeder/studio/widgetModeler.py
index 5d29bec..6c0b52e 100644
--- a/src/ocrfeeder/studio/widgetModeler.py
+++ b/src/ocrfeeder/studio/widgetModeler.py
@@ -287,6 +287,10 @@ class ImageReviewer(Gtk.HPaned):
     def focusCurrentEditorTextArea(self):
         self.editor.box_editor.text_widget.grab_focus()
 
+    def updateOcrEngines(self, ocr_engines):
+        self.ocr_engines = ocr_engines
+        self.editor.updateOcrEngines(ocr_engines)
+
 class ImageReviewer_Controler:
 
     REVIEWER_CACHE_LENGTH = 5
@@ -792,6 +796,13 @@ class ImageReviewer_Controler:
         current_reviewer = self.__getCurrentReviewer()
         SpellCheckerDialog(self.main_window.window, current_reviewer, locale)
 
+    def updateOcrEngines(self, ocr_engines):
+        n_pages = self.notebook.get_n_pages()
+        index = 0
+        while index < n_pages:
+            reviewer = self.notebook.get_nth_page(index)
+            reviewer.updateOcrEngines(ocr_engines)
+            index += 1
 
 class Editor:
 
diff --git a/src/ocrfeeder/studio/widgetPresenter.py b/src/ocrfeeder/studio/widgetPresenter.py
index 667052a..30d4818 100644
--- a/src/ocrfeeder/studio/widgetPresenter.py
+++ b/src/ocrfeeder/studio/widgetPresenter.py
@@ -1747,6 +1747,7 @@ class OcrManagerDialog(Gtk.Dialog):
         self.new_engine.connect('clicked', self.__engine_settings)
         self.edit_engine.connect('clicked', self.__edit)
         self.detect_engines.connect('clicked', self.__detectEnginesCb)
+        self.modified = False
 
     def __makeMainArea(self):
         frame = PlainFrame(_('OCR Engines'))
@@ -1778,6 +1779,7 @@ class OcrManagerDialog(Gtk.Dialog):
             delete_dialog = QuestionDialog(_('Are you sure you want to delete this engine?'))
             response = delete_dialog.run()
             if response == Gtk.ResponseType.YES:
+                self.modified = True
                 index = model.get_path(iter)[0]
                 self.engines_manager.delete(index)
                 model.remove(iter)
@@ -1791,6 +1793,7 @@ class OcrManagerDialog(Gtk.Dialog):
         if index != None:
             engine = self.engines_manager.ocr_engines[index][0]
             if engine:
+                self.modified = True
                 self.__engine_settings(widget, engine)
 
     def __engine_settings(self, widget, engine = None):
@@ -1798,6 +1801,7 @@ class OcrManagerDialog(Gtk.Dialog):
         quit = False
         while not quit:
             if new_ocr_dialog.run() == Gtk.ResponseType.ACCEPT:
+                self.modified = True
                 quit = new_ocr_dialog.setEngine()
                 if quit:
                     self.__getEngines()
@@ -1833,7 +1837,9 @@ class OcrManagerDialog(Gtk.Dialog):
         engines_dialog = SystemEnginesDialog(engines)
         response = engines_dialog.run()
         if response == Gtk.ResponseType.ACCEPT:
-            for engine in engines_dialog.getChosenEngines():
+            engines = engines_dialog.getChosenEngines()
+            self.modified = bool(engines)
+            for engine in engines:
                 self.engines_manager.addNewEngine(engine)
         engines_dialog.destroy()
         self.__getEngines()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]