Class: MultimediaParadise::GUI::UniversalWidgets::TagMp3Files
- Inherits:
-
Base
- Object
- Base
- MultimediaParadise::GUI::UniversalWidgets::TagMp3Files
show all
- Includes:
- InformationAboutAMp3FileModule, UniversalWidgets::BaseModule
- Defined in:
- lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb
Overview
Constant Summary
collapse
- TITLE =
'Tag .mp3 files'
- WIDTH =
'99% or minimum 1800px'
- HEIGHT =
'85% or minimum 500px'
- USE_THIS_FONT =
:hack_23
- LARGER_FONT =
:hack_25
- SMALLER_FONT =
:hack_20
- USE_THESE_CSS_RULES =
'
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;
}
'
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
-
#add_this_text_to_the_status_bar(this_text) ⇒ Object
# === add_this_text_to_the_status_bar ========================================================================= #.
-
#album? ⇒ Boolean
(also: #album)
# === album? ========================================================================= #.
-
#artist? ⇒ Boolean
# === artist? ========================================================================= #.
-
#artist_of_the_song? ⇒ Boolean
(also: #artist)
# === artist_of_the_song? ========================================================================= #.
-
#band? ⇒ Boolean
(also: #band)
# === band? ========================================================================= #.
-
#border_size? ⇒ Boolean
# === border_size? ========================================================================= #.
-
#bpm? ⇒ Boolean
(also: #bpm)
# === bpm? ========================================================================= #.
-
#clear_old_entries ⇒ Object
# === clear_old_entries ========================================================================= #.
-
#comment? ⇒ Boolean
(also: #comment)
-
#comment_entry? ⇒ Boolean
-
#connect_the_skeleton ⇒ Object
# === connect_the_skeleton (connect tag) ========================================================================= #.
-
#context_menu? ⇒ Boolean
-
#create_the_buttons ⇒ Object
-
#create_the_combo_box_entry_for_genre_select ⇒ Object
# === create_the_combo_box_entry_for_genre_select ========================================================================= #.
-
#create_the_context_menu ⇒ Object
-
#create_the_entries ⇒ Object
# === create_the_entries (entries tag, entry tag).
-
#create_the_header_bar ⇒ Object
-
#create_the_labels ⇒ Object
# === create_the_labels (labels tag, label tag) ========================================================================= #.
-
#create_the_settings ⇒ Object
# === create_the_settings ========================================================================= #.
-
#create_the_skeleton ⇒ Object
# === create_the_skeleton (create tag, skeleton tag).
-
#create_the_status_bar ⇒ Object
# === create_the_status_bar ========================================================================= #.
-
#create_the_status_icon(tooltip_text = 'This text will show up upon a hover-event.') ⇒ Object
# === create_the_status_icon ========================================================================= #.
-
#date? ⇒ Boolean
(also: #date)
# === date? ========================================================================= #.
-
#disc? ⇒ Boolean
(also: #disc)
# === disc? ========================================================================= #.
-
#display_information_about_the_song ⇒ Object
(also: #do_debug)
-
#do_all_startup_related_actions ⇒ Object
-
#do_analyse_the_audio_file_then_set_all_relevant_entries ⇒ Object
# === do_analyse_the_audio_file_then_set_all_relevant_entries ========================================================================= #.
-
#do_analyse_the_mp3_file(_ = entry_file_path_text? ) ⇒ Object
(also: #load_the_id3_dataset_from_this_file, #do_analyse_the_audio_file_at_once, #do_open_a_local_file_and_then_set_the_proper_entry, #do_analyse_the_audio_file, #determine_the_metadata_for_this_song, #analyse_this_song, #do_analyse_the_default_file, #ensure_that_we_have_a_dataset)
# === do_analyse_the_mp3_file (analyse tag, load tag).
-
#do_assign_a_new_random_audio_file ⇒ Object
# === do_assign_a_new_random_audio_file ========================================================================= #.
-
#do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly ⇒ Object
# === do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly ========================================================================= #.
-
#do_determine_the_length_of_the_song(this_file = main_file? ) ⇒ Object
# === do_determine_the_length_of_the_song.
-
#do_empty_the_tags ⇒ Object
(also: #empty_tags)
-
#do_focus_on_the_entry_containing_the_title_of_the_song ⇒ Object
# === do_focus_on_the_entry_containing_the_title_of_the_song ========================================================================= #.
-
#do_look_for_a_local_file_and_then_analyse_the_audio_file_at_once ⇒ Object
(also: #do_open_the_file_opener_dialog, #do_open_file, #open_local_file)
# === do_look_for_a_local_file_and_then_analyse_the_audio_file_at_once (open tag) ========================================================================= #.
-
#do_open_a_random_audio_file_and_then_set_the_proper_entry(_ = return_random_audio_file) ⇒ Object
# === do_open_a_random_audio_file_and_then_set_the_proper_entry.
-
#do_perform_a_google_search(song_name = song_name?, , artist_name = artist? ) ⇒ Object
-
#do_play_the_selected_song(_ = entry_file_path_text? ) ⇒ Object
(also: #play_the_selected_audio_file)
# === do_play_the_selected_song.
-
#do_popup_the_settings_widget ⇒ Object
-
#do_save_the_tags ⇒ Object
(also: #do_save_tags)
-
#do_show_information_about_this_application ⇒ Object
-
#entry_for_the_title_of_the_song? ⇒ Boolean
(also: #entry_for_the_song_name?)
# === entry_for_the_title_of_the_song? ========================================================================= #.
-
#entry_use_which_audio_file? ⇒ Boolean
(also: #entry_on_top?, #entry_file_path?)
# === entry_use_which_audio_file? ========================================================================= #.
-
#filename? ⇒ Boolean
# === filename? ========================================================================= #.
-
#genre? ⇒ Boolean
(also: #genre)
# === genre? ========================================================================= #.
-
#handle_CSS_rules ⇒ Object
# === handle_CSS_rules (CSS tag).
-
#header_bar? ⇒ Boolean
(also: #header?)
-
#header_bar_height? ⇒ Boolean
-
#initialize(commandline_arguments = nil, run_already = true) ⇒ TagMp3Files
constructor
# === initialize ========================================================================= #.
-
#instantiate_the_metadata_from_this_file(this_file) ⇒ Object
-
#label_duration_content? ⇒ Boolean
# === label_duration_content? ========================================================================= #.
-
#length_in_seconds? ⇒ Boolean
# === length_in_seconds? ========================================================================= #.
-
#main_file_text? ⇒ Boolean
(also: #main_file?, #which_file?, #entry_file_path_text?)
# === main_file_text? ========================================================================= #.
-
#menu(i = commandline_arguments? ) ⇒ Object
(also: #parse_the_commandline_arguments)
-
#metadata_for_the_song? ⇒ Boolean
(also: #metadata?, #dataset?)
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#parent_widget=(i = ARGV) ⇒ Object
-
#performer? ⇒ Boolean
(also: #performer)
-
#report_album(i = @album) ⇒ Object
# === report_album ========================================================================= #.
-
#report_artist(i = @artist) ⇒ Object
# === report_artist ========================================================================= #.
-
#report_comment(i = @comment) ⇒ Object
-
#report_everything ⇒ Object
(also: #report)
# === report_everything.
-
#report_genre(i = @genre) ⇒ Object
# === report_genre.
-
#report_length_in_seconds(i = @length_in_seconds) ⇒ Object
# === report_length_in_seconds ========================================================================= #.
-
#report_title(i = @title) ⇒ Object
# === report_title ========================================================================= #.
-
#report_year(i = @year) ⇒ Object
# === report_year ========================================================================= #.
-
#require_the_appropriate_id_tagger(i = ID_TAGGER_TO_USE_FOR_THE_MP3_FILES) ⇒ Object
# === require_the_appropriate_id_tagger.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#reset_all_main_entries ⇒ Object
# === reset_all_main_entries ========================================================================= #.
-
#reset_the_shared_module ⇒ Object
# === reset_the_shared_module.
-
#return_all_entries_on_the_right_side_widget ⇒ Object
-
#return_button_open_a_random_audio_file(options = nil) ⇒ Object
-
#return_button_play ⇒ Object
-
#return_entry_from_the_combo_box_entry_for_genre_select_or_from_the_entry_for_the_genre ⇒ Object
# === return_entry_from_the_combo_box_entry_for_genre_select_or_from_the_entry_for_the_genre ========================================================================= #.
-
#return_event_box_for_opening_a_file(width = 110, height = 65) ⇒ Object
# === return_event_box_for_opening_a_file.
-
#return_random_audio_file(from_this_directory = @entry_use_this_as_the_directory_to_the_local_songs.text?) ⇒ Object
# === return_random_audio_file.
-
#return_the_save_button(make_use_of_special_CSS_rules = true) ⇒ Object
-
#return_widget_information_about_a_mp3_file ⇒ Object
(also: #return_the_grid_containing_the_bitrate_and_associated_values, #create_table1)
-
#right_colour(i) ⇒ Object
# === right_colour ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#save ⇒ Object
# === save ========================================================================= #.
-
#set_a_uniform_background_for_the_entries_on_the_right_side_widget(array = return_all_entries_on_the_right_side_widget) ⇒ Object
-
#set_album(i) ⇒ Object
(also: #album=)
# === set_album ========================================================================= #.
-
#set_all_relevant_entries_based_on_the_metadata(this_file = main_file? ) ⇒ Object
(also: #sync_everything)
-
#set_artist(i) ⇒ Object
(also: #artist=)
# === set_artist ========================================================================= #.
-
#set_comment(i) ⇒ Object
(also: #comment=)
-
#set_genre(i) ⇒ Object
(also: #genre=)
# === set_genre ========================================================================= #.
-
#set_main_entry(i) ⇒ Object
# === set_main_entry ========================================================================= #.
-
#set_new_album(i) ⇒ Object
# === set_new_album ========================================================================= #.
-
#set_new_year(i) ⇒ Object
# === set_new_year ========================================================================= #.
-
#set_the_bitrate(i) ⇒ Object
# === set_the_bitrate.
-
#set_the_file_size_from_this_file(this_file = @entry_file_path.text?) ⇒ Object
# === set_the_file_size_from_this_file ========================================================================= #.
-
#set_the_samplerate(i) ⇒ Object
# === set_the_samplerate ========================================================================= #.
-
#set_this_file(i) ⇒ Object
# === set_this_file ========================================================================= #.
-
#set_title(i) ⇒ Object
(also: #title=)
# === set_title ========================================================================= #.
-
#set_track(i) ⇒ Object
(also: #track=)
# === set_track ========================================================================= #.
-
#set_year(i) ⇒ Object
(also: #year=)
# === set_year ========================================================================= #.
-
#show_debug_information ⇒ Object
-
#smaller_font? ⇒ Boolean
# === smaller_font? ========================================================================= #.
-
#song_directory? ⇒ Boolean
# === song_directory? ========================================================================= #.
-
#song_name? ⇒ Boolean
# === song_name? ========================================================================= #.
-
#sync_artist_onto_entry ⇒ Object
# === sync_artist_onto_entry ========================================================================= #.
-
#sync_comment_onto_entry ⇒ Object
-
#sync_genre_onto_entry(this_text = :infer_from_the_dataset) ⇒ Object
# === sync_genre_onto_entry ========================================================================= #.
-
#sync_the_duration_of_the_file_onto_the_correct_entry(_ = @metadata_for_the_song) ⇒ Object
# === sync_the_duration_of_the_file_onto_the_correct_entry ========================================================================= #.
-
#sync_this_text_onto_the_genre_entry(i) ⇒ Object
# === sync_this_text_onto_the_genre_entry.
-
#sync_title_onto_entry ⇒ Object
# === sync_title_onto_entry ========================================================================= #.
-
#sync_year_onto_entry ⇒ Object
# === sync_year_onto_entry ========================================================================= #.
-
#tag? ⇒ Boolean
(also: #tag)
# === tag? ========================================================================= #.
-
#the_save_button_is_available_again ⇒ Object
(also: #do_activate_the_save_button)
-
#this_file? ⇒ Boolean
# === this_file? ========================================================================= #.
-
#title? ⇒ Boolean
(also: #title)
# === title? ========================================================================= #.
-
#track? ⇒ Boolean
(also: #track)
# === track? ========================================================================= #.
-
#try_to_require_the_tablib_gem ⇒ Object
# === try_to_require_the_tablib_gem ========================================================================= #.
-
#update!(this_file = @this_file) ⇒ Object
# === update!.
-
#update_the_MPEG_entry(i = which_file? ) ⇒ Object
# === update_the_MPEG_entry ========================================================================= #.
-
#widget_in_the_middle ⇒ Object
-
#widget_left ⇒ Object
(also: #create_and_return_the_pane_holding_various_file_related_entries)
-
#widget_right ⇒ Object
(also: #return_vbox_containing_the_buttons)
-
#widget_second_row ⇒ Object
-
#widget_top ⇒ Object
(also: #return_the_header_bar)
-
#work_on_this_file(this_file = @this_file) ⇒ Object
# === work_on_this_file ========================================================================= #.
-
#year? ⇒ Boolean
(also: #year)
# === year? ========================================================================= #.
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?, #log_dir?, #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
#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) ⇒ TagMp3Files
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 126
def initialize(
commandline_arguments = nil,
run_already = true
)
determine_the_GUI_to_be_used(commandline_arguments) reset
set_commandline_arguments(
commandline_arguments
)
on_delete_event_quit_the_application
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
2418
2419
2420
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2418
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2395
def self.run(
i = ARGV
)
require 'gtk_paradise/run'
_ = ::MultimediaParadise::GUI::Gtk::TagMp3Files.new(i)
r = ::Gtk.run
_.set_parent_widget(r) r << _
r.automatic_size_then_automatic_title
r.enable_quick_exit
r.set_background :white
r.on_button_press_event { |widget, event|
if ::Gtk.right_mouse_click?(event) _..(event)
end
}
_.parent_widget = r
r.top_left_then_run
end
|
Instance Method Details
#add_this_text_to_the_status_bar(this_text) ⇒ Object
#
add_this_text_to_the_status_bar
#
2021
2022
2023
2024
2025
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2021
def add_this_text_to_the_status_bar(this_text)
@status_bar.push(
@status_bar_context_id, this_text
)
end
|
#album? ⇒ Boolean
Also known as:
album
1460
1461
1462
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1460
def album?
@album
end
|
#artist? ⇒ Boolean
934
935
936
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 934
def artist?
@entry_for_the_artist.text?
end
|
#artist_of_the_song? ⇒ Boolean
Also known as:
artist
941
942
943
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 941
def artist_of_the_song?
@artist
end
|
#band? ⇒ Boolean
Also known as:
band
1474
1475
1476
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1474
def band?
@band
end
|
#border_size? ⇒ Boolean
209
210
211
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 209
def border_size?
2
end
|
#bpm? ⇒ Boolean
Also known as:
bpm
1453
1454
1455
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1453
def bpm?
@bpm
end
|
#clear_old_entries ⇒ Object
581
582
583
584
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 581
def clear_old_entries
@entry_for_the_album.set_text('')
@information_about_a_mp3_file.label_mpeg_level_content.set_text('')
end
|
1495
1496
1497
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1495
def
@comment
end
|
1170
1171
1172
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1170
def
@entry_for_the_comment
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag)
#
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2265
def connect_the_skeleton
abort_on_exception
outer_vbox = create_vbox
first_dragger = drag_via_up_and_down_movement(
, widget_second_row )
first_dragger.position = outer_vbox.minimal(first_dragger)
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
third_dragger = drag_via_up_and_down_movement(
second_dragger,
@status_bar )
third_dragger.position = 1300
outer_vbox.minimal(third_dragger)
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
handle_CSS_rules if use_gtk3?
run_main
end
|
660
661
662
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 660
def
@context_menu
end
|
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
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
451
452
453
454
455
456
457
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 317
def create_the_buttons
@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 = create_hbox
@box_for_the_button_analyse_the_mp3_file.maximal(@button_analyse_the_mp3_file, 2)
@spinner = create_spinner
@box_for_the_button_analyse_the_mp3_file.minimal(@spinner, 4)
@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 = return_button_play
@event_box_open_file = return_event_box_for_opening_a_file
@button_debug = create_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 = create_button('_Update') 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.on_hover(: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 }
@button_delete_the_tags = create_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 = return_the_save_button(:do_not_make_use_of_a_special_CSS_class)
@button_close = create_button_with_label(' _Close') use_this_icon_name = 'application-exit'
icon = load_icon(use_this_icon_name, 32, 0) @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 = return_button_open_a_random_audio_file
@button_perform_a_google_search = create_button_with_label(' _Google search')
use_this_icon_name = 'help-browser'
icon = load_icon(use_this_icon_name, 32, 0) @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 ⇒ Object
#
create_the_combo_box_entry_for_genre_select
#
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 808
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 = [] end
@combo_box_entry_for_genre_select = create_combo_box_entry(
with_these_elements: array_available_genres
)
@combo_box_entry_for_genre_select.clear_background
@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
@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
|
667
668
669
670
671
672
673
674
675
676
677
678
679
680
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 667
def
@context_menu = (self) {{
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 ⇒ Object
#
create_the_entries (entries tag, entry tag)
This method will bundle - and create - all relevant gtk-entries in this application.
#
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 744
def create_the_entries
@entry_use_this_as_the_directory_to_the_local_songs = create_entry
@entry_use_this_as_the_directory_to_the_local_songs.set_text(
PATH_TO_THE_LOCAL_AUDIO_DIRECTORY
)
@entry_for_the_comment = create_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 = create_entry
@entry_for_the_title_of_the_song.set_max_length(150)
@entry_file_path = create_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
}
@entry_file_path.on_mouse_double_click_event {|widget, event|
do_open_a_local_file_and_then_set_the_proper_entry
}
end
|
462
463
464
465
466
467
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 462
def
@header_bar = widget_top
end
|
#create_the_labels ⇒ Object
#
create_the_labels (labels tag, label tag)
#
697
698
699
700
701
702
703
704
705
706
707
708
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 697
def create_the_labels
@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 ⇒ Object
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 713
def create_the_settings
@settings_vbox = create_vbox
@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 = create_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_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
The order for the various create-method calls is important.
#
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2374
def create_the_skeleton
create_the_labels create_the_entries create_the_buttons create_the_status_bar create_the_status_icon create_the_settings end
|
#create_the_status_bar ⇒ Object
#
create_the_status_bar
#
685
686
687
688
689
690
691
692
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 685
def create_the_status_bar
@status_bar = create_status_bar
@status_bar.bblack1
@status_bar_context_id = @status_bar.get_context_id('tag_mp3_files')
end
|
#create_the_status_icon(tooltip_text = 'This text will show up upon a hover-event.') ⇒ Object
#
create_the_status_icon
#
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 280
def create_the_status_icon(
tooltip_text = 'This text will show up upon a hover-event.'
)
@status_icon = create_status_icon
@status_icon.stock = ::Gtk::Stock::DIALOG_INFO
@status_icon.set_icon_name('default_status_icon_name') @status_icon.set_tooltip_text(tooltip_text)
@status_icon.signal_connect(:activate) { |icon|
if icon.respond_to? :blinking
icon.blinking = !(icon.blinking?)
end
}
=
play_button = ::Gtk::ImageMenuItem.new(stock: ::Gtk::Stock::MEDIA_PLAY)
play_button.signal_connect(:activate) {
do_play_the_selected_song
}
.append(play_button)
quit_button = ::Gtk::ImageMenuItem.new(stock: ::Gtk::Stock::QUIT)
quit_button.signal_connect(:activate) { ::Gtk.main_quit }
.append(quit_button)
.show_all
@status_icon.signal_connect(:popup_menu) { |icon, button, time|
.(nil, nil, button, time)
}
end
|
#date? ⇒ Boolean
Also known as:
date
1439
1440
1441
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1439
def date?
@date
end
|
#disc? ⇒ Boolean
Also known as:
disc
1446
1447
1448
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1446
def disc?
@disc
end
|
#
This method exists mostly to simplify debugging the application at hand.
#
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 546
def display_information_about_the_song
e horizontal_unicode_bar*80
dataset = metadata?
if dataset
ee 'Title: '.ljust(30); pp dataset.title ee 'Album: '.ljust(30); pp dataset.album ee 'Performer: (not in use) '.ljust(30);pp dataset.performer 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 ee 'Year: '.ljust(30); pp dataset.year ee 'Comment: '.ljust(30); pp dataset. e horizontal_unicode_bar*80
e
else
e 'No dataset has been assigned yet.'
end
end
|
216
217
218
219
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 216
def do_all_startup_related_actions
do_focus_on_the_entry_containing_the_title_of_the_song
end
|
#do_analyse_the_audio_file_then_set_all_relevant_entries ⇒ Object
#
do_analyse_the_audio_file_then_set_all_relevant_entries
#
2219
2220
2221
2222
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2219
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_mp3_file(_ = entry_file_path_text?
) ⇒ Object
Also known as:
load_the_id3_dataset_from_this_file, do_analyse_the_audio_file_at_once, do_open_a_local_file_and_then_set_the_proper_entry, do_analyse_the_audio_file, determine_the_metadata_for_this_song, analyse_this_song, do_analyse_the_default_file, ensure_that_we_have_a_dataset
#
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.
#
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1829
def do_analyse_the_mp3_file(
_ = entry_file_path_text?
)
if _ and !_.empty? and File.exist?(_)
case ID_TAGGER_TO_USE_FOR_THE_MP3_FILES
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 = create_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
= return_popover(
text_to_display,
entry_on_top?,
25, custom_widget
)
.
end
when :id3lib
if Object.const_defined? :ID3Lib
this_song = ID3Lib::Tag.new(this_song)
else
e 'ID3Lib is not available/installed. Please install '\
'it for your platform / operating-system.'
end
end
@spinner.start_spinning
Thread.new {
add_this_text_to_the_status_bar('')
clear_old_entries
e steelblue('-' * 60)
instantiate_the_metadata_from_this_file(_) @metadata_for_the_song.report @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)
do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly
sync_everything
@spinner.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 ⇒ Object
#
do_assign_a_new_random_audio_file
#
2109
2110
2111
2112
2113
2114
2115
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2109
def do_assign_a_new_random_audio_file
_ = return_random_audio_file.to_s
unless _.empty? 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 ⇒ Object
#
do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly
#
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 596
def do_assume_the_name_of_the_song_and_the_artist_from_the_filename_directly
_ = filename?
if _ and File.exist?(_)
raw_name = File.basename(_)
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_determine_the_length_of_the_song(this_file = main_file?
) ⇒ Object
#
do_determine_the_length_of_the_song
The first argument should be the name of the .mp3 file at hand.
#
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1648
def do_determine_the_length_of_the_song(
this_file = main_file?
)
@length_in_seconds = ::MultimediaParadise.length_of?(this_file)
end
|
#
This method will empty our tags.
#
917
918
919
920
921
922
923
924
925
926
927
928
929
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 917
def do_empty_the_tags
dataset = dataset?
if dataset
dataset.album = ''
dataset.artist = ''
dataset. = ''
dataset.genre = ''
dataset.title = ''
dataset.track = ''
dataset.year = ''
@button_save.sensitive = true
end
end
|
#do_focus_on_the_entry_containing_the_title_of_the_song ⇒ Object
#
do_focus_on_the_entry_containing_the_title_of_the_song
#
856
857
858
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 856
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 ⇒ Object
Also known as:
do_open_the_file_opener_dialog, do_open_file, open_local_file
#
do_look_for_a_local_file_and_then_analyse_the_audio_file_at_once (open tag)
#
1966
1967
1968
1969
1970
1971
1972
1973
1974
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1966
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] }}
@entry_file_path.set_text(::Gtk.main_file?.to_s)
do_analyse_the_audio_file_at_once
end
|
#do_open_a_random_audio_file_and_then_set_the_proper_entry(_ = return_random_audio_file) ⇒ Object
#
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.
#
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1785
def do_open_a_random_audio_file_and_then_set_the_proper_entry(
_ = return_random_audio_file
)
clear_old_entries entry_file_path?.set_text(_.to_s)
if File.exist? _
do_analyse_the_audio_file(entry_file_path_text?)
set_all_relevant_entries_based_on_the_metadata
add_this_text_to_the_status_bar('')
end
end
|
#
This method will “perform” a browser search. We will simply open the browser; on linux this works fine. :-)
#
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1013
def do_perform_a_google_search(
song_name = song_name?,
artist_name = artist?
)
unless Object.const_defined? :Open
begin
require 'open'
rescue LoadError; end
end
_ = ''.dup
_ << 'https://www.google.com/search?q='
_ << 'wikipedia+' _ << song_name.to_s.tr(' ','+')+'+'
_ << artist_name.to_s.tr(' ','+')
_ << '&ie=utf-8&oe=utf-8'
Open.in_browser(_)
end
|
#do_play_the_selected_song(_ = entry_file_path_text?
) ⇒ Object
Also known as:
play_the_selected_audio_file
#
do_play_the_selected_song
This method can be used to play the currently selected song.
If no song is selected, a pop-over message should appear.
#
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2343
def do_play_the_selected_song(
_ = entry_file_path_text?
)
if _ and File.exist?(_)
Thread.new {
esystem "mpv #{_}"
}
else
e 'No file exists at '+_.to_s+'.'
return_popover(
'Please first select a .mp3 file that exists. You '\
'can double-click on this entry above.',
entry_file_path?, 20
).
end
end
|
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1089
def
if @settings_popover.nil?
@settings_popover = return_popover(
'',
, :default_padding, @settings_vbox
)
end
@settings_popover.
end
|
#
This method applies all changes by invoking metadata?.update!
#
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2122
def do_save_the_tags
metadata = metadata?
return unless metadata
display_information_about_the_song if is_on_roebe?
_ = @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. = @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
metadata.update!
display_information_about_the_song if is_on_roebe?
add_this_text_to_the_status_bar(
'The meta-data was saved (on '+
::MultimediaParadise.return_ss_mm_hh.to_s+').'
)
end
|
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2182
def do_show_information_about_this_application
dialog = create_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.(
"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
|
#entry_for_the_title_of_the_song? ⇒ Boolean
Also known as:
entry_for_the_song_name?
#
entry_for_the_title_of_the_song?
#
1127
1128
1129
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1127
def entry_for_the_title_of_the_song?
@entry_for_the_title_of_the_song
end
|
#entry_use_which_audio_file? ⇒ Boolean
Also known as:
entry_on_top?, entry_file_path?
#
entry_use_which_audio_file?
#
515
516
517
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 515
def entry_use_which_audio_file?
@entry_file_path
end
|
#filename? ⇒ Boolean
589
590
591
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 589
def filename?
@entry_file_path.text?.to_s
end
|
#genre? ⇒ Boolean
Also known as:
genre
1481
1482
1483
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1481
def genre?
@genre
end
|
#handle_CSS_rules ⇒ Object
#
handle_CSS_rules (CSS tag)
This is currently only in use if gtk3 is in use.
#
184
185
186
187
188
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 184
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
more_CSS_then_apply_it(USE_THESE_CSS_RULES)
end
|
849
850
851
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 849
def
@header_bar
end
|
1765
1766
1767
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1765
def
54
end
|
#
This will set @metadata_for_the_song.
#
1734
1735
1736
1737
1738
1739
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1734
def instantiate_the_metadata_from_this_file(this_file)
@metadata_for_the_song = MultimediaParadise.analyse_tags_of_this_mp3_file(this_file)
end
|
#label_duration_content? ⇒ Boolean
#
label_duration_content?
#
1134
1135
1136
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1134
def label_duration_content?
@information_about_a_mp3_file.label_duration_content?
end
|
#length_in_seconds? ⇒ Boolean
1639
1640
1641
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1639
def length_in_seconds?
@length_in_seconds
end
|
#main_file_text? ⇒ Boolean
Also known as:
main_file?, which_file?, entry_file_path_text?
2363
2364
2365
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2363
def main_file_text?
@entry_file_path.text?
end
|
#
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
#
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 978
def (
i = commandline_arguments?
)
if i and i.is_a?(Array)
i.each {|entry| (entry) }
else
unless i.start_with?('--')
_ = i.to_s
_ = File.expand_path(i).to_s.delete('-')
@entry_file_path.set_text(_)
if File.exist? _ do_analyse_the_default_file
set_all_relevant_entries_based_on_the_metadata
end
end
end
end
|
1744
1745
1746
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1744
def metadata_for_the_song?
@metadata_for_the_song
end
|
#padding? ⇒ Boolean
202
203
204
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 202
def padding?
4
end
|
961
962
963
964
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 961
def parent_widget=(i = ARGV)
i = i.first if i.is_a? Array
@parent_widget = i
end
|
1488
1489
1490
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1488
def performer?
@performer
end
|
#report_album(i = @album) ⇒ Object
1378
1379
1380
1381
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1378
def report_album(i = @album)
e sfancy(' Album: '.ljust(N_PAD))+
right_colour(i.to_s)
end
|
#report_artist(i = @artist) ⇒ Object
1370
1371
1372
1373
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1370
def report_artist(i = @artist)
e sfancy(' Artist: '.ljust(N_PAD))+
right_colour(i.to_s)
end
|
1386
1387
1388
1389
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1386
def (i = @comment)
e sfancy(' Comment: '.ljust(N_PAD))+
right_colour(i.to_s)
end
|
#report_everything ⇒ Object
Also known as:
report
#
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.
#
1577
1578
1579
1580
1581
1582
1583
1584
1585
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1577
def report_everything
report_title
report_artist
report_album
report_year
report_genre
report_length_in_seconds
end
|
#report_genre(i = @genre) ⇒ Object
#
report_genre
To get all available genres, see:
https://en.wikipedia.org/wiki/ID3
#
1399
1400
1401
1402
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1399
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) ⇒ Object
#
report_length_in_seconds
#
1415
1416
1417
1418
1419
1420
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1415
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) ⇒ Object
1717
1718
1719
1720
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1717
def report_title(i = @title)
e sfancy(' Title: '.ljust(N_PAD))+
right_colour(i.to_s)
end
|
#report_year(i = @year) ⇒ Object
1407
1408
1409
1410
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1407
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) ⇒ Object
#
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.
#
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 228
def require_the_appropriate_id_tagger(
i = ID_TAGGER_TO_USE_FOR_THE_MP3_FILES
)
case i
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
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 ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 142
def reset
super() if respond_to?(:super)
reset_the_shared_module reset_the_base_module
reset_the_internal_variables
infer_the_namespace
@configuration = [true, __dir__, namespace?]
title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
infer_the_size_automatically
@information_about_a_mp3_file = return_widget_information_about_a_mp3_file
@metadata_for_the_song = nil
require_the_appropriate_id_tagger
end
|
#reset_all_main_entries ⇒ Object
#
reset_all_main_entries
#
878
879
880
881
882
883
884
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 878
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
|
#reset_the_shared_module ⇒ Object
#
reset_the_shared_module
This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.
#
196
197
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 196
def reset_the_shared_module
end
|
863
864
865
866
867
868
869
870
871
872
873
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 863
def return_all_entries_on_the_right_side_widget
[ @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
|
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1981
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
when :no_text
button = create_button
button.set_image(icon)
else
button = create_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
|
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1034
def return_button_play
button_play = create_button_with_label(' _Play')
use_this_icon_name = 'video-x-generic-symbolic.symbolic'
icon = load_icon(use_this_icon_name, 32, 0) 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.on_hover(: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 ⇒ Object
#
return_entry_from_the_combo_box_entry_for_genre_select_or_from_the_entry_for_the_genre
#
999
1000
1001
1002
1003
1004
1005
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 999
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) ⇒ Object
#
return_event_box_for_opening_a_file
The first two arguments can designate a certain width and height for the widget.
#
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1932
def return_event_box_for_opening_a_file(
width = 110,
height = 65
)
event_box_open_file = create_event_box
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?) ⇒ Object
#
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.
#
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2034
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
|
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2227
def return_the_save_button(
make_use_of_special_CSS_rules = true
)
case make_use_of_special_CSS_rules
when :do_not_make_use_of_a_special_CSS_class
make_use_of_special_CSS_rules = false
end
button_save = create_button_with_label(' _Save', use_underline: true) use_this_icon_name = 'folder-download'
icon = load_icon(use_this_icon_name, 32, 0) 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
|
1772
1773
1774
1775
1776
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1772
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) ⇒ Object
1725
1726
1727
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1725
def right_colour(i)
mediumpurple(i)
end
|
#run ⇒ Object
2388
2389
2390
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2388
def run
run_super
end
|
#save ⇒ Object
1703
1704
1705
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1703
def save
@tag.save
end
|
#
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.
#
503
504
505
506
507
508
509
510
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 503
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) ⇒ Object
Also known as:
album=
1516
1517
1518
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1516
def set_album(i)
@album = i.to_s
end
|
#
This method will sync all relevant entries into the corresponding gtk-entry at hand.
#
626
627
628
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/tag_mp3_files/tag_mp3_files.rb', line 626
def set_all_relevant_entries_based_on_the_metadata(
this_file = main_file?
)
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?)
_.
return
end
set_the_file_size_from_this_file
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
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
|
#set_artist(i) ⇒ Object
Also known as:
artist=
1523
1524
1525
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1523
def set_artist(i)
@artist = i.to_s
end
|
1530
1531
1532
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1530
def (i)
@comment = i.to_s
end
|
#set_genre(i) ⇒ Object
Also known as:
genre=
1551
1552
1553
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1551
def set_genre(i)
@genre = i.to_s
end
|
#set_main_entry(i) ⇒ Object
1806
1807
1808
1809
1810
1811
1812
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1806
def set_main_entry(i)
@entry_file_path.set_text(i)
if File.exist? i do_analyse_the_default_file
set_all_relevant_entries_based_on_the_metadata
end
end
|
#set_new_album(i) ⇒ Object
1565
1566
1567
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1565
def set_new_album(i)
@tag.album = i
end
|
#set_new_year(i) ⇒ Object
1558
1559
1560
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1558
def set_new_year(i)
@tag.year = i.to_i end
|
#set_the_bitrate(i) ⇒ Object
#
set_the_bitrate
This method will update the appropriate label in the grid, containing the bitrate of the .mp3 file.
#
1144
1145
1146
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1144
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?) ⇒ Object
#
set_the_file_size_from_this_file
#
472
473
474
475
476
477
478
479
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 472
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) ⇒ Object
1151
1152
1153
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1151
def set_the_samplerate(i)
@information_about_a_mp3_file.label_sample_rate_content.set_text(i.to_s)
end
|
#set_this_file(i) ⇒ Object
1710
1711
1712
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1710
def set_this_file(i)
@this_file = i
end
|
#set_title(i) ⇒ Object
Also known as:
title=
1509
1510
1511
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1509
def set_title(i)
@title = i.to_s
end
|
#set_track(i) ⇒ Object
Also known as:
track=
1537
1538
1539
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1537
def set_track(i)
@track = i.to_i end
|
#set_year(i) ⇒ Object
Also known as:
year=
1544
1545
1546
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1544
def set_year(i)
@year = i.to_i end
|
#
This method can be used to show some debug-related information.
#
950
951
952
953
954
955
956
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 950
def show_debug_information
e
e '@width and @height are: '+
@width.to_s+', '+
@height.to_s
e
end
|
#smaller_font? ⇒ Boolean
175
176
177
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 175
def smaller_font?
SMALLER_FONT
end
|
#song_directory? ⇒ Boolean
2332
2333
2334
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2332
def song_directory?
'/home/x/songs/'
end
|
#song_name? ⇒ Boolean
889
890
891
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 889
def song_name?
@entry_for_the_title_of_the_song.text?
end
|
#sync_artist_onto_entry ⇒ Object
#
sync_artist_onto_entry
#
896
897
898
899
900
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 896
def sync_artist_onto_entry
if metadata?
@entry_for_the_artist.set_text(metadata?.artist.to_s)
end
end
|
484
485
486
487
488
489
490
491
492
493
494
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 484
def
dataset = dataset?
if dataset
_ = dataset..to_s.dup
_ = _.force_encoding(::MultimediaParadise::UTF_ENCODING)
@entry_for_the_comment.set_text(_)
end
end
|
#sync_genre_onto_entry(this_text = :infer_from_the_dataset) ⇒ Object
#
sync_genre_onto_entry
#
1158
1159
1160
1161
1162
1163
1164
1165
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1158
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) ⇒ Object
#
sync_the_duration_of_the_file_onto_the_correct_entry
#
1752
1753
1754
1755
1756
1757
1758
1759
1760
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1752
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) ⇒ Object
#
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.
#
2173
2174
2175
2176
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2173
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 ⇒ Object
#
sync_title_onto_entry
#
534
535
536
537
538
539
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 534
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 ⇒ Object
905
906
907
908
909
910
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 905
def sync_year_onto_entry
dataset = dataset?
if dataset
@entry_for_the_year.set_text(dataset.year.to_s)
end
end
|
#tag? ⇒ Boolean
Also known as:
tag
1425
1426
1427
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1425
def tag?
@tag
end
|
#
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.
#
527
528
529
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 527
def the_save_button_is_available_again
@button_save.is_sensitive_again
end
|
#this_file? ⇒ Boolean
1632
1633
1634
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1632
def this_file?
@this_file
end
|
#title? ⇒ Boolean
Also known as:
title
1432
1433
1434
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1432
def title?
@title
end
|
#track? ⇒ Boolean
Also known as:
track
1502
1503
1504
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1502
def track?
@track
end
|
#try_to_require_the_tablib_gem ⇒ Object
#
try_to_require_the_tablib_gem
#
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1664
def try_to_require_the_tablib_gem
begin
require 'taglib'
rescue LoadError; end
end
|
#update!(this_file = @this_file) ⇒ Object
#
update!
This method can be used to update the tags.
#
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1680
def update!(
this_file = @this_file
)
TagLib::FileRef.open(this_file) { |fileref| unless fileref.null?
@tag = fileref.tag set_new_album(@album) set_new_year(@year) @tag.title = @title.to_s
@tag.artist = @artist.to_s
@tag.genre = @genre.to_s
@tag. = @comment.to_s
if @track
@tag.track = @track.to_i end
fileref.save
end
}
end
|
#update_the_MPEG_entry(i = which_file?
) ⇒ Object
#
update_the_MPEG_entry
#
2158
2159
2160
2161
2162
2163
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2158
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
|
2258
2259
2260
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2258
def widget_in_the_middle
@information_about_a_mp3_file
end
|
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1177
def widget_left
_ = @widget_on_the_right_side_including_the_title_of_the_song = create_vbox
_.set_border_width(2)
label_title = modify_bold_label(
'Title of the song:',
'black', :right
).center another_tiny_hbox = create_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 = create_image_pixbuf(icon)
another_tiny_hbox.minimal(label_with_the_audio_symbol)
another_tiny_hbox.maximal(label_title)
mini_vbox = create_vbox
mini_vbox.maximal(another_tiny_hbox)
arrow_to_the_right = create_label('→ ')
tiny_hbox = create_hbox
tiny_hbox.minimal(arrow_to_the_right)
tiny_hbox.maximal(@entry_for_the_title_of_the_song)
mini_vbox.maximal(tiny_hbox)
_.minimal(mini_vbox, 0)
@grid_on_the_right_side = create_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)
label_the_artist = create_label('Artist: ').align_left_and_center_in_the_middle
label_the_artist.make_bold
@entry_for_the_artist = create_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) @grid_on_the_right_side.attach(@entry_for_the_artist, 1, 0, 1, 1)
label_for_the_year = create_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 = create_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) hbox = create_hbox
hbox.maximal(@entry_for_the_year, 1)
combo_box_entry = create_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)
label_for_the_album = create_label('Album: ').align_left_and_center_in_the_middle
label_for_the_album.make_bold
@entry_for_the_album = create_entry
@entry_for_the_album.set_max_length(75)
@grid_on_the_right_side.attach(label_for_the_album, 0, 2, 1, 1) @grid_on_the_right_side.attach(@entry_for_the_album, 1, 2, 1, 1)
= create_label('Comment: ').align_left_and_center_in_the_middle
.make_bold
event_box_with_left_arrow = create_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('"'+.text.to_s.strip+'"') unless .text.to_s.empty?
}
mini_hbox = create_hbox
mini_hbox.maximal(@entry_for_the_comment)
mini_hbox.minimal(event_box_with_left_arrow)
@grid_on_the_right_side.attach(, 0, 3, 1, 1) @grid_on_the_right_side.attach(mini_hbox, 1, 3, 1, 1)
label_for_the_track_number = create_label('Track number: ').align_left_and_center_in_the_middle
label_for_the_track_number.make_bold
@entry_for_the_track_number = create_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) @grid_on_the_right_side.attach(@entry_for_the_track_number, 1, 4, 1, 1)
label_for_the_genre = create_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 = create_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) @grid_on_the_right_side.attach(@entry_for_the_genre, 1, 5, 1, 1)
label_for_the_genre_select = create_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
hbox_for_the_genre_select_components = create_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
|
#
This is the large vbox that appears on the very left side, containing tons of buttons.
#
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1107
def widget_right
vbox_containing_the_buttons = create_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
|
#
This widget contains the “File path: ” string.
#
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1057
def widget_second_row
_ = create_hbox
_.pad2px
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 = create_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 = create_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(create_vspacer)
_.minimal(create_vspacer, 1)
return _
end
|
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 2051
def widget_top
_ =
_.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 = create_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)
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 = create_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 {
}
_.pack_start(button_show_the_settings)
return _
end
|
#work_on_this_file(this_file = @this_file) ⇒ Object
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1590
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
TagLib::FileRef.open(this_file) { |fileref| unless fileref.null?
@tag = fileref.tag @title = @tag.title @artist = @tag.artist @album = @tag.album @year = @tag.year @genre = @tag.genre @comment = @tag.
@track = @tag.track
@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
} end
|
#year? ⇒ Boolean
Also known as:
year
1467
1468
1469
|
# File 'lib/multimedia_paradise/gui/universal_widgets/tag_mp3_files/tag_mp3_files.rb', line 1467
def year?
@year
end
|