Module: MultimediaParadise::GUI::Gtk::PlayVideoFromMyCollectionModule
- Extended by:
- Colours
- Includes:
- Colours, Gtk::BaseModule, MultimediaParadise::GUI
- Included in:
- PlayVideoFromMyCollection
- Defined in:
- lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- WIDTH =
#
WIDTH
#
'90%'
- HEIGHT =
#
HEIGHT
#
820
- MPLAYER =
#
MPLAYER
#
'mplayer -vo x11 -zoom'
- MPV =
#
NPV
#
'mpv'
- FILE_VIDEOCAMERA =
"/home/x/data/images/#{Cyberweb.web_images(:videocamera)}"
- FROM_WHERE =
#
FROM_WHERE
#
'/home/x/video/Realvids/*'
- TITLE =
#
TITLE
#
'Play Videos'
- FONT_FAMILY_TO_USE =
#
FONT_FAMILY_TO_USE
#
'DejaVu Sans Mono'
- FONT_SIZE =
#
FONT_SIZE
#
'20'
Constants included from MultimediaParadise::GUI
ISO, MAIN_FONT_TO_USE, N, UTF, VIDEO_COLLECTION
Class Method Summary collapse
-
.[](i = '') ⇒ Object
# === MultimediaParadise::GUI::Gtk::PlayVideoFromMyCollectionModule[] ========================================================================= #.
-
.padding? ⇒ Boolean
# === PlayVideoFromMyCollection ========================================================================= #.
-
.run ⇒ Object
# === MultimediaParadise::GUI::Gtk::PlayFromRadioStation.run ========================================================================= #.
Instance Method Summary collapse
-
#add_alignment ⇒ Object
# === add_alignment.
-
#add_buttons_from_video_files ⇒ Object
# === add_buttons_from_video_files ========================================================================= #.
-
#add_the_scrolled_window ⇒ Object
# === add_the_scrolled_window ========================================================================= #.
-
#create_skeleton ⇒ Object
# === create_skeleton ========================================================================= #.
-
#create_the_fancy_search_bar ⇒ Object
# === create_the_fancy_search_bar ========================================================================= #.
-
#favicon? ⇒ Boolean
# === favicon? ========================================================================= #.
-
#initialize(i = nil, run_already = true) ⇒ Object
# === initialize ========================================================================= #.
-
#input? ⇒ Boolean
# === input? ========================================================================= #.
-
#is_video_file?(i) ⇒ Boolean
# === is_video_file? ========================================================================= #.
-
#obtain_all_video_files ⇒ Object
# === obtain_all_video_files.
-
#on_key_event(widget, event) ⇒ Object
# === on_key_event.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#play_this_videofile(videofile) ⇒ Object
(also: #play_this_video_file)
# === play_this_videofile.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#return_new_videocamera_image ⇒ Object
# === return_new_videocamera_image ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#set_input(i = '') ⇒ Object
# === set_input ========================================================================= #.
-
#try_to_find_a_match ⇒ Object
# === try_to_find_a_match.
-
#try_to_open_the_imdb_link_in_the_browser(i) ⇒ Object
# === try_to_open_the_imdb_link_in_the_browser ========================================================================= #.
Methods included from MultimediaParadise::GUI
#esystem, #populate_the_dataset_with_this_array, #set_gtk_font_to_use
Class Method Details
.[](i = '') ⇒ Object
#
MultimediaParadise::GUI::Gtk::PlayVideoFromMyCollectionModule[]
#
296 297 298 |
# 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 |
.padding? ⇒ Boolean
#
PlayVideoFromMyCollection
#
169 170 171 |
# 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 ⇒ Object
#
MultimediaParadise::GUI::Gtk::PlayFromRadioStation.run
#
370 371 372 373 374 375 376 377 378 379 |
# 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) { || Gtk.main_quit } r.modify_background(:normal, :lightskyblue) r.top_left_then_run end |
Instance Method Details
#add_alignment ⇒ Object
#
add_alignment
The alignment will hold the @scrolled_window widgt.
#
271 272 273 274 275 276 277 278 279 280 281 282 |
# 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 ⇒ Object
#
add_buttons_from_video_files
#
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb', line 190 def # ======================================================================= # # 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. # ===================================================================== # = (name_of_the_videofile, false) # False for "Do not use a shortcut". .css_class('bblack1') .on_clicked {|, event| play_this_videofile(videofile) # This contains the full path. } .set_border_width(3) .set_image(return_new_videocamera_image) # use the videocamera image. .align_to_the_left_side # ===================================================================== # # The index button is the small button on the very left side. # ===================================================================== # = ("#{index.to_s.rjust(3)}") .css_class('bblack1') .set_size_request(90, 32) .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'] . { 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 .fancy_tooltip = use_this_as_tooltip .fancy_tooltip = use_this_as_tooltip end .show_all = gtk_hbox .minimal(, 0) .maximal(, 0) @vbox_with_buttons.add() } end |
#add_the_scrolled_window ⇒ Object
#
add_the_scrolled_window
#
313 314 315 |
# 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 ⇒ Object
#
create_skeleton
#
287 288 289 290 291 |
# File 'lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb', line 287 def create_skeleton @vbox_with_buttons = gtk_vbox end |
#create_the_fancy_search_bar ⇒ Object
#
create_the_fancy_search_bar
#
456 457 458 459 460 461 462 |
# File 'lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb', line 456 def @search_bar, @search_entry = drop_down_find_box @search_entry.width_height(400, 50) @search_entry.on_enter { try_to_find_a_match } end |
#favicon? ⇒ Boolean
#
favicon?
#
327 328 329 |
# 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 |
#initialize(i = nil, run_already = true) ⇒ Object
#
initialize
#
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# 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('') .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) {|, event| on_key_event(, event) } run if run_already end |
#input? ⇒ Boolean
#
input?
#
162 163 164 |
# 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) ⇒ Boolean
#
is_video_file?
#
146 147 148 |
# 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 ⇒ Object
#
obtain_all_video_files
Simply return all video files
#
178 179 180 181 182 183 184 185 |
# 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) ⇒ Object
#
on_key_event
Cause the searchbar to show up.
#
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# 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( , 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? ⇒ Boolean
#
padding?
#
320 321 322 |
# 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_videofile(videofile) ⇒ Object Also known as: play_this_video_file
#
play_this_videofile
This is the method that will play a given videofile.
#
413 414 415 416 417 418 419 420 421 422 423 424 |
# 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 |
#reset ⇒ Object
#
reset (reset tag)
#
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# 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 ⇒ Object
#
return_new_videocamera_image
#
303 304 305 306 307 308 |
# 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 ⇒ Object
#
run (run tag)
#
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# 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 { |, 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 = '') ⇒ Object
#
set_input
#
153 154 155 156 157 |
# 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 ⇒ Object
#
try_to_find_a_match
This method will try to find a corresponding match to the given search term.
#
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# 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 |
#try_to_open_the_imdb_link_in_the_browser(i) ⇒ Object
#
try_to_open_the_imdb_link_in_the_browser
#
334 335 336 337 |
# File 'lib/multimedia_paradise/gui/shared_code/play_video_from_my_collection/play_video_from_my_collection_module.rb', line 334 def try_to_open_the_imdb_link_in_the_browser(i) require 'open' Open.in_browser(i) end |