diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-07-04 14:02:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-07-04 14:02:30 +0400 |
commit | 8e97e561a9b0a9ab48675699c525410f4ad8a928 (patch) | |
tree | 0b10abd975866a7859512d9ac859811d0dacd23e /release | |
parent | ce94f52dbc1f18b805436313d26cdcef804622e9 (diff) |
convenience functionality for browse button (requested by Colin for the sequence editor, useful for managing files for the final edit)
- Holding Alt while clocking on the browse button opens a file browser with the containing dir.
- Holding Shift opens the file its self in the default application.
obscure but at least theres a tooltip so its not totally hidden.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/op/wm.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index 5ef79887228..481df3488b8 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -430,6 +430,40 @@ class WM_OT_url_open(bpy.types.Operator): return {'FINISHED'} +class WM_OT_path_open(bpy.types.Operator): + "Open a path in a file browser" + bl_idname = "wm.path_open" + bl_label = "" + + filepath = StringProperty(name="File Path", maxlen= 1024) + + def execute(self, context): + import sys + import os + import subprocess + + filepath = bpy.utils.expandpath(self.properties.filepath) + filepath = os.path.normpath(filepath) + + if not os.path.exists(filepath): + self.report({'ERROR'}, "File '%s' not found" % filepath) + return {'CANCELLED'} + + if sys.platform == 'win32': + subprocess.Popen(['start', filepath], shell= True) + elif sys.platform == 'darwin': + subprocess.Popen(['open', filepath]) + else: + try: + subprocess.Popen(['xdg-open', filepath]) + except OSError: + # xdg-open *should* be supported by recent Gnome, KDE, Xfce + pass + + return {'FINISHED'} + + + class WM_OT_doc_view(bpy.types.Operator): '''Load online reference docs''' bl_idname = "wm.doc_view" @@ -562,6 +596,7 @@ classes = [ WM_OT_context_modal_mouse, WM_OT_url_open, + WM_OT_path_open, WM_OT_doc_view, WM_OT_doc_edit, |