docutil/docsvg.py
branchwxPython4
changeset 3573 1ee56fb544fc
parent 3482 31f6d7221f60
child 3750 f62625418bff
equal deleted inserted replaced
3572:b46af5b80c7d 3573:1ee56fb544fc
    22 # along with this program; if not, write to the Free Software
    22 # along with this program; if not, write to the Free Software
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    24 
    24 
    25 
    25 
    26 from __future__ import absolute_import
    26 from __future__ import absolute_import
       
    27 import os
    27 import wx
    28 import wx
    28 import subprocess
    29 import subprocess
       
    30 from dialogs import MessageBoxOnce
    29 
    31 
    30 
    32 
    31 def _get_inkscape_path():
    33 def _get_inkscape_path():
    32     """ Return the Inkscape binary path """
    34     """ Return the Inkscape binary path """
    33 
    35 
    84         return _inkscape_version
    86         return _inkscape_version
    85 
    87 
    86     _inkscape_version = _get_inkscape_version()
    88     _inkscape_version = _get_inkscape_version()
    87     return _inkscape_version
    89     return _inkscape_version
    88 
    90 
    89 def open_svg(svgfile):
    91 if os.environ.has_key("SNAP"):
    90     """ Generic function to open SVG file """
    92     def open_svg(svgfile):
    91     
    93         MessageBoxOnce("Launching Inkscape with xdg-open",
    92     inkpath = get_inkscape_path()
    94                 "Confined app can't launch Inkscape directly.\n"+
    93     if inkpath is None:
    95                     "Instead, SVG file is passed to xdg-open.\n"+
    94         wx.MessageBox("Inkscape is not found or installed !")
    96                     "Please select Inskape when proposed.\n\n"+
    95     else:
    97                     "Notes: \n"+
    96         subprocess.Popen([inkpath,svgfile])
    98                     " - Inkscape must be installed on you system.\n"+
       
    99                     " - If no choice is proposed, use file manager to change SVG file properties.\n",
       
   100                 "DocSVGSnapWarning")
       
   101 
       
   102         subprocess.Popen(["xdg-open",svgfile])
       
   103 else:
       
   104     def open_svg(svgfile):
       
   105         """ Generic function to open SVG file """
       
   106         inkpath = get_inkscape_path()
       
   107         if inkpath is None:
       
   108             wx.MessageBox("Inkscape is not found or installed !")
       
   109         else:
       
   110             subprocess.Popen([inkpath,svgfile])