Refactor inputhook to allow easy extension

Not ready for merge

Prompted by #5645, @minrk suggested that we should provide an extension mechanism for input hooks, so that that code (which we don't use, test or maintain very much) can be maintained outside IPython. This is a prototype of that.

To define a new GUI integration, you register a class like this:

```python
from IPython.lib.inputhook import register, InputHookBase

@register('clutter')
class ClutterInputHook(InputHookBase):
    def enable(self, app=None):
        self.manager.set_inputhook(inputhook_clutter)
```

It can also define a `disable()` method, but only one of the 7 we include needs that. Once this code has run (e.g. by importing a module or using `%load_ext`), the user should be able to do `%gui clutter`.

To do:

- [x] Similar mechanisms for the kernel event loop
- [x] Docs

@jhamrick says I broke the `--gui=osx` option. It looks like it was already doing nothing, and it just got lost in the refactor. So now `ipython --gui=osx` refuses to start instead of silently ignoring the option.

The option is used in @jhamrick's 'moderately popular' emacs config, so we may want to put it back with a deprecation warning for a release cycle.