1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
# Copyright 1999-2005 Gentoo Foundation
# This source code is distributed under the terms of version 2 of the GNU
# General Public License as published by the Free Software Foundation, a copy
# of which can be found in the main directory of this project.
import gtk, gobject
from GLIScreen import *
import Widgets
import commands, string
import copy
from ProgressDialog import *
class Panel(GLIScreen):
title = "Local Mounts"
columns = []
localmounts = []
active_entry = -1
_helptext = """
<b><u>Local Mounts</u></b>
Here, you can add partitions and special devices to mount during (and after) \
the install. All mountpoints are relative to /mnt/gentoo during the install.
To start, click the button labeled 'Add'. Enter a device name or select if from \
the list. If you entered a device name yourself, you'll need to fill in the \
type in the next field. Then enter the mountpoint and mount options (defaults to \
"defaults"). Click 'Update' to save the new mount.
To edit a mount that you've already added to the list list, select it by \
clicking on it. Edit any of the fields below and click the 'Update' button. You \
can remove it from the list by clicking the 'Delete' button.
"""
def __init__(self, controller):
GLIScreen.__init__(self, controller)
vert = gtk.VBox(False, 0)
vert.set_border_width(10)
self.treedata = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
self.treedatasort = gtk.TreeModelSort(self.treedata)
self.treeview = gtk.TreeView(self.treedatasort)
self.treeview.connect("cursor-changed", self.selection_changed)
self.columns.append(gtk.TreeViewColumn("Device", gtk.CellRendererText(), text=1))
self.columns.append(gtk.TreeViewColumn("Type", gtk.CellRendererText(), text=2))
self.columns.append(gtk.TreeViewColumn("Mount Point", gtk.CellRendererText(), text=3))
self.columns.append(gtk.TreeViewColumn("Mount Options", gtk.CellRendererText(), text=4))
col_num = 0
for column in self.columns:
column.set_resizable(True)
column.set_sort_column_id(col_num)
self.treeview.append_column(column)
col_num += 1
self.treewindow = gtk.ScrolledWindow()
self.treewindow.set_size_request(-1, 130)
self.treewindow.set_shadow_type(gtk.SHADOW_IN)
self.treewindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.treewindow.add(self.treeview)
vert.pack_start(self.treewindow, expand=False, fill=False, padding=0)
self.mount_info_box = gtk.HBox(False, 0)
mount_info_table = gtk.Table(5, 3, False)
mount_info_table.set_col_spacings(10)
mount_info_table.set_row_spacings(6)
mount_info_device_label = gtk.Label("Device:")
mount_info_device_label.set_alignment(0.0, 0.5)
mount_info_table.attach(mount_info_device_label, 0, 1, 0, 1)
self.mount_info_device = gtk.ComboBoxEntry(gtk.ListStore(gobject.TYPE_STRING))
if not self.mount_info_device.get_text_column() == 0:
self.mount_info_device.set_text_column(0)
mount_info_table.attach(self.mount_info_device, 1, 2, 0, 1)
mount_info_type_label = gtk.Label("Type:")
mount_info_type_label.set_alignment(0.0, 0.5)
mount_info_table.attach(mount_info_type_label, 0, 1, 1, 2)
self.mount_info_type = gtk.Entry()
self.mount_info_type.set_width_chars(20)
mount_info_table.attach(self.mount_info_type, 1, 2, 1, 2)
mount_info_mountpoint_label = gtk.Label("Mount point:")
mount_info_mountpoint_label.set_alignment(0.0, 0.5)
mount_info_table.attach(mount_info_mountpoint_label, 0, 1, 2, 3)
self.mount_info_mountpoint = gtk.Entry()
self.mount_info_mountpoint.set_width_chars(30)
mount_info_table.attach(self.mount_info_mountpoint, 1, 2, 2, 3)
mount_info_mountopts_label = gtk.Label("Mount options:")
mount_info_mountopts_label.set_alignment(0.0, 0.5)
mount_info_table.attach(mount_info_mountopts_label, 0, 1, 3, 4)
self.mount_info_mountopts = gtk.Entry()
self.mount_info_mountopts.set_width_chars(30)
mount_info_table.attach(self.mount_info_mountopts, 1, 2, 3, 4)
self.mount_info_box.pack_start(mount_info_table, expand=False, fill=False)
vert.pack_start(self.mount_info_box, expand=False, fill=False, padding=10)
mount_button_box = gtk.HBox(False, 0)
mount_button_add = gtk.Button(" _Add ")
mount_button_add.connect("clicked", self.new_mount)
mount_button_box.pack_start(mount_button_add, expand=False, fill=False, padding=10)
self.mount_button_update = gtk.Button(" _Update ")
self.mount_button_update.connect("clicked", self.update_mount)
self.mount_button_update.set_sensitive(False)
mount_button_box.pack_start(self.mount_button_update, expand=False, fill=False, padding=10)
self.mount_button_delete = gtk.Button(" _Delete ")
self.mount_button_delete.connect("clicked", self.delete_mount)
self.mount_button_delete.set_sensitive(False)
mount_button_box.pack_start(self.mount_button_delete, expand=False, fill=False, padding=10)
vert.pack_start(mount_button_box, expand=False, fill=False, padding=10)
self.add_content(vert)
def disable_all_fields(self):
self.mount_info_device.get_child().set_text("")
self.mount_info_device.set_model(gtk.ListStore(gobject.TYPE_STRING))
self.mount_info_type.set_text("")
self.mount_info_mountpoint.set_text("")
self.mount_info_mountopts.set_text("")
self.mount_info_device.set_sensitive(False)
self.mount_info_type.set_sensitive(False)
self.mount_info_mountpoint.set_sensitive(False)
self.mount_info_mountopts.set_sensitive(False)
def enable_all_fields(self):
self.mount_info_device.get_child().set_text("")
self.mount_info_device.set_model(gtk.ListStore(gobject.TYPE_STRING))
self.mount_info_mountpoint.set_text("")
self.mount_info_mountopts.set_text("")
self.mount_info_device.set_sensitive(True)
self.mount_info_type.set_sensitive(True)
self.mount_info_mountpoint.set_sensitive(True)
self.mount_info_mountopts.set_sensitive(True)
def refresh_list_at_top(self):
# self.treedata = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
self.treedata.clear()
for i, mount in enumerate(self.localmounts):
self.treedata.append([i, mount['devnode'], mount['type'], mount['mountpoint'], mount['mountopts']])
self.treedatasort = gtk.TreeModelSort(self.treedata)
self.treeview.set_model(self.treedatasort)
self.treeview.show_all()
def selection_changed(self, treeview, data=None):
treeselection = treeview.get_selection()
treemodel, treeiter = treeselection.get_selected()
row = treemodel.get(treeiter, 0)
self.active_entry = row[0]
mount = self.localmounts[self.active_entry]
self.enable_all_fields()
# self.mount_info_export.set_model(gtk.ListStore(gobject.TYPE_STRING))
# self.mount_info_export.get_child().set_text(mount['export'])
# i = 0
# for mounttype in self.mount_types:
# if mounttype == mount['type']:
# self.mount_info_type.set_active(i)
# else:
# i = i + 1
self.mount_info_device.get_child().set_text(mount['devnode'])
self.mount_info_type.set_text(mount['type'])
self.mount_info_mountpoint.set_text(mount['mountpoint'])
self.mount_info_mountopts.set_text(mount['mountopts'])
self.mount_button_update.set_sensitive(True)
self.mount_button_delete.set_sensitive(True)
def new_mount(self, button, data=None):
self.active_entry = -1
self.mount_button_update.set_sensitive(True)
self.mount_button_delete.set_sensitive(False)
self.enable_all_fields()
self.mount_info_device.grab_focus()
def update_mount(self, button):
if self.mount_info_device.get_child().get_text().strip() == "":
msgdialog = Widgets.Widgets().error_Box("Invalid Entry", "You must enter a value for the device field")
result = msgdialog.run()
if result == gtk.RESPONSE_ACCEPT:
msgdialog.destroy()
return
if self.mount_info_mountpoint.get_text().strip() == "":
msgdialog = Widgets.Widgets().error_Box("Invalid Entry", "You must enter a mountpoint")
result = msgdialog.run()
if result == gtk.RESPONSE_ACCEPT:
msgdialog.destroy()
return
if self.mount_info_type.get_text().strip() == "":
self.mount_info_type.set_text("auto")
if self.mount_info_mountopts.get_text().strip() == "":
self.mount_info_mountopts.set_text("defaults")
if self.active_entry == -1:
self.localmounts.append({ 'devnode': self.mount_info_device.get_child().get_text(), 'type': self.mount_info_type.get_text(), 'mountpoint': self.mount_info_mountpoint.get_text(), 'mountopts': self.mount_info_mountopts.get_text() })
self.active_entry = -1
self.mount_button_update.set_sensitive(False)
self.mount_button_delete.set_sensitive(False)
else:
self.localmounts[self.active_entry]['devnode'] = self.mount_info_device.get_child().get_text()
self.localmounts[self.active_entry]['type'] = self.mount_info_type.get_text()
self.localmounts[self.active_entry]['mountpoint'] = self.mount_info_mountpoint.get_text()
self.localmounts[self.active_entry]['mountopts'] = self.mount_info_mountopts.get_text()
self.refresh_list_at_top()
self.disable_all_fields()
def delete_mount(self, button):
self.localmounts.pop(self.active_entry)
self.active_entry = -1
self.mount_button_update.set_sensitive(False)
self.mount_button_delete.set_sensitive(False)
self.refresh_list_at_top()
self.disable_all_fields()
def activate(self):
self.controller.SHOW_BUTTON_BACK = True
self.controller.SHOW_BUTTON_FORWARD = True
self.localmounts = copy.deepcopy(self.controller.install_profile.get_mounts())
self.refresh_list_at_top()
self.disable_all_fields()
self.mount_button_update.set_sensitive(False)
self.mount_button_delete.set_sensitive(False)
def next(self):
for mount in self.localmounts:
if mount['mountpoint'] == "/":
break
else:
msgdlg = gtk.MessageDialog(parent=self.controller.window, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_OK, message_format=_("You must specify a mount at / to continue"))
resp = msgdlg.run()
msgdlg.destroy()
return
self.controller.install_profile.set_mounts(self.localmounts)
self.controller.load_screen("NetworkMounts")
# progress = ProgressDialog(self.controller, ("mount_local_partitions", ), self.progress_callback)
# progress.run()
# def progress_callback(self, result, data=None):
# if result == PROGRESS_DONE:
# self.controller.load_screen("Network Mounts")
# else:
# GLIScreen.progress_callback(self, result, data)
def previous(self):
self.controller.install_profile.set_mounts(self.localmounts)
self.controller.load_screen("Partition")
|