Skip to content
Snippets Groups Projects
Commit 5f2e4c81 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

[Alex V. Myltsev] idle.c: cleanup.

Replace METH_VARARGS with METH_NOARGS, discard win32 ifdefs (it's no more compiled on win32 anyway).
parent 140e9227
No related branches found
No related tags found
No related merge requests found
...@@ -23,36 +23,27 @@ ...@@ -23,36 +23,27 @@
* along with Gajim. If not, see <http://www.gnu.org/licenses/>. * along with Gajim. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _WIN32 #include <X11/Xlib.h>
#include <X11/Xlib.h> #include <X11/Xutil.h>
#include <X11/Xutil.h> #include <X11/extensions/scrnsaver.h>
#include <X11/extensions/scrnsaver.h>
#endif
#include <Python.h> #include <Python.h>
#ifndef _WIN32 Display *display;
Display *display;
#endif
static PyObject * idle_init(PyObject *self, PyObject *args) static PyObject * idle_init(PyObject *self, PyObject *args)
{ {
#ifndef _WIN32
display = XOpenDisplay(NULL); display = XOpenDisplay(NULL);
#endif
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
static PyObject * idle_getIdleSec(PyObject *self, PyObject *args) static PyObject * idle_getIdleSec(PyObject *self, PyObject *args)
{ {
#ifndef _WIN32
static XScreenSaverInfo *mit_info = NULL; static XScreenSaverInfo *mit_info = NULL;
int idle_time, event_base, error_base; int idle_time, event_base, error_base;
#endif
#ifndef _WIN32
if (XScreenSaverQueryExtension(display, &event_base, &error_base)) if (XScreenSaverQueryExtension(display, &event_base, &error_base))
{ {
if (mit_info == NULL) if (mit_info == NULL)
...@@ -62,24 +53,23 @@ static PyObject * idle_getIdleSec(PyObject *self, PyObject *args) ...@@ -62,24 +53,23 @@ static PyObject * idle_getIdleSec(PyObject *self, PyObject *args)
} }
else else
idle_time = 0; idle_time = 0;
#endif
return Py_BuildValue("i", idle_time); return Py_BuildValue("i", idle_time);
} }
static PyObject * idle_close(PyObject *self, PyObject *args) static PyObject * idle_close(PyObject *self, PyObject *args)
{ {
#ifndef _WIN32
XCloseDisplay(display); XCloseDisplay(display);
#endif
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
static PyMethodDef idleMethods[] = static PyMethodDef idleMethods[] =
{ {
{"init", idle_init, METH_VARARGS, "init idle"}, {"init", idle_init, METH_NOARGS, "init idle"},
{"getIdleSec", idle_getIdleSec, METH_VARARGS, "Give the idle time in secondes"}, {"getIdleSec", idle_getIdleSec, METH_NOARGS, "Give the idle time in secondes"},
{"close", idle_close, METH_VARARGS, "close idle"}, {"close", idle_close, METH_NOARGS, "close idle"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment