diff options
author | Walter Bender <walter@sugarlabs.org> | 2014-01-13 21:31:53 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2014-01-13 21:31:53 (GMT) |
commit | fcf16f9f4f0c9e5654017db84215041f7dc7704f (patch) | |
tree | 7c3ed453ffee27badcbaee1084e9f66ddf043a3e | |
parent | c97dc560c31ce093915d1b44c40dca84b324aab8 (diff) | |
parent | 8944bad3d4de6cdee622c93725ef4941a9f45ab9 (diff) |
merges from GCI committed to correct branch
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | filedialog.py (renamed from FileDialog.py) | 0 | ||||
-rw-r--r-- | icondialog.py (renamed from IconDialog.py) | 0 | ||||
-rw-r--r-- | icons/pippy-create-bundle.svg | 54 | ||||
-rw-r--r-- | icons/pippy-create-disutils.svg | 50 | ||||
-rw-r--r-- | icons/pippy-create_bundle.svg | 34 | ||||
-rw-r--r-- | icons/pippy-export-doc.svg (renamed from icons/pippy-export_doc.svg) | 0 | ||||
-rw-r--r-- | icons/pippy-export-example.svg (renamed from icons/pippy-export_example.svg) | 0 | ||||
-rw-r--r-- | icons/pippy-export-library.svg | 74 | ||||
-rw-r--r-- | icons/pippy-import-doc.svg | 83 | ||||
-rw-r--r-- | notebook.py (renamed from Notebook.py) | 0 | ||||
-rw-r--r-- | pippy_app.py | 385 |
12 files changed, 485 insertions, 201 deletions
@@ -1,15 +1,17 @@ 55 ENHANCEMENTS: -* Edit on multiple tabs (svineet) +* Export as disutils, as library, as example (Sai Vineet) +* Edit on multiple tabs (Sai Vineet) * Add custom icon selection when saving as Sugar activity (Ignacio Rodriguez) +* New icons 54 ENHANCEMENTS: * Add confirmation alert before loading new projects (Emil Dudev) * Use open palette instead of treeview (Ignacio Rodriguez) -* Show/Hide terminal widget (svineet) +* Show/Hide terminal widget (Sai Vineet) * Added new examples (math/pi, math/stern-brocot) * Added i18n support for examples (Jorge Alberto Gómez López) * Added tutorials (Jorge Alberto Gómez López) diff --git a/FileDialog.py b/filedialog.py index ea6da02..ea6da02 100644 --- a/FileDialog.py +++ b/filedialog.py diff --git a/IconDialog.py b/icondialog.py index 1087d8a..1087d8a 100644 --- a/IconDialog.py +++ b/icondialog.py diff --git a/icons/pippy-create-bundle.svg b/icons/pippy-create-bundle.svg new file mode 100644 index 0000000..43b089a --- /dev/null +++ b/icons/pippy-create-bundle.svg @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<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" + version="1.1" + width="55" + height="55" + viewBox="0 0 55 55" + id="svg2" + xml:space="preserve"><metadata + id="metadata12"><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><defs + id="defs10" /><rect + width="22.039503" + height="22.039503" + x="-27.222408" + y="44.910072" + transform="matrix(0.83456543,-0.55090883,0.83456543,0.55090883,0,0)" + id="rect3936" + style="fill:none;stroke:#ffffff;stroke-width:2.08566689;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><g + transform="matrix(1,0,0,-1,-27.367495,50.587259)" + id="g4770" + style="stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><g + transform="translate(34.0803,-1006.42)" + id="g4772" + style="stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><polyline + transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)" + style="fill:none;stroke:#ffffff;stroke-width:3.01383209;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + points="51.562,15.306 41.17,16.188 42.053,5.794" + id="polyline4774" /><path + d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067" + id="path4776" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g><g + transform="translate(-8.8152101,-10.21213)" + id="g4709-6" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><path + d="m 28.090497,40.381834 c 3.974667,-0.06221 9.878139,-1.753708 9.878139,-6.911631 0,-5.73755 -4.497322,-6.751378 -6.645938,-7.265877 -2.341015,-0.560569 -4.551388,-0.765446 -4.645545,-1.7177 -0.161426,-1.632578 0.768742,-2.268447 2.619566,-2.268447 0,0 4.402457,2.26367 8.142826,0.457274 1.05398,-0.509016 2.942197,-2.884533 2.942197,-4.523303 0,-1.639388 -6.094837,-3.533985 -7.944332,-3.533985 -1.850824,0 -3.424821,2.377206 -3.424821,2.377206 -3.700318,0 -7.401302,3.278776 -7.401302,6.557553 0,3.278158 3.417627,6.165937 7.653709,6.85261 1.962616,0.318142 3.729994,1.076753 3.3563,3.065286 -0.303435,1.614661 -1.696316,2.770905 -5.258386,2.736319 -2.749295,-0.02669 -6.417645,0.138525 -8.840139,-1.714654 -1.314772,-1.005784 -1.146531,-3.578075 -1.146531,-3.578075 0,0 -3.4034,0.162415 -2.757976,3.376412 0.965274,4.806741 6.251099,6.204027 13.472233,6.091012 z" + id="path2474-6" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path + d="M 37.438881,22.676071 C 35.697593,22.498722 33.050146,21.440194 32.481887,19.572788" + id="path2476-1" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><circle + cx="35.805" + cy="10.96" + r="1.676" + transform="matrix(0.3489205,0,0,0.32478716,20.448838,13.620467)" + id="circle2478-8" + style="fill:none;stroke:#ffffff;stroke-width:5.94110632;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></svg>
\ No newline at end of file diff --git a/icons/pippy-create-disutils.svg b/icons/pippy-create-disutils.svg new file mode 100644 index 0000000..3f0717c --- /dev/null +++ b/icons/pippy-create-disutils.svg @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<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" + version="1.1" + width="55" + height="55" + viewBox="0 0 55 55" + id="svg2" + xml:space="preserve"><metadata + id="metadata12"><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><defs + id="defs10" /><path + d="m 25.71298,32.769402 3.289473,-3.289473 6.578948,0 3.289473,3.289473 13.157895,0 0,20.394737 -26.315789,0 z" + id="path3854" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><g + transform="matrix(1,0,0,-1,-27.367494,50.58726)" + id="g4770" + style="stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><g + transform="translate(34.0803,-1006.42)" + id="g4772" + style="stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><polyline + transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)" + style="fill:none;stroke:#ffffff;stroke-width:3.01383209;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + points="51.562,15.306 41.17,16.188 42.053,5.794" + id="polyline4774" /><path + d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067" + id="path4776" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g><g + transform="translate(-8.815209,-10.212129)" + id="g4709-6" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><path + d="m 28.090497,40.381834 c 3.974667,-0.06221 9.878139,-1.753708 9.878139,-6.911631 0,-5.73755 -4.497322,-6.751378 -6.645938,-7.265877 -2.341015,-0.560569 -4.551388,-0.765446 -4.645545,-1.7177 -0.161426,-1.632578 0.768742,-2.268447 2.619566,-2.268447 0,0 4.402457,2.26367 8.142826,0.457274 1.05398,-0.509016 2.942197,-2.884533 2.942197,-4.523303 0,-1.639388 -6.094837,-3.533985 -7.944332,-3.533985 -1.850824,0 -3.424821,2.377206 -3.424821,2.377206 -3.700318,0 -7.401302,3.278776 -7.401302,6.557553 0,3.278158 3.417627,6.165937 7.653709,6.85261 1.962616,0.318142 3.729994,1.076753 3.3563,3.065286 -0.303435,1.614661 -1.696316,2.770905 -5.258386,2.736319 -2.749295,-0.02669 -6.417645,0.138525 -8.840139,-1.714654 -1.314772,-1.005784 -1.146531,-3.578075 -1.146531,-3.578075 0,0 -3.4034,0.162415 -2.757976,3.376412 0.965274,4.806741 6.251099,6.204027 13.472233,6.091012 z" + id="path2474-6" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path + d="M 37.438881,22.676071 C 35.697593,22.498722 33.050146,21.440194 32.481887,19.572788" + id="path2476-1" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><circle + cx="35.805" + cy="10.96" + r="1.676" + transform="matrix(0.3489205,0,0,0.32478716,20.448838,13.620467)" + id="circle2478-8" + style="fill:none;stroke:#ffffff;stroke-width:5.94110632;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></svg>
\ No newline at end of file diff --git a/icons/pippy-create_bundle.svg b/icons/pippy-create_bundle.svg deleted file mode 100644 index b5d0a26..0000000 --- a/icons/pippy-create_bundle.svg +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ - <!ENTITY fill_color "#FFFFFF"> - <!ENTITY stroke_color "#010101"> -]> -<svg - xmlns="http://www.w3.org/2000/svg" - version="1.1" - width="55" - height="55" - viewBox="0 0 55 55" - id="svg2" - xml:space="preserve"><rect - width="29.497099" - height="29.497099" - x="-28.68516" - y="32.139339" - transform="matrix(0.83456543,-0.55090883,0.83456543,0.55090883,0,0)" - id="rect3936" - style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:3.64991689;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" /><g - transform="translate(0,-2)" - id="g4709"><path - d="m 28.090497,40.381834 c 3.974667,-0.06221 9.878139,-1.753708 9.878139,-6.911631 0,-5.73755 -4.497322,-6.751378 -6.645938,-7.265877 -2.341015,-0.560569 -4.551388,-0.765446 -4.645545,-1.7177 -0.161426,-1.632578 0.768742,-2.268447 2.619566,-2.268447 0,0 4.402457,2.26367 8.142826,0.457274 1.05398,-0.509016 2.942197,-2.884533 2.942197,-4.523303 0,-1.639388 -6.094837,-3.533985 -7.944332,-3.533985 -1.850824,0 -3.424821,2.377206 -3.424821,2.377206 -3.700318,0 -7.401302,3.278776 -7.401302,6.557553 0,3.278158 3.417627,6.165937 7.653709,6.85261 1.962616,0.318142 3.729994,1.076753 3.3563,3.065286 -0.303435,1.614661 -1.696316,2.770905 -5.258386,2.736319 -2.749295,-0.02669 -6.417645,0.138525 -8.840139,-1.714654 -1.314772,-1.005784 -1.146531,-3.578075 -1.146531,-3.578075 0,0 -3.4034,0.162415 -2.757976,3.376412 0.965274,4.806741 6.251099,6.204027 13.472233,6.091012 z" - id="path2474" - style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path - d="M 37.438881,22.676071 C 35.697593,22.498722 33.050146,21.440194 32.481887,19.572788" - id="path2476" - style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><circle - cx="35.805" - cy="10.96" - r="1.676" - transform="matrix(0.3489205,0,0,0.32478716,20.448838,13.620467)" - id="circle2478" - style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.42034841;stroke-miterlimit:4;stroke-dasharray:none" /></g></svg>
\ No newline at end of file diff --git a/icons/pippy-export_doc.svg b/icons/pippy-export-doc.svg index b8e8c86..b8e8c86 100644 --- a/icons/pippy-export_doc.svg +++ b/icons/pippy-export-doc.svg diff --git a/icons/pippy-export_example.svg b/icons/pippy-export-example.svg index 014460b..014460b 100644 --- a/icons/pippy-export_example.svg +++ b/icons/pippy-export-example.svg diff --git a/icons/pippy-export-library.svg b/icons/pippy-export-library.svg new file mode 100644 index 0000000..256cf47 --- /dev/null +++ b/icons/pippy-export-library.svg @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<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" + version="1.1" + width="55" + height="55" + viewBox="0 0 55 55" + id="Icon" + xml:space="preserve" + style="overflow:visible"><metadata + id="metadata17"><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><defs + id="defs15" /><circle + cx="35.805" + cy="10.96" + r="1.676" + transform="matrix(0.66385342,0,0,0.61793751,-2.1883406,-1.1658202)" + id="circle2478" + style="fill:none;stroke:#ffffff;stroke-width:3.12263775;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><g + transform="matrix(1,0,0,-1,-30.386574,49.171266)" + id="g4770" + style="stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><g + transform="translate(34.0803,-1006.42)" + id="g4772" + style="stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><polyline + transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)" + style="fill:none;stroke:#ffffff;stroke-width:3.01383209;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + points="51.562,15.306 41.17,16.188 42.053,5.794" + id="polyline4774" /><path + d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067" + id="path4776" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g><g + transform="translate(-11.83429,-11.628123)" + id="g4709" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><path + d="m 28.090497,40.381834 c 3.974667,-0.06221 9.878139,-1.753708 9.878139,-6.911631 0,-5.73755 -4.497322,-6.751378 -6.645938,-7.265877 -2.341015,-0.560569 -4.551388,-0.765446 -4.645545,-1.7177 -0.161426,-1.632578 0.768742,-2.268447 2.619566,-2.268447 0,0 4.402457,2.26367 8.142826,0.457274 1.05398,-0.509016 2.942197,-2.884533 2.942197,-4.523303 0,-1.639388 -6.094837,-3.533985 -7.944332,-3.533985 -1.850824,0 -3.424821,2.377206 -3.424821,2.377206 -3.700318,0 -7.401302,3.278776 -7.401302,6.557553 0,3.278158 3.417627,6.165937 7.653709,6.85261 1.962616,0.318142 3.729994,1.076753 3.3563,3.065286 -0.303435,1.614661 -1.696316,2.770905 -5.258386,2.736319 -2.749295,-0.02669 -6.417645,0.138525 -8.840139,-1.714654 -1.314772,-1.005784 -1.146531,-3.578075 -1.146531,-3.578075 0,0 -3.4034,0.162415 -2.757976,3.376412 0.965274,4.806741 6.251099,6.204027 13.472233,6.091012 z" + id="path2474-6" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path + d="M 37.438881,22.676071 C 35.697593,22.498722 33.050146,21.440194 32.481887,19.572788" + id="path2476-1" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><circle + cx="35.805" + cy="10.96" + r="1.676" + transform="matrix(0.3489205,0,0,0.32478716,20.448838,13.620467)" + id="circle2478-8" + style="fill:none;stroke:#ffffff;stroke-width:5.94110632;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><polygon + points="31.874,6.088 43.818,18.027 43.818,48.914 10.932,48.914 10.932,6.088 " + transform="matrix(0.57043764,0,0,0.57043764,27.123144,25.347613)" + id="polygon9" + style="fill:none;stroke:#ffffff;stroke-width:2.62955999;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><polyline + id="polyline11" + points="43.818,18.027 31.874,18.027 31.874,6.088 " + style="fill:none;stroke:#ffffff;stroke-width:2.62955999;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + transform="matrix(0.57043764,0,0,0.57043764,27.123144,25.347613)" /><path + d="m 42.788977,49.853753 c 1.647156,0 4.093132,-0.780667 4.093132,-3.076727 0,-2.554081 -2.129913,-2.790096 -3.013183,-3.048668 -0.976245,-0.219786 -1.626525,-0.526495 -1.665586,-0.950388 -0.06684,-0.726751 0.318538,-1.009804 1.085451,-1.009804 0,0 1.824304,1.007879 3.374083,0.203556 0.436821,-0.226387 1.219137,-1.284055 1.219137,-2.013557 0,-0.729776 -2.525473,-1.57316 -3.291835,-1.57316 -0.766913,0 -1.419118,1.058218 -1.419118,1.058218 -1.533274,0 -3.066823,1.459553 -3.066823,2.919107 0,1.459279 1.466981,2.600844 3.220315,2.919108 0.815051,0.12901 1.49669,0.610668 1.341821,1.495863 -0.125709,0.718775 -0.823852,1.459554 -2.299911,1.459554 -1.169623,0 -3.658512,-0.06024 -4.055997,-1.122035 -0.255545,-0.683839 0.04621,-1.431771 0.429669,-1.431771 l -0.0074,-0.04402 c -0.390608,-0.04346 -1.526122,0.04402 -1.526122,1.503291 -2.75e-4,1.871068 2.515296,2.711425 5.582394,2.711425 z" + id="path3086" + style="fill:none;stroke:#ffffff;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path + d="m 46.662599,41.971997 c -0.721525,-0.07895 -1.818528,-0.550152 -2.053993,-1.381432" + id="path3088" + style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><circle + cx="35.805" + cy="10.96" + r="1.676" + transform="matrix(0.27507609,0,0,0.27507609,34.950134,36.510637)" + id="circle3090" + style="fill:none;stroke:#ffffff;stroke-width:5.45303679;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></svg>
\ No newline at end of file diff --git a/icons/pippy-import-doc.svg b/icons/pippy-import-doc.svg new file mode 100644 index 0000000..2026290 --- /dev/null +++ b/icons/pippy-import-doc.svg @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<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" + version="1.1" + width="55" + height="55" + viewBox="0 0 55 55" + id="svg2" + xml:space="preserve"><metadata + id="metadata27"><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><defs + id="defs25" /><g + transform="translate(-28.621062,-0.03390309)" + id="g3789"><g + transform="matrix(0.55205508,0,0,0.55205508,75.618464,18.235971)" + id="g4382" + style="stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><g + transform="translate(-80.093659,12.220029)" + id="g4308" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><g + id="g4310" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><path + d="m 6.736,49.002 h 24.52 c 2.225,0 3.439,-1.447 3.439,-3.441 v -27.28 c 0,-1.73 -1.732,-3.441 -3.439,-3.441 h -4.389" + id="path4312" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g><g + transform="translate(-80.093659,12.220029)" + id="g4314" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><g + id="g4316" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><path + d="m 26.867,38.592 c 0,1.836 -1.345,3.201 -3.441,4.047 L 6.736,49.002 V 14.84 l 16.69,-8.599 c 2.228,-0.394 3.441,0.84 3.441,2.834 v 29.517 z" + id="path4318" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g><path + d="m -70.669659,54.827029 c 0,0 -1.351,-0.543 -2.702,-0.543 -1.351,0 -2.703,0.543 -2.703,0.543" + id="path4320" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path + d="m -70.669659,44.226029 c 0,0 -1.239,-0.543 -2.815,-0.543 -1.577,0 -2.59,0.543 -2.59,0.543" + id="path4322" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path + d="m -70.669659,33.898029 c 0,0 -1.125,-0.544 -2.927,-0.544 -1.802,0 -2.478,0.544 -2.478,0.544" + id="path4324" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><line + id="line4326" + y2="23.725029" + y1="58.753029" + x2="-66.884659" + x1="-66.884659" + style="fill:none;stroke:#ffffff;stroke-width:3.62282681;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><g + transform="matrix(0,-1,-1,0,71.401366,89.939026)" + id="g4770" + style="stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><g + transform="translate(34.0803,-1006.42)" + id="g4772" + style="stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><polyline + id="polyline4774" + points="51.562,15.306 41.17,16.188 42.053,5.794" + style="fill:none;stroke:#ffffff;stroke-width:3.01383209;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)" /><path + d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067" + id="path4776" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g></g><g + transform="translate(10.165712,-11.628123)" + id="g4709" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><path + d="m 28.090497,40.381834 c 3.974667,-0.06221 9.878139,-1.753708 9.878139,-6.911631 0,-5.73755 -4.497322,-6.751378 -6.645938,-7.265877 -2.341015,-0.560569 -4.551388,-0.765446 -4.645545,-1.7177 -0.161426,-1.632578 0.768742,-2.268447 2.619566,-2.268447 0,0 4.402457,2.26367 8.142826,0.457274 1.05398,-0.509016 2.942197,-2.884533 2.942197,-4.523303 0,-1.639388 -6.094837,-3.533985 -7.944332,-3.533985 -1.850824,0 -3.424821,2.377206 -3.424821,2.377206 -3.700318,0 -7.401302,3.278776 -7.401302,6.557553 0,3.278158 3.417627,6.165937 7.653709,6.85261 1.962616,0.318142 3.729994,1.076753 3.3563,3.065286 -0.303435,1.614661 -1.696316,2.770905 -5.258386,2.736319 -2.749295,-0.02669 -6.417645,0.138525 -8.840139,-1.714654 -1.314772,-1.005784 -1.146531,-3.578075 -1.146531,-3.578075 0,0 -3.4034,0.162415 -2.757976,3.376412 0.965274,4.806741 6.251099,6.204027 13.472233,6.091012 z" + id="path2474-6" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path + d="M 37.438881,22.676071 C 35.697593,22.498722 33.050146,21.440194 32.481887,19.572788" + id="path2476-1" + style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><circle + cx="35.805" + cy="10.96" + r="1.676" + transform="matrix(0.3489205,0,0,0.32478716,20.448838,13.620467)" + id="circle2478-8" + style="fill:none;stroke:#ffffff;stroke-width:5.94110632;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></svg>
\ No newline at end of file diff --git a/Notebook.py b/notebook.py index 23b0be3..23b0be3 100644 --- a/Notebook.py +++ b/notebook.py diff --git a/pippy_app.py b/pippy_app.py index 2b95c04..28fbf44 100644 --- a/pippy_app.py +++ b/pippy_app.py @@ -48,13 +48,14 @@ from gettext import gettext as _ from sugar3.datastore import datastore from sugar3.activity.widgets import EditToolbar from sugar3.activity.widgets import StopButton -from sugar3.activity.activity import get_bundle_path from sugar3.activity.activity import get_bundle_name -from sugar3.graphics.alert import ConfirmationAlert +from sugar3.activity.activity import get_bundle_path from sugar3.graphics.alert import Alert -from sugar3.graphics.icon import Icon +from sugar3.graphics.alert import ConfirmationAlert from sugar3.graphics.alert import NotifyAlert from sugar3.graphics import style +from sugar3.graphics.icon import Icon +from sugar3.graphics.objectchooser import ObjectChooser from sugar3.graphics.toggletoolbutton import ToggleToolButton from sugar3.graphics.objectchooser import ObjectChooser @@ -66,15 +67,16 @@ from activity import TARGET_TYPE_TEXT import groupthink.sugar_tools import groupthink.gtk_tools -from FileDialog import FileDialog -from IconDialog import IconDialog +from filedialog import FileDialog +from icondialog import IconDialog text_buffer = None # magic prefix to use utf-8 source encoding -PYTHON_PREFIX = """#!/usr/bin/python +PYTHON_PREFIX = '''#!/usr/bin/python # -*- coding: utf-8 -*- -""" -default_categoties = [_('graphics'), _('math'), _('pyhton'), _('sound'), +''' +# Force category names into Pootle +DEFAULT_CATEGORIES = [_('graphics'), _('math'), _('pyhton'), _('sound'), _('string'), _('tutorials')] from sugar3.graphics.toolbarbox import ToolbarButton @@ -86,7 +88,18 @@ SIZE_Y = Gdk.Screen.height() groupthink_mimetype = 'pickle/groupthink-pippy' -from Notebook import SourceNotebook +from notebook import SourceNotebook + +DISUTILS_SETUP_SCRIPT = """#!/usr/bin/python +# -*- coding: utf-8 -*- +from distutils.core import setup +setup(name='{modulename}', + version='1.0', + py_modules=[ + {filenames} + ], + ) +""" # This is .format()'ed with the list of the file names. DISUTILS_SETUP_SCRIPT = """#!/usr/bin/python # -*- coding: utf-8 -*- @@ -101,7 +114,7 @@ setup(name='{modulename}', class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): - """Pippy Activity as specified in activity.info""" + '''Pippy Activity as specified in activity.info''' def early_setup(self): from gi.repository import GtkSource self.initial_text_buffer = GtkSource.Buffer() @@ -110,7 +123,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): self.loaded_session = [] self.session_data = [] - sys.path.append(os.path.join(self.get_activity_root(), "Library")) + sys.path.append(os.path.join(self.get_activity_root(), 'Library')) def initialize_display(self): self._logger = logging.getLogger('pippy-activity') @@ -123,39 +136,39 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): separator.show() activity_toolbar.insert(separator, -1) - import_py_button = ToolButton("pippy-import_py") - import_py_button.set_tooltip(_("Import Python File")) - import_py_button.connect("clicked", self._import_py_cb) + import_py_button = ToolButton('pippy-import-doc') + import_py_button.set_tooltip(_('Import Python file to new tab')) + import_py_button.connect('clicked', self._import_py_cb) import_py_button.show() activity_toolbar.insert(import_py_button, -1) - save_as_library = ToolButton("pippy-save_library") - save_as_library.set_tooltip(_("Save this file as a library")) - save_as_library.connect("clicked", self._save_as_library) - save_as_library.show() - activity_toolbar.insert(save_as_library, -1) - - export_doc_button = ToolButton('pippy-export_doc') - export_doc_button.set_tooltip(_("Export as Pippy Document")) + export_doc_button = ToolButton('pippy-export-doc') + export_doc_button.set_tooltip(_('Export as Pippy document')) export_doc_button.connect('clicked', self._export_document_cb) export_doc_button.show() activity_toolbar.insert(export_doc_button, -1) - export_example_button = ToolButton('pippy-export_example') - export_example_button.set_tooltip(_("Export as Pippy Example")) + save_as_library = ToolButton('pippy-export-library') + save_as_library.set_tooltip(_('Save this file to the Pippy library')) + save_as_library.connect('clicked', self._save_as_library) + save_as_library.show() + activity_toolbar.insert(save_as_library, -1) + + export_example_button = ToolButton('pippy-export-example') + export_example_button.set_tooltip(_('Export as new Pippy example')) export_example_button.connect('clicked', self._export_example_cb) export_example_button.show() activity_toolbar.insert(export_example_button, -1) - create_bundle_button = ToolButton('pippy-create_bundle') - create_bundle_button.set_tooltip(_("Create Activity Bundle")) + create_bundle_button = ToolButton('pippy-create-bundle') + create_bundle_button.set_tooltip(_('Create a Sugar activity bundle')) create_bundle_button.connect('clicked', self._create_bundle_cb) create_bundle_button.show() activity_toolbar.insert(create_bundle_button, -1) - export_disutils = ToolButton("pippy-create_bundle") - export_disutils.set_tooltip(_("Export as disutils package")) - export_disutils.connect("clicked", self.__export_disutils_cb) + export_disutils = ToolButton('pippy-create-disutils') + export_disutils.set_tooltip(_('Export as a disutils package')) + export_disutils.connect('clicked', self.__export_disutils_cb) export_disutils.show() activity_toolbar.insert(export_disutils, -1) @@ -176,20 +189,20 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): actions_toolbar = self.get_toolbar_box().toolbar - self.toggle_output = ToggleToolButton("tray-show") - self.toggle_output.set_tooltip(_("Show output panel")) - self.toggle_output.connect("toggled", self._toggle_output_cb) + self.toggle_output = ToggleToolButton('tray-show') + self.toggle_output.set_tooltip(_('Show output panel')) + self.toggle_output.connect('toggled', self._toggle_output_cb) actions_toolbar.insert(self.toggle_output, -1) # The "go" button goicon_bw = Gtk.Image() - goicon_bw.set_from_file("%s/icons/run_bw.svg" % os.getcwd()) + goicon_bw.set_from_file('%s/icons/run_bw.svg' % os.getcwd()) goicon_color = Gtk.Image() - goicon_color.set_from_file("%s/icons/run_color.svg" % os.getcwd()) - gobutton = ToolButton(label=_("Run!")) + goicon_color.set_from_file('%s/icons/run_color.svg' % os.getcwd()) + gobutton = ToolButton(label=_('Run!')) gobutton.props.accelerator = _('<alt>r') gobutton.set_icon_widget(goicon_bw) - gobutton.set_tooltip(_("Run!")) + gobutton.set_tooltip(_('Run!')) gobutton.connect('clicked', self.flash_cb, dict({'bw': goicon_bw, 'color': goicon_color})) gobutton.connect('clicked', self.gobutton_cb) @@ -197,40 +210,40 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): # The "stop" button stopicon_bw = Gtk.Image() - stopicon_bw.set_from_file("%s/icons/stopit_bw.svg" % os.getcwd()) + stopicon_bw.set_from_file('%s/icons/stopit_bw.svg' % os.getcwd()) stopicon_color = Gtk.Image() - stopicon_color.set_from_file("%s/icons/stopit_color.svg" % os.getcwd()) - stopbutton = ToolButton(label=_("Stop")) + stopicon_color.set_from_file('%s/icons/stopit_color.svg' % os.getcwd()) + stopbutton = ToolButton(label=_('Stop')) stopbutton.props.accelerator = _('<alt>s') stopbutton.set_icon_widget(stopicon_bw) stopbutton.connect('clicked', self.flash_cb, dict({'bw': stopicon_bw, 'color': stopicon_color})) stopbutton.connect('clicked', self.stopbutton_cb) - stopbutton.set_tooltip(_("Stop")) + stopbutton.set_tooltip(_('Stop')) actions_toolbar.insert(stopbutton, -1) # The "clear" button clearicon_bw = Gtk.Image() - clearicon_bw.set_from_file("%s/icons/eraser_bw.svg" % os.getcwd()) + clearicon_bw.set_from_file('%s/icons/eraser_bw.svg' % os.getcwd()) clearicon_color = Gtk.Image() - clearicon_color.set_from_file("%s/icons/eraser_color.svg" % + clearicon_color.set_from_file('%s/icons/eraser_color.svg' % os.getcwd()) - clearbutton = ToolButton(label=_("Clear")) + clearbutton = ToolButton(label=_('Clear')) clearbutton.props.accelerator = _('<alt>c') clearbutton.set_icon_widget(clearicon_bw) clearbutton.connect('clicked', self.clearbutton_cb) clearbutton.connect('clicked', self.flash_cb, dict({'bw': clearicon_bw, 'color': clearicon_color})) - clearbutton.set_tooltip(_("Clear")) + clearbutton.set_tooltip(_('Clear')) actions_toolbar.insert(clearbutton, -1) activity_toolbar.show() - examples = ToolButton("pippy-openoff") - examples.set_tooltip(_("Load example")) - examples.connect("clicked", self.load_example) + examples = ToolButton('pippy-openoff') + examples.set_tooltip(_('Load example')) + examples.connect('clicked', self.load_example) self.get_toolbar_box().toolbar.insert(Gtk.SeparatorToolItem(), -1) self.get_toolbar_box().toolbar.insert(examples, -1) @@ -283,13 +296,13 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): # check if dir exists in pref language, if exists, add it if os.path.exists(os.path.join(lang_path, folder)): direntry = { - "name": _(folder.capitalize()), - "path": os.path.join(lang_path, folder) + "/"} + 'name': _(folder.capitalize()), + 'path': os.path.join(lang_path, folder) + '/'} # if not try to see if it's in default English path elif os.path.exists(os.path.join(en_lang_path, folder)): direntry = { - "name": _(folder.capitalize()), - "path": os.path.join(en_lang_path, folder) + "/"} + 'name': _(folder.capitalize()), + 'path': os.path.join(en_lang_path, folder) + '/'} self.paths.append([direntry['name'], direntry['path']]) # Adding local examples @@ -297,7 +310,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): self.paths.append([_('My examples'), root]) self.source_tabs = SourceNotebook(self) - self.source_tabs.connect("tab-added", self._add_source_cb) + self.source_tabs.connect('tab-added', self._add_source_cb) if self.loaded_from_journal and self.py_file: self.source_tabs.add_tab( self.initial_title, @@ -341,15 +354,15 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): shown = button.get_active() if shown: self.outbox.show_all() - self.toggle_output.set_tooltip(_("Hide output panel")) - self.toggle_output.set_icon_name("tray-hide") + self.toggle_output.set_tooltip(_('Hide output panel')) + self.toggle_output.set_icon_name('tray-hide') else: self.outbox.hide() - self.toggle_output.set_tooltip(_("Show output panel")) - self.toggle_output.set_icon_name("tray-show") + self.toggle_output.set_tooltip(_('Show output panel')) + self.toggle_output.set_icon_name('tray-show') def load_example(self, widget): - widget.set_icon_name("pippy-openon") + widget.set_icon_name('pippy-openon') dialog = FileDialog(self.paths, self, widget) dialog.run() path = dialog.get_path() @@ -376,11 +389,11 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): def selection_cb(self, value): self.save() - self._logger.debug("clicked! %s" % value['path']) + self._logger.debug('clicked! %s' % value['path']) _file = open(value['path'], 'r') lines = _file.readlines() text_buffer = self.source_tabs.get_text_buffer() - text_buffer.set_text("".join(lines)) + text_buffer.set_text(''.join(lines)) text_buffer.set_modified(False) self.metadata['title'] = value['name'] self.stopbutton_cb(None) @@ -392,8 +405,9 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): if text_buffer.get_modified(): alert = ConfirmationAlert() alert.props.title = _('Example selection Warning') - alert.props.msg = _('You have modified the currently selected file.' - ' Discard changes?') + alert.props.msg = \ + _('You have modified the currently selected file. ' + 'Discard changes?') alert.connect('response', self._discard_changes_cb, path) self.add_alert(alert) return False @@ -428,7 +442,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): def clearbutton_cb(self, button): self.save() text_buffer = self.source_tabs.get_text_buffer() - text_buffer.set_text("") + text_buffer.set_text('') text_buffer.set_modified(False) self.metadata['title'] = _('%s Activity') % get_bundle_name() self.stopbutton_cb(None) @@ -440,7 +454,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): zipdata = zip(data[0], data[1]) for name, content in zipdata: with open(os.path.join(tmp_dir, name), 'w') as f: - # write utf-8 coding prefix if there's not already one + # Write utf-8 coding prefix if there's not one already if re.match(r'coding[:=]\s*([-\w.]+)', '\n'.join(content.splitlines()[:2])) is None: f.write(PYTHON_PREFIX) @@ -448,7 +462,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): def _reset_vte(self): self._vte.grab_focus() - self._vte.feed("\x1B[H\x1B[J\x1B[0;39m") + self._vte.feed('\x1B[H\x1B[J\x1B[0;39m') def __undobutton_cb(self, butston): text_buffer = self.source_tabs.get_text_buffer() @@ -461,20 +475,18 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): text_buffer.redo() def __copybutton_cb(self, button): - # global text_buffer text_buffer = self.source_tabs.get_text_buffer() clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) text_buffer.copy_clipboard(clipboard) def __pastebutton_cb(self, button): - # global text_buffer text_buffer = self.source_tabs.get_text_buffer() clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) text_buffer.paste_clipboard(clipboard, None, True) def gobutton_cb(self, button): from shutil import copy2 - self.stopbutton_cb(button) # try stopping old code first. + self.stopbutton_cb(button) # Try stopping old code first. self._reset_vte() # FIXME: We're losing an odd race here @@ -491,18 +503,18 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): pippy_tmp_dir, self.source_tabs.get_current_file_name()) - # write activity.py here too, to support pippy-based activities. + # Write activity.py here too, to support pippy-based activities. copy2('%s/activity.py' % get_bundle_path(), '%s/tmp/activity.py' % self.get_activity_root()) self._pid = self._vte.fork_command_full( Vte.PtyFlags.DEFAULT, get_bundle_path(), - ["/bin/sh", "-c", "python %s; sleep 1" % current_file, - "PYTHONPATH=%s/library:%s" % (get_bundle_path(), - os.getenv("PYTHONPATH", ""))], - ["PYTHONPATH=%s/library:%s" % (get_bundle_path(), - os.getenv("PYTHONPATH", ""))], + ['/bin/sh', '-c', 'python %s; sleep 1' % current_file, + 'PYTHONPATH=%s/library:%s' % (get_bundle_path(), + os.getenv('PYTHONPATH', ''))], + ['PYTHONPATH=%s/library:%s' % (get_bundle_path(), + os.getenv('PYTHONPATH', ''))], GLib.SpawnFlags.DO_NOT_REAP_CHILD, None, None,) @@ -512,7 +524,32 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): if self._pid is not None: os.kill(self._pid[1], SIGTERM) except: - pass # process must already be dead. + pass # Process must already be dead. + + def _save_as_library(self, button): + library_dir = os.path.join(get_bundle_path(), 'library') + file_name = self.source_tabs.get_current_file_name() + text_buffer = self.source_tabs.get_text_buffer() + content = text_buffer.get_text( + *text_buffer.get_bounds(), + include_hidden_chars=True) + + if not os.path.isdir(library_dir): + os.mkdir(library_dir) + + with open(os.path.join(library_dir, file_name), 'w') as f: + f.write(content) + success = True + + if success: + alert = NotifyAlert(5) + alert.props.title = _('Python File added to Library') + IMPORT_MESSAGE = _('The file you selected has been added' + ' to the library. Use "import {importname}"' + ' to import the library for using.') + alert.props.msg = IMPORT_MESSAGE.format(importname=file_name[:-3]) + alert.connect('response', self.remove_alert_cb) + self.add_alert(alert) def _save_as_library(self, button): import unicodedata @@ -556,7 +593,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): result = chooser.run() if result is Gtk.ResponseType.ACCEPT: dsitem = chooser.get_selected_object() - if dsitem.metadata['mime_type'] != "text/x-python": + if dsitem.metadata['mime_type'] != 'text/x-python': alert = NotifyAlert(5) alert.props.title = _('Error importing Python file') alert.props.msg = _('The file you selected is not a ' @@ -573,7 +610,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): else: name = dsitem.metadata['title'] file_path = dsitem.get_file_path() - content = open(file_path, "r").read() + content = open(file_path, 'r').read() self.source_tabs.add_tab(name, content) self.session_data.append(dsitem.object_id) @@ -584,7 +621,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): from shutil import rmtree from tempfile import mkdtemp - # get the name of this pippy program. + # Get the name of this pippy program. title = self.metadata['title'].replace('.py', '') title = title.replace('-', '') if title == 'Pippy Activity': @@ -617,49 +654,49 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): self._logger.debug('writing out source file: %s' % sourcefile) def internal_callback(window=None, event=None): - icon = "%s/activity/activity-default.svg" % (get_bundle_path()) + icon = '%s/activity/activity-default.svg' % (get_bundle_path()) if window: icon = window.get_icon() - - self.stopbutton_cb(None) # try stopping old code first. + self.stopbutton_cb(None) # Try stopping old code first. self._reset_vte() - self._vte.feed(_("Creating activity bundle...")) - self._vte.feed("\r\n") + self._vte.feed(_('Creating activity bundle...')) + self._vte.feed('\r\n') + TMPDIR = 'instance' app_temp = mkdtemp('.activity', 'Pippy', os.path.join(self.get_activity_root(), TMPDIR)) sourcefile = os.path.join(app_temp, 'xyzzy.py') - # invoke ourself to build the activity bundle. + # Invoke ourself to build the activity bundle. self._logger.debug('writing out source file: %s' % sourcefile) - # write out application code + # Write out application code self._write_text_buffer(sourcefile) try: # FIXME: vte invocation was raising errors. - # Switched to subprocess + # Switched to subprocss output = subprocess.check_output( - ["/usr/bin/python", - "%s/pippy_app.py" % get_bundle_path(), + ['/usr/bin/python', + '%s/pippy_app.py' % get_bundle_path(), '-p', '%s/library' % get_bundle_path(), '-d', app_temp, title, sourcefile, icon]) self._vte.feed(output) - self._vte.feed("\r\n") + self._vte.feed('\r\n') self.bundle_cb(title, app_temp) except subprocess.CalledProcessError: rmtree(app_temp, ignore_errors=True) # clean up! self._vte.feed(_('Save as Activity Error')) - self._vte.feed("\r\n") + self._vte.feed('\r\n') raise def alert_response(alert, response_id): self.remove_alert(alert) - def _icon_dialog(): + def dialog(): dialog = IconDialog() dialog.connect('destroy', internal_callback) - GObject.idle_add(_icon_dialog) + GObject.idle_add(dialog) alert_icon.connect('response', alert_response) self.add_alert(alert_icon) @@ -670,7 +707,7 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): text = text_buffer.get_text(start, end, True) with open(filename, 'w') as f: - # write utf-8 coding prefix if there's not already one + # Write utf-8 coding prefix if there's not one already if re.match(r'coding[:=]\s*([-\w.]+)', '\n'.join(text.splitlines()[:2])) is None: f.write(PYTHON_PREFIX) @@ -678,14 +715,14 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): f.write(line) def __export_disutils_cb(self, button): - app_temp = os.path.join(self.get_activity_root(), "instance") + app_temp = os.path.join(self.get_activity_root(), 'instance') data = self.source_tabs.get_all_data() for filename, content in zip(data[0], data[1]): - fileobj = open(os.path.join(app_temp, filename), "w") + fileobj = open(os.path.join(app_temp, filename), 'w') fileobj.write(content) fileobj.close() - filenames = ",".join([("'"+name[:-3]+"'") for name in data[0]]) + filenames = ','.join([("'"+name[:-3]+"'") for name in data[0]]) title = self.metadata['title'] if title is _('Pippy Activity'): @@ -704,20 +741,20 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): setup_script = DISUTILS_SETUP_SCRIPT.format(modulename=title, filenames=filenames) - setupfile = open(os.path.join(app_temp, "setup.py"), "w") + setupfile = open(os.path.join(app_temp, 'setup.py'), 'w') setupfile.write(setup_script) setupfile.close() os.chdir(app_temp) - output = subprocess.check_output( + subprocess.check_output( [ - "/usr/bin/python", - os.path.join(app_temp, "setup.py"), - "sdist", "-v" + '/usr/bin/python', + os.path.join(app_temp, 'setup.py'), + 'sdist', '-v' ]) - # hand off to journal + # Hand off to journal os.chmod(app_temp, 0777) jobject = datastore.create() metadata = { @@ -726,69 +763,70 @@ class PippyActivity(ViewSourceActivity, groupthink.sugar_tools.GroupActivity): 'mime_type': 'application/x-gzip', } for k, v in metadata.items(): - # the dict.update method is missing =( + # The dict.update method is missing =( jobject.metadata[k] = v - tarname = "dist/{modulename}-1.0.tar.gz".format(modulename=title) + tarname = 'dist/{modulename}-1.0.tar.gz'.format(modulename=title) jobject.file_path = os.path.join(app_temp, tarname) datastore.write(jobject) def _export_example_cb(self, __): - # get the name of this pippy program. + # Get the name of this pippy program. title = self.metadata['title'] if title == _('Pippy Activity'): from sugar3.graphics.alert import Alert from sugar3.graphics.icon import Icon alert = Alert() alert.props.title = _('Save as Example Error') - alert.props.msg = _('Please give your activity a meaningful \ -name before attempting to save it as an example.') + alert.props.msg = \ + _('Please give your activity a meaningful ' + 'name before attempting to save it as an example.') ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon) alert.connect('response', self.dismiss_alert_cb) self.add_alert(alert) return - self.stopbutton_cb(None) # try stopping old code first. + self.stopbutton_cb(None) # Try stopping old code first. self._reset_vte() - self._vte.feed(_("Creating example...")) - self._vte.feed("\r\n") + self._vte.feed(_('Creating example...')) + self._vte.feed('\r\n') local_data = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'], 'data') local_file = os.path.join(local_data, title) if os.path.exists(local_file): alert = ConfirmationAlert() alert.props.title = _('Save as Example Warning') - alert.props.msg = _('This example already exists. \ -Do you want to overwrite it?') + alert.props.msg = _('This example already exists. ' + 'Do you want to overwrite it?') alert.connect('response', self.confirmation_alert_cb, local_file) self.add_alert(alert) else: self.write_file(local_file) self._reset_vte() - self._vte.feed(_("Saved as example.")) - self._vte.feed("\r\n") + self._vte.feed(_('Saved as example.')) + self._vte.feed('\r\n') self.add_to_example_list(local_file) def child_exited_cb(self, *args): - """Called whenever a child exits. If there's a handler, run it.""" + '''Called whenever a child exits. If there's a handler, run it.''' h, self._child_exited_handler = self._child_exited_handler, None if h is not None: h() def bundle_cb(self, title, app_temp): - """Called when we're done building a bundle for a source file.""" + '''Called when we're done building a bundle for a source file.''' from sugar3 import profile from shutil import rmtree try: - # find the .xo file: were we successful? + # Find the .xo file: were we successful? bundle_file = [f for f in os.listdir(app_temp) if f.endswith('.xo')] if len(bundle_file) != 1: self._logger.debug("Couldn't find bundle: %s" % str(bundle_file)) - self._vte.feed("\r\n") - self._vte.feed(_("Error saving activity to journal.")) - self._vte.feed("\r\n") - return # something went wrong. - # hand off to journal + self._vte.feed('\r\n') + self._vte.feed(_('Error saving activity to journal.')) + self._vte.feed('\r\n') + return # Something went wrong. + # Hand off to journal os.chmod(app_temp, 0755) jobject = datastore.create() metadata = { @@ -800,13 +838,13 @@ Do you want to overwrite it?') 'mime_type': 'application/vnd.olpc-sugar', } for k, v in metadata.items(): - # the dict.update method is missing =( + # The dict.update method is missing =( jobject.metadata[k] = v jobject.file_path = os.path.join(app_temp, bundle_file[0]) datastore.write(jobject) - self._vte.feed("\r\n") - self._vte.feed(_("Activity saved to journal.")) - self._vte.feed("\r\n") + self._vte.feed('\r\n') + self._vte.feed(_('Activity saved to journal.')) + self._vte.feed('\r\n') self.journal_show_object(jobject.object_id) jobject.destroy() finally: @@ -816,22 +854,22 @@ Do you want to overwrite it?') self.remove_alert(alert) def confirmation_alert_cb(self, alert, response_id, local_file): - # callback for conf alert + # Callback for conf alert self.remove_alert(alert) if response_id is Gtk.ResponseType.OK: self.write_file(local_file) self._reset_vte() - self._vte.feed(_("Saved as example.")) - self._vte.feed("\r\n") + self._vte.feed(_('Saved as example.')) + self._vte.feed('\r\n') else: self._reset_vte() def add_to_example_list(self, local_file): # def for add example - entry = {"name": _(os.path.basename(local_file)), - "path": local_file} + entry = {'name': _(os.path.basename(local_file)), + 'path': local_file} _iter = self.model.insert_before(self.example_iter, None) self.model.set_value(_iter, 0, entry) - self.model.set_value(_iter, 1, entry["name"]) + self.model.set_value(_iter, 1, entry['name']) def save_to_journal(self, file_path, cloudstring): _file = open(file_path, 'w') @@ -839,15 +877,15 @@ Do you want to overwrite it?') data = self.source_tabs.get_all_data() zipped_data = zip(data[0], data[1]) sessionlist = [] - app_temp = os.path.join(self.get_activity_root(), "instance") + app_temp = os.path.join(self.get_activity_root(), 'instance') tmpfile = os.path.join(app_temp, - "pippy-tempfile-storing.py") + 'pippy-tempfile-storing.py') for zipdata, dsid in map(None, zipped_data, self.session_data): name, content = zipdata if dsid is not None: dsitem = datastore.get(dsid) - __file = open(tmpfile, "w") + __file = open(tmpfile, 'w') __file.write(content) __file.close() dsitem.set_file_path(tmpfile) @@ -857,7 +895,7 @@ Do you want to overwrite it?') dsobject = datastore.create() dsobject.metadata['mime_type'] = 'text/x-python' dsobject.metadata['title'] = name - __file = open(tmpfile, "w") + __file = open(tmpfile, 'w') __file.write(content) __file.close() dsobject.set_file_path(tmpfile) @@ -898,8 +936,7 @@ Do you want to overwrite it?') self.initial_text_buffer = text self.initial_title = self.metadata['title'] self.loaded_from_journal = self.py_file = True - - elif self.metadata['mime_type'] == "application/json": + elif self.metadata['mime_type'] == 'application/json': data = json.loads(open(file_path).read()) for name, dsid in data: dsitem = datastore.get(dsid) @@ -911,7 +948,7 @@ Do you want to overwrite it?') return open(file_path).read() ############# TEMPLATES AND INLINE FILES ############## -ACTIVITY_INFO_TEMPLATE = """ +ACTIVITY_INFO_TEMPLATE = ''' [Activity] name = %(title)s bundle_id = %(bundle_id)s @@ -921,7 +958,7 @@ 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 @@ -934,7 +971,25 @@ 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="M28.497,48.507 +c5.988,0,14.88-2.838,14.88-11.185 +c0-9.285-7.743-10.143-10.954-11.083 +c-3.549-0.799-5.913-1.914-6.055-3.455 +c-0.243-2.642,1.158-3.671,3.946-3.671 +c0,0,6.632,3.664,12.266,0.74 +c1.588-0.823,4.432-4.668,4.432-7.32 +c0-2.653-9.181-5.719-11.967-5.719 +c-2.788,0-5.159,3.847-5.159,3.847 +c-5.574,0-11.149,5.306-11.149,10.612 +c0,5.305,5.333,9.455,11.707,10.612 +c2.963,0.469,5.441,2.22,4.878,5.438 +c-0.457,2.613-2.995,5.306-8.361,5.306 +c-4.252,0-13.3-0.219-14.745-4.079 +c-0.929-2.486,0.168-5.205,1.562-5.205l-0.027-0.16 +c-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"/> @@ -948,13 +1003,13 @@ stroke="&stroke_color;" stroke-linecap="round" stroke-width="3"/> def pippy_activity_version(): - """Returns the version number of the generated activity bundle.""" + '''Returns the version number of the generated activity bundle.''' return 39 def pippy_activity_extra_files(): - """Returns a map of 'extra' files which should be included in the - generated activity bundle.""" + '''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() @@ -967,41 +1022,41 @@ def pippy_activity_extra_files(): def pippy_activity_news(): - """Return the NEWS file for this activity.""" + '''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 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 the class which should be started to run this activity.''' return 'pippy_app.PippyActivity' def pippy_activity_bundle_id(): - """Return the bundle_id for the generated activity.""" + '''Return the bundle_id for the generated activity.''' return 'org.laptop.Pippy' def pippy_activity_mime_types(): - """Return the mime types handled by the generated activity, as a list.""" + '''Return the mime types handled by the generated activity, as a list.''' return ['text/x-python', groupthink_mimetype] def pippy_activity_extra_info(): - return """ + return ''' license = GPLv2+ -update_url = http://activities.sugarlabs.org """ +update_url = http://activities.sugarlabs.org ''' ################# ACTIVITY BUNDLER ################ def main(): - """Create a bundle from a pippy-style source file""" + '''Create a bundle from a pippy-style source file''' from optparse import OptionParser from pyclbr import readmodule_ex from tempfile import mkdtemp @@ -1026,7 +1081,7 @@ def main(): if re.match(r'[0-9]', pytitle) is not None: pytitle = '_' + pytitle # first character cannot be numeric - # first take a gander at the source file and see if it's got extra info + # First take a gander at the source file and see if it's got extra info # for us. sourcedir, basename = os.path.split(sourcefile) if not sourcedir: @@ -1035,7 +1090,7 @@ def main(): f = open(icon_path, 'r') icon = f.read() f.close() - # things we look for: + # Things we look for: bundle_info = { 'version': 1, 'extra_files': {}, @@ -1048,7 +1103,7 @@ def main(): 'mime_types': '', 'extra_info': '', } - # are any of these things in the module? + # Are any of these things in the module? try_import = False info = readmodule_ex(module, [sourcedir] + options.path) @@ -1057,7 +1112,7 @@ def main(): if p_a_func in info: try_import = True if try_import: - # yes, let's try to execute them to get better info about our bundle + # Yes, let's try to execute them to get better info about our bundle oldpath = list(sys.path) sys.path[0:0] = [sourcedir] + options.path modobj = __import__(module) @@ -1067,9 +1122,9 @@ def main(): bundle_info[func] = modobj.__dict__[p_a_func]() sys.path = oldpath - # okay! We've done the hard part. Now let's build a bundle. - # create a new temp dir in which to create the bundle. - app_temp = mkdtemp('.activity', 'Pippy') # hope TMPDIR is set correctly! + # Okay! We've done the hard part. Now let's build a bundle. + # Create a new temp dir in which to create the bundle. + app_temp = mkdtemp('.activity', 'Pippy') # Hope TMPDIR is set correctly! bundle = get_bundle_path() try: copytree('%s/library' % bundle, '%s/library' % app_temp) @@ -1093,9 +1148,9 @@ def main(): os.makedirs(dirname) with open(os.path.join(dirname, filename), 'w') as f: f.write(contents) - # put script into $app_temp/pippy_app.py + # Put script into $app_temp/pippy_app.py copy2(sourcefile, '%s/pippy_app.py' % app_temp) - # invoke bundle builder + # Invoke bundle builder olddir = os.getcwd() oldargv = sys.argv os.chdir(app_temp) @@ -1104,7 +1159,7 @@ def main(): bundlebuilder.start() sys.argv = oldargv os.chdir(olddir) - # move to destination directory. + # Move to destination directory. src = '%s/dist/%s-%d.xo' % (app_temp, pytitle, bundle_info['version']) dst = '%s/%s-%d.xo' % (options.dir, pytitle, bundle_info['version']) if not os.path.exists(src): @@ -1116,13 +1171,13 @@ def main(): print('Finally\r\n') if __name__ == '__main__': - from gettext import gettext as _ import sys - if False: # change this to True to test within Pippy + from gettext import gettext as _ + if False: # Change this to True to test within Pippy sys.argv = sys.argv + ['-d', '/tmp', 'Pippy', '/home/olpc/pippy_app.py'] - print(_("Working...")) + print(_('Working...')) sys.stdout.flush() main() - print(_("done!")) + print(_('done!')) sys.exit(0) |