Class: Libnotify::API
Overview
API for Libnotify
Class Attribute Summary collapse
-
.icon_dirs ⇒ Object
List of globs to icons.
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#append ⇒ Object
Returns the value of attribute append.
-
#body ⇒ Object
Returns the value of attribute body.
-
#icon_path ⇒ Object
Returns the value of attribute icon_path.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#transient ⇒ Object
Returns the value of attribute transient.
-
#urgency ⇒ Object
Returns the value of attribute urgency.
Class Method Summary collapse
-
.show(options = {}, &block) ⇒ Object
Creates and shows a notification.
Instance Method Summary collapse
-
#close ⇒ Object
Close a previously shown notification.
-
#initialize(options = {}, &block) ⇒ API
constructor
Creates a notification object.
-
#show ⇒ Object
Shows an existing notification.
-
#show! ⇒ Object
Shows a new notification.
-
#update(options = {}, &block) ⇒ Object
Updates a previously shown notification or creates a new one.
Methods included from FFI
attach_functions!, included, load_libs, #method_missing
Constructor Details
#initialize(options = {}, &block) ⇒ API
Creates a notification object.
27 28 29 30 |
# File 'lib/libnotify/api.rb', line 27 def initialize(={}, &block) set_defaults (, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Libnotify::FFI
Class Attribute Details
.icon_dirs ⇒ Object
List of globs to icons
16 17 18 |
# File 'lib/libnotify/api.rb', line 16 def icon_dirs @icon_dirs end |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
12 13 14 |
# File 'lib/libnotify/api.rb', line 12 def app_name @app_name end |
#append ⇒ Object
Returns the value of attribute append.
12 13 14 |
# File 'lib/libnotify/api.rb', line 12 def append @append end |
#body ⇒ Object
Returns the value of attribute body.
12 13 14 |
# File 'lib/libnotify/api.rb', line 12 def body @body end |
#icon_path ⇒ Object
Returns the value of attribute icon_path.
11 12 13 |
# File 'lib/libnotify/api.rb', line 11 def icon_path @icon_path end |
#summary ⇒ Object
Returns the value of attribute summary.
12 13 14 |
# File 'lib/libnotify/api.rb', line 12 def summary @summary end |
#timeout ⇒ Object
Returns the value of attribute timeout.
11 12 13 |
# File 'lib/libnotify/api.rb', line 11 def timeout @timeout end |
#transient ⇒ Object
Returns the value of attribute transient.
12 13 14 |
# File 'lib/libnotify/api.rb', line 12 def transient @transient end |
#urgency ⇒ Object
Returns the value of attribute urgency.
12 13 14 |
# File 'lib/libnotify/api.rb', line 12 def urgency @urgency end |
Class Method Details
.show(options = {}, &block) ⇒ Object
Creates and shows a notification. It’s a shortcut for Libnotify.new(options).show!.
124 125 126 |
# File 'lib/libnotify/api.rb', line 124 def self.show(={}, &block) new(, &block).show! end |
Instance Method Details
#close ⇒ Object
Close a previously shown notification.
80 81 82 |
# File 'lib/libnotify/api.rb', line 80 def close notify_notification_close(@notification, nil) if @notification end |
#show ⇒ Object
Shows an existing notification.
59 60 61 62 63 64 65 66 |
# File 'lib/libnotify/api.rb', line 59 def show notify_notification_set_urgency(@notification, urgency) notify_notification_set_timeout(@notification, timeout || -1) set_hints notify_notification_show(@notification, nil) ensure clear_hints end |
#show! ⇒ Object
Shows a new notification.
51 52 53 54 55 56 |
# File 'lib/libnotify/api.rb', line 51 def show! notify_init(app_name) or raise "notify_init failed" raw_ptr = notify_notification_new(summary, body, icon_path, nil) @notification = ::FFI::AutoPointer.new(raw_ptr, method(:g_object_unref)) show end |
#update(options = {}, &block) ⇒ Object
Updates a previously shown notification or creates a new one.
69 70 71 72 73 74 75 76 77 |
# File 'lib/libnotify/api.rb', line 69 def update(={}, &block) (, &block) if @notification notify_notification_update(@notification, summary, body, icon_path, nil) show else show! end end |