diff --git a/examples/WhatAQuietStiff.rb b/examples/WhatAQuietStiff.rb index 8d70f770eb6f83e5f3143ba8c146efcc310d3217..d87da665c059d808676f121638f4a149f0429a90 100755 --- a/examples/WhatAQuietStiff.rb +++ b/examples/WhatAQuietStiff.rb @@ -38,11 +38,11 @@ class WhatAQuietWindow < FXMainWindow super(app, "What a Quiet Stiff", :opts => DECOR_ALL, :width => 850, :height => 600, :padLeft => 0, :padRight => 0) # Icons for list items - File.open("icons/bluebullet14x14.gif", "rb") do |f| + File.open(File.expand_path("../icons/bluebullet14x14.gif", __FILE__), "rb") do |f| bytes = f.read @itemIcon = FXGIFIcon.new(getApp(), bytes) end - File.open("icons/transpbullet14x14.gif", "rb") do |f| + File.open(File.expand_path("../icons/transpbullet14x14.gif", __FILE__), "rb") do |f| bytes = f.read @transpIcon = FXGIFIcon.new(getApp(), bytes) end diff --git a/examples/babelfish.rb b/examples/babelfish.rb index e9d41a5d975a419f19eee03e9cacdb5c28210757..85d14f99b91a3e6883fba3adc2dcc294129c4fe4 100755 --- a/examples/babelfish.rb +++ b/examples/babelfish.rb @@ -33,7 +33,7 @@ class Babelfish < FXMainWindow FXLabel.new(controlsFrame, " to:") @toCombo = FXComboBox.new(controlsFrame, 15, :opts => COMBOBOX_STATIC|FRAME_SUNKEN|FRAME_THICK) @toCombo.numVisible = 6 - Tranexp::Codes.constants.each do |lang| + Tranexp::Codes.constants.map(&:to_s).each do |lang| @fromCombo.appendItem(lang) @toCombo.appendItem(lang) end diff --git a/examples/browser.rb b/examples/browser.rb index b3da40a0c672e090b2cbdd24174462c898c99796..6d62be55d83b58972f0bab501c94689ab2d3b64b 100755 --- a/examples/browser.rb +++ b/examples/browser.rb @@ -41,7 +41,7 @@ class ClassTree # Get an hash containing class names for Fox classes = {} - @mFox.constants.each do |name| + @mFox.constants.map(&:to_s).each do |name| c = @mFox.const_get(name) if c.kind_of? Class parentclass = c.superclass.name.sub("Fox::", "") diff --git a/examples/button.rb b/examples/button.rb index 0da7e8815d4a17e95423c4bfb998a019ed29d49d..a1de7315966f5d6f9791361bcf2fb4c23dbd509b 100755 --- a/examples/button.rb +++ b/examples/button.rb @@ -134,15 +134,9 @@ class ButtonWindow < FXMainWindow # Load the named icon from a file def loadIcon(filename) - begin - filename = File.join("icons", filename) - icon = nil - File.open(filename, "rb") do |f| - icon = FXPNGIcon.new(getApp(), f.read) - end - icon - rescue - raise RuntimeError, "Couldn't load icon: #{filename}" + filename = File.expand_path("../icons/#{filename}", __FILE__) + File.open(filename, "rb") do |f| + FXPNGIcon.new(getApp(), f.read) end end diff --git a/examples/canvasdemo.rb b/examples/canvasdemo.rb index 06b05e82a42b00e0f36488f04d91505c6c24f4b5..b13f10a922c62fd7457bc0f53bd06fcdd1f103dc 100755 --- a/examples/canvasdemo.rb +++ b/examples/canvasdemo.rb @@ -1,5 +1,5 @@ require 'fox16' -require '../lib/fox16/canvas' +require 'fox16/canvas' include Fox include Canvas diff --git a/examples/dctest.rb b/examples/dctest.rb index 92376991c43a58da9028e0b58ef9476968df3859..dd0fc76ffc59d3705c7c70863eabb21718b16377 100755 --- a/examples/dctest.rb +++ b/examples/dctest.rb @@ -532,7 +532,7 @@ class DCTestWindow < FXMainWindow FXMenuCommand.new(@filemenu, "&Quit\tCtl-Q", nil, getApp(), FXApp::ID_QUIT) FXMenuTitle.new(menubar, "&File", nil, @filemenu) - @birdImage = FXPNGImage.new(getApp(), File.open("icons/dippy.png", "rb").read) + @birdImage = FXPNGImage.new(getApp(), File.open(File.expand_path("../icons/dippy.png", __FILE__), "rb").read) @bitmap = FXBitmap.new(getApp(), $bitmap_bits, 0, 64, 64) @function = BLT_SRC @@ -674,15 +674,9 @@ class DCTestWindow < FXMainWindow # Load the named icon from a file def loadIcon(filename, clr = FXRGB(192, 192, 192), opts = 0) - begin - filename = File.join("icons", filename) - icon = nil - File.open(filename, "rb") { |f| - icon = FXPNGIcon.new(getApp(), f.read, clr, opts) - } - icon - rescue - raise RuntimeError, "Couldn't load icon: #{filename}" + filename = File.expand_path("../icons/#{filename}", __FILE__) + File.open(filename, "rb") do |f| + FXPNGIcon.new(getApp(), f.read) end end end diff --git a/examples/gembrowser.rb b/examples/gembrowser.rb index 77df8b3af6e40786247b0017c63ec92c83022297..b62eb3ff62caab172758c9939de91de80e55dab1 100755 --- a/examples/gembrowser.rb +++ b/examples/gembrowser.rb @@ -37,7 +37,7 @@ class GemBrowser # Return an array of the installed specifications. def cache # Gem.cache - Gem::Cache.from_installed_gems + Gem::SourceIndex.from_installed_gems end end @@ -53,7 +53,7 @@ class GemInfoPanel < FXVerticalFrame self.backColor = FXRGB(255, 255, 255) - File.open(File.join("icons", "gem_big.png"), "rb") do |f| + File.open(File.expand_path("../icons/gem_big.png", __FILE__), "rb") do |f| @bigIcon = FXPNGIcon.new(getApp(), f.read) end @@ -107,10 +107,10 @@ class GemsPanel < FXVerticalFrame # Save a reference to the browser @browser = br - File.open(File.join("icons", "gem_big.png"), "rb") do |f| + File.open(File.expand_path("../icons/gem_big.png", __FILE__), "rb") do |f| @bigIcon = FXPNGIcon.new(getApp(), f.read) end - File.open(File.join("icons", "gem_small.png"), "rb") do |f| + File.open(File.expand_path("../icons/gem_small.png", __FILE__), "rb") do |f| @smallIcon = FXPNGIcon.new(getApp(), f.read) end diff --git a/examples/hello2.rb b/examples/hello2.rb index 9dc0e8edc39c37e7407acbbee913b2da053f4bbd..60b73060e1f4ab53f13bb80214835d4826f156dc 100755 --- a/examples/hello2.rb +++ b/examples/hello2.rb @@ -30,7 +30,7 @@ main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL) # on disk. icon = nil -File.open(File.join("icons", "hello2.png"), "rb") { |f| +File.open(File.expand_path("../icons/hello2.png", __FILE__), "rb") { |f| icon = FXPNGIcon.new(application, f.read) } diff --git a/examples/iconlist.rb b/examples/iconlist.rb index ab262d9338911b0ea7df0f8548ee2d4bbc68b55d..8643d0317df281d80c099bf392bf163b9ce6b54e 100755 --- a/examples/iconlist.rb +++ b/examples/iconlist.rb @@ -6,15 +6,9 @@ class IconListWindow < FXMainWindow # Load the named PNG icon from a file def loadIcon(filename) - begin - filename = File.join("icons", filename) - icon = nil - File.open(filename, "rb") do |f| - icon = FXPNGIcon.new(getApp(), f.read) - end - icon - rescue - raise RuntimeError, "Couldn't load icon: #{filename}" + filename = File.expand_path("../icons/#{filename}", __FILE__) + File.open(filename, "rb") do |f| + FXPNGIcon.new(getApp(), f.read) end end diff --git a/examples/imageviewer.rb b/examples/imageviewer.rb index 2d3f508f45cade027a3e979a7391481aca8bfe7d..85ece9b3c63102410b55fe3d2a6c632cf0ca177a 100755 --- a/examples/imageviewer.rb +++ b/examples/imageviewer.rb @@ -240,15 +240,9 @@ class ImageWindow < FXMainWindow # Convenience function to construct a PNG icon def getIcon(filename) - begin - filename = File.join("icons", filename) - icon = nil - File.open(filename, "rb") do |f| - icon = FXPNGIcon.new(getApp(), f.read) - end - icon - rescue - raise RuntimeError, "Couldn't load icon: #{filename}" + filename = File.expand_path("../icons/#{filename}", __FILE__) + File.open(filename, "rb") do |f| + FXPNGIcon.new(getApp(), f.read) end end diff --git a/examples/mditest.rb b/examples/mditest.rb index e7441763e1040ebca437975a3a8ea2a66573d511..718046695de9e488662d0d50f76e5965e1adcdc8 100755 --- a/examples/mditest.rb +++ b/examples/mditest.rb @@ -64,7 +64,7 @@ class MDITestWindow < FXMainWindow # Icon for MDI Child @mdiicon = nil - File.open(File.join("icons", "penguin.png"), "rb") do |f| + File.open(File.expand_path("../icons/penguin.png", __FILE__), "rb") do |f| @mdiicon = FXPNGIcon.new(getApp(), f.read) end diff --git a/examples/shutter.rb b/examples/shutter.rb index 8386c7f329f2fcbf6a11b93765c152688a4b0e07..136f93e071d64b096a0b26b8f456ce6917c618cd 100755 --- a/examples/shutter.rb +++ b/examples/shutter.rb @@ -28,15 +28,9 @@ class ShutterWindow < FXMainWindow # and constructs and returns a ICO icon object. def loadIcon(filename) - begin - filename = File.join("icons", filename) - icon = nil - File.open(filename, "rb") do |f| - icon = FXICOIcon.new(getApp(), f.read) - end - icon - rescue - raise RuntimeError, "Couldn't load icon: #{filename}" + filename = File.expand_path("../icons/#{filename}", __FILE__) + File.open(filename, "rb") do |f| + FXPNGIcon.new(getApp(), f.read) end end diff --git a/examples/splitter.rb b/examples/splitter.rb index 9ec6cc5432b5727a33a512df4f70a71a35a40cff..a8de10fbdd81067be4f081b2602900e03441248b 100755 --- a/examples/splitter.rb +++ b/examples/splitter.rb @@ -8,15 +8,9 @@ class SplitterWindow < FXMainWindow # Convenience function to load & construct an icon def makeIcon(filename) - begin - filename = File.join("icons", filename) - icon = nil - File.open(filename, "rb") do |f| - icon = FXPNGIcon.new(getApp(), f.read) - end - icon - rescue - raise RuntimeError, "Couldn't load icon: #{filename}" + filename = File.expand_path("../icons/#{filename}", __FILE__) + File.open(filename, "rb") do |f| + FXPNGIcon.new(getApp(), f.read) end end diff --git a/examples/table.rb b/examples/table.rb index 2d4f0449c976c68f5e016caad2f36220804d177b..0335643ccd750a60190a65ad15314b33e28c77fb 100755 --- a/examples/table.rb +++ b/examples/table.rb @@ -38,7 +38,7 @@ class TableWindow < FXMainWindow # Icon used in some cells penguinicon = nil - File.open(File.join('icons', 'penguin.png'), 'rb') do |f| + File.open(File.expand_path('../icons/penguin.png', __FILE__), 'rb') do |f| penguinicon = FXPNGIcon.new(getApp(), f.read, 0, IMAGE_ALPHAGUESS) end