Browse files

Merge pull request #14 from nuisanceofcats/master

Close notification via API#close
  • Loading branch information...
2 parents 74de1db + 5c44680 commit 79769c6c72e6d07ff0761e67c0c7195110899a5c @splattael committed Jan 3, 2012
Showing with 12 additions and 2 deletions.
  1. +3 −1 README.rdoc
  2. +3 −1 lib/libnotify.rb
  3. +5 −0 lib/libnotify/api.rb
  4. +1 −0 lib/libnotify/ffi.rb
View
4 README.rdoc
@@ -37,13 +37,15 @@ http://github.com/splattael/libnotify/raw/master/libnotify.png
Libnotify.show(:icon_path => "emblem-default.png")
Libnotify.show(:icon_path => :"emblem-default")
- # Update pre-existing notification
+ # Update pre-existing notification then close it
n = Libnotify.new(:summary => "hello", :body => "world")
n.update # identical to show! if not shown before
Kernel.sleep 1
n.update(:body => "my love") do |notify|
notify.summary = "goodbye"
end
+ Kernel.sleep 1
+ n.close
== Installation
View
4 lib/libnotify.rb
@@ -23,13 +23,15 @@ module Libnotify
# @example Hash syntax
# Libnotify.show(:body => "hello", :summary => "world", :timeout => 2.5)
#
- # @example Update pre-existing notification
+ # @example Update pre-existing notification then close it
# n = Libnotify.new(:summary => "hello", :body => "world")
# n.update # identical to show! if not shown before
# Kernel.sleep 1
# n.update(:body => "my love") do |notify|
# notify.summary = "goodbye"
# end
+ # Kernel.sleep 1
+ # n.close
#
# @example Mixed syntax
# Libnotify.new(options) do |n|
View
5 lib/libnotify/api.rb
@@ -89,6 +89,11 @@ def update(options={}, &block)
end
end
+ # Close a previously shown notification.
+ def close
+ notify_notification_close(@notification, nil) if @notification
+ end
+
# @todo Simplify timeout=
def timeout=(timeout)
@timeout = case timeout
View
1 lib/libnotify/ffi.rb
@@ -29,6 +29,7 @@ def self.attach_functions!
attach_function :notify_notification_set_hint_uint32, [:pointer, :string, :int], :void
attach_function :notify_notification_clear_hints, [:pointer], :void
attach_function :notify_notification_show, [:pointer, :pointer], :bool
+ attach_function :notify_notification_close, [:pointer, :pointer], :bool
end
def lookup_urgency(urgency)

0 comments on commit 79769c6

Please sign in to comment.