svghmi/ui.py
branchwxPython4
changeset 3573 1ee56fb544fc
parent 3526 074046800624
child 3609 51a3d6f39944
equal deleted inserted replaced
3572:b46af5b80c7d 3573:1ee56fb544fc
    28 import util.paths as paths
    28 import util.paths as paths
    29 from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath
    29 from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath
    30 from docutil import get_inkscape_path, get_inkscape_version
    30 from docutil import get_inkscape_path, get_inkscape_version
    31 
    31 
    32 from util.ProcessLogger import ProcessLogger
    32 from util.ProcessLogger import ProcessLogger
       
    33 
       
    34 # When running as a confined Snap, /tmp isn't accessible from the outside
       
    35 # and Widget DnD to Inkscape can't work, since it can't find generated svg 
       
    36 # This forces tmp directory in $SNAP_USER_DATA, accessible from other apps
       
    37 if os.environ.has_key("SNAP"):
       
    38      NamedTemporaryFile_orig = NamedTemporaryFile
       
    39      tmpdir = os.path.join(os.environ["SNAP_USER_DATA"], ".tmp")
       
    40      if not os.path.exists(tmpdir):
       
    41          os.mkdir(tmpdir)
       
    42      def NamedTemporaryFile(*args,**kwargs):
       
    43         kwargs["dir"] = tmpdir
       
    44         return NamedTemporaryFile_orig(*args, **kwargs)
       
    45 
    33 
    46 
    34 ScriptDirectory = paths.AbsDir(__file__)
    47 ScriptDirectory = paths.AbsDir(__file__)
    35 
    48 
    36 HMITreeDndMagicWord = "text/beremiz-hmitree"
    49 HMITreeDndMagicWord = "text/beremiz-hmitree"
    37 
    50 
   462 
   475 
   463         export_opt = "-o" if get_inkscape_version()[0] > 0 else "-e"
   476         export_opt = "-o" if get_inkscape_version()[0] > 0 else "-e"
   464 
   477 
   465         # TODO: spawn a thread, to decouple thumbnail gen
   478         # TODO: spawn a thread, to decouple thumbnail gen
   466         status, result, _err_result = ProcessLogger(
   479         status, result, _err_result = ProcessLogger(
   467             self.Controler.GetCTRoot().logger,
   480             #self.Controler.GetCTRoot().logger,
       
   481             None,
   468             '"' + inkpath + '" "' + svgpath + '" ' +
   482             '"' + inkpath + '" "' + svgpath + '" ' +
   469             export_opt + ' "' + thumbpath +
   483             export_opt + ' "' + thumbpath +
   470             '" -D -h ' + str(_preview_height)).spin()
   484             '" -D -h ' + str(_preview_height)).spin()
   471         if status != 0:
   485         if status != 0:
   472             self.msg = _("Inkscape couldn't generate thumbnail.")
   486             self.msg = _("Inkscape couldn't generate thumbnail.")