Skip to content
Permalink
Browse files
fix to SL#4788; add export to SVG to GNOME menu (Alan Aguiar)
  • Loading branch information
walterbender committed Sep 18, 2014
1 parent 1be77a4 commit 87c0e2a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
4 NEWS
@@ -1,7 +1,11 @@
209

ENHANCEMENT:
* Add export SVG and Icon to GNOME menu (Alan Aguiar)

BUG FIXES:
* Fine-tune some block label positioning
* Use unique name (by user) for tmp files for multiuser systems (#4788)

208

@@ -19,6 +19,8 @@
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.

import os
from random import uniform
from gettext import gettext as _

# Packaging constants
@@ -81,8 +83,10 @@
XO30 = 'xo3.0'
XO4 = 'xo4'
UNKNOWN = 'unknown'
TMP_SVG_PATH = '/tmp/turtle_output.svg'
TMP_ODP_PATH = '/tmp/turtle_presentation'
TMP_SVG_PATH = os.path.join(
'/tmp', 'turtle-blocks-%d.svg' % int(uniform(0, 10000)))
TMP_ODP_PATH = os.path.join(
'/tmp', 'turtle-blocks-%d.odp' % int(uniform(0, 10000)))

ARG_MUST_BE_NUMBER = ['product2', 'minus2', 'random', 'remainder2', 'forward',
'back', 'left', 'right', 'arc', 'setxy2', 'setxy',
@@ -1397,6 +1397,11 @@ def _notify_active_cb(self, widget, event):
def can_close(self):
''' Override activity class can_close inorder to notify plugins '''
self.tw.quit_plugins()
# Clean up temporary files
if os.path.exists(TMP_SVG_PATH):
os.remove(TMP_SVG_PATH)
if os.path.exists(TMP_ODP_PATH):
os.remove(TMP_ODP_PATH)
return True

def write_file(self, file_path):
@@ -54,7 +54,8 @@
from gettext import gettext as _

from TurtleArt.taconstants import (OVERLAY_LAYER, DEFAULT_TURTLE_COLORS,
TAB_LAYER, SUFFIX)
TAB_LAYER, SUFFIX, TMP_SVG_PATH,
TMP_ODP_PATH)
from TurtleArt.tautils import (data_from_string, get_load_name,
get_path, get_save_name, is_writeable)
from TurtleArt.tapalette import default_values
@@ -443,6 +444,8 @@ def _get_menu_bar(self):

MenuBuilder.make_menu_item(export_submenu, _('image'),
self._do_save_picture_cb)
MenuBuilder.make_menu_item(export_submenu, _('SVG'),
self._do_save_svg_cb)
MenuBuilder.make_menu_item(export_submenu, _('icon'),
self._do_save_as_icon_cb)
# TRANS: ODP is Open Office presentation
@@ -541,6 +544,13 @@ def _quit_ta(self, widget=None, e=None):
for plugin in self.tw.turtleart_plugins:
if hasattr(plugin, 'quit'):
plugin.quit()

# Clean up temporary files
if os.path.exists(TMP_SVG_PATH):
os.remove(TMP_SVG_PATH)
if os.path.exists(TMP_ODP_PATH):
os.remove(TMP_ODP_PATH)

gtk.main_quit()
exit()

@@ -662,6 +672,10 @@ def _do_save_picture_cb(self, widget):
''' Callback for save canvas. '''
self.tw.save_as_image()

def _do_save_svg_cb(self, widget):
''' Callback for save canvas as SVG. '''
self.tw.save_as_image(svg=True)

def _do_save_as_icon_cb(self, widget):
''' Callback for save canvas. '''
self.tw.write_svg_operation()

0 comments on commit 87c0e2a

Please sign in to comment.