Class: MultimediaParadise::GUI::UniversalWidgets::ChangeMetadataWidget

Inherits:
Base
  • Object
show all
Includes:
UniversalWidgets::BaseModule
Defined in:
lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb

Overview

MultimediaParadise::GUI::UniversalWidgets::ChangeMetadataWidget

Constant Summary collapse

ARRAY_SUPPORTED_VIDEO_FILES =
#

ARRAY_SUPPORTED_VIDEO_FILES

List all supported video files here in this array.

#
::MultimediaParadise::ARRAY_VIDEO_FILETYPES
TITLE =
#

TITLE

#
'Change Metadata'
WIDTH =
#

WIDTH

#
'75% or minimum 1300px'
HEIGHT =
#

HEIGHT

#
'15% or minimum 250px'
USE_THIS_FONT =
#

USE_THIS_FONT

#
:hack_23
LARGER_FONT =
#

LARGER_FONT

#
:hack_25
SMALLER_FONT =
#

SMALLER_FONT

#
:hack_20

Constants inherited from Base

Base::ERROR, Base::ERROR_LINE, Base::NAMESPACE, Base::USE_THIS_NAMESPACE_FOR_THE_COLOURS, Base::USE_THIS_NAMESPACE_FOR_THE_CORE_COLOURS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#actions, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #cartoons_directory?, #clear_the_internal_hash, #cliner, #cliner_with_time_stamp, #colourized_comment, #copy_file, #crimson, #dataset_from_file_video_collection, #dd_mm_yyyy, #debug?, #default_readlines, #directory_to_realvids?, #do_not_use_opn, #dodgerblue, #does_the_video_player_support_this_commandline?, #e, #ecomment, #ecrimson, #efancy, #enable_debug, #ensure_main_encoding, #ensure_that_the_output_directory_exists, #eparse, #erev, #esystem, #ewarn, #file_video_collection?, #filter_for_audio_files, #filter_for_video_files, #forestgreen, #gold, #grey, #hh_mm_ss, #home_x_video?, #indianred, #infer_the_namespace, #internal_hash?, #is_audio_file?, #is_mkv?, #is_mp3?, #is_mp4?, #is_multimedia_file?, #is_on_roebe?, #is_video_file?, #konsole_colour_peru, #lightblue, #lightgreen, #load_yaml, #local_audio_directory?, #map_symbol_to_locally_existing_file, #mediumorchid, #mediumpurple, #mediumslateblue, #mkdir, #move_file, #namespace?, #no_file_exists, #no_file_exists_at, #olive, #olivedrab, #opne, #opnecomment, #opnn, #orange, #palegoldenrod, #palegreen, #powderblue, #project_base_directory?, #rds, #register_sigint, #remove_file, #report_pwd, #reset_the_internal_hash, #return_all_video_files, #return_pwd, #return_random_video, #rev, #royalblue, #save_what_into, #sdir, #seagreen, #seconds_to_time_format, #select_only_video_files_from, #set_be_verbose, #set_use_colours, #sfancy, #sfile, #simp, #skyblue, #slateblue, #springgreen, #steelblue, #swarn, #teal, #time_right_now, #to_hh_mm_ss, #tomato, #true_rev, #try_to_rename_kde_konsole_tab, #ucliner, #use_colours?, #use_opn?, #use_which_video_player?, #verbose_truth, #video_collection?, #violet, #yaml_directory?, #yel

Methods included from CommandlineArgumentsModule

#all_input_starts_with_a_number?, #commandline_arguments?, #commandline_arguments_as_a_string, #first_argument?, #first_non_hyphened_commandline_argument?, #set_commandline_arguments

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ ChangeMetadataWidget

#

initialize

#


94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 94

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  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

Class Method Details

.[](i = ARGV) ⇒ Object

#

MultimediaParadise::GUI::UniversalWidgets::ChangeMetadataWidget[]

#


743
744
745
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 743

def self.[](i = ARGV)
  new(i)
end

.run(i = ARGV) ⇒ Object

#

MultimediaParadise::GUI::UniversalWidgets::ChangeMetadataWidget.run

#


725
726
727
728
729
730
731
732
733
734
735
736
737
738
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 725

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::MultimediaParadise::GUI::Gtk::ChangeMetadataWidget.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.maximize
  r.top_left_then_run
end

Instance Method Details

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


486
487
488
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 486

def border_size?
  2
end

#clear_the_old_entriesObject

#

clear_the_old_entries

#


661
662
663
664
665
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 661

def clear_the_old_entries
  @entry_comment.set_text('')
  @entry_year.set_text('')
  @entry_title.set_text('')
end

#connect_the_skeletonObject

#

connect_the_skeleton (connect tag)

#


500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 500

def connect_the_skeleton
  abort_on_exception

  outer_vbox = create_vbox

  outer_vbox.minimal(@header)
  @grid.left_right(return_text1, @entry_input_file)
  @grid.new_line
  small_hbox = create_hbox
  small_hbox.maximal(@entry_output_file)
  event_box = create_event_box(create_icon('view-refresh'))
  event_box.hint =
    "Click on this image to automatically rename the video file to "\
    "the original name seen above.\n\n"\
    "This currently does not notify the user that the rename-action "\
    "has been applied, but it should work just fine nonetheless."
  event_box.on_clicked {
    do_rename_the_newly_created_file_to_the_original_file
  }
  small_hbox.minimal(event_box)
  @grid.left_right(return_text2, small_hbox) # Output file to use.
  @grid.new_line
  @grid.left_right(return_text3, entry_title?)
  @grid.new_line
  @grid.left_right(return_text4, entry_comment?)
  @grid.new_line
  @grid.left_right(return_text5, entry_year?)
  hbox_small = create_hbox
  hbox_small.minimal(@button_run_the_sys_command, 4)
  hbox_small.minimal(@spinner,                    4)
  hbox_small.center_into_the_middle
  @grid.full_row(hbox_small)

  outer_vbox.minimal(@grid, 2)

  window = create_window_or_runner(nil, width?, height?, title?)
  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
  menu
  handle_CSS_rules if use_gtk3?
  run_main
end

#create_the_buttonsObject

#

create_the_buttons (buttons tag, button tag)

#


387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 387

def create_the_buttons
  # ======================================================================= #
  # === @button_run_the_sys_command
  # ======================================================================= #
  @button_run_the_sys_command = button('_Run')
  @button_run_the_sys_command.remove_background
  @button_run_the_sys_command.hint = 'This will run the sys-command.'
  @button_run_the_sys_command.on_hover(:lightblue)
  @additional_CSS_rules << @button_run_the_sys_command.rounded_border(
    '12px',
    :default,
    '5px solid royalblue'
  )
  @button_run_the_sys_command.css_class('border12')

  @button_run_the_sys_command.on_clicked {
    work_on_this_file = work_on_which_file?
    unless File.exist? work_on_this_file
      popup_this_text_over_that_widget(
        "The target file at \n\n"\
        "  <b>#{File.absolute_path(work_on_this_file)}</b>\n"\
        "\ndoes not exist.",
        entry_input?
      )
    else # else the file exists, so we can continue here.
      @spinner.start_to_spin if gtk3?
      @button_run_the_sys_command.is_insensitive
      # =================================================================== #
      # The built-up command shall be similar to this:
      #
      #   ffmpeg -i foobar.mp4 -metadata title=foobar -codec copy output.mp4
      #
      # =================================================================== #
      cmd_to_run = 'ffmpeg '.dup
      cmd_to_run << ' -i '+work_on_this_file
      cmd_to_run << ' -metadata '
      cmd_to_run << ' title="'+entry_title?.text?+'"'
      # =================================================================== #
      # Next add comments
      # =================================================================== #
      unless @entry_comment.text?.empty?
        cmd_to_run << ' -metadata '
        cmd_to_run << ' comment='+@entry_comment.text?
      end
      # =================================================================== #
      # Next add the year
      # =================================================================== #
      unless @entry_year.text?.empty?
        cmd_to_run << ' -metadata '
        cmd_to_run << ' year='+@entry_year.text?
      end
      cmd_to_run << ' -codec copy'
      cmd_to_run << ' -y' # To overwrite any existing files at once.
      cmd_to_run << " #{default_output_file?}"
      cmd_to_run.squeeze!(' ')
      Thread.new {
        esystem(cmd_to_run)
        @spinner.stop_spinning if gtk3?
        @button_run_the_sys_command.is_sensitive
        log_this_file_has_been_modified(work_on_this_file)
      }
    end
  }
end

#create_the_entriesObject

#

create_the_entries (entries tag, entry tag)

#


587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 587

def create_the_entries
  # ======================================================================= #
  # === @entry_input_file
  # ======================================================================= #
  @entry_input_file = entry('foobar.mp4')
  @entry_input_file.width_height(600, 30)
  @entry_input_file.very_light_yellowish_background
  @entry_input_file.use_this_font = SMALLER_FONT
  @entry_input_file.enable_scroll_events
  # ======================================================================= #
  # === @entry_output_file
  # ======================================================================= #
  @entry_output_file = entry(File.absolute_path('output.mp4'))
  @entry_output_file.width_height(600, 30)
  @entry_output_file.very_light_yellowish_background
  @entry_output_file.use_this_font = SMALLER_FONT
  # ======================================================================= #
  # === @entry_title
  # ======================================================================= #
  @entry_title = entry
  @entry_title.width_height(600, 30)
  @entry_title.very_light_yellowish_background
  @entry_title.use_this_font = SMALLER_FONT
  # ======================================================================= #
  # === @entry_comment
  # ======================================================================= #
  @entry_comment = entry
  @entry_comment.width_height(600, 30)
  @entry_comment.very_light_yellowish_background
  @entry_comment.use_this_font = SMALLER_FONT
  # ======================================================================= #
  # === @entry_year
  # ======================================================================= #
  @entry_year = entry
  @entry_year.width_height(600, 30)
  @entry_year.very_light_yellowish_background
  @entry_year.use_this_font = SMALLER_FONT
end

#create_the_gridObject

#

create_the_grid (grid tag)

#


462
463
464
465
466
467
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 462

def create_the_grid
  # ======================================================================= #
  # === @grid
  # ======================================================================= #
  @grid = default_grid
end

#create_the_headerObject

#

create_the_header (header tag)

#


298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 298

def create_the_header
  # ======================================================================= #
  # === @header
  # ======================================================================= #
  @header = default_header
  @header.set_title('Change Metadata')
  button_open_file = button('Open file')
  button_open_file.on_clicked {
    do_open_a_local_file
  }
  @header.add_right(button_open_file)
  icon = gtk_icon('media-playback-start')
  button_play_the_video = event_box(icon)
  button_play_the_video.hint = 'Play the video file listed under '\
    '"Input file to use:".'
  button_play_the_video.on_clicked {
    Thread.new {
      esystem "mpv #{work_on_which_file?}"
    }
  }
  @header.add_left(button_play_the_video)
end

#create_the_skeletonObject

#

create_the_skeleton (create tag, skeleton tag)

#


707
708
709
710
711
712
713
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 707

def create_the_skeleton
  create_the_buttons
  create_the_entries
  create_the_spinner
  create_the_header
  create_the_grid
end

#create_the_spinnerObject

#

create_the_spinner

#


281
282
283
284
285
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 281

def create_the_spinner
  if use_gtk3?
    @spinner = return_spinner_widget # Create the spinner before the buttons.
  end
end

#default_output_file?Boolean

#

default_output_file?

#

Returns:

  • (Boolean)


163
164
165
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 163

def default_output_file?
  @entry_output_file.text?
end
#
#


493
494
495
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 493

def do_all_startup_related_actions
  respond_to_scroll_events_of_the_first_entry
end

#do_analyse_this_file(i) ⇒ Object Also known as: do_open_this_file, work_on_this_file_now

#

do_analyse_this_file (open tag)

#


629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 629

def do_analyse_this_file(i)
  @entry_input_file.set_text(i)
  read_the_title_and_then_assign_it
  read_the_comment_and_then_assign_it
  if is_on_roebe?
    old_value = @entry_output_file.text?.dup
    original_filename = File.basename(i).delete_suffix(File.extname(i))
    old_value.delete_suffix!(File.extname(old_value))
    old_value.sub!(/output/, '')
    old_value << "#{original_filename}_output#{File.extname(i)}"
    @entry_output_file.set_text(old_value)
    # ===================================================================== #
    # We may also infer the title if the entry is empty.
    # ===================================================================== #
    if entry_title? and entry_title?.empty?
      new_name = File.basename(input_file_name?).delete_suffix(
        File.extname(i)
      )
      if new_name.include?('_') and (new_name =~ /^\d+/)
        splitted = new_name.split('_')
        new_name = splitted[1 .. -1].join('_')
      end
      new_name.tr!('_',' ')
      entry_title?.set_text(new_name)
    end
  end
end

#do_open_a_local_fileObject

#

do_open_a_local_file (open tag)

#


559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 559

def do_open_a_local_file
  new_open_file_dialog {{
    name_for_the_file_chooser_dialog: :custom_dialog,
    use_this_as_the_current_folder:   return_pwd,
    filter_for:                       ARRAY_SUPPORTED_VIDEO_FILES,
    additional_folders:
      %w(
        /Depot/j/
        /home/x/video/Realvids/
      )
  }}
  _ = main_file?
  if _ and File.exist?(_)
    # ===================================================================== #
    # First, clear the old entries that contain meta-data.
    # ===================================================================== #
    clear_the_old_entries
    # ===================================================================== #
    # Next proceed by analysing the file.
    # ===================================================================== #
    do_analyse_this_file(_)
    sync_the_output_directory_based_on_this_file(_)
  end
end

#do_rename_the_newly_created_file_to_the_original_fileObject

#

do_rename_the_newly_created_file_to_the_original_file

#


211
212
213
214
215
216
217
218
219
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 211

def do_rename_the_newly_created_file_to_the_original_file
  newly_created_file = @entry_output_file.text?
  original_file      = @entry_input_file.text?
  unless is_still_spinning?
    if File.exist? newly_created_file
      FileUtils.mv(newly_created_file, original_file)
    end
  end
end

#entry2?Boolean

#

entry2?

#

Returns:

  • (Boolean)


359
360
361
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 359

def entry2?
  @entry_output_file
end

#entry_comment?Boolean

#

entry_comment?

#

Returns:

  • (Boolean)


366
367
368
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 366

def entry_comment?
  @entry_comment
end

#entry_input?Boolean

#

entry_input?

#

Returns:

  • (Boolean)


455
456
457
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 455

def entry_input?
  @entry_input_file
end

#entry_title?Boolean

#

entry_title?

#

Returns:

  • (Boolean)


380
381
382
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 380

def entry_title?
  @entry_title
end

#entry_year?Boolean Also known as: entry5?

#

entry_year?

#

Returns:

  • (Boolean)


373
374
375
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 373

def entry_year?
  @entry_year
end

#handle_CSS_rulesObject

#

handle_CSS_rules (CSS tag)

This is currently only in use if gtk3 is in use.

#


143
144
145
146
147
148
149
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 143

def handle_CSS_rules
  use_gtk_paradise_project_css_file
  append_project_css_file
  more_CSS_then_apply_it '

'+@additional_CSS_rules
end

#input_file_name?Boolean Also known as: work_on_which_file?, file?

#

input_file_name?

#

Returns:

  • (Boolean)


290
291
292
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 290

def input_file_name?
  @entry_input_file.text?
end

#is_still_spinning?Boolean

#

is_still_spinning?

#

Returns:

  • (Boolean)


224
225
226
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 224

def is_still_spinning?
  @spinner.is_still_spinning?
end

#log_dir?Boolean

#

log_dir?

#

Returns:

  • (Boolean)


231
232
233
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 231

def log_dir?
  MultimediaParadise.log_dir?
end

#log_this_file_has_been_modified(this_file) ⇒ Object

#

log_this_file_has_been_modified (log tag)

This method will log which file has been modified. Knowing this information is helpful when we want to copy only those video files that were modified.

What information must we save?

The file name, as well as the time when the file was modified.

#


246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 246

def log_this_file_has_been_modified(this_file)
  what = this_file.dup
  what << ' # '+dd_mm_yyyy?+' '+hh_mm_ss?
  into = log_dir?+'metadata_of_video_files_that_were_modified.md'
  if File.exist? into
    what.prepend(File.read(into))
  end
  if is_on_roebe?
    e "Storing log-information into the file "\
      "at `#{sfile(into)}`."
  end
  write_what_into("#{what}\n", into)
end
#

menu (menu tag)

#


196
197
198
199
200
201
202
203
204
205
206
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 196

def menu(
    i = commandline_arguments?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    if i and File.exist?(i)
      do_analyse_this_file(i)
    end
  end
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


479
480
481
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 479

def padding?
  4
end

#read_the_comment_and_then_assign_itObject

#

read_the_comment_and_then_assign_it

#


263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 263

def read_the_comment_and_then_assign_it
  _ = file?
  result_from_exiftool = `exiftool #{_}`
  begin
    if result_from_exiftool.include? 'Comment'
      current_comment = result_from_exiftool.split("\n").select {|entry|
        entry.include? 'Comment'
      }.flatten.first.sub(/Comment/,'').strip.delete(':').strip
      @entry_comment.set_text(current_comment)
    end
  rescue ArgumentError => error
    pp error
  end
end

#read_the_title_and_then_assign_itObject

#

read_the_title_and_then_assign_it

#


177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 177

def read_the_title_and_then_assign_it
  _ = file?
  result_from_exiftool = `exiftool #{_}`
  if result_from_exiftool.include? 'Title'
    begin
      splitted = result_from_exiftool.split("\n")
      current_title = splitted.select {|entry|
        entry.include? 'Title'
      }.flatten.first.sub(/Title/,'').strip.delete(':').strip
      entry_title?.set_text(current_title)
    rescue ArgumentError => error
      pp error
    end 
  end
end

#resetObject

#

reset (reset tag)

#


110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 110

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, USE_THIS_FONT)
  infer_the_size_automatically
  # ======================================================================= #
  # === @additional_CSS_rules
  # ======================================================================= #
  @additional_CSS_rules = ''.dup
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.

#


157
158
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 157

def reset_the_shared_module
end

#respond_to_scroll_events_of_the_first_entryObject

#

respond_to_scroll_events_of_the_first_entry

#


687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 687

def respond_to_scroll_events_of_the_first_entry
  @entry_input_file.on_scroll_event {|widget, event|
    # ===================================================================== #
    # If the user scrolls then a new random file will be selected.
    # ===================================================================== #
    base_dir = File.dirname(
      File.absolute_path(@entry_input_file.text?)
    )+'/'
    this_new_file = Dir["#{base_dir}*"].select {|entry|
      ARRAY_SUPPORTED_VIDEO_FILES.include?(File.extname(entry).delete('.'))
    }.sample
    clear_the_old_entries
    work_on_this_file_now(this_new_file)
    sync_the_output_directory_based_on_this_file(this_new_file)
  }
end

#return_spinner_widgetObject

#

return_spinner_widget

#


472
473
474
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 472

def return_spinner_widget
  return new_spinner
end

#return_text1Object

#

return_text1

#


324
325
326
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 324

def return_text1
  text('Input file to use:')
end

#return_text2Object

#

return_text2

#


331
332
333
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 331

def return_text2
  text('Output file to use:')
end

#return_text3Object

#

return_text3

#


338
339
340
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 338

def return_text3
  text('Title to use:')
end

#return_text4Object

#

return_text4

#


345
346
347
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 345

def return_text4
  text('Comment:')
end

#return_text5Object

#

return_text5

#


352
353
354
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 352

def return_text5
  text('Year:')
end

#runObject

#

run (run tag)

#


718
719
720
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 718

def run
  run_super
end

#set_output_file_to_use(i) ⇒ Object

#

set_output_file_to_use

#


170
171
172
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 170

def set_output_file_to_use(i)
  @entry_output_file.set_text(i.to_s)
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


134
135
136
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 134

def smaller_font?
  SMALLER_FONT
end

#sync_the_output_directory_based_on_this_file(_) ⇒ Object

#

sync_the_output_directory_based_on_this_file

#


670
671
672
673
674
675
676
677
678
679
680
681
682
# File 'lib/multimedia_paradise/gui/universal_widgets/change_metadata_widget/change_metadata_widget.rb', line 670

def sync_the_output_directory_based_on_this_file(_)
  # ======================================================================= #
  # Sync the output directory too:
  # ======================================================================= #
  base_dir = File.dirname(_)

  new_filename = File.basename(_).dup
  new_filename.delete_suffix!(File.extname(new_filename))
  new_filename.sub!(/output/, '')
  new_filename = "#{new_filename}_output#{File.extname(_)}" # This will be like "004_Cube_output.avi"

  set_output_file_to_use("#{base_dir}/#{new_filename}")
end