class RBT::GUI::UniversalWidgets::Statistics

Constants

EXPLANATION_ABOUT_THE_PURPOSE_OF_THIS_WIDGET
#

EXPLANATION_ABOUT_THE_PURPOSE_OF_THIS_WIDGET

#
HEIGHT
#

HEIGHT

#
LARGER_FONT
#

LARGER_FONT

#
SMALLER_FONT
#

SMALLER_FONT

#
TITLE
#

TITLE

#
USE_THESE_CSS_RULES
#

USE_THESE_CSS_RULES

#
USE_THIS_FONT
#

USE_THIS_FONT

#
WIDTH
#

WIDTH

#

Public Class Methods

[](i = ARGV) click to toggle source
#

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

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 487
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
Calls superclass method RBT::LeanPrototype::new
# 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
run( i = ARGV ) click to toggle source
#

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

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

Public Instance Methods

border_size?() click to toggle source
#

border_size?

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 246
def border_size?
  2
end
connect_the_skeleton() click to toggle source
#

connect_the_skeleton (connect tag)

#
# 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_buttons() click to toggle source
#

create_the_buttons (buttons tag)

#
# 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_liststore() click to toggle source
#

create_the_liststore

#
# 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_window() click to toggle source
#

create_the_scrolled_window

#
# 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_skeleton() click to toggle source
#

create_the_skeleton (create tag, skeleton tag)

#
# 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_treeview() click to toggle source
#

create_the_treeview

#
# 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
do_prepare_the_list_store( i = @list_store ) click to toggle source
#

do_prepare_the_list_store

#
# 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
Also aliased as: populate
favicon?() click to toggle source
#

favicon?

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 142
def favicon?
  :tabble
end
handle_CSS_rules() click to toggle source
#

handle_CSS_rules (CSS tag)

#
# 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?() click to toggle source
#

hash?

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 259
def hash?
  @compile_time_statistics
end
list_store?() click to toggle source
#

list_store?

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 278
def list_store?
  @list_store
end
make_the_treeview_sortable() click to toggle source
#

make_the_treeview_sortable

#
# 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_selection() click to toggle source
#

on_right_mouse_button_deselect_the_treeview_selection

#
# 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?() click to toggle source
#

padding?

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 239
def padding?
  0
end
populate( i = @list_store )
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# 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_module() click to toggle source
#

reset_the_shared_module

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

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 233
def reset_the_shared_module
end
return_time_sorted_dataset() click to toggle source
#

return_time_sorted_dataset

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 330
def return_time_sorted_dataset
  _ = hash?
  _ = _.sort_by {|name, time|
    time
  }.reverse
  _
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 416
def run
  run_super
end
Also aliased as: start_gui_application
smaller_font?() click to toggle source
#

smaller_font?

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 149
def smaller_font?
  SMALLER_FONT
end
start_gui_application()
Alias for: run
style_the_treeview_properly() click to toggle source
#

style_the_treeview_properly

#
# 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?() click to toggle source
#

treeview?

#
# File lib/rbt/gui/universal_widgets/statistics/statistics.rb, line 285
def treeview?
  @treeview
end