~ubuntu-branches/ubuntu/oneiric/arkose/oneiric

« back to all changes in this revision

Viewing changes to arkose-nautilus.py

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Graber
  • Date: 2010-12-08 22:41:52 UTC
  • Revision ID: james.westby@ubuntu.com-20101208224152-s67e2vn4yp9hhmvm
Tags: upstream-0.3.1
Import upstream version 0.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import nautilus, subprocess, os
 
2
 
 
3
class SandboxExtension(nautilus.MenuProvider):
 
4
    def __init__(self):
 
5
        return
 
6
 
 
7
    def menu_activate_cb(self, menu, file):
 
8
        path=file.get_uri().replace('file://','')
 
9
        subprocess.Popen(['arkose-gui',path])
 
10
        return
 
11
 
 
12
    def get_file_items(self, window, files):
 
13
        if len(files) != 1:
 
14
            return
 
15
 
 
16
        if files[0].is_directory():
 
17
            return
 
18
        if files[0].get_uri_scheme() != "file":
 
19
            return
 
20
        path=files[0].get_uri().replace('file://','')
 
21
 
 
22
        if not os.path.exists(path) or not os.access(path, os.X_OK):
 
23
            return
 
24
 
 
25
        item = nautilus.MenuItem('NautilusPython::openterminal_file_item',
 
26
                                 'Open in a sandbox' ,
 
27
                                 'Open %s in a sandbox' % files[0].get_name())
 
28
        item.connect('activate', self.menu_activate_cb, files[0])
 
29
        return [item]