diff options
author | James Simmons <ja.simmons@sbcglobal.net> | 2008-03-01 20:48:13 (GMT) |
---|---|---|
committer | James Simmons <ja.simmons@sbcglobal.net> | 2008-03-01 20:48:13 (GMT) |
commit | b94f392f0379ff84831c19304d7978a3a4771a91 (patch) | |
tree | 0f38a0c420a1ea6282b4ef8ffbb8f9b910f8949d |
Initial import
35 files changed, 1431 insertions, 0 deletions
diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..a4e1d0b --- /dev/null +++ b/MANIFEST @@ -0,0 +1,2 @@ +ReadEtextsActivity.py +readtoolbar.py @@ -0,0 +1 @@ +Initial creation of Read ETexts Activity 02-21-08. diff --git a/ReadEtextsActivity.py b/ReadEtextsActivity.py new file mode 100755 index 0000000..1c9ba3f --- /dev/null +++ b/ReadEtextsActivity.py @@ -0,0 +1,324 @@ +#! /usr/bin/env python + +# Copyright (C) 2008 James D. Simmons +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +import sys +import os +import zipfile +import pygtk +import gtk +import string +from sugar.activity import activity +from readtoolbar import ReadToolbar, ViewToolbar, EditToolbar +from gettext import gettext as _ +import pango + +_PAGE_SIZE = 40 +_TOOLBAR_READ = 2 + +class ReadEtextsActivity(activity.Activity): + def __init__(self, handle): + "The entry point to the Activity" + activity.Activity.__init__(self, handle) + self.connect("key_press_event", self.keypress_cb) + toolbox = activity.ActivityToolbox(self) + self.set_toolbox(toolbox) + + self._edit_toolbar = EditToolbar() + self._edit_toolbar.undo.props.visible = False + self._edit_toolbar.redo.props.visible = False + self._edit_toolbar.separator.props.visible = False + self._edit_toolbar.copy.set_sensitive(False) + self._edit_toolbar.copy.connect('clicked', self.edit_toolbar_copy_cb) + self._edit_toolbar.paste.props.visible = False + toolbox.add_toolbar(_('Edit'), self._edit_toolbar) + self._edit_toolbar.set_activity(self) + self._edit_toolbar.show() + + self._read_toolbar = ReadToolbar() + toolbox.add_toolbar(_('Read'), self._read_toolbar) + self._read_toolbar.set_activity(self) + self._read_toolbar.show() + + self._view_toolbar = ViewToolbar() + toolbox.add_toolbar(_('View'), self._view_toolbar) + self._view_toolbar.set_activity(self) + self._view_toolbar.show() + + toolbox.show() + self.scrolled = gtk.ScrolledWindow() + self.scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + self.scrolled.props.shadow_type = gtk.SHADOW_NONE + self.textview = gtk.TextView() + self.textview.set_editable(False) + self.textview.set_cursor_visible(False) + self.textview.set_left_margin(50) + buffer = self.textview.get_buffer() + buffer.connect("mark-set", self.mark_set_cb) + self.font_desc = pango.FontDescription("sans 12") + self.scrolled.add(self.textview) + self.textview.show() + self.set_canvas(self.scrolled) + self.scrolled.show() + v_adjustment = self.scrolled.get_vadjustment() + self.clipboard = gtk.Clipboard(display=gtk.gdk.display_get_default(), selection="CLIPBOARD") + + # start on the read toolbar + self.toolbox.set_current_toolbar(_TOOLBAR_READ) + + def mark_set_cb(self, textbuffer, iter, textmark): + if textbuffer.get_has_selection(): + self._edit_toolbar.copy.set_sensitive(True) + else: + self._edit_toolbar.copy.set_sensitive(False) + + def edit_toolbar_copy_cb(self, button): + buffer = self.textview.get_buffer() + begin, end = buffer.get_selection_bounds() + copy_text = buffer.get_text(begin, end) + self.clipboard.set_text(copy_text) + + def keypress_cb(self, widget, event): + "Respond when the user presses one of the arrow keys" + keyname = gtk.gdk.keyval_name(event.keyval) + if keyname == 'plus': + self.font_increase() + return True + if keyname == 'minus': + self.font_decrease() + return True + if keyname == 'KP_Right': + self.scroll_down() + return True + if keyname == 'Page_Up': + self.page_previous() + return True + if keyname == 'KP_Left': + self.scroll_up() + return True + if keyname == 'Page_Down' : + self.page_next() + return True + if keyname == 'Up'or keyname == 'KP_Up': + self.scroll_up() + return True + if keyname == 'Down' or keyname == 'KP_Down': + self.scroll_down() + return True + return False + + def page_next(self): + page = self.page + page = page + 1 + if page >= len(self.page_index): page=len(self.page_index) - 1 + self.show_page(page) + v_adjustment = self.scrolled.get_vadjustment() + v_adjustment.value = v_adjustment.lower + self._read_toolbar.set_current_page(page) + self.page = page + + def page_previous(self): + page = self.page + page=page-1 + if page < 0: page=0 + self.show_page(page) + v_adjustment = self.scrolled.get_vadjustment() + v_adjustment.value = v_adjustment.upper - v_adjustment.page_size + self._read_toolbar.set_current_page(page) + self.page = page + + def font_decrease(self): + font_size = self.font_desc.get_size() / 1024 + font_size = font_size - 1 + if font_size < 1: + font_size = 1 + self.font_desc.set_size(font_size * 1024) + self.textview.modify_font(self.font_desc) + + def font_increase(self): + font_size = self.font_desc.get_size() / 1024 + font_size = font_size + 1 + self.font_desc.set_size(font_size * 1024) + self.textview.modify_font(self.font_desc) + + def scroll_down(self): + v_adjustment = self.scrolled.get_vadjustment() + if v_adjustment.value == v_adjustment.upper - v_adjustment.page_size: + self.page_next() + return + if v_adjustment.value < v_adjustment.upper - v_adjustment.page_size: + new_value = v_adjustment.value + v_adjustment.step_increment + if new_value > v_adjustment.upper - v_adjustment.page_size: + new_value = v_adjustment.upper - v_adjustment.page_size + v_adjustment.value = new_value + + def scroll_up(self): + v_adjustment = self.scrolled.get_vadjustment() + if v_adjustment.value == v_adjustment.lower: + self.page_previous() + return + if v_adjustment.value > v_adjustment.lower: + new_value = v_adjustment.value - v_adjustment.step_increment + if new_value < v_adjustment.lower: + new_value = v_adjustment.lower + v_adjustment.value = new_value + + def set_current_page(self, page): + self.page = page + + def show_page(self, page_number): + position = self.page_index[page_number] + self.etext_file.seek(position) + linecount = 0 + label_text = '\n\n\n' + while linecount < _PAGE_SIZE: + line = self.etext_file.readline() + if not line: + continue + else: + label_text = label_text + unicode(line, "iso-8859-1") + linecount = linecount + 1 + textbuffer = self.textview.get_buffer() + textbuffer.set_text(label_text) + + def show_found_page(self, page_tuple): + position = self.page_index[page_tuple[0]] + self.etext_file.seek(position) + linecount = 0 + label_text = '\n\n\n' + while linecount < _PAGE_SIZE: + line = self.etext_file.readline() + if not line: + label_text = label_text + '\n' + else: + label_text = label_text + unicode(line, "iso-8859-1") + linecount = linecount + 1 + textbuffer = self.textview.get_buffer() + tag = textbuffer.create_tag() + tag.set_property('weight', pango.WEIGHT_BOLD) + tag.set_property( 'foreground', "white") + tag.set_property( 'background', "black") + textbuffer.set_text(label_text) + iterStart = textbuffer.get_iter_at_offset(page_tuple[1]) + iterEnd = textbuffer.get_iter_at_offset(page_tuple[2]) + textbuffer.apply_tag(tag, iterStart, iterEnd) + self._edit_toolbar._update_find_buttons() + + def save_extracted_file(self, zipfile, filename): + "Extract the file to a temp directory for viewing" + filebytes = zipfile.read(filename) + f = open("/tmp/" + filename, 'w') + try: + f.write(filebytes) + finally: + f.close + + def read_file(self, filename): + "Read the Etext file" + if filename.endswith(".zip"): + self.zf = zipfile.ZipFile(filename, 'r') + self.book_files = self.zf.namelist() + self.save_extracted_file(self.zf, self.book_files[0]) + current_file_name = "/tmp/" + self.book_files[0] + else: + current_file_name = filename + + self.etext_file = open(current_file_name,"r") + + self.page_index = [ 0 ] + pagecount = 0 + linecount = 0 + while self.etext_file: + line = self.etext_file.readline() + if not line: + break + linecount = linecount + 1 + if linecount >= _PAGE_SIZE: + position = self.etext_file.tell() + self.page_index.append(position) + linecount = 0 + pagecount = pagecount + 1 + self.page = int(self.metadata.get('current_page', '0')) + self.show_page(self.page) + self._read_toolbar.set_total_pages(pagecount + 1) + self._read_toolbar.set_current_page(self.page) + if filename.endswith(".zip"): + os.remove(current_file_name) + + def write_file(self, filename): + "Save meta data for the file." + self.metadata['current_page'] =str(self.page) + + def find_previous(self): + self.current_found_item = self.current_found_item - 1 + if self.current_found_item <= 0: + self.current_found_item = 0 + current_found_tuple = self.found_records[self.current_found_item] + self.page = current_found_tuple[0] + self._read_toolbar.set_current_page(self.page) + self.show_found_page(current_found_tuple) + + def find_next(self): + self.current_found_item = self.current_found_item + 1 + if self.current_found_item >= len(self.found_records): + self.current_found_item = len(self.found_records) - 1 + current_found_tuple = self.found_records[self.current_found_item] + self.page = current_found_tuple[0] + self._read_toolbar.set_current_page(self.page) + self.show_found_page(current_found_tuple) + + def can_find_previous(self): + if self.current_found_item == 0: + return False + return True + + def can_find_next(self): + if self.current_found_item >= len(self.found_records) - 1: + return False + return True + + def find_begin(self, search_text): + pagecount = 0 + linecount = 0 + charcount = 0 + self.found_records = [] + self.current_found_item = -1 + self.etext_file.seek(0) + while self.etext_file: + line = unicode(self.etext_file.readline(), "iso-8859-1") + line_length = len(line) + if not line: + break + linecount = linecount + 1 + position = string.find(line, search_text) + if (position >= 0): + found_pos = charcount + position + 3 + found_tuple = (pagecount, found_pos, len(search_text) + found_pos) + self.found_records.append(found_tuple) + self.current_found_item = 0 + charcount = charcount + line_length + if linecount >= _PAGE_SIZE: + linecount = 0 + charcount = 0 + pagecount = pagecount + 1 + if self.current_found_item == 0: + current_found_tuple = self.found_records[self.current_found_item] + self.page = current_found_tuple[0] + self._read_toolbar.set_current_page(self.page) + self.show_found_page(current_found_tuple) + + def get_current_page(self): + return self.page diff --git a/ReadEtextsActivity.pyc b/ReadEtextsActivity.pyc Binary files differnew file mode 100644 index 0000000..e666bec --- /dev/null +++ b/ReadEtextsActivity.pyc diff --git a/activity/activity.info b/activity/activity.info new file mode 100644 index 0000000..2e839a4 --- /dev/null +++ b/activity/activity.info @@ -0,0 +1,9 @@ +[Activity] +name = Read ETexts +service_name = org.laptop.sugar.ReadEtextsActivity +icon = read-etexts +exec = sugar-activity ReadEtextsActivity.ReadEtextsActivity +show_launcher = no +activity_version = 1 +mime_types = text/plain;application/zip + diff --git a/activity/activity.info~ b/activity/activity.info~ new file mode 100644 index 0000000..2e839a4 --- /dev/null +++ b/activity/activity.info~ @@ -0,0 +1,9 @@ +[Activity] +name = Read ETexts +service_name = org.laptop.sugar.ReadEtextsActivity +icon = read-etexts +exec = sugar-activity ReadEtextsActivity.ReadEtextsActivity +show_launcher = no +activity_version = 1 +mime_types = text/plain;application/zip + diff --git a/activity/read-etexts.svg b/activity/read-etexts.svg new file mode 100644 index 0000000..1953b7b --- /dev/null +++ b/activity/read-etexts.svg @@ -0,0 +1,191 @@ +<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [ + <!ENTITY stroke_color "#000000"> + <!ENTITY fill_color "#FFFFFF"> +]><svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="48px" + height="48px" + id="svg2160" + sodipodi:version="0.32" + inkscape:version="0.45.1" + sodipodi:docbase="/home/jim/python/ReadEtexts.activity/activity" + sodipodi:docname="read-etexts.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <defs + id="defs2162" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="14" + inkscape:cx="24" + inkscape:cy="26.857143" + inkscape:current-layer="layer1" + showgrid="true" + inkscape:grid-bbox="true" + inkscape:document-units="px" + inkscape:window-width="980" + inkscape:window-height="823" + inkscape:window-x="218" + inkscape:window-y="92" /> + <metadata + id="metadata2165"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + id="layer1" + inkscape:label="Layer 1" + inkscape:groupmode="layer"> + <rect + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3141" + width="29.857143" + height="29.571428" + x="10" + y="8.8571424" /> + <rect + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3143" + width="39.57143" + height="5.1428571" + x="5" + y="3" /> + <rect + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3145" + width="39.142857" + height="5.1428571" + x="5" + y="38" /> + <rect + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3147" + width="0.5714286" + height="0.14285715" + x="45.714287" + y="5.5714288" /> + <rect + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3149" + width="1.2857143" + height="0" + x="2.8571429" + y="6" /> + <rect + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3151" + width="0.85714287" + height="0.14285715" + x="3.2857144" + y="41.142857" /> + <rect + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3155" + width="1" + height="0.14285715" + x="45.42857" + y="40.714287" /> + <rect + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3157" + width="1.4285715" + height="0" + x="2.4285715" + y="5.5714288" /> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 4,5.5 C 2.4285714,5.5 2.4285714,5.5 2.4285714,5.5" + id="path3213" /> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 4.4285714,6.4285714 C 2.5,6.4285714 2.5,6.4285714 2.5,6.4285714" + id="path3215" /> + <rect + style="fill:#000000;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3217" + width="0.071428575" + height="9.1428576" + x="4.5" + y="1" /> + <rect + style="fill:#000000;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3237" + width="0.5714286" + height="9" + x="44" + y="1" /> + <rect + style="fill:#000000;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3243" + width="0.21428572" + height="10.071428" + x="5" + y="35" /> + <rect + style="fill:#000000;fill-opacity:1;stroke:&stroke_color;;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect3245" + width="0.14285716" + height="9.8571424" + x="44" + y="35" /> + <text + xml:space="preserve" + style="font-size:12px;font-style:italic;font-weight:bold;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:URW Chancery L;font-stretch:normal;font-variant:normal;text-anchor:start;text-align:start;writing-mode:lr;line-height:100%" + x="14" + y="22.714287" + id="text3249" + sodipodi:linespacing="100%"><tspan + sodipodi:role="line" + id="tspan3251" + x="14" + y="22.714287">G</tspan></text> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 26,16.5 C 35,16.571429 34.571429,16.571429 34.571429,16.571429" + id="path3253" /> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 34.428571,19 L 26,19 L 26,19 L 26,19 L 26,19" + id="path3255" /> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 26,21.428571 C 34,21.428571 34,21.428571 34,21.428571" + id="path3257" /> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 26,24 C 34,24 34,24 34,24" + id="path3259" /> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 26,26.5 C 34,26.428571 34,26.428571 34,26.428571 L 34,26.428571" + id="path3261" /> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 14,29 C 34,29 34,29 34,29" + id="path3263" /> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 14,31 C 34,31 34,31 34,31" + id="path3265" /> + <path + style="fill:none;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 14,33 C 34,33 34,33 34,33" + id="path3267" /> + </g> +</svg> diff --git a/locale/ar/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo b/locale/ar/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo Binary files differnew file mode 100644 index 0000000..91cfaf9 --- /dev/null +++ b/locale/ar/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo diff --git a/locale/ar/activity.linfo b/locale/ar/activity.linfo new file mode 100644 index 0000000..e6785f1 --- /dev/null +++ b/locale/ar/activity.linfo @@ -0,0 +1,2 @@ +[Activity] +name = Read diff --git a/locale/de/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo b/locale/de/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo Binary files differnew file mode 100644 index 0000000..7c7a4bd --- /dev/null +++ b/locale/de/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo diff --git a/locale/de/activity.linfo b/locale/de/activity.linfo new file mode 100644 index 0000000..e6785f1 --- /dev/null +++ b/locale/de/activity.linfo @@ -0,0 +1,2 @@ +[Activity] +name = Read diff --git a/locale/el/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo b/locale/el/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo Binary files differnew file mode 100644 index 0000000..ebafd05 --- /dev/null +++ b/locale/el/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo diff --git a/locale/el/activity.linfo b/locale/el/activity.linfo new file mode 100644 index 0000000..e6785f1 --- /dev/null +++ b/locale/el/activity.linfo @@ -0,0 +1,2 @@ +[Activity] +name = Read diff --git a/locale/es/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo b/locale/es/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo Binary files differnew file mode 100644 index 0000000..2e798a9 --- /dev/null +++ b/locale/es/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo diff --git a/locale/es/activity.linfo b/locale/es/activity.linfo new file mode 100644 index 0000000..e6785f1 --- /dev/null +++ b/locale/es/activity.linfo @@ -0,0 +1,2 @@ +[Activity] +name = Read diff --git a/locale/fr/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo b/locale/fr/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo Binary files differnew file mode 100644 index 0000000..35cde87 --- /dev/null +++ b/locale/fr/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo diff --git a/locale/fr/activity.linfo b/locale/fr/activity.linfo new file mode 100644 index 0000000..e6785f1 --- /dev/null +++ b/locale/fr/activity.linfo @@ -0,0 +1,2 @@ +[Activity] +name = Read diff --git a/locale/mk/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo b/locale/mk/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo Binary files differnew file mode 100644 index 0000000..f3e3a43 --- /dev/null +++ b/locale/mk/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo diff --git a/locale/mk/activity.linfo b/locale/mk/activity.linfo new file mode 100644 index 0000000..e6785f1 --- /dev/null +++ b/locale/mk/activity.linfo @@ -0,0 +1,2 @@ +[Activity] +name = Read diff --git a/locale/pt/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo b/locale/pt/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo Binary files differnew file mode 100644 index 0000000..9f5daac --- /dev/null +++ b/locale/pt/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo diff --git a/locale/pt/activity.linfo b/locale/pt/activity.linfo new file mode 100644 index 0000000..e6785f1 --- /dev/null +++ b/locale/pt/activity.linfo @@ -0,0 +1,2 @@ +[Activity] +name = Read diff --git a/locale/pt_BR/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo b/locale/pt_BR/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo Binary files differnew file mode 100644 index 0000000..bbba31b --- /dev/null +++ b/locale/pt_BR/LC_MESSAGES/org.laptop.sugar.ReadActivity.mo diff --git a/locale/pt_BR/activity.linfo b/locale/pt_BR/activity.linfo new file mode 100644 index 0000000..e6785f1 --- /dev/null +++ b/locale/pt_BR/activity.linfo @@ -0,0 +1,2 @@ +[Activity] +name = Read diff --git a/po/ar.po b/po/ar.po new file mode 100644 index 0000000..4d23c30 --- /dev/null +++ b/po/ar.po @@ -0,0 +1,74 @@ +# translation of xbook.master.po to Arabic +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Khaled Hosny <khaledhosny@eglug.org>, 2007. +msgid "" +msgstr "" +"Project-Id-Version: xbook.master\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-31 09:25+0100\n" +"PO-Revision-Date: 2007-06-28 21:41+0300\n" +"Last-Translator: Khaled Hosny <khaledhosny@eglug.org>\n" +"Language-Team: Arabic <doc@arabeyes.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" +"Plural-Forms: nplurals=4; plural=n==1 ? 0 : n==2 ? 1 : n>=3 && n<=10 ? 2 : " +"3\n" + +#: activity/activity.info:2 readactivity.py:77 +msgid "Read" +msgstr "" + +#: readactivity.py:73 +msgid "Edit" +msgstr "" + +#: readactivity.py:81 +msgid "View" +msgstr "اعرض" + +#: readtoolbar.py:60 +msgid "Previous" +msgstr "السابق" + +#: readtoolbar.py:67 +msgid "Next" +msgstr "التالي" + +#: readtoolbar.py:105 +msgid "Back" +msgstr "للخلف" + +#: readtoolbar.py:112 +msgid "Forward" +msgstr "للأمام" + +#: readtoolbar.py:207 +msgid "Zoom out" +msgstr "" + +#: readtoolbar.py:213 +msgid "Zoom in" +msgstr "" + +#: readtoolbar.py:219 +msgid "Zoom to width" +msgstr "" + +#: readtoolbar.py:225 +msgid "Zoom to fit" +msgstr "" + +#: readtoolbar.py:230 +msgid "Actual size" +msgstr "" + +#: readtoolbar.py:248 +msgid "%" +msgstr "" + +#~ msgid "Read Activity" +#~ msgstr "نشاط القراءة" diff --git a/po/de.po b/po/de.po new file mode 100644 index 0000000..b697bb7 --- /dev/null +++ b/po/de.po @@ -0,0 +1,71 @@ +# This file is distributed under the same license as the PACKAGE package. +# Fabian Affolter <fab@fedoraproject.org>, 2007. +# +# +msgid "" +msgstr "" +"Project-Id-Version: xbook\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-31 09:25+0100\n" +"PO-Revision-Date: 2007-07-30 10:11+0100\n" +"Last-Translator: Fabian Affolter <fab@fedoraproject.org>\n" +"Language-Team: cvs@fedoraproject.org <fedora-trans-de@redhat.com>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: German\n" + +#: activity/activity.info:2 readactivity.py:77 +msgid "Read" +msgstr "" + +#: readactivity.py:73 +msgid "Edit" +msgstr "" + +#: readactivity.py:81 +msgid "View" +msgstr "Ansehen" + +#: readtoolbar.py:60 +msgid "Previous" +msgstr "Vorheriges" + +#: readtoolbar.py:67 +msgid "Next" +msgstr "Nächstes" + +#: readtoolbar.py:105 +msgid "Back" +msgstr "Zurück" + +#: readtoolbar.py:112 +msgid "Forward" +msgstr "Weiter" + +#: readtoolbar.py:207 +msgid "Zoom out" +msgstr "" + +#: readtoolbar.py:213 +msgid "Zoom in" +msgstr "" + +#: readtoolbar.py:219 +msgid "Zoom to width" +msgstr "" + +#: readtoolbar.py:225 +msgid "Zoom to fit" +msgstr "" + +#: readtoolbar.py:230 +msgid "Actual size" +msgstr "" + +#: readtoolbar.py:248 +msgid "%" +msgstr "" + +#~ msgid "Read Activity" +#~ msgstr "Lese-Aktivitäten" diff --git a/po/el.po b/po/el.po new file mode 100644 index 0000000..351089a --- /dev/null +++ b/po/el.po @@ -0,0 +1,71 @@ +# Greek translation of Xbook project. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Simos Xenitellis <simos.lists@googlemail.com>, 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: Xbook project\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-31 09:25+0100\n" +"PO-Revision-Date: 2007-07-25 18:53+0100\n" +"Last-Translator: Simos Xenitellis <simos.lists@googlemail.com>\n" +"Language-Team: Greek <olpc@grnet.gr>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: activity/activity.info:2 readactivity.py:77 +msgid "Read" +msgstr "" + +#: readactivity.py:73 +msgid "Edit" +msgstr "" + +#: readactivity.py:81 +msgid "View" +msgstr "Προβολή" + +#: readtoolbar.py:60 +msgid "Previous" +msgstr "Προηγούμενο" + +#: readtoolbar.py:67 +msgid "Next" +msgstr "Επόμενο" + +#: readtoolbar.py:105 +msgid "Back" +msgstr "Πίσω" + +#: readtoolbar.py:112 +msgid "Forward" +msgstr "Μπροστά" + +#: readtoolbar.py:207 +msgid "Zoom out" +msgstr "" + +#: readtoolbar.py:213 +msgid "Zoom in" +msgstr "" + +#: readtoolbar.py:219 +msgid "Zoom to width" +msgstr "" + +#: readtoolbar.py:225 +msgid "Zoom to fit" +msgstr "" + +#: readtoolbar.py:230 +msgid "Actual size" +msgstr "" + +#: readtoolbar.py:248 +msgid "%" +msgstr "" + +#~ msgid "Read Activity" +#~ msgstr "Ανάγνωση δραστηριότητας" diff --git a/po/es.po b/po/es.po new file mode 100644 index 0000000..f76508c --- /dev/null +++ b/po/es.po @@ -0,0 +1,85 @@ +# Spanish translations for PACKAGE package. +# Copyright (C) 2007 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Tomeu Vizoso <tomeu@tomeuvizoso.net>, 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: xbook\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-31 09:25+0100\n" +"PO-Revision-Date: 2007-09-18 09:59-0300\n" +"Last-Translator: Domingo Becker <domingobecker@gmail.com>\n" +"Language-Team: Fedora Spanish <fedora-trans-es@redhat.com>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-Language: Spanish\n" + +#: activity/activity.info:2 readactivity.py:77 +msgid "Read" +msgstr "" + +#: readactivity.py:73 +msgid "Edit" +msgstr "" + +#: readactivity.py:81 +msgid "View" +msgstr "Ver" + +#: readtoolbar.py:60 +msgid "Previous" +msgstr "Anterior" + +#: readtoolbar.py:67 +msgid "Next" +msgstr "Siguiente" + +#: readtoolbar.py:105 +msgid "Back" +msgstr "Volver" + +#: readtoolbar.py:112 +msgid "Forward" +msgstr "Avanzar" + +#: readtoolbar.py:207 +msgid "Zoom out" +msgstr "" + +#: readtoolbar.py:213 +msgid "Zoom in" +msgstr "" + +#: readtoolbar.py:219 +msgid "Zoom to width" +msgstr "" + +#: readtoolbar.py:225 +msgid "Zoom to fit" +msgstr "" + +#: readtoolbar.py:230 +msgid "Actual size" +msgstr "" + +#: readtoolbar.py:248 +msgid "%" +msgstr "" + +#~ msgid "Read Activity" +#~ msgstr "Actividad Leer" + +#~ msgid "Open a document to read" +#~ msgstr "Abrir un documento para leer" + +#~ msgid "All supported formats" +#~ msgstr "Todos los formatos soportados" + +#~ msgid "All files" +#~ msgstr "Todos los ficheros" + +#~ msgid "Open" +#~ msgstr "Abrir" diff --git a/po/fr.po b/po/fr.po new file mode 100644 index 0000000..d92f9fd --- /dev/null +++ b/po/fr.po @@ -0,0 +1,72 @@ +# translation of xbook.master.po to Français +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Gauthier Ancelin <gauthier.ancelin@laposte.net>, 2007. +msgid "" +msgstr "" +"Project-Id-Version: xbook.master\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-31 09:25+0100\n" +"PO-Revision-Date: 2007-07-31 00:03+0200\n" +"Last-Translator: Gauthier Ancelin <gauthier.ancelin@laposte.net>\n" +"Language-Team: Français <fedora-trans-fr@redhat.com>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" + +#: activity/activity.info:2 readactivity.py:77 +msgid "Read" +msgstr "" + +#: readactivity.py:73 +msgid "Edit" +msgstr "" + +#: readactivity.py:81 +msgid "View" +msgstr "Vue" + +#: readtoolbar.py:60 +msgid "Previous" +msgstr "Précédent" + +#: readtoolbar.py:67 +msgid "Next" +msgstr "Suivant" + +#: readtoolbar.py:105 +msgid "Back" +msgstr "Reculer" + +#: readtoolbar.py:112 +msgid "Forward" +msgstr "Avancer" + +#: readtoolbar.py:207 +msgid "Zoom out" +msgstr "" + +#: readtoolbar.py:213 +msgid "Zoom in" +msgstr "" + +#: readtoolbar.py:219 +msgid "Zoom to width" +msgstr "" + +#: readtoolbar.py:225 +msgid "Zoom to fit" +msgstr "" + +#: readtoolbar.py:230 +msgid "Actual size" +msgstr "" + +#: readtoolbar.py:248 +msgid "%" +msgstr "" + +#~ msgid "Read Activity" +#~ msgstr "Lecture" diff --git a/po/mk.po b/po/mk.po new file mode 100644 index 0000000..f338876 --- /dev/null +++ b/po/mk.po @@ -0,0 +1,72 @@ +# translation of mk.po to Macedonian +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Arangel Angov <arangel@linux.net.mk>, 2007. +msgid "" +msgstr "" +"Project-Id-Version: mk\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-31 09:25+0100\n" +"PO-Revision-Date: 2007-07-06 13:50+0200\n" +"Last-Translator: Arangel Angov <arangel@linux.net.mk>\n" +"Language-Team: Macedonian <ossm-members@hedona.on.net.mk>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" + +#: activity/activity.info:2 readactivity.py:77 +msgid "Read" +msgstr "" + +#: readactivity.py:73 +msgid "Edit" +msgstr "" + +#: readactivity.py:81 +msgid "View" +msgstr "Поглед" + +#: readtoolbar.py:60 +msgid "Previous" +msgstr "Претходно" + +#: readtoolbar.py:67 +msgid "Next" +msgstr "Следно" + +#: readtoolbar.py:105 +msgid "Back" +msgstr "Назад" + +#: readtoolbar.py:112 +msgid "Forward" +msgstr "Напред" + +#: readtoolbar.py:207 +msgid "Zoom out" +msgstr "" + +#: readtoolbar.py:213 +msgid "Zoom in" +msgstr "" + +#: readtoolbar.py:219 +msgid "Zoom to width" +msgstr "" + +#: readtoolbar.py:225 +msgid "Zoom to fit" +msgstr "" + +#: readtoolbar.py:230 +msgid "Actual size" +msgstr "" + +#: readtoolbar.py:248 +msgid "%" +msgstr "" + +#~ msgid "Read Activity" +#~ msgstr "Активност за читање" diff --git a/po/pt.po b/po/pt.po new file mode 100644 index 0000000..b53ba25 --- /dev/null +++ b/po/pt.po @@ -0,0 +1,84 @@ +# Portuguese translations for PACKAGE package. +# Copyright (C) 2007 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Tomeu Vizoso <tomeu@tomeuvizoso.net>, 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-31 09:25+0100\n" +"PO-Revision-Date: 2007-03-23 16:51+0100\n" +"Last-Translator: Tomeu Vizoso <tomeu@tomeuvizoso.net>\n" +"Language-Team: Portuguese <translation-team-pt@lists.sourceforge.net>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: activity/activity.info:2 readactivity.py:77 +msgid "Read" +msgstr "" + +#: readactivity.py:73 +msgid "Edit" +msgstr "" + +#: readactivity.py:81 +msgid "View" +msgstr "" + +#: readtoolbar.py:60 +msgid "Previous" +msgstr "Anterior" + +#: readtoolbar.py:67 +msgid "Next" +msgstr "Seguinte" + +#: readtoolbar.py:105 +msgid "Back" +msgstr "Voltar" + +#: readtoolbar.py:112 +msgid "Forward" +msgstr "Avançar" + +#: readtoolbar.py:207 +msgid "Zoom out" +msgstr "" + +#: readtoolbar.py:213 +msgid "Zoom in" +msgstr "" + +#: readtoolbar.py:219 +msgid "Zoom to width" +msgstr "" + +#: readtoolbar.py:225 +msgid "Zoom to fit" +msgstr "" + +#: readtoolbar.py:230 +msgid "Actual size" +msgstr "" + +#: readtoolbar.py:248 +msgid "%" +msgstr "" + +#~ msgid "Read Activity" +#~ msgstr "Actividade Ler" + +#~ msgid "Open a document to read" +#~ msgstr "Abrir um documento para o ler" + +#~ msgid "All supported formats" +#~ msgstr "Todos os formatos suportados" + +#~ msgid "All files" +#~ msgstr "Todos os ficheiros" + +#~ msgid "Open" +#~ msgstr "Abrir" diff --git a/po/pt_BR.po b/po/pt_BR.po new file mode 100644 index 0000000..98b63b8 --- /dev/null +++ b/po/pt_BR.po @@ -0,0 +1,72 @@ +# translation of pt_BR.po to Brazilian Portuguese +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Diego Búrigo Zacarão <diegobz@gmail.com>, 2007. +msgid "" +msgstr "" +"Project-Id-Version: pt_BR\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-31 09:25+0100\n" +"PO-Revision-Date: 2007-07-03 10:25-0300\n" +"Last-Translator: Diego Búrigo Zacarão <diegobz@gmail.com>\n" +"Language-Team: Brazilian Portuguese <fedora-docs-br@redhat.com>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" + +#: activity/activity.info:2 readactivity.py:77 +msgid "Read" +msgstr "" + +#: readactivity.py:73 +msgid "Edit" +msgstr "" + +#: readactivity.py:81 +msgid "View" +msgstr "Visualizar" + +#: readtoolbar.py:60 +msgid "Previous" +msgstr "Anterior" + +#: readtoolbar.py:67 +msgid "Next" +msgstr "Próxima" + +#: readtoolbar.py:105 +msgid "Back" +msgstr "Voltar" + +#: readtoolbar.py:112 +msgid "Forward" +msgstr "Ir adiante" + +#: readtoolbar.py:207 +msgid "Zoom out" +msgstr "" + +#: readtoolbar.py:213 +msgid "Zoom in" +msgstr "" + +#: readtoolbar.py:219 +msgid "Zoom to width" +msgstr "" + +#: readtoolbar.py:225 +msgid "Zoom to fit" +msgstr "" + +#: readtoolbar.py:230 +msgid "Actual size" +msgstr "" + +#: readtoolbar.py:248 +msgid "%" +msgstr "" + +#~ msgid "Read Activity" +#~ msgstr "Ler a Atividade" diff --git a/po/xbook.pot b/po/xbook.pot new file mode 100644 index 0000000..13e7f96 --- /dev/null +++ b/po/xbook.pot @@ -0,0 +1,41 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-06-21 17:41+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: XbookActivity.py:49 XbookActivity.py:140 +msgid "Read Activity" +msgstr "" + +#: XbookActivity.py:57 +msgid "View" +msgstr "" + +#: xbooktoolbar.py:56 +msgid "Back" +msgstr "" + +#: xbooktoolbar.py:63 +msgid "Forward" +msgstr "" + +#: xbooktoolbar.py:117 +msgid "Previous" +msgstr "" + +#: xbooktoolbar.py:124 +msgid "Next" +msgstr "" diff --git a/readtoolbar.py b/readtoolbar.py new file mode 100644 index 0000000..15d5eab --- /dev/null +++ b/readtoolbar.py @@ -0,0 +1,216 @@ +# Copyright (C) 2008, James Simmons. +# Adapted from code Copyright (C) Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import logging +from gettext import gettext as _ +import re + +import pango +import gobject +import gtk + +from sugar.graphics.toolbutton import ToolButton +from sugar.graphics.menuitem import MenuItem +from sugar.activity import activity + +class ReadToolbar(gtk.Toolbar): + __gtype_name__ = 'ReadToolbar' + + def __init__(self): + gtk.Toolbar.__init__(self) + self._back = ToolButton('go-previous') + self._back.set_tooltip(_('Back')) + self._back.props.sensitive = False + self._back.connect('clicked', self._go_back_cb) + self.insert(self._back, -1) + self._back.show() + + self._forward = ToolButton('go-next') + self._forward.set_tooltip(_('Forward')) + self._forward.props.sensitive = False + self._forward.connect('clicked', self._go_forward_cb) + self.insert(self._forward, -1) + self._forward.show() + + num_page_item = gtk.ToolItem() + + self._num_page_entry = gtk.Entry() + self._num_page_entry.set_text('0') + self._num_page_entry.set_alignment(1) + self._num_page_entry.connect('insert-text', + self._num_page_entry_insert_text_cb) + self._num_page_entry.connect('activate', + self._num_page_entry_activate_cb) + + self._num_page_entry.set_width_chars(4) + + num_page_item.add(self._num_page_entry) + self._num_page_entry.show() + + self.insert(num_page_item, -1) + num_page_item.show() + + total_page_item = gtk.ToolItem() + + self._total_page_label = gtk.Label() + + label_attributes = pango.AttrList() + label_attributes.insert(pango.AttrSize(14000, 0, -1)) + label_attributes.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1)) + self._total_page_label.set_attributes(label_attributes) + + self._total_page_label.set_text(' / 0') + total_page_item.add(self._total_page_label) + self._total_page_label.show() + + self.insert(total_page_item, -1) + total_page_item.show() + + def _num_page_entry_insert_text_cb(self, entry, text, length, position): + if not re.match('[0-9]', text): + entry.emit_stop_by_name('insert-text') + return True + return False + + def _num_page_entry_activate_cb(self, entry): + if entry.props.text: + page = int(entry.props.text) - 1 + else: + page = 0 + + if page >= self.total_pages: + page = self.total_pages - 1 + elif page < 0: + page = 0 + + self.current_page = page + self.activity.set_current_page(page) + self.activity.show_page(page) + entry.props.text = str(page + 1) + self._update_nav_buttons() + + def _go_back_cb(self, button): + self.activity.page_previous() + + def _go_forward_cb(self, button): + self.activity.page_next() + + def _update_nav_buttons(self): + current_page = self.current_page + self._back.props.sensitive = current_page > 0 + self._forward.props.sensitive = \ + current_page < self.total_pages - 1 + + self._num_page_entry.props.text = str(current_page + 1) + self._total_page_label.props.label = \ + ' / ' + str(self.total_pages) + + def set_total_pages(self, pages): + self.total_pages = pages + + def set_current_page(self, page): + self.current_page = page + self._update_nav_buttons() + + def set_activity(self, activity): + self.activity = activity + +class ViewToolbar(gtk.Toolbar): + __gtype_name__ = 'ViewToolbar' + + def __init__(self): + gtk.Toolbar.__init__(self) + self._zoom_out = ToolButton('zoom-out') + self._zoom_out.set_tooltip(_('Zoom out')) + self._zoom_out.connect('clicked', self._zoom_out_cb) + self.insert(self._zoom_out, -1) + self._zoom_out.show() + + self._zoom_in = ToolButton('zoom-in') + self._zoom_in.set_tooltip(_('Zoom in')) + self._zoom_in.connect('clicked', self._zoom_in_cb) + self.insert(self._zoom_in, -1) + self._zoom_in.show() + + def _zoom_in_cb(self, button): + self.activity.font_increase() + + def _zoom_out_cb(self, button): + self.activity.font_decrease() + + def set_activity(self, activity): + self.activity = activity + +class EditToolbar(activity.EditToolbar): + __gtype_name__ = 'EditToolbar' + + def __init__(self): + activity.EditToolbar.__init__(self) + separator = gtk.SeparatorToolItem() + separator.set_draw(False) + separator.set_expand(True) + self.insert(separator, -1) + separator.show() + + search_item = gtk.ToolItem() + + self._search_entry = gtk.Entry() + self._search_entry.connect('activate', self._search_entry_activate_cb) + + width = int(gtk.gdk.screen_width() / 3) + self._search_entry.set_size_request(width, -1) + + search_item.add(self._search_entry) + self._search_entry.show() + + self.insert(search_item, -1) + search_item.show() + + self._prev = ToolButton('go-previous-paired') + self._prev.set_tooltip(_('Previous')) + self._prev.props.sensitive = False + self._prev.connect('clicked', self._find_prev_cb) + self.insert(self._prev, -1) + self._prev.show() + + self._next = ToolButton('go-next-paired') + self._next.set_tooltip(_('Next')) + self._next.props.sensitive = False + self._next.connect('clicked', self._find_next_cb) + self.insert(self._next, -1) + self._next.show() + + def set_activity(self, activity): + self.activity = activity + + def _search_entry_activate_cb(self, entry): + current_page = self.activity.get_current_page() + self.activity.find_begin(entry.props.text) + self._update_find_buttons() + + def _find_changed_cb(self, page, spec): + self._update_find_buttons() + + def _find_prev_cb(self, button): + self.activity.find_previous() + + def _find_next_cb(self, button): + self.activity.find_next() + + def _update_find_buttons(self): + self._prev.props.sensitive = self.activity.can_find_previous() + self._next.props.sensitive = self.activity.can_find_next() diff --git a/readtoolbar.pyc b/readtoolbar.pyc Binary files differnew file mode 100644 index 0000000..36f42f8 --- /dev/null +++ b/readtoolbar.pyc diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..429c697 --- /dev/null +++ b/setup.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +# Copyright (C) 2006, Red Hat, Inc.
+# +# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# +# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# +# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ +from sugar.activity import bundlebuilder + +bundlebuilder.start('ReadEtexts') |