module MultimediaParadise::GUI::Gtk::PlayVideoFromMyCollectionModule

Constants

FILE_VIDEOCAMERA
FONT_FAMILY_TO_USE
#

FONT_FAMILY_TO_USE

#
FONT_SIZE
#

FONT_SIZE

#
FROM_WHERE
#

FROM_WHERE

#
HEIGHT
#

HEIGHT

#
MPLAYER
#

MPLAYER

#
MPV
#

NPV

#
NAMESPACE
#

NAMESPACE

#
TITLE
#

TITLE

#
WIDTH
#

WIDTH

#

Public Class Methods

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

MultimediaParadise::GUI::Gtk::PlayVideoFromMyCollectionModule[]

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 296
def self.[](i = '')
  new(i)
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
Calls superclass method
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 98
def initialize(
    i           = nil,
    run_already = true
  )
  super('')
  label_widget.set_markup(
    '<span weight="bold" size="x-large" foreground="darkblue"> '+TITLE+' </span>'
  )
  reset
  set_input(i)
  # ======================================================================= #
  # Delegate all key-press events next.
  # ======================================================================= #
  signal_connect(:key_press_event) {|widget, event|
    on_key_event(widget, event)
  }
  run if run_already
end
padding?() click to toggle source
#

PlayVideoFromMyCollection

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 169
def self.padding?
  12
end
run() click to toggle source
#

MultimediaParadise::GUI::Gtk::PlayFromRadioStation.run

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 370
def self.run
  require 'gtk_paradise/run'
  video_collection = MultimediaParadise::GUI::Gtk::PlayVideoFromMyCollection.new(ARGV)
  r = ::Gtk.run
  r << video_collection
  r.set_size_request(video_collection.width?, video_collection.height?)
  r.signal_connect(:delete_event) { |_widget| Gtk.main_quit }
  r.modify_background(:normal, :lightskyblue)
  r.top_left_then_run
end

Public Instance Methods

add_alignment() click to toggle source
#

add_alignment

The alignment will hold the @scrolled_window widgt.

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 271
def add_alignment
  padding = 0.98
  @alignment = ::Gtk::Alignment.new(padding, padding, padding, padding)
  @alignment.set_padding(1,1,1,1) # oben,unten,links,rechts
  vbox = gtk_vbox
  vbox.minimal(@search_bar,       2)
  vbox.maximal(@scrolled_window, 1)
  @child_widget.maximal(vbox)
  @child_widget.set_size_request(500, 600)
  @alignment.add @child_widget
  add(@alignment)
end
add_buttons_from_video_files() click to toggle source
#

add_buttons_from_video_files

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 190
def add_buttons_from_video_files
  # ======================================================================= #
  # Next iterate over all the available video files.
  # ======================================================================= #
  @array_all_video_files = obtain_all_video_files
  @array_all_video_files.each_with_index {|videofile, index| index += 1
    # ===================================================================== #
    # We want to show a little tooltip, so we have to return the
    # information from the yaml-file that keeps track of things.
    # ===================================================================== #
    this_entry = File.basename(videofile).split('_')
    this_entry = this_entry.first.to_i
    use_this_as_tooltip = ::MultimediaParadise.return_data_from_video_collection_file_for_this_entry(
      this_entry
    )
    name_of_the_videofile = File.basename(videofile).tr('_',' ')
    # ===================================================================== #
    # We add a button for each videofile.
    # ===================================================================== #
    button = gtk_bold_button(name_of_the_videofile, false) # False for "Do not use a shortcut".
    button.css_class('bblack1')
    button.on_clicked {|widget, event|
      play_this_videofile(videofile) # This contains the full path.
    }
    button.set_border_width(3)
    button.set_image(return_new_videocamera_image) # use the videocamera image.
    button.align_to_the_left_side
    # ===================================================================== #
    # The index button is the small button on the very left side.
    # ===================================================================== #
    index_button = gtk_bold_button("#{index.to_s.rjust(3)}")
    index_button.css_class('bblack1')
    index_button.set_size_request(90, 32)
    index_button.on_clicked {
      play_this_videofile(videofile)
    }
    if use_this_as_tooltip
      # =================================================================== #
      # === Extensive tooltip
      #
      # Add a tooltip there if it was given, but convert it into a String
      # if it is a Hash. Furthermore, add a bit of pseudo-css as well.
      # =================================================================== #
      if use_this_as_tooltip.is_a? Hash
        if use_this_as_tooltip.has_key? 'imdb'
          imdb_URL = use_this_as_tooltip['imdb']
          button.on_right_mouse_button_clicked {
            try_to_open_the_imdb_link_in_the_browser(imdb_URL)
          }
        end
        use_this_as_tooltip = use_this_as_tooltip.map {|key, value|
          "#{key.tr('_',' ')}: #{value}"
        }.join("\n").
          sub(/title:/, '<b>title:</b>').
          sub(/release date:/, '<b>release date:</b>').
          sub(/genre:/, '<b>genre:</b>').
          sub(/addition date:/, '<b>addition date:</b>').
          sub(/imdb:/, '<b>imdb:</b>').
          sub(/language:/, '<b>language:</b>').
          sub(/my rating:/, '<b>my rating:</b>').dup
        # ================================================================= #
        # Add the file-extension as well, for additional info.
        # ================================================================= #
        use_this_as_tooltip << "\n<b>File type</b>: #{File.extname(videofile)}"
      end
      button.fancy_tooltip = use_this_as_tooltip
      index_button.fancy_tooltip = use_this_as_tooltip
    end
    button.show_all
    hbox_with_two_buttons = gtk_hbox
    hbox_with_two_buttons.minimal(index_button, 0)
    hbox_with_two_buttons.maximal(button, 0)
    @vbox_with_buttons.add(hbox_with_two_buttons)
  }
end
add_the_scrolled_window() click to toggle source
#

add_the_scrolled_window

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 313
def add_the_scrolled_window
  @scrolled_window = gtk_scrolled_window(@vbox_with_buttons)
end
create_skeleton() click to toggle source
#

create_skeleton

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 287
def create_skeleton
  create_the_fancy_search_bar
  @vbox_with_buttons = gtk_vbox
  add_buttons_from_video_files
end
favicon?() click to toggle source
#

favicon?

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 327
def favicon?
  :tabble
end
input?() click to toggle source
#

input?

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 162
def input?
  @input
end
is_video_file?(i) click to toggle source
#

is_video_file?

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 146
def is_video_file?(i)
  ::MultimediaParadise.is_video_file?(i) # Delegate to the module-method here.
end
obtain_all_video_files() click to toggle source
#

obtain_all_video_files

Simply return all video files

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 178
def obtain_all_video_files
  from_where = '/home/x/video/Realvids/*' # Hardcoded by default.
  from_where = FROM_WHERE
  results = Dir[from_where].select {|entry|
    is_video_file?(entry)
  }.sort
  return results
end
on_key_event( widget, event ) click to toggle source
#

on_key_event

Cause the searchbar to show up.

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 386
def on_key_event(
    widget, event
  )
  shortcut = ::Gtk.accelerator_get_label(event.keyval, event.state)
  # ======================================================================= #
  # Get support for Ctrl+F next:
  # ======================================================================= #
  if ['Ctrl+F', 'Ctrl+Mod2+F'].include? shortcut
    if @search_bar.search_mode?
      # =================================================================== #
      # This causes the search bar to disappear.
      # =================================================================== #
      @search_bar.disappear
    else
      # =================================================================== #
      # And appear here in this event.
      # =================================================================== #
      @search_bar.appear
    end
  end
end
padding?() click to toggle source
#

padding?

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 320
def padding?
  8
end
play_this_video_file(videofile)
Alias for: play_this_videofile
play_this_videofile(videofile) click to toggle source
#

play_this_videofile

This is the method that will play a given videofile.

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 413
def play_this_videofile(videofile)
  efancy videofile
  @thread = Thread.new {
    _ = MPV+' '+videofile
    cliner
    e sfancy(_)
    cliner
    system _
  }
  @thread.join
  @thread = nil # Unsure whether we will need this here.
end
Also aliased as: play_this_video_file
reset() click to toggle source
#

reset (reset tag)

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 120
def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
  # ======================================================================= #
  # === @title
  # ======================================================================= #
  @title  = TITLE
  # ======================================================================= #
  # === @width
  # ======================================================================= #
  set_width(WIDTH)
  # ======================================================================= #
  # === @height
  # ======================================================================= #
  set_height(HEIGHT)
  @child_widget = gtk_vbox # This widget will hold the other variants.
  set_font(:dejagnu_20)
  append_project_css_file
end
return_new_videocamera_image() click to toggle source
#

return_new_videocamera_image

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 303
def return_new_videocamera_image
  pixbuf = ::GdkPixbuf::Pixbuf.new(file: FILE_VIDEOCAMERA)
  pixbuf.scale(5, 5, :hyper)
  image = gtk_image(pixbuf)
  return image
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 342
def run
  set_the_font_in_use_for_this_application
  create_skeleton
  input_field  = gtk_input_field {{ max_length: 50 }}
  result_field = gtk_input_field
  input_field.on_key_press_event { |widget, event|
    case Gdk::Keyval.to_name(event.keyval)
    when 'Return','KP_Enter'
      _ = input_field.text
      _ = FindVideo[_]
      unless _.empty?
        _.map! {|entry| entry.last }
      end
      if _.is_a? Array
        _ = _.join(', ')
      end
      result_field.set_text(_)
    end
  }
  search_box = gtk_hbox(input_field, result_field)
  @vbox_with_buttons.minimal(search_box, 0)
  add_the_scrolled_window
  add_alignment # We will put all the
end
set_input(i = '') click to toggle source
#

set_input

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 153
def set_input(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup if i
  @input = i
end
try_to_find_a_match() click to toggle source
#

try_to_find_a_match

This method will try to find a corresponding match to the given search term.

#
# File lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb, line 432
def try_to_find_a_match
  _ = @search_entry.text?
  possible_matches = @array_all_video_files.select {|entry|
    basename = File.basename(entry)
    basename.downcase.include? _
  }
  if possible_matches.empty?
    # ===================================================================== #
    # Show a popover in this case
    # ===================================================================== #
    popover_on(
      this_widget:      @search_entry,
      use_this_message: 'No match was found for the search '\
                        'term <b>'+_+'</b>.'
    )
  else
    first = possible_matches.first
    play_this_video_file(first)
  end
end