Default custom editors for each platform in Bazaar Explorer 0.9.0
Olaf Conradi
olaf at conradi.org
Sun Nov 1 13:33:09 GMT 2009
Hi Ian,
2009/11/1 Ian Clatworthy <ian.clatworthy at canonical.com>:
> Robert Collins wrote:
>
>> On win32 right-mouse, 'Edit' is common for doing this - I'd suggest
>> looking up the edit action for the file type as a default, with manual
>> configuration permitted to extend this. Or better still provide a shell
>> view of the files so the win32 shell can do this for free.
>
> By 'shell view', I assume you mean 'OS-specific File manager'. Explorer
> does that currently. 'Edit' is an explicit action in the Working Tree
> Browser and also the default action on added/modified files in the
> 'status view'.
>
> I'm happy to use values from the registry on win32 if someone provides
> code for that. Likewise for any other desktop environment that let's one
> configure 'edit' separately to 'open'.
You can use this:
win32api.ShellExecute(0,"open",filename,None,workingdir,1) for open
win32api.ShellExecute(0,"edit",filename,None,workingdir,1) for edit
Where filename is an absolute path to the file, and workingdir is best
set to the directory of the file, None refers to any commandline
arguments, and finally the last 1 makes the application visible as a
normal window.
see http://docs.activestate.com/activepython/2.4/pywin32/win32api__ShellExecute_meth.html
and http://support.microsoft.com/kb/238245
However, I just found out that not every file has an edit action
causing the shellexecute to fail.
So you need to fall back to open
try:
try:
win32api.ShellExecute(0,"edit",filename,None,workingdir,1)
except win32api.error:
# Fall back to open
win32api.ShellExecute(0,"open",filename,None,workingdir,1)
except win32api.error:
print "Can't start %s" % filename
Don't know if there is a way to find out when edit is not there.
Cheers,
-Olaf
More information about the bazaar
mailing list