nserver 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +7 -0
- data/bin/nclient +11 -3
- data/lib/nserver.rb +35 -2
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 1.1.4 / 2007-11-12
|
2
|
+
|
3
|
+
* Add a "Message History" dialog, available by activating the NServer tray
|
4
|
+
icon (left-click is default)
|
5
|
+
* This obviously means we now keep track of messages.
|
6
|
+
* Update nclient to accept title parameter, and to pass in priority properly
|
7
|
+
|
1
8
|
== 1.1.3 / 2007-11-10
|
2
9
|
|
3
10
|
* Minor updates
|
data/bin/nclient
CHANGED
@@ -6,12 +6,14 @@ require 'getoptlong'
|
|
6
6
|
|
7
7
|
opts = GetoptLong.new(
|
8
8
|
[ '--priority', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
9
|
-
[ '--host', GetoptLong::REQUIRED_ARGUMENT ]
|
9
|
+
[ '--host', GetoptLong::REQUIRED_ARGUMENT ],
|
10
|
+
[ '--title', GetoptLong::REQUIRED_ARGUMENT ]
|
10
11
|
)
|
11
12
|
|
12
13
|
priority = :normal
|
13
14
|
host_ip = '127.0.0.1'
|
14
15
|
msg = nil
|
16
|
+
title = nil
|
15
17
|
|
16
18
|
opts.each do |opt,arg|
|
17
19
|
case opt
|
@@ -24,6 +26,8 @@ opts.each do |opt,arg|
|
|
24
26
|
priority = p
|
25
27
|
when '--host'
|
26
28
|
host_ip = arg
|
29
|
+
when '--title'
|
30
|
+
title = arg
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
@@ -32,11 +36,15 @@ if ARGV.length != 1
|
|
32
36
|
exit 1
|
33
37
|
end
|
34
38
|
|
35
|
-
|
39
|
+
text = ARGV[0]
|
36
40
|
|
37
41
|
begin
|
38
42
|
client = NServer::Client.new(:host => host_ip)
|
39
|
-
|
43
|
+
msg = NServer::Message.new
|
44
|
+
msg.text = text
|
45
|
+
msg.priority = priority
|
46
|
+
msg.title = title
|
47
|
+
client.notify(msg)
|
40
48
|
rescue NServer::NoServerAvailable
|
41
49
|
STDERR.puts("No server available.")
|
42
50
|
exit 1
|
data/lib/nserver.rb
CHANGED
@@ -11,7 +11,7 @@ require 'ipaddr'
|
|
11
11
|
require 'yaml'
|
12
12
|
|
13
13
|
module NServer
|
14
|
-
VERSION = '1.1.
|
14
|
+
VERSION = '1.1.4'
|
15
15
|
class Server < GServer
|
16
16
|
# Create a NServer::Server instance
|
17
17
|
#
|
@@ -50,6 +50,7 @@ module NServer
|
|
50
50
|
@check_interval = opts[:check_interval]
|
51
51
|
|
52
52
|
@msg_list = [ Message.new("NServer Ready.") ]
|
53
|
+
@msg_history = []
|
53
54
|
@allowed_clients = opts[:allow]
|
54
55
|
|
55
56
|
Notify.init("Notification Server")
|
@@ -60,11 +61,36 @@ module NServer
|
|
60
61
|
|
61
62
|
@notification = Notify::Notification::new("X", nil, nil, @tray_icon)
|
62
63
|
@notification.timeout = opts[:msg_timeout]
|
64
|
+
#@notification.signal_connect('closed') do |s|
|
65
|
+
# puts "Closed!"
|
66
|
+
#end
|
63
67
|
|
64
68
|
Thread.new { Gtk.main }
|
65
69
|
sleep 5
|
66
70
|
@tray_icon.embedded? || raise("Failed to setup tray icon.")
|
67
71
|
|
72
|
+
@tray_icon.signal_connect('activate') do |ti|
|
73
|
+
dialog = Gtk::Dialog.new(
|
74
|
+
"Message History",
|
75
|
+
nil,
|
76
|
+
Gtk::Dialog::DESTROY_WITH_PARENT,
|
77
|
+
[ Gtk::Stock::OK, Gtk::Dialog::RESPONSE_NONE ]
|
78
|
+
)
|
79
|
+
dialog.signal_connect('response') {|d,r| d.destroy }
|
80
|
+
dialog.vbox.add(Gtk::Label.new("Message history (most recent on top)"))
|
81
|
+
@msg_history.reverse.each do |m|
|
82
|
+
label = Gtk::Label.new(m.text)
|
83
|
+
label.set_alignment(0,0.5)
|
84
|
+
|
85
|
+
dialog.vbox.add(Gtk::HSeparator.new)
|
86
|
+
dialog.vbox.add(label)
|
87
|
+
end
|
88
|
+
dialog.default_response = -1
|
89
|
+
dialog.set_default_size(300, 0)
|
90
|
+
dialog.show_all
|
91
|
+
end
|
92
|
+
|
93
|
+
|
68
94
|
## Setup msg thread
|
69
95
|
@msg_thread = Thread.new(self, @check_interval) do |server, intv|
|
70
96
|
loop do
|
@@ -76,6 +102,9 @@ module NServer
|
|
76
102
|
|
77
103
|
# Display the message
|
78
104
|
def notify(msg)
|
105
|
+
@msg_history << msg
|
106
|
+
@msg_history.shift if @msg_history.size > 5
|
107
|
+
|
79
108
|
@notification.update((msg.title or "Message Received"), msg.text, nil)
|
80
109
|
@notification.urgency = msg.priority
|
81
110
|
#@tray_icon.tooltip = msg.title
|
@@ -230,9 +259,13 @@ module NServer
|
|
230
259
|
|
231
260
|
def initialize( text = "", priority = :normal, title = nil )
|
232
261
|
@text = text
|
233
|
-
|
262
|
+
self.priority = priority
|
234
263
|
@title = title
|
235
264
|
end
|
265
|
+
|
266
|
+
def priority=(p)
|
267
|
+
@priority = (PRIORITIES.index(p) or 1)
|
268
|
+
end
|
236
269
|
end
|
237
270
|
|
238
271
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4.5
|
|
3
3
|
specification_version: 2
|
4
4
|
name: nserver
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.1.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 1.1.4
|
7
|
+
date: 2007-11-12 00:00:00 -05:00
|
8
8
|
summary: Notification server for ruby using libnotify
|
9
9
|
require_paths:
|
10
10
|
- lib
|