class RBT::GUI::Gtk::Statistics
Constants
- HEIGHT
#¶ ↑
HEIGHT
¶ ↑#¶ ↑
- TITLE
#¶ ↑
TITLE
¶ ↑#¶ ↑
- USE_THIS_FONT
#¶ ↑
USE_THIS_FONT
¶ ↑#¶ ↑
- WIDTH
#¶ ↑
WIDTH
¶ ↑#¶ ↑
Public Class Methods
new( commandline_arguments = ARGV, run_already = true )
click to toggle source
run( i = ARGV )
click to toggle source
#¶ ↑
RBT::GUI::Gtk::Statistics.run
¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/statistics/statistics.rb, line 385 def self.run( i = ARGV ) require 'gtk_paradise/app/app.rb' _ = ::RBT::GUI::Gtk::Statistics.new(i) r = ::Gtk.run r << _ r.automatic_size_then_automatic_title r.enable_quick_exit r.top_left_then_run end
Public Instance Methods
border_size?()
click to toggle source
connect_skeleton()
click to toggle source
#¶ ↑
connect_skeleton
(connect tag)¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/statistics/statistics.rb, line 356 def connect_skeleton abort_on_exception 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 = text( "This widget shows some information as to how long it took\n"\ "to compile different programs on the given computer system." ) outer_vbox = vbox # A new vbox. outer_vbox.maximal(info_text, 20) outer_vbox.maximal(@scrolled_window) small_container = 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) minimal(outer_vbox) end
create_liststore()
click to toggle source
create_scrolled_window()
click to toggle source
create_skeleton()
click to toggle source
create_treeview()
click to toggle source
#¶ ↑
create_treeview
¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/statistics/statistics.rb, line 162 def create_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/gtk/statistics/statistics.rb, line 312 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, populate
handle_custom_CSS()
click to toggle source
#¶ ↑
handle_custom_CSS
(CSS tag, CSS rules)¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/statistics/statistics.rb, line 98 def handle_custom_CSS use_gtk_paradise_project_css_file more_CSS ' 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; }' end
hash?()
click to toggle source
list_store?()
click to toggle source
make_the_treeview_sortable()
click to toggle source
#¶ ↑
make_the_treeview_sortable
¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/statistics/statistics.rb, line 283 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
padding?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/statistics/statistics.rb, line 68 def reset 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) handle_custom_CSS 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
return_time_sorted_dataset()
click to toggle source
run()
click to toggle source
style_the_treeview_properly()
click to toggle source
#¶ ↑
style_the_treeview_properly
¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/statistics/statistics.rb, line 211 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