Merge lp:~flimm/usb-creator/warn-before-format into lp:usb-creator

Proposed by David D Lowe on 2010-01-11
Status: Work in progress
Proposed branch: lp:~flimm/usb-creator/warn-before-format
Merge into: lp:usb-creator
Diff against target: 149 lines (+83/-4)
5 files modified
bin/usb-creator-helper (+1/-1)
debian/changelog (+5/-1)
debian/copyright (+5/-0)
usbcreator/backends/devicekit/backend.py (+1/-1)
usbcreator/frontends/gtk/frontend.py (+71/-1)
To merge this branch: bzr merge lp:~flimm/usb-creator/warn-before-format
Reviewer Review Type Date Requested Status
Dimitri John Ledkov 2010-01-11 Needs Information on 2012-06-08
Review via email: mp+17177@code.launchpad.net
To post a comment you must log in.
259. By David D Lowe on 2010-01-13

Merged with trunk.

260. By David D Lowe on 2010-01-13

Display partition name instead of drive name if only one partition is going to be deleted.

Dimitri John Ledkov (xnox) wrote :

Now we do have a warning dialog box "Are you sure you want to erase this drive?" (at least in gtk).
Also we erase individual partitions now.
Is this still necessary? I see that you make more informative dialog boxes.

review: Needs Information
David D Lowe (flimm) wrote :

Seeing as USB Creator only erases individual partitions now, this fix is no longer necessary.

Any ideas what I could have done different to get this patch reviewed sooner? If it's just a matter of usb-creator developers being busy, I understand.

Dimitri John Ledkov (xnox) wrote :

I am so sorry, the review delay was a failure on our side. In the recent times, the core developer of usb-creator started working on other projects and this one got less attention. I am hoping to do timely reviews of usb-creator merge proposals.

Unmerged revisions

260. By David D Lowe on 2010-01-13

Display partition name instead of drive name if only one partition is going to be deleted.

259. By David D Lowe on 2010-01-13

Merged with trunk.

258. By David D Lowe on 2010-01-11

Warn user before formatting, listing all partitions that are going to be lost if more than one. (Fixes bug #446891

257. By David D Lowe on 2010-01-11

Warn user before formatting drive. (Fixes bug #443330)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/usb-creator-helper'
2--- bin/usb-creator-helper 2009-12-08 08:58:46 +0000
3+++ bin/usb-creator-helper 2010-01-13 18:33:15 +0000
4@@ -100,7 +100,7 @@
5 def Format(self, device, sender=None, conn=None):
6 self.check_polkit(sender, conn, 'com.ubuntu.usbcreator.format')
7 check_system_internal(device)
8- # TODO evand 2009-08-25: Needs a confirmation dialog.
9+ # TODO evand 2009-08-25: Needs a confirmation dialog. (Note: completed for gtk)
10 # XXX test with a device that doesn't have a partition table.
11 bus = dbus.SystemBus()
12 devkit = bus.get_object('org.freedesktop.DeviceKit.Disks',
13
14=== modified file 'debian/changelog'
15--- debian/changelog 2010-01-11 19:28:39 +0000
16+++ debian/changelog 2010-01-13 18:33:15 +0000
17@@ -1,9 +1,13 @@
18 usb-creator (0.2.15) UNRELEASED; urgency=low
19
20+ [Mario Limonciello]
21 * Ensure that the download_dir is really a directory before scanning it for
22 ISOs to include in the list. Fixes launching usb-creator-gtk as root.
23
24- -- Mario Limonciello <mario_limonciello@dell.com> Mon, 11 Jan 2010 13:27:36 -0600
25+ [ David D Lowe ]
26+ * Warn users before formatting entire drive. (LP: #443330)
27+
28+ -- David D Lowe <daviddlowe.flimm@gmail.com> Wed, 13 Jan 2010 18:11:08 +0000
29
30 usb-creator (0.2.14) lucid; urgency=low
31
32
33=== modified file 'debian/copyright'
34--- debian/copyright 2009-08-26 19:26:08 +0000
35+++ debian/copyright 2010-01-13 18:33:15 +0000
36@@ -8,6 +8,11 @@
37
38 Copyright (C) 2008 Canonical Ltd.
39
40+To the extent possible under law, David D Lowe has waived all copyright and
41+related or neighboring rights to his modifications to this work, according to
42+http://creativecommons.org/publicdomain/zero/1.0/
43+You may delete this line and the three before it.
44+
45 KDE/Qt port Details
46 -------------------
47
48
49=== modified file 'usbcreator/backends/devicekit/backend.py'
50--- usbcreator/backends/devicekit/backend.py 2009-10-19 09:53:52 +0000
51+++ usbcreator/backends/devicekit/backend.py 2010-01-13 18:33:15 +0000
52@@ -243,7 +243,7 @@
53 return mp
54
55 def format(self, device):
56- # TODO evand 2009-08-25: Needs a confirmation dialog.
57+ # TODO evand 2009-08-25: Needs a confirmation dialog. (Note: completed for gtk)
58 try:
59 dk = self.bus.get_object('org.freedesktop.DeviceKit.Disks', device)
60 device = dk.Get(device, 'device-file', dbus_interface=PROPS_IFACE)
61
62=== modified file 'usbcreator/frontends/gtk/frontend.py'
63--- usbcreator/frontends/gtk/frontend.py 2010-01-11 19:28:39 +0000
64+++ usbcreator/frontends/gtk/frontend.py 2010-01-13 18:33:15 +0000
65@@ -659,13 +659,83 @@
66 message)
67 dialog.run()
68 dialog.destroy()
69+
70+ def _confirm(self, message, buttons, default=0, secondary_markup=None):
71+ dialog = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL |
72+ gtk.DIALOG_DESTROY_WITH_PARENT,
73+ gtk.MESSAGE_WARNING, gtk.BUTTONS_NONE, message)
74+ for ii in xrange(len(buttons)):
75+ dialog.add_button(buttons[ii], ii)
76+ dialog.set_default_response(default)
77+ if not secondary_markup is None:
78+ dialog.format_secondary_markup(secondary_markup)
79+ response = dialog.run()
80+ if response == gtk.RESPONSE_DELETE_EVENT:
81+ response = -1
82+ dialog.destroy()
83+ return response
84+
85+ @staticmethod
86+ def get_drive(dev):
87+ drive = None
88+ monitor = gio.volume_monitor_get()
89+ for item in monitor.get_connected_drives():
90+ if 'unix-device' in item.enumerate_identifiers():
91+ if item.get_identifier('unix-device') == dev:
92+ drive = item
93+ if drive is None:
94+ for item in monitor.get_volumes():
95+ if 'unix-device' in item.enumerate_identifiers():
96+ if item.get_identifier('unix-device') == dev:
97+ drive = item.get_drive()
98+ return drive
99+
100+ if 'unix-device' in item.enumerate_identifiers():
101+ driveStr = drive.get_identifier('unix-device')
102+ vols = drive.get_volumes()
103+ volsStr = ""
104+ for vol in vols:
105+ if 'unix-device' in item.enumerate_identifiers():
106+ volsStr += vol.get_identifier('unix-device') + "\t"
107+ volsStr += vol.get_name() + "\n"
108
109 def format_dest_clicked(self, *args):
110- # FIXME evand 2009-04-30: This needs a big warning dialog.
111 model, iterator = self.dest_treeview.get_selection().get_selected()
112 if not iterator:
113 return
114 udi = model[iterator][0]
115+
116+ # warn user before continuing
117+ drive = self.get_drive(self.backend.targets[udi]['device'])
118+ details = ''
119+ drive_title = udi
120+ if not drive is None:
121+ if 'unix-device' in drive.enumerate_identifiers():
122+ drive_title = ' (' + drive.get_identifier('unix-device') + ')'
123+ drive_title = '<i>' + drive.get_name() + drive_title + '</i>'
124+ if len(drive.get_volumes()) > 1:
125+ details = '\n\n' + \
126+ _('The following partitions will be deleted:') + '\n<tt>'
127+ for vol in drive.get_volumes():
128+ details += '\t'
129+ if 'unix-device' in vol.enumerate_identifiers():
130+ details += vol.get_identifier('unix-device')
131+ details += '\t' + vol.get_name() + '\n'
132+ details += '</tt>'
133+ elif len(drive.get_volumes()) == 1:
134+ vol = drive.get_volumes()[0]
135+ if 'unix-device' in vol.enumerate_identifiers():
136+ drive_title = '<i>%s (%s)</i>' % (vol.get_name(),
137+ vol.get_identifier('unix-device'))
138+ rv = self._confirm(_('Formatting the drive will erase it in its '
139+ 'entirety.'), (gtk.STOCK_CANCEL,
140+ _('_Format entire drive')), 1,( _('Make a backup '
141+ 'copy of any valuable data on %s before '
142+ 'continuing.') % drive_title)
143+ + details)
144+ if rv != 1:
145+ return
146+
147 self.backend.format(udi)
148
149 def open_dest_folder(self, *args):

Subscribers

People subscribed via source and target branches