Class: MultimediaParadise::GUI::UniversalWidgets::CutMultimedia
- Inherits:
-
Base
- Object
- Base
- MultimediaParadise::GUI::UniversalWidgets::CutMultimedia
show all
- Includes:
- UniversalWidgets::BaseModule
- Defined in:
- lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb
Overview
Constant Summary
collapse
- TITLE =
'Cut multimedia files'
- WIDTH =
'82% or minimum 800px'
- HEIGHT =
'55% or minimum 600px'
- USE_THIS_FONT =
:dejavu_condensed_20
- LARGER_FONT =
:hack_25
- SMALLER_FONT =
:hack_20
Constants inherited
from Base
Base::ERROR, Base::ERROR_LINE, Base::NAMESPACE, Base::USE_THIS_NAMESPACE_FOR_THE_COLOURS, Base::USE_THIS_NAMESPACE_FOR_THE_CORE_COLOURS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#actions, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #cartoons_directory?, #clear_the_internal_hash, #cliner, #cliner_with_time_stamp, #colourized_comment, #copy_file, #crimson, #dataset_from_file_video_collection, #dd_mm_yyyy, #debug?, #default_readlines, #directory_to_realvids?, #do_not_use_opn, #dodgerblue, #does_the_video_player_support_this_commandline?, #e, #ecomment, #ecrimson, #efancy, #enable_debug, #ensure_main_encoding, #ensure_that_the_output_directory_exists, #eparse, #erev, #esystem, #ewarn, #file_video_collection?, #filter_for_audio_files, #filter_for_video_files, #forestgreen, #gold, #grey, #hh_mm_ss, #home_x_video?, #indianred, #infer_the_namespace, #internal_hash?, #is_audio_file?, #is_mkv?, #is_mp3?, #is_mp4?, #is_multimedia_file?, #is_on_roebe?, #is_video_file?, #konsole_colour_peru, #lightblue, #lightgreen, #load_yaml, #local_audio_directory?, #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) ⇒ CutMultimedia
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 68
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
649
650
651
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 649
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 631
def self.run(
i = ARGV
)
require 'gtk_paradise/run'
_ = ::MultimediaParadise::GUI::Gtk::CutMultimedia.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.maximize
r.top_left_then_run
end
|
Instance Method Details
#a_new_file_has_been_assigned(i) ⇒ Object
#
a_new_file_has_been_assigned
#
147
148
149
150
151
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 147
def a_new_file_has_been_assigned(i)
@cut_multimedia_object.set_work_on_this_file(i)
set_use_this_file(i)
update_the_duration
end
|
#border_size? ⇒ Boolean
360
361
362
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 360
def border_size?
2
end
|
200
201
202
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 200
def button_trim?
@button_trim
end
|
235
236
237
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 235
def commit_button?
@button_commit
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag)
#
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 521
def connect_the_skeleton
abort_on_exception
outer_vbox = create_vbox
instantiate_a_new_cut_multimedia_object
hbox = create_hbox
hbox.minimal(
text('Work on this file'), 5
)
commandline_arguments = commandline_arguments?
if commandline_arguments and
!commandline_arguments.empty? and
File.file?(commandline_arguments.first.to_s)
set_use_this_file(
commandline_arguments.first.to_s
)
end
hbox.maximal(@entry_work_on_this_file, 3)
_ = drag_from_left_to_right(hbox, return_file_chooser_widget)
_.position = 900
outer_vbox.minimal(_, 2)
hbox = create_hbox
hbox.minimal(text('Duration of the file:'), 3)
@text_duration_of_the_file = create_label
@text_duration_of_the_file.make_bold
hbox.minimal(@text_duration_of_the_file, 3)
outer_vbox.minimal(hbox, 3)
hbox = create_hbox
outer_vbox.minimal(hbox, 3)
hbox = create_hbox
hbox.minimal(image_audio_x_generic_symbolic, 3)
hbox.minimal(button_trim?, 3)
hbox.minimal(@entry_n_seconds_for_trimming, 3)
hbox.minimal(@button_play_the_audio_file, 3)
hbox.minimal(@button_delete_the_audio_file, 3)
hbox.minimal(@button_quit, 3)
outer_vbox.minimal(hbox, 3)
unless @entry_work_on_this_file.text?.empty?
update_the_duration
end
hbox = create_hbox
hbox.minimal(
text('This <b>multimedia-player</b> is in use:'), 3
)
hbox.minimal(@entry_multimedia_player_in_use, 3)
outer_vbox.minimal(hbox, 3)
outer_vbox.minimal(return_hbox_containing_the_start_and_end_position_entries, 3)
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
|
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
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 367
def create_the_buttons
create_the_commit_button
create_the_trim_button
create_the_play_the_audio_file_button
create_the_delete_the_audio_file_button
@button_quit = button('_Quit')
@button_quit.signal_connect_after(:clicked) {
signal_emit('destroy')
Gtk.main_quit
}
return_all_buttons.each {|this_button|
this_button.bblack2
}
end
|
220
221
222
223
224
225
226
227
228
229
230
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 220
def create_the_commit_button
@button_commit = button('_Commit')
@button_commit.hint = 'Click on this button to cut at the specified start and end positions.'
@button_commit.bblack2
@button_commit.on_clicked {
new_file = do_cut_the_audio_file
if !uses_gtk3?
main_entry?.set_text(new_file.to_s)
end
}
end
|
282
283
284
285
286
287
288
289
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 282
def create_the_delete_the_audio_file_button
@button_delete_the_audio_file = button('_Delete the audio file')
@button_delete_the_audio_file.hint = 'Click this button in '\
'order to delete the audio-file.'
@button_delete_the_audio_file.on_clicked {
do_delete_the_audio_file
}
end
|
#create_the_entries ⇒ Object
#
create_the_entries (entries tag, entry tag)
The shared attributes for all entries are batch-defined near the end of this method.
#
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 461
def create_the_entries
@entry_work_on_this_file = create_entry
@entry_work_on_this_file.set_size_request(450, 44)
@entry_work_on_this_file.hint = "Denote on which "\
"file you work here.\nThis is a mandatory entry."
@entry_work_on_this_file.on_enter {
_ = @entry_work_on_this_file.text?.to_s
if _ and File.exist?(_)
a_new_file_has_been_assigned(_)
end
}
@entry_multimedia_player_in_use = create_entry
@entry_multimedia_player_in_use.hint =
'This entry designates the multimedia player in use. '\
'<b>mpv</b> is a good choice here normally.'
@entry_multimedia_player_in_use.do_center
@entry_multimedia_player_in_use.on_click_select_everything
@entry_multimedia_player_in_use.set_text(
::MultimediaParadise.player?.to_s
)
@entry_multimedia_player_in_use.on_clicked {
_ = @entry_multimedia_player_in_use.text?
MultimediaParadise.set_use_this_multimedia_player(_) unless _.empty?
}
@entry_n_seconds_for_trimming = create_entry
@entry_n_seconds_for_trimming.center
@entry_n_seconds_for_trimming.set_text('30')
@entry_n_seconds_for_trimming.set_size_request(50, 40)
return_all_entries.each {|this_entry|
this_entry.pad8px
this_entry.set_name(
'entry_yellow_background_and_slight_border'
)
}
end
|
207
208
209
210
211
212
213
214
215
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 207
def create_the_play_the_audio_file_button
@button_play_the_audio_file = button('_Play the audio file')
@button_play_the_audio_file.hint = 'Click this button to '\
'play the audio file. This requires that you have assigned '\
'a file in the above user-input entry.'
@button_play_the_audio_file.on_clicked {
do_play_the_audio_file
}
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
513
514
515
516
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 513
def create_the_skeleton
create_the_entries
create_the_buttons
end
|
188
189
190
191
192
193
194
195
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 188
def create_the_trim_button
@button_trim = button('_Trim')
@button_trim.hint = 'Trim n seconds from the beginning '\
'of the multimedia file.'
@button_trim.on_clicked {
do_trim
}
end
|
602
603
604
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 602
def do_all_startup_related_actions
do_assume_the_duration_as_end_position_if_a_file_has_been_assigned
end
|
#do_assume_the_duration_as_end_position_if_a_file_has_been_assigned(main_file = main_file?
) ⇒ Object
#
do_assume_the_duration_as_end_position_if_a_file_has_been_assigned
This method may modify the content of the entry stored under
#
612
613
614
615
616
617
618
619
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 612
def do_assume_the_duration_as_end_position_if_a_file_has_been_assigned(
main_file = main_file?
)
if main_file and File.file?(main_file)
_ = duration_of_the_file?
@end_position_entry.set_text(_.to_s)
end
end
|
#do_cut_the_audio_file ⇒ Object
#
do_cut_the_audio_file
#
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 294
def do_cut_the_audio_file
start_position = @start_position_entry.text?
end_position = @end_position_entry.text?
audio_file_to_use = File.absolute_path(main_file?)
cd('/tmp/') if File.directory? '/tmp/'
cd('/home/x/Temp/') if File.directory? '/home/x/Temp/'
e 'The file `'+sfile(audio_file_to_use.to_s)+'` will be used.'
_ = MultimediaParadise::CutMultimedia.new(audio_file_to_use, :do_not_run_yet)
_.assign_this_file(audio_file_to_use)
_.set_start_position(start_position)
_.set_end_position(end_position)
_.do_cut
result = _.absolute_path_of_the_output_file?
(
commit_button?,
"The new file can now be found at:\n\n <b>#{result}</b>\n\n"
) { :make_selectable } if uses_gtk3?
return result
end
|
#do_delete_the_audio_file(i = main_file?
) ⇒ Object
#
do_delete_the_audio_file
#
400
401
402
403
404
405
406
407
408
409
410
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 400
def do_delete_the_audio_file(
i = main_file?
)
if i
@cut_multimedia_object.set_main_file(i)
Thread.new {
@cut_multimedia_object.('delete_the_audio_file')
}
main_entry?.clear
end
end
|
#do_merge_the_created_files ⇒ Object
#
do_merge_the_created_files
#
415
416
417
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 415
def do_merge_the_created_files
e 'The merge-functionality has not yet been implemented.'
end
|
#do_play_the_audio_file(i = main_file?
) ⇒ Object
#
do_play_the_audio_file
#
172
173
174
175
176
177
178
179
180
181
182
183
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 172
def do_play_the_audio_file(
i = main_file?
)
if i
@cut_multimedia_object.set_main_file(i)
Thread.new {
@cut_multimedia_object.(
'play_the_audio_file'
)
}
end
end
|
#do_trim ⇒ Object
341
342
343
344
345
346
347
348
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 341
def do_trim
_ = "trim #{@entry_n_seconds_for_trimming.text?}"
@cut_multimedia_object.(_)
this_file = @cut_multimedia_object.output_file?
set_main_entry(this_file)
update_the_duration
@cut_multimedia_object.set_work_on_this_file(this_file)
end
|
#duration?(i) ⇒ Boolean
156
157
158
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 156
def duration?(i)
::MultimediaParadise.duration?(i) { :do_not_exit }.to_s
end
|
#duration_of_the_file?(this_file = main_file?
) ⇒ Boolean
#
duration_of_the_file?
#
163
164
165
166
167
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 163
def duration_of_the_file?(
this_file = main_file?
)
duration?(this_file).to_f
end
|
#handle_CSS_rules ⇒ Object
#
handle_CSS_rules (CSS tag)
This is currently only in use if gtk3 is in use.
#
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 132
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
more_CSS_then_apply_it '
popover {
padding: 25px;
border: 3px dotted green;
font-size: 20px;
}
'
end
|
104
105
106
107
108
109
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 104
def instantiate_a_new_cut_multimedia_object
@cut_multimedia_object = MultimediaParadise::CutMultimedia.new(first_argument?) { :gui }
end
|
#main_entry? ⇒ Boolean
320
321
322
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 320
def main_entry?
@entry_work_on_this_file
end
|
#main_file? ⇒ Boolean
327
328
329
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 327
def main_file?
main_entry?.text?.to_s
end
|
#padding? ⇒ Boolean
353
354
355
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 353
def padding?
2
end
|
#reset ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 84
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
end
|
#reset_the_shared_module ⇒ Object
#
reset_the_shared_module
This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.
#
117
118
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 117
def reset_the_shared_module
end
|
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 437
def return_file_chooser_widget
file_chooser = create_file_chooser_button
file_chooser.bblack1
file_chooser.on_click {
create_a_new_file_chooser_dialog(self, 'Choose a file:') {{
additional_directories: '/home/x/songs/'
}}
_ = ::Gtk.main_file?
if _ and File.exist?(_)
a_new_file_has_been_assigned(_)
end
}
return file_chooser
end
|
#return_hbox_containing_the_start_and_end_position_entries ⇒ Object
#
return_hbox_containing_the_start_and_end_position_entries
#
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
276
277
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 242
def return_hbox_containing_the_start_and_end_position_entries
hbox = create_hbox
hbox.minimal(text('Start position:'), 5)
@start_position_entry = create_entry('0')
@start_position_entry.light_blue_background
@start_position_entry.bblack1
@start_position_entry.center
@start_position_entry.hint = 'You can provide n seconds, such as '\
'20, to start at the 20 seconds mark.'
hbox.minimal(@start_position_entry, 3)
hbox.minimal(text('End position:'), 5)
@end_position_entry = create_entry
@end_position_entry.light_blue_background
@end_position_entry.bblack1
@end_position_entry.center
@end_position_entry.hint = 'You can provide n seconds, such as '\
'20, to end at the 20 seconds mark.'
hbox.minimal(@end_position_entry, 3)
hbox.minimal(button_commit?, 3)
button_merge_the_created_files = button('_Merge the created files')
button_merge_the_created_files.clear_background
button_merge_the_created_files.bblack2
button_merge_the_created_files.css_class('BG_lightgreen')
button_merge_the_created_files.on_hover_colour(:springgreen)
button_merge_the_created_files.on_clicked {
do_merge_the_created_files
}
hbox.minimal(button_merge_the_created_files, 3)
return hbox
end
|
#run ⇒ Object
624
625
626
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 624
def run
run_super
end
|
#set_use_this_file(i) ⇒ Object
Also known as:
set_main_entry
334
335
336
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 334
def set_use_this_file(i)
main_entry?.set_text(i.to_s)
end
|
#smaller_font? ⇒ Boolean
123
124
125
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 123
def smaller_font?
SMALLER_FONT
end
|
#update_the_duration(target_file = main_file?
) ⇒ Object
422
423
424
425
426
427
428
429
430
431
432
|
# File 'lib/multimedia_paradise/gui/universal_widgets/cut_multimedia/cut_multimedia.rb', line 422
def update_the_duration(
target_file = main_file?
)
if target_file and !target_file.empty?
_ = duration?(target_file)
@text_duration_of_the_file.set_text(
'<b>'+_.to_s+'</b> seconds'
)
@text_duration_of_the_file.do_markify
end
end
|