diff options
author | James Booth <boothj5@gmail.com> | 2016-04-07 21:25:12 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-04-07 21:25:12 +0100 |
commit | bfdc3b88072e0231c026fa6ebadc942343a56e2c (patch) | |
tree | a5845c5a038144259f9a10ee71577151d6b4859c /src/plugins/python_api.c | |
parent | a328367eb400012a04b9aac9204c9fab2e2fc583 (diff) | |
download | profani-tty-bfdc3b88072e0231c026fa6ebadc942343a56e2c.tar.gz |
Plugins: Added completer_remove
Diffstat (limited to 'src/plugins/python_api.c')
-rw-r--r-- | src/plugins/python_api.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index 9cac70ae..90b72619 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -213,6 +213,34 @@ python_api_completer_add(PyObject *self, PyObject *args) return Py_BuildValue(""); } +static PyObject * +python_api_completer_remove(PyObject *self, PyObject *args) +{ + const char *key = NULL; + PyObject *items = NULL; + + if (!PyArg_ParseTuple(args, "sO", &key, &items)) { + return Py_BuildValue(""); + } + + Py_ssize_t len = PyList_Size(items); + char *c_items[len]; + + Py_ssize_t i = 0; + for (i = 0; i < len; i++) { + PyObject *item = PyList_GetItem(items, i); + char *c_item = PyString_AsString(item); + c_items[i] = c_item; + } + c_items[len] = NULL; + + allow_python_threads(); + autocompleters_remove(key, c_items); + disable_python_threads(); + + return Py_BuildValue(""); +} + static PyObject* python_api_notify(PyObject *self, PyObject *args) { @@ -664,6 +692,7 @@ static PyMethodDef apiMethods[] = { { "register_command", python_api_register_command, METH_VARARGS, "Register a command." }, { "register_timed", python_api_register_timed, METH_VARARGS, "Register a timed function." }, { "completer_add", python_api_completer_add, METH_VARARGS, "Add items to an autocompleter." }, + { "completer_remove", python_api_completer_remove, METH_VARARGS, "Remove items from an autocompleter." }, { "send_line", python_api_send_line, METH_VARARGS, "Send a line of input." }, { "notify", python_api_notify, METH_VARARGS, "Send desktop notification." }, { "get_current_recipient", python_api_get_current_recipient, METH_VARARGS, "Return the jid of the recipient of the current window." }, |