Module: Notifu

Defined in:
lib/rb-notifu.rb,
lib/rb-notifu/version.rb

Constant Summary collapse

ERROR_ARGUMENT =

There was an error in one the argument or some required argument was missing.

1
ERROR_NOT_SUPPORTED =

IUserNotification class object or interface is not supported on this version of Windows.

5
ERROR_UNEXPECTED =

There was some unexpected error.

256
ERRORS =
[ERROR_ARGUMENT, ERROR_NOT_SUPPORTED, ERROR_UNEXPECTED]
SUCCESS_REGISTRY =

Registry was succesfully edited. Only returned when /e is used with no other argument.

0
SUCCESS_TIMEOUT =

The balloon timed out waiting. The user didn’t click the close button or the balloon itself.

2
SUCCESS_CLICK =

The user clicked the balloon.

3
SUCCESS_CLOSE =

The user closed the balloon using the X in the top right corner.

4
SUCCESS_RIGHT =

The user clicked with the right mouse button on the icon, in the system notification area (Vista and later)

6
SUCCESS_LEFT =

The user clicked with the left mouse button on the icon, in the system notification area (Vista and later)

7
SUCCESS_NEW_INSTANCE =

A new instance of Notifu dismissed a running instace

8
VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.escape(value) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/rb-notifu.rb', line 95

def self.escape(value)
  if value
    return '"' + value.to_s.gsub('"','\"') + '"'
  else
    return ''
  end
end

.show(options = {}, &block) ⇒ Object

Params:

:type     The type of message to display values are:
            info   The message is an informational message
            warn   The message is an warning message
            error  The message is an error message
:time     The number of seconds to display (omit or 0 for infinit)
:title    The title (or prompt) of the ballon
:message  The message text
:icon     Specify an icon to use ("parent" uses the icon of the parent process)
:baloon   Enable ballon tips in the registry (for this user only)
:nosound  Do not play a sound when the tooltip is displayed
:noquiet  Show the tooltip even if the user is in the quiet period that follows his very first login (Windows 7 and up)
:xp       Use IUserNotification interface event when IUserNotification2 is available


75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rb-notifu.rb', line 75

def self.show(options = {}, &block)
  flags = ""
  @option_default.each do |key, value|
    flag = options.key?(key) ? options[key] : value
    if key == :time
      flag = (flag * 1000).to_i
    end
    if flag
      flags += "/" + @option_to_flag[key] + " "
      if flag != true
        flags += self.escape(flag) + " "
      end
    end
  end
  Thread.new{
    system "#{@executable} #{flags}"
    block.call($?.exitstatus)
  }
end