/[gli]/branches/overhaul/src/fe/gtk/PartProperties.py
Gentoo

Diff of /branches/overhaul/src/fe/gtk/PartProperties.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1595 Revision 1596
5 5
6import gtk 6import gtk
7import PartitionButton 7import PartitionButton
8from gettext import gettext as _ 8from gettext import gettext as _
9 9
10# keep these in sync with GLIStorageDevice!
11# these are here so that we can change them easily in future
12# the values were chosen to represent perfect floating point representations
13FREE_MINOR_FRAC_PRI = 1.0/32.0
14FREE_MINOR_FRAC_LOG = 1.0/8.0
15
16class PartProperties(gtk.Window): 10class PartProperties(gtk.Window):
17 11
18 def __init__(self, controller, device, minor, cur_size, min_size, max_size, fstype, bytes_in_sector=512, format=True): 12 def __init__(self, controller, device, idx):
19 gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) 13 gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
20 14
21 self.controller = controller 15 self.controller = controller
22 self.device = device 16 self.device = device
17 self.idx = idx
18 self.part = self.controller.devices[device].get_partition(idx)
23 self.minor = minor 19 self.minor = self.part['minor']
24 self.min_size = min_size 20 self.min_size = self.part['min_size']
25 self.max_size = max_size 21 self.max_size = self.part['max_size']
26 self.cur_size = cur_size 22 self.cur_size = self.part['mb']
27 self.fstype = fstype 23 self.fstype = self.part['type']
28 self.bytes_in_sector = bytes_in_sector
29 self.format = format
30 if self.min_size == -1 or self.max_size == -1: 24 if self.min_size == -1 or self.max_size == -1:
31 self.min_size = self.cur_size 25 self.min_size = self.cur_size
32 self.max_size = self.cur_size 26 self.max_size = self.cur_size
33 self.sync_slider_to_text = True 27 self.sync_slider_to_text = True
34 self.supported_filesystems = self.controller.devices[self.device].get_supported_filesystems() 28 self.supported_filesystems = self.controller.devices[self.device].get_supported_filesystems()
37 self.connect("destroy", self.destroy_event) 31 self.connect("destroy", self.destroy_event)
38 self.set_default_size(400,300) 32 self.set_default_size(400,300)
39 if self.fstype == "free": 33 if self.fstype == "free":
40 self.set_title(_("New partition on ") + device) 34 self.set_title(_("New partition on ") + device)
41 else: 35 else:
42 self.set_title(_("Properties for ") + self.controller.devices[self.device][minor]['devnode']) 36 self.set_title(_("Properties for ") + self.part['devnode'])
43 37
44 self.globalbox = gtk.VBox(False, 0) 38 self.globalbox = gtk.VBox(False, 0)
45 self.globalbox.set_border_width(10) 39 self.globalbox.set_border_width(10)
46 40
47 self.resize_box = gtk.VBox(False, 0) 41 self.resize_box = gtk.VBox(False, 0)
94 part_info_table.attach(info_partition_label, 0, 1, 0, 1) 88 part_info_table.attach(info_partition_label, 0, 1, 0, 1)
95 self.info_partition = gtk.Label() 89 self.info_partition = gtk.Label()
96 self.info_partition.set_alignment(0.0, 0.5) 90 self.info_partition.set_alignment(0.0, 0.5)
97 part_info_table.attach(self.info_partition, 1, 2, 0, 1) 91 part_info_table.attach(self.info_partition, 1, 2, 0, 1)
98 92
99 info_partition_format = gtk.Label(_("Format:"))
100 info_partition_format.set_alignment(0.0, 0.5)
101 part_info_table.attach(info_partition_format, 0, 1, 1, 2)
102 resize_info_part_format_box = gtk.HBox(False, 0)
103 self.resize_info_part_format_yes = gtk.RadioButton(label=_("Yes"))
104 self.resize_info_part_format_no = gtk.RadioButton(label=_("No"), group=self.resize_info_part_format_yes)
105 if self.fstype == "free":
106 self.resize_info_part_format_yes.set_sensitive(False)
107 self.resize_info_part_format_no.set_sensitive(False)
108 else:
109 if self.format:
110 self.resize_info_part_format_yes.set_active(True)
111 else:
112 self.resize_info_part_format_no.set_active(True)
113 resize_info_part_format_box.pack_start(self.resize_info_part_format_yes, expand=False, fill=False)
114 resize_info_part_format_box.pack_start(self.resize_info_part_format_no, expand=False, fill=False, padding=10)
115 part_info_table.attach(resize_info_part_format_box, 1, 2, 1, 2)
116
117 info_partition_type = gtk.Label(_("Type:")) 93 info_partition_type = gtk.Label(_("Type:"))
118 info_partition_type.set_alignment(0.0, 0.5) 94 info_partition_type.set_alignment(0.0, 0.5)
119 part_info_table.attach(info_partition_type, 0, 1, 2, 3) 95 part_info_table.attach(info_partition_type, 0, 1, 1, 2)
120 self.resize_info_part_type = gtk.combo_box_new_text() 96 self.resize_info_part_type = gtk.combo_box_new_text()
121 self.resize_info_part_type.append_text(_("Primary")) 97 self.resize_info_part_type.append_text(_("Primary"))
122 self.resize_info_part_type.append_text(_("Logical")) 98 self.resize_info_part_type.append_text(_("Logical"))
123 self.resize_info_part_type.set_active(0) 99 self.resize_info_part_type.set_active(0)
124 part_info_table.attach(self.resize_info_part_type, 1, 2, 2, 3) 100 part_info_table.attach(self.resize_info_part_type, 1, 2, 1, 2)
125 101
126 info_partition_fs = gtk.Label(_("Filesystem:")) 102 info_partition_fs = gtk.Label(_("Filesystem:"))
127 info_partition_fs.set_alignment(0.0, 0.5) 103 info_partition_fs.set_alignment(0.0, 0.5)
128 part_info_table.attach(info_partition_fs, 0, 1, 3, 4) 104 part_info_table.attach(info_partition_fs, 0, 1, 2, 3)
129 self.resize_info_part_filesystem = gtk.combo_box_new_text() 105 self.resize_info_part_filesystem = gtk.combo_box_new_text()
130# for fs in self.controller.supported_filesystems: 106# for fs in self.controller.supported_filesystems:
131 for fs in self.supported_filesystems: 107 for fs in self.supported_filesystems:
132 self.resize_info_part_filesystem.append_text(fs) 108 self.resize_info_part_filesystem.append_text(fs)
133 self.resize_info_part_filesystem.set_active(0) 109 self.resize_info_part_filesystem.set_active(0)
134 self.resize_info_part_filesystem.connect("changed", self.filesystem_changed) 110 self.resize_info_part_filesystem.connect("changed", self.filesystem_changed)
135 part_info_table.attach(self.resize_info_part_filesystem, 1, 2, 3, 4) 111 part_info_table.attach(self.resize_info_part_filesystem, 1, 2, 2, 3)
136 112
137 info_partition_mountpoint = gtk.Label(_("Mount point:")) 113 info_partition_mountpoint = gtk.Label(_("Mount point:"))
138 info_partition_mountpoint.set_alignment(0.0, 0.5) 114 info_partition_mountpoint.set_alignment(0.0, 0.5)
139 part_info_table.attach(info_partition_mountpoint, 0, 1, 4, 5) 115 part_info_table.attach(info_partition_mountpoint, 0, 1, 3, 4)
140 self.part_mount_point_entry = gtk.Entry() 116 self.part_mount_point_entry = gtk.Entry()
141 part_info_table.attach(self.part_mount_point_entry, 1, 2, 4, 5) 117 part_info_table.attach(self.part_mount_point_entry, 1, 2, 3, 4)
142 118
143 info_partition_mountopts = gtk.Label(_("Mount options:")) 119 info_partition_mountopts = gtk.Label(_("Mount options:"))
144 info_partition_mountopts.set_alignment(0.0, 0.5) 120 info_partition_mountopts.set_alignment(0.0, 0.5)
145 part_info_table.attach(info_partition_mountopts, 0, 1, 5, 6) 121 part_info_table.attach(info_partition_mountopts, 0, 1, 4, 5)
146 self.part_mount_opts_entry = gtk.Entry() 122 self.part_mount_opts_entry = gtk.Entry()
147 part_info_table.attach(self.part_mount_opts_entry, 1, 2, 5, 6) 123 part_info_table.attach(self.part_mount_opts_entry, 1, 2, 4, 5)
148 124
149 self.part_info_box.pack_start(part_info_table, expand=False, fill=False, padding=0) 125 self.part_info_box.pack_start(part_info_table, expand=False, fill=False, padding=0)
150 self.globalbox.pack_start(self.part_info_box, expand=False, fill=False, padding=10) 126 self.globalbox.pack_start(self.part_info_box, expand=False, fill=False, padding=10)
151 127
152 bottom_box = gtk.HBox(True, 0) 128 bottom_box = gtk.HBox(True, 0)
246 hpaned_pos = self.resize_hpaned.get_position() 222 hpaned_pos = self.resize_hpaned.get_position()
247 part_space = float(hpaned_width - (hpaned_width - hpaned_pos)) / hpaned_width 223 part_space = float(hpaned_width - (hpaned_width - hpaned_pos)) / hpaned_width
248# part_size = round(self.max_size * part_space) 224# part_size = round(self.max_size * part_space)
249 part_size = int(self.resize_info_part_size.get_text()) 225 part_size = int(self.resize_info_part_size.get_text())
250 if self.resize_info_part_type.get_active() == 1 and self.controller.devices[self.device].get_extended_partition() == 0: # Logical and no extended partition 226 if self.resize_info_part_type.get_active() == 1 and self.controller.devices[self.device].get_extended_partition() == 0: # Logical and no extended partition
251 self.controller.devices[self.device].add_partition(self.minor, self.max_size, 0, 0, "extended") 227 self.controller.devices[self.device].add_partition(self.idx, self.max_size, "extended")
252 self.minor = 4 + FREE_MINOR_FRAC_LOG 228 # TODO: determine idx for new unallocated space inside extended partititon
253 fstype = self.supported_filesystems[self.resize_info_part_filesystem.get_active()] 229 fstype = self.supported_filesystems[self.resize_info_part_filesystem.get_active()]
254 new_minor = self.controller.devices[self.device].add_partition(self.minor, part_size, 0, 0, fstype, mountpoint=self.part_mount_point_entry.get_text(), mountopts=self.part_mount_opts_entry.get_text()) 230 newidx = self.controller.devices[self.device].add_partition(self.idx, part_size, fstype)
255 self.controller.draw_part_box() 231 self.controller.draw_part_box()
256 self.controller.part_selected(None, self.device, new_minor) 232 self.controller.part_selected(None, self.device, newidx)
257 else: 233 else:
258 tmppart = self.controller.devices[self.device].get_partition(self.minor)
259 tmppart.set_mountpoint(self.part_mount_point_entry.get_text())
260 tmppart.set_mountopts(self.part_mount_opts_entry.get_text())
261 tmppart.set_format(self.resize_info_part_format_yes.get_active())
262 new_size = int(self.resize_info_part_size.get_text())
263 if new_size != self.cur_size:
264 tmppart.resize(new_size)
265 self.controller.draw_part_box() 234 self.controller.draw_part_box()
266 self.controller.part_selected(None, self.device, int(self.minor)) 235 self.controller.part_selected(None, self.device, self.idx)
267 236
268 self.destroy() 237 self.destroy()
269 238
270 def cancel_clicked(self, button): 239 def cancel_clicked(self, button):
271 self.destroy() 240 self.destroy()

Legend:
Removed from v.1595  
changed lines
  Added in v.1596

  ViewVC Help
Powered by ViewVC 1.1.20