code/superant.com.rwdtinkerbackwindow/initiateapplets.rb in bigtinker-0.96 vs code/superant.com.rwdtinkerbackwindow/initiateapplets.rb in bigtinker-0.97
- old
+ new
@@ -28,164 +28,73 @@
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
+ require 'lib/rwdtinker/rwdlangdir'
+
+ tempdoc = RwdtinkerTools.findlanguagefiles(LangDir,"en")
-
#writes the contents of doc into the languagehashvariable
-
- languagehashvariable = languagehashvariable + $tempdoc + ' :rwdtinker => "Rwdtinker" ) ;'
+ 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
- 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
+ tempdoc = RwdtinkerTools.findlanguagefiles(LangDir,$lang)
+ #writes the contents of doc into the variable
- #writes the contents of doc into the variable
+ languagehashvariable = languagehashvariable + tempdoc
- 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
-
+ 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
@@ -238,8 +147,24 @@
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