class RBT::GUI::Gtk::CompileShellStatistics

Public Class Methods

new() click to toggle source
#

initialize

#
Calls superclass method
# File lib/rbt/gui/gtk/compile_shell_statistics.rb, line 29
def initialize
  super()
  set_policy(
    ::Gtk::POLICY_AUTOMATIC, ::Gtk::POLICY_AUTOMATIC
  )
  reset
  run
end

Public Instance Methods

hash?() click to toggle source
#

hash?

#
# File lib/rbt/gui/gtk/compile_shell_statistics.rb, line 53
def hash?
  @compile_time_statistics
end
height?() click to toggle source
#

height?

#
# File lib/rbt/gui/gtk/compile_shell_statistics.rb, line 121
def height?
  520
end
reset() click to toggle source
#

reset

#
# File lib/rbt/gui/gtk/compile_shell_statistics.rb, line 41
def reset
  # ======================================================================= #
  # The next instance-variable is a Hash.
  # ======================================================================= #
  @compile_time_statistics =
    ::RBT::Compile::Shell.new(:dont_run_yet).return_compile_time
  set_gtk_font_size(:default)
end
return_time_sorted_dataset() click to toggle source
#

return_time_sorted_dataset

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

run

#
# File lib/rbt/gui/gtk/compile_shell_statistics.rb, line 71
def run
  treeview = gtk_tree_view
  # treeview.selection.mode = ::Gtk::SELECTION_MULTIPLE
  treeview.headers_clickable = true
  # ======================================================================= #
  # Create a new GtkCellRendererText, add it to the tree
  # view column and append the column to the tree view.
  # ======================================================================= #
  renderer = gtk_cell_renderer_text
  renderer.foreground = '#0c087d' # This is a darkblue colour.
  column   = ::Gtk::TreeViewColumn.new(
    'Name of the program', renderer,  :text => 0
  )
  column.alignment = 0.5
  treeview.append_column(column)
  renderer = gtk_cell_renderer_text
  renderer.foreground = '#037317' # This is a darkgreen colour.
  column   = ::Gtk::TreeViewColumn.new(
    'Time (in seconds)', renderer, :text => 1
  )
  column.alignment = 0.1
  treeview.append_column(column)

  list_store = ::Gtk::ListStore.new(String, String)
  return_time_sorted_dataset.each {|name_of_the_program, compile_time|
    iter = list_store.append
    iter.set_value(0, name_of_the_program)
    _ = ('%.2f' % compile_time.round(2)).rjust(10,' ')
    iter.set_value(1, _)
  }
  treeview.model = list_store
  treeview.signal_connect(:button_press_event) { |widget, event|
    if event.event_type == Gdk::Event::BUTTON2_PRESS and event.button == 1 # event.event_type.name
      selected = treeview.selection.selected.first
      pp selected  
    end
  }
  add(treeview)
end
width?() click to toggle source
#

width?

#
# File lib/rbt/gui/gtk/compile_shell_statistics.rb, line 114
def width?
  1000
end