1 #Copyright (C) 2008 Codethink Ltd
3 #This library is free software; you can redistribute it and/or
4 #modify it under the terms of the GNU Lesser General Public
5 #License version 2 as published by the Free Software Foundation.
7 #This program is distributed in the hope that it will be useful,
8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 #GNU General Public License for more details.
11 #You should have received a copy of the GNU Lesser General Public License
12 #along with this program; if not, write to the Free Software
13 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 from base import BaseProxy
17 from factory import add_accessible_class
24 #------------------------------------------------------------------------------
26 class EditableText(Text):
28 Derived from interface Text, EditableText provides methods for
29 modifying textual content of components which support editing.
30 EditableText also interacts with the system clipboard via copyText,
31 cutText, and pasteText.
34 def copyText(self, *args, **kwargs):
36 Copy a range of text into the system clipboard.
38 the character offset of the first character in the range of text
41 the offset of the first character past the end of the range of
44 func = self.get_dbus_method("copyText")
45 return func(*args, **kwargs)
47 def cutText(self, *args, **kwargs):
49 Excise a range of text from a Text object, copying it into the
52 the character offset of the first character in the range of text
55 the offset of the first character past the end of the range of
57 @return True if the text was successfully cut, False otherwise.
59 func = self.get_dbus_method("cutText")
60 return func(*args, **kwargs)
62 def deleteText(self, *args, **kwargs):
64 Excise a range of text from a Text object without copying it
65 into the system clipboard.
67 the character offset of the first character in the range of text
70 the offset of the first character past the end of the range of
72 @return True if the text was successfully deleted, False otherwise.
74 func = self.get_dbus_method("deleteText")
75 return func(*args, **kwargs)
77 def insertText(self, *args, **kwargs):
79 Insert new text contents into an existing text object at a given
80 location, while retaining the old contents.
82 the character offset into the Text implementor's content at which
83 the new content will be inserted.
85 a UTF-8 string of which length characters will be inserted into
86 the text object's text buffer.
88 the number of characters of text to insert. If the character
89 count of text is less than or equal to length, the entire contents
90 of text will be inserted.
91 @return True if the text content was successfully inserted, False
94 func = self.get_dbus_method("insertText")
95 return func(*args, **kwargs)
97 def pasteText(self, *args, **kwargs):
99 Copy the text contents of the system clipboard, if any, into
100 a Text object, inserting it at a particular character offset.
102 the character offset before which the text will be inserted.
103 @return True if the text was successfully pasted into the Text
104 object, False otherwise.
106 func = self.get_dbus_method("pasteText")
107 return func(*args, **kwargs)
109 def setAttributes(self, *args, **kwargs):
111 Apply a particular set of attributes to a range of text.
112 @return True if the text attributes were successfully modified,
115 func = self.get_dbus_method("setAttributes")
116 return func(*args, **kwargs)
118 def setTextContents(self, *args, **kwargs):
120 Replace the text contents with a new string, discarding the old
123 a UTF-8 string with which the text object's contents will be
125 @return True if the text content was successfully changed, False
128 func = self.get_dbus_method("setTextContents")
129 return func(*args, **kwargs)
131 # ATTENTION - Register the Application class with the accessible factory.
132 add_accessible_class(interfaces.ATSPI_EDITABLE_TEXT, EditableText)
134 #END----------------------------------------------------------------------------