Permalink
Browse files

removed Growl.rb and implemented growl on the official framework

  • Loading branch information...
1 parent b57a032 commit e71ab4e1f84de52d85d13c2b5ebbdfc5be0d42ad @ashchan committed Jan 23, 2011
@@ -5,7 +5,7 @@
# Created by james on 10/3/08.
# Copyright (c) 2008 ashchan.com. All rights reserved.
#
-
+framework 'Growl'
require 'yaml'
require 'uri'
@@ -195,12 +195,16 @@ def updateAccountMenuItem(notification)
updateMenuBarCount
end
- # delegate not working if :click_context not provided?
- def growlNotifierClicked(sender, context:context)
- openInboxForAccountName(context) if context
+ # Growl delegate
+ def applicationNameForGrowl
+ "Gmail Notifr"
end
-
- def growlNotifierTimedOut(sender, context:context)
+
+ def growlNotificationWasClicked(clickContext)
+ openInboxForAccountName(clickContext) if clickContext
+ end
+
+ def growlNotificationTimedOut(clickContext)
end
def handleMailTo(event, eventReply)
@@ -231,9 +235,7 @@ def registerObservers
end
def registerGrowl
- g = Growl::Notifier.sharedInstance
- g.delegate = self
- g.register('Gmail Notifr', ['new_messages'])
+ GrowlApplicationBridge.setGrowlDelegate(self)
end
def setupCheckers
View
@@ -5,6 +5,7 @@
# Created by James Chen on 8/27/09.
# Copyright (c) 2009 ashchan.com. All rights reserved.
#
+framework 'Growl'
class GNChecker
def init
@@ -154,7 +155,13 @@ def notifyMenuUpdate
end
def notify(title, desc)
- Growl::Notifier.sharedInstance.notify('new_messages', title, desc, :click_context => title)
+ GrowlApplicationBridge.notifyWithTitle(title,
+ description: desc,
+ notificationName: "new_messages",
+ iconData: nil,
+ priority: 0,
+ isSticky: false,
+ clickContext: title)
end
def cleanup
View
@@ -1,164 +0,0 @@
-# Copyright (c) 2007-2008 Satoshi Nakagawa <psychs@limechat.net>, Eloy Duran <e.duran@superalloy.nl>
-# You can redistribute it and/or modify it under the same terms as Ruby.
-# this growl file was extracted from the growlnotifier project(http://rubyforge.org/projects/growlnotifier/, http://github.com/psychs/growlnotifier/tree/master) with the authors' permission
-
-
-module Growl
- class Notifier
- VERSION = '1.0'
-
- GROWL_IS_READY = "Lend Me Some Sugar; I Am Your Neighbor!"
- GROWL_NOTIFICATION_CLICKED = "GrowlClicked!"
- GROWL_NOTIFICATION_TIMED_OUT = "GrowlTimedOut!"
- GROWL_KEY_CLICKED_CONTEXT = "ClickedContext"
-
- PRIORITIES = {
- :emergency => 2,
- :high => 1,
- :normal => 0,
- :moderate => -1,
- :very_low => -2,
- }
-
- class << self
- # Returns the singleton instance of Growl::Notifier with which you register and send your Growl notifications.
- def sharedInstance
- @sharedInstance ||= alloc.init
- end
- end
-
- attr_reader :application_name, :application_icon, :notifications, :default_notifications
- attr_accessor :delegate
-
- # Registers the applications metadata and the notifications, that your application might send, to Growl.
- # The +default_notifications+ are notifications that will be enabled by default, the regular +notifications+ are
- # optional and should be enabled by the user in the Growl system preferences.
- #
- # Register the applications name and the notifications that will be used.
- # * +default_notifications+ defaults to the regular +notifications+.
- # * +application_icon+ defaults to OSX::NSApplication.sharedApplication.applicationIconImage.
- #
- # Growl::Notifier.sharedInstance.register 'FoodApp', ['YourHamburgerIsReady', 'OhSomeoneElseAteIt']
- #
- # Register the applications name, the notifications plus the default notifications that will be used and the icon that's to be used in the Growl notifications.
- #
- # Growl::Notifier.sharedInstance.register 'FoodApp', ['YourHamburgerIsReady', 'OhSomeoneElseAteIt'], ['DefaultNotification], OSX::NSImage.imageNamed('GreasyHamburger')
- def register(application_name, notifications, default_notifications = nil, application_icon = nil)
- @application_name, @application_icon = application_name, (application_icon || NSApplication.sharedApplication.applicationIconImage)
- @notifications, @default_notifications = notifications, (default_notifications || notifications)
- @callbacks = {}
- send_registration!
- end
-
- # Sends a Growl notification.
- #
- # * +notification_name+ : the name of one of the notifcations that your apllication registered with Growl. See register for more info.
- # * +title+ : the title that should be used in the Growl notification.
- # * +description+ : the body of the Grow notification.
- # * +options+ : specifies a few optional options:
- # * <tt>:sticky</tt> : indicates if the Grow notification should "stick" to the screen. Defaults to +false+.
- # * <tt>:priority</tt> : sets the priority level of the Growl notification. Defaults to 0.
- # * <tt>:icon</tt> : specifies the icon to be used in the Growl notification. Defaults to the registered +application_icon+, see register for more info.
- #
- # Simple example:
- #
- # name = 'YourHamburgerIsReady'
- # title = 'Your hamburger is ready for consumption!'
- # description = 'Please pick it up at isle 4.'
- #
- # Growl::Notifier.sharedInstance.notify(name, title, description)
- #
- # Example with optional options:
- #
- # Growl::Notifier.sharedInstance.notify(name, title, description, :sticky => true, :priority => 1, :icon => OSX::NSImage.imageNamed('SuperBigHamburger'))
- #
- # When you pass notify a block, that block will be used as the callback handler if the Growl notification was clicked. Eg:
- #
- # Growl::Notifier.sharedInstance.notify(name, title, description, :sticky => true) do
- # user_clicked_notification_so_do_something!
- # end
- def notify(notification_name, title, description, options = {}, &callback)
- dict = {
- :ApplicationName => @application_name,
- :ApplicationPID => pid,
- :NotificationName => notification_name,
- :NotificationTitle => title,
- :NotificationDescription => description,
- :NotificationPriority => PRIORITIES[options[:priority]] || options[:priority] || 0
- }
- dict[:NotificationIcon] = options[:icon].TIFFRepresentation if options[:icon]
- dict[:NotificationSticky] = 1 if options[:sticky]
-
- context = {}
- context[:user_click_context] = options[:click_context] if options[:click_context]
- if block_given?
- @callbacks[callback.object_id] = callback
- context[:callback_object_id] = callback.object_id.to_s
- end
- dict[:NotificationClickContext] = context unless context.empty?
-
- notification_center.postNotificationName(:GrowlNotification, object:nil, userInfo:dict, deliverImmediately:true)
- end
-
- def onReady(notification)
- send_registration!
- end
-
- def onClicked(notification)
- user_context = nil
- if context = notification.userInfo[GROWL_KEY_CLICKED_CONTEXT]
- user_context = context[:user_click_context]
- if callback_object_id = context[:callback_object_id]
- @callbacks.delete(callback_object_id.to_i).call
- end
- end
-
- @delegate.growlNotifierClicked(self, context:user_context) if @delegate && @delegate.respond_to?("growlNotifierClicked:context:")
- end
-
- def onTimeout(notification)
- user_context = nil
- if context = notification.userInfo[GROWL_KEY_CLICKED_CONTEXT]
- @callbacks.delete(context[:callback_object_id].to_i) if context[:callback_object_id]
- user_context = context[:user_click_context]
- end
-
- @delegate.growlNotifierTimedOut(self, context:user_context) if @delegate && @delegate.respond_to?("growlNotifierTimedOut:context:")
- end
-
- private
-
- def pid
- NSProcessInfo.processInfo.processIdentifier.to_i
- end
-
- def notification_center
- NSDistributedNotificationCenter.defaultCenter
- end
-
- def send_registration!
- add_observer 'onReady:', GROWL_IS_READY, false
- add_observer 'onClicked:', GROWL_NOTIFICATION_CLICKED, true
- add_observer 'onTimeout:', GROWL_NOTIFICATION_TIMED_OUT, true
-
- dict = {
- :ApplicationName => @application_name,
- :ApplicationIcon => application_icon.TIFFRepresentation,
- :AllNotifications => @notifications,
- :DefaultNotifications => @default_notifications
- }
-#FIXME!
- #notification_center.objc_send(
- # :postNotificationName, :GrowlApplicationRegistrationNotification,
- # :object, nil,
- # :userInfo, dict,
- # :deliverImmediately, true
- #)
- end
-
- def add_observer(selector, name, prepend_name_and_pid)
- name = "#{@application_name}-#{pid}-#{name}" if prepend_name_and_pid
- notification_center.addObserver(self, selector:selector, name:name, object:nil)
- end
- end
-end
@@ -43,6 +43,10 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
+ 1A0BBCED12EBFC2700D98CD8 /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A0BBCEC12EBFC2700D98CD8 /* Growl.framework */; };
+ 1A0BBCF512EBFC4300D98CD8 /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A0BBCEC12EBFC2700D98CD8 /* Growl.framework */; };
+ 1A0BBD1812EC041F00D98CD8 /* Growl Registration Ticket.growlRegDict in Resources */ = {isa = PBXBuildFile; fileRef = 1A0BBD1712EC041F00D98CD8 /* Growl Registration Ticket.growlRegDict */; };
+ 1A0BBD1912EC047300D98CD8 /* Growl Registration Ticket.growlRegDict in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A0BBD1712EC041F00D98CD8 /* Growl Registration Ticket.growlRegDict */; };
1A7A954712D2097000F4D5F3 /* keychain.rb in Resources */ = {isa = PBXBuildFile; fileRef = 1A7A952412D2097000F4D5F3 /* keychain.rb */; };
1A7A954812D2097000F4D5F3 /* exception.rb in Resources */ = {isa = PBXBuildFile; fileRef = 1A7A952612D2097000F4D5F3 /* exception.rb */; };
1A7A954912D2097000F4D5F3 /* generic_item.rb in Resources */ = {isa = PBXBuildFile; fileRef = 1A7A952712D2097000F4D5F3 /* generic_item.rb */; };
@@ -75,7 +79,6 @@
1AC3DCCF12748771006832E4 /* GNPreferences.rb in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3DCC612748771006832E4 /* GNPreferences.rb */; };
1AC3DCD012748771006832E4 /* GNSound.rb in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3DCC712748771006832E4 /* GNSound.rb */; };
1AC3DCD112748771006832E4 /* GNStartItems.rb in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3DCC812748771006832E4 /* GNStartItems.rb */; };
- 1AC3DCD212748771006832E4 /* Growl.rb in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3DCC912748771006832E4 /* Growl.rb */; };
1AC3DDE01275CF44006832E4 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC3DDDF1275CF44006832E4 /* Sparkle.framework */; };
1AC3DDEB1275CF8E006832E4 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1AC3DDDF1275CF44006832E4 /* Sparkle.framework */; };
4DE339F70D74FCDD00ADB6EE /* rb_main.rb in Resources */ = {isa = PBXBuildFile; fileRef = 4DE339F60D74FCDD00ADB6EE /* rb_main.rb */; };
@@ -91,6 +94,8 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
+ 1A0BBD1912EC047300D98CD8 /* Growl Registration Ticket.growlRegDict in CopyFiles */,
+ 1A0BBCF512EBFC4300D98CD8 /* Growl.framework in CopyFiles */,
1AC3DDEB1275CF8E006832E4 /* Sparkle.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -102,6 +107,8 @@
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
172754D5107598EA00D0347B /* stub_test.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = stub_test.rb; sourceTree = "<group>"; };
17D55CD81076A1A2008207BD /* run_suite.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = run_suite.rb; sourceTree = "<group>"; };
+ 1A0BBCEC12EBFC2700D98CD8 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Growl.framework; path = Libs/Growl.framework; sourceTree = "<group>"; };
+ 1A0BBD1712EC041F00D98CD8 /* Growl Registration Ticket.growlRegDict */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "Growl Registration Ticket.growlRegDict"; sourceTree = "<group>"; };
1A7A952412D2097000F4D5F3 /* keychain.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = keychain.rb; sourceTree = "<group>"; };
1A7A952612D2097000F4D5F3 /* exception.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = exception.rb; sourceTree = "<group>"; };
1A7A952712D2097000F4D5F3 /* generic_item.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = generic_item.rb; sourceTree = "<group>"; };
@@ -152,7 +159,6 @@
1AC3DCC612748771006832E4 /* GNPreferences.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; name = GNPreferences.rb; path = Classes/GNPreferences.rb; sourceTree = "<group>"; };
1AC3DCC712748771006832E4 /* GNSound.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; name = GNSound.rb; path = Classes/GNSound.rb; sourceTree = "<group>"; };
1AC3DCC812748771006832E4 /* GNStartItems.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; name = GNStartItems.rb; path = Classes/GNStartItems.rb; sourceTree = "<group>"; };
- 1AC3DCC912748771006832E4 /* Growl.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; name = Growl.rb; path = Classes/Growl.rb; sourceTree = "<group>"; };
1AC3DDDF1275CF44006832E4 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = Libs/Sparkle.framework; sourceTree = "<group>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
@@ -171,6 +177,7 @@
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
4DE3BE140D8651D900ECA448 /* MacRuby.framework in Frameworks */,
1AC3DDE01275CF44006832E4 /* Sparkle.framework in Frameworks */,
+ 1A0BBCED12EBFC2700D98CD8 /* Growl.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -192,6 +199,7 @@
4DE3BE130D8651D900ECA448 /* MacRuby.framework */,
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
1AC3DDDF1275CF44006832E4 /* Sparkle.framework */,
+ 1A0BBCEC12EBFC2700D98CD8 /* Growl.framework */,
);
name = "Linked Frameworks";
sourceTree = "<group>";
@@ -274,7 +282,6 @@
1AC3DCC612748771006832E4 /* GNPreferences.rb */,
1AC3DCC712748771006832E4 /* GNSound.rb */,
1AC3DCC812748771006832E4 /* GNStartItems.rb */,
- 1AC3DCC912748771006832E4 /* Growl.rb */,
);
name = Models;
sourceTree = "<group>";
@@ -321,6 +328,7 @@
1AC3DC8A12748643006832E4 /* mail_a.tiff */,
1AC3DC8B12748643006832E4 /* mail.tiff */,
8D1107310486CEB800E47090 /* Info.plist */,
+ 1A0BBD1712EC041F00D98CD8 /* Growl Registration Ticket.growlRegDict */,
);
name = Resources;
sourceTree = "<group>";
@@ -422,12 +430,12 @@
1AC3DCCF12748771006832E4 /* GNPreferences.rb in Resources */,
1AC3DCD012748771006832E4 /* GNSound.rb in Resources */,
1AC3DCD112748771006832E4 /* GNStartItems.rb in Resources */,
- 1AC3DCD212748771006832E4 /* Growl.rb in Resources */,
1A7A954712D2097000F4D5F3 /* keychain.rb in Resources */,
1A7A954812D2097000F4D5F3 /* exception.rb in Resources */,
1A7A954912D2097000F4D5F3 /* generic_item.rb in Resources */,
1A7A954A12D2097000F4D5F3 /* internet_item.rb in Resources */,
1A7A954B12D2097000F4D5F3 /* README.md in Resources */,
+ 1A0BBD1812EC041F00D98CD8 /* Growl Registration Ticket.growlRegDict in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+<key>TicketVersion</key>
+<integer>1</integer>
+<key>AllNotifications</key>
+<array>
+<string>new_messages</string>
+</array>
+<key>DefaultNotifications</key>
+<array>
+<string>new_messages</string>
+</array>
+</dict>
+</plist>
Binary file not shown.
@@ -0,0 +1,6 @@
+#include "GrowlDefines.h"
+
+#ifdef __OBJC__
+# include "GrowlApplicationBridge.h"
+#endif
+#include "GrowlApplicationBridge-Carbon.h"
Oops, something went wrong.

0 comments on commit e71ab4e

Please sign in to comment.