Class: MultimediaParadise::GUI::UniversalWidgets::MultimediaConverter
- Inherits:
-
Base
- Object
- Base
- MultimediaParadise::GUI::UniversalWidgets::MultimediaConverter
show all
- Includes:
- MultimediaParadise::GUI, UniversalWidgets::BaseModule
- Defined in:
- lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb
Overview
Constant Summary
collapse
- ARRAY_FILTER_THESE_FILES =
#
ARRAY_FILTER_THESE_FILES
#
%w(
*.ogg
*.mp3
*.wav
*.flac
)
- WIDTH =
'95% or minimum 850px'
- HEIGHT =
'80% or minimum 500px'
- TITLE =
'Multimedia Converter'
- FONT_SIZE =
18
- USE_THIS_FONT =
"Liberation serif #{FONT_SIZE}"
ISO, MAIN_FONT_TO_USE, N, MultimediaParadise::GUI::UTF, VIDEO_COLLECTION
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
#populate_the_dataset_with_this_array, #set_gtk_font_to_use
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, #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 = ARGV, run_already = true) ⇒ MultimediaConverter
#
initialize
You can pass an argument as optional file name, as the very first argument to this method (via an Array).
#
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 88
def initialize(
commandline_arguments = ARGV,
run_already = true
)
determine_the_GUI_to_be_used(commandline_arguments) reset
set_commandline_arguments(
commandline_arguments
)
set_selected_file(commandline_arguments.first)
on_delete_event_quit_the_application
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
581
582
583
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 581
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
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/multimedia_converter/multimedia_converter.rb', line 547
def self.run(
i = ARGV
)
require 'gtk_paradise/run'
_ = ::MultimediaParadise::GUI::Gtk::MultimediaConverter.new(i)
r = ::Gtk.run
_.set_parent_widget(r) r << _
r.automatic_size_then_automatic_title
r.enable_simple_exit
r.set_background :white
boat_cursor = :boat
r.window.set_cursor(Gdk::Cursor.new(boat_cursor))
r.maximize
r.shortcuts {[
[1, 'click_on_button_number(0)', :alt],
[2, 'click_on_button_number(1)', :alt],
[3, 'click_on_button_number(2)', :alt],
[4, 'click_on_button_number(3)', :alt],
[5, 'click_on_button_number(4)', :alt],
[6, 'click_on_button_number(5)', :alt],
[7, 'click_on_button_number(6)', :alt],
[8, 'click_on_button_number(7)', :alt],
[9, 'click_on_button_number(8)', :alt]
]}
r.top_left_then_run
end
|
.width? ⇒ Boolean
63
64
65
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 63
def self.width?
WIDTH
end
|
Instance Method Details
#add_statusbar_message(this_msg = 'Start') ⇒ Object
Also known as:
add_to_statusbar, statusbar_message
#
add_statusbar_message
This method will add to the status-bar queue.
#
418
419
420
421
422
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 418
def add_statusbar_message(
this_msg = 'Start'
)
@status_bar.push(@status_bar_context_id, this_msg) end
|
#border_size? ⇒ Boolean
206
207
208
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 206
def border_size?
2
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag)
#
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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 480
def connect_the_skeleton
abort_on_exception
outer_vbox = create_vbox
label = modify_bold_label('Convert to the following format:','slateblue')
label.the_text_appears_on_the_left_side
hbox = create_hbox(
@entry_base_file,
vbox(label, @combo_box_convert_to_this_audio_type)
)
outer_vbox.minimal(hbox)
hbox2 = create_hbox
hbox2.minimal(
modify_bold_label('Save file to this directory:'),
0
)
hbox2.maximal(
@entry_save_where_to, 0
)
outer_vbox.minimal(hbox2)
outer_vbox.add(@button_convert)
outer_vbox.add(
hbox(@button_file_chooser, @button_quit)
)
outer_vbox.minimal(
@status_bar, 2
)
window = create_window_or_runner(nil, width?, height?, title?)
window << outer_vbox
properly_prepare_this_window(window,
{
title: title?,
font: font?,
width: width?,
height: height?,
padding: padding?,
border_size: border_size?
}
)
window.show_all
window.top_left
window.set_size(width?, height?)
do_all_startup_related_actions
handle_CSS_rules if use_gtk3?
run_main
end
|
#create_combo_boxes ⇒ Object
262
263
264
265
266
267
268
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 262
def create_combo_boxes
@combo_box_convert_to_this_audio_type = create_combo_box(true)
%w( wav mp3 ogg ).each {|val|
@combo_box_convert_to_this_audio_type.append_text(val)
}
@combo_box_convert_to_this_audio_type.active = 0
end
|
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
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 362
def create_the_buttons
@button_quit = button('_Quit')
@button_convert = button('_Convert')
@button_convert.on_clicked { |widget|
do_convert_multimedia_file
}
@button_convert.hint =
' <b>Click</b> this button in order to <b>convert the '\
'audio-file to another format</b>. '
@button_file_chooser = button('_Open File')
@button_file_chooser.on_clicked { |widget|
@file_chooser_dialog = ::Gtk::FileChooserDialog.new(
'Open MultimediaFile',
::Gtk::Window.new,
::Gtk::FileChooser::ACTION_OPEN,
nil,
[ ::Gtk::Stock::CANCEL, ::Gtk::Dialog::RESPONSE_CANCEL ],
[ ::Gtk::Stock::OPEN, ::Gtk::Dialog::RESPONSE_ACCEPT ]
)
@file_chooser_dialog.current_folder = return_pwd
if ENV.has_key? 'MY_SONGS'
@file_chooser_dialog.add_shortcut_folder(ENV['MY_SONGS'])
end
@file_filter_audio_files = create_file_filter
@file_filter_audio_files.name = 'Audio Files'
ARRAY_FILTER_THESE_FILES.each { |entry|
@file_filter_audio_files.add_pattern(entry)
}
@file_chooser_dialog.add_filter(@file_filter_audio_files)
if File.directory? @save_file_to_this_directory
_ = @save_file_to_this_directory
if is_on_roebe?
_ = '/Depot/j/'
end
@file_chooser_dialog.cd_to(_)
end
case @file_chooser_dialog.run
when ::Gtk::Dialog::RESPONSE_ACCEPT
@entry_base_file.set_text(@file_chooser_dialog.filename)
@selected_file = @file_chooser_dialog.filename
add_to_statusbar(@selected_file)
else
puts 'No file selected.'
end
@file_chooser_dialog.destroy
}
end
|
#create_the_entries ⇒ Object
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 448
def create_the_entries
@entry_base_file = create_entry
@entry_base_file.signal_connect(:event) { |widget, event|
_ = event.event_type
case _.name
when 'GDK_BUTTON_PRESS'
@button_file_chooser.signal_emit(:clicked)
when 'GDK_SCROLL'
case event.direction
when Gdk::EventScroll::UP
get_audio_file_listing
@counter_position += 1
pp @counter_position
pp @array_audio_files[@counter_position]
when Gdk::EventScroll::DOWN
get_audio_file_listing
@counter_position -= 1
pp @counter_position
pp @array_audio_files[@counter_position]
end
else
end
}
@entry_save_where_to = create_entry
update
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (skeleton tag)
#
438
439
440
441
442
443
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 438
def create_the_skeleton
create_the_buttons
create_the_entries
create_combo_boxes
create_the_statusbar
end
|
#create_the_statusbar ⇒ Object
236
237
238
239
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 236
def create_the_statusbar
@status_bar = create_statusbar { :with_resize_grip }
@status_bar_context_id = @status_bar.get_context_id('Conversion Information')
end
|
533
534
535
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 533
def do_all_startup_related_actions
sync_selected_file_to_the_corresponding_entry
end
|
#
This is the unified method to convert a multimedia file from one format to another one.
#
276
277
278
279
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
313
314
315
316
317
318
319
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 276
def do_convert_multimedia_file
if @selected_file.to_s.empty?
statusbar_message(
'Please input a valid (existing) file, on the top-left most entry.'
)
return
end
format_type = @combo_box_convert_to_this_audio_type.active_text
case format_type
when 'mp3'
application_to_use = 'lame --decode '
when 'ogg'
application_to_use = 'ffmpeg -i '
when 'wav'
application_to_use = 'lame --decode '
else
application_to_use = '' end
e ::Colours.sfancy(
'Now converting '+@selected_file
)
cmd = application_to_use.dup
cmd << "#{@selected_file} "
cmd << @entry_save_where_to.text
cmd << get_rid_of_mp3_and_other_dirs+'.'
cmd << format_type
esystem(cmd)
converted_file = @entry_save_where_to.text+
File.basename(@selected_file)
if File.exist?(converted_file)
add_statusbar_message(
"The file #{@selected_file} has been "\
"converted. New location should be: #{converted_file}"
)
end
end
|
#esystem(i) ⇒ Object
324
325
326
327
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 324
def esystem(i)
e i
system_command(i)
end
|
#favicon? ⇒ Boolean
191
192
193
194
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 191
def favicon?
'/home/x/programming/ruby/src/multimedia_paradise/lib/multimedia_paradise/images/'\
'MULTIMEDIA.jpg'
end
|
#get_audio_file_listing(i = return_pwd) ⇒ Object
#
get_audio_file_listing
#
251
252
253
254
255
256
257
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 251
def get_audio_file_listing(
i = return_pwd
)
@array_audio_files = Dir["#{i}*"].select {|entry|
File.file?(entry)
}
end
|
#get_rid_of_mp3 ⇒ Object
244
245
246
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 244
def get_rid_of_mp3
return @selected_file.gsub(/\.mp3/,'')
end
|
#get_rid_of_mp3_and_other_dirs ⇒ Object
#
get_rid_of_mp3_and_other_dirs
we get rid of .mp3 in our name, and any pathname.
#
354
355
356
357
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 354
def get_rid_of_mp3_and_other_dirs
tmp = get_rid_of_mp3
tmp = Pathname.new(tmp).basename.to_s
end
|
#handle_CSS_rules ⇒ Object
#
handle_CSS_rules (CSS tag)
This is currently only in use if gtk3 is in use.
#
164
165
166
167
168
169
170
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 164
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
more_CSS_then_apply_it '
'
end
|
#large_font_in_use? ⇒ Boolean
#
large_font_in_use?
This is like the main font, but a bit larger.
#
215
216
217
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 215
def large_font_in_use?
LARGER_FONT
end
|
#main_font? ⇒ Boolean
Also known as:
normal_font?
222
223
224
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 222
def main_font?
USE_THIS_FONT
end
|
#padding? ⇒ Boolean
199
200
201
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 199
def padding?
10
end
|
#reset ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 105
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
@counter_position = 0
@save_file_to_this_directory = return_pwd
if is_on_roebe? and File.directory?('/home/Temp')
@save_file_to_this_directory = '/home/Temp/'
end
end
|
#reset_the_shared_module ⇒ Object
#
reset_the_shared_module
This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.
#
142
143
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 142
def reset_the_shared_module
end
|
#run ⇒ Object
540
541
542
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 540
def run
run_super
end
|
#set_selected_file(i) ⇒ Object
428
429
430
431
432
433
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 428
def set_selected_file(i)
if i.is_a? Array
i = i.first
end
@selected_file = i
end
|
#slightly_smaller_font? ⇒ Boolean
#
slightly_smaller_font?
#
229
230
231
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 229
def slightly_smaller_font?
SLIGHTLY_SMALLER_FONT
end
|
#smaller_font? ⇒ Boolean
148
149
150
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 148
def smaller_font?
SMALLER_FONT
end
|
#smallest_font? ⇒ Boolean
155
156
157
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 155
def smallest_font?
SMALLEST_FONT
end
|
#sync_selected_file_to_the_corresponding_entry ⇒ Object
#
sync_selected_file_to_the_corresponding_entry
#
184
185
186
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 184
def sync_selected_file_to_the_corresponding_entry
@entry_base_file.set_text(@selected_file.to_s)
end
|
#system_command(cmd) ⇒ Object
#
system_command
Wrapper to run a system-command
#
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 334
def system_command(cmd)
if cmd.include? ' '
first_command = cmd.split(' ').first
result = `#{first_command} 2>&1`
if result.empty? _ = 'The program `'+first_command+'` was not found. Is it installed?'
e _
add_to_statusbar(_)
else
system cmd
end
end
end
|
#update ⇒ Object
#
update
Update certain components of the widget.
#
177
178
179
|
# File 'lib/multimedia_paradise/gui/universal_widgets/multimedia_converter/multimedia_converter.rb', line 177
def update
@entry_save_where_to.set_text(@save_file_to_this_directory.to_s)
end
|