diff -ur rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/ruby.lib.rb --- rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-12-05 13:58:40.000000000 +0100 +++ rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-12-17 12:40:15.000000000 +0100 @@ -792,6 +792,7 @@ set_trace_func lambda { |event, file, line, id, binding, classname| $stderr.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname } + if block_given? res = yield diff -ur rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-12-05 13:58:40.000000000 +0100 +++ rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-12-17 12:40:15.000000000 +0100 @@ -40,11 +40,9 @@ Format = "\n<!-- %-10s %-10s -->\t" unless rcfile.nil? - $stderr.puts "Reading #{rcfile} ..." + puts "Reading #{rcfile} ..." Hash.file(rcfile).each do |k, v| - #$stderr.puts "Setting #{k} to \"#{v}\" ..." - ENV[k] = v unless ENV.include?(k) end end @@ -276,7 +274,23 @@ when "list" then res << "<ul #{align}>" when "item" then res << "<li #{align}>" when "empty" then res << "<p><br>" - when "image" then res << "<img src=´#{@args["src"]}´ alt=´#{@args["alt"]}´>" + when "image" + width = "width=´#{@args["width"]}" if @args.include?("width") + height = "height=´#{@args["height"]}´" if @args.include?("height") + + res << "<img src=´#{@args["src"]}´ alt=´#{@args["alt"]}´ #{width} #{height}>" + when "progressbar" + width = 200 + + res << "<table>" + res << " <tr>" + res << " <td colspan=´2´><img src=´rwd_pixel.gif´ height=´1´ width=´#{width+5}´></td>" + res << " </tr>" + res << " <tr>" + res << " <td bgcolor=´#DDDDDD´><img src=´rwd_pixel.gif´ height=´10´ width=´#{(width*@args["value"].to_f).to_i}´></td>" + res << " <td bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´10´ width=´#{(width*(1.0-@args["value"].to_f)).to_i}´></td>" + res << " </tr>" + res << "</table>" when "br" then res << "<br>" when "hr" then res << "<hr>" when "b" then res << "<b>" @@ -344,6 +358,10 @@ res << "<input type=´submit´ value=´Back´ onclick=´document.bodyform.rwd_action.value=\"rwd_back\";´>" firstaction << "rwd_back" if firstaction.empty? oneormorefields << "true" + when "cancel" + res << "<input type=´submit´ value=´Cancel´ onclick=´document.bodyform.rwd_action.value=\"rwd_cancel\";´>" + firstaction << "rwd_cancel" if firstaction.empty? + oneormorefields << "true" when "help" res << "<input type=´submit´ value=´Help´ onclick=´document.bodyform.rwd_action.value=\"rwd_help\";´>" firstaction << "rwd_help" if firstaction.empty? @@ -356,9 +374,13 @@ res << "<input type=´submit´ value=´Close´ onclick=´window.close();´>" firstaction << "rwd_quit" if firstaction.empty? oneormorefields << "true" + when "main" + res << "<input type=´submit´ value=´Main´ onclick=´document.bodyform.rwd_action.value=\"rwd_main\";´>" + firstaction << "rwd_main" if firstaction.empty? + oneormorefields << "true" when "reset" res << "<input type=´reset´ value=´Reset´>" - firstaction << "rwd_quit" if firstaction.empty? + firstaction << "rwd_quit" if firstaction.empty? # ??? oneormorefields << "true" when "closewindow" #res << "<script type=´text/javascript´>\n" # ??? @@ -467,6 +489,7 @@ when "item" then res << "</li>" when "empty" then res << "</p>" when "image" then res << "" + when "progressbar" then res << "" when "br" then res << "" when "hr" then res << "" when "b" then res << "</b>" @@ -488,9 +511,11 @@ when "option" then res << "</option>" when "button" then res << "" when "back" then res << "" + when "cancel" then res << "" when "help" then res << "" when "quit" then res << "" when "close" then res << "" + when "main" then res << "" when "reset" then res << "" when "closewindow" then res << "" when "tabs" @@ -606,7 +631,7 @@ @helprwd = (@@helpwindows[rwd][window] or "").dup end - def render(pda, vars=Hash.new, switches=Hash.new, help=false, tab="") + def render(pda, action=nil, vars=Hash.new, switches=Hash.new, help=false, tab="") varshtml = Hash.new varsstring = Hash.new oneormorefields = "" @@ -661,6 +686,8 @@ focus = "document.bodyform.elements[0].focus();" end + firstaction = action if windowobject.args.keys.include?("refresh") unless action.nil? + html.gsub!(/\$RWD_FIRSTACTION\$/ , firstaction) html.gsub!(/\$RWD_FOCUS\$/ , focus) @@ -670,13 +697,34 @@ class RWDMessage < RWDWindow def initialize(msg) - super("<window title=´RWD Message´ nobackbuttons noclosebutton><vertical><p>#{msg}</p><back/></vertical></window>") + super("<window title=´RWD Message´ nobackbuttons noclosebutton><p>#{msg}</p><back/></window>") end end class RWDError < RWDWindow def initialize(msg) - super("<window title=´RWD Error´ nobackbuttons noclosebutton><vertical><p><b>Error:</b> #{msg}</p><back/></vertical></window>") + super("<window title=´RWD Error´ nobackbuttons noclosebutton><p><b>Error:</b> #{msg}</p><back/></window>") + end +end + +class RWDProgressBar < RWDWindow + def initialize(refresh, progress) + s = "" + s << "<window title=´RWD Progress´ nobackbuttons noclosebutton refresh=´#{refresh}´>" + if progress.length == 1 + progress.each do |caption, value| + s << "<p>#{caption}</p><progressbar value=´#{value}´/><p>#{(100*value).to_i}%%</p>" + end + else + s << "<table>" + progress.each do |caption, value| + s << "<row><p align=´left´>#{caption}</p><progressbar value=´#{value}´/><p align=´right´>#{(100*value).to_i}%%</p></row>" + end + s << "</table>" + end + s << "<cancel/>" + s << "</window>" + super(s) end end @@ -729,7 +777,7 @@ help = false back = false tab = "" - @rwd_msg = nil + @rwd_msgtype = nil @rwd_download = nil @rwd_download_file = nil @@ -751,10 +799,12 @@ # Stack handling for rwd_action, rwd_window and rwd_tab. - @rwd_action = vars["rwd_action"] + @rwd_action = vars["rwd_action"] if vars.include?("rwd_action") @rwd_action, @rwd_args = @rwd_action.split(/\//, 2) unless @rwd_action.nil? @rwd_action, rest = @rwd_action.split(/\?/) unless @rwd_action.nil? + @rwd_refresh_action = (@rwd_action or @rwd_refresh_action or "main") + unless rest.nil? rest.each do |s| k, v = s.split(/=/, 2) @@ -762,6 +812,12 @@ end end + if @rwd_action == "rwd_cancel" + @rwd_progress_thread.kill unless @rwd_progress_thread.nil? + @rwd_progress_thread = nil + @rwd_action = "rwd_back" + end + if @rwd_action =~ /^rwd_tab_/ @rwd_tab = @rwd_action.sub(/^rwd_tab_/, "") @rwd_history[-1][3] = @rwd_tab @@ -820,12 +876,12 @@ # History stuff - @rwd_history = [["main", nil, "main", nil]] if @rwd_action == "main" - @rwd_history = [["main", nil, "main", nil]] if @rwd_history.empty? + @rwd_history = [["main", [], "main", ""]] if @rwd_action == "main" + @rwd_history = [["main", [], "main", ""]] if @rwd_history.empty? a = [@rwd_action, @rwd_args, @rwd_window, @rwd_tab] - @rwd_history.push a if (@rwd_history[-1] != a or not @rwd_msg.nil?) + @rwd_history.push a if (@rwd_history[-1] != a or not @rwd_msgtype.nil?) end end @@ -842,6 +898,7 @@ puts "Pre: #{key} -> #{value.inspect}" if $rwd_debug end + # Answer to browser. if done @@ -853,14 +910,18 @@ download << @rwd_download downloadfile << @rwd_download_file else - if not @rwd_msg.nil? + if not @rwd_msgtype.nil? res << RWDMessage.new(@rwd_msg).render(pda) if @rwd_msgtype == "message" res << RWDError.new(@rwd_msg).render(pda) if @rwd_msgtype == "error" else - puts "Window: #{@rwd_window}" if $rwd_debug - puts "Tab: #{@rwd_tab}" if $rwd_debug + if not @rwd_progress_thread.nil? + res << RWDProgressBar.new(@rwd_progress_refresh, @rwd_progress_progress).render(pda, @rwd_refresh_action) + else + puts "Window: #{@rwd_window}" if $rwd_debug + puts "Tab: #{@rwd_tab}" if $rwd_debug - res << RWDWindow.new(@rwd_xml, @rwd_window).render(pda, vars, @rwd_switches, help, @rwd_tab) + res << RWDWindow.new(@rwd_xml, @rwd_window).render(pda, @rwd_refresh_action, vars, @rwd_switches, help, @rwd_tab) + end end end end @@ -872,16 +933,48 @@ @rwd_history[-1][2] == @rwd_window end - def message(msg) + def message(msg, &block) @rwd_msg = msg @rwd_msgtype = "message" end - def error(msg) + def error(msg, &block) @rwd_msg = msg @rwd_msgtype = "error" end + def progressbar(refresh, *progress) + @rwd_progress_refresh = (refresh or 1) + @rwd_progress_progress = [] + + while not progress.empty? + s = (progress.shift or "") + if s.kind_of?(Array) + caption, value = s + value = (value or 0.0).to_f + else + caption = s + value = (progress.shift or 0.0).to_f + end + + @rwd_progress_progress << [caption, value] + end + + if @rwd_progress_thread.nil? + @rwd_progress_progress.each do |a| + a[1] = 0.0 + end + + @rwd_progress_thread = + Thread.new do + yield + end + Thread.pass + end + + @rwd_progress_thread = nil unless @rwd_progress_thread.alive? + end + def download(data, filename="") @rwd_download = data @rwd_download_file = filename @@ -996,12 +1089,12 @@ #if ENV["RWDBROWSER"].downcase =~ /iexplore/ # ??? #@ie = IE.new("http://localhost:#{port}/") #else - browser = ENV["RWDBROWSER"] + browser = ENV["RWDBROWSER"].dup url = "http://localhost:%s/" % [port] if cygwin? browser.gsub!(/\\/, "/") - browser.gsub!(/ /, "\ ") + browser.gsub!(/ /, "\\ ") end re = /[$%]1\b/ @@ -1010,7 +1103,7 @@ command.gsub!(/%port%/, port.to_s) - system(command) + system(command) or puts "Starting of the browser failed, or the browser terminated abnormally.\nCommand => #{command}" #end puts "The browser has terminated." @@ -1187,8 +1280,9 @@ <head> <title>%TITLE%</title> - <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> --> + <meta http-equiv=´Content-Type´ content=´text/html; charset=%CHARSET%´> <meta http-equiv=´Content-Style-Type´ content=´text/css´> + <meta http-equiv=´Refresh´ content=´%REFRESH%, javascript:document.bodyform.submit();´> <link rel=´shortcut icon´ href=´%LOGO%´> @@ -1498,8 +1592,9 @@ <head> <title>%TITLE%</title> - <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> --> + <meta http-equiv=´Content-Type´ content=´text/html; charset=%CHARSET%´> <meta http-equiv=´Content-Style-Type´ content=´text/css´> + <meta http-equiv=´Refresh´ content=´%REFRESH%, javascript:document.bodyform.submit();´> <link rel=´shortcut icon´ href=´%LOGO%´> @@ -1663,7 +1758,8 @@ <head> <title>%TITLE%</title> - <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> --> + <meta http-equiv=´Content-Type´ content=´text/html; charset=%CHARSET%´> + <meta http-equiv=´Refresh´ content=´%REFRESH%, javascript:document.bodyform.submit();´> <link rel=´shortcut icon´ href=´%LOGO%´> diff -ur rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/tree.lib.rb rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/tree.lib.rb --- rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-12-05 13:58:40.000000000 +0100 +++ rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-12-17 12:40:15.000000000 +0100 @@ -65,7 +65,7 @@ attr_writer :parent attr_reader :children attr_writer :children - attr_writer :closed + attr_reader :closed attr_writer :closed attr_reader :text attr_writer :text