[ocrfeeder] Add controls to select next/previous content area (gb#622568)



commit c4eadfda789d530db155e674b93593a0349b2ff5
Author: Joaquim Rocha <jrocha igalia com>
Date:   Thu Jun 24 10:10:57 2010 +0200

    Add controls to select next/previous content area (gb#622568)
    
    Add "Select Next Area" and "Select Previous Area" to the Document menu.
    These select the next/previous content areas in order of creation.

 studio/customWidgets.py   |   24 ++++++++++++++++++++++++
 studio/studioBuilder.py   |    5 ++++-
 studio/widgetModeler.py   |    8 ++++++++
 studio/widgetPresenter.py |   10 ++++++++++
 4 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/studio/customWidgets.py b/studio/customWidgets.py
index e99abd9..0a6480a 100644
--- a/studio/customWidgets.py
+++ b/studio/customWidgets.py
@@ -162,6 +162,30 @@ class SelectableBoxesArea(goocanvas.Canvas):
         self.emit('deselected_box', area)
         return True
 
+    def selectNextArea(self):
+        self.__selectSurroundingArea(-1)
+
+    def selectPreviousArea(self):
+        self.__selectSurroundingArea(1)
+
+    def __selectSurroundingArea(self, area_offset):
+        areas = self.getAllAreas()
+        if not areas:
+            return
+        area_index = self.__getCurrentSelectedAreaIndex(areas)
+        area_index += area_offset
+        if abs(area_index) >= len(areas):
+            area_index = 0
+        self.deselectAreas()
+        self.selectArea(areas[area_index])
+
+    def __getCurrentSelectedAreaIndex(self, areas):
+        current_area = areas[0]
+        if self.selected_areas:
+            current_area = self.selected_areas[-1]
+        area_index = areas.index(current_area)
+        return area_index
+
     def zoom(self, zoom_value, add_zoom = True):
         new_zoom = zoom_value
         set_zoom = False
diff --git a/studio/studioBuilder.py b/studio/studioBuilder.py
index 7e799d7..922c0e4 100644
--- a/studio/studioBuilder.py
+++ b/studio/studioBuilder.py
@@ -95,7 +95,10 @@ class Studio:
                                  'unpaper': self.unpaper, 'preferences': self.preferences, 'about': self.about,
                                  'ocr_engines': self.ocrEngines, 'zoom_in': self.zoomIn, 'zoom_out': self.zoomOut,
                                  'zoom_fit': self.zoomFit, 'reset_zoom': self.resetZoom,
-                                 'recognize_areas': self.source_images_controler.recognizeSelectedAreas}
+                                 'recognize_areas': self.source_images_controler.recognizeSelectedAreas,
+                                 'select_next_area': self.source_images_controler.selectNextArea,
+                                 'select_previous_area': self.source_images_controler.selectPreviousArea,
+                                 }
         
         self.main_window.setHeader(menubar_callback_dict, toolbar_callback_dict)
         self.main_window.setDestroyEvent(self.quit)
diff --git a/studio/widgetModeler.py b/studio/widgetModeler.py
index 0a708c4..20c8c30 100644
--- a/studio/widgetModeler.py
+++ b/studio/widgetModeler.py
@@ -635,6 +635,14 @@ class ImageReviewer_Controler:
         current_reviewer = self.__getCurrentReviewer()
         current_reviewer.selectable_boxes_area.zoom(1, False)
 
+    def selectPreviousArea(self, widget):
+        current_reviewer = self.__getCurrentReviewer()
+        current_reviewer.selectable_boxes_area.selectPreviousArea()
+
+    def selectNextArea(self, widget):
+        current_reviewer = self.__getCurrentReviewer()
+        current_reviewer.selectable_boxes_area.selectNextArea()
+
 class Editor:
     
     def __init__(self, box, pixbuf, ocr_engines, reviewer):
diff --git a/studio/widgetPresenter.py b/studio/widgetPresenter.py
index 1784752..664a916 100644
--- a/studio/widgetPresenter.py
+++ b/studio/widgetPresenter.py
@@ -74,6 +74,8 @@ class MainWindow:
         <menu action="Document">
             <menuitem action="OCRFeederDetection"/>
             <menuitem action="RecognizeAreas"/>
+            <menuitem action="SelectPreviousArea"/>
+            <menuitem action="SelectNextArea"/>
         </menu>
         <menu action="Tools">
             <menuitem action="OCREngines"/>
@@ -160,6 +162,14 @@ class MainWindow:
                                   ('About', gtk.STOCK_ABOUT, _('_About'), None, _('About this application'), menu_items['about']),
                                   ('OCRFeederDetection', None, _('_Recognize Document'), None, _("Automatic Detection and Recognition"), tool_items['detection']),
                                   ('RecognizeAreas', None, _('Recognize Selected _Areas'), None, _("Recognize Selected Areas"), menu_items['recognize_areas']),
+                                  ('SelectPreviousArea', gtk.STOCK_GO_BACK,
+                                   _('Select _Previous Area'), None,
+                                   _("Select the previous area from the content areas"),
+                                   menu_items['select_previous_area']),
+                                  ('SelectNextArea', gtk.STOCK_GO_FORWARD,
+                                   _('Select _Next Area'), None,
+                                   _("Select the next area from the content areas"),
+                                   menu_items['select_next_area']),
                                   ('GenerateODT', None, _('_Generate ODT'), None, _("Export to ODT"), tool_items['export_to_odt']),
                                   ])
         ui_manager.insert_action_group(action_group, 0)



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