Skip to content

Commit

Permalink
Hack on a reflecticle menu bar app in macruby
Browse files Browse the repository at this point in the history
  • Loading branch information
vanstee committed Mar 27, 2012
1 parent 5bf2eba commit 44f1d0d
Show file tree
Hide file tree
Showing 10 changed files with 763 additions and 3,446 deletions.
12 changes: 10 additions & 2 deletions Reflecticle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@
103A10E815215EF200C7E225 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 103A10E615215EF200C7E225 /* MainMenu.xib */; };
103A10EB15215EF200C7E225 /* rb_main.rb in Resources */ = {isa = PBXBuildFile; fileRef = 103A10EA15215EF200C7E225 /* rb_main.rb */; };
103A10ED15215EF200C7E225 /* AppDelegate.rb in Resources */ = {isa = PBXBuildFile; fileRef = 103A10EC15215EF200C7E225 /* AppDelegate.rb */; };
103A1101152173C200C7E225 /* NSMenuWithTextField.rb in Resources */ = {isa = PBXBuildFile; fileRef = 103A1100152173C200C7E225 /* NSMenuWithTextField.rb */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
103A10D315215EF200C7E225 /* Reflecticle.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Reflecticle.app; sourceTree = BUILT_PRODUCTS_DIR; };
103A10D715215EF200C7E225 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
103A10D915215EF200C7E225 /* MacRuby.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MacRuby.framework; path = Library/Frameworks/MacRuby.framework; sourceTree = DEVELOPER_DIR; };
103A10DE15215EF200C7E225 /* Reflecticle-Info.plist */ = {isa = PBXFileReference; path = "Reflecticle-Info.plist"; sourceTree = "<group>"; };
103A10DE15215EF200C7E225 /* Reflecticle-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Reflecticle-Info.plist"; sourceTree = "<group>"; };
103A10E015215EF200C7E225 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
103A10E215215EF200C7E225 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
103A10E415215EF200C7E225 /* Reflecticle-Prefix.pch */ = {isa = PBXFileReference; path = "Reflecticle-Prefix.pch"; sourceTree = "<group>"; };
103A10E415215EF200C7E225 /* Reflecticle-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Reflecticle-Prefix.pch"; sourceTree = "<group>"; };
103A10E715215EF200C7E225 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
103A10EA15215EF200C7E225 /* rb_main.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = rb_main.rb; sourceTree = "<group>"; };
103A10EC15215EF200C7E225 /* AppDelegate.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = AppDelegate.rb; sourceTree = "<group>"; };
103A10FA1521675000C7E225 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
103A10FC152167D000C7E225 /* PreferencePanes.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PreferencePanes.framework; path = System/Library/Frameworks/PreferencePanes.framework; sourceTree = SDKROOT; };
103A1100152173C200C7E225 /* NSMenuWithTextField.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = NSMenuWithTextField.rb; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -45,6 +49,8 @@
103A10C815215EF200C7E225 = {
isa = PBXGroup;
children = (
103A10FC152167D000C7E225 /* PreferencePanes.framework */,
103A10FA1521675000C7E225 /* CoreFoundation.framework */,
103A10DC15215EF200C7E225 /* Reflecticle */,
103A10D615215EF200C7E225 /* Frameworks */,
103A10D415215EF200C7E225 /* Products */,
Expand Down Expand Up @@ -75,6 +81,7 @@
103A10E515215EF200C7E225 /* Resources */,
103A10E915215EF200C7E225 /* Other Sources */,
103A10DD15215EF200C7E225 /* Supporting Files */,
103A1100152173C200C7E225 /* NSMenuWithTextField.rb */,
);
path = Reflecticle;
sourceTree = "<group>";
Expand Down Expand Up @@ -177,6 +184,7 @@
103A10E815215EF200C7E225 /* MainMenu.xib in Resources */,
103A10EB15215EF200C7E225 /* rb_main.rb in Resources */,
103A10ED15215EF200C7E225 /* AppDelegate.rb in Resources */,
103A1101152173C200C7E225 /* NSMenuWithTextField.rb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "103A10DB15215EF200C7E225"
BuildableName = "Deployment"
BlueprintName = "Deployment"
ReferencedContainer = "container:Reflecticle.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "103A10D215215EF200C7E225"
BuildableName = "Reflecticle.app"
BlueprintName = "Reflecticle"
ReferencedContainer = "container:Reflecticle.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "103A10D215215EF200C7E225"
BuildableName = "Reflecticle.app"
BlueprintName = "Reflecticle"
ReferencedContainer = "container:Reflecticle.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "103A10D215215EF200C7E225"
BuildableName = "Reflecticle.app"
BlueprintName = "Reflecticle"
ReferencedContainer = "container:Reflecticle.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "103A10D215215EF200C7E225"
BuildableName = "Reflecticle.app"
BlueprintName = "Reflecticle"
ReferencedContainer = "container:Reflecticle.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Deployment.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>Reflecticle.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>103A10D215215EF200C7E225</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>103A10DB15215EF200C7E225</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
52 changes: 40 additions & 12 deletions Reflecticle/AppDelegate.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
#
# AppDelegate.rb
# Reflecticle
#
# Created by Patrick Van Stee on 3/26/12.
# Copyright 2012 __MyCompanyName__. All rights reserved.
#

class AppDelegate
attr_accessor :window
def applicationDidFinishLaunching(a_notification)
# Insert code here to initialize your application
attr_accessor :window, :menu, :api_key, :projects, :project, :post, :menu_item_view

def awakeFromNib
@api_key.stringValue = NSUserDefaults.standardUserDefaults["api_key"]

@status_bar = NSStatusBar.systemStatusBar.statusItemWithLength(NSVariableStatusItemLength)
@status_bar.setMenu(@menu)
@status_bar.setTitle("Reflecticle")
@status_bar.setHighlightMode(true)

@menu_item = NSMenuItem.new
@menu_item.setView(@menu_item_view)
@menu.insertItem(@menu_item, atIndex: 0)

api_key = NSUserDefaults.standardUserDefaults["api_key"]
unless api_key.empty?
uri = URI.parse("http://www.reflecticle.com/api/projects.json?api_key=#{api_key}")
@projects ||= Hash[JSON.parse(Net::HTTP.get_response(uri).body).map { |p| [p["id"], p["name"]] }]
@project.removeAllItems
@project.addItemsWithTitles(@projects.values)
end
end
end

def populate(sender)
p @project.itemArray
end

def post(sender)
api_key = NSUserDefaults.standardUserDefaults["api_key"]
if !api_key.empty? && !@post.stringValue.empty?
uri = URI.parse("http://www.reflecticle.com/api/activities/create.json?api_key=#{api_key}&project_id=1&description=#{@post.stringValue}")
p Net::HTTP.get_response(uri)
@post.stringValue = ""
end
end

def save(sender)
NSUserDefaults.standardUserDefaults["api_key"] = @api_key.stringValue
NSUserDefaults.standardUserDefaults.synchronize
@window.performClose(true)
end
end
6 changes: 6 additions & 0 deletions Reflecticle/NSMenuWithTextField.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class NSMenuItemWithTextField < NSMenuItem
def setView(view)
text_field = NSTextField.alloc.init
view.addSubview(text_field)
end
end
Loading

0 comments on commit 44f1d0d

Please sign in to comment.