module MultimediaParadise::GUI::SimplePlayWidgetModule

Constants

HEIGHT
#

HEIGHT

#
NAMESPACE
#

NAMESPACE

#
TITLE
#

TITLE

#
WIDTH
#

WIDTH

#

Public Class Methods

new( run_already = true ) click to toggle source
#

initialize

#
Calls superclass method
# File lib/multimedia_paradise/gui/shared_code/simple_play_widget/simple_play_widget_module.rb, line 49
def initialize(
    run_already = true
  )
  super(:vertical, 2)
  reset
  run if run_already
end
run() click to toggle source
#

MultimediaParadise::GUI::SimplePlayWidgetModule.run

#
# File lib/multimedia_paradise/gui/shared_code/simple_play_widget/simple_play_widget_module.rb, line 214
def self.run
  require 'gtk_paradise/run'
  _ = ::MultimediaParadise::GUI::Gtk::SimplePlayWidget.new
  r = ::Gtk.run
  r.set_width(_.width?)
  r.set_height(_.height?)
  r.set_size_request(
    _.width?  / 1.5,
    _.height? / 1.5
  )
  r.signal_connect(:delete_event) { |_widget| ::Gtk.main_quit }
  r.enable_simple_exit
  # ======================================================================= #
  # Next we will add several alt+key shortcuts.
  # ======================================================================= #
  r.shortcuts {[
    [1, 'click_on_button_number(0)', :alt],
    [2, 'click_on_button_number(1)', :alt],
    [3, 'click_on_button_number(2)', :alt],
    [4, 'click_on_button_number(3)', :alt],
    [5, 'click_on_button_number(4)', :alt],
    [6, 'click_on_button_number(5)', :alt],
    [7, 'click_on_button_number(6)', :alt],
    [8, 'click_on_button_number(7)', :alt],
    [9, 'click_on_button_number(8)', :alt]
  ]}
  r << _
  r.top_middle_then_run(_.width?)
  return r
end

Public Instance Methods

connect_skeleton() click to toggle source
#

connect_skeleton

#
# File lib/multimedia_paradise/gui/shared_code/simple_play_widget/simple_play_widget_module.rb, line 185
def connect_skeleton
  hbox_center_aligned = hbox
  hbox_center_aligned.set_border_width(1)
  hbox_center_aligned.maximal(
    return_widget_increase_or_decrease_audio
  )
  center_aligned_box = gtk_alignment(0.5, 0.5, 0.5, 0.5)
  center_aligned_box.add(hbox_center_aligned)
  _ = draggable_hpane(
    @scrolled_window,
    center_aligned_box
  )
  n_percent_to_use = 50.0
  use_this_vertical_position = ( (height?.to_i * n_percent_to_use) / 100.0 ).to_i
  _.position = use_this_vertical_position
  maximal(_, 0)
end
create_skeleton() click to toggle source
#

create_skeleton

#
# File lib/multimedia_paradise/gui/shared_code/simple_play_widget/simple_play_widget_module.rb, line 116
def create_skeleton
  set_font_size(@font_size_to_use)
  @main_vbox = gtk_vbox
  # ======================================================================= #
  # Add the vbox onto a scroll-window widget:
  # ======================================================================= #
  @scrolled_window = gtk_scrolled_window(@main_vbox) { :automatic_scrollbars }
  @dataset.each_with_index {|entry, index| index += 1
    padded_index = index.to_s.rjust(3, ' ')
    name_of_the_song = File.basename(entry).
                       sub(/#{File.extname(entry)}$/,'').
                       tr('_',' ')
    button = gtk_bold_button(
      label: name_of_the_song
    )
    # ===================================================================== #
    # add a tooltip next. This will have bold markup, in colour.
    # ===================================================================== #
    button.tooltip_markup = ""\
      "<span weight=\"bold\">#{padded_index}</span> "\
      "#{name_of_the_song} 🎵️\n  → "\
      "<span weight=\"bold\" foreground=\"#{@use_this_colour_for_the_tooltip}\">#{entry}</span>"
    button.lightgreen
    # ===================================================================== #
    # Next, add code so that the button for the radio-station can
    # play the audio stream.
    # ===================================================================== #
    button.on_clicked {
      do_perform_the_default_actions(button, index)
    }
    @array_buttons << button

    index_button = gtk_button(padded_index)
    index_button.make_bold
    index_button.on_clicked {
      do_perform_the_default_actions(button, index)
    }
    index_button.limegreen
    @array_buttons << index_button
    mini_hbox = gtk_hbox
    mini_hbox.minimal(index_button)
    mini_hbox.maximal(button)
    @main_vbox.minimal(mini_hbox, 1)
  }
end
do_perform_the_default_actions(button, index = 0) click to toggle source
#

do_perform_the_default_actions

#
# File lib/multimedia_paradise/gui/shared_code/simple_play_widget/simple_play_widget_module.rb, line 108
def do_perform_the_default_actions(button, index = 0)
  this_song = @dataset[index - 1]
  play_this_song_via_mpv(this_song)
end
play_this_song_via_mpv(this_song) click to toggle source
#

play_this_song_via_mpv

#
# File lib/multimedia_paradise/gui/shared_code/simple_play_widget/simple_play_widget_module.rb, line 165
def play_this_song_via_mpv(this_song)
  e
  e "Next playing #{::Colours.steelblue(this_song)} via mpv."
  e
  @array_threads << Thread.new {
    pid = Process.spawn("mpv #{this_song}")
    @array_pids << pid
  }
end
reset() click to toggle source
#

reset

#
# File lib/multimedia_paradise/gui/shared_code/simple_play_widget/simple_play_widget_module.rb, line 60
def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
  # ======================================================================= #
  # === @width
  # ======================================================================= #
  set_width(WIDTH)
  # ======================================================================= #
  # === @height
  # ======================================================================= #
  set_height(HEIGHT)
  # ======================================================================= #
  # === @array_threads
  # ======================================================================= #
  @array_threads = []
  # ======================================================================= #
  # === @array_pids
  # ======================================================================= #
  @array_pids = []
  # ======================================================================= #
  # === @dataset
  # ======================================================================= #
  @dataset = []
  # ======================================================================= #
  # === @font_size_to_use
  # ======================================================================= #
  @font_size_to_use = 20
  # ======================================================================= #
  # === @use_this_colour_for_the_tooltip
  # ======================================================================= #
  if use_gtk2?
    @use_this_colour_for_the_tooltip = :darkblue
  else # for ruby-gtk3
    @use_this_colour_for_the_tooltip = :lightblue
  end
  # ======================================================================= #
  # === @array_buttons
  # ======================================================================= #
  @array_buttons = []
  append_project_css_file
end
return_widget_increase_or_decrease_audio() click to toggle source
#

return_widget_increase_or_decrease_audio

#
# File lib/multimedia_paradise/gui/shared_code/simple_play_widget/simple_play_widget_module.rb, line 178
def return_widget_increase_or_decrease_audio
  ::MultimediaParadise.widget_increase_or_decrease_audio
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/gui/shared_code/simple_play_widget/simple_play_widget_module.rb, line 206
def run
  populate_the_dataset_with_this_array
  create_skeleton_then_connect_skeleton
end