Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Add notification close API #14

Merged
merged 1 commit into from over 2 years ago

2 participants

Nuisance of Cats Peter Suschlik
Nuisance of Cats

Extended update example to show close in rdoc.

Peter Suschlik splattael closed this January 03, 2012
Peter Suschlik splattael reopened this January 03, 2012
Peter Suschlik splattael merged commit 79769c6 into from January 03, 2012
Peter Suschlik splattael closed this January 03, 2012
Peter Suschlik
Owner

Thank you for the pull request :)

Could you please test the latest master branch?

Nuisance of Cats

Sure, I'm at work now (boo) so I'll have to do it after 6pm

Peter Suschlik
Owner

No problem and again thanks for your time and effort! I appreciate it :)

Peter Suschlik
Owner

I've just release 0.7.1 which includes API#close :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jan 02, 2012
Nuisance of Cats Libnotify#close to close notification before timeout. 5c44680
This page is out of date. Refresh to see the latest.
4  README.rdoc
Source Rendered
@@ -37,13 +37,15 @@ http://github.com/splattael/libnotify/raw/master/libnotify.png
37 37
   Libnotify.show(:icon_path => "emblem-default.png")
38 38
   Libnotify.show(:icon_path => :"emblem-default")
39 39
 
40  
-  # Update pre-existing notification
  40
+  # Update pre-existing notification then close it
41 41
   n = Libnotify.new(:summary => "hello", :body => "world")
42 42
   n.update # identical to show! if not shown before
43 43
   Kernel.sleep 1
44 44
   n.update(:body => "my love") do |notify|
45 45
     notify.summary = "goodbye"
46 46
   end
  47
+  Kernel.sleep 1
  48
+  n.close
47 49
 
48 50
 
49 51
 == Installation
4  lib/libnotify.rb
@@ -23,13 +23,15 @@ module Libnotify
23 23
   # @example Hash syntax
24 24
   #   Libnotify.show(:body => "hello", :summary => "world", :timeout => 2.5)
25 25
   #
26  
-  # @example Update pre-existing notification
  26
+  # @example Update pre-existing notification then close it
27 27
   #   n = Libnotify.new(:summary => "hello", :body => "world")
28 28
   #   n.update # identical to show! if not shown before
29 29
   #   Kernel.sleep 1
30 30
   #   n.update(:body => "my love") do |notify|
31 31
   #     notify.summary = "goodbye"
32 32
   #   end
  33
+  #   Kernel.sleep 1
  34
+  #   n.close
33 35
   #
34 36
   # @example Mixed syntax
35 37
   #   Libnotify.new(options) do |n|
5  lib/libnotify/api.rb
@@ -89,6 +89,11 @@ def update(options={}, &block)
89 89
       end
90 90
     end
91 91
 
  92
+    # Close a previously shown notification.
  93
+    def close
  94
+      notify_notification_close(@notification, nil) if @notification
  95
+    end
  96
+
92 97
     # @todo Simplify timeout=
93 98
     def timeout=(timeout)
94 99
       @timeout = case timeout
1  lib/libnotify/ffi.rb
@@ -29,6 +29,7 @@ def self.attach_functions!
29 29
       attach_function :notify_notification_set_hint_uint32, [:pointer, :string, :int],              :void
30 30
       attach_function :notify_notification_clear_hints,     [:pointer],                             :void
31 31
       attach_function :notify_notification_show,            [:pointer, :pointer],                   :bool
  32
+      attach_function :notify_notification_close,           [:pointer, :pointer],                   :bool
32 33
     end
33 34
 
34 35
     def lookup_urgency(urgency)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.