32
32
from threading import Thread
33
33
import nautilus_api as nautilus
35
from ecryptfs import ecryptapi
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")
37
40
class StorageBar(gtk.HBox):
38
41
"""The storage bar widget."""
40
43
def __init__(self, path, *args, **kw):
41
44
"""Initialize the widget."""
42
45
super(StorageBar, self).__init__(*args, **kw)
48
# Create the left-side label text.
43
49
self.__label = gtk.Label()
44
50
self.__label.set_markup("These are files in an encrypted directory")
45
51
self.__label.set_alignment(0.0, 0.5)
46
52
self.__label.show()
47
self.add(self.__label)
53
# Initialize the lock/unlock button and image.
48
54
self.__button = gtk.Button()
55
self.__button.set_property("image-position", gtk.POS_LEFT)
49
56
self.__button.connect("clicked", self.__toggle_state)
50
57
self.__button.show()
51
self.pack_end(self.__button, expand=False, fill=False)
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.
54
68
self.__update_status()
56
70
def __toggle_state(self, button):
57
71
"""Toggle the connectivity state."""
59
ecryptapi.setMounted(False)
73
ecryptapi.set_mounted(False)
61
ecryptapi.setMounted(True)
75
ecryptapi.set_mounted(True)
63
77
self.__update_status()
79
def __onclick_configure(self, button):
65
82
def __update_status(self):
66
83
"""Update the label, and button when connection status changes."""
67
self.__mounted = ecryptapi.getMounted()
84
self.__mounted = ecryptapi.get_mounted()
69
self.__button.set_label("Lock directory")
86
label = "Lock directory"
87
img = LOCK_SECURE_SMALL
71
self.__button.set_label("Unlock 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)
74
97
def is_storagefs(path):