From 0ddbf7e9ab54157244fa3ee6abe892413680b87d Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 21 May 2007 15:36:08 +0000 Subject: Add the AddressEntry object to sugar --- (limited to 'sugar') diff --git a/sugar/Makefile.am b/sugar/Makefile.am index 937441c..93e548d 100644 --- a/sugar/Makefile.am +++ b/sugar/Makefile.am @@ -9,3 +9,39 @@ sugar_PYTHON = \ ltihooks.py \ profile.py \ util.py + +INCLUDES = \ + $(LIB_CFLAGS) \ + $(LIB_BINDINGS_CFLAGS) \ + $(PYTHON_INCLUDES) \ + -I$(top_srcdir)/lib + +pkgpyexecdir = $(pythondir)/sugar + +pkgpyexec_LTLIBRARIES = _sugarext.la + +_sugarext_la_LDFLAGS = -module -avoid-version +_sugarext_la_LIBADD = \ + $(LIB_BINDINGS_LIBS) \ + $(LIB_LIBS) \ + $(top_builddir)/lib/libsugar.la + +_sugarext_la_SOURCES = \ + _sugarextmodule.c + +nodist__sugarext_la_SOURCES = _sugarext.c + +_sugarext.c: _sugarext.defs _sugarext.override + +CLEANFILES = _sugarext.c +EXTRA_DIST = _sugarext.override _sugarext.defs + +.defs.c: + (cd $(srcdir)\ + && $(PYGTK_CODEGEN) \ + --register $(PYGTK_DEFSDIR)/gdk-types.defs \ + --register $(PYGTK_DEFSDIR)/gtk-types.defs \ + --override $*.override \ + --prefix py$* $*.defs) > gen-$*.c \ + && cp gen-$*.c $*.c \ + && rm -f gen-$*.c diff --git a/sugar/_sugarext.c b/sugar/_sugarext.c new file mode 100644 index 0000000..7c7c35a --- /dev/null +++ b/sugar/_sugarext.c @@ -0,0 +1,108 @@ +/* -- THIS FILE IS GENERATED - DO NOT EDIT *//* -*- Mode: C; c-basic-offset: 4 -*- */ + +#include + + + +#line 4 "_sugarext.override" +#include + +#include "pygobject.h" +#include "sugar-address-entry.h" + +#include +#include + +#line 17 "_sugarext.c" + + +/* ---------- types from other modules ---------- */ +static PyTypeObject *_PyGtkEntry_Type; +#define PyGtkEntry_Type (*_PyGtkEntry_Type) + + +/* ---------- forward type declarations ---------- */ +PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type; + +#line 28 "_sugarext.c" + + + +/* ----------- SugarAddressEntry ----------- */ + +PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "_sugarext.AddressEntry", /* tp_name */ + sizeof(PyGObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)0, /* tp_dealloc */ + (printfunc)0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ + (cmpfunc)0, /* tp_compare */ + (reprfunc)0, /* tp_repr */ + (PyNumberMethods*)0, /* tp_as_number */ + (PySequenceMethods*)0, /* tp_as_sequence */ + (PyMappingMethods*)0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)0, /* tp_str */ + (getattrofunc)0, /* tp_getattro */ + (setattrofunc)0, /* tp_setattro */ + (PyBufferProcs*)0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + NULL, /* Documentation string */ + (traverseproc)0, /* tp_traverse */ + (inquiry)0, /* tp_clear */ + (richcmpfunc)0, /* tp_richcompare */ + offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */ + (getiterfunc)0, /* tp_iter */ + (iternextfunc)0, /* tp_iternext */ + (struct PyMethodDef*)NULL, /* tp_methods */ + (struct PyMemberDef*)0, /* tp_members */ + (struct PyGetSetDef*)0, /* tp_getset */ + NULL, /* tp_base */ + NULL, /* tp_dict */ + (descrgetfunc)0, /* tp_descr_get */ + (descrsetfunc)0, /* tp_descr_set */ + offsetof(PyGObject, inst_dict), /* tp_dictoffset */ + (initproc)0, /* tp_init */ + (allocfunc)0, /* tp_alloc */ + (newfunc)0, /* tp_new */ + (freefunc)0, /* tp_free */ + (inquiry)0 /* tp_is_gc */ +}; + + + +/* ----------- functions ----------- */ + +const PyMethodDef py_sugarext_functions[] = { + { NULL, NULL, 0, NULL } +}; + +/* initialise stuff extension classes */ +void +py_sugarext_register_classes(PyObject *d) +{ + PyObject *module; + + if ((module = PyImport_ImportModule("gtk")) != NULL) { + _PyGtkEntry_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Entry"); + if (_PyGtkEntry_Type == NULL) { + PyErr_SetString(PyExc_ImportError, + "cannot import name Entry from gtk"); + return ; + } + } else { + PyErr_SetString(PyExc_ImportError, + "could not import gtk"); + return ; + } + + +#line 107 "_sugarext.c" + pygobject_register_class(d, "SugarAddressEntry", SUGAR_TYPE_ADDRESS_ENTRY, &PySugarAddressEntry_Type, Py_BuildValue("(O)", &PyGtkEntry_Type)); +} diff --git a/sugar/_sugarext.defs b/sugar/_sugarext.defs new file mode 100644 index 0000000..e35a6c9 --- /dev/null +++ b/sugar/_sugarext.defs @@ -0,0 +1,9 @@ +;; -*- scheme -*- +; object definitions ... + +(define-object AddressEntry + (in-module "Sugar") + (parent "GtkEntry") + (c-name "SugarAddressEntry") + (gtype-id "SUGAR_TYPE_ADDRESS_ENTRY") +) diff --git a/sugar/_sugarext.override b/sugar/_sugarext.override new file mode 100644 index 0000000..a732581 --- /dev/null +++ b/sugar/_sugarext.override @@ -0,0 +1,20 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +headers +#include + +#include "pygobject.h" +#include "sugar-address-entry.h" + +#include +#include + +%% +modulename _sugarext +%% +import gtk.Entry as PyGtkEntry_Type +%% +ignore-glob + *_get_type + _* +%% diff --git a/sugar/_sugarextmodule.c b/sugar/_sugarextmodule.c new file mode 100644 index 0000000..e813e00 --- /dev/null +++ b/sugar/_sugarextmodule.c @@ -0,0 +1,27 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* include this first, before NO_IMPORT_PYGOBJECT is defined */ +#include + +void py_sugarext_register_classes (PyObject *d); + +extern PyMethodDef py_sugarext_functions[]; + +DL_EXPORT(void) +init_sugarext(void) +{ + PyObject *m, *d; + + init_pygobject (); + + m = Py_InitModule ("_sugarext", py_sugarext_functions); + d = PyModule_GetDict (m); + + py_sugarext_register_classes (d); + + if (PyErr_Occurred ()) { + Py_FatalError ("can't initialise module _sugarext"); + } +} -- cgit v0.9.1