Merge lp:~s-linus/blacknbacker/trunk into lp:blacknbacker
- trunk
- Merge into trunk
Proposed by
Linus Seelinger
Status: | Merged |
---|---|
Approved by: | Dominique Lasserre |
Approved revision: | 2 |
Merged at revision: | 2 |
Proposed branch: | lp:~s-linus/blacknbacker/trunk |
Merge into: | lp:blacknbacker |
Diff against target: |
376 lines (+123/-112) 5 files modified
src/backup.vala (+5/-2) src/execute.vala (+1/-2) src/pipes.vala (+108/-98) src/settings.vala (+1/-0) src/widget_execute.vala (+8/-10) |
To merge this branch: | bzr merge lp:~s-linus/blacknbacker/trunk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Linus Seelinger | Approve | ||
Review via email: mp+90432@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Linus Seelinger (s-linus) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/backup.vala' |
2 | --- src/backup.vala 2012-01-19 19:15:25 +0000 |
3 | +++ src/backup.vala 2012-01-27 13:40:37 +0000 |
4 | @@ -50,9 +50,12 @@ |
5 | }); |
6 | |
7 | window.add(nbook); |
8 | - window.set_default_size(250, 300); |
9 | + window.set_default_size(550, 350); |
10 | window.show_all(); |
11 | - nbook.set_current_page(0); |
12 | + if (settings.pipes.size == 0) |
13 | + nbook.set_current_page(1); |
14 | + else |
15 | + nbook.set_current_page(0); |
16 | window.destroy.connect(()=>{ |
17 | //settings.save(); |
18 | Gtk.main_quit(); |
19 | |
20 | === modified file 'src/execute.vala' |
21 | --- src/execute.vala 2012-01-19 19:15:25 +0000 |
22 | +++ src/execute.vala 2012-01-27 13:40:37 +0000 |
23 | @@ -1,5 +1,4 @@ |
24 | |
25 | public static void backup (Settings.pipe pipe, Settings.target target, udevmonitor monitor){ |
26 | - //stdout.printf("Execute: " + "rsync -r --update --progress --delete " + pipe.source + "/ " + target.getFullPath(monitor) + "/"); |
27 | - Process.spawn_command_line_sync("rsync -a --progress " + pipe.source + "/ " + target.getFullPath(monitor)); |
28 | + Process.spawn_command_line_sync("rsync -a --progress --stats " + pipe.source + "/ " + target.getFullPath(monitor)); |
29 | } |
30 | |
31 | === modified file 'src/pipes.vala' |
32 | --- src/pipes.vala 2012-01-19 19:15:25 +0000 |
33 | +++ src/pipes.vala 2012-01-27 13:40:37 +0000 |
34 | @@ -4,7 +4,7 @@ |
35 | public widgetPipes(Settings settings, udevmonitor monitor){ |
36 | this.settings = settings; |
37 | this.monitor = monitor; |
38 | - widget = new Table(1,1,false); |
39 | + widget = new Table(0,0,false); |
40 | build(); |
41 | } |
42 | |
43 | @@ -17,123 +17,132 @@ |
44 | |
45 | public void build(){ |
46 | |
47 | - var tblMain = new Table(0, 2, false); |
48 | + var tblMain = new Table(0, 0, false); |
49 | |
50 | tblMain.attach(new Label("Source"), 0, 1, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 5); |
51 | tblMain.attach(new Label("Target"), 1, 2, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 0); |
52 | tblMain.attach(new HSeparator(), 0, 4, 1, 2, AttachOptions.FILL, AttachOptions.SHRINK, 0, 8); |
53 | |
54 | - int i = 2; |
55 | - foreach (Settings.pipe pipe in settings.pipes){ |
56 | - |
57 | - |
58 | - FileChooserButton btnSource = new FileChooserButton("Backup source", FileChooserAction.SELECT_FOLDER); |
59 | - btnSource.set_filename(pipe.source); |
60 | - /*btnSource.file_set.connect(()=>{ |
61 | - pipe.source = btnSource.get_filename(); |
62 | - });*/ |
63 | - btnSource.current_folder_changed.connect(()=>{ |
64 | - pipe.source = btnSource.get_filename(); |
65 | - }); |
66 | - |
67 | - int t = 0; |
68 | - foreach (Settings.target target in pipe.targets){ |
69 | + if (settings.pipes.size == 0 && monitor.devices.length == 0){ |
70 | + Label lbl = new Label("Attach a backup device to define a backup"); |
71 | + tblMain.attach(lbl, 0, 4, 2, 3, AttachOptions.EXPAND, AttachOptions.EXPAND, 0, 0); |
72 | + lbl.sensitive = false; |
73 | + } |
74 | + else |
75 | + { |
76 | + int i = 2; |
77 | + foreach (Settings.pipe pipe in settings.pipes){ |
78 | + |
79 | + |
80 | + FileChooserButton btnSource = new FileChooserButton("Backup source", FileChooserAction.SELECT_FOLDER); |
81 | + stdout.printf("source " + pipe.source + "\n"); |
82 | + stdout.flush(); |
83 | + btnSource.set_current_folder (pipe.source); |
84 | + stdout.printf(pipe.source + "\n"); |
85 | + stdout.flush(); |
86 | + |
87 | + btnSource.selection_changed.connect(()=>{ |
88 | + pipe.source = btnSource.get_filename(); |
89 | + stdout.printf("Change: " + pipe.source + "\n"); |
90 | + stdout.flush(); |
91 | + }); |
92 | + |
93 | + int t = 0; |
94 | + foreach (Settings.target target in pipe.targets){ |
95 | |
96 | - GUdev.Device dev = monitor.get_dev_by_property("ID_SERIAL", target.serial); |
97 | - string mountpoint = ""; |
98 | - FileChooserButton btnTarget = new FileChooserButton("Backup target", FileChooserAction.SELECT_FOLDER); |
99 | - btnTarget.set_filename("/"); |
100 | - if (dev == null) |
101 | - btnTarget.sensitive = false; |
102 | - else { |
103 | - string[] mps = monitor.get_mount_points(dev); |
104 | - if (mps.length > 0){ |
105 | - mountpoint = mps[0]; |
106 | - btnTarget.set_filename(monitor.get_mount_points(dev)[0] + target.path); |
107 | - }else |
108 | + GUdev.Device dev = monitor.get_dev_by_property("ID_SERIAL", target.serial); |
109 | + string mountpoint = ""; |
110 | + FileChooserButton btnTarget = new FileChooserButton("Backup target", FileChooserAction.SELECT_FOLDER); |
111 | + btnTarget.set_filename("/"); |
112 | + if (dev == null) |
113 | btnTarget.sensitive = false; |
114 | + else { |
115 | + string[] mps = monitor.get_mount_points(dev); |
116 | + if (mps.length > 0){ |
117 | + mountpoint = mps[0]; |
118 | + btnTarget.set_filename(monitor.get_mount_points(dev)[0] + target.path); |
119 | + }else |
120 | + btnTarget.sensitive = false; |
121 | + } |
122 | + |
123 | + btnTarget.file_set.connect(()=>{ |
124 | + string newFilename = btnTarget.get_filename(); |
125 | + if (newFilename.has_prefix(mountpoint)) |
126 | + target.path = newFilename.replace(mountpoint, ""); |
127 | + }); |
128 | + |
129 | + var btnRemoveTarget = new Button.from_stock(Stock.REMOVE); |
130 | + btnRemoveTarget.clicked.connect(()=>{ |
131 | + pipe.targets.remove(target); |
132 | + if (pipe.targets.size == 0) |
133 | + settings.pipes.remove(pipe); |
134 | + build(); |
135 | + }); |
136 | + |
137 | + var lblName = new Label(target.name); |
138 | + |
139 | + tblMain.attach(lblName, 1, 2, i+t, i+t+1, AttachOptions.EXPAND, AttachOptions.SHRINK, xpadding, 0); |
140 | + tblMain.attach(btnTarget, 2, 3, i+t, i+t+1, AttachOptions.EXPAND | AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
141 | + tblMain.attach(btnRemoveTarget, 3, 4, i+t, i+t+1, AttachOptions.SHRINK, AttachOptions.SHRINK, xpadding, 0); |
142 | + t++; |
143 | } |
144 | - |
145 | - btnTarget.file_set.connect(()=>{ |
146 | - //GUdev.Device dev = monitor.get_dev_by_property("ID_SERIAL", target.serial); |
147 | - |
148 | - string newFilename = btnTarget.get_filename(); |
149 | - if (newFilename.has_prefix(mountpoint)) |
150 | - target.path = newFilename.replace(mountpoint, ""); |
151 | - }); |
152 | - |
153 | - var btnRemoveTarget = new Button.from_stock(Stock.REMOVE); |
154 | - btnRemoveTarget.clicked.connect(()=>{ |
155 | - pipe.targets.remove(target); |
156 | - if (pipe.targets.size == 0) |
157 | - settings.pipes.remove(pipe); |
158 | - build(); |
159 | - }); |
160 | - |
161 | - var lblName = new Label(target.name); |
162 | - |
163 | - //tblTargets.attach(lblName, 0, 1, t, t+1, AttachOptions.SHRINK, AttachOptions.SHRINK, 0, 0); |
164 | - //tblTargets.attach(btnTarget, 1, 2, t, t+1, AttachOptions.FILL, AttachOptions.SHRINK, 0, 0); |
165 | - //tblTargets.attach(btnRemoveTarget, 2, 3, t, t+1, AttachOptions.SHRINK, AttachOptions.SHRINK, 0, 0); |
166 | - tblMain.attach(lblName, 1, 2, i+t, i+t+1, AttachOptions.EXPAND, AttachOptions.SHRINK, xpadding, 0); |
167 | - tblMain.attach(btnTarget, 2, 3, i+t, i+t+1, AttachOptions.EXPAND | AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
168 | - tblMain.attach(btnRemoveTarget, 3, 4, i+t, i+t+1, AttachOptions.SHRINK, AttachOptions.SHRINK, xpadding, 0); |
169 | - t++; |
170 | + |
171 | + tblMain.attach(btnSource, 0, 1, i, i+t+1, AttachOptions.EXPAND | AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
172 | + i+=t; |
173 | + |
174 | + |
175 | + Button btnAddTarget = new Button(); |
176 | + btnAddTarget.label = "Add Target"; |
177 | + btnAddTarget.set_image(new Image.from_stock(Stock.ADD, IconSize.BUTTON)); |
178 | + |
179 | + monitor.change.connect(()=>{ |
180 | + if (monitor.devices.length > 0) |
181 | + btnAddTarget.sensitive = true; |
182 | + else |
183 | + btnAddTarget.sensitive = false; |
184 | + }); |
185 | + if (monitor.devices.length > 0) |
186 | + btnAddTarget.sensitive = true; |
187 | + else |
188 | + btnAddTarget.sensitive = false; |
189 | + btnAddTarget.clicked.connect(()=>{ |
190 | + GUdev.Device? dev = backup_device_selector(); |
191 | + if (dev != null){ |
192 | + add_new_target_to_pipe(dev, pipe); |
193 | + build(); |
194 | + } |
195 | + }); |
196 | + //tblTargets.attach(btnAddTarget, 0, 1, t, t+1, AttachOptions.FILL, AttachOptions.SHRINK, 0, 0); |
197 | + //i++; |
198 | + tblMain.attach(btnAddTarget, 1, 2, i, i+1, AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
199 | + i++; |
200 | + tblMain.attach(new HSeparator(), 0, 4, i, i+1, AttachOptions.FILL, AttachOptions.SHRINK, 0, 8); |
201 | + |
202 | + //tblMain.attach(tblTargets, 1, 2, i, i+1, AttachOptions.FILL, AttachOptions.FILL, 0, 0); |
203 | + i++; |
204 | } |
205 | - |
206 | - tblMain.attach(btnSource, 0, 1, i, i+t+1, AttachOptions.EXPAND | AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
207 | - i+=t; |
208 | - Button btnAddTarget = new Button.from_stock(Stock.ADD); |
209 | + |
210 | + |
211 | + var btnAddPipe = new Button.from_stock(Stock.ADD); |
212 | monitor.change.connect(()=>{ |
213 | if (monitor.devices.length > 0) |
214 | - btnAddTarget.sensitive = true; |
215 | + btnAddPipe.sensitive = true; |
216 | else |
217 | - btnAddTarget.sensitive = false; |
218 | - }); |
219 | - if (monitor.devices.length > 0) |
220 | - btnAddTarget.sensitive = true; |
221 | - else |
222 | - btnAddTarget.sensitive = false; |
223 | - btnAddTarget.clicked.connect(()=>{ |
224 | - GUdev.Device? dev = backup_device_selector(); |
225 | - if (dev != null){ |
226 | - add_new_target_to_pipe(dev, pipe); |
227 | - build(); |
228 | - } |
229 | - }); |
230 | - //tblTargets.attach(btnAddTarget, 0, 1, t, t+1, AttachOptions.FILL, AttachOptions.SHRINK, 0, 0); |
231 | - //i++; |
232 | - tblMain.attach(btnAddTarget, 1, 2, i, i+1, AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
233 | - i++; |
234 | - tblMain.attach(new HSeparator(), 0, 4, i, i+1, AttachOptions.FILL, AttachOptions.SHRINK, 0, 8); |
235 | - |
236 | - //tblMain.attach(tblTargets, 1, 2, i, i+1, AttachOptions.FILL, AttachOptions.FILL, 0, 0); |
237 | - i++; |
238 | - } |
239 | - |
240 | - |
241 | - var btnAddPipe = new Button.from_stock(Stock.ADD); |
242 | - monitor.change.connect(()=>{ |
243 | + btnAddPipe.sensitive = false; |
244 | + }); |
245 | + tblMain.attach(btnAddPipe, 0, 1, i, i+1, AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
246 | if (monitor.devices.length > 0) |
247 | btnAddPipe.sensitive = true; |
248 | else |
249 | btnAddPipe.sensitive = false; |
250 | - }); |
251 | - if (monitor.devices.length > 0) |
252 | - btnAddPipe.sensitive = true; |
253 | - else |
254 | - btnAddPipe.sensitive = false; |
255 | - btnAddPipe.clicked.connect(on_btnAdd_clicked); |
256 | - |
257 | - tblMain.attach(btnAddPipe, 0, 1, i, i+1, AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
258 | + btnAddPipe.clicked.connect(on_btnAdd_clicked); |
259 | + } |
260 | |
261 | if (inner_widget != null) |
262 | inner_widget.destroy(); |
263 | |
264 | inner_widget = tblMain; |
265 | - tblMain.expand = true; |
266 | - widget.expand = true; |
267 | - widget.attach(tblMain, 0, 1, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 0); |
268 | + widget.attach(tblMain, 0, 1, 0, 1, AttachOptions.EXPAND | AttachOptions.FILL, AttachOptions.EXPAND | AttachOptions.FILL, 0, 0); |
269 | widget.show_all(); |
270 | } |
271 | |
272 | @@ -141,7 +150,7 @@ |
273 | string[] mountpoints = monitor.get_mount_points(dev); |
274 | |
275 | var newTarget = new Settings.target(); |
276 | - newTarget.path = mountpoints[0]; |
277 | + newTarget.path = "/"; |
278 | newTarget.serial = dev.get_property("ID_SERIAL"); |
279 | newTarget.name = monitor.getDescription(dev); |
280 | |
281 | @@ -187,6 +196,7 @@ |
282 | if (dev == null) |
283 | return; |
284 | Settings.pipe pipe = new Settings.pipe(); |
285 | + pipe.source = Environment.get_home_dir(); |
286 | settings.pipes.add(pipe); |
287 | add_new_target_to_pipe(dev, pipe); |
288 | build(); |
289 | |
290 | === modified file 'src/settings.vala' |
291 | --- src/settings.vala 2012-01-19 19:15:25 +0000 |
292 | +++ src/settings.vala 2012-01-27 13:40:37 +0000 |
293 | @@ -38,6 +38,7 @@ |
294 | |
295 | var ost = new DataOutputStream(file.create(FileCreateFlags.NONE)); |
296 | foreach (pipe p in pipes){ |
297 | + stdout.printf(@"Save target $(p.source)\n"); |
298 | ost.put_string(p.source + "\n"); |
299 | foreach (target t in p.targets){ |
300 | ost.put_string(t.path + "\n"); |
301 | |
302 | === modified file 'src/widget_execute.vala' |
303 | --- src/widget_execute.vala 2012-01-19 19:15:25 +0000 |
304 | +++ src/widget_execute.vala 2012-01-27 13:40:37 +0000 |
305 | @@ -25,9 +25,15 @@ |
306 | if (!(target.serial in target_serials)) |
307 | target_serials += target.serial; |
308 | |
309 | - int i = 0; |
310 | + int i = 1; |
311 | + tblMain.attach(new Label("Source"), 0, 1, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 5); |
312 | + tblMain.attach(new Label("Target"), 1, 2, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 0); |
313 | + |
314 | bool anyDevice = false; |
315 | foreach (string serial in target_serials){ |
316 | + |
317 | + tblMain.attach(new HSeparator(), 0, 4, i, i+1, AttachOptions.FILL | AttachOptions.EXPAND, AttachOptions.SHRINK, 0, 8); |
318 | + i++; |
319 | |
320 | GUdev.Device dev = monitor.get_dev_by_property("ID_SERIAL", serial); |
321 | if (dev == null) |
322 | @@ -47,8 +53,6 @@ |
323 | |
324 | } |
325 | var lblDevice= new Label(devname); |
326 | - |
327 | - //Table tblTargets = new Table(0, 0, false); |
328 | |
329 | int t = 0; |
330 | foreach (Settings.pipe pipe in settings.pipes) |
331 | @@ -57,24 +61,20 @@ |
332 | continue; |
333 | |
334 | var lblSource = new Label(pipe.source); |
335 | - //tblTargets.attach(lblSource, 0, 1, t, t+1, AttachOptions.SHRINK, AttachOptions.SHRINK, 0, 0); |
336 | tblMain.attach(lblSource, 1, 2, i+t, i+t+1, AttachOptions.SHRINK, AttachOptions.SHRINK, xpadding, 0); |
337 | |
338 | var lblTarget = new Label(target.path); |
339 | - //tblTargets.attach(lblTarget, 1, 2, t, t+1, AttachOptions.SHRINK, AttachOptions.SHRINK, 0, 0); |
340 | tblMain.attach(lblTarget, 2, 3, i+t, i+t+1, AttachOptions.SHRINK, AttachOptions.SHRINK, xpadding, 0); |
341 | |
342 | var button_exec = new Button.from_stock(Stock.EXECUTE); |
343 | button_exec.clicked.connect(()=>{ |
344 | backup(pipe, target, monitor); |
345 | }); |
346 | - //tblTargets.attach(button_exec, 2, 3, t, t+1, AttachOptions.FILL, AttachOptions.SHRINK, 0, 0); |
347 | tblMain.attach(button_exec, 3, 4, i+t, i+t+1, AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
348 | t++; |
349 | } |
350 | tblMain.attach(lblDevice, 0, 1, i, i+t+1, AttachOptions.FILL, AttachOptions.SHRINK, xpadding, 0); |
351 | i+=t; |
352 | - //tblMain.attach(tblTargets, 1, 2, i, i+1, AttachOptions.FILL, AttachOptions.FILL, 0, 0); |
353 | |
354 | i++; |
355 | } |
356 | @@ -85,19 +85,17 @@ |
357 | |
358 | if (target_serials.length == 0){ |
359 | var labelNoBackups = new Label("No backups defined"); |
360 | - labelNoBackups.expand = true; |
361 | labelNoBackups.sensitive = false; |
362 | inner_widget = labelNoBackups; |
363 | } else if (!anyDevice){ |
364 | var labelNoDevices = new Label("No devices with defined backups are attached"); |
365 | - labelNoDevices.expand = true; |
366 | labelNoDevices.sensitive = false; |
367 | inner_widget = labelNoDevices; |
368 | }else |
369 | inner_widget = tblMain; |
370 | |
371 | inner_widget.show_all(); |
372 | - widget.attach(inner_widget, 0, 1, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 0); |
373 | + widget.attach(inner_widget, 0, 1, 0, 1, AttachOptions.EXPAND | AttachOptions.FILL, AttachOptions.EXPAND | AttachOptions.FILL, 0, 0); |
374 | } |
375 | |
376 | } |