#*********************************************************************** #* 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 require 'lib/rwdtinker/rwdlangdir' tempdoc = RwdtinkerTools.findlanguagefiles(LangDir,"en") #writes the contents of doc into the languagehashvariable languagehashvariable = tempdoc # END of en Lang building $tempdoc = " " Dir.chdir($progdir) # change back to top program directory # build the local Language hash file from the parts tempdoc = RwdtinkerTools.findlanguagefiles(LangDir,$lang) #writes the contents of doc into the variable languagehashvariable = languagehashvariable + 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 = " " require 'lib/rwdtinker/rwdguidir' tempdoc = RwdtinkerTools.findguifiles(GuiDir) $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 def findfiles(d) a = Array.new(Dir[d].entries.sort) #loop through and get the files names a.each do |x| #adjust the filters to the files you want to see... if(!test(?d,x)) # only rwd files if x =~ /rb|rwd|txt/ fileA=File.open("#{x}","r") #opens the file thats in fileName as read only $tempdoc+=fileA.read #reads the file into the doc string fileA.close end end end end