Thread: [Python-gtkextra-commits] CVS: python-gtkextra2/gtkextra ltihooks.py,NONE,1.1 Makefile.am,1.4,1.5 gt
Status: Beta
Brought to you by:
treeves
Update of /cvsroot/python-gtkextra/python-gtkextra2/gtkextra In directory sc8-pr-cvs1:/tmp/cvs-serv4818/gtkextra Modified Files: Makefile.am gtkextra-addons.defs gtkextra-types.defs gtkextra.defs gtkextra.override gtkextramodule.c Added Files: ltihooks.py Log Message: Working toward first release. Much works correctly now. --- NEW FILE: ltihooks.py --- # -*- Mode: Python; py-indent-offset: 4 -*- # ltihooks.py: python import hooks that understand libtool libraries. # Copyright (C) 2000 James Henstridge. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import os, ihooks class LibtoolHooks(ihooks.Hooks): def get_suffixes(self): """Like normal get_suffixes, but adds .la suffixes to list""" ret = ihooks.Hooks.get_suffixes(self) ret.insert(0, ('module.la', 'rb', 3)) ret.insert(0, ('.la', 'rb', 3)) return ret def load_dynamic(self, name, filename, file=None): """Like normal load_dynamic, but treat .la files specially""" if len(filename) > 3 and filename[-3:] == '.la': fp = open(filename, 'r') dlname = '' installed = 1 line = fp.readline() while line: if len(line) > 7 and line[:7] == 'dlname=': dlname = line[8:-2] elif len(line) > 10 and line[:10] == 'installed=': installed = line[10:-1] == 'yes' line = fp.readline() fp.close() if dlname: if installed: filename = os.path.join(os.path.dirname(filename), dlname) else: filename = os.path.join(os.path.dirname(filename), '.libs', dlname) return ihooks.Hooks.load_dynamic(self, name, filename, file) importer = ihooks.ModuleImporter() importer.set_hooks(LibtoolHooks()) def install(): importer.install() def uninstall(): importer.uninstall() install() Index: Makefile.am =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra2/gtkextra/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.am 22 Jul 2002 13:06:54 -0000 1.4 --- Makefile.am 24 Dec 2002 18:49:10 -0000 1.5 *************** *** 19,29 **** # gtkextra module #GTKEXTRA_LIBS=-lgtkextra-x11-1.1 #DOES NOT WORK ! pygtkextraexec_LTLIBRARIES = gtkextramodule.la ! gtkextramodule_la_CFLAGS = $(PYGTK_CFLAGS) $(GTK_CFLAGS) $(GTKEXTRA_CFLAGS) ! gtkextramodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex initgtkextra ! gtkextramodule_la_LIBADD = $(GTKEXTRA_LIBS) $(PYGTK_LIBS) $(GTK_LIBS) ! gtkextramodule_la_SOURCES = gtkextramodule.c gtkextra.c: $(COMMONDEFS) gtkextra-addons.defs gtkextra-types.defs gtkextra.override ! nodist_gtkextramodule_la_SOURCES = gtkextra.c CLEANFILES += gtkextra.c --- 19,29 ---- # gtkextra module #GTKEXTRA_LIBS=-lgtkextra-x11-1.1 #DOES NOT WORK ! pygtkextraexec_LTLIBRARIES = _gtkextramodule.la ! _gtkextramodule_la_CFLAGS = $(PYGTK_CFLAGS) $(GTK_CFLAGS) $(GTKEXTRA_CFLAGS) ! _gtkextramodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex initgtkextra ! _gtkextramodule_la_LIBADD = $(GTKEXTRA_LIBS) $(PYGTK_LIBS) $(GTK_LIBS) ! _gtkextramodule_la_SOURCES = gtkextramodule.c gtkextra.c: $(COMMONDEFS) gtkextra-addons.defs gtkextra-types.defs gtkextra.override ! nodist__gtkextramodule_la_SOURCES = gtkextra.c CLEANFILES += gtkextra.c Index: gtkextra-addons.defs =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra2/gtkextra/gtkextra-addons.defs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gtkextra-addons.defs 16 Jul 2002 17:05:14 -0000 1.2 --- gtkextra-addons.defs 24 Dec 2002 18:49:10 -0000 1.3 *************** *** 20,22 **** --- 20,26 ---- ) + (define-function _set_data_from_pyobject_callback + (c-name "_set_data_from_pyobject_callback") + ) + Index: gtkextra-types.defs =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra2/gtkextra/gtkextra-types.defs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gtkextra-types.defs 16 Jul 2002 17:05:15 -0000 1.3 --- gtkextra-types.defs 24 Dec 2002 18:49:10 -0000 1.4 *************** *** 131,134 **** --- 131,144 ---- (parent "GtkWidget") (c-name "GtkPlotData") + (fields + '("gdouble*" "x") + '("gdouble*" "dx") + '("gdouble*" "y") + '("gdouble*" "dy") + '("gdouble*" "z") + '("gdouble*" "dz") + '("gdouble*" "a") + '("gdouble*" "da") + ) (gtype-id "GTK_TYPE_PLOT_DATA") ) *************** *** 239,242 **** --- 249,263 ---- ; Also gtkextra code needs all of those boxed fixed up with types and macros. + (define-boxed GtkPlotLine + (in-module "Gtk") + (c-name "GtkPlotLine") + (gtype-id "GTK_TYPE_PLOT_LINE") + (fields + '("GtkPlotLineStyle" "line_style") + '("GdkCapStyle" "cap_style") + '("GdkJoinStyle" "join_style") + ) + ) + (define-boxed PlotText (in-module "Gtk") *************** *** 273,276 **** --- 294,308 ---- ;; Enumerations and flags ... + (define-enum IconListMode + (in-module "Gtk") + (c-name "GtkIconListMode") + (gtype-id "GTK_TYPE_ICON_LIST_MODE") + (values + '("icon" "GTK_ICON_LIST_ICON") + '("text-right" "GTK_ICON_LIST_TEXT_RIGHT") + '("text-below" "GTK_ICON_LIST_TEXT_BELOW") + ) + ) + (define-enum PlotPlane (in-module "Gtk") *************** *** 407,410 **** --- 439,453 ---- ) + (define-enum PlotProjection + (in-module "Gtk") + (c-name "GtkPlotProjection") + (gtype-id "GTK_TYPE_PLOT_PROJECTION") + (values + '("none" "GTK_PLOT_PROJECT_NONE") + '("empty" "GTK_PLOT_PROJECT_EMPTY") + '("full" "GTK_PLOT_PROJECT_FULL") + ) + ) + (define-enum PlotScale (in-module "Gtk") *************** *** 555,558 **** --- 598,636 ---- ) + (define-enum PlotPageSize + (in-module "Gtk") + (c-name "GtkPlotPageSize") + (gtype-id "GTK_TYPE_PLOT_PAGE_SIZE") + (values + '("letter" "GTK_PLOT_LETTER") + '("legal" "GTK_PLOT_LEGAL") + '("a4" "GTK_PLOT_A4") + '("executive" "GTK_PLOT_EXECUTIVE") + '("custom" "GTK_PLOT_CUSTOM") + ) + ) + + (define-enum PlotPageOrientation + (in-module "Gtk") + (c-name "GtkPlotPageOrientation") + (gtype-id "GTK_TYPE_PLOT_PAGE_ORIENTATION") + (values + '("portrait" "GTK_PLOT_PORTRAIT") + '("landscape" "GTK_PLOT_LANDSCAPE") + ) + ) + + (define-enum PlotUnits + (in-module "Gtk") + (c-name "GtkPlotUnits") + (gtype-id "GTK_TYPE_PLOT_UNITS") + (values + '("pspoints" "GTK_PLOT_PSPOINTS") + '("mm" "GTK_PLOT_MM") + '("cm" "GTK_PLOT_CM") + '("inches" "GTK_PLOT_INCHES") + ) + ) + (define-enum SheetAttrType (in-module "Gtk") *************** *** 570,573 **** ) ) - - --- 648,649 ---- Index: gtkextra.defs =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra2/gtkextra/gtkextra.defs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gtkextra.defs 22 Jul 2002 13:06:55 -0000 1.5 --- gtkextra.defs 24 Dec 2002 18:49:10 -0000 1.6 *************** *** 1,13 **** ;; -*- scheme -*- ! ;; Use newer cvs version not what is stock on RH 7.3 ! ;; python2 ~/gnome-cvs/gnome-python/pygtk/codegen/h2def.py /usr/include/gtk-2.0/gtkextra/*.h >gtkextra_.defs ! ;; Then merge old defs with new defs with mergedefs.py (for fields) (include "gtkextra-types.defs") (include "gtkextra-addons.defs") - ;; From /usr/include/gtk-2.0/gtkextra/gtkbordercombo.h [...1586 lines suppressed...] (define-function gtk_toggle_combo_new - (c-name "gtk_toggle_combo_new") (is-constructor-of "GtkToggleCombo") (return-type "GtkWidget*") (parameters --- 5980,5985 ---- (define-function gtk_toggle_combo_new (is-constructor-of "GtkToggleCombo") + (c-name "gtk_toggle_combo_new") (return-type "GtkWidget*") (parameters *************** *** 5914,5917 **** ) ) - --- 6030,6032 ---- Index: gtkextra.override =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra2/gtkextra/gtkextra.override,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gtkextra.override 22 Jul 2002 13:06:55 -0000 1.5 --- gtkextra.override 24 Dec 2002 18:49:10 -0000 1.6 *************** *** 30,33 **** --- 30,60 ---- #include <gtkextra/gtkextratypebuiltins.h> + static PyObject *pygtkextra_data_from_pyobject_callback = NULL; + + /* + This exists in pygtk/gtk/gtk-types.c. It is not static there, but + is exported for our use. Especially since dlopen is now not done + with RTLD_GLOBAL flags by default. Might wish to ask James if it + could be published or if there is another way. + */ + + static gboolean + pygdk_rectangle_from_pyobject(PyObject *object, GdkRectangle *rectangle) + { + g_return_val_if_fail(rectangle != NULL, FALSE); + + if (pyg_boxed_check(object, GDK_TYPE_RECTANGLE)) { + *rectangle = *pyg_boxed_get(object, GdkRectangle); + return TRUE; + } + if (PyArg_ParseTuple(object, "iiii", &rectangle->x, &rectangle->y, + &rectangle->width, &rectangle->height)) { + return TRUE; + } + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError, "could not convert to GdkRectangle"); + return FALSE; + } + /* ---------------------------------------------------------------------- Fixup boo-boo's or ommissions. Probably should be fixed in gtkextra. *************** *** 42,46 **** #define GTK_TYPE_TOGGLE_COMBO (gtk_toggle_combo_get_type()) ! /* Hack boxed types. Just enought to let code generator compile. Not correct! These and lots more need to be fixed in gtkextra code. A good example is GtkIconSet in gtkiconfactory.[hc]. --- 69,73 ---- #define GTK_TYPE_TOGGLE_COMBO (gtk_toggle_combo_get_type()) ! /* Hack boxed types. Just enough to let code generator compile. Not correct! These and lots more need to be fixed in gtkextra code. A good example is GtkIconSet in gtkiconfactory.[hc]. *************** *** 53,56 **** --- 80,84 ---- */ + #define GTK_TYPE_PSFONT (gtk_psfont_get_type ()) static GType *************** *** 83,86 **** --- 111,131 ---- } + #define GTK_TYPE_PLOT_LINE (gtk_plot_line_get_type ()) + static GType + gtk_plot_line_get_type (void) + { + static GType our_type = 0; + + #if 1 //HACK + if (our_type == 0) + our_type = g_pointer_type_register_static ("GtkPlotLine"); + #else //Should be something similiar to this + if (our_type == 0) + our_type = g_boxed_type_register_static ("GtkPlotLine", + (GBoxedCopyFunc) gtk_plot_line_ref, + (GBoxedFreeFunc) gtk_plot_line_unref); + #endif + return our_type; + } static void *************** *** 90,93 **** --- 135,149 ---- } + static void + gtk_plot_draw_line_PY (GtkPlot *plot, GtkPlotLine *line, gdouble x1, gdouble y1, gdouble x2, gdouble y2) + { + gtk_plot_draw_line(plot, *line, x1, y1, x2, y2); + } + + static void + gtk_plot_set_line_attributes_PY (GtkPlot *plot, GtkPlotLine *line) + { + gtk_plot_set_line_attributes (plot, *line); + } /* This one is probably an "error" in h2def.py */ *************** *** 97,102 **** guint16 gtk_plot_canvas_unset_flags(GtkPlotCanvas *canvas, guint16 flags) { return GTK_PLOT_CANVAS_UNSET_FLAGS(canvas, flags); } ! /* cpp abuse. ! */ #define _GET_ONE_DOUBLE(_f, _c) static PyObject * \ _wrap_##_f(PyGObject *self) \ --- 153,157 ---- guint16 gtk_plot_canvas_unset_flags(GtkPlotCanvas *canvas, guint16 flags) { return GTK_PLOT_CANVAS_UNSET_FLAGS(canvas, flags); } ! /* cpp abuse */ #define _GET_ONE_DOUBLE(_f, _c) static PyObject * \ _wrap_##_f(PyGObject *self) \ *************** *** 115,228 **** } - #define _GET_ONE_DOUBLE_VEC(_f, _c) static PyObject * \ - _wrap_##_f(PyGObject *self) \ - { \ - PyObject *py_ret; \ - gdouble *p_d; \ - gint len_d; \ - \ - p_d = _f(_c(self->obj), &len_d); \ - \ - if( !(py_ret = pygtkextra_vec2py(len_d, p_d))) \ - return NULL; \ - \ - return py_ret; \ - } - - /* ---------------------------------------------------------------------- - Functions for converting Python sequence like objects To/From C arrays. - The C arrays are limited to either type gdouble* or gint*. - - This is very limited for now. It will grow to include NumPy and some - generic object get/set method look-up and use. - - May desire to more this out to separate file. - - May reuse large parts of Andreas Voegele's code here. May not. - I have to first become more familiar with the gtkextra C code. - - For now, I'll just leak.... - - Also, not doing iterators or function dataset's (yet). - - */ int ! pygtkextra_py2vec(PyObject *sequence, gint *p_n, gdouble **p_points) { ! int n = 0; ! gdouble *points = NULL; ! *p_n = 0; *p_points = NULL; ! if (sequence == Py_None || sequence == NULL) { ! /* done */ } - else if (PySequence_Check(sequence)) { - n = PySequence_Length(sequence); - if (n > 0) { - int i; - - points = g_new(gdouble, n); - for (i = 0; i < n; ++i) { - PyObject *item, *value; ! item = PySequence_GetItem(sequence, i); ! if (PyFloat_Check(item)) { ! points[i] = PyFloat_AS_DOUBLE(item); ! } else if (PyNumber_Check(item) ! && (value = PyNumber_Float(item))) { ! points[i] = PyFloat_AS_DOUBLE(value); ! Py_DECREF(value); ! } else { ! #if 1 ! PyErr_SetString(PyExc_TypeError, ! "sequence items must be numbers"); ! #endif ! Py_DECREF(item); ! g_free(points); ! return -1; ! } ! Py_DECREF(item); ! } ! } ! } ! #if 1 ! else { ! PyErr_SetString(PyExc_TypeError, "argument must be sequence or None"); ! return -2; } ! #endif ! *p_points = points; ! *p_n = n; return 0; } ! ! PyObject * ! pygtkextra_vec2py(const gint n, const gdouble *points) { ! PyObject *sequence; ! ! int i; ! if (points == NULL) { ! Py_INCREF(Py_None); ! return Py_None; ! } ! ! if ( !(sequence=PyList_New((int) n)) ) ! return NULL; ! for(i=0; i<n; i++) { ! PyObject *value; ! ! value = PyFloat_FromDouble(points[i]); ! if (!value) { ! Py_DECREF(sequence); ! return NULL; ! } ! PyList_SET_ITEM(sequence, i, value); ! } ! return sequence; } --- 170,226 ---- } int ! pygtkextra_data_from_pyobject(PyObject **out_obj, PyObject *in_obj, gint *p_n, gdouble **p_points) { ! *out_obj = NULL; *p_n = 0; *p_points = NULL; ! if ( !in_obj || (in_obj == Py_None )) { ! *out_obj = Py_None; ! Py_INCREF(Py_None); ! return 0; } ! /* ! Use the stored callback to convert into needed format. ! */ ! PyObject *arglist, *result; ! if ( !pygtkextra_data_from_pyobject_callback ) { ! PyErr_SetString(PyExc_TypeError, "There is no data callback function registered."); ! return -1; } ! arglist = Py_BuildValue("(O)", in_obj); ! result = PyEval_CallObject(pygtkextra_data_from_pyobject_callback, arglist); ! Py_DECREF(arglist); ! ! if ( !result || !PyTuple_Check(result) || PyObject_Length(result) != 3) { ! PyErr_SetString(PyExc_TypeError, "callback must return (in_obj, buffer, buffer_len)"); ! return -1; ! } ! ! *out_obj = PyTuple_GET_ITEM(result, 0); ! *p_points = (double*) PyLong_AsLong(PyTuple_GET_ITEM(result, 1)); ! *p_n = PyInt_AsLong(PyTuple_GET_ITEM(result, 2)); ! ! Py_INCREF(*out_obj); /* We now own a reference before tuple is destroyed. */ ! Py_DECREF(result); return 0; } ! static int ! pygtkextra_set_data(PyGObject *gobj, const char *key, PyObject *pobj) { ! PyObject *result = PyObject_CallMethod( (PyObject*) gobj, "set_data", "(sO)", key, pobj); ! if ( !result ) ! return -1; ! Py_DECREF(result); /* was Py_None */ ! return 0; ! } ! static PyObject * ! pygtkextra_get_data(PyGObject *gobj, const char *key) ! { ! return PyObject_CallMethod( (PyObject*) gobj, "get_data", "(s)", key); } *************** *** 270,273 **** --- 268,272 ---- import gtk.gdk.Pixmap as PyGdkPixmap_Type import gtk.gdk.Drawable as PyGdkDrawable_Type + import gtk.gdk.Rectangle as PyGdkRectangle_Type import gtk._gtk.Widget as PyGtkWidget_Type import gtk._gtk.Object as PyGtkObject_Type *************** *** 281,285 **** import gtk._gtk.Adjustment as PyGtkAdjustment_Type import gtk._gtk.HBox as PyGtkHBox_Type - %% override gtk_psfont_get_char_size --- 280,283 ---- *************** *** 290,294 **** return NULL; } - %% override-attr GtkPlotCanvasChild.data --- 288,291 ---- *************** *** 314,318 **** } } - %% override gtk_plot_data_set_points kwargs --- 311,314 ---- *************** *** 320,328 **** _wrap_gtk_plot_data_set_points(PyGObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = { "x", "dx", "y", "dy", "z", "dz", "a", "da", NULL }; gdouble *x = NULL, *y = NULL, *dx = NULL, *dy = NULL, *z = NULL, *dz = NULL, *a = NULL, *da = NULL; PyObject *py_x = NULL, *py_y = NULL, *py_z = NULL, *py_a = NULL; PyObject *py_dx = NULL, *py_dy = NULL, *py_dz = NULL, *py_da = NULL; ! int rx, nx, rdx, ndx, ry, ny, rdy, ndy, rz, nz, rdz, ndz, ra, na, rda, nda; gint num_points=0; --- 316,335 ---- _wrap_gtk_plot_data_set_points(PyGObject *self, PyObject *args, PyObject *kwargs) { + /* + Treat kwargs as a complete data set. + If a key is specified set value. + If a key is not specified clear value. + */ + static char *kwlist[] = { "x", "dx", "y", "dy", "z", "dz", "a", "da", NULL }; gdouble *x = NULL, *y = NULL, *dx = NULL, *dy = NULL, *z = NULL, *dz = NULL, *a = NULL, *da = NULL; PyObject *py_x = NULL, *py_y = NULL, *py_z = NULL, *py_a = NULL; PyObject *py_dx = NULL, *py_dy = NULL, *py_dz = NULL, *py_da = NULL; ! ! PyObject *py_x_out = NULL, *py_y_out = NULL, *py_z_out = NULL, *py_a_out = NULL; ! PyObject *py_dx_out = NULL, *py_dy_out = NULL, *py_dz_out = NULL, *py_da_out = NULL; ! ! int nx, ndx, ny, ndy, nz, ndz, na, nda; ! int rx, rdx, ry, rdy, rz, rdz, ra, rda; gint num_points=0; *************** *** 331,350 **** return NULL; ! rx = pygtkextra_py2vec( py_x, &nx, &x ); ! ry = pygtkextra_py2vec( py_y, &ny, &y ); ! rz = pygtkextra_py2vec( py_z, &nz, &z ); ! ra = pygtkextra_py2vec( py_a, &na, &a ); ! rdx = pygtkextra_py2vec( py_dx, &ndx, &dx ); ! rdy = pygtkextra_py2vec( py_dy, &ndy, &dy ); ! rdz = pygtkextra_py2vec( py_dz, &ndz, &dz ); ! rda = pygtkextra_py2vec( py_da, &nda, &da ); printf("n: %d %d %d %d %d %d %d %d\n", nx, ny, ndx, ndy, nz, ndz, na, nda); printf("r: %d %d %d %d %d %d %d %d\n", rx, ry, rdx, rdy, rz, rdz, ra, rda); ! if ( (rx < 0) || (ry < 0) || (rdx < 0) || (rdy < 0) ! || (rz < 0) || (rdz < 0) || (rda < 0) || (rda < 0) ) ! return NULL; num_points = MAX(nx, ndx); num_points = MAX(num_points, ny); --- 338,360 ---- return NULL; ! rx = pygtkextra_data_from_pyobject( &py_x_out, py_x, &nx, &x); ! ry = pygtkextra_data_from_pyobject( &py_y_out, py_y, &ny, &y ); ! rz = pygtkextra_data_from_pyobject( &py_z_out, py_z, &nz, &z ); ! ra = pygtkextra_data_from_pyobject( &py_a_out, py_a, &na, &a ); ! rdx = pygtkextra_data_from_pyobject( &py_dx_out, py_dx, &ndx, &dx ); ! rdy = pygtkextra_data_from_pyobject( &py_dy_out, py_dy, &ndy, &dy ); ! rdz = pygtkextra_data_from_pyobject( &py_dz_out, py_dz, &ndz, &dz ); ! rda = pygtkextra_data_from_pyobject( &py_da_out, py_da, &nda, &da ); + #if defined(_DEBUG) printf("n: %d %d %d %d %d %d %d %d\n", nx, ny, ndx, ndy, nz, ndz, na, nda); printf("r: %d %d %d %d %d %d %d %d\n", rx, ry, rdx, rdy, rz, rdz, ra, rda); ! #endif if ( (rx < 0) || (ry < 0) || (rdx < 0) || (rdy < 0) ! || (rz < 0) || (rdz < 0) || (rda < 0) || (rda < 0) ) { ! goto do_err; ! } ! num_points = MAX(nx, ndx); num_points = MAX(num_points, ny); *************** *** 355,358 **** --- 365,372 ---- num_points = MAX(num_points, nda); + #if defined(_DEBUG) + printf("num+_points = %d\n", num_points); + #endif + if ( (rx && (nx != num_points)) || (rdx && (ndx != num_points)) *************** *** 364,446 **** || (rda && (nda != num_points)) ) { PyErr_SetString(PyExc_TypeError, "argments must have same length"); } gtk_plot_data_set_numpoints(GTK_PLOT_DATA(self->obj), num_points); ! if (py_x) gtk_plot_data_set_x (GTK_PLOT_DATA(self->obj), x); ! if (py_dx) gtk_plot_data_set_dx (GTK_PLOT_DATA(self->obj), dx); ! if (py_y) gtk_plot_data_set_y (GTK_PLOT_DATA(self->obj), y); ! if (py_dy) gtk_plot_data_set_dy (GTK_PLOT_DATA(self->obj), dy); ! if (py_z) gtk_plot_data_set_z (GTK_PLOT_DATA(self->obj), z); ! if (py_dz) gtk_plot_data_set_dz (GTK_PLOT_DATA(self->obj), dz); ! if (py_a) gtk_plot_data_set_a (GTK_PLOT_DATA(self->obj), a); ! if (py_da) gtk_plot_data_set_da (GTK_PLOT_DATA(self->obj), da); Py_INCREF(Py_None); return Py_None; - } %% ! override gtk_plot_data_get_points noargs static PyObject * ! _wrap_gtk_plot_data_get_points(PyGObject *self) { ! PyObject *py_x, *py_y, *py_dx, *py_dy; ! gdouble *x, *y, *dx, *dy; ! gint num_points; ! ! gtk_plot_data_get_points(GTK_PLOT_DATA(self->obj), &x, &y, &dx, &dy, &num_points); ! ! if( !(py_x = pygtkextra_vec2py(num_points, x))) ! return NULL; ! if( !(py_y = pygtkextra_vec2py(num_points, y))) { ! Py_DECREF(py_x); ! return NULL; ! } ! if( !(py_dx = pygtkextra_vec2py(num_points, dx))) { ! Py_DECREF(py_x); ! Py_DECREF(py_y); ! return NULL; ! } ! if( !(py_dy = pygtkextra_vec2py(num_points, dy))) { ! Py_DECREF(py_x); ! Py_DECREF(py_y); ! Py_DECREF(py_dx); ! return NULL; ! } ! return Py_BuildValue("(OOOO)", py_x, py_y, py_dx, py_dy); } - %% ! override gtk_plot_data_get_x noargs ! _GET_ONE_DOUBLE_VEC(gtk_plot_data_get_x, GTK_PLOT_DATA) ! %% ! override gtk_plot_data_get_y noargs ! _GET_ONE_DOUBLE_VEC(gtk_plot_data_get_y, GTK_PLOT_DATA) ! %% ! override gtk_plot_data_get_z noargs ! _GET_ONE_DOUBLE_VEC(gtk_plot_data_get_z, GTK_PLOT_DATA) ! %% ! override gtk_plot_data_get_a noargs ! _GET_ONE_DOUBLE_VEC(gtk_plot_data_get_a, GTK_PLOT_DATA) ! %% ! override gtk_plot_data_get_dx noargs ! _GET_ONE_DOUBLE_VEC(gtk_plot_data_get_dx, GTK_PLOT_DATA) ! %% ! override gtk_plot_data_get_dy noargs ! _GET_ONE_DOUBLE_VEC(gtk_plot_data_get_dy, GTK_PLOT_DATA) ! %% ! override gtk_plot_data_get_dz noargs ! _GET_ONE_DOUBLE_VEC(gtk_plot_data_get_dz, GTK_PLOT_DATA) ! %% ! override gtk_plot_data_get_da noargs ! _GET_ONE_DOUBLE_VEC(gtk_plot_data_get_da, GTK_PLOT_DATA) ! %% override gtk_plot_canvas_get_active_point noargs --- 378,492 ---- || (rda && (nda != num_points)) ) { PyErr_SetString(PyExc_TypeError, "argments must have same length"); + goto do_err; } gtk_plot_data_set_numpoints(GTK_PLOT_DATA(self->obj), num_points); ! ! #define _DO_ONE(_x) \ ! if ( pygtkextra_set_data(self, #_x, py_ ## _x ## _out) ) \ ! goto do_err; \ ! Py_DECREF(py_ ## _x ##_out); \ ! gtk_plot_data_set_ ## _x (GTK_PLOT_DATA(self->obj), _x); \ ! ! _DO_ONE(x); ! _DO_ONE(dx); ! _DO_ONE(y); ! _DO_ONE(dy); ! _DO_ONE(z); ! _DO_ONE(dz); ! _DO_ONE(a); ! _DO_ONE(da); ! ! #undef _DO_ONE Py_INCREF(Py_None); return Py_None; + do_err: + Py_XDECREF(py_x_out); + Py_XDECREF(py_dx_out); + Py_XDECREF(py_y_out); + Py_XDECREF(py_dy_out); + Py_XDECREF(py_z_out); + Py_XDECREF(py_dz_out); + Py_XDECREF(py_a_out); + Py_XDECREF(py_da_out); + return NULL; + } %% ! override-attr GtkPlotData.x static PyObject * ! _wrap_gtk_plot_data__get_x(PyGObject *self, void *closure) { ! return pygtkextra_get_data(self, "x"); } %% ! override-attr GtkPlotData.dx ! static PyObject * ! _wrap_gtk_plot_data__get_dx(PyGObject *self, void *closure) ! { ! return pygtkextra_get_data(self, "dx"); ! } %% ! override-attr GtkPlotData.y ! static PyObject * ! _wrap_gtk_plot_data__get_y(PyGObject *self, void *closure) ! { ! return pygtkextra_get_data(self, "y"); ! } %% ! override-attr GtkPlotData.dy ! static PyObject * ! _wrap_gtk_plot_data__get_dy(PyGObject *self, void *closure) ! { ! return pygtkextra_get_data(self, "dy"); ! } %% ! override-attr GtkPlotData.z ! static PyObject * ! _wrap_gtk_plot_data__get_z(PyGObject *self, void *closure) ! { ! return pygtkextra_get_data(self, "z"); ! } %% ! override-attr GtkPlotData.dz ! static PyObject * ! _wrap_gtk_plot_data__get_dz(PyGObject *self, void *closure) ! { ! return pygtkextra_get_data(self, "dz"); ! } %% ! override-attr GtkPlotData.a ! static PyObject * ! _wrap_gtk_plot_data__get_a(PyGObject *self, void *closure) ! { ! return pygtkextra_get_data(self, "a"); ! } %% ! override-attr GtkPlotData.da ! static PyObject * ! _wrap_gtk_plot_data__get_da(PyGObject *self, void *closure) ! { ! return pygtkextra_get_data(self, "da"); ! } %% ! ignore ! gtk_plot_data_get_points ! gtk_plot_data_get_x ! gtk_plot_data_get_dx ! gtk_plot_data_get_y ! gtk_plot_data_get_dy ! gtk_plot_data_get_z ! gtk_plot_data_get_dz ! gtk_plot_data_get_a ! gtk_plot_data_get_da ! gtk_plot_data_set_x ! gtk_plot_data_set_dx ! gtk_plot_data_set_y ! gtk_plot_data_set_dy ! gtk_plot_data_set_z ! gtk_plot_data_set_dz ! gtk_plot_data_set_a ! gtk_plot_data_set_da %% override gtk_plot_canvas_get_active_point noargs *************** *** 454,474 **** return Py_BuildValue("(idd)", (int) active_point, (double) x, (double) y); } %% override gtk_plot_get_xrange noargs _GET_TWO_DOUBLE(gtk_plot_get_xrange, GTK_PLOT) ! %% override gtk_plot_get_position noargs _GET_TWO_DOUBLE(gtk_plot_get_position, GTK_PLOT) - %% override gtk_plot_get_size noargs _GET_TWO_DOUBLE(gtk_plot_get_size, GTK_PLOT) %% ignore-glob *_get_type - %% - ignore - triangulate --- 500,694 ---- return Py_BuildValue("(idd)", (int) active_point, (double) x, (double) y); } + %% + override gtk_color_combo_find_color + static PyObject * + _wrap_gtk_color_combo_find_color(PyGObject *self, PyObject *args) + { + int row, col; + GdkColor *color = NULL; + PyObject *py_color = NULL; + if (!PyArg_ParseTuple(args, "O", &py_color)) { + return NULL; + } + if (pyg_boxed_check(py_color, GDK_TYPE_COLOR)) + color = pyg_boxed_get(py_color, GdkColor); + else { + PyErr_SetString(PyExc_TypeError, "color should be a GdkColor"); + return NULL; + } + gtk_color_combo_find_color(GTK_COLOR_COMBO(self->obj), pyg_boxed_get(py_color, GdkColor), &row, &col); + return Py_BuildValue("(ii)", row, col); + } + %% + override gtk_plot_canvas_get_pixel + static PyObject * + _wrap_gtk_plot_canvas_get_pixel(PyGObject *self, PyObject *args) + { + double px, py; + int x, y; + if (!PyArg_ParseTuple(args, "dd", &px, &py)) { + return NULL; + } + gtk_plot_canvas_get_pixel(GTK_PLOT_CANVAS(self->obj), px, py, &x, &y); + return Py_BuildValue("(ii)", x, y); + } + %% + override gtk_plot_canvas_get_position + static PyObject * + _wrap_gtk_plot_canvas_get_position(PyGObject *self, PyObject *args) + { + int x, y; + gdouble px, py; + if (!PyArg_ParseTuple(args, "ii", &x, &y)) { + return NULL; + } + gtk_plot_canvas_get_position(GTK_PLOT_CANVAS(self->obj), x, y, &px, &py); + return Py_BuildValue("(dd)", px, py); + } + %% + override gtk_plot_get_internal_allocation noargs + static PyObject * + _wrap_gtk_plot_get_internal_allocation(PyGObject *self) + { + GtkAllocation allocation; + allocation = gtk_plot_get_internal_allocation(GTK_PLOT(self->obj)); + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &allocation, TRUE, TRUE); + } + %% + override gtk_plot_add_data kwargs + static PyObject * + _wrap_gtk_plot_add_data(PyGObject *self, PyObject *args, PyObject *kwargs) + { + static char *kwlist[] = { "data", NULL }; + PyGObject *data; + char key[1024]; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GtkPlot.add_data", kwlist, &PyGtkPlotData_Type, &data)) + return NULL; + gtk_plot_add_data(GTK_PLOT(self->obj), GTK_PLOT_DATA(data->obj)); + g_snprintf(key, sizeof(key), "data_%p", data); + pygtkextra_set_data(self, key, (PyObject*) data); + Py_INCREF(Py_None); + return Py_None; + } + %% + override gtk_plot_remove_data kwargs + static PyObject * + _wrap_gtk_plot_remove_data(PyGObject *self, PyObject *args, PyObject *kwargs) + { + static char *kwlist[] = { "data", NULL }; + PyGObject *data; + int ret; + char key[1024]; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GtkPlot.remove_data", kwlist, &PyGtkPlotData_Type, &data)) + return NULL; + ret = gtk_plot_remove_data(GTK_PLOT(self->obj), GTK_PLOT_DATA(data->obj)); + g_snprintf(key, sizeof(key), "data_%p", data); + pygtkextra_set_data(self, key, Py_None); /* not perfect, but harmless */ + return PyInt_FromLong(ret); + } + %% + override gtk_plot_get_pixel + static PyObject * + _wrap_gtk_plot_get_pixel(PyGObject *self, PyObject *args) + { + double xx, yy; + double x, y; + if (!PyArg_ParseTuple(args, "dd", &xx, &yy)) { + return NULL; + } + gtk_plot_get_pixel(GTK_PLOT(self->obj), xx, yy, &x, &y); + return Py_BuildValue("(dd)", x, y); + } + %% + override gtk_plot_get_point + static PyObject * + _wrap_gtk_plot_get_point(PyGObject *self, PyObject *args) + { + int x, y; + double xx, yy; + if (!PyArg_ParseTuple(args, "ii", &x, &y)) { + return NULL; + } + gtk_plot_get_point(GTK_PLOT(self->obj), x, y, &xx, &yy); + return Py_BuildValue("(dd)", xx, yy); + } %% override gtk_plot_get_xrange noargs _GET_TWO_DOUBLE(gtk_plot_get_xrange, GTK_PLOT) ! %% ! override gtk_plot_get_yrange noargs ! _GET_TWO_DOUBLE(gtk_plot_get_yrange, GTK_PLOT) %% override gtk_plot_get_position noargs _GET_TWO_DOUBLE(gtk_plot_get_position, GTK_PLOT) %% override gtk_plot_get_size noargs _GET_TWO_DOUBLE(gtk_plot_get_size, GTK_PLOT) + %% + override gtk_plot_axis_get_attributes kwargs + static PyObject * + _wrap_gtk_plot_axis_get_attributes(PyGObject *self, PyObject *args, PyObject *kwargs) + { + static char *kwlist[] = { "axis", NULL }; + PyObject *py_axis = NULL; + gfloat width; + GdkColor color = {0, }; + GtkPlotAxisPos axis; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkPlot.axis_get_attributes", kwlist, &py_axis)) + return NULL; + if (pyg_enum_get_value(GTK_TYPE_PLOT_AXIS_POS, py_axis, (gint *)&axis)) + return NULL; + gtk_plot_axis_get_attributes(GTK_PLOT(self->obj), axis, &width, &color); + return Py_BuildValue("(dO)", (double)width, pyg_boxed_new(GDK_TYPE_COLOR, &color, TRUE, TRUE)); + } + %% + override gtk_plot_grids_visible noargs + static PyObject * + _wrap_gtk_plot_grids_visible(PyGObject *self) + { + gboolean vmajor, vminor, hmajor, hminor; + gtk_plot_grids_visible(GTK_PLOT(self->obj), &vmajor, &vminor, &hmajor, &hminor); + return Py_BuildValue("(iiii)", (int) vmajor, (int) vminor, (int) hmajor, (int) hminor); + } + %% + override gtk_plot_legends_get_position noargs + _GET_TWO_DOUBLE(gtk_plot_legends_get_position, GTK_PLOT) + %% + override gtk_plot_legends_get_allocation noargs + static PyObject * + _wrap_gtk_plot_legends_get_allocation(PyGObject *self) + { + GtkAllocation allocation; + allocation = gtk_plot_legends_get_allocation(GTK_PLOT(self->obj)); + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &allocation, TRUE, TRUE); + } + %% + override _set_data_from_pyobject_callback + static PyObject * + _wrap__set_data_from_pyobject_callback(PyObject *dummy, PyObject *args) + { + + PyObject *cb; + + if (!PyArg_ParseTuple(args, "O", &cb)) { + return NULL; + } + if (cb == Py_None) { + if ( pygtkextra_data_from_pyobject_callback != NULL ) { + Py_DECREF(pygtkextra_data_from_pyobject_callback); + } + pygtkextra_data_from_pyobject_callback = NULL; + } + else { + Py_INCREF(cb); + pygtkextra_data_from_pyobject_callback = cb; + } + Py_INCREF(Py_None); + return Py_None; + } %% ignore-glob *_get_type Index: gtkextramodule.c =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra2/gtkextra/gtkextramodule.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gtkextramodule.c 22 Jul 2002 13:06:55 -0000 1.4 --- gtkextramodule.c 24 Dec 2002 18:49:10 -0000 1.5 *************** *** 15,25 **** extern PyMethodDef pygtkextra_functions[]; DL_EXPORT(void) ! initgtkextra(void) { ! PyObject *m, *d; ! //m = Py_InitModule("gtkextra.gtkextra", pygtkextra_functions); ! m = Py_InitModule("gtkextra", pygtkextra_functions); d = PyModule_GetDict(m); --- 15,26 ---- extern PyMethodDef pygtkextra_functions[]; + PyTypeObject *_PyArray_Type; + DL_EXPORT(void) ! init_gtkextra(void) { ! PyObject *m, *d, *module; ! m = Py_InitModule("gtkextra._gtkextra", pygtkextra_functions); d = PyModule_GetDict(m); *************** *** 46,50 **** PyModule_AddIntConstant(m, "ICON_LIST_TEXT_BELOW", GTK_ICON_LIST_TEXT_BELOW); if (PyErr_Occurred()) ! Py_FatalError("could not initialise module gtkextra.gtkextra"); } --- 47,62 ---- PyModule_AddIntConstant(m, "ICON_LIST_TEXT_BELOW", GTK_ICON_LIST_TEXT_BELOW); + + if ((module = PyImport_ImportModule("array")) != NULL) { + PyObject *moddict = PyModule_GetDict(module); + _PyArray_Type = (PyTypeObject *)PyDict_GetItemString(moddict, "ArrayType"); + } + else { + Py_FatalError("could not import array"); + return; + } + + if (PyErr_Occurred()) ! Py_FatalError("could not initialise module gtkextra._gtkextra"); } |