1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#!/usr/bin/python
import string
objects = ( "AccelLabel", "Adjustment", "Alignment", "Arrow",
"AspectFrame", "Bin", "Box", "Button", "ButtonBox", "CheckButton",
"CheckMenuItem", "CList", "CTree", "ColorSelection",
"ColorSelectionDialog", "Combo", "Container", "Curve", "Data",
"Dialog", "DrawingArea", "Editable", "Entry", "EventBox",
"FileSelection", "Fixed", "FontSelection", "FontSelectionDialog",
"Frame", "GammaCurve", "HandleBox", "HBox", "HButtonBox", "HPaned",
"HRuler", "HScale", "HScrollbar", "HSeparator", "Image",
"InputDialog", "Item", "ItemFactory", "Label", "List", "ListItem",
"Menu", "MenuBar", "MenuItem", "MenuShell", "Misc", "Notebook",
"Object", "OptionMenu", "Packer", "Paned", "Pixmap", "Preview",
"Progress", "ProgressBar", "RadioButton", "RadioMenuItem", "Range",
"Ruler", "Scale", "Scrollbar", "ScrolledWindow", "Separator",
"SpinButton", "Statusbar", "Table", "TearoffMenuItem", "Text",
"TipsQuery", "ToggleButton", "Toolbar", "Tooltips", "Tree",
"TreeItem", "VBox", "VButtonBox", "Viewport", "VPaned", "VRuler",
"VScale", "VScrollbar", "VSeparator", "Widget", "Window" )
f = open("obj_typemap.i", "w")
f.write("# typemaps for Gtk objects to Python equivalents\n\n");
for obj in objects:
OBJ = ''
for c in obj:
if c in string.uppercase:
OBJ = OBJ + '_' + c
else:
OBJ = OBJ + string.upper(c)
if obj == 'CList': OBJ = '_CLIST'
if obj == 'CTree': OBJ = '_CTREE'
f.write("%%typemap(python,in) Gtk%s * {\n" % (obj,))
f.write(" if (PyGtk_Check($source))\n")
f.write(" $target = GTK%s(PyGtk_Get($source));\n" % (OBJ,))
f.write(" else {\n")
f.write(' PyErr_SetString(PyExc_TypeError, "object not a Gtk Object");\n')
f.write(" return NULL;\n")
f.write(" }\n")
f.write(" }\n\n")
f.write("%%typemap(python,out) Gtk%s * {\n" % (obj,))
f.write(" $target = PyGtk_New((GtkObject *)$source);\n")
f.write(" }\n\n")
f.close()
|