~mrooney/ecryptfs/nautilus-integration

« back to all changes in this revision

Viewing changes to src/python/nautilus/storage.py

  • Committer: Michael Rooney
  • Date: 2009-05-26 23:54:55 UTC
  • Revision ID: mrooney@ubuntu.com-20090526235455-a0dn5fkakvl3l2oc
initial add of nautilus work

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
from threading import Thread
33
33
import nautilus_api as nautilus
34
34
 
35
 
from ecryptfs import ecryptapi, ecryptui
36
 
 
37
 
LOCK_SECURE_SMALL = os.path.join(os.getcwd(), "ecryptfs/nautilus/lock-secure-small.png")
38
 
LOCK_INSECURE_SMALL = os.path.join(os.getcwd(), "ecryptfs/nautilus/lock-insecure-small.png")
 
35
from ecryptfs import ecryptapi
39
36
 
40
37
class StorageBar(gtk.HBox):
41
38
    """The storage bar widget."""
43
40
    def __init__(self, path, *args, **kw):
44
41
        """Initialize the widget."""
45
42
        super(StorageBar, self).__init__(*args, **kw)
46
 
        self.__path = path
47
 
        self.__mounted = None
48
 
        # Create the left-side label text.
49
43
        self.__label = gtk.Label()
50
44
        self.__label.set_markup("These are files in an encrypted directory")
51
45
        self.__label.set_alignment(0.0, 0.5)
52
46
        self.__label.show()
53
 
        # Initialize the lock/unlock button and image.
 
47
        self.add(self.__label)
54
48
        self.__button = gtk.Button()
55
 
        self.__button.set_property("image-position", gtk.POS_LEFT)
56
49
        self.__button.connect("clicked", self.__toggle_state)
57
50
        self.__button.show()
58
 
        self.__button_image = gtk.Image()
59
 
        # Initialize the configure button.
60
 
        self.__button_settings = gtk.Button("Configure")
61
 
        self.__button_settings.connect("clicked", self.__onclick_configure)
62
 
        self.__button_settings.show()
63
 
        # Layout everything
64
 
        self.add(self.__label)
65
 
        self.pack_start(self.__button, expand=False, fill=False)
66
 
        self.pack_end(self.__button_settings, expand=False, fill=False)
67
 
        # Update the status appropriately.
 
51
        self.pack_end(self.__button, expand=False, fill=False)
 
52
        self.__path = path
 
53
        self.__mounted = None
68
54
        self.__update_status()
69
55
 
70
56
    def __toggle_state(self, button):
71
57
        """Toggle the connectivity state."""
72
58
        if self.__mounted:
73
 
            ecryptapi.set_mounted(False)
 
59
            ecryptapi.setMounted(False)
74
60
        else:
75
 
            ecryptapi.set_mounted(True)
 
61
            ecryptapi.setMounted(True)
76
62
 
77
63
        self.__update_status()
78
 
        
79
 
    def __onclick_configure(self, button):
80
 
        ecryptui.main()
81
64
 
82
65
    def __update_status(self):
83
66
        """Update the label, and button when connection status changes."""
84
 
        self.__mounted = ecryptapi.get_mounted()
 
67
        self.__mounted = ecryptapi.getMounted()
85
68
        if self.__mounted:
86
 
            label = "Lock directory"
87
 
            img = LOCK_SECURE_SMALL
 
69
            self.__button.set_label("Lock directory")
88
70
        else:
89
 
            label = "Unlock directory"
90
 
            img = LOCK_INSECURE_SMALL
91
 
 
92
 
        self.__button_image.set_from_file(img)
93
 
        self.__button.set_image(self.__button_image)
94
 
        self.__button.set_label(label)
 
71
            self.__button.set_label("Unlock directory")
95
72
 
96
73
 
97
74
def is_storagefs(path):
107
84
    else:
108
85
        return False
109
86
 
110
 
class EcryptfsBarProvider(nautilus.LocationWidgetProvider):
 
87
class StorageBarProvider(nautilus.LocationWidgetProvider):
111
88
    """An extension class providing a location widget for storage
112
89
    directories.
113
90