backup_paradise 1.2.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of backup_paradise might be problematic. Click here for more details.

Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +375 -0
  3. data/backup_paradise.gemspec +50 -0
  4. data/bin/backup_for_ingrid +10 -0
  5. data/bin/backup_paradise +7 -0
  6. data/bin/windows_backup_paradise +9 -0
  7. data/doc/README.gen +347 -0
  8. data/doc/TODO.md +130 -0
  9. data/lib/backup_paradise/actions/README.md +2 -0
  10. data/lib/backup_paradise/actions/backup.rb +62 -0
  11. data/lib/backup_paradise/base/base.rb +493 -0
  12. data/lib/backup_paradise/base/colours.rb +137 -0
  13. data/lib/backup_paradise/base/namespace.rb +16 -0
  14. data/lib/backup_paradise/base/tab.rb +47 -0
  15. data/lib/backup_paradise/colours/colours.rb +88 -0
  16. data/lib/backup_paradise/constants/constants.rb +162 -0
  17. data/lib/backup_paradise/gui/glimmer/libui/backup_for_ingrid/backup_for_ingrid.rb +87 -0
  18. data/lib/backup_paradise/gui/gtk2/OLD_backup.rb +222 -0
  19. data/lib/backup_paradise/gui/gtk3/simple_backup_widget/create.rb +64 -0
  20. data/lib/backup_paradise/gui/gtk3/simple_backup_widget/misc.rb +34 -0
  21. data/lib/backup_paradise/gui/gtk3/simple_backup_widget/simple_backup_widget.rb +167 -0
  22. data/lib/backup_paradise/gui/libui/backup_for_ingrid/backup_for_ingrid.rb +99 -0
  23. data/lib/backup_paradise/gui/libui/simple_backup_widget/simple_backup_widget.rb +119 -0
  24. data/lib/backup_paradise/gui/shared_code/simple_backup_widget/simple_backup_widget_module.rb +595 -0
  25. data/lib/backup_paradise/gui/tk/backup.rb +108 -0
  26. data/lib/backup_paradise/images/BACKUP_IMAGE.png +0 -0
  27. data/lib/backup_paradise/images/right_arrow.png +0 -0
  28. data/lib/backup_paradise/project/project.rb +40 -0
  29. data/lib/backup_paradise/requires/require_the_backup_paradise_project.rb +18 -0
  30. data/lib/backup_paradise/requires/require_yaml.rb +7 -0
  31. data/lib/backup_paradise/tab/tab.rb +87 -0
  32. data/lib/backup_paradise/toplevel_methods/cliner.rb +16 -0
  33. data/lib/backup_paradise/toplevel_methods/config.rb +77 -0
  34. data/lib/backup_paradise/toplevel_methods/create_and_remove.rb +63 -0
  35. data/lib/backup_paradise/toplevel_methods/e.rb +16 -0
  36. data/lib/backup_paradise/toplevel_methods/esystem.rb +19 -0
  37. data/lib/backup_paradise/toplevel_methods/files_and_directories.rb +181 -0
  38. data/lib/backup_paradise/toplevel_methods/help.rb +93 -0
  39. data/lib/backup_paradise/toplevel_methods/misc.rb +153 -0
  40. data/lib/backup_paradise/toplevel_methods/mountpoint.rb +185 -0
  41. data/lib/backup_paradise/toplevel_methods/opnn.rb +25 -0
  42. data/lib/backup_paradise/utility_scripts/backup/backup.rb +1389 -0
  43. data/lib/backup_paradise/utility_scripts/backup/constants.rb +34 -0
  44. data/lib/backup_paradise/utility_scripts/backup/initialize.rb +71 -0
  45. data/lib/backup_paradise/utility_scripts/backup/menu.rb +360 -0
  46. data/lib/backup_paradise/utility_scripts/backup/run.rb +20 -0
  47. data/lib/backup_paradise/version/version.rb +19 -0
  48. data/lib/backup_paradise/windows/README.md +1 -0
  49. data/lib/backup_paradise/windows/windows.rb +101 -0
  50. data/lib/backup_paradise/www/backup.cgi +63 -0
  51. data/lib/backup_paradise/yaml/config.yml +78 -0
  52. data/lib/backup_paradise.rb +5 -0
  53. data/test/testing_toplevel_functionality.rb +11 -0
  54. metadata +198 -0
@@ -0,0 +1,595 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === BackupParadise::GUI::SimpleBackupWidgetModule
6
+ # =========================================================================== #
7
+ # require 'backup_paradise/gui/shared_code/simple_backup_widget/simple_backup_widget_module.rb'
8
+ # include BackupParadise::GUI::SimpleBackupWidgetModule
9
+ # =========================================================================== #
10
+ module BackupParadise
11
+
12
+ module GUI
13
+
14
+ module SimpleBackupWidgetModule # === BackupParadise::GUI::SimpleBackupWidgetModule
15
+
16
+ # ========================================================================= #
17
+ # Add backup-paradise related .rb files next:
18
+ # ========================================================================= #
19
+ require 'backup_paradise/project/project.rb'
20
+ require 'backup_paradise/utility_scripts/backup/backup.rb'
21
+ require 'backup_paradise/actions/backup.rb'
22
+ require 'backup_paradise/windows/windows.rb'
23
+
24
+ begin
25
+ require 'open'
26
+ rescue LoadError; end
27
+
28
+ begin
29
+ require 'mountpoints'
30
+ rescue LoadError; end
31
+
32
+ # ========================================================================= #
33
+ # === TITLE
34
+ # ========================================================================= #
35
+ TITLE = 'Simple Backup Widget'
36
+
37
+ # ========================================================================= #
38
+ # === WIDTH
39
+ # ========================================================================= #
40
+ WIDTH = '50%'
41
+
42
+ # ========================================================================= #
43
+ # === HEIGHT
44
+ # ========================================================================= #
45
+ HEIGHT = '40%'
46
+
47
+ # ========================================================================= #
48
+ # === USE_THIS_FONT
49
+ # ========================================================================= #
50
+ USE_THIS_FONT = :dejavu_condensed_19
51
+
52
+ # ========================================================================= #
53
+ # === LARGER_FONT
54
+ # ========================================================================= #
55
+ LARGER_FONT = :dejavu_condensed_21
56
+
57
+ # ========================================================================= #
58
+ # === reset_shared_module
59
+ # ========================================================================= #
60
+ def reset_shared_module
61
+ # ======================================================================= #
62
+ # === @title
63
+ # ======================================================================= #
64
+ set_title(TITLE)
65
+ # ======================================================================= #
66
+ # === @width
67
+ # ======================================================================= #
68
+ set_width(WIDTH)
69
+ # ======================================================================= #
70
+ # === @height
71
+ # ======================================================================= #
72
+ set_height(HEIGHT)
73
+ # ======================================================================= #
74
+ # === @file_chooser_dialog
75
+ # ======================================================================= #
76
+ @file_chooser_dialog = nil
77
+ # ======================================================================= #
78
+ # === @dataset_from_the_config_file
79
+ # ======================================================================= #
80
+ @dataset_from_the_config_file = nil
81
+ if File.exist? BackupParadise.file_config?
82
+ @dataset_from_the_config_file = YAML.load_file(BackupParadise.file_config?)
83
+ end
84
+ end
85
+
86
+ # ========================================================================= #
87
+ # === padding?
88
+ # ========================================================================= #
89
+ def padding?
90
+ 1
91
+ end
92
+
93
+ # ========================================================================= #
94
+ # === border_size?
95
+ # ========================================================================= #
96
+ def border_size?
97
+ 0
98
+ end
99
+
100
+ # ========================================================================= #
101
+ # === return_backup_complete_message
102
+ # ========================================================================= #
103
+ def return_backup_complete_message
104
+ 'Backup complete! Time finish at: '+time_now?
105
+ end
106
+
107
+ # ========================================================================= #
108
+ # === copy_this_file
109
+ # ========================================================================= #
110
+ def copy_this_file(from, b)
111
+ ::BackupParadise.copy_this_file(from, b)
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === larger_font?
116
+ # ========================================================================= #
117
+ def larger_font?
118
+ LARGER_FONT
119
+ end
120
+
121
+ # ========================================================================= #
122
+ # === do_transfer_a_single_file
123
+ # ========================================================================= #
124
+ def do_transfer_a_single_file(
125
+ _ = entry_left?.text?.strip,
126
+ target = onto?
127
+ )
128
+ target = target.dup if target.frozen?
129
+ target << File.basename(_)
130
+
131
+ if _.empty?
132
+ e 'Please supply a file to transfer.'
133
+ else
134
+ e "Now trying to copy #{_} to #{target}."
135
+ Thread.new {
136
+ copy_this_file(_, target)
137
+ pop_up_this_text_over_that_widget(return_backup_complete_message, @button_backup)
138
+ }
139
+ end
140
+ end
141
+
142
+ # ========================================================================= #
143
+ # === main_target?
144
+ #
145
+ # This method will "return" our main target.
146
+ # ========================================================================= #
147
+ def main_target?
148
+ @backup_to_this_target.text?
149
+ end
150
+
151
+ # ========================================================================= #
152
+ # === do_backup_my_songs
153
+ # ========================================================================= #
154
+ def do_backup_my_songs(
155
+ to =
156
+ ("#{onto?}#{File.basename(entry_left?.text?)}/").squeeze('/')
157
+ )
158
+ to.squeeze!('/')
159
+ Thread.new {
160
+ BackupParadise.simple_backup(
161
+ entry_left?.text?, to
162
+ )
163
+ pop_up_this_text_over_that_widget(
164
+ return_backup_complete_message,
165
+ @button_backup_audio
166
+ )
167
+ }
168
+ end
169
+
170
+ # ========================================================================= #
171
+ # === time_now?
172
+ # ========================================================================= #
173
+ def time_now?
174
+ return ::Time.now.strftime('%d.%m.%Y, %H:%M:%S')
175
+ end
176
+
177
+ # ========================================================================= #
178
+ # === entry1?
179
+ # ========================================================================= #
180
+ def entry1?
181
+ @entry1_for_the_backup_from_value
182
+ end; alias entry_left? entry1? # === entry_left?
183
+
184
+ # ========================================================================= #
185
+ # === create_the_entries (entries tag)
186
+ # ========================================================================= #
187
+ def create_the_entries
188
+ # ======================================================================= #
189
+ # === @entry1_for_the_backup_from_value
190
+ # ======================================================================= #
191
+ @entry1_for_the_backup_from_value = entry
192
+ @entry1_for_the_backup_from_value.pad4px
193
+ @entry1_for_the_backup_from_value.bblack1
194
+ @entry1_for_the_backup_from_value.very_light_yellow_background
195
+ # ======================================================================= #
196
+ # === @entry2_for_the_backup_onto_value
197
+ # ======================================================================= #
198
+ @entry2_for_the_backup_onto_value = entry
199
+ @entry2_for_the_backup_onto_value.pad4px
200
+ @entry2_for_the_backup_onto_value.bblack1
201
+ @entry2_for_the_backup_onto_value.very_light_yellow_background
202
+ @entry2_for_the_backup_onto_value.width_height(250, 50)
203
+ end
204
+
205
+ # ========================================================================= #
206
+ # === from?
207
+ #
208
+ # This method has to keep in mind that Strings such as ":ingrid" are
209
+ # used. This indicates a symbol which has to be treated in a special
210
+ # manner.
211
+ #
212
+ # Furthermore, only directories will have a '/' appended; files must
213
+ # not have a '/' appended.
214
+ # ========================================================================= #
215
+ def from?(
216
+ i = @entry1_for_the_backup_from_value.text?
217
+ )
218
+ if i.is_a?(String) and i.start_with?(':')
219
+ case i.delete(':').to_sym
220
+ # ===================================================================== #
221
+ # === :ingrid
222
+ # ===================================================================== #
223
+ when :ingrid
224
+ i = 'C/ingrid/'
225
+ end
226
+ end
227
+ if i.is_a?(String) and i.frozen?
228
+ i = i.dup
229
+ end
230
+ i.squeeze!('/')
231
+ if File.directory?(i) and !i.end_with?('/')
232
+ i << '/'
233
+ end
234
+ return i
235
+ end
236
+
237
+ # ========================================================================= #
238
+ # === copy_from_to
239
+ #
240
+ # This is the method that can be used for backing up the data.
241
+ # ========================================================================= #
242
+ def copy_from_to(
243
+ from = from?,
244
+ to = onto?
245
+ )
246
+ unless File.directory? from
247
+ e "#{sfile(from)} should be a directory."
248
+ end
249
+ if from == 'C/ingrid/'
250
+ # ====================================================================== #
251
+ # The first entry is a special case, applying to only one particular
252
+ # situation on Windows. It is retained here on an ad-hoc basis,
253
+ # but it may be better to move this into another location.
254
+ # ====================================================================== #
255
+ BackupParadise::Windows.backup_ingrid_directory
256
+ elsif File.file?(from)
257
+ # ====================================================================== #
258
+ # Backup files here.
259
+ # ====================================================================== #
260
+ do_transfer_a_single_file
261
+ else
262
+ # ====================================================================== #
263
+ # Backup directories here.
264
+ # ====================================================================== #
265
+ if from.is_a?(String) and from.start_with?(':')
266
+ case from.delete(':').to_sym
267
+ # ===================================================================== #
268
+ # === :everything
269
+ #
270
+ # This will default to the registered action stored in the
271
+ # config.yml file.
272
+ # ===================================================================== #
273
+ when :everything
274
+ if @dataset_from_the_config_file
275
+ i = @dataset_from_the_config_file['backup_these_directories']
276
+ BackupParadise::Actions.backup {{
277
+ backup_these_directories: i,
278
+ where_to: to
279
+ }}
280
+ else
281
+ e 'No file called config.yml was found. Defaulting to the'
282
+ e 'current working directory thus.'
283
+ i = File.absolute_path("#{Dir.pwd}/")
284
+ end
285
+ end
286
+ else
287
+ begin
288
+ Thread.new {
289
+ @spinner.is_active # go_and_spin_now
290
+ FileUtils.cp_r(from, to)
291
+ pop_up_this_text_over_that_widget(
292
+ return_backup_complete_message, @button_backup
293
+ )
294
+ @spinner.stop_spinning
295
+ }
296
+ rescue Exception => error
297
+ pp error
298
+ end
299
+ end
300
+ end
301
+ end
302
+
303
+ # ========================================================================= #
304
+ # === backup_audio_button?
305
+ # ========================================================================= #
306
+ def backup_audio_button?
307
+ @button_backup_audio
308
+ end
309
+
310
+ # ========================================================================= #
311
+ # === backup_ingrid_button?
312
+ # ========================================================================= #
313
+ def backup_ingrid_button?
314
+ @button_ingrid
315
+ end
316
+
317
+ # ========================================================================= #
318
+ # === backup_button?
319
+ # ========================================================================= #
320
+ def backup_button?
321
+ @button_backup
322
+ end
323
+
324
+ # ========================================================================= #
325
+ # === create_the_file_chooser_button
326
+ # ========================================================================= #
327
+ def create_the_file_chooser_button
328
+ # ======================================================================= #
329
+ # === @button_choose_file
330
+ # ======================================================================= #
331
+ @button_choose_file = button('Choose file')
332
+ @button_choose_file.on_clicked {
333
+ create_file_chooser_dialog_widget
334
+ run_file_chooser_dialog
335
+ }
336
+ end
337
+
338
+ # ========================================================================= #
339
+ # === choose_file_button?
340
+ # ========================================================================= #
341
+ def choose_file_button?
342
+ @button_choose_file
343
+ end
344
+
345
+ # ========================================================================= #
346
+ # === create_the_label_showing_results
347
+ # ========================================================================= #
348
+ def create_the_label_showing_results
349
+ @label_showing_results = label
350
+ end
351
+
352
+ # ========================================================================= #
353
+ # === create_the_buttons (buttons tag, button tag)
354
+ # ========================================================================= #
355
+ def create_the_buttons
356
+ create_the_file_chooser_button
357
+ create_the_backup_button
358
+ create_the_backup_audio_button
359
+ create_the_ingrid_button if is_on_roebe?
360
+ end
361
+
362
+ # ========================================================================= #
363
+ # === onto
364
+ # ========================================================================= #
365
+ def onto?
366
+ return "#{@entry2_for_the_backup_onto_value.text?}/".squeeze('/')
367
+ end; alias to? onto? # === to?
368
+
369
+ # ========================================================================= #
370
+ # === create_the_grid (grid tag)
371
+ # ========================================================================= #
372
+ def create_the_grid
373
+ # ======================================================================= #
374
+ # === @grid
375
+ # ======================================================================= #
376
+ @grid = default_grid
377
+ @grid.pad10px
378
+ @grid.css_class('dotted_steelblue_border')
379
+ @grid.set_size_request(100, 50)
380
+ @grid.row_spacing = 5
381
+ @grid.line_spacing = 5
382
+ label_backup_from = text('Backup from:')
383
+ label_backup_from.make_bold
384
+ label_backup_from.hint = 'Input which directory '\
385
+ 'you wish to back up. Use the combo-box entry '\
386
+ 'below this widget, or the entry below '\
387
+ 'that combo-box.'
388
+ @grid.left(label_backup_from)
389
+
390
+ label_backup_onto = text('Backup onto:')
391
+ label_backup_onto.make_bold
392
+ label_backup_onto.hint = 'Input the target device onto which we will '\
393
+ 'copy the data onto.'
394
+ @grid.right(label_backup_onto)
395
+
396
+ # ======================================================================= #
397
+ # Next we will add the two main combo-boxes.
398
+ # ======================================================================= #
399
+ @grid.left(@combo_box_backup_from)
400
+ @grid.right(@combo_box_backup_onto)
401
+ @grid.left(@entry1_for_the_backup_from_value)
402
+ @grid.right(@entry2_for_the_backup_onto_value)
403
+ end
404
+
405
+ # ========================================================================= #
406
+ # === create_the_combo_boxes (combo tag)
407
+ # ========================================================================= #
408
+ def create_the_combo_boxes
409
+ # ======================================================================= #
410
+ # === @combo_box_backup_from
411
+ #
412
+ # This is the combo-box that keeps the core entries, such as
413
+ # "/home/x/songs" and so forth.
414
+ # ======================================================================= #
415
+ @combo_box_backup_from = combo_box
416
+ @combo_box_backup_from.bblack1
417
+ @combo_box_backup_from.set_border_width(2)
418
+ # ======================================================================= #
419
+ # Next we will populate the combo-box with proper entries:
420
+ # ======================================================================= #
421
+ _ = BackupParadise.backup_these_directories?.map {|entry| "#{entry}/".squeeze('/') }
422
+ _.prepend(':everything')
423
+ _.prepend(':ingrid') if is_on_roebe?
424
+ @combo_box_backup_from.populate(_)
425
+ @combo_box_backup_from.the_first_entry_is_active
426
+ @combo_box_backup_from.hint =
427
+ ':everything means to backup the default action, as-is. If you '\
428
+ 'need a more fine-tuned level of control then simply backup only '\
429
+ 'some directories, or use the entry to the right side of this '\
430
+ 'combo box to backup only individual directories or files.'
431
+ # ======================================================================= #
432
+ # === @combo_box_backup_onto
433
+ # ======================================================================= #
434
+ @combo_box_backup_onto = combo_box
435
+ @combo_box_backup_onto.bblack1
436
+ @combo_box_backup_onto.set_border_width(2)
437
+ scan_for_mountpoints_then_update_the_appropriate_combo_box
438
+ end
439
+
440
+ # ========================================================================= #
441
+ # === sync_the_combo_box_values_onto_the_entries_below
442
+ # ========================================================================= #
443
+ def sync_the_combo_box_values_onto_the_entries_below
444
+ _ = @combo_box_backup_from.text?.to_s
445
+ entry1?.set_text(_)
446
+ sync_the_second_entry
447
+ end
448
+
449
+ # ========================================================================= #
450
+ # === sync_the_second_entry
451
+ # ========================================================================= #
452
+ def sync_the_second_entry
453
+ entry2?.set_text(
454
+ @combo_box_backup_onto.text?.to_s
455
+ )
456
+ end
457
+
458
+ # ========================================================================= #
459
+ # === entry2?
460
+ # ========================================================================= #
461
+ def entry2?
462
+ @entry2_for_the_backup_onto_value
463
+ end
464
+
465
+ # ========================================================================= #
466
+ # === do_handle_the_proper_syncing_when_the_combo_box_entries_are_changed
467
+ # ========================================================================= #
468
+ def do_handle_the_proper_syncing_when_the_combo_box_entries_are_changed
469
+ # ======================================================================= #
470
+ # Sync any change made in the combo box onto the associated entry.
471
+ # ======================================================================= #
472
+ sync_connect(@combo_box_backup_from, entry1?)
473
+ sync_connect(@combo_box_backup_onto, entry2?)
474
+ end
475
+
476
+ # ========================================================================= #
477
+ # === create_the_ingrid_button
478
+ # ========================================================================= #
479
+ def create_the_ingrid_button
480
+ # ======================================================================= #
481
+ # === @button_ingrid
482
+ # ======================================================================= #
483
+ @button_ingrid = button('Backup ingrid')
484
+ @button_ingrid.clear_background
485
+ @button_ingrid.pad8px
486
+ @button_ingrid.css_class('the_backup_button_for_ingrid')
487
+ @button_ingrid.set_size_request(16, 25)
488
+ @button_ingrid.on_clicked {
489
+ do_backup_for_ingrid
490
+ }
491
+ @button_ingrid.set_border_width(2)
492
+ @button_ingrid.hint = 'This will backup c:\ingrid to '\
493
+ 'the appropriate external USB device.'
494
+ end
495
+
496
+ # ========================================================================= #
497
+ # === scan_for_mountpoints_then_update_the_appropriate_combo_box
498
+ # ========================================================================= #
499
+ def scan_for_mountpoints_then_update_the_appropriate_combo_box
500
+ if Object.const_defined? :Mountpoints
501
+ @combo_box_backup_onto.clear_old_datapoints
502
+ @combo_box_backup_onto.populate(Mountpoints[])
503
+ @combo_box_backup_onto.the_first_entry_is_active
504
+ sync_the_second_entry
505
+ end
506
+ end
507
+
508
+ # ========================================================================= #
509
+ # === create_the_backup_audio_button
510
+ # ========================================================================= #
511
+ def create_the_backup_audio_button
512
+ # ======================================================================= #
513
+ # === @button_backup_audio
514
+ # ======================================================================= #
515
+ @button_backup_audio = button('Backup Audio')
516
+ @button_backup_audio.hint = 'This button is ad-hoc code to quickly '\
517
+ 'copy all local songs on my home layout. You can modify this '\
518
+ 'by modifying the config.yml file and changing the entry called '\
519
+ '<b>local_audio_directory</b>.'
520
+ @button_backup_audio.on_clicked {
521
+ # ===================================================================== #
522
+ # First, if the config-dataset exists, sync the combo-box entry.
523
+ # ===================================================================== #
524
+ if @dataset_from_the_config_file
525
+ local_audio_directory = @dataset_from_the_config_file['local_audio_directory'].to_s
526
+ entry_left?.set_text(
527
+ local_audio_directory
528
+ )
529
+ end
530
+ do_backup_my_songs
531
+ }
532
+ end
533
+
534
+ # ========================================================================= #
535
+ # === create_the_backup_button
536
+ # ========================================================================= #
537
+ def create_the_backup_button
538
+ # ======================================================================= #
539
+ # === @button_backup
540
+ # ======================================================================= #
541
+ @button_backup = button('Backup the data')
542
+ @button_backup.clear_background
543
+ @button_backup.pad8px
544
+ @button_backup.css_class('the_backup_button')
545
+ @button_backup.set_size_request(16, 25)
546
+ @button_backup.on_clicked {
547
+ do_backup_the_data
548
+ }
549
+ @button_backup.set_border_width(2)
550
+ @button_backup.hint =
551
+ "Click this button to <b>backup your data</b>. This works for both "\
552
+ "directories, as well as individual files and special instructions. "\
553
+ "Special instructions are indicated via a leading : character on "\
554
+ "the top-left hand side.\n\n"\
555
+ "Make sure that the USB device(s) are properly connected before "\
556
+ "clicking any button, though."
557
+ end
558
+
559
+ # ========================================================================= #
560
+ # === do_backup_the_data
561
+ # ========================================================================= #
562
+ def do_backup_the_data(
563
+ from = from?,
564
+ to = to?
565
+ )
566
+ @label_showing_results.set_text(
567
+ 'Command that will be run: '+"\n\n"+
568
+ ' <b>cp -rv '+from+' '+to+"</b>\n"
569
+ )
570
+ @label_showing_results.do_markify
571
+ Thread.new {
572
+ e 'Backing up the data next, from `'+
573
+ sfile(from)+'` to `'+sfile(to)+'`.'
574
+ copy_from_to(from, to)
575
+ }
576
+ end
577
+
578
+ # ========================================================================= #
579
+ # === backup_ingrid_directory
580
+ #
581
+ # This is a method for a custom-backup. Other users won't need to use
582
+ # this method.
583
+ # ========================================================================= #
584
+ def backup_ingrid_directory
585
+ BackupParadise::Windows.backup_ingrid_directory
586
+ end; alias do_backup_for_ingrid backup_ingrid_directory # === do_backup_for_ingrid
587
+
588
+ # ========================================================================= #
589
+ # === run (run tag)
590
+ # ========================================================================= #
591
+ def run
592
+ create_skeleton_then_connect_skeleton
593
+ end
594
+
595
+ end; end; end
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This file shall provide simple bindings for backup-related activity
6
+ # on windows. On windows paths such as "E:/songs" will work.
7
+ # =========================================================================== #
8
+ # require 'backup_paradise/gui/tk/backup.rb'
9
+ # =========================================================================== #
10
+ require 'backup_paradise'
11
+
12
+ @object_backup = BackupParadise::Backup.new { :do_not_run_yet }
13
+
14
+ require 'tk_paradise/tk_paradise.rb'
15
+ include Tk
16
+
17
+ alias e puts
18
+ require 'colours'
19
+
20
+ # =========================================================================== #
21
+ # === TITLE
22
+ # =========================================================================== #
23
+ TITLE = 'Backup data'
24
+
25
+ # =========================================================================== #
26
+ # === rev
27
+ # =========================================================================== #
28
+ def rev
29
+ ::Colours.rev
30
+ end
31
+
32
+ # =========================================================================== #
33
+ # === do_start_to_backup
34
+ # =========================================================================== #
35
+ def do_start_to_backup(i = :usb1)
36
+ if i and i.is_a? String
37
+ i = i.dup
38
+ if i.include? 'onto '
39
+ i.sub!(/onto /) # 'onto F:'
40
+ end
41
+ end
42
+ unless i.end_with? '/'
43
+ i << '/'
44
+ end
45
+ e rev+'Starting to backup data.'
46
+ @object_backup = BackupParadise::Backup.new { :do_not_run_yet }
47
+ #pp @object_backup.mountpoint?
48
+ # @object_backup.set_mountpoint(i)
49
+ #pp @object_backup.mountpoint?
50
+ end
51
+
52
+ # =========================================================================== #
53
+ # === Fonts
54
+ # =========================================================================== #
55
+ USE_THIS_FONT_FAMILY = 'DejaVu Sans'
56
+ larger_font = Font.new(family: USE_THIS_FONT_FAMILY, size: 28, weight: 'bold')
57
+ font = Font.new(family: USE_THIS_FONT_FAMILY, size: 20, weight: 'bold')
58
+
59
+ root = Tk.root {{ geometry: '820x450+0+0', title: TITLE }}
60
+
61
+ button_start_to_backup_onto_drive_letter_e = Button.new(
62
+ root,
63
+ text: 'Start to backup onto label E:',
64
+ bg: '#0052cc',
65
+ fg: '#ffffff'
66
+ ) {
67
+ command proc {
68
+ do_start_to_backup('onto E:')
69
+ }
70
+ }.grid(row: 1, column: 3, columnspan: 3, padx: 2, pady: 2)
71
+
72
+ button_start_to_backup_onto_drive_letter_e.set_font(larger_font)
73
+ Grid.grid(button_start_to_backup_onto_drive_letter_e, columnspan: 2)
74
+
75
+ button_start_to_backup_onto_drive_letter_f = Button.new(
76
+ root,
77
+ text: 'Start to backup onto label F:',
78
+ bg: '#0052cc',
79
+ fg: '#ffffff'
80
+ ) {
81
+ command proc {
82
+ do_start_to_backup('onto F:')
83
+ }
84
+ }.grid(row: 2, column: 3, columnspan: 3, padx: 2, pady: 2)
85
+
86
+ button_start_to_backup_onto_drive_letter_f.set_font(larger_font)
87
+ Grid.grid(button_start_to_backup_onto_drive_letter_f, columnspan: 2)
88
+
89
+ button_ad_hoc = Button.new(
90
+ root,
91
+ text: 'Auto-backup (easy debug mode for now onto E:)',
92
+ bg: '#0052cc',
93
+ fg: '#ffffff'
94
+ ) {
95
+ command proc {
96
+ @object_backup = BackupParadise::Backup.new { :do_not_run_yet }
97
+ @object_backup.set_mountpoint('E:/')
98
+ @object_backup.do_backup
99
+ }
100
+ }.grid(row: 3, column: 3, columnspan: 3, padx: 2, pady: 2)
101
+
102
+ button_ad_hoc.set_font(larger_font)
103
+ Grid.grid(button_ad_hoc, columnspan: 2)
104
+
105
+
106
+ Tk.run
107
+
108
+ #TkLabel.new(root) { text 'Attention!'; font TkCaptionFont }