Class: GloudApp::Tray
- Inherits:
-
Object
- Object
- GloudApp::Tray
- Defined in:
- lib/gloudapp.rb
Instance Method Summary collapse
- #add_action(title, options = {}, &proc) ⇒ Object
- #add_separator ⇒ Object
- #icon=(icon) ⇒ Object
-
#initialize(options = {}, &default) ⇒ Tray
constructor
A new instance of Tray.
- #message=(message) ⇒ Object
- #run! ⇒ Object
Constructor Details
#initialize(options = {}, &default) ⇒ Tray
Returns a new instance of Tray.
229 230 231 232 |
# File 'lib/gloudapp.rb', line 229 def initialize( = {}, &default) = {:tooltip => 'GloudApp', :icon => GloudApp::Icon.normal_path}.merge() [:default] = default unless [:default].is_a?(Proc) end |
Instance Method Details
#add_action(title, options = {}, &proc) ⇒ Object
234 235 236 237 238 239 240 |
# File 'lib/gloudapp.rb', line 234 def add_action(title, = {}, &proc) @actions ||= [] = {} unless .is_a?(Hash) [:action] = proc unless [:action].is_a?(Proc) [:title] = title unless [:title].is_a?(String) @actions << end |
#add_separator ⇒ Object
242 243 244 245 |
# File 'lib/gloudapp.rb', line 242 def add_separator() @actions ||= [] @actions << {:separator => true} end |
#icon=(icon) ⇒ Object
270 271 272 |
# File 'lib/gloudapp.rb', line 270 def icon=(icon) @si.pixbuf = icon.is_a?(Gdk::Pixbuf) ? icon : Gdk::Pixbuf.new(icon) end |
#message=(message) ⇒ Object
274 275 276 |
# File 'lib/gloudapp.rb', line 274 def () @si.tooltip = .nil? ? [:tooltip] : .to_s end |
#run! ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/gloudapp.rb', line 247 def run! @si = Gtk::StatusIcon.new @si.pixbuf = Gdk::Pixbuf.new([:icon]) @si.tooltip = [:tooltip] @si.signal_connect('activate') do run_action [:default] end @si.signal_connect('popup-menu') do |tray, , time| if not @working @actions.each do |action| if action[:show].is_a?(Proc) action[:show].call(action[:item]) end end self.icon = Icon.normal self. = nil .popup(nil, nil, , time) end end end |