class MultimediaParadise::GUI::Gtk::TagMp3Files

Public Class Methods

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

MultimediaParadise::GUI::Gtk::TagMp3Files[]

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 398
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = ARGV, run_already = true ) click to toggle source
#

initialize

#
Calls superclass method
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 18
def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  super(:vertical)
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end
run( i = ARGV ) click to toggle source
#

MultimediaParadise::GUI::Gtk::TagMp3Files.run

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 405
def self.run(
    i = ARGV
  )require 'gtk_paradise/app/app'
  tag_mp3_files = ::MultimediaParadise::GUI::Gtk::TagMp3Files.new(i)
  r = ::Gtk.app
  r << tag_mp3_files
  r.on_button_press_event { |widget, event|
    if ::Gtk.right_mouse_click?(event) # right mouse click event.
      tag_mp3_files.context_menu?.popup_based_on_this_event(event)
    end
  }
  tag_mp3_files.parent_widget = r
  r.automatic_size_then_automatic_title
  r.top_left_then_run
end

Public Instance Methods

add_custom_CSS_rules() click to toggle source
#

add_custom_CSS_rules (CSS tag)

This method is used to add additional CSS rules to this widget.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1575
  def add_custom_CSS_rules
    # ======================================================================= #
    # The first rule is to style the separator.
    # ======================================================================= #
    more_CSS_rules_then_apply_them '
button {
  border-color: steelblue;
  border-width: 2px;
}

.button_class {
  border: 2px solid steelblue;;
}

#fancy_separator separator {
  border:  1px dotted lightgrey;
  padding: 0px;
  margin:  4px;
}

.save_button {
  border: 3px dashed steelblue;
  padding: 2px;
  margin:  4px;
}

.fancy_combobox window.popup {
  color: royalblue;
  font-weight: bold;
  border: 3px dashed lightgreen;
}

/* style the top header bar next */
#header_bar_on_top {
  border: 2px dotted royalblue;
}

   '
  end
add_this_text_to_the_status_bar(this_text) click to toggle source
#

add_this_text_to_the_status_bar

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 309
def add_this_text_to_the_status_bar(this_text)
  @status_bar.push(
    @status_bar_context_id, this_text
  )
end
album()
Alias for: album?
album=(i)
Alias for: set_album
album?() click to toggle source
#

album?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 836
def album?
  @album
end
Also aliased as: album
analyse_this_song( _ = entry_file_path_text? )
artist()
Alias for: artist?
artist=(i)
Alias for: set_artist
artist?() click to toggle source
#

artist?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 216
def artist?
  @entry_for_the_artist.text?
end
Also aliased as: artist
band()
Alias for: band?
band?() click to toggle source
#

band?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 850
def band?
  @band
end
Also aliased as: band
border_size?() click to toggle source
#

border_size?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 124
def border_size?
  2
end
bpm()
Alias for: bpm?
bpm?() click to toggle source
#

bpm?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 829
def bpm?
  @bpm
end
Also aliased as: bpm
clear_old_entries() click to toggle source
#

clear_old_entries

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1736
def clear_old_entries
  @entry_for_the_album.set_text('')
  @information_about_a_mp3_file.label_mpeg_level_content.set_text('')
end
comment()
Alias for: comment?
comment=(i)
Alias for: set_comment
comment?() click to toggle source
#

comment?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 871
def comment?
  @comment
end
Also aliased as: comment
comment_entry?() click to toggle source
#

comment_entry?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 539
def comment_entry?
  @entry_for_the_comment
end
connect_skeleton() click to toggle source
#

connect_skeleton (connect skeleton, connect tag)

This method should ideally reside in the file connect_skeleton.rb

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/connect_skeleton.rb, line 20
def connect_skeleton
  abort_on_exception
  # ======================================================================= #
  # The first dragger is the one close to the top of the main application.
  # It will contain the header bar, as well as the widget that is on
  # the second row.
  # ======================================================================= #
  first_dragger = drag_via_up_and_down_movement(
    header_bar?,      # The header bar on top.
    widget_second_row # The main entry below the header bar.
  )
  first_dragger.position = header_bar_height? # This height should be the height of the header bar.
  minimal(first_dragger)
  # ======================================================================= #
  # Next the middle box - this one will contain several widgets at the
  # same time.
  # ======================================================================= #
  middle_box = drag_via_left_and_right_movement(
    widget_left,
    widget_in_the_middle
  )
  middle_box.set_name('fancy_separator')
  middle_box.position = 880

  second_dragger = drag_via_left_and_right_movement(middle_box, widget_right)
  use_this_position = 1600
  if use_this_position > max_width?
    use_this_position = max_width? * 0.8
  end
  second_dragger.position = use_this_position
  # ======================================================================= #
  # The last dragger will add the status bar to the top.
  # ======================================================================= #
  third_dragger = drag_via_up_and_down_movement(
    second_dragger,
    @status_bar # The middle vbox contains the three main widgets.
  )
  third_dragger.position = 1300
  minimal(third_dragger)
end
context_menu?() click to toggle source
#

context_menu?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1815
def context_menu?
  @context_menu
end
create_skeleton() click to toggle source
#

create_skeleton (create tag, skeleton tag)

The order for the various create-method calls is important.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 394
def create_skeleton
  create_the_labels       # (1) Must come before create_the_header_bar()
  create_the_entries      # (4) Must come before we create the header, the main grid and the buttons.
  create_the_header_bar   # (2)
  create_the_context_menu # (3) Ok to call it here.
  create_the_buttons      # (5) Must come after we create_the_entries().
  create_the_status_bar   # (6)
  create_status_icon      # (7)
  create_the_settings     # (8)
end
create_status_icon( tooltip_text = 'This text will show up upon a hover-event.' ) click to toggle source
#

create_status_icon

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 200
def create_status_icon(
    tooltip_text = 'This text will show up upon a hover-event.'
  )
  @status_icon       = gtk_status_icon
  @status_icon.stock = ::Gtk::Stock::DIALOG_INFO
  @status_icon.set_icon_name('default_status_icon_name') # We can set a name.
  @status_icon.set_tooltip_text(tooltip_text)
  @status_icon.signal_connect(:activate) { |icon|
    if icon.respond_to? :blinking
      icon.blinking = !(icon.blinking?)
    end
  }
  # =========================================================================== #
  # Add a menu and a quit-button too. These will be triggered upon a
  # right-mouse-button presse vent.
  # =========================================================================== #
  menu = gtk_menu

  play_button = ::Gtk::ImageMenuItem.new(stock: ::Gtk::Stock::MEDIA_PLAY)
  play_button.signal_connect(:activate) {
    do_play_the_selected_song
  }
  menu.append(play_button)

  quit_button = ::Gtk::ImageMenuItem.new(stock: ::Gtk::Stock::QUIT)
  quit_button.signal_connect(:activate) { ::Gtk.main_quit }
  menu.append(quit_button)

  menu.show_all
  @status_icon.signal_connect(:popup_menu) { |icon, button, time|
    menu.popup(nil, nil, button, time)
  }
end
create_table1()
create_the_buttons() click to toggle source
#

create_the_buttons (buttons tag, button tag)

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 237
def create_the_buttons
  # ======================================================================= #
  # === @button_analyse_the_mp3_file
  # ======================================================================= #
  @button_analyse_the_mp3_file = button('_Analyse the .mp3 file')
  @button_analyse_the_mp3_file.on_clicked {
    do_analyse_the_mp3_file
  }
  # ======================================================================= #
  # === @box_for_the_button_analyse_the_mp3_file
  # ======================================================================= #
  @box_for_the_button_analyse_the_mp3_file = gtk_hbox
  @box_for_the_button_analyse_the_mp3_file.maximal(@button_analyse_the_mp3_file, 2)
  @spinner = gtk_spinner
  @box_for_the_button_analyse_the_mp3_file.minimal(@spinner, 4)
  # ======================================================================= #
  # === @button_assume
  # ======================================================================= #
  @button_assume = button('Assume')
  @button_assume.hint = 'This button can be used to assume and infer '\
                        'from the filename of the .mp3 file at hand '\
                        'the artist and the name of the song. This will '\
                        'only work for some songs, naturally, and you need '\
                        'to have a file assigned prior to being able to '\
                        'use this button.'
  @button_assume.on_clicked {
    do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly
  }
  # ======================================================================= #
  # === @button_play
  # ======================================================================= #
  @button_play = return_button_play
  # ======================================================================= #
  # === @event_box_open_file
  #
  # This is a small "icon" that also makes use of an open-file functionality.
  # ======================================================================= #
  @event_box_open_file = return_event_box_for_opening_a_file
  # ======================================================================= #
  # === @button_debug
  #
  # The debug-button is created next.
  # ======================================================================= #
  @button_debug = gtk_button('_Debug')
  @button_debug.on_hover(:lightgreen)
  @button_debug.on_clicked {
    load_the_id3_dataset_from_this_file
    do_debug
  }
  @button_debug.hint = 'This button is just for quick debugging. '\
                       'Most users will not need this button.'
  # ======================================================================= #
  # === @button_update
  #
  # The update button. It will update the id3 tags at hand, once pressed.
  # ======================================================================= #
  @button_update = gtk_button('_Update') # update tag
  use_this_icon_name = 'software-update-available-symbolic.symbolic'
  icon = load_icon(use_this_icon_name, 32, 0) 
  @button_update.set_image(icon)
  @button_update.set_always_show_image(true)
  @button_update.set_border_width(1)
  @button_update.set_size_request(125, 68)
  @button_update.lightgreen
  @button_update.hint = 'Press this button to '\
    '<b>update the id3-tags</b> of the .mp3 file at hand.'
  @button_update.on_clicked {
    do_save_the_tags # Save the dataset upon a click-event.
  }
  # ======================================================================= #
  # === @button_delete_the_tags
  #
  # The delete-the-tags-button.
  # ======================================================================= #
  @button_delete_the_tags = gtk_button('Delete the tags')
  use_this_icon_name = 'edit-delete-symbolic.symbolic'
  icon = load_icon(use_this_icon_name, 32, 0)
  @button_delete_the_tags.set_image(icon)
  @button_delete_the_tags.set_always_show_image(true)
  @button_delete_the_tags.set_border_width(1)
  @button_delete_the_tags.set_size_request(125, 68)
  @button_delete_the_tags.hint =
    "Click on this button to <b>remove all tags</b> "\
    "from the given .mp3 file at hand. (The "\
    "<b>save-button</b> works in precisely the same "\
    "manner, by the way.)\n\nBe certain to use this only when you really"\
    "want to remove all tags. Otherwise it may be better to ignore this "\
    "button and instead modify the content, as-is, on the right-hand "\
    "side."
  @button_delete_the_tags.set_border_width(1)
  @button_delete_the_tags.on_clicked {
    do_empty_the_tags
  }
  @button_delete_the_tags.set_size_request(125, 68)
  # ======================================================================= #
  # === @button_save
  #
  # The save-button. It is located on the left-hand side of the main
  # UI interface. This could be made inactive via a not_sensitive call.
  # ======================================================================= #
  @button_save = return_the_save_button(:do_not_make_use_of_a_special_CSS_class)
  # ======================================================================= #
  # === @button_close
  # ======================================================================= #
  @button_close = gtk_button_with_label(' _Close') # close tag
  use_this_icon_name = 'application-exit'
  icon = load_icon(use_this_icon_name, 32, 0) # Use the video-x-generic button.
  @button_close.set_image(icon)
  @button_close.set_always_show_image(true)
  @button_close.set_border_width(1)
  @button_close.set_size_request(125, 68)
  @button_close.on_clicked { ::Gtk.main_quit }
  @button_close.do_focus
  @button_close.hint = 'Press this button to '\
                       '<b>exit the application</b>.'
  # ======================================================================= #
  # === @button_open_a_random_audio_file
  # ======================================================================= #
  @button_open_a_random_audio_file = return_button_open_a_random_audio_file
  # ======================================================================= #
  # === @button_perform_a_google_search
  # ======================================================================= #
  @button_perform_a_google_search = gtk_button_with_label(' _Google search')
  use_this_icon_name = 'help-browser'
  icon = load_icon(use_this_icon_name, 32, 0) # Use the video-x-generic button.
  @button_perform_a_google_search.set_image(icon)
  @button_perform_a_google_search.set_always_show_image(true)
  @button_perform_a_google_search.set_border_width(1)
  @button_perform_a_google_search.set_size_request(125, 68)
  @button_perform_a_google_search.on_clicked {
    do_perform_a_google_search
  }
  @button_perform_a_google_search.do_focus
  @button_perform_a_google_search.hint = "Search via google "\
    "for wikipedia-related entries about the assumed "\
    "song and group.\n\nNote that this requires some entries to "\
    "exist already, such as the name of the song, and ideally "\
    "the name of the artist as well.\n\nThis functionality depends "\
    "on the gem called '<b>open</b>', so install that gem before "\
    "trying to use this button.\n"
end
create_the_combo_box_entry_for_genre_select() click to toggle source
#

create_the_combo_box_entry_for_genre_select

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 159
def create_the_combo_box_entry_for_genre_select
  if File.exist? FILE_MUSIC_GENRES
    array_available_genres = YAML.load_file(FILE_MUSIC_GENRES)
  else
    array_available_genres = [] # Safeguard.
  end
  # ======================================================================= #
  # === @combo_box_entry_for_genre_select
  # ======================================================================= #
  @combo_box_entry_for_genre_select = return_combo_box_entry(
    with_these_elements: array_available_genres
  )
  @combo_box_entry_for_genre_select.clear_background
  # @combo_box_entry_for_genre_select.bblack1
  @combo_box_entry_for_genre_select.pad1px
  @combo_box_entry_for_genre_select.css_class('fancy_combobox')
  @combo_box_entry_for_genre_select.six_per_row
  # ======================================================================= #
  # Next we will unify the background for these entries here. Disabled
  # in August 2021.
  # ======================================================================= #
  # set_a_uniform_background_for_the_entries_on_the_right_side_widget
  # ======================================================================= #
  # Next add the combo-box that contains all genres. We will not set
  # an active entry, so that we can determine that this depends on
  # the user having set it (or not, accordingly).
  #
  #   @combo_box_entry_for_genre_select.active = 0
  #
  # ======================================================================= #
  @combo_box_entry_for_genre_select.on_changed {
    if @combo_box_entry_for_genre_select.active_iter
      text = @combo_box_entry_for_genre_select.active_text
      sync_this_text_onto_the_genre_entry(text)
    end
  }
end
create_the_context_menu() click to toggle source
#

create_the_context_menu

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 18
def create_the_context_menu
  # ======================================================================= #
  # === @context_menu
  # ======================================================================= #
  @context_menu = create_context_menu(self) {{
    # n_entries: 12,
    actions: {
      '• Play the selected audio file via mpv':              :play_the_selected_audio_file,
      '• Display some debug-information on the commandline': :show_debug_information
    }
  }}
  @context_menu.use_this_font(main_font?)
  @context_menu.css_class('bblack3_and_padding')
end
create_the_entries() click to toggle source
#

create_the_entries (entries tag, entry tag)

This method will bundle - and create - all relevant gtk-entries in this application.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 95
def create_the_entries
  # ======================================================================= #
  # === @entry_use_this_as_the_directory_to_the_local_songs
  #
  # This entry can be used to designate another directory for the
  # local .mp3 files.
  # ======================================================================= #
  @entry_use_this_as_the_directory_to_the_local_songs = gtk_entry
  @entry_use_this_as_the_directory_to_the_local_songs.set_text(
    PATH_TO_THE_LOCAL_AUDIO_DIRECTORY
  )
  # ======================================================================= #
  # === @entry_for_the_comment
  # ======================================================================= #
  @entry_for_the_comment = gtk_entry
  @entry_for_the_comment.set_max_length(120)
  @entry_for_the_comment.set_size_request(680, 40)
  # ======================================================================= #
  # === @entry_for_the_title_of_the_song
  #
  # The next entry contains the title of the song.
  # ======================================================================= #
  @entry_for_the_title_of_the_song = gtk_entry
  @entry_for_the_title_of_the_song.set_max_length(150)
  # ======================================================================= #
  # === @entry_file_path
  #
  # The next entry, stored in @entry_file_path, will keep track
  # of our audio-file. This is the most important entry.
  # ======================================================================= #
  @entry_file_path = gtk_entry
  @entry_file_path.clear_background
  @entry_file_path.pad5px
  @entry_file_path.css_class('mar4px')
  @entry_file_path.yellow_background
  @entry_file_path.bblack2
  @entry_file_path.make_bold
  @entry_file_path.width_height(620, 42)
  @entry_file_path.ghost_text('Provide the path to the .mp3 file here ...')
  array = Dir['/home/x/songs/*'].map {|entry| File.basename(entry) }
  @entry_file_path.simple_completion(array)
  @entry_file_path.on_enter {
    do_analyse_the_mp3_file
  }
  @entry_file_path.make_scrollable
  @entry_file_path.signal_connect(:event) {|widget, event|
    if scroll_up_event?(event)
      do_assign_a_new_random_audio_file
    elsif scroll_down_event?(event)
      do_assign_a_new_random_audio_file
    end
  }
  # ======================================================================= #
  # If the user double-clicks on the file path then a new local file
  # will be added.
  # ======================================================================= #
  @entry_file_path.on_mouse_double_click_event {|widget, event|
    do_open_a_local_file_and_then_set_the_proper_entry
  }
end
create_the_header_bar() click to toggle source
#

create_the_header_bar (header tag)

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 382
def create_the_header_bar
  # ======================================================================= #
  # === @header_bar
  # ======================================================================= #
  @header_bar = widget_top
end
create_the_labels() click to toggle source
#

create_the_labels (labels tag, label tag)

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 48
def create_the_labels
  # ======================================================================= #
  # === @label_description
  #
  # This is the very top-level description.
  # ======================================================================= #
  @label_description = bold_label(
    'This widget can be used to modify the ID3 tags of .mp3 files'
  )
  @label_description.css_class('indigo')
  @label_description.font_to_use = FONT_TO_USE_FOR_THE_MAIN_DESCRIPTION
end
create_the_settings() click to toggle source
#

create_the_settings

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 64
def create_the_settings
  # ======================================================================= #
  # === @settings_vbox
  # ======================================================================= #
  @settings_vbox = gtk_vbox
  # ======================================================================= #
  # Style this vbox a bit:
  # ======================================================================= #
  @settings_vbox.pad5px
  @settings_vbox.set_border_width(20)
  @settings_vbox.use_this_font = main_font?
  _ = text("Settings\n")
  _.use_this_font = main_font?
  @settings_vbox.add(_)
  @settings_vbox.add_hspacer
  hbox = gtk_hbox
  hbox.minimal(left_aligned_text('Specify the directory to the local songs here: '), 2)
  hbox.minimal(@entry_use_this_as_the_directory_to_the_local_songs)
  @settings_vbox << hbox
  @settings_vbox.add_hspacer
  @settings_vbox.use_this_font = main_font?
  @settings_vbox.width_height(800, 300)
  @settings_vbox.show_all
end
create_the_status_bar() click to toggle source
#

create_the_status_bar

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/create.rb, line 36
def create_the_status_bar
  # ======================================================================= #
  # === @status_bar
  # ======================================================================= #
  @status_bar = gtk_status_bar
  @status_bar.bblack1
  @status_bar_context_id = @status_bar.get_context_id('tag_mp3_files')
end
dataset?()
date()
Alias for: date?
date?() click to toggle source
#

date?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 815
def date?
  @date
end
Also aliased as: date
determine_the_metadata_for_this_song( _ = entry_file_path_text? )
disc()
Alias for: disc?
disc?() click to toggle source
#

disc?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 822
def disc?
  @disc
end
Also aliased as: disc
display_information_about_the_song() click to toggle source
#

display_information_about_the_song (debug tag)

This method exists mostly to simplify debugging the application at hand.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1692
def display_information_about_the_song
  # ======================================================================= #
  # Get and set text frames with convenience methods.
  # ======================================================================= #
  e horizontal_unicode_bar*80
  dataset = metadata?
  if dataset
    ee 'Title: '.ljust(30);     pp dataset.title # => "Talk"
    ee 'Album: '.ljust(30);     pp dataset.album # new album setter
    ee 'Performer: (not in use) '.ljust(30);pp dataset.performer # performer; this is not in use by this application though.
    ee 'Artist: '.ljust(30);    pp dataset.artist
    ee 'Band: '.ljust(30);      pp dataset.band
    ee 'bpm: '.ljust(30);       pp dataset.bpm
    ee 'Date: '.ljust(30);      pp dataset.date
    ee 'Disc: '.ljust(30);      pp dataset.disc
    ee 'Genre: '.ljust(30);     pp dataset.genre
    ee 'time: '.ljust(30);      pp dataset.time if dataset.respond_to? :time
    ee 'track: '.ljust(30);     pp dataset.track if dataset.respond_to? :track
    ee 'language: '.ljust(30);  pp dataset.language if dataset.respond_to? :language
    ee 'Grouping: '.ljust(30);  pp dataset.grouping if dataset.respond_to? :grouping
    ee 'Encoded by: '.ljust(30);pp dataset.encoded_by if dataset.respond_to? :encoded_by
    ee 'composer: '.ljust(30);  pp dataset.composer if dataset.respond_to? :composer
    ee 'Track: '.ljust(30);     pp dataset.track if dataset.respond_to? :track # new track setter
    ee 'Year: '.ljust(30);      pp dataset.year # 2000, query year.
    ee 'Comment: '.ljust(30);   pp dataset.comment # Comments are listed there.
    e horizontal_unicode_bar*80
    e
  else
    e 'No dataset has been assigned yet.'
  end
end
Also aliased as: do_debug
do_activate_the_save_button()
do_analyse_the_audio_file( _ = entry_file_path_text? )
do_analyse_the_audio_file_at_once( _ = entry_file_path_text? )
do_analyse_the_audio_file_then_set_all_relevant_entries() click to toggle source
#

do_analyse_the_audio_file_then_set_all_relevant_entries

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1565
def do_analyse_the_audio_file_then_set_all_relevant_entries
  do_analyse_the_audio_file(entry_file_path_text?)
  set_all_relevant_entries_based_on_the_metadata
end
do_analyse_the_default_file( _ = entry_file_path_text? )
do_analyse_the_mp3_file( _ = entry_file_path_text? ) click to toggle source
#

do_analyse_the_mp3_file (analyse tag, load tag)

This is closely related to the method called do_analyse_the_audio_file_then_set_all_relevant_entries().

This is the method that should be called when the user wants to obtain information about the metadata of the song (.mp3 file) at hand.

It will not do anything with the different gtk-widgets in use, so you have to call other methods if you want to sync towards the gtk-widgets.

We also need to check whether ID3Lib is available if this is used; in particular windows-users may often not have it installed by default.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1205
  def do_analyse_the_mp3_file(
      _ = entry_file_path_text?
    )
    if _ and !_.empty? and File.exist?(_)
      # ===================================================================== #
      # First we have to honour the correct id-tagger to use, as specified
      # by the user.
      # ===================================================================== #
      case ID_TAGGER_TO_USE_FOR_THE_MP3_FILES
      # ===================================================================== #
      # === :taglib
      #
      # We must notify the user that taglib is mandatory - otherwise the
      # application will not work properly.
      # ===================================================================== #
      when :taglib
        unless Object.const_defined? :TagLib
          text_to_display = <<-EOF
Please install TagLib first via:

  <b>gem install taglib-ruby</b>

EOF
        custom_widget = gtk_vbox
        custom_widget.pad12px
        custom_widget.bblack1
        button_to_use = button('gem install taglib-ruby')
        button_to_use.on_clicked {
          esystem(button_to_use.text?)
        }
        custom_widget.maximal(button_to_use)
        custom_widget.show_all
          a_new_popup = return_popover(
            text_to_display,
            entry_on_top?,
            25, # Padding is 25 px.
            custom_widget
          )
          a_new_popup.popup
        end
      # ===================================================================== #
      # === :id3lib
      # ===================================================================== #
      when :id3lib
        if Object.const_defined? :ID3Lib
          this_song = ID3Lib::Tag.new(this_song)
          # Enable the save-button functionality. This is currently (2021)
          # not needed anymore.
          # the_save_button_is_available_again
        else
          e 'ID3Lib is not available/installed. Please install '\
            'it for your platform / operating-system.'
        end
      end
      @spinner.start_spinning
      Thread.new {
        # =================================================================== #
        # Clear the old status-bar message first.
        # =================================================================== #
        add_this_text_to_the_status_bar('')
        # =================================================================== #
        # The class here is: MultimediaParadise::AudioTagReader.
        # The old code used MultimediaParadise::AudioTagReader.new()
        # directly. In September 2021 this was changed to a
        # toplevel-method instead.
        # =================================================================== #
        clear_old_entries
        e steelblue('-' * 60)
        instantiate_the_metadata_from_this_file(_)# This will set @metadata_for_the_song
        @metadata_for_the_song.report # This can be used for debugging.
        @information_about_a_mp3_file.set_duration(@metadata_for_the_song.length_in_seconds?.to_s)
        file_size = File.size(_)
        @information_about_a_mp3_file.set_filesize(file_size.to_s)
        # entry_for_the_title_of_the_song?.set_text(@metadata_for_the_song.title?.to_s)
        do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly
        sync_everything
        @spinner.stop_spinning # Now we can stop spinning.
        if is_on_roebe?
          display_information_about_the_song
          e 'Next, as we are on roebe, we will display the '+
            ::Colours.steelblue('@dataset')+' variable.'
          pp dataset?
        end
      }
    else
      e 'First assign a path, please.'
    end
  end
do_assign_a_new_random_audio_file() click to toggle source
#

do_assign_a_new_random_audio_file

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1455
def do_assign_a_new_random_audio_file
  _ = return_random_audio_file.to_s
  unless _.empty? # Check against no results.
    entry_file_path?.set_text(_)
    do_open_a_random_audio_file_and_then_set_the_proper_entry
  end
end
do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly() click to toggle source
#

do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1751
def do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly
  _ = filename?
  if _ and File.exist?(_)
    raw_name = File.basename(_)
    # ===================================================================== #
    # Get rid of the extension.
    # ===================================================================== #
    raw_name.delete_suffix!(
      File.extname(raw_name)
    )
    if raw_name.include? '_'
      splitted    = raw_name.split('_')
      artist_name = splitted.first.to_s
      song_name   = splitted.last.to_s
      @entry_for_the_artist.set_text(artist_name)
      entry_for_the_song_name?.set_text(song_name)
    else
      @entry_for_the_artist.set_text(raw_name)
    end
  else
    e 'No file has been assigned yet. Please assign a file first.'
  end
end
do_debug()
do_determine_the_length_of_the_song( this_file = main_file? ) click to toggle source
#

do_determine_the_length_of_the_song

The first argument should be the name of the .mp3 file at hand.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1024
def do_determine_the_length_of_the_song(
    this_file = main_file?
  )
  # ======================================================================= #
  # The way for the mp3-library goes like this:
  #   @length_in_seconds = @properties.length_in_seconds  # => 335 (song length)
  # But this was buggy for me, so we query ffmpeg instead. The code above
  # is retained, though, in the event that we may want to re-instate it
  # one day. (Noted this down at 26.10.2021)
  # ======================================================================= #
  @length_in_seconds = ::MultimediaParadise.length_of?(this_file)
end
do_empty_the_tags() click to toggle source
#

do_empty_the_tags

This method will empty our tags.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 199
def do_empty_the_tags
  dataset = dataset?
  if dataset
    dataset.album   = ''
    dataset.artist  = ''
    dataset.comment = ''
    dataset.genre   = ''
    dataset.title   = ''
    dataset.track   = ''
    dataset.year    = ''
    @button_save.sensitive = true
  end
end
Also aliased as: empty_tags
do_focus_on_the_entry_containing_the_title_of_the_song() click to toggle source
#

do_focus_on_the_entry_containing_the_title_of_the_song

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 138
def do_focus_on_the_entry_containing_the_title_of_the_song
  @entry_for_the_title_of_the_song.do_focus
end
do_look_for_a_local_file_and_then_analyse_the_audio_file_at_once() click to toggle source
#

do_look_for_a_local_file_and_then_analyse_the_audio_file_at_once (open tag)

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1342
def do_look_for_a_local_file_and_then_analyse_the_audio_file_at_once
  look_for_a_local_file {{
    filter_for:             %w( .mp3 .ogg ),
    start_directory:        return_path_to_the_local_songs_directory_or_return_pwd,
    additional_directories: [return_pwd] # Always add the current working directory.
  }}
  @entry_file_path.set_text(::Gtk.main_file?.to_s)
  do_analyse_the_audio_file_at_once
end
do_open_a_local_file_and_then_set_the_proper_entry( _ = entry_file_path_text? )
do_open_a_random_audio_file_and_then_set_the_proper_entry( _ = return_random_audio_file ) click to toggle source
#

do_open_a_random_audio_file_and_then_set_the_proper_entry

The first argument to this method must be the file path to the local .mp3 file at hand.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1161
def do_open_a_random_audio_file_and_then_set_the_proper_entry(
    _ = return_random_audio_file
  )
  clear_old_entries # We must clear old entries as well.
  entry_file_path?.set_text(_.to_s)
  # ======================================================================= #
  # If the file exists we will also update the file size label.
  # ======================================================================= #
  if File.exist? _
    do_analyse_the_audio_file(entry_file_path_text?)
    set_all_relevant_entries_based_on_the_metadata
    # ===================================================================== #
    # Empty the status bar as well whenever a new file is assigned.
    # ===================================================================== #
    add_this_text_to_the_status_bar('')
  end
end
do_open_the_file_opener_dialog()
do_popup_the_settings_widget() click to toggle source
#

do_popup_the_settings_widget (settings tag)

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 458
def do_popup_the_settings_widget
  if @settings_popover.nil?
    @settings_popover = return_popover(
      '',
      header?, # This is the header bar actually.
      :default_padding, # This is the default padding to use.
      @settings_vbox
    )
  end
  @settings_popover.popup
end
do_save_tags()
Alias for: do_save_the_tags
do_save_the_tags() click to toggle source
#

do_save_the_tags (save tag)

This method applies all changes by invoking metadata?.update!

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1468
def do_save_the_tags
  metadata = metadata?
  return unless metadata
  display_information_about_the_song if is_on_roebe?
  # ======================================================================= #
  # Squeeze the entry for the comment, so that leading and trailing ' '
  # are not retained.
  # ======================================================================= #
  _ = @entry_for_the_comment.text?
  if _ and !_.empty?
    @entry_for_the_comment.set_text(_.strip)
  end
  metadata.title   = @entry_for_the_title_of_the_song.text
  metadata.album   = @entry_for_the_album.text
  metadata.artist  = @entry_for_the_artist.text
  metadata.comment = @entry_for_the_comment.text
  metadata.track   = @entry_for_the_track_number.text
  metadata.year    = @entry_for_the_year.text
  metadata.genre   = return_entry_from_the_combo_box_entry_for_genre_select_or_from_the_entry_for_the_genre
  # ======================================================================= #
  # Next we will update the dataset and apply the changes made above.
  # ======================================================================= #
  metadata.update! 
  display_information_about_the_song if is_on_roebe?
  # ======================================================================= #
  # Update the status-bar as well.
  # ======================================================================= #
  add_this_text_to_the_status_bar(
    'The meta-data was saved (on '+
    ::MultimediaParadise.return_ss_mm_hh.to_s+').'
  )
end
Also aliased as: do_save_tags
do_show_information_about_this_application() click to toggle source
#

do_show_information_about_this_application (about tag)

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1528
def do_show_information_about_this_application
  dialog = gtk_about_dialog
  authors = ['Robert A. Heiler']
  documenters = ['Robert A. Heiler']
  begin
    logo = GdkPixbuf::Pixbuf.new(
      pixbuf: return_pixbuf_based_on_the_default_icon_theme(:inode_directory)
    )
    dialog.set_logo(logo)
  rescue Exception => error
    pp error
  end
  dialog.set_name('tag_mp3_files')
  dialog.set_version(::MultimediaParadise::VERSION)
  dialog.set_copyright("(C) 2022 Robert A. Heiler")
  dialog.set_comments(
    "This application can be used to rename the meta-tags "\
    "of .mp3 files. It is recommended to install the "\
    "taglib-ruby gem, in order to use this application."
  )
  dialog.license = 'GPL-2.0'
  dialog.set_website(
    'https://rubygems.org/gems/multimedia_paradise'
  )
  dialog.set_website_label('https://rubygems.org/gems/multimedia_paradise')
  dialog.set_authors(authors)
  dialog.set_documenters(documenters)
  dialog.set_program_name('tag_mp3_files')
  dialog.signal_connect(:response) {
    dialog.destroy
  }
  dialog.run
end
empty_tags()
Alias for: do_empty_the_tags
ensure_that_we_have_a_dataset( _ = entry_file_path_text? )
entry_file_path?()
entry_for_the_song_name?()
entry_for_the_title_of_the_song?() click to toggle source
#

entry_for_the_title_of_the_song?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 496
def entry_for_the_title_of_the_song?
  @entry_for_the_title_of_the_song
end
Also aliased as: entry_for_the_song_name?
entry_on_top?()
entry_use_which_audio_file?() click to toggle source
#

entry_use_which_audio_file?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1661
def entry_use_which_audio_file?
  @entry_file_path
end
Also aliased as: entry_on_top?, entry_file_path?
filename?() click to toggle source
#

filename?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1744
def filename?
  @entry_file_path.text?.to_s
end
genre()
Alias for: genre?
genre=(i)
Alias for: set_genre
genre?() click to toggle source
#

genre?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 857
def genre?
  @genre
end
Also aliased as: genre
handle_CSS_rules() click to toggle source
#

handle_CSS_rules (CSS tag)

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1727
def handle_CSS_rules
  use_gtk_paradise_project_css_file
  append_project_css_file
  add_custom_CSS_rules
end
header?()
Alias for: header_bar?
header_bar?() click to toggle source
#

header_bar?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 131
def header_bar?
  @header_bar
end
Also aliased as: header?
header_bar_height?() click to toggle source
#

header_bar_height?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1141
def header_bar_height?
  54
end
instantiate_the_metadata_from_this_file(this_file) click to toggle source
#

instantiate_the_metadata_from_this_file

This will set @metadata_for_the_song.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1110
def instantiate_the_metadata_from_this_file(this_file)
  # ======================================================================= #
  # === @metadata_for_the_song
  # ======================================================================= #
  @metadata_for_the_song = MultimediaParadise.analyse_tags_of_this_mp3_file(this_file)
end
label_duration_content?() click to toggle source
#

label_duration_content?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 503
def label_duration_content?
  @information_about_a_mp3_file.label_duration_content?
end
length_in_seconds?() click to toggle source
#

length_in_seconds?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1015
def length_in_seconds?
  @length_in_seconds
end
load_the_id3_dataset_from_this_file( _ = entry_file_path_text? )
main_file?()
Alias for: this_file?
menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

The most important aspect for menu() is to allow the user to load up a specific .mp3 file, on startup of this application.

Usage example for this on my home system:

tag_mp3_files /home/x/songs/Womack_and_Womack_Teardrops.mp3
gtkidrenamer  /home/x/songs/2Pac_GhettoGospel.mp3
#
metadata?()
metadata_for_the_song?() click to toggle source
#

metadata_for_the_song?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1120
def metadata_for_the_song?
  @metadata_for_the_song
end
Also aliased as: metadata?, dataset?
padding?() click to toggle source
#

padding?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 117
def padding?
  4
end
parent_widget=(i = ARGV) click to toggle source
#

parent_widget=

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 236
def parent_widget=(i = ARGV)
  i = i.first if i.is_a? Array
  @parent_widget = i
end
parse_the_commandline_arguments( i = commandline_arguments? )
Alias for: menu
performer()
Alias for: performer?
performer?() click to toggle source
#

performer?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 864
def performer?
  @performer
end
Also aliased as: performer
report()
Alias for: report_everything
report_album(i = @album) click to toggle source
#

report_album

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 747
def report_album(i = @album)
  e sfancy('  Album: '.ljust(N_PAD))+
    right_colour(i.to_s)
end
report_artist(i = @artist) click to toggle source
#

report_artist

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 739
def report_artist(i = @artist)
  e sfancy('  Artist: '.ljust(N_PAD))+
    right_colour(i.to_s)
end
report_comment(i = @comment) click to toggle source
#

report_comment

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 755
def report_comment(i = @comment)
  e sfancy('  Comment: '.ljust(N_PAD))+
    right_colour(i.to_s)
end
report_everything() click to toggle source
#

report_everything

This method will report as much as possible about the song at hand.

“track” would also be a tag that could be shown. Personally I don’t really need it, though.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 953
def report_everything
  report_title
  report_artist
  report_album
  report_year
  report_genre
  report_comment
  report_length_in_seconds
end
Also aliased as: report
report_genre(i = @genre) click to toggle source
#

report_genre

To get all available genres, see:

https://en.wikipedia.org/wiki/ID3#Genre_list_in_ID3v1[12]
#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 768
def report_genre(i = @genre)
  e sfancy('  Genre: '.ljust(N_PAD))+
    right_colour(i.to_s)
end
report_length_in_seconds( i = @length_in_seconds ) click to toggle source
#

report_length_in_seconds

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 784
def report_length_in_seconds(
    i = @length_in_seconds
  )
  e sfancy('  Duration (in seconds): '.ljust(N_PAD))+
    right_colour(i.to_s)
end
report_title(i = @title) click to toggle source
#

report_title

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1093
def report_title(i = @title)
  e sfancy('  Title: '.ljust(N_PAD))+
    right_colour(i.to_s)
end
report_year(i = @year) click to toggle source
#

report_year

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 776
def report_year(i = @year)
  e sfancy('  Year: '.ljust(N_PAD))+
    right_colour(i.to_s)
end
require_the_appropriate_id_tagger( i = ID_TAGGER_TO_USE_FOR_THE_MP3_FILES ) click to toggle source
#

require_the_appropriate_id_tagger

This method will load the correct id-tagger for .mp3 files. We need to make this flexible, in the event that the user wants to use another id-tagger rather than the “default” one.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 65
def require_the_appropriate_id_tagger(
    i = ID_TAGGER_TO_USE_FOR_THE_MP3_FILES
  )
  case i
  # ======================================================================= #
  # === :taglib
  #
  # Note that since as of the year 2021, taglib is the default id3-tagger
  # that will be used by this application, thus replacing the older
  # id3lib code. The latter is still retained, though, in the event
  # we may have to switch again one day. But in my opinion taglib is
  # actually better than idlib.
  # ======================================================================= #
  when :taglib
    begin
      require 'taglib'
    rescue LoadError
      e "the taglib gem is not available. Please install it."
      e
      e '  gem install taglib-ruby # The github-page is at: '\
        'https://github.com/robinst/taglib-ruby'
      e
      if is_on_roebe?
        e 'As we are on roebe we will install the gem next.'
        e
        system 'gem install taglib-ruby'
        e
        begin
          require 'taglib'
        rescue LoadError; end
      end
    end
  # ======================================================================= #
  # === when :idlib
  # ======================================================================= #
  when :idlib
    begin
      require 'id3lib'
    rescue LoadError
      e "ruby-id3lib not available. Please install it."
      e
      e '  gem install id3lib-ruby'
      e
    end
  else
    e "Unknown ID-tagger #{i}"
  end
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 33
def reset
  reset_the_internal_variables
  infer_the_namespace
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, namespace?]
  title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
  infer_the_size_automatically
  handle_CSS_rules # Should be called from the reset() method.
  # ======================================================================= #
  # === @information_about_a_mp3_file
  # ======================================================================= #
  @information_about_a_mp3_file = return_widget_information_about_a_mp3_file
  # ======================================================================= #
  # === @metadata_for_the_song
  #
  # This variable will change when the metadata of a song is analysed.
  # It will contain the dataset of that song, including the audio
  # tags, at a later point - whenever a .mp3 file is analysed.
  # ======================================================================= #
  @metadata_for_the_song = nil
  require_the_appropriate_id_tagger
end
reset_all_main_entries() click to toggle source
#

reset_all_main_entries

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 160
def reset_all_main_entries
  @entry_for_the_title_of_the_song.set_text('')
  @entry_for_the_year.set_text('')
  @entry_for_the_artist.set_text('')
  @entry_for_the_genre.set_text('')
  @entry_for_the_comment.set_text('')
end
return_all_entries_on_the_right_side_widget() click to toggle source
#

return_all_entries_on_the_right_side_widget

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 145
def return_all_entries_on_the_right_side_widget
  [ # Let's keep them ordered how we want to display them.
    @entry_for_the_artist,
    @entry_for_the_year,
    @entry_for_the_album,
    @entry_for_the_comment,
    @entry_for_the_track_number,
    @entry_for_the_genre,
    @entry_for_the_title_of_the_song
  ]
end
return_button_open_a_random_audio_file( options = nil ) click to toggle source
#

return_button_open_a_random_audio_file

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1357
def return_button_open_a_random_audio_file(
    options = nil
  )
  use_this_icon_name = 'folder-music'
  icon = load_icon(use_this_icon_name, 32, 0)
  case options
  # ======================================================================= #
  # === :no_text
  # ======================================================================= #
  when :no_text
    button = create_button
    button.set_image(icon)
  else
    button = gtk_button_with_label('Open _random audio-file')
    button.set_image(icon)
    button.set_always_show_image(true)
    button.set_border_width(1)
    button.set_size_request(125, 68)
  end
  button.hint =
    "This button can, upon being clicked, be used to <b>open a random</b> .mp3 "\
    "file.\n\n"\
    "Take note that the path to these random audio files default to "\
    "a hardcoded path specified based on a constant, "\
    "so you may have to change this to fit to your own "\
    "computer system.\n\n"+
    "The constant that determines this is called "\
    "<span weight=\"bold\" foreground=\"gold\" background=\"black\">PATH_TO_THE_LOCAL_AUDIO_DIRECTORY</span>,"\
    "and it currently points at "\
    "<span weight=\"bold\" foreground=\"gold\" background=\"black\">#{@entry_use_this_as_the_directory_to_the_local_songs.text?}</span>,"\
    ", so make sure that you adapt this to your own setup.\n"
  button.on_clicked {
    do_open_a_random_audio_file_and_then_set_the_proper_entry
  }
  return button
end
return_button_play() click to toggle source
#

return_button_play

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 377
def return_button_play
  button_play = gtk_button_with_label(' _Play')
  use_this_icon_name = 'video-x-generic-symbolic.symbolic'
  icon = load_icon(use_this_icon_name, 32, 0) # Use the video-x-generic button.
  button_play.set_image(icon)
  button_play.set_always_show_image(true)
  button_play.set_border_width(1)
  button_play.set_size_request(120, 65)
  button_play.lightgreen
  button_play.hint =
    'Click this button in order to <b>play</b> the selected song. '\
    'Make sure to select a .mp3 file that exists locally as well.'
  button_play.on_clicked {
    do_play_the_selected_song
  }
  return button_play
end
return_entry_from_the_combo_box_entry_for_genre_select_or_from_the_entry_for_the_genre() click to toggle source
#

return_entry_from_the_combo_box_entry_for_genre_select_or_from_the_entry_for_the_genre

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 274
def return_entry_from_the_combo_box_entry_for_genre_select_or_from_the_entry_for_the_genre
  _ = @combo_box_entry_for_genre_select.active_text
  unless @entry_for_the_genre.text.to_s.empty?
    _ = @entry_for_the_genre.text.to_s
  end
  return _
end
return_event_box_for_opening_a_file( width = 110, height = 65 ) click to toggle source
#

return_event_box_for_opening_a_file

The first two arguments can designate a certain width and height for the widget.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1308
def return_event_box_for_opening_a_file(
    width  = 110,
    height =  65
  )
  event_box_open_file = gtk_event_box
  # ======================================================================= #
  # In April 2021 the code below this comment was changed to an image.
  #
  # Relying on an emoji is unfortunately not that reliable, because
  # we depend on the emojis available on the local computer. This
  # may not always work, whereas with an image we can depend on
  # more reliably so.
  #
  #   event_box_open_file << emoji(:open_file)
  #
  # ======================================================================= #
  # event_box_open_file << gtk_image(:open_local_file)
  event_box_open_file << text('Open a local file')
  event_box_open_file.set_border_width(1)
  event_box_open_file.set_size_request(125, 68)
  event_box_open_file.css_class('button_class')
  event_box_open_file.pad5px
  event_box_open_file.on_clicked {
    do_look_for_a_local_file_and_then_analyse_the_audio_file_at_once
  }
  event_box_open_file.hint =
    'Click on this button to open '\
    '<b>a local .mp3 file</b>.'
  return event_box_open_file
end
return_random_audio_file( from_this_directory = @entry_use_this_as_the_directory_to_the_local_songs.text? ) click to toggle source
#

return_random_audio_file

This method can be used to return a random audio file from a given (local) directory. This will only work, evidently, when the directory contains audio files.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 322
def return_random_audio_file(
    from_this_directory =
      @entry_use_this_as_the_directory_to_the_local_songs.text?
  )
  if File.directory? from_this_directory.delete('*')
    _ = from_this_directory.delete('*')+'*'
    this_file = Dir[_].select {|entry|
      entry.end_with?('.mp3')
    }.sample
    return this_file
  end
  return nil
end
return_the_grid_containing_the_bitrate_and_associated_values()
return_the_header_bar()
Alias for: widget_top
return_the_save_button( make_use_of_special_CSS_rules = true ) click to toggle source
#

return_the_save_button

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 339
def return_the_save_button(
    make_use_of_special_CSS_rules = true
  )
  case make_use_of_special_CSS_rules
  # ======================================================================= #
  # === :do_not_make_use_of_a_special_CSS_class
  # ======================================================================= #
  when :do_not_make_use_of_a_special_CSS_class
    make_use_of_special_CSS_rules = false
  end
  button_save = gtk_button_with_label(' _Save', use_underline: true) # (:save) # (save tag)
  use_this_icon_name = 'folder-download'
  icon = load_icon(use_this_icon_name, 32, 0) # Use the window-close example.
  button_save.set_image(icon)
  button_save.set_border_width(1)
  button_save.set_size_request(125, 68)
  button_save.set_always_show_image(true)
  if make_use_of_special_CSS_rules
    button_save.css_class('save_button')
  end
  button_save.hint = 'Click this button in order to <b>save</b> the id3 '\
                     'tags into the .mp3 file at hand.'
  button_save.on_clicked {
    do_save_tags
  }
  return button_save
end
return_vbox_containing_the_buttons()
Alias for: widget_right
return_widget_information_about_a_mp3_file() click to toggle source
#

return_widget_information_about_a_mp3_file

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1148
def return_widget_information_about_a_mp3_file
  @information_about_a_mp3_file = MultimediaParadise::GUI::Gtk::InformationAboutAMp3File.new
  @information_about_a_mp3_file.set_parent_widget(self)
  return @information_about_a_mp3_file
end
right_colour(i) click to toggle source
#

right_colour

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1101
def right_colour(i)
  mediumpurple(i)
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1822
def run
  create_skeleton_then_connect_skeleton
  menu # Must come after the skeleton has been created.
  do_focus_on_the_entry_containing_the_title_of_the_song
  apply_the_CSS_rules
end
Also aliased as: run_the_gtk_widget
run_the_gtk_widget()
Alias for: run
save() click to toggle source
#

save

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1079
def save
  @tag.save
end
set_a_uniform_background_for_the_entries_on_the_right_side_widget( array = return_all_entries_on_the_right_side_widget ) click to toggle source
#

set_a_uniform_background_for_the_entries_on_the_right_side_widget

This is currently (August 2021) not in use. I realized that it actually rather distracts then enhances. I keep it here if we want to re-enable it again at one moment in time.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1649
def set_a_uniform_background_for_the_entries_on_the_right_side_widget(
    array = return_all_entries_on_the_right_side_widget
  )
  array.each {|this_entry|
    this_entry.clear_background
    this_entry.very_light_yellowish_background
  }
end
set_album(i) click to toggle source
#

set_album

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 892
def set_album(i)
  @album = i.to_s
end
Also aliased as: album=
set_all_relevant_entries_based_on_the_metadata( this_file = main_file? ) click to toggle source
#

set_all_relevant_entries_based_on_the_metadata (sync tag)

This method will sync all relevant entries into the corresponding gtk-entry at hand.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1781
def set_all_relevant_entries_based_on_the_metadata(
    this_file = main_file?
  )
  # ======================================================================= #
  # First ensure that the file exists.
  # ======================================================================= #
  if this_file.nil? or !File.exist?(this_file)
    e "No file exists at `#{sfile(this_file)}`."
    _ = return_popover("No file exists at #{this_file}.", entry_on_top?)
    _.popup
    return
  end
  set_the_file_size_from_this_file
  # ======================================================================= #
  # Keep track of the song's duration as well.
  # ======================================================================= #
  sync_the_duration_of_the_file_onto_the_correct_entry
  sync_title_onto_entry
  sync_year_onto_entry
  sync_artist_onto_entry
  sync_genre_onto_entry
  sync_comment_onto_entry
  set_the_bitrate(
    MultimediaParadise.bitrate_of_this_song(this_file)
  )
  set_the_samplerate(
    MultimediaParadise.samplerate_of_this_song(this_file)
  )
  update_the_MPEG_entry(this_file)
end
Also aliased as: sync_everything
set_artist(i) click to toggle source
#

set_artist

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 899
def set_artist(i)
  @artist = i.to_s
end
Also aliased as: artist=
set_comment(i) click to toggle source
#

set_comment

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 906
def set_comment(i)
  @comment = i.to_s
end
Also aliased as: comment=
set_genre(i) click to toggle source
#

set_genre

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 927
def set_genre(i)
  @genre = i.to_s
end
Also aliased as: genre=
set_main_entry(i) click to toggle source
#

set_main_entry

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1182
def set_main_entry(i)
  @entry_file_path.set_text(i)
  if File.exist? i # Safeguard.
    do_analyse_the_default_file
    set_all_relevant_entries_based_on_the_metadata
  end
end
set_new_album(i) click to toggle source
#

set_new_album

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 941
def set_new_album(i)
  @tag.album = i
end
set_new_year(i) click to toggle source
#

set_new_year

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 934
def set_new_year(i)
  @tag.year = i.to_i # This must be an Integer.
end
set_the_bitrate(i) click to toggle source
#

set_the_bitrate

This method will update the appropriate label in the grid, containing the bitrate of the .mp3 file.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 513
def set_the_bitrate(i)
  @information_about_a_mp3_file.label_bit_rate_content?.set_text(i.to_s)
end
set_the_file_size_from_this_file( this_file = @entry_file_path.text? ) click to toggle source
#

set_the_file_size_from_this_file

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1618
def set_the_file_size_from_this_file(
    this_file = @entry_file_path.text?
  )
  @information_about_a_mp3_file.label_file_size_content.set_text(
    "#{(File.size(this_file) / 1024.0 / 1000.0).round(2)} MB".
    rjust(8)
  )
end
set_the_samplerate(i) click to toggle source
#

set_the_samplerate

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 520
def set_the_samplerate(i)
  @information_about_a_mp3_file.label_sample_rate_content.set_text(i.to_s)
end
set_this_file(i) click to toggle source
#

set_this_file

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1086
def set_this_file(i)
  @this_file = i
end
set_title(i) click to toggle source
#

set_title

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 885
def set_title(i)
  @title = i.to_s
end
Also aliased as: title=
set_track(i) click to toggle source
#

set_track

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 913
def set_track(i)
  @track = i.to_i # This must be an Integer.
end
Also aliased as: track=
set_year(i) click to toggle source
#

set_year

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 920
def set_year(i)
  @year = i.to_i # This must be an Integer.
end
Also aliased as: year=
show_debug_information() click to toggle source
#

show_debug_information

This method can be used to show some debug-related information.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 225
def show_debug_information
  e
  e '@width and @height are: '+
    @width.to_s+', '+
    @height.to_s
  e
end
song_name?() click to toggle source
#

song_name?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 171
def song_name?
  @entry_for_the_title_of_the_song.text?
end
sync_artist_onto_entry() click to toggle source
#

sync_artist_onto_entry

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 178
def sync_artist_onto_entry
  if metadata?
    @entry_for_the_artist.set_text(metadata?.artist.to_s)
  end
end
sync_comment_onto_entry() click to toggle source
#

sync_comment_onto_entry

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1630
def sync_comment_onto_entry
  dataset = dataset?
  if dataset
    _ = dataset.comment.to_s.dup
    # ===================================================================== #
    # We have to use the proper encoding for the comment-field.
    # ===================================================================== #
    _ = _.force_encoding(::MultimediaParadise::UTF_ENCODING)
    @entry_for_the_comment.set_text(_)
  end
end
sync_everything( this_file = main_file? )
sync_genre_onto_entry( this_text = :infer_from_the_dataset ) click to toggle source
#

sync_genre_onto_entry

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 527
def sync_genre_onto_entry(
    this_text = :infer_from_the_dataset
  )
  if dataset?
    this_text = dataset?.genre.to_s
    @entry_for_the_genre.set_text(this_text)
  end
end
sync_the_duration_of_the_file_onto_the_correct_entry( _ = @metadata_for_the_song ) click to toggle source
#

sync_the_duration_of_the_file_onto_the_correct_entry

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1128
def sync_the_duration_of_the_file_onto_the_correct_entry(
    _ = @metadata_for_the_song
  )
  if _
    use_this_duration = _.length_in_seconds?.round(5).to_s
    label_duration_content?.set_text(use_this_duration)
    label_duration_content?.make_bold
  end
end
sync_this_text_onto_the_genre_entry(i) click to toggle source
#

sync_this_text_onto_the_genre_entry

This method can be used to “sync” onto the entry containing the genre tag. We won’t do any additional sanitizing or checks within this method, excluding .to_s, so you have to ensure that the given input is valid, as-is.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1519
def sync_this_text_onto_the_genre_entry(i)
  @entry_for_the_genre.set_text(i.to_s)
  @entry_for_the_genre.make_bold
end
sync_title_onto_entry() click to toggle source
#

sync_title_onto_entry

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1680
def sync_title_onto_entry
  dataset = dataset?
  if dataset
    @entry_for_the_title_of_the_song.set_text(dataset.title.to_s)
  end
end
sync_year_onto_entry() click to toggle source
#

sync_year_onto_entry

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 187
def sync_year_onto_entry
  dataset = dataset?
  if dataset
    @entry_for_the_year.set_text(dataset.year.to_s)
  end
end
tag()
Alias for: tag?
tag?() click to toggle source
#

tag?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 794
def tag?
  @tag
end
Also aliased as: tag
the_save_button_is_available_again() click to toggle source
#

the_save_button_is_available_again

This is currently (January 2021) not in use. I am not sure whether it will be re-enabled, but for now the method will remain part of the widget.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1673
def the_save_button_is_available_again
  @button_save.is_sensitive_again
end
Also aliased as: do_activate_the_save_button
this_file?() click to toggle source
#

this_file?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1008
def this_file?
  @this_file
end
Also aliased as: main_file?
title()
Alias for: title?
title=(i)
Alias for: set_title
title?() click to toggle source
#

title?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 801
def title?
  @title
end
Also aliased as: title
track()
Alias for: track?
track=(i)
Alias for: set_track
track?() click to toggle source
#

track?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 878
def track?
  @track
end
Also aliased as: track
try_to_require_the_tablib_gem() click to toggle source
#

try_to_require_the_tablib_gem

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1040
def try_to_require_the_tablib_gem
  begin
    # ===================================================================== #
    # Require the taglib-ruby gem.
    #
    # See: https://rubygems.org/gems/taglib-ruby
    # ===================================================================== #
    require 'taglib'
  rescue LoadError; end
end
update!( this_file = @this_file ) click to toggle source
#

update!

This method can be used to update the tags.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1056
def update!( 
    this_file = @this_file
  )
  TagLib::FileRef.open(this_file) { |fileref| # of class TagLib::FileRef.
    unless fileref.null?
      @tag       = fileref.tag # Keep a reference to it here.
      set_new_album(@album) # Use the old reference.
      set_new_year(@year)  # Use the old reference, via @year.
      @tag.title   = @title.to_s
      @tag.artist  = @artist.to_s
      @tag.genre   = @genre.to_s
      @tag.comment = @comment.to_s
      if @track
        @tag.track = @track.to_i # This must be an integer.
      end
      fileref.save
    end
  }
end
update_the_MPEG_entry( i = which_file? ) click to toggle source
#

update_the_MPEG_entry

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1504
def update_the_MPEG_entry(
    i = which_file?
  )
  _ = MultimediaParadise.return_the_mpeg_layer_from_this_mp3_file(i)
  @information_about_a_mp3_file.label_mpeg_level_content.set_text(_.to_s)
end
widget_in_the_middle() click to toggle source
#

widget_in_the_middle

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 370
def widget_in_the_middle
  @information_about_a_mp3_file
end
widget_left() click to toggle source
#

widget_left

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 546
def widget_left
  _ = @widget_on_the_right_side_including_the_title_of_the_song = gtk_vbox
  _.set_border_width(2)
  # ======================================================================= #
  # === Title of the song
  # ======================================================================= #
  label_title = modify_bold_label(
    'Title of the song:',
    'black', :right
  ).center # align_left_and_center_in_the_middle
  # label_with_the_audio_symbol = gtk_label(:three_stars) # This used to be :audio3
  another_tiny_hbox = gtk_hbox
  use_this_icon_name = 'audio-speakers'
  begin
    icon = icon_theme?.load_icon(use_this_icon_name, 32, 0)
  rescue ::Gtk::IconThemeError::NotFound => error
    e tomato('An error occurred:')
    e
    pp error
    e
    icon = icon_theme?.load_icon('audio-x-generic', 32, 0)
  end

  label_with_the_audio_symbol = gtk_image_pixbuf(icon)

  another_tiny_hbox.minimal(label_with_the_audio_symbol)
  another_tiny_hbox.maximal(label_title)
  mini_vbox = gtk_vbox
  # mini_vbox.pack_start(label_title)
  mini_vbox.maximal(another_tiny_hbox)
  arrow_to_the_right = gtk_label('→ ')
  tiny_hbox = gtk_hbox
  tiny_hbox.minimal(arrow_to_the_right)
  # ======================================================================= #
  # Add the entry for the title of the song next.
  # ======================================================================= #
  tiny_hbox.maximal(@entry_for_the_title_of_the_song)
  mini_vbox.maximal(tiny_hbox)
  _.minimal(mini_vbox, 0)
  # ======================================================================= #
  # Create the grid next that is situated on the right side.
  # ======================================================================= #
  @grid_on_the_right_side = gtk_grid
  @grid_on_the_right_side.set_column_spacing(1)
  @grid_on_the_right_side.set_row_spacing(1)
  _.minimal(@grid_on_the_right_side, 2)
  # ======================================================================= #
  # === Artist
  # ======================================================================= #
  label_the_artist = gtk_label('Artist: ').align_left_and_center_in_the_middle
  label_the_artist.make_bold
  # ======================================================================= #
  # === @entry_for_the_artist
  # ======================================================================= #
  @entry_for_the_artist = gtk_entry
  @entry_for_the_artist.set_max_length(40)
  @entry_for_the_artist.set_size_request(300, 40)

  @grid_on_the_right_side.attach(label_the_artist,      0, 0, 1, 1) # left, top, width, height
  @grid_on_the_right_side.attach(@entry_for_the_artist, 1, 0, 1, 1)

  # ======================================================================= #
  # === Year
  # ======================================================================= #
  label_for_the_year = gtk_label('Year: ').align_left_and_center_in_the_middle
  label_for_the_year.make_bold
  label_for_the_year.hint = 'The <b>Year</b> entry should ideally '\
    'indicate when a song was released officially. Some songs were '\
    'recorded in a year before, but the more relevant entry will '\
    'be the year in which that song was released.'
  # ======================================================================= #
  # === @entry_for_the_year
  # ======================================================================= #
  @entry_for_the_year = gtk_entry
  @entry_for_the_year.set_max_length(50)
  @entry_for_the_year.allow_only_numbers
  @entry_for_the_year.focus_on_click_event

  @grid_on_the_right_side.attach(label_for_the_year,  0, 1, 1, 1) # left, top, width, height
  hbox = gtk_hbox
  hbox.maximal(@entry_for_the_year, 1)
  combo_box_entry = gtk_combo_box_entry
  combo_box_entry.populate(
    (1960 .. 2050).to_a.map(&:to_s)
  )
  combo_box_entry.this_entry_is_active(30)
  combo_box_entry.on_changed {
    @entry_for_the_year.set_text(combo_box_entry.text?)
  }
  hbox.minimal(combo_box_entry)
  @grid_on_the_right_side.attach(hbox, 1, 1, 1, 1)

  # ======================================================================= #
  # === Album
  # ======================================================================= #
  label_for_the_album = gtk_label('Album: ').align_left_and_center_in_the_middle
  label_for_the_album.make_bold
  # ======================================================================= #
  # === @entry_for_the_album
  # ======================================================================= #
  @entry_for_the_album = gtk_entry
  @entry_for_the_album.set_max_length(75)

  @grid_on_the_right_side.attach(label_for_the_album,  0, 2, 1, 1) # left, top, width, height
  @grid_on_the_right_side.attach(@entry_for_the_album, 1, 2, 1, 1)

  # ======================================================================= #
  # === Comment                                               (comment tag)
  #
  # Personally I use this field as a placeholder for a remote URL,
  # to some of the .mp3 songs. This may be useful in other graphical
  # applications.
  # ======================================================================= #
  label_for_the_comment = gtk_label('Comment: ').align_left_and_center_in_the_middle
  label_for_the_comment.make_bold
  event_box_with_left_arrow = gtk_eventbox(emoji(:left_arrow))
  event_box_with_left_arrow.hint = 'Click on this arrow '\
    'to open the URL (if there is one), via the browser.'
  event_box_with_left_arrow.on_clicked {
    require 'open' unless Object.const_defined? :Open
    Open.in_browser('"'+comment_entry?.text.to_s.strip+'"') unless comment_entry?.text.to_s.empty?
  }
  mini_hbox = gtk_hbox
  mini_hbox.maximal(@entry_for_the_comment)
  mini_hbox.minimal(event_box_with_left_arrow)
  @grid_on_the_right_side.attach(label_for_the_comment,  0, 3, 1, 1) # left, top, width, height
  @grid_on_the_right_side.attach(mini_hbox,              1, 3, 1, 1)

  # ======================================================================= #
  # === Track number
  # ======================================================================= #
  label_for_the_track_number = gtk_label('Track number: ').align_left_and_center_in_the_middle
  label_for_the_track_number.make_bold
  # ======================================================================= #
  # === @entry_for_the_track_number
  # ======================================================================= #
  @entry_for_the_track_number = gtk_entry
  @entry_for_the_track_number.set_max_length(3)
  @entry_for_the_track_number.set_size_request(50, -1)
  @entry_for_the_track_number.allow_only_numbers
  unless @dataset.nil?
    save_this = @dataset
    save_this = @dataset.track if @dataset.respond_to? :track
    @entry_for_the_track_number.set_text(save_this)
    do_activate_the_save_button
  end

  @grid_on_the_right_side.attach(label_for_the_track_number,  0, 4, 1, 1) # left, top, width, height
  @grid_on_the_right_side.attach(@entry_for_the_track_number, 1, 4, 1, 1)

  # ======================================================================= #
  # === Genre
  # ======================================================================= #
  label_for_the_genre = gtk_label('Genre: ').align_left_and_center_in_the_middle
  label_for_the_genre.make_bold
  label_for_the_genre.set_size_request(125, 40)
  @entry_for_the_genre = gtk_entry
  @entry_for_the_genre.set_size_request(125, 40)
  @entry_for_the_genre.make_bold

  @grid_on_the_right_side.attach(label_for_the_genre,  0, 5, 1, 1) # left, top, width, height
  @grid_on_the_right_side.attach(@entry_for_the_genre, 1, 5, 1, 1)
  # ======================================================================= #
  # === Genre (select)
  #
  # This will load the file called "music_genres.yml", which in turn
  # contains the most commonly used genre entries. Note that this file
  # will NOT contain all genres, as that would lead to a very long
  # dropdown listing.
  # ======================================================================= #
  label_for_the_genre_select = gtk_label('Genre (select): ').align_left_and_center_in_the_middle
  label_for_the_genre_select.make_bold
  create_the_combo_box_entry_for_genre_select
  # ======================================================================= #
  # Next build up the hbox that contains the label and the combo box:
  # ======================================================================= #
  hbox_for_the_genre_select_components = gtk_hbox(
    label_for_the_genre_select,
    @combo_box_entry_for_genre_select
  )
  hbox_for_the_genre_select_components.pack_end(
    @button_assume, padding: 2
  )
  _.minimal(
    hbox_for_the_genre_select_components, 0
  )
  _.minimal(return_the_save_button, 2)
  return _
end
widget_right() click to toggle source
#

widget_right

This is the large vbox that appears on the very left side, containing tons of buttons.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 476
def widget_right
  vbox_containing_the_buttons = gtk_vbox
  vbox_containing_the_buttons.border_width = 6
  vbox_containing_the_buttons.minimal(@button_debug,                            1)
  vbox_containing_the_buttons.minimal(@box_for_the_button_analyse_the_mp3_file, 1)
  vbox_containing_the_buttons.minimal(@event_box_open_file,                     1)
  vbox_containing_the_buttons.minimal(@button_perform_a_google_search,          1)
  vbox_containing_the_buttons.minimal(@button_open_a_random_audio_file,         1)
  vbox_containing_the_buttons.minimal(@button_delete_the_tags,                  1)
  vbox_containing_the_buttons.minimal(@button_update,                           1)
  vbox_containing_the_buttons.minimal(@button_play,                             1)
  vbox_containing_the_buttons.minimal(@button_save,                             1)
  vbox_containing_the_buttons.minimal(@button_close,                            1)
  vbox_containing_the_buttons.use_this_font = slightly_smaller_font?
  return vbox_containing_the_buttons
end
widget_second_row() click to toggle source
#

widget_second_row

This widget contains the “File path: ” string.

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 426
def widget_second_row
  _ = gtk_hbox
  _.pad2px
  # ======================================================================= #
  # === The label containing "Input the path to a local .mp3 file: "
  # ======================================================================= #
  label = label('File path: ')
  label.align_to_the_left
  label.hint = 'To the right of this text you can designate the '\
               'path to the local .mp3 file.'
  _.minimal(label, 6)
  eventbox_arrow_right = gtk_eventbox(emoji(:arrow_right))
  eventbox_arrow_right.on_clicked {
    do_open_a_local_file_and_then_set_the_proper_entry
  }
  _.minimal(eventbox_arrow_right, 2)
  _.maximal(entry_file_path?,     4)
  button_open_local_file = gtk_button('Open local file')
  button_open_local_file.use_this_font = slightly_smaller_font?
  button_open_local_file.hint = 'Click on this button to open a local file.'
  button_open_local_file.on_clicked {
    do_look_for_a_local_file_and_then_analyse_the_audio_file_at_once
  }
  _.minimal(button_open_local_file,  4)
  _.minimal(gtk_vspacer)
  _.minimal(gtk_vspacer, 1)
  return _
end
widget_top() click to toggle source
#

widget_top

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 1397
def widget_top
  # ======================================================================= #
  # === @header_bar
  #
  # This is the widget that will be found on the very top of this
  # application.
  # ======================================================================= #
  _ = default_header_bar
  _.show_close_button = true
  _.has_close_button
  _.set_name('header_bar_on_top')
  _.set_custom_title(@label_description)
  _.spacing = 2
  _.use_this_font = normal_font?

  button_open_a_random_audio_file = return_button_open_a_random_audio_file(:no_text)
  button_open_a_random_audio_file.hint = 
    'Click this button to <b>open and assign a random .mp3 file</b>.'
  _.pack_start(button_open_a_random_audio_file)

  # ======================================================================= #
  # === Open a local file, as part of the menu-interface
  # ======================================================================= #
  open_a_local_file = gtk_button('Open a local file')
  open_a_local_file.on_activate {
    do_open_a_local_file_and_then_set_the_proper_entry
  }
  _.pack_start(open_a_local_file)

  # ======================================================================= #
  # === Show about-information, as part of the top header-bar
  #
  # It will be appended, aka .pack_end() is used.
  # ======================================================================= #
  button_about = button('About')
  button_about.hint = 'This will display information about this '\
                      'application.'
  button_about.on_clicked {
    do_show_information_about_this_application
  }
  _.pack_end(button_about)

  # ======================================================================= #
  # === button_show_the_settings
  # ======================================================================= #
  button_show_the_settings = gtk_button('Settings')
  button_show_the_settings.hint = 'This button allows you to change a few '\
                                  'settings of this application.'
  button_show_the_settings.on_clicked {
    do_popup_the_settings_widget
  }
  _.pack_start(button_show_the_settings)
  return _
end
Also aliased as: return_the_header_bar
work_on_this_file( this_file = @this_file ) click to toggle source
#

work_on_this_file

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 966
  def work_on_this_file(
      this_file = @this_file
    )
    unless Object.const_defined? :TagLib
      text = <<-EOF
Please install TagLib first via:

  gem install taglib

EOF
      e text
      return text
    end
    # ======================================================================= #
    # Load up the file via TagLib first.
    # ======================================================================= #
    TagLib::FileRef.open(this_file) { |fileref| # of class TagLib::FileRef.
      unless fileref.null?
        @tag       = fileref.tag  # Keep a reference to it here.
        @title     = @tag.title   # => "Wake Up"
        @artist    = @tag.artist  # => "DJ Punk"
        @album     = @tag.album   # => "Funeral"
        @year      = @tag.year    # => 2004
        @genre     = @tag.genre   # => "Indie Rock"
        @comment   = @tag.comment
        @track     = @tag.track
        # @band    = @tag.band # Does not exist.
        @performer = @tag.performer if @tag.respond_to? :performer
        @properties = fileref.audio_properties
        do_determine_the_length_of_the_song(this_file)
        if @may_we_report
          e
          report_everything
          e
        end
      end
    } # File is automatically closed at block end.
  end
year()
Alias for: year?
year=(i)
Alias for: set_year
year?() click to toggle source
#

year?

#
# File lib/multimedia_paradise/gui/gtk3/tag_mp3_files/misc.rb, line 843
def year?
  @year
end
Also aliased as: year