Code

Fix ef spam when adjusting pattern on text - patch from Adonis Papaderos
[inkscape.git] / share / extensions / extractimage.py
index 07074c8a4693fd47527246267ad35b6531a896fe..d5cf285c81041347aec9ab638440c1c81c651342 100644 (file)
@@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 '''
 
 import inkex, base64, os
+import gettext
+_ = gettext.gettext
 
 class MyEffect(inkex.Effect):
     def __init__(self):
@@ -52,16 +54,22 @@ class MyEffect(inkex.Effect):
                                 semicolon = xlink.find(';')
                                 if semicolon>0:
                                     for sub in mimesubext.keys():
-                                        if sub in xlink[5:semicolon]:
+                                        if sub in xlink[5:semicolon].lower():
                                             fileext=mimesubext[sub]
                                             path=path+fileext;
-                                            break
+                                            if (not os.path.isabs(path)):
+                                                if os.name == 'nt':
+                                                    path = os.path.join(os.environ['USERPROFILE'],path)
+                                                else:
+                                                    path = os.path.join(os.path.expanduser("~"),path)
+                                            inkex.errormsg(_('Image extracted to: %s') % path)
+                                            break 
                                 #save
                                 data = base64.decodestring(xlink[comma:])
                                 open(path,'wb').write(data)
                                 node.set(inkex.addNS('href','xlink'),os.path.realpath(path)) #absolute for making in-mem cycles work
                             else:
-                                inkex.debug('Difficulty finding the image data.')
+                                inkex.errormsg(_('Unable to find image data.'))
                             break
 
 if __name__ == '__main__':
@@ -69,4 +77,4 @@ if __name__ == '__main__':
     e.affect()
 
 
-# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99