Module: Gtk::Stock

Defined in:
lib/gtk3/stock.rb

Class Method Summary collapse

Class Method Details

.add(stock_id, label, *rest) ⇒ Object



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
# File 'lib/gtk3/stock.rb', line 21

def add(stock_id, label, *rest)
  case rest.size
  when 0
    options = {}
  when 1
    if rest[0].is_a?(Hash)
      options = rest[0]
    else
      options = {:modifier => rest[0]}
    end
  else
    options = {
      :modifier           => rest[0],
      :key_value          => rest[1],
      :translation_domain => rest[2],
    }
  end

  item = StockItem.new

  stock_id = stock_id.to_s if stock_id.is_a?(Symbol)
  item.stock_id = stock_id

  item.label = label

  modifier = options[:modifier]
  item.modifier = modifier if modifier

  key_value = options[:key_value]
  item.keyval = key_value if key_value

  translation_domain = options[:translation_domain]
  item.translation_domain = translation_domain if translation_domain

  add_raw([item])
end

.add_rawObject



20
# File 'lib/gtk3/stock.rb', line 20

alias_method :add_raw, :add

.lookup(stock_id) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/gtk3/stock.rb', line 59

def lookup(stock_id)
  stock_id = stock_id.to_s if stock_id.is_a?(Symbol)
  found, item = lookup_raw(stock_id)
  if found
    item
  else
    nil
  end
end

.lookup_rawObject



58
# File 'lib/gtk3/stock.rb', line 58

alias_method :lookup_raw, :lookup