diff options
-rw-r--r-- | TurtleArtActivity.py | 74 | ||||
-rw-r--r-- | icons/image-saveoff.svg | 65 | ||||
-rw-r--r-- | icons/image-saveoff.svg~ | 104 | ||||
-rw-r--r-- | icons/image-saveon.svg | 53 | ||||
-rw-r--r-- | icons/image-saveon.svg~ | 109 |
5 files changed, 382 insertions, 23 deletions
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py index 1c71a34..6a6e200 100644 --- a/TurtleArtActivity.py +++ b/TurtleArtActivity.py @@ -234,7 +234,6 @@ class TurtleArtActivity(activity.Activity): reply_handler=self._list_tubes_reply_cb, error_handler=self._list_tubes_error_cb) - # joiner should request current state from sharer self.waiting_for_blocks = True @@ -348,7 +347,6 @@ class TurtleArtActivity(activity.Activity): Write the project and a screen snapshot to the Journal """ def write_file(self, file_path): - # just save .ta file _logger.debug("Writing file %s" % file_path) self.metadata['mime_type'] = 'application/x-tar' import tempfile @@ -448,6 +446,20 @@ class SaveAsToolbar(gtk.Toolbar): gtk.Toolbar.__init__(self) self.activity = pc + # project open + self.sampb = ToolButton( "stock-open" ) + self.sampb.set_tooltip(_('samples')) + self.sampb.props.sensitive = True + self.sampb.connect('clicked', self.do_samples) + self.sampb.props.accelerator = '<Alt>o' + self.insert(self.sampb, -1) + self.sampb.show() + + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + self.insert(separator, -1) + separator.show() + # HTML save source button self.savehtml = ToolButton( "htmloff" ) self.savehtml.set_tooltip(_('save as HTML')) @@ -464,6 +476,14 @@ class SaveAsToolbar(gtk.Toolbar): self.insert(self.savelogo, -1) self.savelogo.show() + # Save as image button + self.saveimage = ToolButton( "image-saveoff" ) + self.saveimage.set_tooltip(_('save as image')) + self.saveimage.props.sensitive = True + self.saveimage.connect('clicked', self.do_saveimage) + self.insert(self.saveimage, -1) + self.saveimage.show() + separator = gtk.SeparatorToolItem() separator.set_draw(True) self.insert(separator, -1) @@ -477,6 +497,33 @@ class SaveAsToolbar(gtk.Toolbar): self.insert(self.loadmyblock, -1) self.loadmyblock.show() + def do_samples(self, button): + tawindow.load_file(self.activity.tw) + # run the activity + tawindow.runbutton(self.activity.tw, 0) + + def do_saveimage(self, button): + self.saveimage.set_icon("image-saveon") + _logger.debug("saving image to journal") + import tempfile + pngfd, pngfile = tempfile.mkstemp(".png") + del pngfd + tawindow.save_pict(self.activity.tw,pngfile) + + # Create a datastore object + file_dsobject = datastore.create() + + # Write metadata + file_dsobject.metadata['title'] = "Turtle Art image" + file_dsobject.metadata['icon-color'] = profile.get_color().to_string() + file_dsobject.metadata['mime_type'] = 'image/png' + file_dsobject.set_file_path(pngfile) + + datastore.write(file_dsobject) + file_dsobject.destroy() + gobject.timeout_add(250,self.saveimage.set_icon, "image-saveoff") + return + def do_savehtml(self, button): # write html out to datastore self.savehtml.set_icon("htmlon") @@ -498,7 +545,7 @@ class SaveAsToolbar(gtk.Toolbar): os.environ['HOME'], \ ".sugar/default/org.laptop.TurtleArtActivity/instance") - html_file = os.path.join(datapath, "taportfolio.html") + html_file = os.path.join(datapath, "portfolio.html") f = file(html_file, "w") f.write(html) f.close() @@ -521,7 +568,7 @@ class SaveAsToolbar(gtk.Toolbar): # Write any metadata (here we specifically set the title of the file # and specify that this is a plain text file). - file_dsobject.metadata['title'] = "TAportfolio" + file_dsobject.metadata['title'] = "Turtle Art portfolio" file_dsobject.metadata['icon-color'] = profile.get_color().to_string() if embed_flag == True: file_dsobject.metadata['mime_type'] = 'text/html' @@ -683,20 +730,6 @@ class ProjectToolbar(gtk.Toolbar): self.insert(separator, -1) separator.show() - # project open - self.sampb = ToolButton( "stock-open" ) - self.sampb.set_tooltip(_('samples')) - self.sampb.props.sensitive = True - self.sampb.connect('clicked', self.do_samples) - self.sampb.props.accelerator = '<Alt>o' - self.insert(self.sampb, -1) - self.sampb.show( -) - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - self.insert(separator, -1) - separator.show() - # full screen self.fullscreenb = ToolButton( "view-fullscreen" ) self.fullscreenb.set_tooltip(_('fullscreen')) @@ -780,11 +813,6 @@ class ProjectToolbar(gtk.Toolbar): tawindow.eraser_button(self.activity.tw) gobject.timeout_add(250,self.eraser.set_icon,"eraseron") - def do_samples(self, button): - tawindow.load_file(self.activity.tw) - # run the activity - tawindow.runbutton(self.activity.tw, 0) - def do_fullscreen(self, button): self.activity.fullscreen() self.activity.recenter() diff --git a/icons/image-saveoff.svg b/icons/image-saveoff.svg new file mode 100644 index 0000000..9f4dc3c --- /dev/null +++ b/icons/image-saveoff.svg @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.0" + width="55" + height="55" + viewBox="0 0 55 55" + id="svg2" + xml:space="preserve"><defs + id="defs41"> +</defs> +<g + transform="translate(-0.5507515,-1.7569535)" + id="g3" + style="fill:none"> + <line + style="fill:none;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="line3290" + y2="4.9169998" + y1="16.188" + x2="52.441002" + x1="41.169998" /> + <polyline + style="fill:none;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="polyline3292" + points="51.562,15.306 41.17,16.188 42.053,5.794" /> +</g> +<polygon + points="10.932,6.088 31.874,6.088 43.818,18.027 43.818,48.914 10.932,48.914 10.932,6.088 " + transform="translate(-6,2)" + id="polygon9" + style="fill:none;stroke:#ffffff;stroke-width:3.5" /><polyline + points="43.818,18.027 31.874,18.027 31.874,6.088" + id="polyline11" + style="fill:none;stroke:#ffffff;stroke-width:3.5" + transform="translate(-6,2)" /> +<line + x1="40.75" + x2="52.021004" + y1="15.249998" + y2="3.9789984" + id="line2513" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><polyline + points="51.562,15.306 41.17,16.188 42.053,5.794" + id="polyline2515" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + transform="translate(-0.4199989,-0.938)" /><polyline + points="43.818,18.027 31.874,18.027 31.874,6.088" + id="polyline2519" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-opacity:1" + transform="translate(45.97349,37.199819)" /><g + transform="matrix(0.6016528,0,0,0.5962542,20.149385,7.0668138)" + id="g2488" + style="fill:#ff00ff;fill-opacity:1"><path + d="M 3.196409,27.818399 C -6.063591,27.818399 -13.778591,37.053399 -13.778591,37.053399 C -13.778591,37.053399 -6.064591,46.330398 3.196409,46.325398 C 12.456409,46.318399 20.174409,37.040399 20.174409,37.040399 C 20.174409,37.040399 12.457409,27.811399 3.196409,27.818399 z M 3.196409,43.566399 C -0.388591,43.566399 -3.295591,40.656399 -3.295591,37.072398 C -3.295591,33.493399 -0.389591,30.578398 3.196409,30.578398 C 6.777409,30.578398 9.686409,33.493399 9.686409,37.072398 C 9.686409,40.656399 6.777409,43.566399 3.196409,43.566399 z" + id="path2465" + style="fill:#ff00ff;fill-opacity:1;display:inline" /><circle + cx="27.504" + cy="27.598" + r="2.9460001" + transform="translate(-24.306591,9.4763985)" + id="circle2467" + style="fill:#ff00ff;fill-opacity:1;display:inline" /></g></svg> diff --git a/icons/image-saveoff.svg~ b/icons/image-saveoff.svg~ new file mode 100644 index 0000000..44fa01d --- /dev/null +++ b/icons/image-saveoff.svg~ @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.0" + width="55" + height="55" + viewBox="0 0 55 55" + id="svg2" + xml:space="preserve"><defs + id="defs41"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +</defs> +<g + transform="translate(-0.5507515,-1.7569535)" + id="g3" + style="fill:none"> + <line + style="fill:none;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="line3290" + y2="4.9169998" + y1="16.188" + x2="52.441002" + x1="41.169998" /> + <polyline + style="fill:none;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="polyline3292" + points="51.562,15.306 41.17,16.188 42.053,5.794" /> +</g> +<polygon + points="10.932,6.088 31.874,6.088 43.818,18.027 43.818,48.914 10.932,48.914 10.932,6.088 " + transform="translate(-6,2)" + id="polygon9" + style="fill:none;stroke:#ffffff;stroke-width:3.5" /><polyline + points="43.818,18.027 31.874,18.027 31.874,6.088" + id="polyline11" + style="fill:none;stroke:#ffffff;stroke-width:3.5" + transform="translate(-6,2)" /> +<line + x1="40.75" + x2="52.021004" + y1="15.249998" + y2="3.9789984" + id="line2513" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><polyline + points="51.562,15.306 41.17,16.188 42.053,5.794" + id="polyline2515" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + transform="translate(-0.4199989,-0.938)" /><polyline + points="43.818,18.027 31.874,18.027 31.874,6.088" + id="polyline2519" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-opacity:1" + transform="translate(45.97349,37.199819)" /><g + transform="matrix(0.6016528,0,0,0.5962542,20.149385,7.0668138)" + id="g2488" + style="fill:#ff00ff;fill-opacity:1"><path + d="M 3.196409,27.818399 C -6.063591,27.818399 -13.778591,37.053399 -13.778591,37.053399 C -13.778591,37.053399 -6.064591,46.330398 3.196409,46.325398 C 12.456409,46.318399 20.174409,37.040399 20.174409,37.040399 C 20.174409,37.040399 12.457409,27.811399 3.196409,27.818399 z M 3.196409,43.566399 C -0.388591,43.566399 -3.295591,40.656399 -3.295591,37.072398 C -3.295591,33.493399 -0.389591,30.578398 3.196409,30.578398 C 6.777409,30.578398 9.686409,33.493399 9.686409,37.072398 C 9.686409,40.656399 6.777409,43.566399 3.196409,43.566399 z" + id="path2465" + style="fill:#ff00ff;fill-opacity:1;display:inline" /><circle + cx="27.504" + cy="27.598" + r="2.9460001" + transform="translate(-24.306591,9.4763985)" + id="circle2467" + style="fill:#ff00ff;fill-opacity:1;display:inline" /></g></svg>
\ No newline at end of file diff --git a/icons/image-saveon.svg b/icons/image-saveon.svg new file mode 100644 index 0000000..369ad11 --- /dev/null +++ b/icons/image-saveon.svg @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.0" + width="55" + height="55" + viewBox="0 0 55 55" + id="svg2" + xml:space="preserve"><defs + id="defs41"> + +</defs> +<g + transform="translate(-0.5507515,-1.7569535)" + id="g3" + style="fill:none;stroke:#ffffff;stroke-opacity:1"> + <line + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="line3290" + y2="4.9169998" + y1="16.188" + x2="52.441002" + x1="41.169998" /> + <polyline + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="polyline3292" + points="51.562,15.306 41.17,16.188 42.053,5.794" /> +</g> +<polygon + points="10.932,6.088 31.874,6.088 43.818,18.027 43.818,48.914 10.932,48.914 10.932,6.088 " + transform="translate(-6,2)" + id="polygon9" + style="fill:#800080;fill-opacity:1;stroke:#ffffff;stroke-width:3.5;stroke-opacity:1" /><polyline + points="43.818,18.027 31.874,18.027 31.874,6.088" + id="polyline11" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-opacity:1" + transform="translate(-6,2)" /> +<g + transform="matrix(0.6016528,0,0,0.5962542,20.149385,7.0668138)" + id="g2488" + style="fill:#ff00ff;fill-opacity:1"><path + d="M 3.196409,27.818399 C -6.063591,27.818399 -13.778591,37.053399 -13.778591,37.053399 C -13.778591,37.053399 -6.064591,46.330398 3.196409,46.325398 C 12.456409,46.318399 20.174409,37.040399 20.174409,37.040399 C 20.174409,37.040399 12.457409,27.811399 3.196409,27.818399 z M 3.196409,43.566399 C -0.388591,43.566399 -3.295591,40.656399 -3.295591,37.072398 C -3.295591,33.493399 -0.389591,30.578398 3.196409,30.578398 C 6.777409,30.578398 9.686409,33.493399 9.686409,37.072398 C 9.686409,40.656399 6.777409,43.566399 3.196409,43.566399 z" + id="path2465" + style="fill:#ff00ff;fill-opacity:1;display:inline" /><circle + cx="27.504" + cy="27.598" + r="2.9460001" + transform="translate(-24.306591,9.4763985)" + id="circle2467" + style="fill:#ff00ff;fill-opacity:1;display:inline" /></g> +</svg> diff --git a/icons/image-saveon.svg~ b/icons/image-saveon.svg~ new file mode 100644 index 0000000..e705778 --- /dev/null +++ b/icons/image-saveon.svg~ @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.0" + width="55" + height="55" + viewBox="0 0 55 55" + id="svg2" + xml:space="preserve"><defs + id="defs41"> + + + + + + + + +</defs> +<g + transform="translate(-0.5507515,-1.7569535)" + id="g3" + style="fill:none;stroke:#ffffff;stroke-opacity:1"> + <line + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="line3290" + y2="4.9169998" + y1="16.188" + x2="52.441002" + x1="41.169998" /> + <polyline + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="polyline3292" + points="51.562,15.306 41.17,16.188 42.053,5.794" /> +</g> +<polygon + points="10.932,6.088 31.874,6.088 43.818,18.027 43.818,48.914 10.932,48.914 10.932,6.088 " + transform="translate(-6,2)" + id="polygon9" + style="fill:#008000;fill-opacity:1;stroke:#ffffff;stroke-width:3.5;stroke-opacity:1" /><polyline + points="43.818,18.027 31.874,18.027 31.874,6.088" + id="polyline11" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-opacity:1" + transform="translate(-6,2)" /><path + d="M 21.379465,44.19975 C 21.102965,44.19975 20.829965,44.18225 20.560965,44.14975 L 21.254965,45.32425 L 21.938965,44.16775 C 21.753465,44.18275 21.568465,44.19975 21.379465,44.19975 z" + id="path11" + style="fill:none;stroke:#00c000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><g + transform="matrix(0.5,0,0,0.5,7.630965,20.06025)" + id="g13" + style="fill:none;stroke:#00c000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"> + <path + d="M 40.16,11.726 C 37.996,11.726 36.202,13.281 35.817,15.333 C 37.676,16.678 39.274,18.448 40.492,20.541 C 42.777,20.369 44.586,18.48 44.586,16.151 C 44.586,13.707 42.604,11.726 40.16,11.726 z" + id="path15" + style="fill:none;stroke:#00c000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + d="M 40.713,39.887 C 39.489,42.119 37.853,44.018 35.916,45.443 C 36.437,47.307 38.129,48.682 40.16,48.682 C 42.603,48.682 44.586,46.702 44.586,44.258 C 44.586,42.003 42.893,40.162 40.713,39.887 z" + id="path17" + style="fill:none;stroke:#00c000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + d="M 14.273,39.871 C 12.02,40.077 10.249,41.95 10.249,44.258 C 10.249,46.701 12.229,48.682 14.673,48.682 C 16.737,48.682 18.457,47.262 18.945,45.35 C 17.062,43.934 15.47,42.061 14.273,39.871 z" + id="path19" + style="fill:none;stroke:#00c000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + d="M 19.026,15.437 C 18.683,13.334 16.872,11.726 14.673,11.726 C 12.229,11.726 10.249,13.707 10.249,16.15 C 10.249,18.532 12.135,20.46 14.494,20.556 C 15.68,18.513 17.226,16.772 19.026,15.437 z" + id="path21" + style="fill:none;stroke:#00c000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + </g><path + d="M 21.379465,26.34175 C 22.333465,26.34175 23.243465,26.54725 24.088465,26.90575 C 24.458965,26.36775 24.677465,25.71725 24.677465,25.01425 C 24.677465,23.17075 23.182965,21.67575 21.338965,21.67575 C 19.495465,21.67575 18.000965,23.17075 18.000965,25.01425 C 18.000965,25.72825 18.226965,26.38875 18.608965,26.93125 C 19.470965,26.55675 20.402465,26.34175 21.379465,26.34175 z" + id="path23" + style="fill:none;stroke:#00c000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /><g + transform="matrix(0.5,0,0,0.5,7.630965,20.06025)" + id="g25" + style="fill:#008000;fill-opacity:1;stroke:#00c000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"> + <path + d="M 43.102,30.421 C 43.102,35.1554 41.4568,39.7008 38.5314,43.0485 C 35.606,46.3963 31.6341,48.279 27.497,48.279 C 23.3599,48.279 19.388,46.3963 16.4626,43.0485 C 13.5372,39.7008 11.892,35.1554 11.892,30.421 C 11.892,20.6244 18.9364,12.563 27.497,12.563 C 36.0576,12.563 43.102,20.6244 43.102,30.421 z" + id="path2988" + style="fill:#008000;fill-opacity:1;stroke:#00c000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + </g><g + transform="matrix(0.5,0,0,0.5,7.630965,20.06025)" + id="g28" + style="fill:#008000;fill-opacity:1;stroke:#00c000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"> + <path + d="M 25.875,33.75 L 24.333,29.125 L 27.497,26.538 L 31.112,29.164 L 29.625,33.833 L 25.875,33.75 z" + id="path30" + style="fill:#008000;fill-opacity:1;stroke:#00c000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + d="M 27.501,41.551 C 23.533,41.391 21.958,39.542 21.958,39.542 L 25.528,35.379 L 29.993,35.547 L 33.125,39.667 C 33.125,39.667 30.235,41.661 27.501,41.551 z" + id="path32" + style="fill:#008000;fill-opacity:1;stroke:#00c000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + d="M 18.453,33.843 C 17.604,30.875 18.625,26.959 18.625,26.959 L 22.625,29.126 L 24.118,33.755 L 20.536,37.988 C 20.536,37.987 19.071,35.998 18.453,33.843 z" + id="path34" + style="fill:#008000;fill-opacity:1;stroke:#00c000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + d="M 19.458,25.125 C 19.458,25.125 19.958,23.167 22.497,21.303 C 24.734,19.66 26.962,19.583 26.962,19.583 L 26.925,24.564 L 23.404,27.314 L 19.458,25.125 z" + id="path2998" + style="fill:#008000;fill-opacity:1;stroke:#00c000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + d="M 32.084,27.834 L 28.625,24.959 L 29,19.75 C 29,19.75 30.834,19.708 32.959,21.417 C 35.187,23.208 36.321,26.4 36.321,26.4 L 32.084,27.834 z" + id="path37" + style="fill:#008000;fill-opacity:1;stroke:#00c000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + d="M 31.292,34.042 L 32.605,29.578 L 36.792,28.042 C 36.792,28.042 37.469,30.705 36.75,33.709 C 36.21,35.965 34.666,38.07 34.666,38.07 L 31.292,34.042 z" + id="path3002" + style="fill:#008000;fill-opacity:1;stroke:#00c000;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + </g> +</svg>
\ No newline at end of file |