Merge lp:~magnun-leno/usbmanager/release-1.0 into lp:usbmanager/1.x-hal
- release-1.0
- Merge into release-1.x-HAL
Proposed by
Magnun Leno
Status: | Merged |
---|---|
Approved by: | Magnun Leno |
Approved revision: | 37 |
Merged at revision: | not available |
Proposed branch: | lp:~magnun-leno/usbmanager/release-1.0 |
Merge into: | lp:usbmanager/1.x-hal |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~magnun-leno/usbmanager/release-1.0 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Magnun Leno | Approve | ||
Review via email: mp+9825@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Magnun Leno (magnun-leno) wrote : | # |
Revision history for this message
Magnun Leno (magnun-leno) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'locale/pt_BR/LC_MESSAGES/usbmanager.mo' |
2 | Binary files locale/pt_BR/LC_MESSAGES/usbmanager.mo 2009-08-01 04:08:37 +0000 and locale/pt_BR/LC_MESSAGES/usbmanager.mo 2009-08-07 13:13:11 +0000 differ |
3 | === modified file 'locale/pt_BR/LC_MESSAGES/usbmanager.po' |
4 | --- locale/pt_BR/LC_MESSAGES/usbmanager.po 2009-08-01 04:08:37 +0000 |
5 | +++ locale/pt_BR/LC_MESSAGES/usbmanager.po 2009-08-07 13:13:11 +0000 |
6 | @@ -2,8 +2,8 @@ |
7 | msgstr "" |
8 | "Project-Id-Version: usbmanager 0.9\n" |
9 | "Report-Msgid-Bugs-To: \n" |
10 | -"POT-Creation-Date: 2009-08-01 01:04-0300\n" |
11 | -"PO-Revision-Date: 2009-08-01 01:06-0300\n" |
12 | +"POT-Creation-Date: 2009-08-07 10:10-0300\n" |
13 | +"PO-Revision-Date: 2009-08-07 10:12-0300\n" |
14 | "Last-Translator: Magnun Leno da Silva <magnun.leno@gmail.com>\n" |
15 | "Language-Team: Magnun Leno <magnun.leno@gmail.com>\n" |
16 | "MIME-Version: 1.0\n" |
17 | @@ -16,12 +16,13 @@ |
18 | "X-Poedit-SearchPath-0: ../../../src\n" |
19 | |
20 | #: ../../../src/gui/widgets.py:70 |
21 | -#: ../../../src/gui/widgets.py:339 |
22 | +#: ../../../src/gui/widgets.py:340 |
23 | msgid "Label" |
24 | msgstr "Rótulo" |
25 | |
26 | #: ../../../src/gui/widgets.py:71 |
27 | -#: ../../../src/gui/windows.py:136 |
28 | +#: ../../../src/gui/windows.py:138 |
29 | +#: ../../../src/gui/windows.py:223 |
30 | msgid "Block Device" |
31 | msgstr "Disp. de Bloco" |
32 | |
33 | @@ -29,78 +30,99 @@ |
34 | msgid "Mounted" |
35 | msgstr "Montado" |
36 | |
37 | -#: ../../../src/gui/widgets.py:213 |
38 | +#: ../../../src/gui/widgets.py:212 |
39 | msgid "Properties" |
40 | msgstr "Propriedades" |
41 | |
42 | -#: ../../../src/gui/widgets.py:213 |
43 | +#: ../../../src/gui/widgets.py:212 |
44 | msgid "Show volume detailed properties" |
45 | msgstr "Mostrar propriedades detalhadas do volume" |
46 | |
47 | -#: ../../../src/gui/widgets.py:217 |
48 | -#: ../../../src/gui/widgets.py:277 |
49 | +#: ../../../src/gui/widgets.py:216 |
50 | +#: ../../../src/gui/widgets.py:276 |
51 | msgid "Mount/Umount" |
52 | msgstr "Montar/Desmontar" |
53 | |
54 | -#: ../../../src/gui/widgets.py:217 |
55 | +#: ../../../src/gui/widgets.py:216 |
56 | msgid "Mount or Umount device" |
57 | msgstr "Montar ou Desmontar dispositivo" |
58 | |
59 | -#: ../../../src/gui/widgets.py:221 |
60 | +#: ../../../src/gui/widgets.py:220 |
61 | +#: ../../../src/gui/windows.py:238 |
62 | msgid "Format" |
63 | msgstr "Formatar" |
64 | |
65 | -#: ../../../src/gui/widgets.py:221 |
66 | +#: ../../../src/gui/widgets.py:220 |
67 | msgid "Format devices" |
68 | msgstr "Formatar dispositivos" |
69 | |
70 | -#: ../../../src/gui/widgets.py:231 |
71 | +#: ../../../src/gui/widgets.py:230 |
72 | msgid "Quit" |
73 | msgstr "Sair" |
74 | |
75 | -#: ../../../src/gui/widgets.py:231 |
76 | +#: ../../../src/gui/widgets.py:230 |
77 | msgid "Quit USBManager" |
78 | msgstr "Sair do USBManager" |
79 | |
80 | -#: ../../../src/gui/widgets.py:278 |
81 | +#: ../../../src/gui/widgets.py:277 |
82 | msgid "Mount/Umount selected device" |
83 | msgstr "Montar/Desmontar dispositivo selecionado" |
84 | |
85 | -#: ../../../src/gui/widgets.py:281 |
86 | +#: ../../../src/gui/widgets.py:280 |
87 | msgid "Umount" |
88 | msgstr "Desmontar" |
89 | |
90 | -#: ../../../src/gui/widgets.py:282 |
91 | +#: ../../../src/gui/widgets.py:281 |
92 | msgid "Umount selected device" |
93 | msgstr "Desmontar dispositivo selecionado" |
94 | |
95 | -#: ../../../src/gui/widgets.py:285 |
96 | +#: ../../../src/gui/widgets.py:284 |
97 | msgid "Mount" |
98 | msgstr "Montar" |
99 | |
100 | -#: ../../../src/gui/widgets.py:286 |
101 | +#: ../../../src/gui/widgets.py:285 |
102 | msgid "Mount selected device" |
103 | msgstr "Montar dispositivo selecionado" |
104 | |
105 | -#: ../../../src/gui/widgets.py:402 |
106 | +#: ../../../src/gui/widgets.py:407 |
107 | msgid "Storage Device" |
108 | msgstr "Armazenamento" |
109 | |
110 | -#: ../../../src/gui/widgets.py:414 |
111 | +#: ../../../src/gui/widgets.py:419 |
112 | msgid "Mount Options" |
113 | msgstr "Montagem" |
114 | |
115 | -#: ../../../src/gui/widgets.py:432 |
116 | +#: ../../../src/gui/widgets.py:437 |
117 | msgid "General" |
118 | msgstr "Geral" |
119 | |
120 | -#: ../../../src/gui/widgets.py:441 |
121 | +#: ../../../src/gui/widgets.py:446 |
122 | msgid "File System" |
123 | msgstr "Sist. de Arquivos" |
124 | |
125 | +#: ../../../src/gui/widgets.py:539 |
126 | +msgid "Device" |
127 | +msgstr "Dispositivo" |
128 | + |
129 | +#: ../../../src/gui/widgets.py:550 |
130 | +msgid "Formating" |
131 | +msgstr "Formatando" |
132 | + |
133 | +#: ../../../src/gui/widgets.py:570 |
134 | +msgid "Check for Bad Blocks" |
135 | +msgstr "Buscar por Bad Blocks" |
136 | + |
137 | +#: ../../../src/gui/widgets.py:585 |
138 | +msgid "Quick Format" |
139 | +msgstr "Formatação Rápida" |
140 | + |
141 | +#: ../../../src/gui/widgets.py:588 |
142 | +msgid "Enable Compression" |
143 | +msgstr "Habilitar Compressão" |
144 | + |
145 | #: ../../../src/gui/tray.py:78 |
146 | #: ../../../src/gui/tray.py:98 |
147 | -#: ../../../src/gui/windows.py:61 |
148 | +#: ../../../src/gui/windows.py:63 |
149 | msgid "USB Volume Storage Manager" |
150 | msgstr "Gerenciador de Volumes USB" |
151 | |
152 | @@ -225,63 +247,95 @@ |
153 | msgid "Erro while umounting %s" |
154 | msgstr "Erro ao desmontar %s" |
155 | |
156 | -#: ../../../src/gui/windows.py:119 |
157 | +#: ../../../src/gui/windows.py:121 |
158 | #, python-format |
159 | msgid "%(device_label)s properties" |
160 | msgstr "Propriedades de %(device_label)s" |
161 | |
162 | -#: ../../../src/gui/windows.py:132 |
163 | +#: ../../../src/gui/windows.py:134 |
164 | msgid "Vendor" |
165 | msgstr "Fabricante" |
166 | |
167 | -#: ../../../src/gui/windows.py:132 |
168 | +#: ../../../src/gui/windows.py:134 |
169 | +#: ../../../src/gui/windows.py:223 |
170 | msgid "Size" |
171 | msgstr "Tamanho" |
172 | |
173 | -#: ../../../src/gui/windows.py:132 |
174 | +#: ../../../src/gui/windows.py:134 |
175 | msgid "Model" |
176 | msgstr "Modelo" |
177 | |
178 | -#: ../../../src/gui/windows.py:133 |
179 | +#: ../../../src/gui/windows.py:135 |
180 | msgid "Is Mounted" |
181 | msgstr "Montado" |
182 | |
183 | -#: ../../../src/gui/windows.py:133 |
184 | +#: ../../../src/gui/windows.py:135 |
185 | msgid "Read Only" |
186 | msgstr "Somente Leitura" |
187 | |
188 | -#: ../../../src/gui/windows.py:134 |
189 | +#: ../../../src/gui/windows.py:136 |
190 | msgid "Mount Point" |
191 | msgstr "Ponto de Montagem" |
192 | |
193 | -#: ../../../src/gui/windows.py:134 |
194 | +#: ../../../src/gui/windows.py:136 |
195 | msgid "Category" |
196 | msgstr "Categoria" |
197 | |
198 | -#: ../../../src/gui/windows.py:135 |
199 | +#: ../../../src/gui/windows.py:137 |
200 | msgid "Serial Number" |
201 | msgstr "Numero de Série" |
202 | |
203 | -#: ../../../src/gui/windows.py:135 |
204 | +#: ../../../src/gui/windows.py:137 |
205 | msgid "Type" |
206 | msgstr "Tipo" |
207 | |
208 | -#: ../../../src/gui/windows.py:136 |
209 | +#: ../../../src/gui/windows.py:138 |
210 | msgid "Version" |
211 | msgstr "Versão" |
212 | |
213 | -#: ../../../src/gui/windows.py:164 |
214 | +#: ../../../src/gui/windows.py:166 |
215 | msgid "Basic Informations" |
216 | msgstr "Informações Básicas" |
217 | |
218 | -#: ../../../src/gui/windows.py:169 |
219 | +#: ../../../src/gui/windows.py:171 |
220 | msgid "Advanced Informations" |
221 | msgstr "Informações Avançadas" |
222 | |
223 | +#: ../../../src/gui/windows.py:215 |
224 | +#, python-format |
225 | +msgid "Formating %(device_label)s" |
226 | +msgstr "Formatando %(device_label)s" |
227 | + |
228 | +#: ../../../src/gui/windows.py:224 |
229 | +msgid "New Label" |
230 | +msgstr "Novo Rótulo" |
231 | + |
232 | +#: ../../../src/gui/windows.py:224 |
233 | +msgid "Files System" |
234 | +msgstr "Sist. de Arquivos" |
235 | + |
236 | +#: ../../../src/gui/windows.py:320 |
237 | +msgid "Details" |
238 | +msgstr "Detalhes" |
239 | + |
240 | +#: ../../../src/gui/windows.py:375 |
241 | +msgid "Formating done" |
242 | +msgstr "Formatação concluída" |
243 | + |
244 | +#: ../../../src/gui/windows.py:376 |
245 | +msgid "Done" |
246 | +msgstr "Concluído" |
247 | + |
248 | +#: ../../../src/gui/windows.py:379 |
249 | +msgid "Error while formating" |
250 | +msgstr "Erro ao montar" |
251 | + |
252 | +#: ../../../src/gui/windows.py:380 |
253 | +msgid "Errors:" |
254 | +msgstr "Erros:" |
255 | + |
256 | #~ msgid "Volume Label" |
257 | #~ msgstr "Rótulo do Vol." |
258 | -#~ msgid "Details" |
259 | -#~ msgstr "Detalhes" |
260 | #~ msgid "Volume Size" |
261 | #~ msgstr "Tam. do Vol." |
262 | #~ msgid "" |
263 | |
264 | === modified file 'src/gui/messages.py' |
265 | --- src/gui/messages.py 2009-08-01 04:08:08 +0000 |
266 | +++ src/gui/messages.py 2009-08-07 13:09:33 +0000 |
267 | @@ -91,4 +91,4 @@ |
268 | ShowMessage(None, _('Erro while mounting %s')%(device.block_device), _("The following error ocurred:")+"\n\n"+msg, 0) |
269 | |
270 | def UmountingError(device, msg): |
271 | - ShowMessage(None, _('Erro while umounting %s')%(device.block_device), _("The following error ocurred:")+"\n\n"+msg, 0) |
272 | + ShowMessage(None, _('Erro while umounting %s')%(device.block_device), _("The following error ocurred:")+"\n\n"+str(msg), 0) |
273 | |
274 | === modified file 'src/gui/widgets.py' |
275 | --- src/gui/widgets.py 2009-08-01 04:08:08 +0000 |
276 | +++ src/gui/widgets.py 2009-08-07 13:09:33 +0000 |
277 | @@ -140,7 +140,6 @@ |
278 | # Existing Device |
279 | if current_devices.has_key(device.udi): |
280 | properties = current_devices[device.udi] |
281 | - print properties, dir(properties) |
282 | properties[0] = device.label |
283 | properties[1] = device.block_device |
284 | properties[2] = device.is_mounted |
285 | @@ -292,7 +291,9 @@ |
286 | |
287 | |
288 | def __on_format_click(self, widget, envet=None): |
289 | - messages.FunctionNotImemented() |
290 | + #messages.FunctionNotImemented() |
291 | + device = self.master.main_window.devices_list_view.get_selected_device() |
292 | + self.master.create_formating_window(device) |
293 | |
294 | def __on_mount_umount_click(self, widget, event=None): |
295 | device = self.master.main_window.devices_list_view.get_selected_device() |
296 | @@ -341,6 +342,10 @@ |
297 | self.entry = gtk.Entry(max=15) |
298 | self.entry.set_text(device.label) |
299 | |
300 | + if not device.is_renamable(): |
301 | + self.entry.set_sensitive(False) |
302 | + messages.DeviceNotRenamable(device) |
303 | + |
304 | self.pack_start(self.label, expand=True, fill=False) |
305 | self.pack_start(self.entry, expand=True, fill=True) |
306 | |
307 | @@ -448,3 +453,146 @@ |
308 | # Block Device |
309 | self.add_label_to_table(table, self.labels[4], 2) |
310 | self.add_text_value_to_table(table, self.device.block_device, 2) |
311 | + |
312 | +class FormatingGenericInfo(gtk.Frame): |
313 | + def __init__(self, device, labels, text): |
314 | + self.device = device |
315 | + self.labels = labels |
316 | + gtk.Frame.__init__(self) |
317 | + label = MarkupLabel("<b>"+text+"</b>") |
318 | + self.set_shadow_type(gtk.SHADOW_NONE) |
319 | + self.set_label_widget(label) |
320 | + |
321 | + self.align = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0) |
322 | + self.align.set_padding(padding_top=5, padding_bottom=5, padding_left=10, padding_right=10) |
323 | + self.add(self.align) |
324 | + |
325 | + self.table = gtk.Table(rows=2, columns=3, homogeneous=False) |
326 | + self.table.set_col_spacings(10) |
327 | + self.align.add(self.table) |
328 | + |
329 | + |
330 | + def add_label_to_table(self, text, index): |
331 | + label = gtk.Label(text) |
332 | + label.set_alignment(xalign=0, yalign=0.5) |
333 | + self.table.attach(label, 0, 1, index, index+1, |
334 | + xoptions=gtk.FILL, |
335 | + yoptions=gtk.EXPAND|gtk.FILL, |
336 | + xpadding=0, ypadding=2) |
337 | + self.add_point_sep(index) |
338 | + |
339 | + def add_entry(self, text, index): |
340 | + entry = gtk.Entry(15) |
341 | + entry.set_text(text) |
342 | + self.table.attach(entry, 2, 3, index, index+1, |
343 | + xoptions=gtk.EXPAND|gtk.FILL, |
344 | + yoptions=gtk.EXPAND|gtk.FILL, |
345 | + xpadding=0, ypadding=2) |
346 | + return entry |
347 | + |
348 | + def add_combo_box(self, items, index): |
349 | + combo = gtk.combo_box_new_text() |
350 | + for item in items: |
351 | + combo.append_text(item) |
352 | + |
353 | + current_fs = None |
354 | + if self.device.fs_type == 'vfat': |
355 | + current_fs = self.device.fs_version |
356 | + else: |
357 | + current_fs = self.device.fs_type |
358 | + if self.device.fs_type == 'ntfs-3g': |
359 | + current_fs = 'NTFS' |
360 | + |
361 | + if items.count(current_fs) is 0: |
362 | + print ' * Device current FS is unknown (%(fs)s). Assuming FAT16'%{"fs":current_fs} |
363 | + combo.set_active(0) |
364 | + else: |
365 | + print ' * Assuming device current FS:', current_fs |
366 | + combo.set_active(items.index(current_fs)) |
367 | + |
368 | + self.table.attach(combo, 2, 3, index, index+1, |
369 | + xoptions=gtk.EXPAND|gtk.FILL, |
370 | + yoptions=gtk.EXPAND|gtk.FILL, |
371 | + xpadding=0, ypadding=2) |
372 | + return combo |
373 | + |
374 | + def add_text_value_to_table(self, text, index): |
375 | + label = gtk.Label(text) |
376 | + label.set_alignment(xalign=0, yalign=0.5) |
377 | + self.table.attach(label, 2, 3, index, index+1, |
378 | + xoptions=gtk.EXPAND|gtk.FILL, |
379 | + yoptions=gtk.EXPAND|gtk.FILL, |
380 | + xpadding=0, ypadding=2) |
381 | + return label |
382 | + |
383 | + def add_point_sep(self, index): |
384 | + label = gtk.Label(":") |
385 | + label.set_alignment(xalign=0.5, yalign=0.5) |
386 | + self.table.attach(label, 1, 2, index, index+1, |
387 | + xoptions=gtk.FILL, |
388 | + yoptions=gtk.EXPAND|gtk.FILL, |
389 | + xpadding=0, ypadding=2) |
390 | + |
391 | + |
392 | +class FormatingDeviceInfo(FormatingGenericInfo): |
393 | + def __init__(self, device, labels): |
394 | + FormatingGenericInfo.__init__(self, device, labels, _("Device")) |
395 | + |
396 | + # Size |
397 | + self.add_label_to_table(self.labels[0], 0) |
398 | + self.add_text_value_to_table(device.size, 0) |
399 | + # Block Device |
400 | + self.add_label_to_table(self.labels[1], 1) |
401 | + self.add_text_value_to_table(device.block_device, 1) |
402 | + |
403 | +class FormatingFormatInfo(FormatingGenericInfo): |
404 | + def __init__(self, device, labels, suported_fs): |
405 | + FormatingGenericInfo.__init__(self, device, labels, _("Formating")) |
406 | + |
407 | + # Label |
408 | + self.add_label_to_table(self.labels[2], 0) |
409 | + self.label_entry = self.add_entry(device.label, 0) |
410 | + # FS Type |
411 | + self.add_label_to_table(self.labels[3], 1) |
412 | + self.fs_combo = self.add_combo_box(suported_fs, 1) |
413 | + |
414 | + def get_selected_fs(self): |
415 | + return self.fs_combo.get_active_text() |
416 | + |
417 | + def get_new_label(self): |
418 | + return self.label_entry.get_text() |
419 | + |
420 | +class FormatingVFatInfo(gtk.Alignment): |
421 | + def __init__(self): |
422 | + gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0) |
423 | + self.set_padding(padding_top=0, padding_bottom=5, padding_left=10, padding_right=10) |
424 | + |
425 | + self.check_bad_blocks = gtk.CheckButton(label=_("Check for Bad Blocks")) |
426 | + self.check_bad_blocks.set_active(False) |
427 | + |
428 | + self.vbox = gtk.VBox() |
429 | + self.add(self.vbox) |
430 | + self.vbox.pack_start(self.check_bad_blocks) |
431 | + |
432 | + def get_options(self): |
433 | + return [self.check_bad_blocks.get_active()] |
434 | + |
435 | +class FormatingNTFSInfo(gtk.Alignment): |
436 | + def __init__(self): |
437 | + gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0) |
438 | + self.set_padding(padding_top=0, padding_bottom=5, padding_left=10, padding_right=10) |
439 | + |
440 | + self.quick_format = gtk.CheckButton(label=_("Quick Format")) |
441 | + self.quick_format.set_active(True) |
442 | + |
443 | + self.compression = gtk.CheckButton(label=_("Enable Compression")) |
444 | + self.compression.set_active(False) |
445 | + |
446 | + self.vbox = gtk.VBox() |
447 | + self.add(self.vbox) |
448 | + self.vbox.pack_start(self.quick_format) |
449 | + self.vbox.pack_start(self.compression) |
450 | + |
451 | + def get_options(self): |
452 | + return [self.quick_format.get_active(), |
453 | + self.compression.get_active()] |
454 | |
455 | === modified file 'src/gui/windows.py' |
456 | --- src/gui/windows.py 2009-08-01 04:08:08 +0000 |
457 | +++ src/gui/windows.py 2009-08-07 13:09:33 +0000 |
458 | @@ -32,6 +32,8 @@ |
459 | import locale |
460 | import gettext |
461 | import sys |
462 | +import time |
463 | +from threading import Thread |
464 | |
465 | WINDOW_ICON = None |
466 | locale.setlocale(locale.LC_ALL, '') |
467 | @@ -199,4 +201,202 @@ |
468 | self.apply.set_sensitive(True) |
469 | |
470 | |
471 | - |
472 | +class FormatWindow(gtk.Dialog): |
473 | + def __init__(self, device, master, suported_fs): |
474 | + self.master = master |
475 | + self.device = device |
476 | + suported_fs.sort() |
477 | + |
478 | + self.new_label = None |
479 | + self.fs_type = None |
480 | + self.fs_options = None |
481 | + self.fs_align = None |
482 | + |
483 | + gtk.Dialog.__init__(self, _("Formating %(device_label)s")%{"device_label":device.label}, |
484 | + self.master.main_window, |
485 | + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) |
486 | + self.set_resizable(False) |
487 | + self.set_icon_from_file(WINDOW_ICON) |
488 | + self.set_border_width(10) |
489 | + self.vbox.set_spacing(10) |
490 | + |
491 | + self.field_labels = [_("Size"), _("Block Device"), |
492 | + _("New Label"), _("Files System")] |
493 | + |
494 | + max_len = max([len(label) for label in self.field_labels]) |
495 | + self.field_labels = [label.ljust(max_len) for label in self.field_labels] |
496 | + |
497 | + self.device_info = widgets.FormatingDeviceInfo(device, self.field_labels) |
498 | + self.vbox.pack_start(self.device_info) |
499 | + |
500 | + self.format_info = widgets.FormatingFormatInfo(device, self.field_labels, suported_fs) |
501 | + self.vbox.pack_start(self.format_info) |
502 | + |
503 | + self.format_info.fs_combo.connect("changed", self.__on_fs_selected) |
504 | + self.__on_fs_selected(None) |
505 | + |
506 | + btn = gtk.Button(_("Format")) |
507 | + btn.set_image(gtk.image_new_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_BUTTON)) |
508 | + self.add_action_widget(btn, gtk.RESPONSE_ACCEPT) |
509 | + self.close = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_REJECT) |
510 | + |
511 | + self.connect("response", self.__on_close) |
512 | + |
513 | + self.show_all() |
514 | + |
515 | + |
516 | + def __on_fs_selected(self, widget): |
517 | + if self.fs_align: |
518 | + self.vbox.remove(self.fs_align) |
519 | + self.fs_align.destroy() |
520 | + |
521 | + selected_fs = self.format_info.get_selected_fs().upper() |
522 | + self.fs_align = None |
523 | + if selected_fs in ("FAT16", "FAT32"): |
524 | + self.fs_align = widgets.FormatingVFatInfo() |
525 | + elif selected_fs == "NTFS": |
526 | + self.fs_align = widgets.FormatingNTFSInfo() |
527 | + elif selected_fs == "EXT2": |
528 | + pass |
529 | + elif selected_fs == "EXT3": |
530 | + pass |
531 | + elif selected_fs == "EXT4": |
532 | + pass |
533 | + |
534 | + self.vbox.pack_start(self.fs_align) |
535 | + self.show_all() |
536 | + |
537 | + def __on_close(self, dialog, response_id): |
538 | + print 'closing' |
539 | + self.new_label = self.format_info.get_new_label() |
540 | + self.fs_type = self.format_info.get_selected_fs().upper() |
541 | + self.fs_options = self.fs_align.get_options() |
542 | + |
543 | + |
544 | +class ProgressBarPulseThread(Thread): |
545 | + def __init__(self, bar): |
546 | + Thread.__init__(self) |
547 | + self.bar = bar |
548 | + |
549 | + def run(self): |
550 | + while self.bar.pulse(): |
551 | + time.sleep(0.2) |
552 | + |
553 | +class ProgressBar: |
554 | + ''' |
555 | + Simple class to create a progress bar to show progress |
556 | + ''' |
557 | + def __init__(self, master, device): |
558 | + '''Initialize the class''' |
559 | + self.progress_bar = None |
560 | + self.window = None |
561 | + self.master = master |
562 | + self.device = device |
563 | + self.keep_pulsing = False |
564 | + self.thread = ProgressBarPulseThread(self) |
565 | + |
566 | + def draw(self): |
567 | + '''Draw the widgets''' |
568 | + # Simple window |
569 | + self.window = gtk.Window(gtk.WINDOW_POPUP) |
570 | + self.window.set_resizable(False) |
571 | + self.window.set_border_width(10) |
572 | + self.window.set_position(gtk.WIN_POS_CENTER) |
573 | + self.window.set_transient_for(self.master.main_window) |
574 | + self.window.set_destroy_with_parent(True) |
575 | + |
576 | + # Create a VBox |
577 | + vbox = gtk.VBox(False, 5) |
578 | + vbox.set_border_width(10) |
579 | + self.window.add(vbox) |
580 | + |
581 | + # Create the desired progress bar |
582 | + self.progress_bar = gtk.ProgressBar() |
583 | + self.progress_bar.set_size_request(500, -1) |
584 | + self.progress_bar.pulse() |
585 | + vbox.pack_start(self.progress_bar, False, False, 0) |
586 | + |
587 | + # An expander to hold the textview |
588 | + expander = gtk.Expander("<b>"+_("Details")+"</b>") |
589 | + expander.set_use_markup(True) |
590 | + expander.set_expanded(True) |
591 | + # Text buffer |
592 | + self.text_buffer = gtk.TextBuffer() |
593 | + # The text view |
594 | + self.text_view = gtk.TextView(self.text_buffer); |
595 | + self.text_view.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("black")) |
596 | + self.text_view.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse("white")) |
597 | + self.text_view.set_editable(False) |
598 | + self.text_view.set_wrap_mode(gtk.WRAP_CHAR) |
599 | + self.text_view.set_justification(gtk.JUSTIFY_LEFT) |
600 | + self.text_view.set_left_margin(10) |
601 | + self.text_view.set_right_margin(10) |
602 | + self.text_view.set_size_request(-1, 150) |
603 | + # A scroller to the text view |
604 | + sw = gtk.ScrolledWindow() |
605 | + sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
606 | + sw.add(self.text_view) |
607 | + expander.add(sw) |
608 | + vbox.pack_start(expander) |
609 | + |
610 | + # close button |
611 | + self.close_button = gtk.Button(stock=gtk.STOCK_CLOSE) |
612 | + self.close_button.set_sensitive(False) |
613 | + self.close_button.connect("clicked", self.__on_close_click) |
614 | + # HButtonBox |
615 | + btn_box = gtk.HButtonBox() |
616 | + btn_box.set_layout(gtk.BUTTONBOX_END) |
617 | + btn_box.pack_start(self.close_button) |
618 | + vbox.pack_start(btn_box) |
619 | + |
620 | + # Show all widgets |
621 | + self.window.show_all() |
622 | + |
623 | + def addTimer(self): |
624 | + self.timer = gobject.timeout_add(5, self.draw_progress, self.progress_bar) |
625 | + |
626 | + def write_text(self, text): |
627 | + '''Write the text to the label''' |
628 | + self.text_buffer.insert(self.text_buffer.get_end_iter(), text) |
629 | + self.text_view.scroll_mark_onscreen(self.text_buffer.get_insert()) |
630 | + #self.pulse() |
631 | + while gtk.events_pending(): |
632 | + gtk.main_iteration(False) |
633 | + |
634 | + def draw_end_progress(self, text, widget=None): |
635 | + '''Update the progress from the progressbar''' |
636 | + self.progress_bar.set_fraction(1) |
637 | + self.progress_bar.set_text(text) |
638 | + |
639 | + def enable_close(self, erro=None): |
640 | + self.keep_pulsing = False |
641 | + self.thread.join() |
642 | + if erro is None: |
643 | + self.draw_end_progress(_("Formating done")) |
644 | + self.write_text("\n\n"+_("Done")+"\n") |
645 | + print ' * Formationg done!' |
646 | + else: |
647 | + self.draw_end_progress(_("Error while formating")) |
648 | + self.write_text("\n\n*** "+_("Errors:")+"\n") |
649 | + self.write_text(erro) |
650 | + print ' * Error while formating!' |
651 | + print erro |
652 | + |
653 | + self.close_button.set_sensitive(True) |
654 | + |
655 | + def __on_close_click(self, widget=None): |
656 | + '''Close the progress bar''' |
657 | + print "Closing..." |
658 | + self.window.destroy() |
659 | + self.master.destroy_format_progress_bar(self.device) |
660 | + |
661 | + def pulse(self, widget=None): |
662 | + self.progress_bar.pulse() |
663 | + while gtk.events_pending(): |
664 | + gtk.main_iteration(False) |
665 | + |
666 | + return self.keep_pulsing |
667 | + |
668 | + def start_pulsing_thread(self): |
669 | + self.keep_pulsing = True |
670 | + self.thread.start() |
671 | |
672 | === modified file 'src/main.py' |
673 | --- src/main.py 2009-08-01 04:08:08 +0000 |
674 | +++ src/main.py 2009-08-07 13:09:33 +0000 |
675 | @@ -33,6 +33,8 @@ |
676 | RESPONSE_ACCEPT = -3 |
677 | RESPONSE_CANCEL = -2 |
678 | |
679 | +SUPPORTED_FS = ["FAT16", "FAT32", "NTFS"] |
680 | + |
681 | class Main: |
682 | ''' |
683 | Main is the main class from the USBManager. |
684 | @@ -59,6 +61,7 @@ |
685 | # Windows 'controllers' |
686 | self.main_window = None |
687 | self.properties_window = None |
688 | + self.formating_window = None |
689 | self.tray = None |
690 | self.mode = None |
691 | if mode is 2: |
692 | @@ -122,6 +125,8 @@ |
693 | self.properties_window.destroy() |
694 | |
695 | def mount_device(self, device): |
696 | + if device.is_mounted: |
697 | + return |
698 | if device.blocked: |
699 | gui.messages.BlockedDevice() |
700 | return |
701 | @@ -130,6 +135,8 @@ |
702 | gui.messages.MountingError(device, msg) |
703 | |
704 | def umount_device(self, device): |
705 | + if not device.is_mounted: |
706 | + return |
707 | if device.blocked: |
708 | gui.messages.BlockedDevice() |
709 | return |
710 | @@ -142,6 +149,7 @@ |
711 | if device.is_mounted: |
712 | gui.messages.UmountingDevice(device) |
713 | self.umount_device(device) |
714 | + |
715 | gui.messages.BlockingDevice() |
716 | ret, error = device.set_label(new_label) |
717 | if not ret: |
718 | @@ -175,6 +183,38 @@ |
719 | self.properties_window.restore_orig_label() |
720 | self.properties_window.destroy() |
721 | |
722 | + def create_formating_window(self, device): |
723 | + if device.blocked: |
724 | + gui.messages.BlockedDevice() |
725 | + return |
726 | + |
727 | + self.formating_window = gui.windows.FormatWindow(device, self, self.devices.get_supported_fs()) |
728 | + ret = self.formating_window.run() |
729 | + |
730 | + if ret is RESPONSE_ACCEPT: |
731 | + new_label = self.formating_window.new_label |
732 | + new_fs = self.formating_window.fs_type |
733 | + fs_options = self.formating_window.fs_options |
734 | + self.formating_window.destroy() |
735 | + # TODO: Check if device is mounted |
736 | + if device.is_mounted: |
737 | + gui.messages.UmountingDevice(device) |
738 | + self.umount_device(device) |
739 | + |
740 | + bar = gui.windows.ProgressBar(self, device) |
741 | + bar.draw() |
742 | + bar.start_pulsing_thread() |
743 | + bar.write_text("Formating "+device.block_device+" to: "+new_fs+"\n") |
744 | + err = device.format(new_label, new_fs, fs_options, bar.write_text) |
745 | + if len(err) is 0: |
746 | + err = None |
747 | + else: |
748 | + err = '\n'.join(err) |
749 | + bar.enable_close(err) |
750 | + return |
751 | + |
752 | + self.formating_window.destroy() |
753 | + |
754 | def destroy_main_window(self): |
755 | if self.main_window: |
756 | self.main_window.hide() |
757 | @@ -185,3 +225,7 @@ |
758 | print 'Quiting...' |
759 | else: |
760 | self.main_window = None |
761 | + |
762 | + def destroy_format_progress_bar(self, device): |
763 | + gui.messages.BlockedDevice() |
764 | + device.blocked = True |
765 | |
766 | === modified file 'src/shexec.py' |
767 | --- src/shexec.py 2009-07-31 03:31:01 +0000 |
768 | +++ src/shexec.py 2009-08-06 14:07:48 +0000 |
769 | @@ -25,8 +25,29 @@ |
770 | __version__ = "1.0" |
771 | __author__ = "Magnun Leno da Silva <magnun.leno@gmail.com>" |
772 | |
773 | + |
774 | +import os |
775 | import subprocess as sp |
776 | -import os |
777 | +FORMATING_DIC = {"mkfs.vfat":"VFAT", |
778 | + "mkfs.ntfs":"NTFS", |
779 | + #"mkfs.ext2":"EXT2", |
780 | + #"mkfs.ext3":"EXT3", |
781 | + #"mkfs.ext4":"EXT4", |
782 | + } |
783 | + |
784 | +SUPPORTED_FS = {} |
785 | +ret = sp.Popen(shell = False, stdin = sp.PIPE, stdout = sp.PIPE, |
786 | + stderr = sp.PIPE, args = ["whereis", "mkfs"]) |
787 | +ret = ret.communicate()[0].split(' ')[2:] |
788 | +for fs in ret: |
789 | + if '/usr/share/man' not in fs: |
790 | + fs = fs.split('/')[-1] |
791 | + if FORMATING_DIC.has_key(fs): |
792 | + if FORMATING_DIC[fs] == "VFAT": |
793 | + SUPPORTED_FS["FAT32"] = fs |
794 | + SUPPORTED_FS["FAT16"] = fs |
795 | + else: |
796 | + SUPPORTED_FS[FORMATING_DIC[fs]] = fs |
797 | |
798 | def whereis_command(command): |
799 | ret = sp.Popen(shell = False, stdin = sp.PIPE, stdout = sp.PIPE, |
800 | @@ -46,4 +67,85 @@ |
801 | |
802 | return ret.communicate() |
803 | |
804 | -# TODO: Add functions to format volumes (FAT16, FAT32, NTFS, EXT2, EXT3 and EXT4) |
805 | +def format(new_fs, new_label, block_device, fs_options, out_func): |
806 | + command = 'gksudo "'+SUPPORTED_FS[new_fs]+' '+block_device +' ' |
807 | + if new_fs == "FAT16": |
808 | + decode_func = fat16_decode |
809 | + if new_fs == "FAT32": |
810 | + decode_func = fat32_decode |
811 | + if new_fs == "NTFS": |
812 | + decode_func = ntfs_decode |
813 | + if new_fs == "EXT2": |
814 | + decode_func = ext2_decode |
815 | + if new_fs == "EXT3": |
816 | + decode_func = ext3_decode |
817 | + if new_fs == "EXT4": |
818 | + decode_func = ext4_decode |
819 | + |
820 | + command += decode_func(new_label, fs_options) |
821 | + |
822 | + out_func("# "+command+"\n\n") |
823 | + print ' * Formating:',command |
824 | + proc = sp.Popen([command], shell=True, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) |
825 | + while True: |
826 | + out = proc.stdout.read(1) |
827 | + out_func(out) |
828 | + if len(out) == 0 and proc.poll() == 0: |
829 | + break |
830 | + return proc.stderr.readlines() |
831 | + |
832 | + |
833 | +def fat16_decode(new_label, fs_options): |
834 | + command = '-F 16 -v ' |
835 | + bad_blocks = fs_options[0] |
836 | + |
837 | + if bad_blocks is True: |
838 | + command += '-c ' |
839 | + |
840 | + if new_label != "": |
841 | + if len(new_label) > 11: |
842 | + new_label = new_label[:11] |
843 | + command += '-n '+new_label |
844 | + command += '"' |
845 | + return command |
846 | + |
847 | +def fat32_decode(new_label, fs_options): |
848 | + command = '-F 32 -v ' |
849 | + bad_blocks = fs_options[0] |
850 | + |
851 | + if bad_blocks is True: |
852 | + command += '-c ' |
853 | + |
854 | + if new_label != "": |
855 | + if len(new_label) > 11: |
856 | + new_label = new_label[:11] |
857 | + command += '-n '+new_label |
858 | + command += '"' |
859 | + return command |
860 | + |
861 | +def ntfs_decode(new_label, fs_options): |
862 | + quick_format = fs_options[0] |
863 | + compression = fs_options[1] |
864 | + |
865 | + command = '-v ' |
866 | + |
867 | + if quick_format: |
868 | + command += '-f ' |
869 | + |
870 | + if compression: |
871 | + command += '-C ' |
872 | + |
873 | + if new_label != "": |
874 | + command += '-L '+new_label |
875 | + command += '"' |
876 | + return command |
877 | + |
878 | +def ext2_decode(new_label, dev, fs_options, bar): |
879 | + pass |
880 | + |
881 | +def ext3_decode(new_label, dev, fs_options, bar): |
882 | + pass |
883 | + |
884 | +def ext4_decode(new_label, fs_options, out_func): |
885 | + pass |
886 | +# TODO: Add functions to format volumes (NTFS, EXT2, EXT3 and EXT4) |
887 | |
888 | === modified file 'src/usbdbus.py' |
889 | --- src/usbdbus.py 2009-07-31 13:41:08 +0000 |
890 | +++ src/usbdbus.py 2009-08-07 13:09:33 +0000 |
891 | @@ -30,6 +30,7 @@ |
892 | |
893 | RENAME_COMMANDS = {"vfat":("mlabel", "-i %(block_device)s ::%(new_label)s", "mtools"), |
894 | "ntfs":("ntfslabel", "%(block_device)s %(new_label)s", "ntfsprogs"), |
895 | + "ntfs-3g":("ntfslabel", "%(block_device)s %(new_label)s", "ntfsprogs"), |
896 | "ext2":("e2label", "%(block_device)s %(new_label)s", "e2fsprogs"), |
897 | "ext3":("e2label", "%(block_device)s %(new_label)s", "e2fsprogs"), |
898 | "ext4":("e2label", "%(block_device)s %(new_label)s", "e2fsprogs")} |
899 | @@ -156,6 +157,10 @@ |
900 | print ' * Device', self.label,"("+self.block_device+") is now locked!" |
901 | return (True, None) |
902 | |
903 | + def format(self, new_label, new_fs, fs_options, out_func): |
904 | + format_func = None |
905 | + return shexec.format(new_fs, new_label, self.block_device, fs_options, out_func) |
906 | + |
907 | def on_device_properties_change(self, key, was_added=None, was_removed=None, path=None): |
908 | self.get_info() |
909 | self.devices.master.device_properties_changed(self) |
910 | @@ -303,6 +308,9 @@ |
911 | if self.devices.has_key(udi): |
912 | return self.devices.pop(udi) |
913 | |
914 | + def get_supported_fs(self): |
915 | + return shexec.SUPPORTED_FS.keys() |
916 | + |
917 | def on_device_add(self, volume_udi): |
918 | ''' |
919 | Function connected to the 'DeviceAdded' signal. |
Added and tested formating functions for the following File Systems:
- NTFS;
- FAT16;
- FAT32.