backup_paradise 1.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

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