32
32
from threading import Thread
33
33
import nautilus_api as nautilus
35
from ecryptfs import ecryptapi, ecryptui
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
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)
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()
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)
68
54
self.__update_status()
70
56
def __toggle_state(self, button):
71
57
"""Toggle the connectivity state."""
73
ecryptapi.set_mounted(False)
59
ecryptapi.setMounted(False)
75
ecryptapi.set_mounted(True)
61
ecryptapi.setMounted(True)
77
63
self.__update_status()
79
def __onclick_configure(self, button):
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()
86
label = "Lock directory"
87
img = LOCK_SECURE_SMALL
69
self.__button.set_label("Lock directory")
89
label = "Unlock directory"
90
img = LOCK_INSECURE_SMALL
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")
97
74
def is_storagefs(path):