idle is a C module, not a C++ one

This commit is contained in:
Yann Leboulanger 2004-05-28 17:54:40 +00:00
parent 28c0b705c5
commit 528e353cee
3 changed files with 14 additions and 10 deletions

View File

@ -6,21 +6,23 @@
#include <gtk/gtk.h>
static PyObject * idle_init(PyObject *self, PyObject *args) {
static PyObject * idle_init(PyObject *self, PyObject *args)
{
gtk_init (NULL, NULL);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject * idle_getIdleSec(PyObject *self, PyObject *args) {
static PyObject * idle_getIdleSec(PyObject *self, PyObject *args)
{
static XScreenSaverInfo *mit_info = NULL;
int idle_time, event_base, error_base;
gtk_init (NULL, NULL);
if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) {
if (mit_info == NULL) {
if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base))
{
if (mit_info == NULL)
mit_info = XScreenSaverAllocInfo();
}
XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info);
idle_time = (mit_info->idle) / 1000;
}
@ -29,13 +31,15 @@ static PyObject * idle_getIdleSec(PyObject *self, PyObject *args) {
return Py_BuildValue("i", idle_time);
}
static PyObject * idle_close(PyObject *self, PyObject *args) {
static PyObject * idle_close(PyObject *self, PyObject *args)
{
gtk_main_quit ();
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef idleMethods[] = {
static PyMethodDef idleMethods[] =
{
{"init", idle_init, METH_VARARGS, "init gtk"},
{"getIdleSec", idle_getIdleSec, METH_VARARGS, "Give the idle time in secondes"},
{"close", idle_close, METH_VARARGS, "close gtk"},

View File

@ -648,13 +648,13 @@ class roster_Window:
acct_iter = model.get_iter((path[0]))
account = model.get_value(acct_iter, 3)
menu = gtk.Menu()
item = gtk.MenuItem(_(u"Log on"))
item = gtk.MenuItem(_("Log on"))
if self.contacts[account][jid][0].show != 'offline':
item.set_sensitive(FALSE)
menu.append(item)
item.connect("activate", self.on_agent_logging, jid, 'available', account)
item = gtk.MenuItem(_(u"Log off"))
item = gtk.MenuItem(_("Log off"))
if self.contacts[account][jid][0].show == 'offline':
item.set_sensitive(FALSE)
menu.append(item)

View File

@ -1,7 +1,7 @@
from distutils.core import setup, Extension
module1 = Extension( 'idle',
sources = ['common/idle.cpp'],
sources = ['common/idle.c'],
# extra_compile_args = ['-W'],
libraries = ['gtk-x11-2.0','gdk-x11-2.0','glib-2.0','X11','Xext','Xss','atk-1.0'],
library_dirs = ['/usr/X11R6/lib'],