82 lines
2.0 KiB
C
82 lines
2.0 KiB
C
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
|
%%
|
|
headers
|
|
#include <Python.h>
|
|
|
|
#include "pygobject.h"
|
|
#include "sugar-address-entry.h"
|
|
#include "sugar-grid.h"
|
|
#include "sugar-key-grabber.h"
|
|
#include "sugar-menu.h"
|
|
#include "sexy-icon-entry.h"
|
|
#include "gsm-session.h"
|
|
#include "gsm-xsmp.h"
|
|
#include "acme-volume-alsa.h"
|
|
|
|
#include "eggsmclient.h"
|
|
#include "eggsmclient-private.h"
|
|
|
|
#include <pygtk/pygtk.h>
|
|
#include <glib.h>
|
|
|
|
%%
|
|
modulename sugar._sugarext
|
|
%%
|
|
import gobject.GObject as PyGObject_Type
|
|
import gtk.Widget as PyGtkWidget_Type
|
|
import gtk.Entry as PyGtkEntry_Type
|
|
import gtk.Menu as PyGtkMenu_Type
|
|
import gtk.Container as PyGtkContainer_Type
|
|
import gtk.gdk.Window as PyGdkWindow_Type
|
|
import gtk.Image as PyGtkImage_Type
|
|
%%
|
|
ignore-glob
|
|
*_get_type
|
|
_*
|
|
%%
|
|
override sugar_key_grabber_grab_keys kwargs
|
|
static PyObject *
|
|
_wrap_sugar_key_grabber_grab_keys(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
{
|
|
static char *kwlist[] = { "key", NULL };
|
|
PyObject *py_keys;
|
|
char **keys;
|
|
int i, len;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args,kwargs,
|
|
"O:SugarKeyGrabber.grab_keys",
|
|
kwlist, &py_keys))
|
|
return NULL;
|
|
|
|
if (!PySequence_Check(py_keys) || (len = PySequence_Size(py_keys)) < 0) {
|
|
PyErr_SetString(PyExc_ValueError,
|
|
"keys should be a sequence of strings");
|
|
return NULL;
|
|
}
|
|
|
|
keys = g_new(char*, len + 1);
|
|
for (i = 0; i < len; i++) {
|
|
PyObject *item = PySequence_GetItem(py_keys, i);
|
|
if (!item) {
|
|
g_free(keys);
|
|
return NULL;
|
|
}
|
|
if (!PyString_Check(item)) {
|
|
PyErr_SetString(PyExc_TypeError, "key must be a string");
|
|
g_free(keys);
|
|
Py_DECREF(item);
|
|
return NULL;
|
|
}
|
|
keys[i] = PyString_AsString(item);
|
|
Py_DECREF(item);
|
|
}
|
|
keys[len] = NULL;
|
|
|
|
sugar_key_grabber_grab_keys (SUGAR_KEY_GRABBER(self->obj), (const char**) keys);
|
|
|
|
Py_INCREF(Py_None);
|
|
return Py_None;
|
|
}
|
|
|
|
%%
|