Class: System::Growl

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/system_control/growl.rb

Constant Summary

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"

Instance Method Summary (collapse)

Instance Method Details

- (Object) notify(notification, title, description, options = {})

Sends a Growl notification.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/system_control/growl.rb', line 42

def notify(notification, title, description, options = {})
  dict = {
    :ApplicationName => @application_name,
    #:ApplicationPID => pid,
    :NotificationName => notification.to_s,
    :NotificationTitle => title.to_s,
    :NotificationDescription => description.to_s,
    :NotificationPriority => options[:priority] || 0,
    :NotificationIcon => @application_icon.TIFFRepresentation,
  }
  dict[:NotificationSticky] = 1 if options[:sticky]

  @center.postNotificationName(:GrowlNotification, object:nil, userInfo:dict, deliverImmediately:false)
end

- (Object) regist(app, notifications, icon = nil)

Regists a application metadata for Growl notification.



21
22
23
24
25
26
27
28
# File 'lib/system_control/growl.rb', line 21

def regist(app, notifications, icon = nil)
  @application_name = app.to_s
  @application_icon = icon || NSApplication.sharedApplication.applicationIconImage
  @notifications = notifications.map!{|x| x.to_s}
  @default_notifications = notifications
  @center = NSDistributedNotificationCenter.defaultCenter
  send_registration!
end