1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
#  PreferencesController.rb
#  PreferencesExample
#
#  Created by Matthew McCray on 1/18/08.
#  Copyright (c) 2008 Elucidata (www.elucidata.net). All rights reserved.
#

require 'osx/cocoa'

class PreferencesController < OSX::NSWindowController
  include OSX
  
  # This is the target action for the toolbar items
  ib_action :selectPrefPanel do |sender|
    # We'll do stuff here later...
  end
  
  def init
    self if self.initWithWindowNibName_owner('Preferences', self)
  end
  
  # Delegate method that returns the itemIdentifiers for the selectable items 
  # (in our case, all of 'em)
  def toolbarSelectableItemIdentifiers(toolbar)
    @toolbaritemidents ||= begin
      window.toolbar.items.map {|item| item.itemIdentifier }
    end
  end
  
  # Select the first toolbar item when the window loads
  def awakeFromNib
    window.toolbar.selectedItemIdentifier = window.toolbar.items[0].itemIdentifier
  end

end