gnms 2.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gnms might be problematic. Click here for more details.

Files changed (140) hide show
  1. data/LICENSE +459 -0
  2. data/README +29 -0
  3. data/bin/gnms +11 -0
  4. data/gnms.gemspec +70 -0
  5. data/lib/cmd_parse.rb +747 -0
  6. data/lib/config_global.rb +414 -0
  7. data/lib/contact.rb +171 -0
  8. data/lib/external/crypt/blowfish-tables.rb +190 -0
  9. data/lib/external/crypt/blowfish.rb +110 -0
  10. data/lib/external/crypt/cbc.rb +123 -0
  11. data/lib/external/crypt/stringxor.rb +27 -0
  12. data/lib/external/fog.rb +41 -0
  13. data/lib/external/jjmx.rb +45 -0
  14. data/lib/external/sms.rb +282 -0
  15. data/lib/external/xmpp4r-simple.rb +497 -0
  16. data/lib/format.rb +85 -0
  17. data/lib/gnms.rb +329 -0
  18. data/lib/gui/about_window.rb +177 -0
  19. data/lib/gui/adddelnode.rb +799 -0
  20. data/lib/gui/base_window.rb +789 -0
  21. data/lib/gui/canvas_map.rb +498 -0
  22. data/lib/gui/charts/gruff.rb +51 -0
  23. data/lib/gui/color_macro.rb +145 -0
  24. data/lib/gui/config_window.rb +2151 -0
  25. data/lib/gui/custom_plugin_window.rb +90 -0
  26. data/lib/gui/debug_window.rb +46 -0
  27. data/lib/gui/event_window.rb +469 -0
  28. data/lib/gui/find_node_window.rb +438 -0
  29. data/lib/gui/help_window.rb +47 -0
  30. data/lib/gui/ipcalculator.rb +147 -0
  31. data/lib/gui/jmx_ref_window.rb +309 -0
  32. data/lib/gui/link_view.rb +46 -0
  33. data/lib/gui/mib_browser.rb +585 -0
  34. data/lib/gui/node_host_property.rb +3712 -0
  35. data/lib/gui/node_host_view.rb +270 -0
  36. data/lib/gui/node_network_property.rb +1059 -0
  37. data/lib/gui/node_network_view.rb +186 -0
  38. data/lib/gui/node_view.rb +672 -0
  39. data/lib/gui/oid_ref_window.rb +288 -0
  40. data/lib/gui/snmptrap_ref_window.rb +288 -0
  41. data/lib/gui/sub/account_frame.rb +196 -0
  42. data/lib/gui/sub/contact_frame.rb +519 -0
  43. data/lib/gui/syslog_ref_window.rb +288 -0
  44. data/lib/gui/treenode_window.rb +320 -0
  45. data/lib/gui/update_window.rb +124 -0
  46. data/lib/gui/widgets.rb +169 -0
  47. data/lib/gui/wmi_ref_window.rb +286 -0
  48. data/lib/interface.rb +16 -0
  49. data/lib/ipcalc.rb +266 -0
  50. data/lib/link.rb +45 -0
  51. data/lib/main.rb +1091 -0
  52. data/lib/monitor/client/custom/custom_monitoring.rb +40 -0
  53. data/lib/monitor/client/jmx/jmx_attr_monitoring.rb +36 -0
  54. data/lib/monitor/client/jmx/jmx_monitoring.rb +83 -0
  55. data/lib/monitor/client/jmx/jmx_ref.rb +114 -0
  56. data/lib/monitor/client/snmp/mibs/SNMPv2-MIB.txt +854 -0
  57. data/lib/monitor/client/snmp/mibs/SNMPv2-SMI.txt +344 -0
  58. data/lib/monitor/client/snmp/oid_ref.rb +141 -0
  59. data/lib/monitor/client/snmp/snmp.rb +178 -0
  60. data/lib/monitor/client/snmp/snmp_monitoring.rb +58 -0
  61. data/lib/monitor/client/wmi/wmi.rb +139 -0
  62. data/lib/monitor/client/wmi/wmi_monitoring.rb +60 -0
  63. data/lib/monitor/client/wmi/wmi_ref.rb +141 -0
  64. data/lib/monitor/custom_plugin.rb +50 -0
  65. data/lib/monitor/server/msg_buffer.rb +39 -0
  66. data/lib/monitor/server/snmp/snmptrap_analyzer.rb +81 -0
  67. data/lib/monitor/server/snmp/snmptrap_capture.rb +26 -0
  68. data/lib/monitor/server/snmp/snmptrap_monitoring.rb +32 -0
  69. data/lib/monitor/server/snmp/snmptrap_ref.rb +135 -0
  70. data/lib/monitor/server/snmp/snmptrap_server.rb +50 -0
  71. data/lib/monitor/server/syslog/syslog_analyzer.rb +141 -0
  72. data/lib/monitor/server/syslog/syslog_capture.rb +28 -0
  73. data/lib/monitor/server/syslog/syslog_monitoring.rb +32 -0
  74. data/lib/monitor/server/syslog/syslog_ref.rb +136 -0
  75. data/lib/monitor/server/syslog/syslog_server.rb +43 -0
  76. data/lib/node.rb +1020 -0
  77. data/lib/node_db.rb +2668 -0
  78. data/lib/node_host.rb +215 -0
  79. data/lib/node_listener.rb +639 -0
  80. data/lib/node_network.rb +269 -0
  81. data/lib/node_property.rb +39 -0
  82. data/lib/notify/alarm.rb +247 -0
  83. data/lib/notify/irc_bot.rb +167 -0
  84. data/lib/notify/xmpp_bot.rb +107 -0
  85. data/lib/service.rb +36 -0
  86. data/lib/version.rb +8 -0
  87. data/pixmap/bg/map_bg.jpg +0 -0
  88. data/pixmap/bg/map_bg2.jpg +0 -0
  89. data/pixmap/logo.jpg +0 -0
  90. data/pixmap/logo_icon.png +0 -0
  91. data/pixmap/os/3com.png +0 -0
  92. data/pixmap/os/aix.gif +0 -0
  93. data/pixmap/os/amiga.png +0 -0
  94. data/pixmap/os/beos.png +0 -0
  95. data/pixmap/os/cisco.png +0 -0
  96. data/pixmap/os/freebsd.png +0 -0
  97. data/pixmap/os/hp.png +0 -0
  98. data/pixmap/os/hurd.gif +0 -0
  99. data/pixmap/os/irix.gif +0 -0
  100. data/pixmap/os/linux.png +0 -0
  101. data/pixmap/os/mac.png +0 -0
  102. data/pixmap/os/netbsd.gif +0 -0
  103. data/pixmap/os/netware.png +0 -0
  104. data/pixmap/os/openbsd.png +0 -0
  105. data/pixmap/os/os2warp.gif +0 -0
  106. data/pixmap/os/qnx.gif +0 -0
  107. data/pixmap/os/sco.gif +0 -0
  108. data/pixmap/os/sgi.xpm +111 -0
  109. data/pixmap/os/solaris.gif +0 -0
  110. data/pixmap/os/unix.gif +0 -0
  111. data/pixmap/os/unknown.png +0 -0
  112. data/pixmap/os/vms.xpm +345 -0
  113. data/pixmap/os/windows.png +0 -0
  114. data/pixmap/type/cloud.png +0 -0
  115. data/pixmap/type/device.png +0 -0
  116. data/pixmap/type/firewall.png +0 -0
  117. data/pixmap/type/gateway.png +0 -0
  118. data/pixmap/type/home.png +0 -0
  119. data/pixmap/type/host.png +0 -0
  120. data/pixmap/type/network.png +0 -0
  121. data/pixmap/type/printer.png +0 -0
  122. data/pixmap/type/router.png +0 -0
  123. data/pixmap/type/server.png +0 -0
  124. data/pixmap/type/switch.png +0 -0
  125. data/pixmap/type/vm.png +0 -0
  126. data/plugins/Defaultme.rb +7 -0
  127. data/plugins/DnsCheck.rb +46 -0
  128. data/plugins/FooMonitor.rb +26 -0
  129. data/plugins/HttpVirtualHostMonitor.rb +43 -0
  130. data/plugins/MysqlShowStatusMonitor.rb +64 -0
  131. data/plugins/PgsqlPercentConnectionMonitor.rb +72 -0
  132. data/plugins/SshCpuLoadMonitor.rb +85 -0
  133. data/plugins/SshDiskMonitor.rb +69 -0
  134. data/plugins/SshFgtAvExpiredMonitor.rb +75 -0
  135. data/plugins/SshPercentUsedRamMonitor.rb +74 -0
  136. data/plugins/TelnetCpuLoadMonitor.rb +69 -0
  137. data/plugins/example1.rb +15 -0
  138. data/plugins/example2.rb +7 -0
  139. data/sound/beep.wav +0 -0
  140. metadata +378 -0
@@ -0,0 +1,498 @@
1
+ require "#{GNMSLIB}"+'/gui/node_view'
2
+ require "#{GNMSLIB}"+'/gui/node_network_view'
3
+ require "#{GNMSLIB}"+'/gui/node_host_view'
4
+ require "#{GNMSLIB}"+'/gui/debug_window'
5
+
6
+ class CanvasMap < Gtk::VBox
7
+
8
+ def fullscreen?()
9
+ return @fullscreen==true
10
+ end
11
+
12
+ def toggle_fullscreen()
13
+ if @fullscreen == false
14
+ @fullscreen=true
15
+ $win.hide_menu()
16
+ $win.fullscreen()
17
+ else
18
+ @fullscreen=false
19
+ $win.show_menu()
20
+ $win.unfullscreen()
21
+ end
22
+ end
23
+
24
+ #
25
+ # set the background image
26
+ #
27
+ def set_background_image(image_file)
28
+ if !defined?(@bg_img) || (@bg_img == nil)
29
+ @bg_img=Goo::CanvasGroup.new(@canvas.root_item,{:x => 0.0,:y => 0.0})
30
+ end
31
+ if (image_file != nil) && FileTest.exist?(image_file)
32
+ im=Gdk::Pixbuf.new(image_file)
33
+ @bg_img.lower(nil)
34
+ if defined?(@img) && (@img != nil)
35
+ @img.visibility = Goo::CanvasItem::HIDDEN
36
+ @img.parent.remove_child(@img)
37
+ end
38
+ @img=Goo::CanvasImage.new(@bg_img, im, 0, 0,:width => @canvas.x2 - @canvas.x1, :height=> @canvas.y2 - @canvas.y1, :scale_to_fit => true)
39
+ @img.lower(nil)
40
+ @bg_img.visibility = Goo::CanvasItem::VISIBLE
41
+ @bg_image_enable=true
42
+ end
43
+ end
44
+
45
+ #
46
+ # return the visible item at position (x,y) or nil
47
+ #
48
+ def item_at(x, y)
49
+ cvitem = @canvas.get_item_at(x, y, true)
50
+ if cvitem
51
+ if !(cvitem.visibility == Goo::CanvasItem::VISIBLE)
52
+ cvitem = nil
53
+ end
54
+ end
55
+ return cvitem
56
+ end
57
+
58
+ def background_image_isset?()
59
+ return @bg_image_enable
60
+ end
61
+
62
+ #
63
+ # unset the background image
64
+ #
65
+ def unset_background_image()
66
+ if defined?(@bg_img)
67
+ @bg_img.visibility = Goo::CanvasItem::HIDDEN unless @bg_img==nil
68
+ @bg_image_enable = false
69
+ end
70
+ end
71
+
72
+ def get_selected_node()
73
+ nodeselected=[]
74
+ if $map != nil
75
+ tmp_node=$network[get_map()]
76
+ if tmp_node
77
+ tmp_node.get_node().each_value {|n|
78
+ if n.node_view and n.node_view.selected?()
79
+ nodeselected.push(n)
80
+ end
81
+ }
82
+ end
83
+ else
84
+ if $network[ROOTMAPADDR] and $network[ROOTMAPADDR].node_view.selected?()
85
+ nodeselected.push($network[ROOTMAPADDR])
86
+ end
87
+ end
88
+ return nodeselected
89
+ end
90
+
91
+ def node_view_zoom_in()
92
+ if $map == nil
93
+ $config.pixmap_size+=5
94
+ $network[ROOTMAPADDR].node_view.resize()
95
+ else
96
+ if $network[get_map()].node_size == nil
97
+ $network[get_map()].node_size=$config.pixmap_size+5
98
+ else
99
+ $network[get_map()].node_size+=5
100
+ end
101
+ $network[get_map()].get_node().each_value {|n|
102
+ n.node_view.resize() if n.node_view
103
+ }
104
+ end
105
+ end
106
+
107
+ def node_view_zoom_out()
108
+ if $map == nil
109
+ $config.pixmap_size-=5 unless $config.pixmap_size < 10
110
+ $network[ROOTMAPADDR].node_view.resize()
111
+ else
112
+ if $network[get_map()].node_size == nil
113
+ $network[get_map()].node_size=$config.pixmap_size-5 unless $config.pixmap_size < 10
114
+ else
115
+ $network[get_map()].node_size-=5 unless $network[get_map()].node_size < 10
116
+ end
117
+ $network[get_map()].get_node().each_value {|n|
118
+ n.node_view.resize() if n.node_view
119
+ }
120
+ end
121
+ end
122
+
123
+ def nb_selected()
124
+ tmp=get_selected_node()
125
+ if tmp
126
+ return get_selected_node().size()
127
+ end
128
+ return 0
129
+ end
130
+
131
+ def key_press(canvas, event)
132
+ estring=Gdk::Keyval.to_name(event.keyval)
133
+ #print "canvas key code: ",event.keyval," = ",estring,"\n"
134
+
135
+ x, y = [canvas.x1,canvas.y1]
136
+ case event.keyval
137
+ when Gdk::Keyval::GDK_KP_Add
138
+ node_view_zoom_in()
139
+ when Gdk::Keyval::GDK_plus
140
+ node_view_zoom_in()
141
+ when Gdk::Keyval::GDK_KP_Subtract
142
+ node_view_zoom_out()
143
+ when Gdk::Keyval::GDK_minus
144
+ node_view_zoom_out()
145
+ when Gdk::Keyval::GDK_Delete
146
+ del_selected_node()
147
+ when Gdk::Keyval::GDK_d
148
+ del_selected_node()
149
+ when Gdk::Keyval::GDK_i
150
+ #up
151
+ get_selected_node().each {|n|
152
+ n.node_view.move_up()
153
+ }
154
+ when Gdk::Keyval::GDK_k
155
+ #down
156
+ get_selected_node().each {|n|
157
+ n.node_view.move_down()
158
+ }
159
+ when Gdk::Keyval::GDK_j
160
+ #left
161
+ get_selected_node().each {|n|
162
+ n.node_view.move_left()
163
+ }
164
+ when Gdk::Keyval::GDK_l
165
+ #right
166
+ get_selected_node().each {|n|
167
+ n.node_view.move_right()
168
+ }
169
+ when Gdk::Keyval::GDK_Up
170
+ #canvas.y1 = y - 10
171
+ #canvas.scroll_to(x, canvas.y1)
172
+ when Gdk::Keyval::GDK_Down
173
+ #canvas.y1 = y + 10
174
+ #canvas.scroll_to(x, canvas.y1)
175
+ when Gdk::Keyval::GDK_Left
176
+ #canvas.x1 = x - 10
177
+ #canvas.scroll_to(canvas.x1, y)
178
+ when Gdk::Keyval::GDK_Right
179
+ #canvas.x1 = x + 10
180
+ #canvas.scroll_to(canvas.x1, y)
181
+ when Gdk::Keyval::GDK_Page_Up
182
+ set_map($network[$map].map) unless $map == nil
183
+ when Gdk::Keyval::GDK_Page_Down
184
+ if $map == nil
185
+ set_map(ROOTMAPADDR)
186
+ else
187
+ if $network[get_map()].nb_network == 1
188
+ $network[get_map()].network.each_key {|k| set_map(k)}
189
+ else
190
+ #$canvas.get_selected_node().each {|n|
191
+ #if n.class == Network
192
+ #$network[get_map()].network.each_key {|k| set_map(n)}
193
+ #break
194
+ #end
195
+ #}
196
+ end
197
+ end
198
+ when Gdk::Keyval::GDK_f
199
+ toggle_fullscreen()
200
+ when Gdk::Keyval::GDK_F7
201
+ DebugWindow.new
202
+ end
203
+ end
204
+
205
+ def grab_focus()
206
+ @canvas.grab_focus(get_root())
207
+ end
208
+
209
+ def get_root()
210
+ @canvas.root_item
211
+ end
212
+
213
+ def redraw_all()
214
+ @canvas.update()
215
+ end
216
+
217
+ #
218
+ # set canvas background color
219
+ #
220
+ def set_rgb(r, g, b)
221
+ #convert the r g b color in a gdk color object,
222
+ #then transform it to a rgb hex value then an int
223
+ @canvas.background_color_rgb = Integer("0x#{rgb_to_hex_color(Gdk::Color.new(r, g, b))}")
224
+ end
225
+
226
+ def set_size(w, h)
227
+ if @bg_image_enable && (@img != nil)
228
+ @img.width = @canvas.x2 - @canvas.x1
229
+ @img.height = @canvas.y2 - @canvas.y1
230
+ end
231
+ end
232
+
233
+ def initialize()
234
+ super()
235
+ @bg_image_enable=false
236
+ @dragging = false
237
+ @cursor_x=nil
238
+ @cursor_y=nil
239
+ @drawing_selection=false
240
+ @selection=nil
241
+ @fullscreen=false
242
+ show()
243
+
244
+ # Create the canvas
245
+ @canvas = Goo::Canvas.new
246
+
247
+ #here we set the background color
248
+ set_rgb($config.rgb[0].to_f, $config.rgb[1].to_f, $config.rgb[2].to_f)
249
+
250
+ # Setup canvas items
251
+ root = @canvas.root_item
252
+
253
+ # Layout the stuff
254
+ table = Gtk::Table.new(2, 2, false)
255
+ pack_start(table,true)
256
+
257
+ table.show()
258
+ table.attach(@canvas,
259
+ 0, 1, 0, 1,
260
+ Gtk::EXPAND | Gtk::FILL | Gtk::SHRINK,
261
+ Gtk::EXPAND | Gtk::FILL | Gtk::SHRINK,
262
+ 0, 0)
263
+
264
+ @canvas.show()
265
+ @canvas.signal_connect_after("key_press_event") do |item, event|
266
+ if !busy?()
267
+ key_press(item, event)
268
+ end
269
+ end
270
+
271
+ @canvas.signal_connect("scroll_event") do |w, event|
272
+ if !busy?()
273
+ if event.state & Gdk::Window::CONTROL_MASK == Gdk::Window::CONTROL_MASK
274
+ case event.direction
275
+ when Gdk::EventScroll::UP
276
+ node_view_zoom_in()
277
+ when Gdk::EventScroll::DOWN
278
+ node_view_zoom_out()
279
+ end
280
+ end
281
+ end
282
+ #use update to cute scroll_event forwarding @canvas.root_item
283
+ @canvas.update()
284
+ end
285
+
286
+ @canvas.signal_connect("button_press_event") do |w, event|
287
+ if busy?()
288
+ next
289
+ end
290
+ #puts "in canvas button press #{w}"
291
+
292
+ xw, yw = w.convert_to_pixels(event.x,event.y)
293
+ cvitem=item_at(xw, yw)
294
+ if (cvitem == nil) || (cvitem.parent == @bg_img if defined?(@bg_img))
295
+ if event.state & Gdk::Window::CONTROL_MASK != Gdk::Window::CONTROL_MASK
296
+ if $map == nil
297
+ $network[ROOTMAPADDR].node_view.unselect()
298
+ else
299
+ $canvas.get_selected_node().each {|n|
300
+ n.node_view.unselect()
301
+ }
302
+ end
303
+ end
304
+
305
+ if (event.event_type == Gdk::Event::BUTTON_PRESS)
306
+ #puts "event button #{event.button}"
307
+ if event.button == 8
308
+ set_map($network[$map].map) unless $map == nil
309
+ end
310
+ if event.button == 9
311
+ if $map == nil
312
+ set_map(ROOTMAPADDR)
313
+ else
314
+ if $network[get_map()].nb_network == 1
315
+ $network[get_map()].network.each_key {|k| set_map(k)}
316
+ end
317
+ end
318
+ end
319
+
320
+ if event.button == 3 #right click
321
+ #show popup menu
322
+ b = event.button
323
+ t = event.time
324
+ popup_menu = Gtk::Menu.new
325
+ add_node=Gtk::ImageMenuItem.new("Add node")
326
+ image_add_node = Gtk::Image.new()
327
+ image_add_node.set_stock(Gtk::Stock::ADD)
328
+ add_node.set_image(image_add_node)
329
+ popup_menu.append(add_node)
330
+ if get_map() != nil
331
+ add_sub_menu=Gtk::Menu.new
332
+ add_sub_menu.append(add_host=Gtk::MenuItem.new("Add host"))
333
+ add_host.signal_connect('button-press-event') {
334
+ addnodewin
335
+ popup_menu.destroy
336
+ }
337
+ add_sub_menu.append(add_host_range_item=Gtk::MenuItem.new("Add host range"))
338
+ add_host_range_item.signal_connect('button-press-event') {
339
+ add_host_range
340
+ popup_menu.destroy
341
+ }
342
+ add_sub_menu.append(add_network=Gtk::MenuItem.new("Add network"))
343
+ add_network.signal_connect('button-press-event') {
344
+ addnetworkwin
345
+ popup_menu.destroy
346
+ }
347
+ end
348
+ add_node.set_submenu(add_sub_menu)
349
+
350
+ find_node=Gtk::ImageMenuItem.new("Find node")
351
+ image_find_node = Gtk::Image.new()
352
+ image_find_node.set_stock(Gtk::Stock::FIND)
353
+ find_node.set_image(image_find_node)
354
+ popup_menu.append(find_node)
355
+
356
+ if $event_win.visible?
357
+ popup_menu.append(ewin_hide=Gtk::MenuItem.new("Hide event log"))
358
+ else
359
+ popup_menu.append(ewin_show=Gtk::MenuItem.new("Show event log"))
360
+ end
361
+ popup_menu.append(layout_grid=Gtk::MenuItem.new("Grid layout"))
362
+
363
+ map_up=Gtk::ImageMenuItem.new("Go up")
364
+ image_map_up = Gtk::Image.new()
365
+ image_map_up.set_stock(Gtk::Stock::GO_UP)
366
+ map_up.set_image(image_map_up)
367
+ popup_menu.append(map_up)
368
+
369
+ if $canvas.fullscreen?()
370
+ popup_menu.append(Gtk::SeparatorMenuItem.new)
371
+ popup_menu.append(exit_fullscreen=Gtk::MenuItem.new("Unfullscreen"))
372
+ exit_fullscreen.signal_connect('button-press-event') {
373
+ toggle_fullscreen()
374
+ popup_menu.destroy
375
+ }
376
+ end
377
+
378
+ if $map == nil
379
+ layout_grid.set_sensitive(false)
380
+ map_up.set_sensitive(false)
381
+ add_node.set_sensitive(false)
382
+ end
383
+ popup_menu.show_all
384
+ popup_menu.popup(nil,nil,b,t)
385
+
386
+ find_node.signal_connect('button-press-event') {
387
+ findnodewin
388
+ popup_menu.destroy
389
+ }
390
+ if (ewin_hide)
391
+ ewin_hide.signal_connect('button-press-event') {
392
+ $event_win.hide()
393
+ popup_menu.destroy
394
+ }
395
+ end
396
+ if (ewin_show)
397
+ ewin_show.signal_connect('button-press-event') {
398
+ $event_win.show()
399
+ popup_menu.destroy
400
+ }
401
+ end
402
+ layout_grid.signal_connect('button-press-event') {
403
+ layout_grid($map)
404
+ popup_menu.destroy
405
+ }
406
+ map_up.signal_connect('button-press-event') {
407
+ if $map != nil
408
+ set_map($network[$map].map)
409
+ end
410
+ popup_menu.destroy
411
+ }
412
+ else
413
+ #draw selection with other button
414
+ @drawing_selection=true
415
+ @cursor_x=event.x
416
+ @cursor_y=event.y
417
+ end
418
+ end
419
+ end
420
+ end
421
+
422
+ @canvas.signal_connect_after("button_release_event") do |w, event|
423
+ if busy?()
424
+ next
425
+ end
426
+ #puts "here canvas signal connect button release"
427
+ if @drawing_selection
428
+ #we select node in rectangle selection
429
+ cursor_x, cursor_y = w.convert_to_pixels(@cursor_x,@cursor_y)
430
+ x2, y2 = w.convert_to_pixels(event.x,event.y)
431
+
432
+ if cursor_x>x2
433
+ xpos=x2.to_i
434
+ x2=cursor_x
435
+ else
436
+ xpos=cursor_x.to_i
437
+ end
438
+ while xpos < x2.to_i
439
+ if cursor_y>y2
440
+ ypos=y2.to_i
441
+ y2=cursor_y
442
+ else
443
+ ypos=cursor_y.to_i
444
+ end
445
+ while ypos < y2.to_i
446
+ if $map == nil
447
+ node=$network[ROOTMAPADDR]
448
+ if xpos<node.x && x2>node.x+$config.pixmap_size && ypos<node.y && y2>node.y+$config.pixmap_size+10
449
+ #pos point is in node zone
450
+ node.node_view.select()
451
+ end
452
+ else
453
+ $network[get_map()].get_node().each_value {|node|
454
+ if xpos<node.x && x2>node.x+$config.pixmap_size && ypos<node.y && y2>node.y+$config.pixmap_size+10
455
+ #pos point is in node zone
456
+ node.node_view.select()
457
+ end
458
+ }
459
+ end
460
+ ypos+=$config.pixmap_size+10
461
+ end
462
+ xpos+=$config.pixmap_size
463
+ end
464
+ @drawing_selection=false
465
+ end
466
+ #hide rectangle selection
467
+ @selection.visibility = Goo::CanvasItem::HIDDEN unless @selection == nil
468
+
469
+ #redraw links cause nodes have moved
470
+ node_tmp=nil
471
+ get_selected_node().each {|n|
472
+ node_tmp=n
473
+ if n.nb_links > 0
474
+ n.get_links().each {|lnk|
475
+ lnk.remove_link
476
+ lnk.display()
477
+ }
478
+ end
479
+ }
480
+ end
481
+
482
+ @canvas.signal_connect("motion_notify_event") do |w, event|
483
+ if busy?()
484
+ next
485
+ end
486
+
487
+ if @drawing_selection
488
+ @selection.visibility = Goo::CanvasItem::HIDDEN unless @selection == nil
489
+
490
+ cursor_x, cursor_y = w.convert_to_pixels(@cursor_x,@cursor_y)
491
+ x2, y2 = w.convert_to_pixels(event.x,event.y)
492
+ @selection=Goo::CanvasRect.new(root, cursor_x, cursor_y, x2 - cursor_x, y2 - cursor_y,
493
+ :stroke_color => "red",
494
+ :line_width => 1.0)
495
+ end
496
+ end
497
+ end
498
+ end