module HardwareInformation::GUI::Gtk::PurchasedHardwareModule

Constants

HEIGHT
#

HEIGHT

#
IMG_DIR
#

IMG_DIR

#
N
#

N

#
NAMESPACE
#

NAMESPACE

#
TITLE
#

TITLE

#
USE_THIS_FONT
#

USE_THIS_FONT

#
WIDTH
#

WIDTH

#

Public Class Methods

new( optional_file = nil, run_already = true ) click to toggle source
#

initialize

#
Calls superclass method
# File lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb, line 69
def initialize(
    optional_file = nil,
    run_already   = true
  )
  super(:horizontal)
  reset
  run if run_already
end
run( i = ARGV ) click to toggle source
#

HardwareInformation::GUI::Gtk::PurchasedHardwareModule.run

#
# File lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb, line 272
def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::HardwareInformation::GUI::Gtk::PurchasedHardware.new(i)
  r = ::Gtk.run
  r << _
  r.set_size_request(_.width?, _.height?)
  r.top_left_then_run
end

Public Instance Methods

border_size?() click to toggle source
#

border_size?

#
# File lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb, line 114
def border_size?
  2
end
connect_skeleton() click to toggle source
#

connect_skeleton (connect tag)

#
# File lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb, line 129
def connect_skeleton
  abort_on_exception
  vbox_containing_the_hardware_entries = gtk_vbox
  hbox = gtk_hbox
  hbox.minimal(
    text('♥️ ').red
  )
  hbox.maximal(@header_on_top)
  vbox_containing_the_hardware_entries.add(hbox)
  hbox.add(gtk_horizontal_spacer)
  # ======================================================================= #
  # Next, go through the dataset and add the relevant entries:
  # ======================================================================= #
  dataset = main_dataset?
  dataset.each_pair {|name_of_the_hardware, inner_dataset|
    this_label = h3("# {name_of_the_hardware}")
    if name_of_the_hardware.include? 'id='
      this_label.set_name(
        name_of_the_hardware.scan(/id=(.+)/).flatten.first.to_s
      )
      name_of_the_hardware = Roebe.remove_html(name_of_the_hardware)
      this_label.set_text(name_of_the_hardware)
    end
    this_label.left_align
    this_label.make_bold
    this_label.make_selectable

    mini_vbox_containing_the_description_for_the_hardware_at_hand = gtk_vbox
    _ = ''.dup
    # ===================================================================== #
    # === image or draggable_image:
    #
    # The first entry contains the desired information.
    #
    # Example:
    #
    #   draggable_image:
    #   - HARDWARE/DRUCKER/HP_OfficeJet_Pro_6230.jpg
    #   - mar1em
    #
    # ===================================================================== #
    if inner_dataset.include?('image') or inner_dataset.include?('draggable_image')
      if inner_dataset.has_key?('draggable_image')
        target = IMG_DIR+inner_dataset['draggable_image'][0]
      else
        target = IMG_DIR+inner_dataset['image'][0]
      end
      this_image = gtk_image(target)
      this_image.align_to_the_left
      this_image.set_name('image1')
      this_image.css_class('pad5px')
      this_image.css_class('bblack1')
      mini_vbox_containing_the_description_for_the_hardware_at_hand.minimal(
        this_image
      )
    end
    # ===================================================================== #
    # === description
    # ===================================================================== #
    if inner_dataset.include? 'description'
      _ << '<b>Beschreibung</b>: '+
           Roebe.remove_html(
             inner_dataset['description'].to_s.
             gsub(/<br><br>/,"\n<br>").
             gsub(/<br>/,"")
           )+N
    end
    # ===================================================================== #
    # === cost
    # ===================================================================== #
    if inner_dataset.include? 'cost'
      cost = inner_dataset['cost'].to_s
      _ << '<b>cost</b>: '+cost+' Euro'+N
      HardwareInformation::PurchasedHardware.add_to_total_cost(
        cost.to_f
      )
    end
    # ===================================================================== #
    # === bought_at
    #
    # Add information when the particular hardware at hand was purchased.
    # ===================================================================== #
    if inner_dataset.include? 'bought_at'
      _ << '<b>erstanden am</b>: '+
           '<span weight="bold" foreground="darkblue">'+
           inner_dataset['bought_at'].to_s+
           '</span>'+
           N
    end
    # ===================================================================== #
    # Next comes the description ("Beschreibung"), which may be really
    # long.
    # ===================================================================== #
    description_for_the_hardware_at_hand = label(_)
    description_for_the_hardware_at_hand.left_align
    description_for_the_hardware_at_hand.make_selectable
    mini_vbox_containing_the_description_for_the_hardware_at_hand.maximal(
      description_for_the_hardware_at_hand, 5
    )
    name_of_the_hardware = Roebe.remove_html(name_of_the_hardware)
    this_label.set_text(name_of_the_hardware)
    tiny_hbox_containing_computer_image_and_the_big_label = gtk_hbox
    # ===================================================================== #
    # Next we will add the tiny computer-image, with some padding.
    # ===================================================================== #
    tiny_hbox_containing_computer_image_and_the_big_label.minimal(
      image_computer, 12
    )
    tiny_hbox_containing_computer_image_and_the_big_label.maximal(
      this_label
    )
    vbox_containing_the_hardware_entries.add(
      tiny_hbox_containing_computer_image_and_the_big_label
    )
    vbox_containing_the_hardware_entries.add(
      mini_vbox_containing_the_description_for_the_hardware_at_hand
    )
    vbox_containing_the_hardware_entries.add(gtk_horizontal_spacer)
  }
  text = '<b>Gesamtkosten</b>: <b>'+
         HardwareInformation::PurchasedHardware.total_cost?.to_s.to_f.round(2).to_s+
         ' Euro</b>'
  vbox_containing_the_hardware_entries.add(
    h2(text).align_left
  )
  # ======================================================================= #
  # Add the big vbox into a scrolled-window interface.
  # ======================================================================= #
  scrolled_window = gtk_scrolled_window(vbox_containing_the_hardware_entries) { :only_up_and_down }
  scrolled_window.set_size_request(1400, 800)
  maximal(scrolled_window)
end
create_skeleton() click to toggle source
#

create_skeleton (create tag)

#
# File lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb, line 121
def create_skeleton
  @header_on_top = h1('Meine Hardware')
  @header_on_top.left_align
end
padding?() click to toggle source
#

padding?

#
# File lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb, line 107
def padding?
  2
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb, line 81
def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
  # ======================================================================= #
  # === @title
  # ======================================================================= #
  @title  = TITLE
  # ======================================================================= #
  # === @width
  # ======================================================================= #
  @width  = WIDTH
  # ======================================================================= #
  # === @height
  # ======================================================================= #
  @height = HEIGHT
  set_use_this_font(USE_THIS_FONT)
  use_gtk_project_css_file
  infer_the_size_automatically
end
run() click to toggle source
#

run (run tag)

#
# File lib/hardware_information/gui/shared_code/purchased_hardware/purchased_hardware_module.rb, line 265
def run
  create_skeleton_then_connect_skeleton
end