module MultimediaParadise::GUI::Gtk::MultimediaConverterModule
Constants
- ARRAY_FILTER_THESE_FILES
#¶ ↑
ARRAY_FILTER_THESE_FILES
¶ ↑#¶ ↑
- HEIGHT
#¶ ↑
HEIGHT
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- WIDTH
#¶ ↑
WIDTH
¶ ↑#¶ ↑
Public Class Methods
new( this_file = ARGV, run_already = true )
click to toggle source
#¶ ↑
initialize¶ ↑
You can pass an argument as optional file name. @save_file_to_this_directory should always have a trailing /
#¶ ↑
Calls superclass method
# File lib/multimedia_paradise/gui/shared_code/multimedia_converter/multimedia_converter_module.rb, line 75 def initialize( this_file = ARGV, run_already = true ) super(:vertical, 2) set_selected_file(this_file) reset run if run_already end
run()
click to toggle source
#¶ ↑
MultimediaParadise::GUI::Gtk::MultimediaConverterModule.run
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/multimedia_converter/multimedia_converter_module.rb, line 441 def self.run require 'gtk_paradise/run' _ = ::MultimediaParadise::GUI::Gtk::MultimediaConverter.new r = ::Gtk.run r << _ r.set_width(_.width?) r.set_height(_.height?) r.set_size_request( _.width? / 1.5, _.height? / 1.5 ) r.realize # This has to be called before set_cursor() below. boat_cursor = :boat if ::Gtk.use_gtk2? boat_cursor = Gdk::CursorType::BOAT end r.window.set_cursor(Gdk::Cursor.new(boat_cursor)) r.signal_connect(:delete_event) { |_widget| ::Gtk.main_quit } r.enable_simple_exit # ======================================================================= # # Next we will add several alt+key shortcuts. # ======================================================================= # 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 return r end
Public Instance Methods
add_statusbar_message( this_msg = 'Start' )
click to toggle source
#¶ ↑
add_statusbar_message
¶ ↑
This method will add to the status-bar queue.
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/multimedia_converter/multimedia_converter_module.rb, line 127 def add_statusbar_message( this_msg = 'Start' ) @status_bar.push(@status_bar_context_id, this_msg) # Add message end
Also aliased as: add_to_statusbar, statusbar_message
connect_skeleton()
click to toggle source
#¶ ↑
connect_skeleton
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/multimedia_converter/multimedia_converter_module.rb, line 371 def connect_skeleton label = modify_bold_label('Convert to the following format:','slateblue') label.the_text_appears_on_the_left_side hbox = ::Gtk.create_paned_hbox(@entry_base_file, ::Gtk.create_paned_vbox( label, @combo_box_convert_to_this_audio_type) ) add(hbox) hbox2 = gtk_hbox hbox2.minimal( modify_bold_label('Save file to this directory:'), 0 ) hbox2.maximal( @entry_save_where_to, 0 ) add(hbox2) add(@button_convert) add( ::Gtk.create_paned_hbox(@button_file_chooser, @button_quit) ) minimal( @status_bar, 2 ) end
create_combo_boxes()
click to toggle source
#¶ ↑
create_combo_boxes
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/multimedia_converter/multimedia_converter_module.rb, line 281 def create_combo_boxes @combo_box_convert_to_this_audio_type = gtk_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
create_entries()
click to toggle source
#¶ ↑
create_entries
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/multimedia_converter/multimedia_converter_module.rb, line 238 def create_entries @entry_base_file = gtk_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 # === scroll-up event when Gdk::EventScroll::UP get_audio_file_listing @counter_position += 1 pp @counter_position pp @array_audio_files[@counter_position] # === scroll-down event 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 = gtk_entry update end
create_skeleton()
click to toggle source
create_statusbar()
click to toggle source
do_convert_multimedia_file()
click to toggle source
#¶ ↑
do_convert_multimedia_file
¶ ↑
This is the unified method to convert a multimedia file from one format to another one.
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/multimedia_converter/multimedia_converter_module.rb, line 295 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 # === mp3 when 'mp3' application_to_use = 'lame --decode ' # === ogg when 'ogg' application_to_use = 'ffmpeg -i ' # === wav when 'wav' application_to_use = 'lame --decode ' else application_to_use = '' # empty fall back... 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) # ======================================================================= # # After the system-command has been run, we may modify the statusbar, to # keep track of changes. This will only be done if the converted file # actually exists. # ======================================================================= # 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)
click to toggle source
favicon?()
click to toggle source
get_audio_file_listing( i = return_pwd )
click to toggle source
get_rid_of_mp3()
click to toggle source
get_rid_of_mp3_and_other_dirs()
click to toggle source
padding?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/multimedia_converter/multimedia_converter_module.rb, line 88 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] increase_font_size # ======================================================================= # # === @counter_position # ======================================================================= # @counter_position = 0 set_width(WIDTH) set_height(HEIGHT) # ======================================================================= # # === @save_file_to_this_directory # # The next variable keeps track into which directory we will save # the converted files. # ======================================================================= # @save_file_to_this_directory = return_pwd if is_on_roebe? and File.directory?('/home/Temp') @save_file_to_this_directory = '/home/Temp/' end append_project_css_file infer_the_size_automatically end
run()
click to toggle source
set_selected_file(i)
click to toggle source
sync_selected_file_to_the_corresponding_entry()
click to toggle source
system_command(cmd)
click to toggle source
#¶ ↑
system_command
¶ ↑
Wrapper to run a system-command
#¶ ↑
# File lib/multimedia_paradise/gui/shared_code/multimedia_converter/multimedia_converter_module.rb, line 353 def system_command(cmd) if cmd.include? ' ' # Find out if the program exists. first_command = cmd.split(' ').first result = `#{first_command} 2>&1` if result.empty? # if empty we assume sox was not installed. _ = 'The program `'+first_command+'` was not found. Is it installed?' e _ add_to_statusbar(_) else system cmd end end end
title?()
click to toggle source