Class: Gtk::SysTray
Overview
class Win < Ruiby_gtk
def component()
. . . . .
systray(nil,50) do
syst_icon "icon.png"
syst_add_button "Reload" do |state| load(__FILE__) rescue log $! ; end
syst_add_button "Configuration" do |state| show_config end
syst_quit_button true
end
end
Instance Method Summary collapse
-
#initialize(window, title = "title?", config, x0, y0) ⇒ SysTray
constructor
A new instance of SysTray.
Constructor Details
#initialize(window, title = "title?", config, x0, y0) ⇒ SysTray
Returns a new instance of SysTray.
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ruiby_gtk/systray.rb', line 18 def initialize(window,title="title?",config,x0,y0) $statusIcon=self @popup_tray=Menu.new @checkMenu={} file= (config[:icon] && File.exist?(config[:icon])) ? config[:icon] : nil Message.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"){Gtk.main_quit} #@popup_tray.append(SeparatorMenuItem.new) @popup_tray.append(@bquit_tray) end @popup_tray.show_all super() self.pixbuf= file ? Gdk::Pixbuf.new(file) : nil #self.tooltip=title self.signal_connect('activate'){ if window.visible? window.hide else window.show end } self.signal_connect('popup-menu'){|tray, , time| @popup_tray.popup(nil,nil, , time) #{|menu, x, y, push_in| [(x0||x),(y0||y)] } } end |