Changeset 741 for lang/ruby/Amalgam
- Timestamp:
- 10/26/07 23:40:50 (6 years ago)
- Location:
- lang/ruby/Amalgam
- Files:
-
- 3 modified
-
AppController.rb (modified) (10 diffs)
-
English.lproj/MainMenu.nib/info.nib (modified) (1 diff)
-
English.lproj/MainMenu.nib/objects.nib (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/Amalgam/AppController.rb
r739 r741 34 34 35 35 def comboBox_objectValueForItemAtIndex(sender, index) 36 (@candidate || [])[index] 36 (@candidate || [])[index].first 37 37 end 38 38 39 39 def numberOfItemsInComboBox(sender) 40 log "Reloaded data"40 # log "Reloaded data" 41 41 (@candidate || []).length 42 42 end … … 44 44 def comboBox_completedString(sender, string) 45 45 #log "completedString->#{string}" 46 (@candidate || []).grep(/^#{string}/i).first 47 rescue 46 string = Regexp.escape(string) 47 (@candidate || []).transpose[0].grep(/^#{string}/i).first 48 rescue Exception 48 49 "" 49 50 end … … 51 52 def comboBox_indexOfItemWithStringValue(sender, string) 52 53 @candidate ||= [] 53 @candidate.index(string) || NSNotFound 54 @candidate.each_with_index do |(r,l),i| 55 if r === string 56 return i 57 end 58 end 59 NSNotFound 54 60 end 55 61 … … 67 73 def windowDidBecomeMain(anot) 68 74 @window.makeFirstResponder(@combo) 69 @combo.reloadData 70 @combo.stringValue = "" 71 @now = nil 75 @combo.delegate = self 76 #@combo.reloadData 77 @editting = false 78 #@combo.stringValue = "" 72 79 end 73 80 … … 101 108 @combo.numberOfVisibleItems = 20 102 109 103 NSApp.register_hotkey("Command+ Control+O") do110 NSApp.register_hotkey("Command+`") do 104 111 log "HotKey hitted" 105 112 NSApp.activateIgnoringOtherApps(true) … … 109 116 end 110 117 111 Thread.start do 112 search_applications() 113 end.join 118 build_candidates() 119 120 NSApp.activateIgnoringOtherApps(true) 121 @window.makeFirstResponder(@combo) 114 122 end 115 123 … … 125 133 case key 126 134 when "\r" 127 case @combo.stringValue 128 when "exit", "Exit" 129 if OSX.NSRunAlertPanel("Sure?", "exit ok?", "Exit", "Cancel", nil) == NSAlertDefaultReturn 130 NSApp.terminate(nil) 131 end 132 when /^d (.+)/i 133 code = Regexp.last_match[1] 134 result = "" 135 begin 136 result = eval(code, binding).inspect 137 rescue Exception => e 138 result = e.inspect 139 end 140 OSX.NSRunAlertPanel("Debug", result, "Ok", "", nil) == NSAlertDefaultReturn 141 when /^\s*$/ 142 # nothing 143 else 135 unless @combo.stringValue.strip.empty? 144 136 index = comboBox_indexOfItemWithStringValue(@combo, @combo.stringValue) 145 137 unless index == NSNotFound 146 @commands[index].call 138 pro = @candidate[index][1] 139 if pro.arity == 0 140 pro.call 141 else 142 pro.call(@candidate[index][0], @combo.stringValue.to_s) 143 end 147 144 end 148 145 end … … 167 164 end 168 165 169 def search_applications 166 def relunch(*) 167 log "relunch" 168 path = NSBundle.mainBundle.executablePath.to_s 169 fork do 170 sleep 2 171 system(path) 172 end 173 NSApp.terminate(nil) 174 end 175 176 def build_candidates 177 @candidate = [] 178 170 179 @applications = [Pathname.new("Finder")] 171 180 search_applications_recursive("/Applications") 172 181 search_applications_recursive("/Developer/Applications") 173 174 175 candidate = [] 176 candidate = @applications.map {|f| 182 183 @candidate = @applications.map {|f| 177 184 [f.basename(".app").to_s, proc { 178 185 system("open", "-a", f) … … 180 187 } 181 188 182 candidate.concat Pathname.glob("/System/Library/PreferencePanes/*.prefPane").map {|f|189 @candidate.concat Pathname.glob("/System/Library/PreferencePanes/*.prefPane").map {|f| 183 190 [f.basename.to_s, proc { 184 191 system("open", f) … … 186 193 } 187 194 188 @candidate, @commands = candidate.transpose 189 190 log @candidate 195 @candidate << [/.d (.+)/, proc {|s,m| 196 code = m[s, 1] 197 result = "" 198 begin 199 result = eval(code, binding).inspect 200 rescue Exception => e 201 result = e.inspect 202 end 203 log result 204 OSX.NSRunAlertPanel("Debug", result, "Ok", "", nil) 205 }] 206 207 @candidate << ["Exit", proc { 208 if OSX.NSRunAlertPanel("Sure?", "exit ok?", "Exit", "Cancel", nil) == NSAlertDefaultReturn 209 NSApp.terminate(nil) 210 end 211 }] 212 191 213 log "Search done" 192 214 #set_status "Search done" -
lang/ruby/Amalgam/English.lproj/MainMenu.nib/info.nib
r735 r741 8 8 <dict> 9 9 <key>196</key> 10 <string>538 496 20463 0 0 1280 778 </string>10 <string>538 496 358 63 0 0 1280 778 </string> 11 11 </dict> 12 12 <key>IBFramework Version</key>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)