1# Copyright (c) 2006-2008, The RubyCocoa Project.
2# Copyright (c) 2001-2006, FUJIMOTO Hisakuni.
3# All Rights Reserved.
4#
5# RubyCocoa is free software, covered under either the Ruby's license or the 
6# LGPL. See the COPYRIGHT file for more information.
7
8require 'osx/cocoa'
9
10module OSX
11
12  APP_DIR = File.expand_path(File.dirname($0)).
13    split(File::SEPARATOR)[0..-3].join(File::SEPARATOR)
14
15  RSRC_DIR = File.join(APP_DIR, 'Contents', 'Resources')
16  $:.unshift(RSRC_DIR) unless $:.include?(RSRC_DIR)
17
18  APP_BUNDLE = NSBundle.bundleWithPath(APP_DIR)
19
20  def APP_BUNDLE.loadNibNamed_owner (name, owner)
21    ret = self.loadNibFile(name, :externalNameTable, {'NSOwner' => owner}, :withZone, nil)
22    return (ret != 0)
23  end
24
25  class NSBundle
26
27    def NSBundle.loadNibNamed_owner (name, owner)
28      return OSX::APP_BUNDLE.loadNibNamed_owner(name, owner)
29    end
30    
31    def NSBundle.mainBundle
32      return OSX::APP_BUNDLE
33    end
34
35  end
36
37end
38