Class: BackupParadise::GUI::UniversalWidgets::SimpleBackupWidget

Inherits:
Base
  • Object
show all
Includes:
UniversalWidgets::BaseModule
Defined in:
lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb

Overview

BackupParadise::GUI::UniversalWidgets::SimpleBackupWidget

Constant Summary collapse

ARRAY_PREDEFINED_DEVICES =
#

ARRAY_PREDEFINED_DEVICES

#
[
  ENV['USB1'], 
  ENV['USB2'], 
  ENV['USB3'], 
  ENV['USB4'],
  ENV['USB5'],
  ENV['FESTPLATTE1']
]
USE_THESE_CSS_RULES =
#

USE_THESE_CSS_RULES

#
'

.dotted_steelblue_border {
border: 2px dotted steelblue;
}

.the_backup_button {
border: 3px dotted royalblue;
padding: 8px;
margin: 4px;
color: darkgreen;
font-weight: bold;
}

.the_backup_button:hover {
color: forestgreen;
font-weight: bold;
}

.the_backup_button_for_ingrid {
border: 2px dotted royalblue;
padding: 5px;
margin: 2px;
color: royalblue;
font-weight: bold;
}

.the_backup_button_for_ingrid_button:hover {
color: steelblue;
font-weight: bold;
}

'
TITLE =
#

TITLE

#
'💾 Simple Backup Widget 💾'
WIDTH =
#

WIDTH

#
'82% or minimum 1280px'
HEIGHT =
#

HEIGHT

#
'30% or minimum 400px'
USE_THIS_FONT =
#

USE_THIS_FONT

#
:dejavu_condensed_19
LARGER_FONT =
#

LARGER_FONT

#
:dejavu_condensed_21
SMALLER_FONT =
#

SMALLER_FONT

#
:dejavu_condensed_18
USE_THIS_MONOSPACED_FONT =
#

USE_THIS_MONOSPACED_FONT

#
:hack_16

Constants inherited from Base

Base::NAMESPACE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#all_important_directories?, #append_what_into, #are_we_on_windows?, #cd_to_the_mounted_device, #chdir, #cliner, #copy_file, #copy_recursively, #create_directory, #cyan, #data_directory?, #dd_mm_yyyy, #delete_files, #delete_symlink, #do_symlink, #e, #esystem, #exit_program, #has_superuser_abilities?, #hh_mm_ss, #home_dir_of_user_x?, #is_on_roebe?, #is_symlink?, #lightcoral, #n_files_in?, #no_file_exists_at, #no_such_directory_exists_at, #no_target_at, #opne, #opnn, #orangered, #print_rev, #rds, #register_sigint, #remove, #remove_directory, #remove_file, #rename, #rename_tab, #report_total_size_of, #return_all_symlinks_from_this_directory, #return_current_date_and_time, #rev, #rosybrown, #royalblue, #sdir, #seagreen, #set_target_mountpoint, #sfancy, #sfile, #simp, #size?, #steelblue, #tab_title, #target_hdd_does_not_have_enough_space_left?, #target_mountpoint?, #tomato, #use_colours?, #use_system_cp?, #use_this_program_to_rename_tabs?, #write_what_into

Constructor Details

#initialize(commandline_arguments = ARGV, run_already = true) ⇒ SimpleBackupWidget

#

initialize

#


140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 140

def initialize(
    commandline_arguments       = ARGV,
    run_already                 = true
  )
  super(:vertical) if use_gtk3?
  determine_the_GUI_to_be_used(commandline_arguments) # This must come first, even before reset().
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  on_delete_event_quit_the_application
  # self.label_widget.set_markup %Q(
  #   <span size="larger" weight="bold">💾 Backup Script</span>
  # )
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

BackupParadise::GUI::UniversalWidgets::SimpleBackupWidget[]

#


825
826
827
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 825

def self.[](i = ARGV)
  new(i)
end

.run(i = ARGV) ⇒ Object

#

BackupParadise::GUI::Gtk::SimpleBackupWidget.run

#


807
808
809
810
811
812
813
814
815
816
817
818
819
820
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 807

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::BackupParadise::GUI::Gtk::SimpleBackupWidget.new(i)
  r = ::Gtk.run
  r << _
  _.set_parent_widget(r)
  r.automatic_size_then_automatic_title
  r.enable_quick_exit
  r.set_background :white
  r.is_resizable # <- This line was added due to a possible prior .maximize action.
  r.top_left_then_run
end

Instance Method Details

#backup_audio_button?Boolean

#

backup_audio_button?

#

Returns:

  • (Boolean)


604
605
606
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 604

def backup_audio_button?
  @button_backup_audio
end

#backup_button?Boolean

#

backup_button?

#

Returns:

  • (Boolean)


618
619
620
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 618

def backup_button?
  @button_backup
end

#backup_ingrid_button?Boolean

#

backup_ingrid_button?

#

Returns:

  • (Boolean)


611
612
613
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 611

def backup_ingrid_button?
  @button_ingrid
end

#backup_ingrid_directoryObject Also known as: do_backup_for_ingrid

#

backup_ingrid_directory

This is a method for a custom-backup. Other users won’t need to use this method.

#


335
336
337
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 335

def backup_ingrid_directory
  BackupParadise::Windows.backup_ingrid_directory
end

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


255
256
257
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 255

def border_size?
  0
end

#choose_file_button?Boolean

#

choose_file_button?

#

Returns:

  • (Boolean)


639
640
641
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 639

def choose_file_button?
  @button_choose_file
end

#connect_the_skeletonObject

#

connect_the_skeleton (connect tag)

#


832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 832

def connect_the_skeleton
  abort_on_exception

  outer_vbox = create_vbox # A new vbox.

  header_bar = return_default_header_bar { :with_close_button_and_inferred_title }
  header_bar.spacing = 10
  header_bar.add_left(@button_choose_file)
  header_bar.add_left(@button_backup_audio)
  @spinner = default_spinner
  @spinner.is_inactive
  header_bar.add_right(@spinner)
  button = icon_theme_image('daytime-sunset-symbolic.symbolic')
  button.hint = 'Click this icon to show which devices are mounted and '\
                'update the combo-box showing all mounted devices.'
  button.on_clicked {
    scan_for_mountpoints_then_update_the_appropriate_combo_box
  }
  header_bar.add_left(button)
  outer_vbox.minimal(header_bar,           1)
  outer_vbox.minimal(horizontal_separator, 1)
  outer_vbox.minimal(@grid,                1)
  outer_vbox.minimal(horizontal_separator, 1)
  hbox = create_hbox
  _ = BackupParadise.project_base_directory?+'images/right_arrow.png'
  if File.exist? _
    hbox.minimal(image(_), 5)
  end
  hbox.maximal(@button_backup)
  outer_vbox.minimal(hbox)
  outer_vbox.minimal(horizontal_separator)
  if is_on_roebe?
    outer_vbox.minimal(@button_ingrid)
    outer_vbox.minimal(horizontal_separator)
  end
  outer_vbox.minimal(@label_showing_results)
  outer_vbox.minimal(horizontal_separator)

  window = create_window_or_runner
  window << outer_vbox

  properly_prepare_this_window(window,
    {
      title:       title?,
      font:        font?,
      width:       width?,
      height:      height?,
      padding:     padding?,
      border_size: border_size?
    }
  )
  window.show_all
  window.top_left
  do_all_startup_related_actions
  run_main
end

#copy_from_to(from = from?, , to = onto? ) ⇒ Object

#

copy_from_to

This is the method that can be used for backing up the data.

#


540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 540

def copy_from_to(
    from = from?,
    to   = onto?
  )
  unless File.directory? from
    e "#{sfile(from)} should be a directory."
  end
  if from == 'C/ingrid/'
    # ====================================================================== #
    # The first entry is a special case, applying to only one particular
    # situation on Windows. It is retained here on an ad-hoc basis,
    # but it may be better to move this into another location.
    # ====================================================================== #
    BackupParadise::Windows.backup_ingrid_directory
  elsif File.file?(from)
    # ====================================================================== #
    # Backup files here.
    # ====================================================================== #
    do_transfer_a_single_file
  else
    # ====================================================================== #
    # Backup directories here.
    # ====================================================================== #
    if from.is_a?(String) and from.start_with?(':')
      case from.delete(':').to_sym
      # ===================================================================== #
      # === :everything
      #
      # This will default to the registered action stored in the
      # config.yml file.
      # ===================================================================== #
      when :everything
        if @dataset_from_the_config_file
          i = @dataset_from_the_config_file['backup_these_directories']
          BackupParadise::Actions.backup {{
            backup_these_directories: i,
            where_to:                 to
          }}
        else
          e 'No file called config.yml was found. Defaulting to the'
          e 'current working directory thus.'
          i = File.absolute_path("#{Dir.pwd}/")
        end
      end
    else
      begin
        Thread.new {
          @spinner.is_active # go_and_spin_now
          FileUtils.cp_r(from, to)
          pop_up_this_text_over_that_widget(
            return_backup_complete_message, @button_backup
          )
          @spinner.stop_spinning
        }
      rescue Exception => error
        pp error
      end
    end
  end
end

#copy_this_file(from, b) ⇒ Object

#

copy_this_file

#


408
409
410
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 408

def copy_this_file(from, b)
  ::BackupParadise.copy_this_file(from, b)
end

#create_file_chooser_dialog_widgetObject

#

create_file_chooser_dialog_widget

#


364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 364

def create_file_chooser_dialog_widget
  @file_chooser_dialog = ::Gtk::FileChooserDialog.new(
    self: self,
    title: 'Choose a file or directory',
    action: ::Gtk::FileChooserAction::OPEN,                                 
    buttons: [[::Gtk::Stock::OPEN, ::Gtk::ResponseType::ACCEPT],
     [::Gtk::Stock::CANCEL, ::Gtk::ResponseType::CANCEL]]
  )
  # ======================================================================= #
  # === /home/Temp
  # ======================================================================= #
  if File.directory? '/home/Temp/'
    @file_chooser_dialog.add_shortcut_folder('/home/Temp/')
  end
  # ======================================================================= #
  # === /home/x/Temp
  # ======================================================================= #
  if File.directory? '/home/x/Temp/'
    @file_chooser_dialog.add_shortcut_folder('/home/x/Temp/')
  end
  # ======================================================================= #
  # === /home/x/data/
  # ======================================================================= #
  if File.directory? HOME_DIRECTORY_OF_THE_USER_X+'data/'
    @file_chooser_dialog.add_shortcut_folder(HOME_DIRECTORY_OF_THE_USER_X+'data/')
  end
  # ======================================================================= #
  # Add the audio-directory shortcut, defined in the yaml file.
  # ======================================================================= #
  if @dataset_from_the_config_file and
     @dataset_from_the_config_file.has_key?('local_audio_directory')
    @file_chooser_dialog.add_shortcut_folder(
      @dataset_from_the_config_file['local_audio_directory'].to_s
    )
  end
  @file_chooser_dialog.add_shortcut_folder('/Ingrid')
  @file_chooser_dialog.current_folder = Dir.pwd
  @file_chooser_dialog.do_show_hidden_files
  # @file_chooser_dialog.destroy
end

#create_the_backup_audio_buttonObject

#

create_the_backup_audio_button

#


262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 262

def create_the_backup_audio_button
  # ======================================================================= #
  # === @button_backup_audio
  # ======================================================================= #
  @button_backup_audio = button('Backup Audio')
  @button_backup_audio.hint = 'This button is ad-hoc code to quickly '\
    'copy all local songs on my home layout. You can modify this '\
    'by modifying the config.yml file and changing the entry called '\
    '<b>local_audio_directory</b>.'
  @button_backup_audio.on_clicked {
    # ===================================================================== #
    # First, if the config-dataset exists, sync the combo-box entry.
    # ===================================================================== #
    if @dataset_from_the_config_file
      local_audio_directory = @dataset_from_the_config_file['local_audio_directory'].to_s
      entry_left?.set_text(
        local_audio_directory
      )
    end
    do_backup_my_songs
  }
end

#create_the_backup_buttonObject

#

create_the_backup_button

#


288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 288

def create_the_backup_button
  # ======================================================================= #
  # === @button_backup
  # ======================================================================= #
  @button_backup = button('_Backup the data', self, :use_mnemonics) {
    :do_backup_the_data
  }
  @button_backup.clear_background
  @button_backup.on_hover(:lightblue)
  @button_backup.pad8px
  @button_backup.css_class('the_backup_button')
  @button_backup.set_size_request(16, 25)
  @button_backup.set_border_width(2)
  @button_backup.hint =
    "Click this button to <b>backup your data</b>. This works for both "\
    "directories, as well as individual files and special instructions. "\
    "Special instructions are indicated via a leading : character on "\
    "the top-left hand side.\n\n"\
    "Make sure that the USB device(s) are properly connected before "\
    "clicking any button, though."
end

#create_the_buttonsObject

#

create_the_buttons (buttons tag, button tag)

#


653
654
655
656
657
658
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 653

def create_the_buttons
  create_the_file_chooser_button
  create_the_backup_button
  create_the_backup_audio_button
  create_the_ingrid_button if is_on_roebe?
end

#create_the_combo_boxesObject

#

create_the_combo_boxes (combo tag)

#


706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 706

def create_the_combo_boxes
  # ======================================================================= #
  # === @combo_box_backup_from
  #
  # This is the combo-box that keeps the core entries, such as
  # "/home/x/songs" and so forth.
  # ======================================================================= #
  @combo_box_backup_from = combo_box
  @combo_box_backup_from.bblack1
  @combo_box_backup_from.set_border_width(2)
  # ======================================================================= #
  # Next we will populate the combo-box with proper entries:
  # ======================================================================= #
  _ = BackupParadise.backup_these_directories?.map {|entry| "#{entry}/".squeeze('/') }
  _.prepend(':everything')
  _.prepend(':ingrid') if is_on_roebe?
  @combo_box_backup_from.populate(_)
  @combo_box_backup_from.the_first_entry_is_active
  @combo_box_backup_from.hint =
    ':everything means to backup the default action, as-is. If you '\
    'need a more fine-tuned level of control then simply backup only '\
    'some directories, or use the entry to the right side of this '\
    'combo box to backup only individual directories or files.'
  # ======================================================================= #
  # === @combo_box_backup_onto
  # ======================================================================= #
  @combo_box_backup_onto = combo_box
  @combo_box_backup_onto.bblack1
  @combo_box_backup_onto.set_border_width(2)
  scan_for_mountpoints_then_update_the_appropriate_combo_box
end

#create_the_entriesObject

#

create_the_entries (entries tag)

#


485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 485

def create_the_entries
  # ======================================================================= #
  # === @entry1_for_the_backup_from_value
  # ======================================================================= #
  @entry1_for_the_backup_from_value = entry
  @entry1_for_the_backup_from_value.pad4px
  @entry1_for_the_backup_from_value.bblack1
  @entry1_for_the_backup_from_value.very_light_yellow_background
  # ======================================================================= #
  # === @entry2_for_the_backup_onto_value
  # ======================================================================= #
  @entry2_for_the_backup_onto_value = entry
  @entry2_for_the_backup_onto_value.pad4px
  @entry2_for_the_backup_onto_value.bblack1
  @entry2_for_the_backup_onto_value.very_light_yellow_background
  @entry2_for_the_backup_onto_value.width_height(250, 50)
end

#create_the_file_chooser_buttonObject

#

create_the_file_chooser_button

#


625
626
627
628
629
630
631
632
633
634
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 625

def create_the_file_chooser_button
  # ======================================================================= #
  # === @button_choose_file
  # ======================================================================= #
  @button_choose_file = button('Choose file')
  @button_choose_file.on_clicked {
    create_file_chooser_dialog_widget
    run_file_chooser_dialog
  }
end

#create_the_gridObject

#

create_the_grid (grid tag)

#


670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 670

def create_the_grid
  # ======================================================================= #
  # === @grid
  # ======================================================================= #
  @grid = default_grid
  @grid.pad10px
  @grid.css_class('dotted_steelblue_border')
  @grid.set_size_request(100, 50)
  @grid.row_spacing  = 5
  @grid.line_spacing = 5
  label_backup_from = text('Backup from:')
  label_backup_from.make_bold
  label_backup_from.hint = 'Input which directory '\
                           'you wish to back up. Use the combo-box entry '\
                           'below this widget, or the entry below '\
                           'that combo-box.'
  @grid.left(label_backup_from)

  label_backup_onto = text('Backup onto:')
  label_backup_onto.make_bold
  label_backup_onto.hint = 'Input the target device onto which we will '\
                           'copy the data onto.'
  @grid.right(label_backup_onto)

  # ======================================================================= #
  # Next we will add the two main combo-boxes.
  # ======================================================================= #
  @grid.left(@combo_box_backup_from)
  @grid.right(@combo_box_backup_onto)
  @grid.left(@entry1_for_the_backup_from_value)
  @grid.right(@entry2_for_the_backup_onto_value)
end

#create_the_ingrid_buttonObject

#

create_the_ingrid_button

#


900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 900

def create_the_ingrid_button
  # ======================================================================= #
  # === @button_ingrid
  # ======================================================================= #
  @button_ingrid = button('Backup _ingrid', self, :use_mnemonics) {
    :do_backup_for_ingrid
  }
  @button_ingrid.clear_background
  @button_ingrid.css_class('the_backup_button_for_ingrid')
  @button_backup.on_hover(:lightblue)
  @button_ingrid.pad8px
  @button_ingrid.set_size_request(16, 25)
  @button_ingrid.set_border_width(2)
  @button_ingrid.hint = 'This will backup c:\ingrid to '\
    'the appropriate external USB device.'
end

#create_the_label_showing_resultsObject

#

create_the_label_showing_results

#


646
647
648
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 646

def create_the_label_showing_results
  @label_showing_results = label
end

#create_the_skeletonObject

#

create_the_skeleton (create tag, skeleton tag)

#


789
790
791
792
793
794
795
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 789

def create_the_skeleton
  create_the_label_showing_results
  create_the_buttons
  create_the_entries
  create_the_combo_boxes
  create_the_grid
end
#
#


892
893
894
895
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 892

def do_all_startup_related_actions
  sync_the_combo_box_values_onto_the_entries_below
  do_handle_the_proper_syncing_when_the_combo_box_entries_are_changed
end

#do_backup_my_songs(to = ("#{onto?}#{File.basename(entry_left?.text?)}/").squeeze('/')) ⇒ Object

#

do_backup_my_songs

#


452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 452

def do_backup_my_songs(
    to =
      ("#{onto?}#{File.basename(entry_left?.text?)}/").squeeze('/')
  )
  to.squeeze!('/')
  Thread.new {
    BackupParadise.simple_backup(
      entry_left?.text?, to
    )
    pop_up_this_text_over_that_widget(
      return_backup_complete_message,
      @button_backup_audio 
    )
  }
end

#do_backup_the_data(from = from?, , to = to? ) ⇒ Object

#

do_backup_the_data

#


313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 313

def do_backup_the_data(
    from = from?,
    to   = to?
  )
  @label_showing_results.set_text(
    'Command that will be run: '+"\n\n"+
    '  <b>cp -rv '+from+' '+to+"</b>\n"
  )
  @label_showing_results.do_markify
  Thread.new {
    e 'Backing up the data next, from `'+
       sfile(from)+'` to `'+sfile(to)+'`.'
    copy_from_to(from, to)
  }
end

#do_handle_the_proper_syncing_when_the_combo_box_entries_are_changedObject

#

do_handle_the_proper_syncing_when_the_combo_box_entries_are_changed

#


766
767
768
769
770
771
772
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 766

def do_handle_the_proper_syncing_when_the_combo_box_entries_are_changed
  # ======================================================================= #
  # Sync any change made in the combo box onto the associated entry.
  # ======================================================================= #
  sync_connect(@combo_box_backup_from, entry1?)
  sync_connect(@combo_box_backup_onto, entry2?)
end

#do_transfer_a_single_file(_ = entry_left?.text?.strip, target = onto? ) ⇒ Object

#

do_transfer_a_single_file

#


422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 422

def do_transfer_a_single_file(
    _      = entry_left?.text?.strip,
    target = onto?
  )
  target = target.dup if target.frozen?
  target << File.basename(_)

  if _.empty?
    e 'Please supply a file to transfer.'
  else
    e "Now trying to copy #{_} to #{target}."
    Thread.new {
      copy_this_file(_, target)
      pop_up_this_text_over_that_widget(return_backup_complete_message, @button_backup)
    }
  end
end

#entry1?Boolean Also known as: entry_left?

#

entry1?

#

Returns:

  • (Boolean)


478
479
480
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 478

def entry1?
  @entry1_for_the_backup_from_value
end

#entry2?Boolean

#

entry2?

#

Returns:

  • (Boolean)


759
760
761
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 759

def entry2?
  @entry2_for_the_backup_onto_value
end

#favicon?Boolean

#

favicon?

#

Returns:

  • (Boolean)


191
192
193
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 191

def favicon?
  :tabble
end

#from?(i = @entry1_for_the_backup_from_value.text?) ⇒ Boolean

#

from?

This method has to keep in mind that Strings such as “:ingrid” are used. This indicates a symbol which has to be treated in a special manner.

Furthermore, only directories will have a ‘/’ appended; files must not have a ‘/’ appended.

#

Returns:

  • (Boolean)


513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 513

def from?(
    i = @entry1_for_the_backup_from_value.text?
  )
  if i.is_a?(String) and i.start_with?(':')
    case i.delete(':').to_sym
    # ===================================================================== #
    # === :ingrid
    # ===================================================================== #
    when :ingrid
      i = 'C/ingrid/'
    end
  end
  if i.is_a?(String) and i.frozen?
    i = i.dup
  end
  i.squeeze!('/')
  if File.directory?(i) and !i.end_with?('/')
    i << '/' 
  end
  return i
end

#handle_CSS_rulesObject

#

handle_CSS_rules (CSS tag)

#


219
220
221
222
223
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 219

def handle_CSS_rules
  use_gtk_paradise_project_css_file
  append_project_css_file
  more_CSS_then_apply_it(USE_THESE_CSS_RULES)
end

#larger_font?Boolean

#

larger_font?

#

Returns:

  • (Boolean)


415
416
417
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 415

def larger_font?
  LARGER_FONT
end

#main_target?Boolean

#

main_target?

This method will “return” our main target.

#

Returns:

  • (Boolean)


445
446
447
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 445

def main_target?
  @backup_to_this_target.text?
end

#onto?Boolean Also known as: to?

#

onto

#

Returns:

  • (Boolean)


663
664
665
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 663

def onto?
  return "#{@entry2_for_the_backup_onto_value.text?}/".squeeze('/')
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


248
249
250
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 248

def padding?
  0
end

#resetObject

#

reset (reset tag)

#


160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 160

def reset
  super() if respond_to?(:super)
  reset_the_shared_module # This can come early.
  reset_the_base_module
  reset_the_internal_variables
  infer_the_namespace
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, namespace?]
  # ======================================================================= #
  # === Set the title, width, height and the font in use.
  # ======================================================================= #
  title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
  if use_gtk3?
    handle_CSS_rules
  end
  infer_the_size_automatically
  # ======================================================================= #
  # === @object_rbackup
  # ======================================================================= #
  # @object_rbackup  = BackupParadise::Backup.new(nil, :do_not_run_yet)
  # ======================================================================= #
  # === @object_hdd_info
  # ======================================================================= #
  # @object_hdd_info = ::Gtk::InformationAboutTheHarddisc.new
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.

#


231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 231

def reset_the_shared_module
  # ======================================================================= #
  # === @file_chooser_dialog
  # ======================================================================= #
  @file_chooser_dialog = nil
  # ======================================================================= #
  # === @dataset_from_the_config_file
  # ======================================================================= #
  @dataset_from_the_config_file = nil
  if File.exist? BackupParadise.file_config?
    @dataset_from_the_config_file = YAML.load_file(BackupParadise.file_config?)
  end
end

#return_backup_complete_messageObject

#

return_backup_complete_message

#


342
343
344
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 342

def return_backup_complete_message
  'Backup complete! Time finish at: '+time_now?
end

#runObject

#

run (run tag)

#


800
801
802
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 800

def run
  run_super
end

#run_file_chooser_dialog(_ = @file_chooser_dialog) ⇒ Object

#

run_file_chooser_dialog

#


349
350
351
352
353
354
355
356
357
358
359
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 349

def run_file_chooser_dialog(
    _ = @file_chooser_dialog
  )
  if _ and (_.run == ::Gtk::ResponseType::ACCEPT)
    filename = _.filename
    e "filename = #{filename}"
    e "uri = #{_.uri}"
    entry_left?.set_text(filename)
    @file_chooser_dialog.destroy
  end
end

#scan_for_mountpoints_then_update_the_appropriate_combo_boxObject

#

scan_for_mountpoints_then_update_the_appropriate_combo_box

#


777
778
779
780
781
782
783
784
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 777

def scan_for_mountpoints_then_update_the_appropriate_combo_box
  if Object.const_defined? :Mountpoints
    @combo_box_backup_onto.clear_old_datapoints
    @combo_box_backup_onto.populate(Mountpoints[])
    @combo_box_backup_onto.the_first_entry_is_active
    sync_the_second_entry
  end
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


198
199
200
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 198

def smaller_font?
  SMALLER_FONT
end

#sync_the_combo_box_values_onto_the_entries_belowObject

#

sync_the_combo_box_values_onto_the_entries_below

#


741
742
743
744
745
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 741

def sync_the_combo_box_values_onto_the_entries_below
  _ = @combo_box_backup_from.text?.to_s
  entry1?.set_text(_)
  sync_the_second_entry
end

#sync_the_second_entryObject

#

sync_the_second_entry

#


750
751
752
753
754
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 750

def sync_the_second_entry
  entry2?.set_text(
    @combo_box_backup_onto.text?.to_s
  )
end

#time_now?Boolean

#

time_now?

#

Returns:

  • (Boolean)


471
472
473
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 471

def time_now?
  return ::Time.now.strftime('%d.%m.%Y, %H:%M:%S')
end

#update_fdiskObject

#

update_fdisk

Use this if you wanna get new fdisk information.

Or use this:

`fdisk -l`.gsub!(%r[^(!?/dev).*\n], '')
#


212
213
214
# File 'lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb', line 212

def update_fdisk
  return `fdisk -l`.split("\n").delete_if { |line| line !~ /^\/dev/ }.join("\n")
end