Sha256: f443516261fd1a07dc82a6e79861536b0bdeeb330b94d2fc2ec376081c47718f
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
require 'drb' require 'RNotify' require 'singleton' require 'smilies/helper' module Smilies class Server include DRbUndumped include Singleton def self.start @gtk_thread = Thread.new { Gtk.main } DRb.start_service('druby://localhost:8809', self.instance) end def self.stop DRb.stop_service @gtk_thread.terminate end def self.join DRb.thread.join end def initialize @green_smiley = read_icon(Helper.green_smiley_path) @yellow_smiley = read_icon(Helper.yellow_smiley_path) @red_smiley = read_icon(Helper.red_smiley_path) Notify.init('Smilies') @tray_icon = Gtk::StatusIcon.new @tray_icon.pixbuf = @green_smiley @tray_icon.tooltip = 'Started' @notification = Notify::Notification.new('Start',nil,nil,@tray_icon) @notification.urgency = Notify::Notification::URGENCY_LOW @notification.timeout = 5000 end def details puts @message end def green(summary=nil, message=nil) message(@green_smiley, summary, message) end def yellow(summary=nil, message=nil) message(@yellow_smiley, summary, message) end def red(summary=nil, message=nil) message(@red_smiley, summary, message) end private def read_icon(icon_path) Gdk::Pixbuf.new(icon_path, 64, 64) end def message(icon, summary=nil, message=nil) @tray_icon.pixbuf = icon if summary @tray_icon.tooltip = summary end if message puts Helper.seperator_line puts message tail = message.split("\n")[-1] @notification.update(summary, tail, nil) @notification.pixbuf_icon = icon @notification.show end nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
armin-joellenbeck-smilies-0.0.3 | lib/smilies/server.rb |