view finch/libgnt/pygnt/gnt.override @ 18724:bfa12b00f54b

Export gnt_widget_get_size for pygnt. I tried to export _register_action, but it doesn't work.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 30 Jul 2007 20:24:04 +0000
parents 7389b597a812
children fae29ba432c8
line wrap: on
line source

%%
headers
#include <Python.h>
#include "pygobject.h"
#include "gnt.h"
#include "gntbindable.h"
#include "gntwidget.h"
#include "gntbox.h"
#include "gntbutton.h"
#include "gntcheckbox.h"
#include "gntcolors.h"
#include "gntcombobox.h"
#include "gntentry.h"
#include "gntfilesel.h"
#include "gntkeys.h"
#include "gntlabel.h"
#include "gntline.h"
#include "gntmenu.h"
#include "gntmenuitem.h"
#include "gntmenuitemcheck.h"
#include "gntslider.h"
#include "gntstyle.h"
#include "gnttextview.h"
#include "gnttree.h"
#include "gntutils.h"
#include "gntwindow.h"
#include "gntwm.h"
#include "gntws.h"
#include "common.h"
%%
include
 gntbox.override
 gntfilesel.override
 gnttree.override
 gntwidget.override
%%
modulename gnt
%%
import gobject.GObject as PyGObject_Type
%%
ignore-glob
	*_get_gtype
%%
define set_flag
static PyObject *
_wrap_set_flag(PyGObject *self, PyObject *args, PyObject *kwargs)
{
	static char *kwlist[] = {"flags", NULL};
	PyGObject *widget;
	int flags;

	if (!PyArg_ParseTuple(args, "O!i:gnt.set_flag", &PyGntWidget_Type, &widget,
				&flags)) {
		return NULL;
	}

	GNT_WIDGET_SET_FLAGS(widget->obj, flags);

	Py_INCREF(Py_None);
	return Py_None;
}
%%
define unset_flag
static PyObject *
_wrap_unset_flag(PyGObject *self, PyObject *args, PyObject *kwargs)
{
	static char *kwlist[] = {"flags", NULL};
	PyGObject *widget;
	int flags;

	if (!PyArg_ParseTuple(args, "O!i:gnt.unset_flag", &PyGntWidget_Type, &widget,
				&flags)) {
		return NULL;
	}

	GNT_WIDGET_UNSET_FLAGS(widget->obj, flags);

	Py_INCREF(Py_None);
	return Py_None;
}
%%
define screen_size noargs
static PyObject *
_wrap_screen_size(PyObject *self)
{
	PyObject *list = PyList_New(0);

	if (list == NULL)
		return NULL;

	PyList_Append(list, PyInt_FromLong((long)getmaxx(stdscr)));
	PyList_Append(list, PyInt_FromLong((long)getmaxy(stdscr)));

	return list;
}
%%
override gnt_register_action
static GHashTable *actions;



static PyObject *
_wrap_gnt_register_action(PyGObject *self, PyObject *args, PyObject *kwargs)
{
	static char *kwlist[] = {"name", "callback", NULL};
	PyGObject *callback;
	GClosure *closure;
	char *name;

	if (!PyArg_ParseTuple(args, "sO:gnt.gnt_register_action", &name, &callback)) {
		return NULL;
	}

	if (!PyCallable_Check(callback)) {
		PyErr_SetString(PyExc_TypeError, "the callback must be callable ... doh!");
		return NULL;
	}

	gnt_register_action(name, callback->obj);

	Py_INCREF(Py_None);
	return Py_None;
}