Code Snippet: open file in external viewer from Serna

by Andrew Sichevoi (kondor) on November 8th, 2009
kondor

Use case: open a file (or url) in external viewer from Serna using file type association rules defined in Tools -> Preferences -> Applications dialog.

Synopsis:

Command: LaunchBrowser
Arguments:

url : string, path/url to a file.

1
2
3
4
5
6
7
8
9
10
11
 class SomeCustomPlugin(DocumentPlugin):
   # Some code goes here
   ...
   def openExternalBrowser(self, path):
       browse_info = PropertyNode("external-viewer")
       url_arg = PropertyNode("url", path)
       browse_info.appendChild(url_arg)
 
       self.executeCommandEvent("LaunchBrowser", browse_info)
   # And some code below
   ...

document path here can be a path to local file as well as URI.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • Twitter

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS