#!/usr/bin/ruby puts 'Welcome to Sensible Cinema...' require 'rubygems' require 'ruby-wmi' require 'swing_helpers' module SensibleSwing class MainWindow < JFrame def initialize super "Sensible-Cinema" setDefaultCloseOperation JFrame::EXIT_ON_CLOSE panel = JPanel.new panel.set_layout nil setSize 350,400 add panel # why can't I just slap these down? jlabel = JLabel.new 'Welcome to Sensible Cinema' happy = Font.new("Tahoma", Font::PLAIN, 11) jlabel.setFont(happy) jlabel.set_bounds(44,44,136,14) panel.add jlabel c=JButton.new( "Save local copy of an edited DVD" ) c.on_clicked { drive = get_disk_name =begin fc = JFileChooser.new fc.setFileSelectionMode(nil) fc.set_dialog_title "Please pick a DVD descriptor file" fc.set_current_directory(JFile.new( __dir__ + "/../zamples/scene_lists/dvds")) descriptor = fc.execute fc = JFileChooser.new # TODO allow for spaces in save to file fc.set_dialog_title "Pick a location to save it to (like 'my_dvd')" fc.setCurrentDirectory(JFile.new("c:\\")) save_to = fc.execute p [drive, descriptor, save_to] descriptors = YAML.load_file descriptor bat_file = VLCProgrammer.convert_to_full_xspf(descriptors, save_to, drive) temp_dir = Dir.tmpdir temp_file = temp_dir + '/' + 'convert_it.bat' File.write(temp_file, bat_file) p 'running', temp_file p 'got', system(temp_file) JOptionPane.showMessageDialog(nil, " Done--you may now watch file #{save_to}.ps in VLC player", "Done!", JOptionPane::ERROR_MESSAGE) self.close =end } c.set_bounds(44,180,200,23) panel.add c reload = JButton.new( "reload code" ).on_clicked { eval File.read(__FILE__), nil, __FILE__ p 're-evaled it' } reload.set_bounds(44,280,200,23) panel.add reload # if ARGV.find{|a| a == '--test'} end def exit_and_close JOptionPane.showMessageDialog(nil, "exiting", "exiting", JOptionPane::ERROR_MESSAGE) close exit end def get_disk_name disks = WMI::Win32_LogicalDisk.find(:all) opticals = disks.select{|d| d.Description =~ /CD-ROM/} opticals.map!{|d| [d.Name + "\\", d.VolumeName]} p opticals p 'showing dialog' dialog = GetDisk.new(self, opticals) p 'done showing dialog' return opticals[0][0] end end class GetDisk < JDialog def initialize parent, options_array super parent, true box = JComboBox.new box.add_action_listener do |e| p 'chosen perhaps?', e, box.get_selected_index, e.get_source, get_selected_item #dispose if end box.add_item "Select DVD drive" box.add_item "halloo" add box pack end end end SensibleSwing::MainWindow.new.set_visible true puts 'Please see the Sensible Cinema window'