require 'fox'

module Fox
  class FXApp

    # Accepted forms are:
    #   addChore(target, selector)
    #   addChore(method(:onTimeout))
    #   addChore() { |sender, sel, ptr| block }

    alias addChoreOrig addChore

    def addChore(*args, &block)
      tgt, sel = nil, 0
      if args.length > 0
        if args[0].respond_to? :call
          tgt = FXPseudoTarget.new
	  tgt.pconnect(SEL_CHORE, args[0], block)
        else
	  tgt, sel = args[0], args[1]
        end
      else
        tgt = FXPseudoTarget.new
	tgt.pconnect(SEL_CHORE, nil, block)
      end
      addChoreOrig(tgt, sel)
    end
  end
end
