Class: Gtk::SysTray

Inherits:
StatusIcon
  • Object
show all
Defined in:
lib/plugins/systray.rb

Instance Method Summary collapse

Constructor Details

#initialize(window, title = "title?", config) ⇒ SysTray

Returns a new instance of SysTray.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/plugins/systray.rb', line 10

def initialize(window,title="title?",config)
		$statusIcon=self
		@popup_tray=Menu.new
		@checkMenu={}
		file= (config[:icon] && File.exist?(config[:icon])) ? config[:icon] : nil
		alert("No icon defined for systray (or unknown file)") if ! file 
		config.each do |label,proc|
if Proc === proc 
  case label
  when  /^\+/
    bshow = CheckMenuItem.new(label[1..-1])
	@checkMenu[bshow]=bshow
    bshow.signal_connect("toggled") { |w|	
	   proc.call(! w.active?) 
	}  
	#TODO : get checkButton state to application closure, set state with closure return value
  when  /^-+/
			    bshow = SeparatorMenuItem.new
  else
			    bshow = MenuItem.new(label)
    bshow.signal_connect("activate") { proc.call(window.visible?) }  
	#TODO : icon in face of button
  end
  @popup_tray.append(bshow) 
end
		end
		if config[:quit]
@bquit_tray=ImageMenuItem.new(Stock::QUIT)
@bquit_tray.signal_connect("activate"){window.main_quit}
@popup_tray.append(SeparatorMenuItem.new)
@popup_tray.append(@bquit_tray)
		end
		@popup_tray.show_all
		
		super()
		self.pixbuf=if file then  Gdk::Pixbuf.new(file) ;else nil ; end
		self.tooltip=title||""
		self.signal_connect('activate'){ window.visible? ? window.hide : window.show }
		self.signal_connect('popup-menu'){|tray, button, time|
 @popup_tray.popup(nil, nil, button, time)
		}
end