lib/libnotify.rb in libnotify-0.2.0 vs lib/libnotify.rb in libnotify-0.3.0

- old
+ new

@@ -18,11 +18,11 @@ # notify.timeout = 1.5 # 1.5 (s), 1000 (ms), "2", nil, false # notify.urgency = :critical # :low, :normal, :critical # notify.icon_path = "/usr/share/icons/gnome/scalable/emblems/emblem-default.svg" # end # n.show! - # + # # @example Mixed syntax # Libnotify.new(options) do |n| # n.timeout = 1.5 # overrides :timeout in options # n.show! # end @@ -75,18 +75,20 @@ attach_function :notify_uninit, [], :void attach_function :notify_notification_new, [:string, :string, :string, :pointer], :pointer attach_function :notify_notification_set_urgency, [:pointer, :urgency], :void attach_function :notify_notification_set_timeout, [:pointer, :long], :void + attach_function :notify_notification_set_hint_string, [:pointer, :string, :string], :void + attach_function :notify_notification_clear_hints, [:pointer], :void attach_function :notify_notification_show, [:pointer, :pointer], :bool end class API include FFI attr_reader :timeout - attr_accessor :summary, :body, :icon_path, :urgency + attr_accessor :summary, :body, :icon_path, :urgency, :append # Creates a notification object. # # @see Libnotify.new def initialize(options={}, &block) @@ -97,10 +99,11 @@ def set_defaults self.summary = self.body = ' ' self.urgency = :normal self.timeout = nil + self.append = true end private :set_defaults # Shows a notification. # @@ -108,10 +111,16 @@ def show! notify_init(self.class.to_s) or raise "notify_init failed" notify = notify_notification_new(summary, body, icon_path, nil) notify_notification_set_urgency(notify, urgency) notify_notification_set_timeout(notify, timeout || -1) + if append + notify_notification_set_hint_string(notify, "x-canonical-append", "") + notify_notification_set_hint_string(notify, "append", "") + end notify_notification_show(notify, nil) + ensure + notify_notification_clear_hints(notify) if append end # @todo Simplify timeout= def timeout=(timeout) @timeout = case timeout