diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-17 13:27:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-17 13:27:31 +0400 |
commit | 5452f335d7fd768fda7320419e3581e5309529fe (patch) | |
tree | f80553108d8541e2d070c02fe86778494f31c188 /release | |
parent | 945ae254092dcbb284072fd4ffcc80b33bff27f6 (diff) |
New optional operator function, check(), it takes the same arguments as execute().
This runs after changing a property and allows correcting incompatible options.
Returning True will redraw the UI.
Currently this is used for setting the write extension when saving files, so changing the image format also corrects the extension.
The same is accessible from python where its used when saving SVG/EPS/PNG files.
This fixes: [#23828] obj export problems, [#23760] Exporting OBJ and filetype ending
also fixed document submission operator.
Now the filename in the file selector is the one used for writing this means we remove the "Save Over" popup which could be overlooked too easily.
Instead display the filename field with red tint, and a note in the tooltip.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/io_utils.py | 8 | ||||
-rw-r--r-- | release/scripts/op/uv.py | 9 | ||||
-rw-r--r-- | release/scripts/op/wm.py | 3 |
3 files changed, 19 insertions, 1 deletions
diff --git a/release/scripts/modules/io_utils.py b/release/scripts/modules/io_utils.py index 04c441100d7..adc3afce71d 100644 --- a/release/scripts/modules/io_utils.py +++ b/release/scripts/modules/io_utils.py @@ -34,6 +34,14 @@ class ExportHelper: context.window_manager.add_fileselect(self) return {'RUNNING_MODAL'} + def check(self, context): + filepath = bpy.path.ensure_ext(self.filepath, self.filename_ext) + if filepath != self.filepath: + self.filepath = filepath + return True + else: + return False + class ImportHelper: filepath = StringProperty(name="File Path", description="Filepath used for importing the file", maxlen=1024, default="", subtype='FILE_PATH') diff --git a/release/scripts/op/uv.py b/release/scripts/op/uv.py index cd0c2acf75c..d01ef070d87 100644 --- a/release/scripts/op/uv.py +++ b/release/scripts/op/uv.py @@ -343,6 +343,15 @@ class ExportUVLayout(bpy.types.Operator): return {'FINISHED'} + def check(self, context): + filepath = bpy.path.ensure_ext(self.filepath, "." + self.mode.lower()) + if filepath != self.filepath: + self.filepath = filepath + return True + else: + return False + + def invoke(self, context, event): self.size = self._image_size(context) wm = context.window_manager diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index 7b500d028fd..af752d69ae9 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -632,7 +632,7 @@ class WM_OT_doc_edit(bpy.types.Operator): def draw(self, context): layout = self.layout - props = self + props = self.properties # XXX, this should not be needed, api problem! layout.label(text="Descriptor ID: '%s'" % props.doc_id) layout.prop(props, "doc_new", text="") @@ -641,6 +641,7 @@ class WM_OT_doc_edit(bpy.types.Operator): return wm.invoke_props_dialog(self, width=600) + from bpy.props import * |