#*********************************************************************** #* Rwd/Tinker -- A Ruby program for the RudyWebDialog. #* Copyright (c) 2004 - 2005 by Steven Gibson. All Rights Reserved. #* #* This library is free software; you can redistribute it and/or #* modify it under the terms of the GNU General Public #* License as published by the Free Software Foundation; either #* . #* #* These files are distributed in the hope that they will be useful, #* but WITHOUT ANY WARRANTY; without even the implied warranty of #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #* General Public License for more details. #* #* You should have received a copy of the GNU General Public #* License along with these files; if not, write to the Free Software #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #* #* For further information please contact the author by e-mail #* at "smalllinux@gmail.com". #***********************************************************************/ # integrate the new configuration files def initiateapplet(nametextlocal) debuginitiate = 0 $rwdtinkerlog.info "initiateapplet: starting config load with: #{nametextlocal}" Dir.chdir($progdir ) #changes the current working directory @confignew = "configuration/" + "#{nametextlocal}.cnf" @configdist = "configuration/" + "#{nametextlocal}.dist" Rconftool::install(@configdist,@confignew) begin configfileload = File.open(@configdist){|f| f.read} eval configfileload #load config file rescue $rwdtinkerlog.error "initiateapplet: error in initiateapplets - config load" debuginitiate += 1 end $tempdoc = " " Dir.chdir($progdir) # change back to top program directory # build the English Language hash file from the parts languagehashvariable = 'Message.update(' startlangdir = File.join(LangDir,"en") #get a list of the files and subdirectories on the starting directory only alanghash = Array.new(Dir[startlangdir].entries.sort) #loop through the list, ignore the files and add all new directories found alanghash.each do |x| #if a directory... if(test(?d,x)) # add to the original list of directories @@tmproot = x + "/**" #adds the new ones to the array blanghash = Dir[@@tmproot].entries.sort blanghash.each do |x| if(test(?d,x)) alanghash.push(x) #appends to the end of the array... end end end end alanghash.each do |x| #if it is a file... if(!test(?d,x)) alanghash.delete(x) else #it is a directory... findfiles(x + "/**") end end #writes the contents of doc into the languagehashvariable languagehashvariable = languagehashvariable + $tempdoc + ' :rwdtinker => "Rwdtinker" ) ;' # END of en Lang building $tempdoc = " " Dir.chdir($progdir) # change back to top program directory # build the local Language hash file from the parts startlangdir = File.join(LangDir,$lang) #get a list of the files and subdirectories on the starting directory only alanghash = Array.new(Dir[startlangdir].entries.sort) #loop through the list, ignore the files and add all new directories found alanghash.each do |x| #if a directory... if(test(?d,x)) # add to the original list of directories @@tmproot = x + "/**" #adds the new ones to the array blanghash = Dir[@@tmproot].entries.sort blanghash.each do |x| if(test(?d,x)) alanghash.push(x) #appends to the end of the array... end end end end alanghash.each do |x| #if it is a file... if(!test(?d,x)) alanghash.delete(x) else #it is a directory... findfiles(x + "/**") end end #writes the contents of doc into the variable languagehashvariable = languagehashvariable + " Message.update(" + $tempdoc + ' :rwdtinker => "Rwdtinker" ) ' $tempdoc = " " Dir.chdir($progdir) # change back to top program directory temp = eval( languagehashvariable ) tempguistorage = $rwd_gui_tinker # if gui load fails restore old begin # error trap # build the actual GUI from the gui parts $tempdoc = " " #get a list of the files and subdirectories on the starting directory only a = Array.new(Dir[GuiDir].entries.sort) #loop through the list, ignore the files and add all new directories found a.each do |x| #if a directory... if(test(?d,x)) #use this new dir find to add to the original list of directories @@root = x + "/**" #adds the new ones to the array b = Dir[@@root].entries.sort b.each do |x| if(test(?d,x)) a.push(x) #appends to the end of the array... end end end end a.each do |x| #if it is a file... if(!test(?d,x)) a.delete(x) else #it is a directory... loadguifile(x + "/**") end end $rwd_gui_tinker = $tempdoc rescue $rwd_gui_tinker = tempguistorage # restore old gui $rwdtinkerlog.error "error in initiateapplets - gui building" debuginitiate += 1 end begin # error trap # now load in the code files $tempdoc = "" tempcodeinstallline = "" @fileName = "installed/" + nametextlocal + ".inf" $rwdtinkerlog.debug "initateapplets: loading file: #{@fileName}" tmpfilearray = File.readlines(@fileName) tmpfilearray.each do |line| tempcodeinstallline = line.chomp if tempcodeinstallline.include?('code/') findfiles(tempcodeinstallline + "/**") tempcoderesult = eval( $tempdoc ) # read the program code and evaluate end end rescue $rwdtinkerlog.error "error in initiateapplets - code building" debuginitiate += 1 end setuphelpaboutoptions # update the help about list setuptinkerdocuments # update the document pull down list runhelpwindow # update the help menu showjumplinkoptions # update the application link menu runrwdtinkerbackwindow # back to applet window # resultend = tempcodeinstallline .index("\n",resultstart) tempresult = @fileName return " applet loading successful " + tempresult if debuginitiate > 0 return " initiateapplet .." else return " initiateapplet success" end end