class Gtk::MessagePicker

Constants

DEFAULT_CONDITION

Public Class Methods

new(conditions, &block) click to toggle source
Calls superclass method
# File core/mui/gtk_message_picker.rb, line 12
def initialize(conditions, &block)
  conditions = [] unless conditions.is_a? MIKU::List
  super()
  @not = (conditions.respond_to?(:car) and (conditions.car == :not))
  if(@not)
    conditions = (conditions[1] or []).freeze end
  @changed_hook = block
  shell = Gtk::VBox.new
  @container = Gtk::VBox.new
  @function, *exprs = *conditions.to_a
  @function ||= :and
  shell.add(@container)
  shell.closeup(add_button.center)
  exprs.each{|x| add_condition(x) }
  add(Gtk::Frame.new.set_border_width(8).set_label_widget(option_widgets).add(shell))
end

Public Instance Methods

add_button() click to toggle source
# File core/mui/gtk_message_picker.rb, line 47
def add_button
  @add_button ||= gen_add_button end
add_condition(expr = DEFAULT_CONDITION) click to toggle source
# File core/mui/gtk_message_picker.rb, line 50
def add_condition(expr = DEFAULT_CONDITION)
  pack = Gtk::HBox.new
  close = Gtk::Button.new.add(Gtk::WebIcon.new(Skin['close.png'], 16, 16)).set_relief(Gtk::RELIEF_NONE)
  close.signal_connect(:clicked){
    @container.remove(pack)
    pack.destroy
    call
    false }
  pack.closeup(close.top)
  case expr.first
  when :and, :or, :not
    pack.add(Gtk::MessagePicker.new(expr, &method(:call)))
  else
    pack.add(Gtk::MessagePicker::PickCondition.new(expr, &method(:call))) end
  @container.closeup(pack) end
function(new = @function) click to toggle source
# File core/mui/gtk_message_picker.rb, line 29
def function(new = @function)
  (new ? :or : :and) end
option_widgets() click to toggle source
# File core/mui/gtk_message_picker.rb, line 32
def option_widgets
  @option_widgets ||= Gtk::HBox.new.
    closeup(Mtk::boolean(lambda{ |new|
                           unless new.nil?
                             @function = function(new)
                             call end
                           @function == :or },
                         'いずれかにマッチする')).
    closeup(Mtk::boolean(lambda{ |new|
                           unless new.nil?
                             @not = new
                             call end
                           @not },
                         '否定')) end
to_a() click to toggle source
# File core/mui/gtk_message_picker.rb, line 66
def to_a
  result = [@function, *@container.children.map{|x| x.children.last.to_a}.reject(&:empty?)].freeze
  if result.size == 1
    [].freeze
  else
    if @not
      result = [:not, result].freeze end
    result end end