From e2b68fc2245dc8eddcabf4f9f081002aa914dc39 Mon Sep 17 00:00:00 2001
From: Lars Kanis <kanis@comcard.de>
Date: Thu, 13 Mar 2014 17:02:26 +0100
Subject: [PATCH] Simplify icon loading in examples.
---
examples/glviewer.rb | 12 +++---------
examples/groupbox.rb | 12 +++---------
2 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/examples/glviewer.rb b/examples/glviewer.rb
index f1ab317..7ee88bc 100755
--- a/examples/glviewer.rb
+++ b/examples/glviewer.rb
@@ -152,15 +152,9 @@ class GLViewWindow < FXMainWindow
# Load the named PNG icon from a file
def loadIcon(filename)
- begin
- filename = File.join("icons", filename) + ".png"
- 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}.png", __FILE__)
+ File.open(filename, "rb") do |f|
+ FXPNGIcon.new(getApp(), f.read)
end
end
diff --git a/examples/groupbox.rb b/examples/groupbox.rb
index 7f80a18..26a99b7 100755
--- a/examples/groupbox.rb
+++ b/examples/groupbox.rb
@@ -8,15 +8,9 @@ class GroupWindow < FXMainWindow
# Convenience function to load & construct an icon
def getIcon(filename)
- begin
- filename = File.join("icons", filename)
- icon = nil
- File.open(filename, "rb") { |f|
- icon = FXPNGIcon.new(getApp(), f.read)
- }
- 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
--
GitLab