[ocrfeeder: 3/15] Implement select next/previous page
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ocrfeeder: 3/15] Implement select next/previous page
- Date: Sat, 6 Oct 2012 16:12:24 +0000 (UTC)
commit 0ecf391c5d677febd5bd19467e291edc1251f897
Author: Joaquim Rocha <jrocha igalia com>
Date: Tue Oct 2 23:06:57 2012 +0200
Implement select next/previous page
src/ocrfeeder/studio/studioBuilder.py | 8 ++++++++
src/ocrfeeder/studio/widgetModeler.py | 23 +++++++++++++++++++++++
src/ocrfeeder/studio/widgetPresenter.py | 4 ++++
3 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/ocrfeeder/studio/studioBuilder.py b/src/ocrfeeder/studio/studioBuilder.py
index ea3ad13..95f9e9f 100644
--- a/src/ocrfeeder/studio/studioBuilder.py
+++ b/src/ocrfeeder/studio/studioBuilder.py
@@ -110,6 +110,8 @@ class Studio:
'copy_to_clipboard': self.source_images_controler.copyRecognizedTextToClipboard,
'spell_checker': self.spellChecker,
'help_contents': self.showHelpContents,
+ 'select_next_page': self.selectNextPage,
+ 'select_previous_page': self.selectPreviousPage,
}
self.main_window.setHeader(menubar_callback_dict, toolbar_callback_dict)
@@ -355,6 +357,12 @@ class Studio:
self.source_images_icon_view.deleteCurrentSelection()
delete_dialog.destroy()
+ def selectNextPage(self, widget):
+ self.source_images_icon_view.selectPageFromOffset(1)
+
+ def selectPreviousPage(self, widget):
+ self.source_images_icon_view.selectPageFromOffset(-1)
+
def __addImagesToReviewer(self, images):
if not images:
return
diff --git a/src/ocrfeeder/studio/widgetModeler.py b/src/ocrfeeder/studio/widgetModeler.py
index 6fccab3..f21f103 100644
--- a/src/ocrfeeder/studio/widgetModeler.py
+++ b/src/ocrfeeder/studio/widgetModeler.py
@@ -150,6 +150,29 @@ class SourceImagesSelectorIconView(gtk.IconView):
def clear(self):
self.get_model().clear()
+ def _getIndexFromOffset(self, offset):
+ selected_items = self.get_selected_items()
+ if not len(selected_items):
+ return
+ selected_item_path = selected_items[0]
+ model = self.get_model()
+ iter = model.get_iter(selected_item_path)
+ index = model.get_path(iter)[0] + offset
+ number_of_items = model.iter_n_children(None)
+ if index < 0:
+ index = number_of_items + offset
+ elif index == number_of_items:
+ index = 0
+ return index
+
+ def selectPageFromOffset(self, offset):
+ selected_items = self.get_selected_items()
+ if not len(selected_items):
+ return
+ selected_item_path = selected_items[0]
+ model = self.get_model()
+ index = self._getIndexFromOffset(offset)
+ self.select_path((index,))
class ImageReviewer(gtk.HPaned):
diff --git a/src/ocrfeeder/studio/widgetPresenter.py b/src/ocrfeeder/studio/widgetPresenter.py
index c8e1dc3..4b808ba 100644
--- a/src/ocrfeeder/studio/widgetPresenter.py
+++ b/src/ocrfeeder/studio/widgetPresenter.py
@@ -69,6 +69,8 @@ class MainWindow:
<separator/>
<menuitem action="EditPage"/>
<menuitem action="DeletePage"/>
+ <menuitem action="SelectNextPage"/>
+ <menuitem action="SelectPreviousPage"/>
<separator/>
<menuitem action="ClearProject"/>
<separator/>
@@ -168,6 +170,8 @@ class MainWindow:
('EditPage', gtk.STOCK_EDIT, _('_Edit Page'), None, _('Edit page settings'), menu_items['edit_page']),
('Preferences', gtk.STOCK_PREFERENCES, _('_Preferences'), None, _('Configure the application'), menu_items['preferences']),
('DeletePage', gtk.STOCK_DELETE, _('_Delete Page'), None, _('Delete current page'), menu_items['delete_page']),
+ ('SelectNextPage', gtk.STOCK_GO_DOWN, _('Select Next Page'), '<control>Page_Down', _('Select next page'), menu_items['select_next_page']),
+ ('SelectPreviousPage', gtk.STOCK_GO_UP, _('Select Previous Page'), '<control>Page_Up', _('Select previous page'), menu_items['select_previous_page']),
('ClearProject', gtk.STOCK_DELETE, _('_Clear Project'), None, _('Delete all images'), menu_items['clear']),
('View', None, _('_View')),
('ZoomIn', gtk.STOCK_ZOOM_IN, _('Zoom In'), '<control>plus', _("Zoom In"), menu_items['zoom_in']),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]