class EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformation

Constants

HEIGHT
#

HEIGHT

#
WIDTH
#

WIDTH

#

Public Class Methods

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

EnvironmentInformation::GUI::UniversalWidgets::EnvironmentInformation[]

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 385
def self.[](i = ARGV)
  new(i)
end
height() click to toggle source
#

EnvironmentInformation::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.height

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 289
def self.height
  HEIGHT
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
Calls superclass method
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 42
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
#

EnvironmentInformation::GUI::Gtk::EnvironmentInformation.run

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 368
def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.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
width() click to toggle source
#

EnvironmentInformation::EnvironmentInformation::GUI::Gtk::EnvironmentInformation.width

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 282
def self.width
  WIDTH
end

Public Instance Methods

add_status_icon() click to toggle source
#

add_status_icon

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 176
def add_status_icon
  if use_gtk3?
    _ = create_status_icon(:dialog_info)
    # ======================================================================= #
    # Add a menu and a quit-button too.
    # ======================================================================= #
    menu = create_menu
    quit = create_image_menu_item(:quit)
    quit.on_activate { ::Gtk.main_quit }
    menu.append(quit)
    menu.show_all
    _.signal_connect(:popup_menu) { |icon, button, time|
      menu.popup(nil, nil, button, time)
    }
    return _
  end
end
connect_the_skeleton() click to toggle source
#

connect_the_skeleton (connect tag)

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 302
def connect_the_skeleton
  abort_on_exception

  outer_vbox = create_vbox

  # ======================================================================= #
  # Append the information contained in our @data variable to the
  # ListStore object next. This will yield an Array.
  # ======================================================================= #
  do_update_the_main_content_of_the_widget
  @tree_view.append('Name',    @renderer, text: 0)
  @tree_view.append('Version', @renderer, text: 1)
  @tree_view.the_headers_are_clickable
  @tree_view.is_sortable
  @tree_view.on_key_press_event { |w, event|
    case Gdk::Keyval.to_name(event.keyval)
    when 'Return','KP_Enter'
      e currently_selected
    end
  }
  vbox = create_vbox
  vbox.add(@toolbar)
  @scrolled_window = create_scrolled_window(@tree_view)
  @scrolled_window.set_size_request(600, 600)
  vbox.maximal(@scrolled_window, 2)
  outer_vbox.maximal(vbox)
  outer_vbox.minimal(add_status_icon) if use_gtk3?

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

create_the_skeleton (create tag, skeleton tag)

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 352
def create_the_skeleton
  create_the_toolbar
  create_the_tree_view
  @renderer = create_cell_renderer_text
end
create_the_toolbar() click to toggle source
#

create_the_toolbar

This will create the toolbar on top of the widget.

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 89
def create_the_toolbar
  @toolbar = create_toolbar
  # ======================================================================= #
  # (1) Add the refresh-button next.
  # ======================================================================= #
  button_refresh = create_button(:refresh)
  button_refresh.no_relief
  button_refresh.on_clicked {
    do_update_the_main_content_of_the_widget
  }
  button_refresh.hint = '<b>Click</b> on this button in order to '\
                        'refresh the information shown below.'
  @toolbar << button_refresh
  # ======================================================================= #
  # (2) Add a pin-emoji next, to assign to the xorg-buffer upon clicking
  #     on it.
  # ======================================================================= #
  pin_emoji = emoji(:pin)
  event_box_for_the_pin_emoji = event_box(pin_emoji)
  event_box_for_the_pin_emoji.on_clicked {
    do_assign_the_current_selection_to_the_xorg_buffer
  }
  pin_emoji.hint = '<b>Click</b> on this button to assign the '\
                   'current selection to the xorg-buffer.'
  @toolbar << event_box_for_the_pin_emoji
  # ======================================================================= #
  # (2) This belongs to the pin-emoji actually; the functionality should
  #     be regarded as a "cohesive unit".
  # ======================================================================= #
  @button_assign_to_the_xorg_buffer = button_xorg_buffer(label: 'Xorg')
  @button_assign_to_the_xorg_buffer.no_relief
  @button_assign_to_the_xorg_buffer.on_clicked {
    do_assign_the_current_selection_to_the_xorg_buffer
  }
  @toolbar << @button_assign_to_the_xorg_buffer
end
create_the_tree_view() click to toggle source
#

create_the_tree_view

The TreeView widget is the main widget which allows the user to display environment-related information about installed programs.

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 201
def create_the_tree_view
  @tree_view = ::Gtk::TreeView.new(@list_store) # rf ruby gtk_TreeView
  @tree_view.do_select_multiple # Allow multiple selections.
  @tree_view.use_clickable_headers
  # ======================================================================= #
  # ruby-gtk3
  # ======================================================================= #
  @tree_view.enable_model_drag_source(
    :button1_mask,
    [ ['GTK_TREE_MODEL_ROW', 0, 0] ],
    Gdk::DragAction::COPY|Gdk::DragAction::MOVE
  )
  @tree_view.enable_model_drag_dest([
    ['GTK_TREE_MODEL_ROW', 0, 0] ],
    Gdk::DragAction::COPY|Gdk::DragAction::MOVE
  )
  @tree_view.signal_connect(:row_activated) {
    # puts "hello"
  } 
  # ========================================================================= #
  # Respond to mouse-button press events. This is currently not in use
  # really.
  # ========================================================================= #
  @tree_view.on_button_press_event { |widget, event|
    if mouse_button_double_click?(event)
      # e 'MouseButton: double click event.'
      # ^^^ Currently we do not handle this event.
    elsif left_mouse_button_clicked?(event)
      # e 'MouseButton: left-click event (once).'
    elsif right_mouse_button_clicked?(event)
      # e 'MouseButton: right-click event (once).'
    end
  }
  @tree_view.selection.set_mode(::Gtk::SelectionMode::MULTIPLE)
  @tree_view.selection.signal_connect(:changed) {|entry|
    entry.each {|model, path, inner_array|
      if @display_information_on_the_commandline
        if inner_array[0]
          name_of_the_program  = inner_array[0].strip
        else
          name_of_the_program  = '(unknown'
        end
        version_of_the_program = inner_array[1]
        result = Colours.steelblue(
          name_of_the_program.ljust(25)
        ).dup
        if ::EnvironmentInformation.is_this_a_registered_program?(name_of_the_program)
          result << 'Version: '
        end
        result << Colours.lightgreen(version_of_the_program.to_s)
        e result
      end
    }
  }
  @tree_view.resizable_headers
end
currently_selected() click to toggle source
#

currently_selected

Will show both key and version.

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 131
def currently_selected
  _ = ''.dup
  if @tree_view and @tree_view.selection
    @tree_view.selection.selected_each {|list_store, tree_path, tree_iter|
      if tree_iter[0]
        name_of_the_program = tree_iter[0].strip
      else
        name_of_the_program = 'unknown'
      end
      version_of_the_program = tree_iter[1]
      _ << "#{name_of_the_program} #{version_of_the_program}"
    }
  end
  return _
end
do_assign_the_current_selection_to_the_xorg_buffer( i = return_the_current_selection_of_the_treeview_widget ) click to toggle source
#

do_assign_the_current_selection_to_the_xorg_buffer

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 150
def do_assign_the_current_selection_to_the_xorg_buffer(
    i = return_the_current_selection_of_the_treeview_widget
  )
  @button_assign_to_the_xorg_buffer.attach(i)
end
do_update_the_main_content_of_the_widget() click to toggle source
#

do_update_the_main_content_of_the_widget

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 159
def do_update_the_main_content_of_the_widget
  assign_the_environment_information_dataset_to_the_data_variable
  @list_store.clear
  @data.each {|line|
    name, version = *line # Decompose line.
    iter = @list_store.append
    if version.nil? or version.to_s.empty?
      version = '[Not installed.]'
    end
    iter.set_value(0, name)
    iter.set_value(1, version)
  }
end
handle_CSS_rules() click to toggle source
#

handle_CSS_rules (CSS tag)

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 261
  def handle_CSS_rules
    use_gtk_paradise_project_css_file
    append_project_css_file
    more_CSS_then_apply_it '


'
  end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 59
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, "Mono #{FONT_SIZE}")
  if use_gtk3?
    handle_CSS_rules
  end
  infer_the_size_automatically
  reset_the_variables
  # ======================================================================= #
  # === @list_store
  # ======================================================================= #
  @list_store = ::Gtk::ListStore.new(String, String)
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/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 276
def reset_the_shared_module
end
return_the_current_selection_of_the_treeview_widget()
Alias for: currently_selected
run() click to toggle source
#

run (run tag)

#
# File lib/environment_information/gui/universal_widgets/environment_information/environment_information.rb, line 361
def run
  run_super
end
Also aliased as: start_gui_application
start_gui_application()
Alias for: run