class Iconify::CommandStatusIcon

プログラム名を表示するステータスアイコン

Constants

COLOR_SCHEME

Public Class Methods

new(name) click to toggle source
Calls superclass method
# File lib/iconify.rb, line 181
def initialize(name)
  super()

  @name = name
end

Public Instance Methods

draw_name(cr) click to toggle source
# File lib/iconify.rb, line 220
def draw_name(cr)
  cr.save do
    cr.set_font_size(24)
    cr.move_to(3, 64 / 2 + cr.font_extents.ascent / 2)
    cr.set_source_rgba(*@foreground_color, 1)
    cr.show_text(@name)
  end
end
fill_rounded_rectangle(cr) click to toggle source
# File lib/iconify.rb, line 212
def fill_rounded_rectangle(cr)
  cr.save do
    cr.set_source_rgb(*@background_color)
    cr.rounded_rectangle(1, 1, 62, 62, 15)
    cr.fill
  end
end
paint_background(cr) click to toggle source
# File lib/iconify.rb, line 204
def paint_background(cr)
  cr.save do
    cr.set_source_rgb(0.8, 0.8, 0.8)
    cr.set_operator(OPERATOR_SOURCE)
    cr.paint
  end
end
redraw() click to toggle source
# File lib/iconify.rb, line 229
def redraw
  using ImageSurface.new(FORMAT_ARGB32, 64, 64) do |surface|
    using Context.new(surface) do |cr|
      paint_background(cr)
      fill_rounded_rectangle(cr)
      draw_name(cr)
    end

    self.pixbuf = surface.to_pixbuf(0, 0, 64, 64)
  end
end
update(state) click to toggle source
# File lib/iconify.rb, line 192
def update(state)
  raise "unknown sate #{state}" unless COLOR_SCHEME.key?(state)

  @background_color, @foreground_color = COLOR_SCHEME[state]
  redraw
end
using(destroyable) { |destroyable| ... } click to toggle source
# File lib/iconify.rb, line 199
def using(destroyable)
  yield destroyable
  destroyable.destroy
end