Class: RBT::GUI::UniversalWidgets::Statistics

Inherits:
Base show all
Includes:
UniversalWidgets::BaseModule
Defined in:
lib/rbt/gui/universal_widgets/statistics/statistics.rb

Overview

RBT::GUI::UniversalWidgets::Statistics

Constant Summary collapse

USE_THESE_CSS_RULES =
#

USE_THESE_CSS_RULES

#
'
treeview.view header button {
  font-size: 1.2em;
  color: steelblue;
  background: lightblue;
  font-weight: bold;
  text-shadow: none;
  box-shadow:  none;
  border: 1px solid black;
}'
EXPLANATION_ABOUT_THE_PURPOSE_OF_THIS_WIDGET =
#

EXPLANATION_ABOUT_THE_PURPOSE_OF_THIS_WIDGET

#
"This widget shows some information as to how long it took\n"\
"to compile different programs on the given computer system,\n"\
"in seconds and in minutes."
TITLE =
#

TITLE

#
'Statistics about the RBT project'
WIDTH =
#

WIDTH

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

HEIGHT

#
'40% or minimum 300px'
USE_THIS_FONT =
#

USE_THIS_FONT

#
:dejavu_condensed_20
LARGER_FONT =
#

LARGER_FONT

#
:dejavu_condensed_22
SMALLER_FONT =
#

SMALLER_FONT

#
:dejavu_condensed_18

Constants inherited from LeanPrototype

LeanPrototype::ALL_COLOUR_METHODS, LeanPrototype::ARRAY_KDE_KONSOLE_COLOURS_IN_USE, LeanPrototype::DAY_NAMES, LeanPrototype::NAMESPACE, LeanPrototype::SILENT_REDIRECTION

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#cat, #cd_back_to_the_current_working_directory, #consider_reporting_how_many_programs_are_registered, #cookbook_files?, #copy_recursively, #delete_code_of_conduct?, #determine_appdir_prefix_from_this_input, #directory_validation?, #do_not_show_names, #fast_return_file_size_of_this_program, #file_last_symlinked_program?, #file_programs_version_url, #gem_version, #is_a_64bit_system?, #is_ccache_available?, #is_porg_available?, #is_this_binary_registered?, #is_this_program_included?, #make_command?, #make_install_command?, #new_cookbook_instance_for, #program_exists?, #publish_list_of_all_programs_version, #rcp, registered_binaries?, #remove_symlink, #rename_kde_konsole_tab, #repackage, #report_n_programs, #report_working_directory, #return_compile_time_statistics, #return_n_random_characters, #return_version_of_this_program, #run_make_then_make_install, #sanitize_url1_entry, #set_source_directory, #show_overview_over_available_utility_scripts, #symlink_all_files_from_this_directory_to_that_directory, #system_tags?, #upload_list_of_all_programs_version, #use_yaml_database_for_tags?, #warn_and_exit, #wget

Methods inherited from LeanPrototype

#a_or_an?, #abbreviations?, #absolute_path, #action, #add_to_the_commandline_arguments, #all_binaries?, #all_files_from, #all_libraries?, #allowed_cookbook_entries?, #appdir_location_of?, #append_onto_the_internal_hash, #append_what_into, #archive_type_of?, #available_programs?, #be_quiet?, #be_verbose?, #begins_with_a_comment?, #capitalize_first_alphabetical_character, #cd_to_the_log_directory, #cd_to_the_temp_directory, #change_directory, #change_permission, #cheering_person?, #chmod, #chop_off_archive, #clear_commandline_options, #cliner, #coloured_and_padded_e, #coloured_and_padded_esystem, #coloured_esystem, #colourize_directory_for_system_results, #colourize_this_error, #colourize_this_file_path, #colourize_this_warning, #commandline_arguments?, #commandline_arguments_without_hyphens?, #comment, #convert_dd_mm_yyyy_to_its_long_variant, #convert_env_variable, #copy_directory, #copy_files, #cpr, #create_directory, #current_hour?, #dd_mmm_yyy, #debug, #debug?, #directory_expanded_cookbooks?, #disable_colours, #display_md5sum?, #do_not_debug, #does_the_cookbook_include_this_program?, #does_this_expanded_cookbook_file_exist_for_this_program?, #does_this_file_exist?, #does_this_file_exist_and_is_it_a_file?, #e, #eblue, #ecomment, #ecrimson, #edir, #editor?, #efancy, #eimp, #enable_colours, #enable_debug, #ensure_main_encoding_for, #eparse, #esystem, #esystem_gold, #etomato, #ewarn, #exit_program, #expanded_cookbooks_directory_exists?, #extract_this_archive, #extract_to?, #file_compiled_programs?, #file_dirname_retaining_trailing_slash, #file_predefined_installation_instructions?, #file_specification_of_registered_cookbook_entries, #find_cookbook_alias_for, #find_this_yaml_file, #first_argument?, #first_non_hyphen_argument?, #get_all_directories_from, #get_all_files_from, #get_all_programs, #get_date, #get_extended_date, #get_files_and_directories_from, #go_to_base_dir, #home_dir?, #host_system?, #infer_the_namespace, #internal_hash?, #internal_hash_set_commandline_arguments, #is_an_archive?, #is_directory?, #is_file?, #is_github_url?, #is_make_available?, #is_on_gobolinux?, #is_on_windows?, #is_roebe?, #is_superuser?, #is_symlink?, #is_this_a_header?, #is_this_a_library?, #is_this_program_included?, #iso_encoding?, #load_dataset_from_this_expanded_cookbook, #load_yaml, #load_yaml_file_from_the_cookbook_directory_for_this_program, #log_directory?, #main_encoding?, #meson_build_file_exists?, #months?, #move_file, #n_programs_are_available?, #n_programs_available?, #namespace?, #no_directory_exists_at, #no_opn, #no_such_file_exists, #open_in_browser, #open_in_editor, #opncomment, #opne, #opnef, #opnerev, #opnerror, #opnesystem, #opnewarn, #opnfancy, #opnn, #packages_directory?, #path_to_this_expanded_cookbooks_dataset, #pkgconfig_directory?, #populate_the_internal_hash_with_default_values, #predefined_installation_instructions?, #prepend_this_commandline_argument, #program_version_of?, #project_base_directory?, #project_yaml_directory?, #query_path?, #rarrow?, #read_file, #read_file_in_default_encoding, #read_file_with_default_encoding, #readlines, #readlines_with_proper_encoding, #register_sigint, #registered_cookbook_entries?, #remove, #remove_archive_from_the_end, #remove_comments_from_each_line, #remove_directory, #remove_double_slashes, #remove_file, #remove_newlines, #remove_parens, #remove_symlink, #remove_this_commandline_argument, #remove_this_entry_from_the_commandline_arguments, #remove_trailing_ANSII_escape_code, #remove_unnecessary_data_from_url, #rename, #report_pwd, #require_the_rbt_aliases, #reset_the_internal_hash, #return_all_archives_from_this_directory, #return_appdir_prefix, #return_commandline_arguments_with_leading_hyphens, #return_current_hour_minutes_second, #return_date, #return_day_of_the_month_based_on_utc, #return_full_time, #return_hours_minutes_seconds_based_on_utc, #return_location_to_this_programs_yaml_file, #return_month_based_on_this_number, #return_month_based_on_utc, #return_opnn, #return_program_information, #return_program_name_for_gobolinux_systems, #return_pwd, #return_unicode_warning_symbol_or_empty_string, #return_utc, #return_utc_time_in_a_format_similar_to_slackware, #return_weekday_based_on_utc, #return_year_based_on_utc, #rev, #run_simulation=, #run_simulation?, #sdir, #sdir_return_pwd, #set_be_silent, #set_be_verbose, #set_first_commandline_argument, #set_namespace, #set_use_opn, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #silently_create_this_directory_if_it_does_not_yet_exist, #simp, #source_base_directory?, #ssym, #stderr, #store_into_this_directory?, #string_right_arrow?, #swarn, #symlink, #sysbin_directory?, #sysetc_directory?, #sysinclude_directory?, #syslib_directory?, #sysshare_directory?, #system_directory?, #temp_directory?, #to_bool, #to_camelcase, #to_iso_encoding, #to_unicode, #today?, #touch, #try_to_require_beautiful_url, #try_to_require_the_environment_information_gem, #try_to_require_the_extracter_gem, #try_to_require_the_open_gem, #try_to_require_the_xorg_buffer, #try_to_require_wget, #try_to_return_a_special_compile_component, #unicode_cliner, #unicode_middle_cliner, #use_colours=, #use_colours?, #use_opn=, #use_opn?, #utf_encoding?, #verbose_truth, #word_wrap, #write_what_into, #write_what_into_via_unicode, #yes_or_no

Constructor Details

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

#

initialize

#


90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 90

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

#

RBT::GUI::UniversalWidgets::Statistics[]

#


487
488
489
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 487

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

.run(i = ARGV) ⇒ Object

#

RBT::GUI::Gtk::Statistics.run

#


470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 470

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::RBT::GUI::Gtk::Statistics.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

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


246
247
248
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 246

def border_size?
  2
end

#connect_the_skeletonObject

#

connect_the_skeleton (connect tag)

#


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
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 423

def connect_the_skeleton
  abort_on_exception

  outer_vbox = create_vbox # A new vbox.

  style_the_treeview_properly
  make_the_treeview_sortable
  on_right_mouse_button_deselect_the_treeview_selection
  container_for_the_treeview = vbox
  container_for_the_treeview.maximal(@treeview, 10)
  @scrolled_window.add(container_for_the_treeview)
  @scrolled_window.set_size_request(820, 820)
  info_text = bold_text(EXPLANATION_ABOUT_THE_PURPOSE_OF_THIS_WIDGET)

  outer_vbox.maximal(info_text, 20)
  outer_vbox.maximal(@scrolled_window)

  small_container = create_vbox
  small_container.minimal(@button_update_the_tree_view, 2)
  small_container.hcenter
  # @button_update_the_tree_view.hcenter
  # @button_update_the_tree_view.align_to_center
  #_.minimal(small_container)
  outer_vbox.minimal(small_container, 12)

  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

#create_the_buttonsObject

#

create_the_buttons (buttons tag)

#


310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 310

def create_the_buttons
  # ======================================================================= #
  # === @button_update_the_tree_view
  # ======================================================================= #
  @button_update_the_tree_view = bold_button(
    '_Update the above listing'
  ) { :use_mnemonics }
  @button_update_the_tree_view.hint = 'Click '\
    'on this button to update the tree-view data above.'
  @button_update_the_tree_view.remove_background
  @button_update_the_tree_view.on_hover(:lightgreen)
  @button_update_the_tree_view.bblack1
  @button_update_the_tree_view.on_clicked {
    do_prepare_the_list_store
  }
end

#create_the_liststoreObject

#

create_the_liststore

#


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

def create_the_liststore
  @list_store = ::Gtk::ListStore.new(#gtk_list_store(
    String,
    String,
    String,
    String
  )
end

#create_the_scrolled_windowObject

#

create_the_scrolled_window

#


156
157
158
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 156

def create_the_scrolled_window
  @scrolled_window = create_scrolled_window { :automatic }
end

#create_the_skeletonObject

#

create_the_skeleton (create tag, skeleton tag)

#


406
407
408
409
410
411
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 406

def create_the_skeleton
  create_the_liststore
  create_the_buttons
  create_the_scrolled_window
  create_the_treeview
end

#create_the_treeviewObject

#

create_the_treeview

#


292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 292

def create_the_treeview
  # ======================================================================= #
  # === @treeview
  # ======================================================================= #
  @treeview = tree_view
  @treeview.the_headers_are_clickable
  @treeview.enable_search # Enable searching.
  @treeview.rubber_banding
  @treeview.enable_drag_and_drop
  @treeview.all_are_sortable
  @treeview.allow_resizing
  @treeview.set_reorderable(true)
  @treeview.set_size_request(500, 800)
end
#
#


253
254
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 253

def do_all_startup_related_actions
end

#do_prepare_the_list_store(i = @list_store) ⇒ Object Also known as: populate

#

do_prepare_the_list_store

#


192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 192

def do_prepare_the_list_store(
    i = @list_store
  )
  # ======================================================================= #
  # Define the dataset that is to be used for this widget.
  # ======================================================================= #
  use_this_dataset = return_time_sorted_dataset
  index = 0
  use_this_dataset.each {|name_of_the_program, compile_time| index += 1
    iter = i.append
    iter.set_value(0, index.to_s.rjust(2, ' '))
    iter.set_value(1, name_of_the_program)
    _ = ('%.2f' % compile_time.round(2)).rjust(10,' ')
    iter.set_value(2, _)
    # ===================================================================== #
    # Next, set the time in n minutes
    # ===================================================================== #
    new_value = (_.strip.to_f / 60.0).round(2).to_s
    new_value = '%.2f' % new_value.to_f
    iter.set_value(
      3,
      new_value
    )
  }
end

#favicon?Boolean

#

favicon?

#

Returns:

  • (Boolean)


142
143
144
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 142

def favicon?
  :tabble
end

#handle_CSS_rulesObject

#

handle_CSS_rules (CSS tag)

#


221
222
223
224
225
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 221

def handle_CSS_rules
  use_gtk_paradise_project_css_file
  append_project_css_file
  more_CSS_then_apply_it(USE_THESE_CSS_RULES)
end

#hash?Boolean

#

hash?

#

Returns:

  • (Boolean)


259
260
261
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 259

def hash?
  @compile_time_statistics
end

#list_store?Boolean

#

list_store?

#

Returns:

  • (Boolean)


278
279
280
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 278

def list_store?
  @list_store
end

#make_the_treeview_sortableObject

#

make_the_treeview_sortable

#


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

def make_the_treeview_sortable
  columns = @treeview.columns?
  
  columns[0].sortable_based_on(0)
  columns[0].align_to_the_center
  columns[1].sortable_based_on(1)
  columns[1].align_to_the_center
  columns[2].sortable_based_on(2)
  columns[2].align_to_the_center
  columns[3].sortable_based_on(3)
  columns[3].align_to_the_center

  # ======================================================================= #
  # Use a custom sort-function next.
  # ======================================================================= #
  list_store?.set_sort_func(2) { |_model, iter1, iter2|
    iter2[2].to_f <=> iter1[2].to_f
  }
  # ======================================================================= #
  # Sort the minutes as well.
  # ======================================================================= #
  list_store?.set_sort_func(3) { |_model, iter1, iter2|
    iter2[3].to_f <=> iter1[3].to_f
  }
end

#on_right_mouse_button_deselect_the_treeview_selectionObject

#

on_right_mouse_button_deselect_the_treeview_selection

#


394
395
396
397
398
399
400
401
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 394

def on_right_mouse_button_deselect_the_treeview_selection
  treeview?.on_button_press_event { |widget, event|
    case event.button
    when 3 # Right-mouse button was clicked here.
      treeview?.deselect
    end
  }
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


239
240
241
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 239

def padding?
  0
end

#resetObject

#

reset (reset tag)

#


107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 107

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
  # ======================================================================= #
  # === @compile_time_statistics
  #
  # The next instance-variable is a Hash. We will tap into class Shell
  # for this information.
  # ======================================================================= #
  @compile_time_statistics =
    ::RBT::Installer::Shell.new(:dont_run_yet).return_compile_time
  if @compile_time_statistics.nil?
    e 'No statistics were found. Exiting now.'
    exit
  end
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

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

#


233
234
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 233

def reset_the_shared_module
end

#return_time_sorted_datasetObject

#

return_time_sorted_dataset

#


330
331
332
333
334
335
336
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 330

def return_time_sorted_dataset
  _ = hash?
  _ = _.sort_by {|name, time|
    time
  }.reverse
  _
end

#runObject

#

run (run tag)

#


416
417
418
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 416

def run
  run_super
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


149
150
151
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 149

def smaller_font?
  SMALLER_FONT
end

#style_the_treeview_properlyObject

#

style_the_treeview_properly

#


341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
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
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 341

def style_the_treeview_properly
  # ======================================================================= #
  # Create a new GtkCellRendererText, add it to the tree
  # view column and append the column to the tree view.
  # ======================================================================= #
  renderer = cell_renderer_text
  renderer.foreground = '#0c087d' # This is a darkblue colour.
  renderer_centered = centered_cell_renderer_text
  renderer_centered.xalign = 0.5 # Center it here.
  very_left_column = tree_view_column(
    '#', renderer_centered, text: 0
  )
  very_left_column.center
  @treeview.append_column(very_left_column)
  # ======================================================================= #
  # === Name of the program
  # ======================================================================= #
  left_column = tree_view_column(
    'Name of the program', renderer, text: 1
  )
  left_column.set_alignment(0.5)
  @treeview.append_column(left_column)
  renderer = cell_renderer_text
  renderer.foreground = '#037317' # This is a darkgreen colour.
  # ======================================================================= #
  # === right_column
  # ======================================================================= #
  right_column = tree_view_column(
    'Time (in seconds)', renderer_centered, text: 2
  )
  right_column.alignment = 0.5 
  @treeview.append_column(right_column)
  # ======================================================================= #
  # === righter_column
  # ======================================================================= #
  righter_column = tree_view_column(
    'Time (in minutes)', renderer_centered, text: 3
  )
  @treeview.append_column(righter_column)

  do_prepare_the_list_store(@list_store)
  @treeview.model = @list_store
  @treeview.on_button_press_event { |widget, event|
    if double_click?(event) # Act on double-click events.
      selected = @treeview.selection.selected[1]
      e ::Colours.steelblue(selected)
    end
  }
end

#treeview?Boolean

#

treeview?

#

Returns:

  • (Boolean)


285
286
287
# File 'lib/rbt/gui/universal_widgets/statistics/statistics.rb', line 285

def treeview?
  @treeview
end