diff options
author | Pootle daemon <pootle@pootle.sugarlabs.org> | 2012-11-28 05:31:35 (GMT) |
---|---|---|
committer | Pootle daemon <pootle@pootle.sugarlabs.org> | 2012-11-28 05:31:35 (GMT) |
commit | 94c9abdfedbc6f24d372f5f53ecdb062e2894451 (patch) | |
tree | 6b5e127cef07b393e996644b8805c2f1f803c283 | |
parent | e3c07acba2bf4edf61e8230c8c07e151877cfc9a (diff) | |
parent | 3dc13b615fea5e4256f2a6674074506a2c5c8d58 (diff) |
Merge branch 'master' of git.sugarlabs.org:write/mainline
-rw-r--r-- | AbiWordActivity.py | 3 | ||||
-rw-r--r-- | activity/activity.info | 2 | ||||
-rw-r--r-- | widgets.py | 60 |
3 files changed, 63 insertions, 2 deletions
diff --git a/AbiWordActivity.py b/AbiWordActivity.py index ccfec0e..8c75cd2 100644 --- a/AbiWordActivity.py +++ b/AbiWordActivity.py @@ -48,6 +48,7 @@ from toolbar import ListToolbar from toolbar import InsertToolbar from toolbar import ParagraphToolbar from widgets import ExportButtonFactory +from widgets import DocumentView from port import chooser import speech @@ -65,7 +66,7 @@ class AbiWordActivity(activity.Activity): os.chdir(os.path.expanduser('~')) # create our main abiword canvas - self.abiword_canvas = Abi.Widget() + self.abiword_canvas = DocumentView() self._shared_activity = None self._new_instance = True toolbar_box = ToolbarBox() diff --git a/activity/activity.info b/activity/activity.info index 4226afc..12bc1dd 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -3,7 +3,7 @@ name = Write bundle_id = org.laptop.AbiWordActivity exec = sugar-activity AbiWordActivity.AbiWordActivity icon = activity-write -activity_version = 83 +activity_version = 84 show_launcher = 1 mime_types = text/rtf;text/plain;application/x-abiword;text/x-xml-abiword;application/msword;application/rtf;application/xhtml+xml;text/html;application/vnd.oasis.opendocument.text license = GPLv2+ @@ -18,6 +18,9 @@ import time from gettext import gettext as _ import logging +from gi.repository import Abi +from gi.repository import GLib + from sugar3.graphics.radiotoolbutton import RadioToolButton from sugar3.graphics.combobox import ComboBox from sugar3.graphics.palette import Palette @@ -247,3 +250,60 @@ class ExportButtonFactory(): datastore.write(fileObject, transfer_ownership=True) fileObject.destroy() del fileObject + + +class DocumentView(Abi.Widget): + + def __init__(self): + Abi.Widget.__init__(self) + self.connect('size-allocate', self.__size_allocate_cb) + self.connect('request-clear-area', self.__request_clear_area_cb) + self.connect('unset-clear-area', self.__unset_clear_area_cb) + self.osk_changed = False + self.dy = 0 + + def __shallow_move_cb(self): + self.moveto_right() + return False + + def __size_allocate_cb(self, widget, allocation): + self.set_allocation(allocation) + + if self.get_child() is not None: + child_allocation = allocation + child_allocation.y = 0 + child_allocation.x = 0 + child_allocation.height -= self.dy + self.get_child().size_allocate(allocation) + + if self.osk_changed is True: + self.moveto_left() + GLib.timeout_add(100, self.__shallow_move_cb) + self.osk_changed = False + + def __request_clear_area_cb(self, widget, clear, cursor): + allocation = widget.get_allocation() + allocation.x = 0 + allocation.y = 0 + allocation.x, allocation.y = \ + widget.get_window().get_root_coords(allocation.x, allocation.y) + + if clear.y > allocation.y + allocation.height or \ + clear.y + clear.height < allocation.y: + return False + + self.dy = allocation.y + allocation.height - clear.y + + # Ensure there's at least some room for the view + if self.dy > allocation.height - 80: + self.dy = 0 + return False + + self.osk_changed = True + self.queue_resize() + return True + + def __unset_clear_area_cb(self, widget, snap_back): + self.dy = 0 + self.queue_resize() + return True |