diff options
author | Laurent BERNABE <laurent.bernabe@gmail.com> | 2011-05-18 15:48:21 (GMT) |
---|---|---|
committer | Laurent BERNABE <laurent.bernabe@gmail.com> | 2011-05-18 15:48:21 (GMT) |
commit | a8cde0abe7984acd0411d5464af2b84ec3a3c1b2 (patch) | |
tree | 467f9a808c31a1bc03735ef970b21e7e5ba489f5 |
initial commit
22 files changed, 1040 insertions, 0 deletions
@@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/MAINTAINERS b/MAINTAINERS new file mode 100644 index 0000000..3f3ff8f --- /dev/null +++ b/MAINTAINERS @@ -0,0 +1,4 @@ +Developper: + Laurent BERNABE laurent.bernabe@gmail.com +Beta-Tester: + Oncle Fab onclefab@gmail.com diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..dec8653 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,21 @@ +COPYING +MAINTAINERS +NEWS +com/__init__.py +com/gmail/bernabe/laurent/__init__.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/TheDrawingAreaEventBox.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/MenuActions.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/InputDialog.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/__init__.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/TheWindow.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/PurePyGTKLauncher.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/__init__.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/__init__.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/sugar_launcher/Launcher.py +com/gmail/bernabe/laurent/sugar_olpc/learning_writing/sugar_launcher/__init__.py +com/gmail/bernabe/laurent/sugar_olpc/__init__.py +com/gmail/bernabe/__init__.py +com/gmail/__init__.py +activity/activity-icon.svg +activity/activity.info +setup.py
\ No newline at end of file @@ -0,0 +1,6 @@ +version 1: + * we can draw some figures + * we can choose line size before starting the drawing + * then we can read the figure + * we can choose reading speed (intervals between parts drawings) + diff --git a/activity/activity-icon.svg b/activity/activity-icon.svg new file mode 100644 index 0000000..57dbf0c --- /dev/null +++ b/activity/activity-icon.svg @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!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://creativecommons.org/ns#" + 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="75" + height="75" + id="svg2" + version="1.1" + inkscape:version="0.48.1 r9760" + sodipodi:docname="activity-icon.svg"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="4.04" + inkscape:cx="60.18502" + inkscape:cy="35.332619" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="723" + inkscape:window-height="494" + inkscape:window-x="585" + inkscape:window-y="128" + inkscape:window-maximized="0" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="icon" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-977.36218)"> + <g + id="g3808" + transform="translate(1.7326733,3.2178218)"> + <g + id="g3799"> + <flowRoot + xml:space="preserve" + id="flowRoot2985" + style="font-size:13px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:&fill_color;fill-opacity:1;stroke:none;font-family:Sans" + transform="translate(0,977.36218)"><flowRegion + id="flowRegion2987"><rect + id="rect2989" + width="24.999998" + height="15.841583" + x="16.336634" + y="6.4356437" /></flowRegion><flowPara + id="flowPara2991">Rec</flowPara></flowRoot> <g + id="g3019" + transform="matrix(0.75459052,0.65619597,-0.65619597,0.75459052,673.83143,213.85337)"> + <rect + y="1005.3947" + x="40.594059" + height="3.0608575" + width="12.128713" + id="rect3012" + style="fill:none;stroke:&stroke_color;stroke-width:1.32911694;stroke-opacity:1" /> + <path + inkscape:transform-center-y="0.014715658" + inkscape:transform-center-x="0.61934305" + transform="matrix(4.769314e-4,0.72069953,-0.99999989,3.4372428e-4,72.020611,993.2018)" + d="m 21.287129,32.673269 -1.134885,1.89285 -1.134885,1.89285 -1.071814,-1.929265 -1.071814,-1.929264 2.206699,0.03641 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="false" + sodipodi:arg2="0.54009905" + sodipodi:arg1="-0.5070985" + sodipodi:r2="1.2742116" + sodipodi:r1="2.5484233" + sodipodi:cy="33.910892" + sodipodi:cx="19.059406" + sodipodi:sides="3" + id="path3014" + style="fill:none;stroke:&stroke_color;stroke-opacity:1" + sodipodi:type="star" /> + </g> + </g> + <g + transform="translate(-0.74257426,1.4851485)" + id="g3795"> + <rect + style="fill:none;stroke:&stroke_color;stroke-opacity:1" + id="rect3023" + width="20.79208" + height="19.059406" + x="18.564358" + y="1009.5404" /> + <path + sodipodi:type="arc" + style="fill:&fill_color;fill-opacity:1;stroke:&stroke_color;stroke-opacity:1" + id="path3025" + sodipodi:cx="29.084158" + sodipodi:cy="41.336632" + sodipodi:rx="5.0742574" + sodipodi:ry="5.19802" + d="m 34.158415,41.336632 c 0,2.870787 -2.271822,5.19802 -5.074257,5.19802 -2.802435,0 -5.074257,-2.327233 -5.074257,-5.19802 0,-2.870787 2.271822,-5.19802 5.074257,-5.19802 2.802435,0 5.074257,2.327233 5.074257,5.19802 z" + transform="translate(0,977.36218)" /> + </g> + </g> + </g> +</svg> diff --git a/activity/activity.info b/activity/activity.info new file mode 100755 index 0000000..da6c6d6 --- /dev/null +++ b/activity/activity.info @@ -0,0 +1,10 @@ +[Activity] +name = LearningWriting +bundle_id = com.gmail.bernabe.laurent.sugar_olpc.learning_writing +service_name = com.gmail.bernabe.laurent.sugar_olpc.learning_writing +exec = sugar-activity com.gmail.bernabe.laurent.sugar_olpc.learning_writing.sugar_launcher.Launcher.Launcher +icon = activity-icon +activity_version = 1 +mime_types = text/plain +show_launcher = yes +license = GPLv2+ diff --git a/com/__init__.py b/com/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/com/__init__.py diff --git a/com/gmail/__init__.py b/com/gmail/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/com/gmail/__init__.py diff --git a/com/gmail/bernabe/__init__.py b/com/gmail/bernabe/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/com/gmail/bernabe/__init__.py diff --git a/com/gmail/bernabe/laurent/__init__.py b/com/gmail/bernabe/laurent/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/com/gmail/bernabe/laurent/__init__.py diff --git a/com/gmail/bernabe/laurent/sugar_olpc/__init__.py b/com/gmail/bernabe/laurent/sugar_olpc/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/__init__.py diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/__init__.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/__init__.py diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/InputDialog.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/InputDialog.py new file mode 100755 index 0000000..fc06d01 --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/InputDialog.py @@ -0,0 +1,53 @@ +''' +Created on 13 mai 2011 + +@author: laurent_bernabe +''' + +import pygtk +pygtk.require('2.0') +import gtk + +class InputDialog(gtk.MessageDialog): + ''' + Creates an input dialog with + => a label (for the prompt) + => a text entry + => ok_button and cancel_button + ''' + + + def __init__(self, prompt, parent=None): + ''' + Constructor(prompt, parent=None) + prompt argument : the text of the dialog + parent : the parent control + ''' + gtk.MessageDialog.__init__(self, + parent, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, + gtk.BUTTONS_OK_CANCEL, prompt) + self.__entry = gtk.Entry() + self.vbox.pack_start(self.__entry, True, True, 0) + self.connect("delete-event", lambda widget, event : self.__close() ) + + def run(self): + ''' + Run() + Runs the dialog + ''' + self.show_all() + response = super(InputDialog,self).run() + if response == gtk.RESPONSE_OK : + text = self.__entry.get_text() + else : + text = None + self.destroy() + return text + + def __close(self): + ''' + __close() + Closes the dialog and returns None + ''' + self.destroy() + return None
\ No newline at end of file diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/MenuActions.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/MenuActions.py new file mode 100755 index 0000000..b9b0dc8 --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/MenuActions.py @@ -0,0 +1,72 @@ +''' +Created on 12 mai 2011 + +@author: laurent_bernabe +''' +from com.gmail.bernabe.laurent.sugar_olpc.learning_writing.gui.InputDialog import \ + InputDialog + +import pygtk +pygtk.require('2.0') +import gtk + +class MenuActions(object): + ''' + Wraps codes for the menu actions in both + pure pygtk mode and in sugar mode + ''' + + def __init__(self, wrappedDrawingArea): + ''' + Constructor + => wrappedDrawingArea argument : the instance of + TheDrawingAreaEventBox to act upon + => MenuActions(wrappedDrawingArea) + ''' + self.__wrappedDrawingArea = wrappedDrawingArea + + def manageDrawingWrite(self): + ''' + manageDrawingWrite() + Wraps code for menu Drawing->Write + ''' + dialog = InputDialog("Line thickness value ?\n(I advice you 5)") + user_value = dialog.run() + if user_value != None : + try: + line_thickness = int(user_value) + assert line_thickness > 0 + except (ValueError, AssertionError) : + message = "As you did not give an correct integer value,\n5 will be taken" + message_dialog = gtk.MessageDialog(None, + gtk.DIALOG_MODAL, + gtk.MESSAGE_ERROR, + gtk.BUTTONS_OK, + message) + message_dialog.run() + message_dialog.destroy() + line_thickness = 5 + self.__wrappedDrawingArea.setRecordingMode(line_thickness) + + def manageDrawingRead(self): + ''' + manageDrawingRead() + Wraps code for menu Drawing->Read + ''' + dialog = InputDialog("Steps drawing delays (milliseconds) ?\n(I advice you 10)") + user_value = dialog.run() + if user_value != None : + try: + delay_milliseconds = int(user_value) + assert delay_milliseconds > 0 + except (ValueError, AssertionError) : + message = "As you did not give an correct integer value,\n10 will be taken" + message_dialog = gtk.MessageDialog(None, + gtk.DIALOG_MODAL, + gtk.MESSAGE_ERROR, + gtk.BUTTONS_OK, + message) + message_dialog.run() + message_dialog.destroy() + delay_milliseconds = 10 + self.__wrappedDrawingArea.setReadingMode(delay_milliseconds)
\ No newline at end of file diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/TheDrawingAreaEventBox.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/TheDrawingAreaEventBox.py new file mode 100755 index 0000000..cdd3319 --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/TheDrawingAreaEventBox.py @@ -0,0 +1,217 @@ +''' +Created on 10 mai 2011 + +@author: laurent_bernabe +''' + +import pygtk +pygtk.require('2.0') +import gtk +import cairo +import gobject + +class TheDrawingAreaEventBox(gtk.EventBox): + ''' + A gtk.EventBox wrapping the DrawingArea (or canvas) of the application + We use an EventBox in order to pass events to the contained DrawingArea + ''' + __DARK_GREEN = (27.0/255.0, 103.0/255.0,46.0/255.0) + __WHITE = (1.0, 1.0, 1.0) + + + def __init__(self): + ''' + Simple constructor without argument + ''' + gtk.EventBox.__init__(self) + self.__setFields() + self.__setConnections() + + def __setFields(self): + ''' + Gives values to fields + ''' + self.__drawingArea = gtk.DrawingArea() + self.add(self.__drawingArea) + self.__figures = [] + self.__lineThickness = 1 + # number of steps (for the figures overall) currently drawn + # only used in reading mode (which is the starting mode) + self.__drawn_steps = -1 + # __overall_maximum_steps stores the steps of all the figures + # only used in reading mode (which is the starting mode) + self.__overall_maximum_steps = -1 + # __current_maximum_steps stores the maximum steps the updater thread + # is allowing to draw. In each cycle of the updater thread, this value + # is incremented, giving this impression of a tape reading + # only used in reading mode (which is the starting mode) + self.__current_maximum_steps = -1 + # the updater delay in milliseconds + # => at which intervals, in reading mode, + # the redraws should be done + self.__updater_delay_milliseconds = -1 + self.__mousePressed = False + self.__readingMode = False + + def __setConnections(self): + ''' + Define the events connections + ''' + self.__drawingArea.connect("expose-event", self.__paintSurface) + self.connect("motion-notify-event", self.__manageMouseMovedEvent) + self.connect("button-press-event", self.__manageButtonPressedEvent) + self.connect("button-release-event", self.__manageButtonReleasedEvent) + + def setRecordingMode(self, line_thickness): + ''' + Switch drawing area management to recording mode + => setRecordingMode(line_thickness) + where line_thickness is an integer + ''' + self.__readingMode = False + self.__figures = [] + self.__drawingArea.queue_draw() + self.__startNewFigure() + self.__setLineThickness(line_thickness) + + def setReadingMode(self, intervals_between_steps_milliseconds): + ''' + Switch drawing area management to reading mode + => intervals_between_steps argument is an integer saying delays + in millisecond between steps + => setReadingMode(intervals_between_steps_milliseconds) + => intervals_between_steps_milliseconds : integer + ''' + self.__updater_delay_milliseconds = intervals_between_steps_milliseconds + self.__drawn_steps = 0 + self.__current_maximum_steps = 0 + self.__computeOverallMaximumSteps() + self.__drawingArea.queue_draw() + self.__readingMode = True + self.__regularlyUpdatePaintForReadingMode() + + + def __setLineThickness(self, line_thickness): + ''' + Sets lines thickness. Only integers greater than 0 will be taken + in consideration. + => __setLineThickness(line_thickness) + where line_thickness is an integer + ''' + if isinstance(line_thickness, int) and line_thickness > 0: + self.__lineThickness = line_thickness + + def __paintSurface(self, widget, event): + ''' + Paint the whole drawing area + => __paintSurface(widget, event) + ''' + cairoContext = self.__drawingArea.window.cairo_create() + self.__drawBackground(cairoContext) + self.__drawFigures(cairoContext) + return True + + def __drawBackground(self, cairoContext): + ''' + Paints the background + => __drawBackground(cairoContext) + where cairoContext is a cairo context of the DrawingArea + ''' + cairoContext.set_source_rgb(*TheDrawingAreaEventBox.__DARK_GREEN) + cairoContext.rectangle( 0,0, *(self.window.get_size()) ) + cairoContext.fill() + + def __drawFigures(self, cairoContext): + ''' + Draws the figures + => __drawFigures(cairoContext) + where cairoContext is a cairo context of the DrawingArea + ''' + cairoContext.set_source_rgb(*TheDrawingAreaEventBox.__WHITE) + cairoContext.set_line_width(self.__lineThickness) + cairoContext.set_line_join(cairo.LINE_JOIN_ROUND) + cairoContext.set_line_cap(cairo.LINE_CAP_ROUND) + if self.__readingMode: + self.__drawn_steps = 0 + for current_figure in self.__figures: + if len(current_figure) > 0 : + startPoint = current_figure[0] + cairoContext.move_to(*startPoint) + if self.__readingMode: + self.__drawn_steps += 1 + for pointIndex in range(1, len(current_figure)): + if self.__readingMode and self.__drawn_steps >= self.__current_maximum_steps : + cairoContext.stroke() + return + endPoint = current_figure[pointIndex] + cairoContext.line_to(*endPoint) + startPoint = endPoint + if self.__readingMode : + self.__drawn_steps += 1 + cairoContext.stroke() + + def __startNewFigure(self): + ''' + Starts a new figure + ''' + self.__figures += [[]] + + def __addPointToCurrentFigure(self, pointTuple): + ''' + Adds a point to the current figure + ==> __addPointToCurrentFigure(pointTuple) + where pointTuple is a tuple of the point coordinates + ''' + self.__figures[len(self.__figures)-1] += [pointTuple] + + def __computeOverallMaximumSteps(self): + ''' + Computes the number of steps of all the Figures to draw + ''' + self.__overall_maximum_steps = 0 + for current_figure in self.__figures : + self.__overall_maximum_steps += len(current_figure) + + def __manageMouseMovedEvent(self, widget, event): + ''' + Manage mouse move event + => __manageMouseMovedEvent(widget, event) + ''' + if self.__mousePressed: + self.__addPointToCurrentFigure((event.x, event.y)) + self.__drawingArea.queue_draw() # repaint the drawing area + return True # we don't need further handling for this event + + def __manageButtonPressedEvent(self, widget, event): + ''' + Manage button pressed event + => __manageButtonPressedEvent(widget, event) + ''' + self.__startNewFigure() + self.__mousePressed = True + return True # we don't need further handling for this event + + def __manageButtonReleasedEvent(self, widget, event): + ''' + Manage button released event + => __manageButtonReleasedEvent(widget, event) + ''' + self.__mousePressed = False + return True # we don't need further handling for this event + + def __regularlyUpdatePaintForReadingMode(self): + ''' + Increases the current maximum drawn steps and repaint all, at + regular delays. (For reading mode) + => __regularlyUpdatePaintForReadingMode(regular_delay_milliseconds) + regular_delay_milliseconds : integer + ''' + if self.__readingMode: + self.__current_maximum_steps += 1 + self.__drawingArea.queue_draw() + if self.__current_maximum_steps < self.__overall_maximum_steps : + gobject.timeout_add( + self.__updater_delay_milliseconds, + self.__regularlyUpdatePaintForReadingMode + ) +
\ No newline at end of file diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/__init__.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/gui/__init__.py diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/PurePyGTKLauncher.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/PurePyGTKLauncher.py new file mode 100755 index 0000000..204552d --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/PurePyGTKLauncher.py @@ -0,0 +1,12 @@ +''' +Created on 10 mai 2011 + +@author: laurent_bernabe +''' + +import gtk +from com.gmail.bernabe.laurent.sugar_olpc.learning_writing.pure_pygtk_launcher.TheWindow import TheWindow + +if __name__ == '__main__': + TheWindow() + gtk.main()
\ No newline at end of file diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/TheWindow.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/TheWindow.py new file mode 100755 index 0000000..d45e418 --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/TheWindow.py @@ -0,0 +1,69 @@ +''' +Created on 10 mai 2011 + +@author: laurent_bernabe +''' +import pygtk + +from com.gmail.bernabe.laurent.sugar_olpc.learning_writing.gui.MenuActions \ +import MenuActions + +pygtk.require('2.0') +import gtk + +from \ +com.gmail.bernabe.laurent.sugar_olpc.learning_writing.gui.TheDrawingAreaEventBox \ +import TheDrawingAreaEventBox + +class TheWindow(gtk.Window): + ''' + The Window of the application + ''' + + def __init__(self): + ''' + Simple constructor + ''' + gtk.Window.__init__(self) + self.__wrapped_drawing_area = TheDrawingAreaEventBox() + self.__menu_actions = MenuActions(self.__wrapped_drawing_area) + self.__vbox = gtk.VBox(False, 2) + self.add(self.__vbox) + self.__addMenuBar() + self.__vbox.pack_start(self.__wrapped_drawing_area) + self.set_size_request(300, 300) + self.connect("delete-event", lambda widget, event : gtk.main_quit()) + self.show_all() + + def __addMenuBar(self): + ''' + Adds a menu bar + ''' + menu_bar = gtk.MenuBar() + drawing_item = gtk.MenuItem("_Drawing") + menu_bar.append(drawing_item) + drawing_sub_menu = gtk.Menu() + drawing_write_item = gtk.RadioMenuItem(None, "_Write") + drawing_write_item.set_active(True) + drawing_write_item.connect("activate", self.__manageDrawingWrite) + drawing_read_item = gtk.RadioMenuItem(drawing_write_item, "_Read") + drawing_read_item.connect("activate", self.__manageDrawingRead) + drawing_sub_menu.append(drawing_write_item) + drawing_sub_menu.append(drawing_read_item) + drawing_item.set_submenu(drawing_sub_menu) + self.__vbox.pack_start(menu_bar, False, True) + menu_bar.show_all() + + def __manageDrawingWrite(self, menu_item): + ''' + Manages drawing->write menu + ''' + if menu_item.get_active() : + self.__menu_actions.manageDrawingWrite() + + def __manageDrawingRead(self, menu_item): + ''' + Manages drawing->read menu + ''' + if menu_item.get_active() : + self.__menu_actions.manageDrawingRead()
\ No newline at end of file diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/__init__.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/pure_pygtk_launcher/__init__.py diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/sugar_launcher/Launcher.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/sugar_launcher/Launcher.py new file mode 100755 index 0000000..84c1c5f --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/sugar_launcher/Launcher.py @@ -0,0 +1,86 @@ +''' +Created on 10 mai 2011 + +@author: laurent_bernabe +''' +from sugar.activity import activity + +from com.gmail.bernabe.laurent.sugar_olpc.learning_writing.gui.MenuActions \ +import MenuActions + +from com.gmail.bernabe.laurent.sugar_olpc.learning_writing.gui.TheDrawingAreaEventBox \ +import TheDrawingAreaEventBox + +import pygtk +pygtk.require('2.0') +import gtk + +class Launcher(activity.Activity): + ''' + Launcher for sugar bundle + ''' + + def __init__(self, handle): + ''' + Constructor + ''' + activity.Activity.__init__(self, handle) + # Be carefull on the callings order !!! + # => self.__wrapped_drawing_area is not defined before + # self.__createAndSetCanvas() call + # => self.__createAndSetToolbox need self.__menu_actions + self.__createAndSetCanvas() + self.__menu_actions = MenuActions(self.__wrapped_drawing_area) + self.__createAndSetToolbox() + + def __createAndSetToolbox(self): + ''' + Creates and sets the tool box + ''' + toolbox = activity.ActivityToolbox(self) + self.__addDrawingToolbarIn(toolbox) + self.set_toolbox(toolbox) + toolbox.show_all() + + def __createAndSetCanvas(self): + ''' + Creates and set the Canvas + ''' + self.__wrapped_drawing_area = TheDrawingAreaEventBox() + self.set_canvas(self.__wrapped_drawing_area) + self.show_all() + + def __manageDrawingWrite(self, menu_item): + ''' + Manages drawing->write menu + ''' + if menu_item.get_active() : + self.__menu_actions.manageDrawingWrite() + + def __manageDrawingRead(self, menu_item): + ''' + Manages drawing->read menu + ''' + if menu_item.get_active() : + self.__menu_actions.manageDrawingRead() + + def __addDrawingToolbarIn(self, toolbox): + ''' + Creates and add Drawing toolbar in toolbox + => __addDrawingToolbarIn(toolbox) + ''' + drawing_toolbar = gtk.Toolbar() + drawing_toolbar.set_style(gtk.TOOLBAR_ICONS) + #---------------------- + drawing_toolbar_write_button = gtk.RadioToolButton(None, gtk.STOCK_MEDIA_RECORD) + drawing_toolbar_write_button.set_active(True) + drawing_toolbar_write_button.connect("clicked", self.__manageDrawingWrite ) + drawing_toolbar.insert(drawing_toolbar_write_button, 0) + #--------------------- + drawing_toolbar_read_button = gtk.RadioToolButton(drawing_toolbar_write_button, gtk.STOCK_MEDIA_PLAY) + drawing_toolbar_read_button.set_active(False) + drawing_toolbar_read_button.connect("clicked", self.__manageDrawingRead ) + drawing_toolbar.insert(drawing_toolbar_read_button, 1) + #-------------------- + toolbox.add_toolbar('Drawing', drawing_toolbar) + drawing_toolbar.show_all()
\ No newline at end of file diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/sugar_launcher/__init__.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/sugar_launcher/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/sugar_launcher/__init__.py diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..1abb31e --- /dev/null +++ b/setup.py @@ -0,0 +1,24 @@ + #!/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()
\ No newline at end of file |