diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
commit | bdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch) | |
tree | d00eb50b749cb001e2b08272c91791e66740b05d /release/scripts/image_edit.py | |
parent | 78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff) | |
parent | 7e4db234cee71ead34ee81a12e27da4bd548eb4b (diff) |
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
Diffstat (limited to 'release/scripts/image_edit.py')
-rw-r--r-- | release/scripts/image_edit.py | 74 |
1 files changed, 48 insertions, 26 deletions
diff --git a/release/scripts/image_edit.py b/release/scripts/image_edit.py index 14ab57515ba..cae40b74097 100644 --- a/release/scripts/image_edit.py +++ b/release/scripts/image_edit.py @@ -1,30 +1,31 @@ #!BPY """ -Name: 'Edit Externaly' +Name: 'Edit Externally' Blender: 242a Group: 'Image' Tooltip: 'Open in an application for editing. (hold Shift to configure)' """ __author__ = "Campbell Barton" -__url__ = ["blender", "elysiun"] +__url__ = ["blender", "blenderartists.org"] __version__ = "1.0" - __bpydoc__ = """\ This script opens the current image in an external application for editing. -Useage: +Usage: Choose an image for editing in the UV/Image view. -To configure the application to open the image with, hold Shift as you click on -this menu item. +To configure the application to open the image with, hold Shift as you +click on this menu item. -For first time users try running the default application for your operating system. -If the application does not open you can type in the full path. -You can choose that the last entered application will be saved as a default. +For first time users try running the default application for your +operating system. If the application does not open you can type in +the full path. You can choose that the last entered application will +be saved as a default. -* Note, default commants for opening an image are "start" for win32 and "open" for macos. -This will use the system default assosiated application. +* Note, default commants for opening an image are "start" for win32 +and "open" for macos. This will use the system default associated +application. """ # ***** BEGIN GPL LICENSE BLOCK ***** @@ -48,17 +49,36 @@ This will use the system default assosiated application. # ***** END GPL LICENCE BLOCK ***** # -------------------------------------------------------------------------- +import Blender +from Blender import Image, sys, Draw, Registry try: - import os + import subprocess import sys as py_sys platform = py_sys.platform except: - Draw.PupMenu('Error, python not installed') - os=None + Draw.PupMenu('Error: Recent version of Python not installed.') + subprocess=None -import Blender -from Blender import Image, sys, Draw, Registry +def os_run(appstring, filename): + ''' + Run the app, take into account different python versions etc + looks like python 2.6 wants a list for + ''' + + # evil trick, temp replace spaces so we can allow spaces in filenames + # also allows multiple instances of %f + appstring = appstring.replace(' ', '\t') + appstring = appstring.replace('%f', filename) + appstring = appstring.split('\t') + + print ' '.join(appstring) + + try: # only python 2.6 wants a list? + p = subprocess.Popen(appstring) + except: + p = subprocess.Popen(' '.join(appstring)) + def edit_extern(image=None): @@ -66,7 +86,7 @@ def edit_extern(image=None): image = Image.GetCurrent() if not image: # Image is None - Draw.PupMenu('ERROR: You must select an active Image.') + Draw.PupMenu('ERROR: Please select active Image.') return if image.packed: Draw.PupMenu('ERROR: Image is packed, unpack before editing.') @@ -94,16 +114,19 @@ def edit_extern(image=None): if new_text: pupblock.append('first time, set path.') if platform == 'win32': - appstring = 'start "" /B "%f"' + # Example of path to popular image editor... ;-) + # appstring = '"C:\\Program Files\\Adobe\\Photoshop CS\\photoshop.exe" "%f"' + # Have to add "cmd /c" to make sure we're using Windows shell. + appstring = 'cmd /c start "" /B "%f"' elif platform == 'darwin': appstring = 'open "%f"' else: - appstring = 'gimp-remote "%f"' + appstring = 'gimp %f' appstring_but = Draw.Create(appstring) save_default_but = Draw.Create(0) - pupblock.append(('editor: ', appstring_but, 0, 48, 'Path to application, %f will be replaced with the image path.')) + pupblock.append(('editor: ', appstring_but, 0, 99, 'Path to application, %f will be replaced with the image path.')) pupblock.append(('Set Default', save_default_but, 'Store this path in the blender registry.')) # Only configure if Shift is held, @@ -118,19 +141,18 @@ def edit_extern(image=None): Registry.SetKey('ExternalImageEditor', {'path':appstring}, True) if appstring.find('%f') == -1: - Draw.PupMenu('ERROR: The comment you entered did not contain the filename ("%f")') + Draw.PupMenu('ERROR: No filename specified! ("%f")') return # ------------------------------- - appstring = appstring.replace('%f', imageFileName) - print '\tediting image with command "%s"' % appstring - os.system(appstring) + os_run(appstring, imageFileName) + def main(): edit_extern() -if __name__ == '__main__' and os != None: - main()
\ No newline at end of file +if __name__ == '__main__' and subprocess: + main() |