Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Libnotify#close to close notification before timeout.

  • Loading branch information...
commit 5c446808aca7ccab7efafb3ca4c0b6b58d41eac4 1 parent 74de1db
@ohjames ohjames authored
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)
Please sign in to comment.
Something went wrong with that request. Please try again.