real-growl 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +46 -0
- data/Rakefile +17 -0
- data/ext/extconf.rb +22 -0
- data/ext/real_growl_api.c +84 -0
- data/ext/real_growl_api.h +5 -0
- data/ext/ruby_delegate.h +12 -0
- data/ext/ruby_delegate.m +14 -0
- data/lib/real_growl.rb +22 -0
- metadata +61 -0
data/README.rdoc
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
real-growl
|
2
|
+
|
3
|
+
== DESCRIPTION:
|
4
|
+
|
5
|
+
A Growl notification library that uses native c bindings to interact with GrowlApplicationBridge rather than Growl's network API.
|
6
|
+
|
7
|
+
== SYNOPSIS:
|
8
|
+
|
9
|
+
>> require 'real_growl'
|
10
|
+
=> true
|
11
|
+
>> rg("Check out", ["Real", "Growl"])
|
12
|
+
=> nil
|
13
|
+
|
14
|
+
>> Kernel.rg_sticky = false
|
15
|
+
=> false
|
16
|
+
>> Kernel.rg_priority = 3
|
17
|
+
=> 3
|
18
|
+
|
19
|
+
>> my_own_application = RealGrowl::Application.new("AppName")
|
20
|
+
=> #<RealGrowl::Application:0x1018eb6b8>
|
21
|
+
>> my_own_application.notify("Title", "Desc", 0, true)
|
22
|
+
|
23
|
+
>> RealGrowl.installed?
|
24
|
+
=> true
|
25
|
+
>> RealGrowl.running?
|
26
|
+
=> true
|
27
|
+
|
28
|
+
== TODO:
|
29
|
+
* Add executable script
|
30
|
+
* Allow for custom icons
|
31
|
+
* Enable growl callbacks
|
32
|
+
|
33
|
+
== REQUIREMENTS:
|
34
|
+
|
35
|
+
* MacOS X 10.5 > ??
|
36
|
+
* Growl Framework - http://growl.info/downloads_developers.php
|
37
|
+
|
38
|
+
== INSTALL:
|
39
|
+
|
40
|
+
Download and install Growl.framework into either ~/Library/Frameworks or /Library/Frameworks
|
41
|
+
gem install real-growl
|
42
|
+
|
43
|
+
== INSTALLATION HINTS:
|
44
|
+
|
45
|
+
Make sure that the Growl.framework is either 32bit or the 64bit depending on the version of MacOS X
|
46
|
+
installed and the kind of machine it is installed on.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |s|
|
4
|
+
s.name = "real-growl"
|
5
|
+
s.summary = "Growl notification library that uses native c bindings."
|
6
|
+
s.description = "A Growl notification library that uses native c bindings to interact with GrowlApplicationBridge rather than Growl's network API."
|
7
|
+
s.email = "dewind@atomicobject.com"
|
8
|
+
s.authors = ["Justin DeWind"]
|
9
|
+
s.files = FileList["README.rdoc", "lib/**/*.rb", "Rakefile", "ext/**/*.h", "ext/**/*.c", "ext/**/*.m"]
|
10
|
+
s.extensions = ["ext/extconf.rb"]
|
11
|
+
s.homepage = "http://github.com/dewind/real-growl"
|
12
|
+
end
|
13
|
+
|
14
|
+
Jeweler::GemcutterTasks.new
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
17
|
+
end
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Loads mkmf which is used to make makefiles for Ruby extensions
|
2
|
+
require 'mkmf'
|
3
|
+
|
4
|
+
|
5
|
+
$CFLAGS << ' ' + "-ObjC"
|
6
|
+
$LDFLAGS << ' ' + "-lobjc -framework Foundation -framework Growl"
|
7
|
+
$objs = %w(ruby_delegate.o real_growl_api.o)
|
8
|
+
|
9
|
+
def growl_framework_paths
|
10
|
+
["/Library/Frameworks/Growl.framework", "#{ENV['HOME']}/Library/Growl.framework"]
|
11
|
+
end
|
12
|
+
|
13
|
+
if(growl_framework_paths.any? {|x| File.exists?(x)})
|
14
|
+
message("checking for framework Growl... yes\n")
|
15
|
+
if(have_library("objc"))
|
16
|
+
extension_name = 'real_growl_api'
|
17
|
+
dir_config(extension_name)
|
18
|
+
create_makefile(extension_name)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
message("checking for framework Growl... no\n")
|
22
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#include "real_growl_api.h"
|
2
|
+
|
3
|
+
VALUE rb_mRealGrowl;
|
4
|
+
VALUE rb_cRealGrowlApplication;
|
5
|
+
|
6
|
+
VALUE
|
7
|
+
classMethod_installed(VALUE self) {
|
8
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
9
|
+
BOOL installed = [GrowlApplicationBridge isGrowlInstalled];
|
10
|
+
[pool release];
|
11
|
+
|
12
|
+
if(installed) {
|
13
|
+
return Qtrue;
|
14
|
+
} else {
|
15
|
+
return Qfalse;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
VALUE
|
20
|
+
classMethod_running(VALUE self) {
|
21
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
22
|
+
BOOL running = [GrowlApplicationBridge isGrowlRunning];
|
23
|
+
[pool release];
|
24
|
+
|
25
|
+
if(running) {
|
26
|
+
return Qtrue;
|
27
|
+
} else {
|
28
|
+
return Qfalse;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
VALUE
|
33
|
+
method_notify(VALUE self, VALUE title, VALUE description, VALUE priority, VALUE sticky) {
|
34
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
35
|
+
|
36
|
+
BOOL nsSticky = (sticky == Qtrue) ? YES : NO;
|
37
|
+
NSString *nsTitle = [NSString stringWithCString:STR2CSTR(title) encoding: NSASCIIStringEncoding];
|
38
|
+
NSString *nsDescription = [NSString stringWithCString:STR2CSTR(description) encoding: NSASCIIStringEncoding];
|
39
|
+
[GrowlApplicationBridge notifyWithTitle: nsTitle description: nsDescription notificationName: REAL_GROWL_NOTIFICATION iconData: nil priority: NUM2INT(priority) isSticky:nsSticky clickContext:nil];
|
40
|
+
|
41
|
+
[pool release];
|
42
|
+
|
43
|
+
return Qnil;
|
44
|
+
}
|
45
|
+
|
46
|
+
VALUE
|
47
|
+
method_init(VALUE self, VALUE applicationName) {
|
48
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
49
|
+
id delegate = NULL;
|
50
|
+
|
51
|
+
Data_Get_Struct(self, RubyDelegate, delegate);
|
52
|
+
|
53
|
+
NSString *nsAppName = [NSString stringWithCString:STR2CSTR(applicationName) encoding: NSASCIIStringEncoding];
|
54
|
+
[delegate setApplicationName: nsAppName];
|
55
|
+
[GrowlApplicationBridge setGrowlDelegate: delegate];
|
56
|
+
|
57
|
+
[pool release];
|
58
|
+
return self;
|
59
|
+
}
|
60
|
+
|
61
|
+
static void
|
62
|
+
free_delegate(id delegate) {
|
63
|
+
[delegate release];
|
64
|
+
}
|
65
|
+
|
66
|
+
static VALUE
|
67
|
+
alloc_delegate(VALUE klass) {
|
68
|
+
return Data_Wrap_Struct(klass, 0, free_delegate, [[RubyDelegate alloc] init]);
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
void
|
73
|
+
Init_real_growl_api() {
|
74
|
+
|
75
|
+
rb_mRealGrowl = rb_define_module("RealGrowl");
|
76
|
+
rb_define_singleton_method(rb_mRealGrowl, "installed?", classMethod_installed, 0);
|
77
|
+
rb_define_singleton_method(rb_mRealGrowl, "running?", classMethod_running, 0);
|
78
|
+
|
79
|
+
rb_cRealGrowlApplication = rb_define_class_under(rb_mRealGrowl, "Application", rb_cObject);
|
80
|
+
rb_define_alloc_func(rb_cRealGrowlApplication, alloc_delegate);
|
81
|
+
rb_define_method(rb_cRealGrowlApplication, "initialize", method_init, 1);
|
82
|
+
rb_define_method(rb_cRealGrowlApplication, "notify", method_notify, 4);
|
83
|
+
}
|
84
|
+
|
data/ext/ruby_delegate.h
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#include <Foundation/Foundation.h>
|
2
|
+
#include <Growl/Growl.h>
|
3
|
+
#define REAL_GROWL_NOTIFICATION XSTR("RealGrowlNotification")
|
4
|
+
|
5
|
+
@interface RubyDelegate : NSObject<GrowlApplicationBridgeDelegate>
|
6
|
+
{
|
7
|
+
NSString *applicationName;
|
8
|
+
}
|
9
|
+
|
10
|
+
-(NSDictionary *) registrationDictionaryForGrowl;
|
11
|
+
@property(nonatomic, assign) NSString *applicationName;
|
12
|
+
@end
|
data/ext/ruby_delegate.m
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#include "ruby_delegate.h"
|
2
|
+
|
3
|
+
@implementation RubyDelegate
|
4
|
+
@synthesize applicationName;
|
5
|
+
|
6
|
+
-(NSDictionary *)registrationDictionaryForGrowl {
|
7
|
+
if(applicationName == nil) {
|
8
|
+
applicationName = @"RealGrowl";
|
9
|
+
}
|
10
|
+
NSArray *notifications = [NSArray arrayWithObject:REAL_GROWL_NOTIFICATION];
|
11
|
+
return [NSDictionary dictionaryWithObjectsAndKeys: [self applicationName], GROWL_APP_ID, [self applicationName], GROWL_APP_NAME, notifications, GROWL_NOTIFICATIONS_ALL, nil];
|
12
|
+
}
|
13
|
+
|
14
|
+
@end
|
data/lib/real_growl.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'real_growl_api'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
module Kernel
|
5
|
+
class<<self
|
6
|
+
attr_accessor :rg_sticky, :rg_priority
|
7
|
+
end
|
8
|
+
|
9
|
+
def rg(*args)
|
10
|
+
Kernel.rg_priority ||= 0
|
11
|
+
Kernel.rg_sticky = true if Kernel.rg_sticky.nil?
|
12
|
+
|
13
|
+
@__growl_app ||= RealGrowl::Application.new("RealGrowl")
|
14
|
+
|
15
|
+
notifications = args.map { |x| x.pretty_inspect }
|
16
|
+
notifications.each do |x|
|
17
|
+
@__growl_app.notify('rg', x, Kernel.rg_priority, Kernel.rg_sticky)
|
18
|
+
end
|
19
|
+
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: real-growl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin DeWind
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-13 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A Growl notification library that uses native c bindings to interact with GrowlApplicationBridge rather than Growl's network API.
|
17
|
+
email: dewind@atomicobject.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
files:
|
25
|
+
- README.rdoc
|
26
|
+
- Rakefile
|
27
|
+
- ext/real_growl_api.c
|
28
|
+
- ext/real_growl_api.h
|
29
|
+
- ext/ruby_delegate.h
|
30
|
+
- ext/ruby_delegate.m
|
31
|
+
- lib/real_growl.rb
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://github.com/dewind/real-growl
|
34
|
+
licenses: []
|
35
|
+
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options:
|
38
|
+
- --charset=UTF-8
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.3.5
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: Growl notification library that uses native c bindings.
|
60
|
+
test_files: []
|
61
|
+
|