Class: Roebe::GUI::UniversalWidgets::MicrosoftController

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

Overview

Roebe::GUI::UniversalWidgets::MicrosoftController

Constant Summary collapse

TITLE =
#

TITLE

#
'Microsoft Controller'
WIDTH =
#

WIDTH

#
:max_width
HEIGHT =
#

HEIGHT

#
:max_height
USE_THIS_FONT =
#

USE_THIS_FONT

#
:dejavu_condensed_20
LARGER_FONT =
#

LARGER_FONT

#
:hack_25
SMALLER_FONT =
#

SMALLER_FONT

#
:hack_20

Constants inherited from Base

Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #show_help, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow

Methods included from Base::CommandlineArguments

#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ MicrosoftController

#

initialize

#


64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 64

def initialize(
    commandline_arguments = nil,
    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
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Roebe::GUI::UniversalWidgets::MicrosoftController[]

#


544
545
546
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 544

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

.run(i = ARGV) ⇒ Object

#

Roebe::GUI::Gtk::MicrosoftController.run

#


527
528
529
530
531
532
533
534
535
536
537
538
539
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 527

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::Roebe::GUI::Gtk::MicrosoftController.new(i)
  r = ::Gtk.run
  _.set_parent_widget(r) # Must come before we enable the key-combinations.
  r << _
  r.automatic_size_then_automatic_title
  r.enable_quick_exit
  r.set_background :white
  r.top_left_then_run
end

Instance Method Details

#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.

#


259
260
261
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 259

def backup_ingrid_directory
  BackupParadise::Windows.backup_ingrid_directory
end

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


146
147
148
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 146

def border_size?
  2
end

#connect_the_skeletonObject

#

connect_the_skeleton (connect tag)

#


420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 420

def connect_the_skeleton
  abort_on_exception

  outer_vbox = create_vbox
  
  outer_vbox.add_hsep
  outer_vbox.minimal(hbox(@button_run_iroebe))
  outer_vbox.add_hsep
  outer_vbox.minimal(hbox(@button_cmd_exe))
  outer_vbox.add_hsep
  hbox1 = padded_hbox
  hbox1.group_maximal(
    @button_enable_autologin,
    @button_enable_wsl,
    @button_copy_doskey_file
  )
  outer_vbox.minimal(hbox1)
  outer_vbox.add_hsep
  hbox3 = padded_hbox
  hbox3.group_maximal(
    @button_install_xvid,
    @button_install_thunderbird,
    @button_install_nsis,
    @button_install_python,
    @button_install_xampp
  )
  outer_vbox.minimal(hbox3)
  outer_vbox.add_hsep
  # ======================================================================= #
  # Add the "system()" invocation entry next
  # ======================================================================= #
  hbox2 = padded_hbox
  hbox2.maximal(text('Run the following system command: '))
  hbox2.group_maximal(@system_command_entry, @button_invoke_system)
  outer_vbox.minimal(hbox2)
  outer_vbox.minimal(@button_backup_ingrid)
  hbox_containing_entry_for_creating_a_new_html_file = create_hbox
  hbox_containing_entry_for_creating_a_new_html_file.minimal(
    text('Specify the target directory to gather all '\
    'images into a .html file ')
  )
  entry_containing_the_path_to_the_directory = entry('C:\ingrid')
  hbox_containing_entry_for_creating_a_new_html_file.maximal(
    entry_containing_the_path_to_the_directory, 1
  )
  button_create_a_new_html_file = button('New .html file')
  button_create_a_new_html_file.on_clicked {
    target = entry_containing_the_path_to_the_directory.text?.to_s
    if File.directory? target
      e 'Now trying to create a new .html file containing images from'
      e '`'+target+'`.'
      begin
        require 'cyberweb/utility_scripts/images_to_html/images_to_html.rb'
        _ = Cyberweb::ImagesToHtml.new(target)
        output_file = _.output_file?
        set_output_file_from_the_new_HTML_file(output_file)
      rescue LoadError => error
        pp error
      end
    end
  }
  hbox_containing_entry_for_creating_a_new_html_file.minimal(
    button_create_a_new_html_file
  )
  vbox1 = vbox
  vbox1.minimal(hbox_containing_entry_for_creating_a_new_html_file)
  vbox1.minimal(@entry_result_of_the_HTML_created_file)
  outer_vbox.minimal(vbox1)

  # ======================================================================= #
  # Next add two more buttons, one being the quit-button:
  # ======================================================================= #
  hbox_on_bottom = padded_hbox
  hbox_on_bottom.group_maximal(@button_quit)
  outer_vbox.minimal(
    LibuiParadise.draw_rectangle(width?, 30, :steelblue)
  ) if use_libui?
  outer_vbox.add_hsep
  outer_vbox.minimal(hbox_on_bottom)
  outer_vbox.add_hsep
  outer_vbox.add(
    LibuiParadise.draw_rectangle(width?, 30, :steelblue)
  ) if use_libui?
  outer_vbox.add_hsep

  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_doskey_fileObject

#

copy_doskey_file

#


171
172
173
174
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 171

def copy_doskey_file
  doskey_file = '/home/x/programming/ruby/src/roebe/lib/roebe/windows/doskey.md'
  copy_file(doskey_file, '/') # Copy it onto the root.
end

#create_the_buttonsObject

#

create_the_buttons (buttons tag, button tag)

#


286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 286

def create_the_buttons 
  # ======================================================================= #
  # === Enable WSL
  # ======================================================================= #
  @button_enable_wsl = return_enable_wsl_button
  # ======================================================================= #
  # === Quit button
  # ======================================================================= #
  @button_quit = quit_button { :with_emoji }
  # ======================================================================= #
  # === Enable autologin button
  # ======================================================================= #
  @button_enable_autologin = return_button_enable_autologin
  # ======================================================================= #
  # === Install xvid button
  # ======================================================================= #
  @button_install_xvid = return_button_install_xvid
  # ======================================================================= #
  # === Install thunderbird button
  # ======================================================================= #
  @button_install_thunderbird = return_button_install_thunderbird
  # ======================================================================= #
  # === Install nsis button
  # ======================================================================= #
  @button_install_nsis = return_button_install_nsis
  # ======================================================================= #
  # === @button_install_python
  # ======================================================================= #
  @button_install_python = return_button_install_python
  # ======================================================================= #
  # === @button_install_xampp
  # ======================================================================= #
  @button_install_xampp = return_button_install_xampp
  # ======================================================================= #
  # === Enable iroebe button
  # ======================================================================= #
  @button_run_iroebe = return_run_iroebe_button
  # ======================================================================= #
  # === Enable cmd.exe button
  # ======================================================================= #
  @button_cmd_exe = return_cmd_exe_button
  # ======================================================================= #
  # === Copy doskey.md
  # ======================================================================= #
  @button_copy_doskey_file = return_copy_doskey_button
  # ======================================================================= #
  # === @button_invoke_system
  # ======================================================================= #
  @button_invoke_system = button('← _Run it', self, :use_mnemonics) {
    :do_run_the_system_command_entry
  }
  # ======================================================================= #
  # === @button_backup_ingrid
  # ======================================================================= #
  @button_backup_ingrid = button('Backup c:\ingrid')
  @button_backup_ingrid.on_clicked {
    do_backup_ingrid
  }
end

#create_the_entriesObject

#

create_the_entries (entries tag, entry tag)

#


357
358
359
360
361
362
363
364
365
366
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 357

def create_the_entries
  # ======================================================================= #
  # === @system_command_entry
  # ======================================================================= #
  @system_command_entry = create_entry
  # ======================================================================= #
  # === @entry_result_of_the_HTML_created_file
  # ======================================================================= #
  @entry_result_of_the_HTML_created_file = create_entry
end

#create_the_skeletonObject

#

create_the_skeleton (create tag, skeleton tag)

#


278
279
280
281
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 278

def create_the_skeleton
  create_the_buttons
  create_the_entries
end
#
#


153
154
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 153

def do_all_startup_related_actions
end

#do_backup_ingridObject

#

do_backup_ingrid

#


391
392
393
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 391

def do_backup_ingrid
  BackupParadise::Windows.backup_ingrid_directory
end

#do_run_the_system_command_entryObject

#

do_run_the_system_command_entry

#


349
350
351
352
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 349

def do_run_the_system_command_entry
  _ = @system_command_entry.text?
  esystem(_)
end

#favicon?Boolean

#

favicon?

#

Returns:

  • (Boolean)


104
105
106
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 104

def favicon?
  :tabble
end

#handle_CSS_rulesObject

#

handle_CSS_rules (CSS tag)

#


118
119
120
121
122
123
124
125
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 118

def handle_CSS_rules
  use_gtk_paradise_project_css_file
  append_project_css_file
  more_CSS_then_apply_it '


'
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


139
140
141
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 139

def padding?
  0
end

#resetObject

#

reset (reset tag)

#


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 81

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
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

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

#


133
134
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 133

def reset_the_shared_module
end

#return_button_enable_autologinObject

#

return_button_enable_autologin

#


159
160
161
162
163
164
165
166
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 159

def return_button_enable_autologin
  button = button('Enable autologin')
  button.on_clicked {
    esystem 'netplwiz'
  }
  button.use_this_font = USE_THIS_FONT
  return button
end

#return_button_install_nsisObject

#

return_button_install_nsis

#


234
235
236
237
238
239
240
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 234

def return_button_install_nsis
  button = button('Install nsis')
  button.on_clicked {
    esystem '/home/x/src/windows/nsis/nsis-3.08-setup.exe'
  }
  return button
end

#return_button_install_pythonObject

#

return_button_install_python

#


201
202
203
204
205
206
207
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 201

def return_button_install_python
  button = button('Install python 🐍')
  button.on_clicked {
    esystem '/home/x/src/windows/python/python-3.10.2-amd64.exe'
  }
  return button
end

#return_button_install_thunderbirdObject

#

return_button_install_thunderbird

#


212
213
214
215
216
217
218
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 212

def return_button_install_thunderbird
  button = button('Install thunderbird')
  button.on_clicked {
    esystem '/home/x/src/windows/thunderbird/Thunderbird_Setup_91.5.0-64bit.msi'
  }
  return button
end

#return_button_install_xamppObject

#

return_button_install_xampp

#


223
224
225
226
227
228
229
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 223

def return_button_install_xampp
  button = button('Install XAMPP')
  button.on_clicked {
    esystem '/home/x/src/windows/xampp/xampp-windows-x64-8.1.2-0-VS16-installer.exe'
  }
  return button
end

#return_button_install_xvidObject

#

return_button_install_xvid

#


190
191
192
193
194
195
196
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 190

def return_button_install_xvid
  button = button('Install xvid')
  button.on_clicked {
    esystem '/home/x/src/windows/xvid/Xvid-1.3.7-20191228.exe'
  }
  return button
end

#return_cmd_exe_buttonObject

#

return_cmd_exe_button

#


245
246
247
248
249
250
251
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 245

def return_cmd_exe_button
  button = button('Run cmd.exe')
  button.on_clicked {
    esystem 'cmd.exe'
  }
  return button
end

#return_copy_doskey_buttonObject

#

return_copy_doskey_button

#


179
180
181
182
183
184
185
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 179

def return_copy_doskey_button
  button = button('Copy doskey.md file')
  button.on_clicked {
    copy_doskey_file
  }
  return button
end

#return_enable_wsl_buttonObject

#

return_enable_wsl_button

#


398
399
400
401
402
403
404
405
406
407
408
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 398

def return_enable_wsl_button
  button = button('Enable wsl')
  button.on_clicked {
    esystem 'dism.exe /online /enable-feature '\
            '/featurename:VirtualMachinePlatform /all /norestart'
    esystem 'dism.exe /online /enable-feature '\
            '/featurename:Microsoft-Windows-Subsystem-Linux /all /norestart'
  }
  # button.use_this_font = :hack_28
  return button
end

#return_run_iroebe_button(emoji_to_use = '🐟') ⇒ Object

#

return_run_iroebe_button

#


371
372
373
374
375
376
377
378
379
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 371

def return_run_iroebe_button(
    emoji_to_use = '🐟' # Tulip would be: 🌷
  )
  button = button("Run #{emoji_to_use} iroebe #{emoji_to_use}")
  button.on_clicked {
    Roebe::Update.new
  }
  return button
end

#runObject

#

run (run tag)

#


413
414
415
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 413

def run
  run_super
end

#set_output_file_from_the_new_HTML_file(i) ⇒ Object

#

set_output_file_from_the_new_HTML_file

#


266
267
268
269
270
271
272
273
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 266

def set_output_file_from_the_new_HTML_file(i)
  # ======================================================================= #
  # Try cd-operations too in this case:
  # ======================================================================= #
  cd '/tmp' if File.directory?('/tmp') # Fail-safe directory first.
  cd '/ingrid' if File.directory?('/ingrid')
  @entry_result_of_the_HTML_created_file.set_text(i.to_s)
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


111
112
113
# File 'lib/roebe/gui/universal_widgets/microsoft_controller/microsoft_controller.rb', line 111

def smaller_font?
  SMALLER_FONT
end