diff options
author | Rafael Ortiz <rafael@activitycentral.com> | 2011-06-09 21:13:21 (GMT) |
---|---|---|
committer | Rafael Ortiz <rafael@activitycentral.com> | 2011-06-09 21:13:21 (GMT) |
commit | dd9ff73475ad78a6bb3af6fb655b9b4594a95862 (patch) | |
tree | 0ea6d1be307bae7cf43825e539014b5c1b2733cd |
Initial
-rw-r--r-- | COPYING | 339 | ||||
-rw-r--r-- | MANIFEST | 8 | ||||
-rw-r--r-- | NEWS | 0 | ||||
-rw-r--r-- | activity.py | 84 | ||||
-rw-r--r-- | activity.pyc | bin | 0 -> 4156 bytes | |||
-rw-r--r-- | activity/activity-icon.svg | 87 | ||||
-rw-r--r-- | activity/activity.info | 8 | ||||
-rw-r--r-- | pippy_app.py | 205 | ||||
-rw-r--r-- | pippy_app.pyc | bin | 0 -> 10103 bytes | |||
-rwxr-xr-x | recordmydesktop | bin | 0 -> 92532 bytes | |||
-rwxr-xr-x | setup.py | 21 |
11 files changed, 752 insertions, 0 deletions
@@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, 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 Library 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) 19yy <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., 675 Mass Ave, Cambridge, MA 02139, 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) 19yy 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 Library General +Public License instead of this License. diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..cb1d070 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,8 @@ +recordmydesktop +COPYING +setup.py +pippy_app.py +activity.py +NEWS +activity/activity-icon.svg +activity/activity.info diff --git a/activity.py b/activity.py new file mode 100644 index 0000000..90b46c7 --- /dev/null +++ b/activity.py @@ -0,0 +1,84 @@ +from sugar.activity import activity + +class ViewSourceActivity(activity.Activity): + """Activity subclass which handles the 'view source' key.""" + def __init__(self, handle): + super(ViewSourceActivity, self).__init__(handle) + self.__source_object_id = None # XXX: persist this across invocations? + self.connect('key-press-event', self._key_press_cb) + def _key_press_cb(self, widget, event): + import gtk + if gtk.gdk.keyval_name(event.keyval) == 'XF86Start': + self.view_source() + return True + return False + def view_source(self): + """Implement the 'view source' key by saving pippy_app.py to the + datastore, and then telling the Journal to view it.""" + if self.__source_object_id is None: + from sugar import profile + from sugar.datastore import datastore + from sugar.activity.activity import get_bundle_name, get_bundle_path + from gettext import gettext as _ + import os.path + jobject = datastore.create() + metadata = { + 'title': _('%s Source') % get_bundle_name(), + 'title_set_by_user': '1', + 'suggested_filename': 'pippy_app.py', + 'icon-color': profile.get_color().to_string(), + 'mime_type': 'text/x-python', + } + for k,v in metadata.items(): + jobject.metadata[k] = v # dict.update method is missing =( + jobject.file_path = os.path.join(get_bundle_path(), 'pippy_app.py') + datastore.write(jobject) + self.__source_object_id = jobject.object_id + jobject.destroy() + self.journal_show_object(self.__source_object_id) + def journal_show_object(self, object_id): + """Invoke journal_show_object from sugar.activity.activity if it + exists.""" + try: + from sugar.activity.activity import show_object_in_journal + show_object_in_journal(object_id) + except ImportError: + pass # no love from sugar. + +class VteActivity(ViewSourceActivity): + def __init__(self, handle): + import gtk, pango, vte + super(VteActivity, self).__init__(handle) + toolbox = activity.ActivityToolbox(self) + self.set_toolbox(toolbox) + toolbox.show() + + # creates vte widget + self._vte = vte.Terminal() + self._vte.set_size(30,5) + self._vte.set_size_request(200, 300) + font = 'Monospace 10' + self._vte.set_font(pango.FontDescription(font)) + self._vte.set_colors(gtk.gdk.color_parse ('#000000'), + gtk.gdk.color_parse ('#E7E7E7'), + []) + # ...and its scrollbar + vtebox = gtk.HBox() + vtebox.pack_start(self._vte) + vtesb = gtk.VScrollbar(self._vte.get_adjustment()) + vtesb.show() + vtebox.pack_start(vtesb, False, False, 0) + self.set_canvas(vtebox) + self.show_all() + + # now start subprocess. + self._vte.grab_focus() + bundle_path = activity.get_bundle_path() + # the 'sleep 1' works around a bug with the command dying before + # the vte widget manages to snarf the last bits of its output + self._pid = self._vte.fork_command \ + (command='/bin/sh', + argv=['/bin/sh','-c', + 'python %s/pippy_app.py; sleep 1' % bundle_path], + envv=["PYTHONPATH=%s/library" % bundle_path], + directory=bundle_path) diff --git a/activity.pyc b/activity.pyc Binary files differnew file mode 100644 index 0000000..bdd1218 --- /dev/null +++ b/activity.pyc diff --git a/activity/activity-icon.svg b/activity/activity-icon.svg new file mode 100644 index 0000000..efb2b7d --- /dev/null +++ b/activity/activity-icon.svg @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ + <!ENTITY ns_svg "http://www.w3.org/2000/svg"> + <!ENTITY ns_xlink " http://www.w3.org/1999/xlink"> + <!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="55" + height="55" + id="svg4535" + sodipodi:version="0.32" + inkscape:version="0.45" + version="1.0" + sodipodi:docname="translation.svg" + sodipodi:docbase="/Users/madeleine" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + sodipodi:modified="true"> + <defs + id="defs4537" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + gridtolerance="10000" + guidetolerance="10" + objecttolerance="10" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="2.8" + inkscape:cx="28.795022" + inkscape:cy="49.551772" + inkscape:document-units="px" + inkscape:current-layer="layer1" + width="48px" + height="48px" + showgrid="true" + inkscape:window-width="697" + inkscape:window-height="581" + inkscape:window-x="121" + inkscape:window-y="73" /> + <metadata + id="metadata4540"> + <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 + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + style="fill:&fill_color;;fill-opacity:1;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" + d="M 28,47.464789 C 22,53.169014 4,47.464789 4,47.464789 L 4,7.5352113 C 4,7.5352113 22,1.8309859 28,7.5352113 C 28,7.5352113 28,47.464789 28,47.464789 z " + id="path4547" + sodipodi:nodetypes="ccccc" /> + <path + style="fill:&fill_color;;fill-opacity:1;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" + d="M 28,47.464789 C 34,53.169014 52,47.464789 52,47.464789 L 52,7.5352116 C 52,7.5352116 34,1.8309856 28,7.5352116 C 28,7.5352116 28,47.464789 28,47.464789 z " + id="path4579" + sodipodi:nodetypes="ccccc" /> + <path + style="fill:&stroke_color;;fill-opacity:1;fill-rule:evenodd;stroke:&fill_color;;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 44.779122,34.354615 L 44.779122,39.866263 L 18.817388,39.866263 L 18.817388,46 L 8,37.110439 L 18.817388,28.220878 L 18.817388,34.354615 L 44.779122,34.354615 z " + id="path4585" + sodipodi:nodetypes="cccccccc" /> + <path + style="fill:&stroke_color;;fill-opacity:1;fill-rule:evenodd;stroke:&fill_color;;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 11.220878,16.133737 L 11.220878,21.645385 L 37.182612,21.645385 L 37.182612,27.779122 L 48,18.889561 L 37.182612,10 L 37.182612,16.133737 L 11.220878,16.133737 z " + id="path2214" + sodipodi:nodetypes="cccccccc" /> + </g> +</svg> diff --git a/activity/activity.info b/activity/activity.info new file mode 100644 index 0000000..3593b89 --- /dev/null +++ b/activity/activity.info @@ -0,0 +1,8 @@ +[Activity] +name = Screencast +bundle_id = org.laptop.Screencast +service_name = org.laptop.Screencast +class = pippy_app.ScreencastActivity +icon = activity-icon +activity_version = 1 +show_launcher = yes diff --git a/pippy_app.py b/pippy_app.py new file mode 100644 index 0000000..a787ab6 --- /dev/null +++ b/pippy_app.py @@ -0,0 +1,205 @@ +# Copyright 2008 Chris Ball. +# +# 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 + +"""Screencast Activity: An activity for producing XO tutorials.""" +from gettext import gettext as _ +from dbus.service import method, signal as dbus_signal +import fcntl +import gobject +import gtk +import logging +import os +import popen2 +import re +import shutil +import signal + +from activity import ViewSourceActivity +from sugar.activity.activity import ActivityToolbox, \ + get_bundle_path, get_bundle_name + +SERVICE = "org.laptop.Screencast" +IFACE = SERVICE +PATH = "/org/laptop/Screencast" + +OUTFILE = "/tmp/recordmydesktop.ogv" + +class ScreencastActivity(ViewSourceActivity): + """Screencast Activity as specified in activity.info""" + def __init__(self, handle): + """Set up the Screencast activity.""" + super(ScreencastActivity, self).__init__(handle) + self._logger = logging.getLogger('screencast-activity') + + from sugar.graphics.menuitem import MenuItem + from sugar.graphics.icon import Icon + + # Main layout. Record button, stop button, label. + hbox = gtk.HBox() + vbox = gtk.VBox() + + # Toolbar. + toolbox = ActivityToolbox(self) + self.set_toolbox(toolbox) + toolbox.show() + + # Recording buttons. + self.record = gtk.Button("Record") + self.record.connect("clicked", self.record_cb) + self.record.set_size_request(100, 100) + self.stop = gtk.Button("Stop") + self.stop.connect("clicked", self.stop_cb) + self.stop.set_size_request(100, 100) + self.stop.set_sensitive(False) + + # Status label. + self.status = gtk.Label(_("Status: Stopped")) + hbox.pack_start(self.record, expand=False) + hbox.pack_start(self.stop, expand=False) + hbox.pack_start(self.status, expand=False) + + vbox.pack_start(hbox) + self.set_canvas(vbox) + self.show_all() + + def write_file (self, file_path): + print "Saving file to %s" % file_path + self.metadata['mime_type'] = 'video/ogg' + try: + shutil.copy(OUTFILE, file_path) + except IOError, e: + print "Error saving outfile: %s" % e + + # FIXME: This fails in /tmp. + try: + os.remove(OUTFILE) + except OSError, e: + print "Error removing outfile: %s" % e + + def record_cb(self, record): + self.stop.set_sensitive(True) + self.record.set_sensitive(False) + execargs = ["./recordmydesktop", "--overwrite", "-o", OUTFILE] + self.childp = popen2.Popen3(execargs, "t", 0) + flags = fcntl.fcntl(self.childp.childerr, fcntl.F_GETFL) + fcntl.fcntl(self.childp.childerr, fcntl.F_SETFL, flags|os.O_NONBLOCK) + self.timed_id = gobject.timeout_add(1000, self.check_status_cb) + self.status.set_text("Status: Recording") + + def stop_cb(self, stop): + print "Stop button clicked" + exitret = os.waitpid(self.childp.pid, os.WNOHANG) + if exitret[0] == 0: + os.kill(self.childp.pid, signal.SIGTERM) + self.record.set_sensitive(True) + self.stop.set_sensitive(False) + + def check_status_cb(self): + if self.childp.pid: + exitret = os.waitpid(self.childp.pid, os.WNOHANG) + if exitret[0] != 0: + print "no more record process" + # The recording process exited + self.status.set_text("Status: Stopped") + return False + else: + # Maybe we have new stderr. + while True: + try: + err_line = self.childp.childerr.readline() + print err_line + if err_line.startswith("STATE:ENCODING"): + self.status.set_text("Status: Encoding, please wait") + except: + break + return True + +############# TEMPLATES AND INLINE FILES ############## +ACTIVITY_INFO_TEMPLATE = """ +[Activity] +name = %(title)s +bundle_id = %(bundle_id)s +service_name = %(bundle_id)s +class = %(class)s +icon = activity-icon +activity_version = %(version)d +mime_types = %(mime_types)s +show_launcher = yes +%(extra_info)s +""" + +PIPPY_ICON = \ +"""<?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 "#010101"> + <!ENTITY fill_color "#FFFFFF"> +]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="activity-pippy"> + <path d="M28.497,48.507 c5.988,0,14.88-2.838,14.88-11.185c0-9.285-7.743-10.143-10.954-11.083c-3.549-0.799-5.913-1.914-6.055-3.455 c-0.243-2.642,1.158-3.671,3.946-3.671c0,0,6.632,3.664,12.266,0.74c1.588-0.823,4.432-4.668,4.432-7.32 c0-2.653-9.181-5.719-11.967-5.719c-2.788,0-5.159,3.847-5.159,3.847c-5.574,0-11.149,5.306-11.149,10.612 c0,5.305,5.333,9.455,11.707,10.612c2.963,0.469,5.441,2.22,4.878,5.438c-0.457,2.613-2.995,5.306-8.361,5.306 c-4.252,0-13.3-0.219-14.745-4.079c-0.929-2.486,0.168-5.205,1.562-5.205l-0.027-0.16c-1.42-0.158-5.548,0.16-5.548,5.465 C8.202,45.452,17.347,48.507,28.497,48.507z" fill="&fill_color;" stroke="&stroke_color;" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5"/> + <path d="M42.579,19.854c-2.623-0.287-6.611-2-7.467-5.022" fill="none" stroke="&stroke_color;" stroke-linecap="round" stroke-width="3"/> + <circle cx="35.805" cy="10.96" fill="&stroke_color;" r="1.676"/> +</g></svg><!-- " --> +""" + +PIPPY_DEFAULT_ICON = \ +"""<?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 "#010101"> + <!ENTITY fill_color "#FFFFFF"> +]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" + viewBox="0 0 55 55" width="55px" x="0px" y="0px" xml:space="preserve" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" +><g display="block" id="activity-icon"><path + d="M 28.497,48.507 C 34.485,48.507 43.377,45.669 43.377,37.322 C 43.377,32.6795 41.44125,30.14375 39.104125,28.651125 C 36.767,27.1585 38.482419,26.816027 39.758087,25.662766 C 39.42248,24.275242 37.206195,22.826987 36.262179,21.037968 C 34.005473,20.582994 27.526,19.113 30.314,19.113 C 30.314,19.113 36.946,22.777 42.58,19.853 C 44.168,19.03 47.012,15.185 47.012,12.533 C 47.012,9.88 37.831,6.814 35.045,6.814 C 32.257,6.814 29.886,10.661 29.886,10.661 C 24.312,10.661 12.043878,16.258005 12.043878,21.564005 C 12.043878,24.216505 16.585399,30.069973 19.144694,33.736352 C 22.438716,38.455279 27.257,31.3065 30.444,31.885 C 33.407,32.354 35.885,34.105 35.322,37.323 C 34.865,39.936 32.327,42.629 26.961,42.629 C 22.709,42.629 13.661,42.41 12.216,38.55 C 11.287,36.064 12.384,33.345 13.778,33.345 L 13.751,33.185 C 12.331,33.027 8.203,33.345 8.203,38.65 C 8.202,45.452 17.347,48.507 28.497,48.507 z " + fill="&fill_color;" stroke="&stroke_color;" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5" /> + <path d="M42.579,19.854c-2.623-0.287-6.611-2-7.467-5.022" fill="none" stroke="&stroke_color;" stroke-linecap="round" stroke-width="3"/> + <circle cx="35.805" cy="10.96" fill="&stroke_color;" r="1.676"/> +</g></svg><!-- " --> +""" + +############# ACTIVITY META-INFORMATION ############### +# this is used by Screencast to generate a bundle for itself. + +def pippy_activity_version(): + """Returns the version number of the generated activity bundle.""" + return 1 +def pippy_activity_extra_files(): + """Returns a map of 'extra' files which should be included in the + generated activity bundle.""" + # Cheat here and generate the map from the fs contents. + extra = {} + bp = get_bundle_path() + for d in [ 'po', 'data' ]: # everybody gets library already + for root, dirs, files in os.walk(os.path.join(bp, d)): + for name in files: + fn = os.path.join(root, name).replace(bp+'/', '') + extra[fn] = open(os.path.join(root, name), 'r').read() + extra['activity/activity-default.svg'] = PIPPY_DEFAULT_ICON + return extra +def pippy_activity_news(): + """Return the NEWS file for this activity.""" + # Cheat again. + return open(os.path.join(get_bundle_path(), 'NEWS')).read() +def pippy_activity_icon(): + """Return an SVG document specifying the icon for this activity.""" + return PIPPY_ICON +def pippy_activity_class(): + """Return the class which should be started to run this activity.""" + return 'pippy_app.ScreencastActivity' +def pippy_activity_bundle_id(): + """Return the bundle_id for the generated activity.""" + return 'org.laptop.Screencast' +def pippy_activity_mime_types(): + """Return the mime types handled by the generated activity, as a list.""" + return None diff --git a/pippy_app.pyc b/pippy_app.pyc Binary files differnew file mode 100644 index 0000000..bac0a48 --- /dev/null +++ b/pippy_app.pyc diff --git a/recordmydesktop b/recordmydesktop Binary files differnew file mode 100755 index 0000000..f930c61 --- /dev/null +++ b/recordmydesktop diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..530f97c --- /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() |