There is a mechanism to custom open files in Smile depending on their file extension:
- If you want to handle the opening of the files of extension .xxx, you have to define in Smile' context a handler named customopen_xxx (replace xxx with the extension you are interested in).
This handler has one parameter that is the file path.
-
If this handler does not exists or if it fails, the default behavior occurs. Such a handler can perform tests to choose opening the file its own way or to fail to get the default opening behavior.
-
You can have such handlers defined in your context additions.
For example, the following handler opens .html files in unicode windows, and add a contextual menu "open this file in Safari":
on customopen_html(f)
set w to make new Unicode window with properties {path name:f}
set script of w to "on CustomMenuItems(w)
try
set x to continue CustomMenuItems(w)
on error
set x to {}
end try
return {\"open this file in Safari\"} & x
end CustomMenuItems
on do menu acmd to w
if acmd is \"open this file in Safari\" then
try
save w in 0
set f to path name of w
tell application \"Safari\" to open f
end try
else
continue do menu acmd to w
end if
end do menu"
end customopen_html
|