Permalink
Browse files

Switch to a menubar app design

  • Loading branch information...
1 parent da46c70 commit d2be7988cbbc21eaea49d57f0cc481d96aa09340 @wfarr committed Jul 9, 2010
Showing with 22 additions and 42 deletions.
  1. +22 −16 lib/application.rb
  2. +0 −26 lib/menu.rb
View
@@ -3,17 +3,34 @@
# Replace the following code with your own hotcocoa code
class Xtt
-
include HotCocoa
def start
- application :name => "Xtt" do |app|
- app.delegate = self
+ @app = application :name => "Xtt", :delegate => self
+ @status = status_item
+ set_status_menu
+ @app.run
+ end
+
+ def set_status_menu
+ @menu = status_menu
+ @status.view = nil
+ @status.menu = @menu
+ @status.title = "Xtt Item"
+ @status.setHighlightMode true
+ end
+
+ def status_menu
+ menu :delegate => self do |status|
+ status.item "New Status", :on_action => proc { new_window }
+ status.separator
+ status.item "Preferences", :on_action => proc { preferences }
+ status.separator
+ status.item "Quit", :on_action => proc { @app.terminate self }
end
end
- # file/new
- def on_new(menu)
+ def new_window
window :size => [400,150], :center => true, :title => "New Status", :view => :layout,
:style => [:titled, :closable, :textured] do |win|
win.contentView.margin = 0
@@ -43,17 +60,6 @@ def on_new(menu)
end
end
end
-
- # xtt/preferences
- def on_preferences(menu)
- window :frame => [100, 100, 100, 100], :title => "Preferences" do |win|
- win << label(:text => "Prefs window!")
- end
- end
-
- # This is commented out, so the minimize menu item is disabled
- def on_minimize(menu)
- end
end
Xtt.new.start
View
@@ -1,26 +0,0 @@
-module HotCocoa
- def application_menu
- menu do |main|
- main.submenu :apple do |apple|
- apple.item :about, :title => "About #{NSApp.name}"
- apple.separator
- apple.item :preferences, :key => ","
- apple.separator
- apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q"
- end
- main.submenu :file do |file|
- file.item :new, :title => "New Status", :key => "n"
- end
- main.submenu :edit do |edit|
- edit.item :undo, :key => "z", :modifiers => [:command], :action => "undo:"
- edit.item :redo, :key => "z", :modifiers => [:command, :shift], :action => "redo:"
- edit.separator
- edit.item :cut, :key => "x", :action => "cut:"
- edit.item :copy, :key => "c", :action => "copy:"
- edit.item :paste, :key => "v", :action => "paste:"
- edit.separator
- edit.item :select_all, :key => "a", :action => "selectAll:"
- end
- end
- end
-end

0 comments on commit d2be798

Please sign in to comment.