[Python-gtkextra-commits] CVS: python-gtkextra/gtkextra __init__.py,1.1.1.1,1.2 gtkextra-extrafuncs.
Status: Beta
Brought to you by:
treeves
From: Andreas V?g. <voe...@us...> - 2002-01-03 22:44:08
|
Update of /cvsroot/python-gtkextra/python-gtkextra/gtkextra In directory usw-pr-cvs1:/tmp/cvs-serv18294/gtkextra Modified Files: __init__.py gtkextra-extrafuncs.defs gtkextra.defs gtkextra.override gtkextramodule.c gtkplotcanvaschild-type.c gtkplotdata-support.c pygtkextra-private.h Log Message: GtkExtra-0.99.17 update Index: __init__.py =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra/gtkextra/__init__.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** __init__.py 2001/09/15 18:52:28 1.1.1.1 --- __init__.py 2002/01/03 22:44:04 1.2 *************** *** 1,5 **** # Python bindings for the GtkExtra widget set # ! # Copyright (C) 2000-2001 Andreas Voegele # # The documentation is based on the GtkAda documentation and used by --- 1,5 ---- # Python bindings for the GtkExtra widget set # ! # Copyright (C) 2000-2002 Andreas Voegele # # The documentation is based on the GtkAda documentation and used by *************** *** 61,64 **** --- 61,75 ---- PLOT_BAR_ABSOLUTE = 2 + # plot data iterator mask + PLOT_DATA_X = 1 << 0 + PLOT_DATA_Y = 1 << 1 + PLOT_DATA_Z = 1 << 2 + PLOT_DATA_A = 1 << 3 + PLOT_DATA_DX = 1 << 4 + PLOT_DATA_DY = 1 << 5 + PLOT_DATA_DZ = 1 << 6 + PLOT_DATA_DA = 1 << 7 + PLOT_DATA_LABELS = 1 << 8 + # plot scale type PLOT_SCALE_LINEAR = 0 *************** *** 203,206 **** --- 214,226 ---- PLOT_ARROW_END = 1 << 1 + # plot canvas selection + PLOT_CANVAS_SELECT_NONE = 0 + PLOT_CANVAS_SELECT_MARKERS = 1 + PLOT_CANVAS_SELECT_TARGET = 2 + + # plot canvas selection mode + PLOT_CANVAS_SELECT_CLICK_1 = 0 + PLOT_CANVAS_SELECT_CLICK_2 = 2 + # plot canvas item type PLOT_CANVAS_NONE = 0 *************** *** 215,219 **** PLOT_CANVAS_ELLIPSE = 9 PLOT_CANVAS_PIXMAP = 10 ! PLOT_CANVAS_CUSTOM = 11 # icon list mode --- 235,240 ---- PLOT_CANVAS_ELLIPSE = 9 PLOT_CANVAS_PIXMAP = 10 ! PLOT_CANVAS_MARKER = 11 ! PLOT_CANVAS_CUSTOM = 12 # icon list mode *************** *** 292,298 **** --- 313,338 ---- entry_widget = _gtk._obj2inst(entry_widget) return entry_widget + def get_entry_widget(self): + """Return the widget used to modify the contents of the cells. + """ + entry_widget = _gtkextra.gtk_sheet_get_entry_widget(self._o) + if entry_widget: + entry_widget = _gtk._obj2inst(entry_widget) + return entry_widget def set_title(self, title): """Change the title of the sheet.""" _gtkextra.gtk_sheet_set_title(self._o, title) + def set_background(self, color): + """Set the sheet's background color.""" + _gtkextra.gtk_sheet_set_background(self._o, color) + def set_grid(self, color): + """Set the sheet's grid color.""" + _gtkextra.gtk_sheet_set_grid(self._o, color) + def show_grid(self, visible): + """Change the visibility of the grid.""" + _gtkextra.gtk_sheet_show_grid(self._o, visible) + def grid_visible(self): + """Check if the grid is visible.""" + return _gtkextra.gtk_sheet_grid_visible(self._o) def freeze(self): """Freeze all visual updates of the sheet until you thaw it. *************** *** 684,695 **** def paint(self): _gtkextra.gtk_plot_data_paint(self._o) def draw_points(self, n): _gtkextra.gtk_plot_data_draw_points(self._o, n) def draw_symbol(self, x, y): _gtkextra.gtk_plot_data_draw_symbol(self._o, x, y) ! def set_points(self, x, y, dx=None, dy=None, n=-1): ! _gtkextra.gtk_plot_data_set_points(self._o, x, y, dx, dy, n) def get_points(self): return _gtkextra.gtk_plot_data_get_points(self._o) def set_numpoints(self, n): _gtkextra.gtk_plot_data_set_numpoints(self._o, n) --- 724,745 ---- def paint(self): _gtkextra.gtk_plot_data_paint(self._o) + def update(self): + _gtkextra.gtk_plot_data_update(self._o) def draw_points(self, n): _gtkextra.gtk_plot_data_draw_points(self._o, n) def draw_symbol(self, x, y): _gtkextra.gtk_plot_data_draw_symbol(self._o, x, y) ! def set_points(self, *args): ! """Set the X, Y, DX and DY arrays and the number of points. ! The arguments can be passed individually or in a 5-tuple. ! """ ! apply(_gtkextra.gtk_plot_data_set_points, (self._o,) + args) def get_points(self): + """Return a 5-tuple that contains the X, Y, DX and DY arrays + and the number of points. + """ return _gtkextra.gtk_plot_data_get_points(self._o) + def get_point(self, i): + return _gtkextra.gtk_plot_data_get_point(self._o, i) def set_numpoints(self, n): _gtkextra.gtk_plot_data_set_numpoints(self._o, n) *************** *** 728,731 **** --- 778,785 ---- def get_da(self): return _gtkextra.gtk_plot_data_get_da(self._o) + def set_a_scale(self, scale): + _gtkextra.gtk_plot_data_set_a_scale(self._o, scale) + def get_a_scale(self): + return _gtkextra.gtk_plot_data_get_a_scale(self._o) def set_labels(self, labels): _gtkextra.gtk_plot_data_set_da(self._o, labels) *************** *** 809,812 **** --- 863,874 ---- def gradient_visible(self): return _gtkextra.gtk_plot_data_gradient_visible(self._o) + def draw_gradient(self, x, y): + _gtkextra.gtk_plot_data_draw_gradient(self._o, x, y) + def gradient_autoscale_a(self): + _gtkextra.gtk_plot_data_gradient_autoscale_a(self._o) + def gradient_autoscale_da(self): + _gtkextra.gtk_plot_data_gradient_autoscale_da(self._o) + def gradient_autoscale_z(self): + _gtkextra.gtk_plot_data_gradient_autoscale_z(self._o) def gradient_get_visible(self): return self.gradient_visible() *************** *** 817,822 **** def get_gradient_colors(self): return _gtkextra.gtk_plot_data_get_gradient_colors(self._o) ! def set_gradient(self, min, max, levels): ! _gtkextra.gtk_plot_data_set_gradient(self._o, min, max, levels) def get_gradient(self): return _gtkextra.gtk_plot_data_get_gradient(self._o) --- 879,885 ---- def get_gradient_colors(self): return _gtkextra.gtk_plot_data_get_gradient_colors(self._o) ! def set_gradient(self, min, max, levels, sublevels=0): ! _gtkextra.gtk_plot_data_set_gradient(self._o, min, max, levels, ! sublevels) def get_gradient(self): return _gtkextra.gtk_plot_data_get_gradient(self._o) *************** *** 830,833 **** --- 893,906 ---- def remove_link(self): _gtkextra.gtk_plot_data_remove_link(self._o); + def add_marker(self, i): + return _gtkextra.gtk_plot_data_add_marker(self._o, i) + def remove_marker(self, marker): + return _gtkextra.gtk_plot_data_remove_marker(self._o, marker) + def remove_markers(self): + _gtkextra.gtk_plot_data_remove_markers(self._o) + def show_markers(self, visible): + _gtkextra.gtk_plot_data_show_markers(self._o, visible) + def markers_visible(self): + return _gtkextra.gtk_plot_data_markers_visible(self._o) _gtk._name2cls['GtkPlotData'] = GtkPlotData *************** *** 903,910 **** def set_ambient(self, ambient): _gtkextra.gtk_plot_surface_set_ambient(self._o, ambient) ! def set_points(self, x, y, z, dx, dy, dz, nx, ny): ! _gtkextra.gtk_plot_surface_set_points(self._o, x, y, z, dx, dy, ! dz, nx, ny) def get_points(self): return _gtkextra.gtk_plot_surface_get_points(self._o) def set_nx(self, nx): --- 976,995 ---- def set_ambient(self, ambient): _gtkextra.gtk_plot_surface_set_ambient(self._o, ambient) ! def use_height_gradient(self, use_gradient): ! _gtkextra.gtk_plot_surface_use_height_gradient(self._o, ! use_gradient) ! def set_transparent(self, transparent): ! _gtkextra.gtk_plot_surface_set_transparent(self._o, ! transparent) ! def set_points(self, *args): ! """Set the X, Y, Z, DX, DY and DY arrays and the number of ! points on the X and the Y axis. The arguments can be passed ! individually or in a 8-tuple. ! """ ! apply(_gtkextra.gtk_plot_surface_set_points, (self._o,) + args) def get_points(self): + """Return a 8-tuple that contains the X, Y, Z, DX, DY and DZ + arrays and the number of points on the X and the Y axis. + """ return _gtkextra.gtk_plot_surface_get_points(self._o) def set_nx(self, nx): *************** *** 948,951 **** --- 1033,1040 ---- def get_ystep(self): _gtkextra.gtk_plot_surface_get_ystep(self._o) + def build_mesh(self): + _gtkextra.gtk_plot_surface_build_mesh(self._o) + def recalc_nodes(self): + _gtkextra.gtk_plot_surface_recalc_nodes(self._o) _gtk._name2cls['GtkPlotSurface'] = GtkPlotSurface *************** *** 1316,1319 **** --- 1405,1413 ---- label_style, precision) + def axis_set_labels_offset(self, axis, offset): + _gtkextra.gtk_plot_axis_set_labels_offset(self._o, axis, + offset) + def axis_get_labels_offset(self, axis): + return _gtkextra.gtk_plot_axis_get_labels_offset(self._o, axis) def axis_labels_set_numbers(self, axis, label_style, precision): """Obsolete, use axis_set_labels_numbers() instead.""" *************** *** 1757,1760 **** --- 1851,1861 ---- def refresh(self): _gtkextra.gtk_plot_canvas_refresh(self._o) + def freeze(self): + """Freeze all visual updates of the canvas until you thaw it. + """ + _gtkextra.gtk_plot_canvas_freeze(self._o) + def thaw(self): + """Thaw the sheet so that visual updates occur again. + """ def remove_child(self, child): return _gtkextra.gtk_plot_canvas_remove_child(self._o, child) *************** *** 1919,1922 **** --- 2020,2024 ---- 'dir_tree': _gtkextra.gtk_icon_file_selection_get_dir_tree, 'file_list': _gtkextra.gtk_icon_file_selection_get_file_list, + 'history_combo': _gtkextra.gtk_icon_file_selection_get_history_combo, 'file_entry': _gtkextra.gtk_icon_file_selection_get_file_entry, 'filter_entry': _gtkextra.gtk_icon_file_selection_get_filter_entry, Index: gtkextra-extrafuncs.defs =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra/gtkextra/gtkextra-extrafuncs.defs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gtkextra-extrafuncs.defs 2001/09/15 18:52:02 1.1.1.1 --- gtkextra-extrafuncs.defs 2002/01/03 22:44:04 1.2 *************** *** 87,94 **** (of-object "GtkItemEntry") (c-name "gtk_item_entry_get_justification") ! (return-type "int") ) ! (define-enum "TODO" (in-module "GtkExtra") (c-name "TODO") --- 87,94 ---- (of-object "GtkItemEntry") (c-name "gtk_item_entry_get_justification") ! (return-type "GtkJustification") ) ! (define-enum TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 102,106 **** ) ! (define-flags "TODO" (in-module "GtkExtra") (c-name "TODO") --- 102,106 ---- ) ! (define-flags TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 114,118 **** ) ! (define-flags "TODO" (in-module "GtkExtra") (c-name "TODO") --- 114,118 ---- ) ! (define-flags TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 137,140 **** --- 137,157 ---- ) + (define-flags TODO + (in-module "GtkExtra") + (c-name "TODO") + (gtype-id "TODO") + (values + '("x" "GTK_PLOT_DATA_X") + '("y" "GTK_PLOT_DATA_Y") + '("z" "GTK_PLOT_DATA_Z") + '("a" "GTK_PLOT_DATA_A") + '("dx" "GTK_PLOT_DATA_DX") + '("dy" "GTK_PLOT_DATA_DY") + '("dz" "GTK_PLOT_DATA_DZ") + '("da" "GTK_PLOT_DATA_DA") + '("labels" "GTK_PLOT_DATA_LABELS") + ) + ) + (define-enum PlotScale (in-module "GtkExtra") *************** *** 275,279 **** ) ! (define-flags "TODO" (in-module "GtkExtra") (c-name "TODO") --- 292,296 ---- ) ! (define-flags TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 314,318 **** ) ! (define-enum "TODO" (in-module "GtkExtra") (c-name "TODO") --- 331,335 ---- ) ! (define-enum TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 327,331 **** ) ! (define-enum "TODO" (in-module "GtkExtra") (c-name "TODO") --- 344,348 ---- ) ! (define-enum TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 343,347 **** ) ! (define-enum "TODO" (in-module "GtkExtra") (c-name "TODO") --- 360,364 ---- ) ! (define-enum TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 353,357 **** ) ! (define-enum "TODO" (in-module "GtkExtra") (c-name "TODO") --- 370,374 ---- ) ! (define-enum TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 365,369 **** ) ! (define-flags "TODO" (in-module "GtkExtra") (c-name "TODO") --- 382,386 ---- ) ! (define-flags TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 379,383 **** ) ! (define-flags "TODO" (in-module "GtkExtra") (c-name "TODO") --- 396,400 ---- ) ! (define-flags TODO (in-module "GtkExtra") (c-name "TODO") *************** *** 418,426 **** '("ellipse" "GTK_PLOT_CANVAS_ELLIPSE") '("pixmap" "GTK_PLOT_CANVAS_PIXMAP") '("custom" "GTK_PLOT_CANVAS_CUSTOM") ) ) ! (define-enum "TODO" (in-module "GtkExtra") (c-name "TODO") --- 435,465 ---- '("ellipse" "GTK_PLOT_CANVAS_ELLIPSE") '("pixmap" "GTK_PLOT_CANVAS_PIXMAP") + '("marker" "GTK_PLOT_CANVAS_MARKER") '("custom" "GTK_PLOT_CANVAS_CUSTOM") ) ) ! (define-enum PlotCanvasSelection ! (in-module "GtkExtra") ! (c-name "GtkPlotCanvasSelection") ! (gtype-id "TODO") ! (values ! '("none" "GTK_PLOT_CANVAS_SELECT_NONE") ! '("markers" "GTK_PLOT_CANVAS_SELECT_MARKERS") ! '("target" "GTK_PLOT_CANVAS_SELECT_TARGET") ! ) ! ) ! ! (define-enum PlotCanvasSelectionMode ! (in-module "GtkExtra") ! (c-name "GtkPlotCanvasSelectionMode") ! (gtype-id "TODO") ! (values ! '("click-1" "GTK_PLOT_CANVAS_SELECT_CLICK_1") ! '("click-2" "GTK_PLOT_CANVAS_SELECT_CLICK_2") ! ) ! ) ! ! (define-enum TODO (in-module "GtkExtra") (c-name "TODO") Index: gtkextra.defs =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra/gtkextra/gtkextra.defs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gtkextra.defs 2001/09/15 18:52:00 1.1.1.1 --- gtkextra.defs 2002/01/03 22:44:04 1.2 *************** *** 130,133 **** --- 130,134 ---- '("GtkWidget*" "dir_tree") '("GtkWidget*" "file_list") + '("GtkWidget*" "history_combo") '("GtkWidget*" "file_entry") '("GtkWidget*" "filter_entry") *************** *** 246,250 **** '("guint" "columns") '("const-gchar*" "title" (null-ok)) [...1577 lines suppressed...] ) --- 4450,4454 ---- (parameters '("const-gchar*" "string") ! '("GtkJustification" "justification") ) ) *************** *** 4219,4223 **** (return-type "none") (parameters ! '("int" "justification") ) ) --- 4459,4463 ---- (return-type "none") (parameters ! '("GtkJustification" "justification") ) ) Index: gtkextra.override =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra/gtkextra/gtkextra.override,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gtkextra.override 2001/09/15 18:52:17 1.1.1.1 --- gtkextra.override 2002/01/03 22:44:04 1.2 *************** *** 823,826 **** --- 823,849 ---- function, extra); Py_DECREF(extra); + } else if (PyTuple_Check(function)) { + PyObject *extra, *iterator; + int n, mask; + + if (!PyArg_ParseTuple(function, "Oii:gtk_plot_data_new", &iterator, + &n, &mask)) { + return NULL; + } + if (!PyCallable_Check(iterator)) { + PyErr_SetString(PyExc_TypeError, "iterator must be callable"); + return NULL; + } + extra = PyTuple_GetSlice(args, 1, num_args); + if (!extra) + return NULL; + widget = + gtk_plot_data_new_iterator((GtkPlotIterator) + pygtkextra_plot_data_call_plot_iterator, + n, mask); + if (widget) + pygtkextra_plot_data_register_plot_iterator(GTK_PLOT_DATA(widget), + iterator, extra); + Py_DECREF(extra); } else if (PyCObject_Check(function)) { if (num_args > 1) { *************** *** 861,868 **** int n = -1; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, ! "OO|OOi:GtkPlotData.set_points", kwlist, ! &x, &y, &dx, &dy, &n)) ! return NULL; return pygtkextra_plot_data_set_points(GTK_PLOT_DATA(self->obj), x, y, dx, dy, n); --- 884,895 ---- int n = -1; ! if (!PyArg_ParseTuple(args, "(OOOOi):GtkPlotData.set_points", ! &x, &y, &dx, &dy, &n)) { ! PyErr_Clear(); ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, ! "OO|OOi:GtkPlotData.set_points", ! kwlist, &x, &y, &dx, &dy, &n)) ! return NULL; ! } return pygtkextra_plot_data_set_points(GTK_PLOT_DATA(self->obj), x, y, dx, dy, n); *************** *** 878,881 **** --- 905,931 ---- } %% + override gtk_plot_data_get_point + static PyObject * + _wrap_gtk_plot_data_get_point(PyObject *self, PyObject *args) + { + int i; + gdouble x = 0.0, y = 0.0, z = 0.0, a = 0.0, dx = 0.0, dy = 0.0, + dz = 0.0, da = 0.0; + gchar *label = NULL; + gboolean error; + + if (!PyArg_ParseTuple(args, "i:GtkPlotData.get_point", &i)) + return NULL; + gtk_plot_data_get_point(GTK_PLOT_DATA(self->obj), i, &x, &y, &z, &a, + &dx, &dy, &dz, &da, &label, &error); + if (error) { + Py_INCREF(Py_None); + return Py_None; + } + return Py_BuildValue("(dddddddds)", (double) x, (double) y, (double) z, + (double) a, (double) dx, (double) dy, (double) dz, + (double) da, label); + } + %% override gtk_plot_data_set_numpoints kwargs static PyObject * *************** *** 1174,1183 **** { gdouble min, max; ! gint levels; if (!PyArg_ParseTuple(args, ":GtkPlotData.get_gradient")) return NULL; ! gtk_plot_data_get_gradient(GTK_PLOT_DATA(self->obj), &min, &max, &levels); ! return Py_BuildValue("(ddi)", (double) min, (double) max, (int) levels); } %% --- 1224,1235 ---- { gdouble min, max; ! gint levels, sublevels; if (!PyArg_ParseTuple(args, ":GtkPlotData.get_gradient")) return NULL; ! gtk_plot_data_get_gradient(GTK_PLOT_DATA(self->obj), &min, &max, &levels, ! &sublevels); ! return Py_BuildValue("(ddii)", (double) min, (double) max, (int) levels, ! (int) sublevels); } %% *************** *** 1258,1261 **** --- 1310,1345 ---- } %% + override gtk_plot_data_add_marker + static PyObject * + _wrap_gtk_plot_data_add_marker(PyObject *self, PyObject *args) + { + int i; + GtkPlotMarker *marker; + + if (!PyArg_ParseTuple(args, "i:GtkPlotData.add_marker", &i)) + return NULL; + marker = gtk_plot_data_add_marker(GTK_PLOT_DATA(self->obj), i); + if (marker) + return PyCObject_FromVoidPtr(marker, NULL); + Py_INCREF(Py_None); + return Py_None; + } + %% + override gtk_plot_data_remove_marker + static PyObject * + _wrap_gtk_plot_data_remove_marker(PyObject *self, PyObject *args) + { + PyObject *py_marker; + GtkPlotMarker *marker; + gboolean ok; + + if (!PyArg_ParseTuple(args, "O!:gtk_plot_data_remove_marker", + &PyCObject_Type, &py_marker)) + return NULL; + marker = PyCObject_AsVoidPtr(py_marker); + ok = gtk_plot_data_remove_marker(GTK_PLOT_DATA(self->obj), marker); + return PyInt_FromLong(ok); + } + %% override gtk_plot_bar_new kwargs static PyObject * *************** *** 1409,1417 **** int nx, ny; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, ! "OOOOOOii:GtkPlotSurface.set_points", ! kwlist, &x, &y, &z, &dx, &dy, &dz, &nx, ! &ny)) ! return NULL; return pygtkextra_plot_surface_set_points(GTK_PLOT_SURFACE(self->obj), x, y, z, dx, dy, dz, nx, ny); --- 1493,1505 ---- int nx, ny; ! if (!PyArg_ParseTuple(args, "(OOOOOOii):GtkPlotSurface.set_points", ! &x, &y, &z, &dx, &dy, &dz, &nx, &ny)) { ! PyErr_Clear(); ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, ! "OOOOOOii:GtkPlotSurface.set_points", ! kwlist, &x, &y, &z, &dx, &dy, &dz, ! &nx, &ny)) ! return NULL; ! } return pygtkextra_plot_surface_set_points(GTK_PLOT_SURFACE(self->obj), x, y, z, dx, dy, dz, nx, ny); *************** *** 1747,1750 **** --- 1835,1840 ---- ignore gtk_plot_new_with_size %% + ignore gtk_plot_set_pc + %% override gtk_plot_get_position static PyObject * *************** *** 2454,2457 **** --- 2544,2549 ---- return pygtkextra_plot_line_new(line_style, line_width, &line_color); } + %% + ignore gtk_plot_canvas_set_pc %% override gtk_plot_canvas_get_active_point Index: gtkextramodule.c =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra/gtkextra/gtkextramodule.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gtkextramodule.c 2001/09/15 18:51:16 1.1.1.1 --- gtkextramodule.c 2002/01/03 22:44:04 1.2 *************** *** 3,7 **** * Python bindings for the GtkExtra widget set * ! * Copyright (C) 2000-2001 Andreas Voegele * * This library is free software; you can redistribute it and/or --- 3,7 ---- * Python bindings for the GtkExtra widget set * ! * Copyright (C) 2000-2002 Andreas Voegele * * This library is free software; you can redistribute it and/or *************** *** 22,26 **** /* ! * Don't forget to add your wrapper functions to the table at the end * of this file! */ --- 22,26 ---- /* ! * Don't forget to add your wrapper functions to the array at the end * of this file! */ *************** *** 85,88 **** --- 85,104 ---- static PyObject * + _wrap_gtk_sheet_get_entry_widget(PyObject *self, PyObject *args) + { + PyObject *obj; + GtkWidget *entry_widget; + + if (!PyArg_ParseTuple(args, "O!:gtk_sheet_get_entry_widget", + &PyGtk_Type, &obj)) + return NULL; + entry_widget = gtk_sheet_get_entry_widget(GTK_SHEET(PyGtk_Get(obj))); + if (entry_widget) + return PyGtk_New(GTK_OBJECT(entry_widget)); + Py_INCREF(Py_None); + return Py_None; + } + + static PyObject * _wrap_gtk_sheet_get_visible_range(PyObject *self, PyObject *args) { *************** *** 850,853 **** --- 866,887 ---- pygtkextra_plot_data_register_plot_function(GTK_PLOT_DATA(widget), function, extra); + } else if (PyTuple_Check(function)) { + PyObject *iterator; + int n, mask; + + if (!PyArg_ParseTuple(function, "Oii:gtk_plot_data_new", &iterator, + &n, &mask)) + return NULL; + if (!PyCallable_Check(iterator)) { + PyErr_SetString(PyExc_TypeError, "iterator must be callable"); + return NULL; + } + widget = + gtk_plot_data_new_iterator((GtkPlotIterator) + pygtkextra_plot_data_call_plot_iterator, + n, mask); + if (widget) + pygtkextra_plot_data_register_plot_iterator(GTK_PLOT_DATA(widget), + iterator, extra); } else if (PyCObject_Check(function)) { if (extra && PyTuple_Size(extra) > 0) { *************** *** 881,887 **** int n = -1; ! if (!PyArg_ParseTuple(args, "O!OO|OOi:gtk_plot_data_set_points", ! &PyGtk_Type, &obj, &x, &y, &dx, &dy, &n)) ! return NULL; return pygtkextra_plot_data_set_points(GTK_PLOT_DATA(PyGtk_Get(obj)), x, y, dx, dy, n); --- 915,925 ---- int n = -1; ! if (!PyArg_ParseTuple(args, "O!(OOOOi):gtk_plot_data_set_points", ! &PyGtk_Type, &obj, &x, &y, &dx, &dy, &n)) { ! PyErr_Clear(); ! if (!PyArg_ParseTuple(args, "O!OO|OOi:gtk_plot_data_set_points", ! &PyGtk_Type, &obj, &x, &y, &dx, &dy, &n)) ! return NULL; ! } return pygtkextra_plot_data_set_points(GTK_PLOT_DATA(PyGtk_Get(obj)), x, y, dx, dy, n); *************** *** 900,903 **** --- 938,965 ---- static PyObject * + _wrap_gtk_plot_data_get_point(PyObject *self, PyObject *args) + { + PyObject *obj; + int i; + gdouble x = 0.0, y = 0.0, z = 0.0, a = 0.0, dx = 0.0, dy = 0.0, + dz = 0.0, da = 0.0; + gchar *label = NULL; + gboolean error; + + if (!PyArg_ParseTuple(args, "O!i:gtk_plot_data_get_point", + &PyGtk_Type, &obj, &i)) + return NULL; + gtk_plot_data_get_point(GTK_PLOT_DATA(PyGtk_Get(obj)), i, &x, &y, &z, &a, + &dx, &dy, &dz, &da, &label, &error); + if (error) { + Py_INCREF(Py_None); + return Py_None; + } + return Py_BuildValue("(dddddddds)", (double) x, (double) y, (double) z, + (double) a, (double) dx, (double) dy, (double) dz, + (double) da, label); + } + + static PyObject * _wrap_gtk_plot_data_set_numpoints(PyObject *self, PyObject *args) { *************** *** 1204,1208 **** PyObject *obj; gdouble min, max; ! gint levels; if (!PyArg_ParseTuple(args, "O!:gtk_plot_data_get_gradient", --- 1266,1270 ---- PyObject *obj; gdouble min, max; ! gint levels, sublevels; if (!PyArg_ParseTuple(args, "O!:gtk_plot_data_get_gradient", *************** *** 1210,1216 **** return NULL; gtk_plot_data_get_gradient(GTK_PLOT_DATA(PyGtk_Get(obj)), &min, &max, ! &levels); ! return Py_BuildValue("(ddi)", (double) min, (double) max, ! (int) levels); } --- 1272,1278 ---- return NULL; gtk_plot_data_get_gradient(GTK_PLOT_DATA(PyGtk_Get(obj)), &min, &max, ! &levels, &sublevels); ! return Py_BuildValue("(ddii)", (double) min, (double) max, ! (int) levels, (int) sublevels); } *************** *** 1292,1296 **** --- 1354,1391 ---- } + static PyObject * + _wrap_gtk_plot_data_add_marker(PyObject *self, PyObject *args) + { + PyObject *obj; + int i; + GtkPlotMarker *marker; + + if (!PyArg_ParseTuple(args, "O!i:gtk_plot_data_add_marker", + &PyGtk_Type, &obj, &i)) + return NULL; + marker = gtk_plot_data_add_marker(GTK_PLOT_DATA(PyGtk_Get(obj)), i); + if (marker) + return PyCObject_FromVoidPtr(marker, NULL); + Py_INCREF(Py_None); + return Py_None; + } + static PyObject * + _wrap_gtk_plot_data_remove_marker(PyObject *self, PyObject *args) + { + PyObject *obj; + PyObject *py_marker; + GtkPlotMarker *marker; + gboolean ok; + + if (!PyArg_ParseTuple(args, "O!O!:gtk_plot_data_remove_marker", + &PyGtk_Type, &obj, &PyCObject_Type, &py_marker)) + return NULL; + marker = PyCObject_AsVoidPtr(py_marker); + ok = gtk_plot_data_remove_marker(GTK_PLOT_DATA(PyGtk_Get(obj)), marker); + return PyInt_FromLong(ok); + } + + /* * GtkPlotBar *************** *** 1430,1437 **** int nx, ny; ! if (!PyArg_ParseTuple(args, "O!OOOOOOii:gtk_plot_surface_set_points", ! &PyGtk_Type, &obj, &x, &y, &z, &dx, &dy, &dz, &nx, ! &ny)) ! return NULL; return pygtkextra_plot_surface_set_points(GTK_PLOT_SURFACE(PyGtk_Get(obj)), x, y, z, dx, dy, dz, nx, ny); --- 1525,1537 ---- int nx, ny; ! if (!PyArg_ParseTuple(args, "O!(OOOOOOii):gtk_plot_surface_set_points", ! &PyGtk_Type, &obj, &x, &y, &z, &dx, &dy, &dz, ! &nx, &ny)) { ! PyErr_Clear(); ! if (!PyArg_ParseTuple(args, "O!OOOOOOii:gtk_plot_surface_set_points", ! &PyGtk_Type, &obj, &x, &y, &z, &dx, &dy, &dz, ! &nx, &ny)) ! return NULL; ! } return pygtkextra_plot_surface_set_points(GTK_PLOT_SURFACE(PyGtk_Get(obj)), x, y, z, dx, dy, dz, nx, ny); *************** *** 3628,3631 **** --- 3728,3732 ---- { "gtk_sheet_new", _wrap_gtk_sheet_new, 1 }, { "gtk_sheet_get_entry", _wrap_gtk_sheet_get_entry, 1 }, + { "gtk_sheet_get_entry_widget", _wrap_gtk_sheet_get_entry_widget, 1 }, { "gtk_sheet_get_visible_range", _wrap_gtk_sheet_get_visible_range, 1 }, { "gtk_sheet_clip_range", _wrap_gtk_sheet_clip_range, 1 }, *************** *** 3679,3682 **** --- 3780,3784 ---- { "gtk_plot_data_set_points", _wrap_gtk_plot_data_set_points, 1 }, { "gtk_plot_data_get_points", _wrap_gtk_plot_data_get_points, 1 }, + { "gtk_plot_data_get_point", _wrap_gtk_plot_data_get_point, 1 }, { "gtk_plot_data_set_labels", _wrap_gtk_plot_data_set_labels, 1 }, { "gtk_plot_data_get_labels", _wrap_gtk_plot_data_get_labels, 1 }, *************** *** 3690,3693 **** --- 3792,3797 ---- { "gtk_plot_data_get_link", _wrap_gtk_plot_data_get_link, 1 }, { "gtk_plot_data_remove_link", _wrap_gtk_plot_data_remove_link, 1 }, + { "gtk_plot_data_add_marker", _wrap_gtk_plot_data_add_marker, 1 }, + { "gtk_plot_data_remove_marker", _wrap_gtk_plot_data_remove_marker, 1 }, { "gtk_plot_bar_new", _wrap_gtk_plot_bar_new, 1 }, { "gtk_plot_box_new", _wrap_gtk_plot_box_new, 1 }, Index: gtkplotcanvaschild-type.c =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra/gtkextra/gtkplotcanvaschild-type.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gtkplotcanvaschild-type.c 2001/09/15 18:51:18 1.1.1.1 --- gtkplotcanvaschild-type.c 2002/01/03 22:44:04 1.2 *************** *** 35,38 **** --- 35,73 ---- } + static PyObject * + PyGtkPlotCanvasChild_set_selection(PyGtkPlotCanvasChild_Object *self, + PyObject *args) + { + int selection; + + if (!PyArg_ParseTuple(args, "i:GtkPlotCanvasChild.set_selection", + &selection)) + return NULL; + gtk_plot_canvas_child_set_selection(self->child, selection); + Py_INCREF(Py_None); + return Py_None; + } + + static PyObject * + PyGtkPlotCanvasChild_set_selection_mode(PyGtkPlotCanvasChild_Object *self, + PyObject *args) + { + int mode; + + if (!PyArg_ParseTuple(args, "i:GtkPlotCanvasChild.set_selection_mode", + &mode)) + return NULL; + gtk_plot_canvas_child_set_selection_mode(self->child, mode); + Py_INCREF(Py_None); + return Py_None; + } + + static PyMethodDef PyGtkPlotCanvasChild_methods[] = + { + { "set_selection", (PyCFunction) PyGtkPlotCanvasChild_set_selection, METH_VARARGS }, + { "set_selection_mode", (PyCFunction) PyGtkPlotCanvasChild_set_selection_mode, METH_VARARGS }, + { NULL, NULL, 0 } + }; + static struct memberlist PyGtkPlotCanvasChild_members[] = { *************** *** 40,43 **** --- 75,80 ---- { "type", T_INT, offsetof(GtkPlotCanvasChild, type), RO }, { "flags",T_INT, offsetof(GtkPlotCanvasChild, flags), 0 }, + { "selection",T_INT, offsetof(GtkPlotCanvasChild, selection), 0 }, + { "mode",T_INT, offsetof(GtkPlotCanvasChild, mode), 0 }, { "state", T_UINT, offsetof(GtkPlotCanvasChild, state), RO }, { "data", -1, 0, RO }, *************** *** 48,51 **** --- 85,90 ---- PyGtkPlotCanvasChild_GetAttr(PyGtkPlotCanvasChild_Object *self, char *attr) { + PyObject *value; + if (strcmp(attr, "allocation") == 0) { return Py_BuildValue("(iiii)", *************** *** 70,75 **** } } ! return PyMember_Get((char *) self->child, PyGtkPlotCanvasChild_members, ! attr); } --- 109,122 ---- } } ! value = PyMember_Get((char *) self->child, PyGtkPlotCanvasChild_members, ! attr); ! if (!value) { ! if (PyErr_ExceptionMatches(PyExc_AttributeError)) { ! PyErr_Clear(); ! value = Py_FindMethod(PyGtkPlotCanvasChild_methods, ! (PyObject *) self, attr); ! } ! } ! return value; } Index: gtkplotdata-support.c =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra/gtkextra/gtkplotdata-support.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gtkplotdata-support.c 2001/09/15 18:51:23 1.1.1.1 --- gtkplotdata-support.c 2002/01/03 22:44:04 1.2 *************** *** 36,42 **** --- 36,62 ---- "DX", "DY", "DZ", "DA" }; + #define PLOT_FUNCTION_TYPE_PLOT 0 + #define PLOT_FUNCTION_TYPE_PLOT3D 1 + #define PLOT_FUNCTION_TYPE_ITERATOR 2 + + static char * + get_ordinal_suffix(int i) + { + switch (i % 10) { + case 1: + return "st"; + case 2: + return "nd"; + case 3: + return "rd"; + default: + return "th"; + } + } + /* * pygtkextra_plot_data_register_plot_function * pygtkextra_plot_data_register_plot3d_function + * pygtkextra_plot_data_register_plot_iterator * * Associates a Python plot function and its arguments with a *************** *** 49,57 **** PyObject *function, PyObject *extra, ! int num_values) { ! int i, len; ! PyObject *args, **vector; ! /* Create a tuple for the plot function's arguments. */ len = (extra) ? PyTuple_Size(extra) : 0; --- 69,87 ---- PyObject *function, PyObject *extra, ! int type) { ! int i, len, num_values; ! PyObject *args, *value, **vector; ! ! switch (type) { ! case PLOT_FUNCTION_TYPE_PLOT: ! case PLOT_FUNCTION_TYPE_ITERATOR: ! num_values = 1; ! break; ! case PLOT_FUNCTION_TYPE_PLOT3D: ! num_values = 2; ! break; ! } ! /* Create a tuple for the plot function's arguments. */ len = (extra) ? PyTuple_Size(extra) : 0; *************** *** 59,65 **** if (!args) return FALSE; ! /* Create the X and Y values. */ ! for (i = 0; i < num_values; ++i) { ! PyObject *value = PyFloat_FromDouble(0.0); if (!value) { Py_DECREF(args); --- 89,106 ---- if (!args) return FALSE; ! switch (type) { ! case PLOT_FUNCTION_TYPE_PLOT: ! case PLOT_FUNCTION_TYPE_PLOT3D: ! for (i = 0; i < num_values; ++i) { ! value = PyFloat_FromDouble(0.0); ! if (!value) { ! Py_DECREF(args); ! return FALSE; ! } ! PyTuple_SET_ITEM(args, i, value); ! } ! break; ! case PLOT_FUNCTION_TYPE_ITERATOR: ! value = PyInt_FromLong(0); if (!value) { Py_DECREF(args); *************** *** 67,70 **** --- 108,112 ---- } PyTuple_SET_ITEM(args, i, value); + break; } /* Copy the extra arguments. */ *************** *** 93,97 **** { return pygtkextra_plot_data_register_plot_function_real(data, function, ! extra, 1); } --- 135,140 ---- { return pygtkextra_plot_data_register_plot_function_real(data, function, ! extra, ! PLOT_FUNCTION_TYPE_PLOT); } *************** *** 102,106 **** { return pygtkextra_plot_data_register_plot_function_real(data, function, ! extra, 2); } --- 145,160 ---- { return pygtkextra_plot_data_register_plot_function_real(data, function, ! extra, ! PLOT_FUNCTION_TYPE_PLOT3D); ! } ! ! gboolean ! pygtkextra_plot_data_register_plot_iterator(GtkPlotData *data, ! PyObject *function, ! PyObject *extra) ! { ! return pygtkextra_plot_data_register_plot_function_real(data, function, ! extra, ! PLOT_FUNCTION_TYPE_ITERATOR); } *************** *** 109,112 **** --- 163,167 ---- * pygtkextra_plot_data_call_plot_function * pygtkextra_plot_data_call_plot3d_function + * pygtkextra_plot_data_call_plot_iterator * * Calls the Python plot function belonging to a GtkPlotData instance. This *************** *** 114,133 **** * created with GtkPlotData.__init__(), GtkPlot.add_function() etc. * ! * 2-D Python plot functions get an X value and all the extra arguments that ! * were passed to GtkPlotData.__init__() or GtkPlot.add_function(). The plot ! * function should return the Y value or None, if it isn't possible to ! * calculate the Y value. ! * ! * 3-D Python plot functions get two values and should return the Z value or ! * None. * ! * Example: * ! * def tangent(x, factor, summand): ! * try: ! * return factor * math.tan(x) + summand ! * except: ! * return None ! * plot.add_function(tangent, 0.5, 1.0) */ gdouble --- 169,181 ---- * created with GtkPlotData.__init__(), GtkPlot.add_function() etc. * ! * 2-D plot functions get an X value and all the extra arguments that ! * were passed to GtkPlotData.__init__() or GtkPlot.add_function(). ! * The plot function should return the Y value or None, if it isn't ! * possible to calculate the Y value. * ! * 3-D plot functions get X and Y and return Z or None. * ! * Iterators get the number of the point and return a tuple of 8 or 9 ! * values, ie. (X, Y, Z, A, DX, DY, DZ, DA[, LABEL]) or None. */ gdouble *************** *** 162,166 **** PyTuple_SetItem(args, 0, value); */ - /* The following code is faster than the commented code above. */ value = PyTuple_GET_ITEM(args, 0); ((PyFloatObject *) value)->ob_fval = x; --- 210,213 ---- *************** *** 234,238 **** PyTuple_SetItem(args, 1, value); */ - /* The following code is faster than the commented code above. */ value = PyTuple_GET_ITEM(args, 0); ((PyFloatObject *) value)->ob_fval = x; --- 281,284 ---- *************** *** 270,273 **** --- 316,432 ---- return z; + } + + void + pygtkextra_plot_data_call_plot_iterator(GtkPlot *plot, GtkPlotData *data, + gint iter, + gdouble *out_x, + gdouble *out_y, + gdouble *out_z, + gdouble *out_a, + gdouble *out_dx, + gdouble *out_dy, + gdouble *out_dz, + gdouble *out_da, + gchar **out_label, + gboolean *out_error) + { + PyObject **vector, *function, *args, *value, *result; + + PyGtk_BlockThreads(); + + *out_error = TRUE; + + /* Get the Python function and the argument tuple that belong to + the given GtkPlotData instance. */ + vector = (PyObject **) gtk_object_get_data(GTK_OBJECT(data), + plot_function_key); + if (!vector) { + PyErr_SetString(PyExc_RuntimeError, "cannot find plot function"); + goto cleanup; + } + function = vector[0]; + args = vector[1]; + + /* Put the index into the first item of the argument tuple. */ + /* + value = PyInt_FromLong(iter); + if (!value) + goto cleanup; + PyTuple_SetItem(args, 0, value); + */ + value = PyTuple_GET_ITEM(args, 0); + ((PyIntObject *) value)->ob_ival = iter; + + /* Call the Python function. */ + result = PyEval_CallObject(function, args); + if (!result) + goto cleanup; + + if (PySequence_Check(result)) { + int n = PySequence_Length(result); + if (n < 8 || n > 9) { + PyErr_SetString(PyExc_TypeError, + "plot iterator must return 9-sequence or None"); + } else { + int i; + gdouble *v[8]; + PyObject *item; + + v[0] = out_x; v[1] = out_y; v[2] = out_z; v[3] = out_a; + v[4] = out_dx; v[5] = out_dy; v[6] = out_dz; v[7] = out_da; + *out_error = FALSE; + for (i = 0; i < 8; ++i) { + item = PySequence_GetItem(result, i); + if (item == Py_None) { + *v[i] = 0.0; + } else if (PyFloat_Check(item)) { + *v[i] = PyFloat_AS_DOUBLE(item); + } else if (PyNumber_Check(item) + && (value = PyNumber_Float(item))) { + *v[i] = PyFloat_AS_DOUBLE(value); + Py_DECREF(value); + } else { + gchar buf[256]; + + *out_error = TRUE; + g_snprintf(buf, sizeof(buf), + "%d%s item must be number or None", + i + 1, get_ordinal_suffix(i + 1)); + PyErr_SetString(PyExc_TypeError, buf); + Py_XDECREF(item); + Py_DECREF(result); + goto cleanup; + } + Py_XDECREF(item); + } + *out_label = NULL; + if (n >= 9) { + item = PySequence_GetItem(result, 8); + if (PyString_Check(item)) { + *out_label = PyString_AS_STRING(item); + } else if (item != Py_None) { + *out_error = TRUE; + PyErr_SetString(PyExc_TypeError, + "last item must be string or None"); + } + Py_XDECREF(item); + } + } + } else if (result != Py_None) { + PyErr_SetString(PyExc_TypeError, + "plot iterator must return sequence or None"); + } + + Py_DECREF(result); + + cleanup: + + if (PyErr_Occurred()) { + PyErr_Print(); + PyErr_Clear(); + } + + PyGtk_UnblockThreads(); } Index: pygtkextra-private.h =================================================================== RCS file: /cvsroot/python-gtkextra/python-gtkextra/gtkextra/pygtkextra-private.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** pygtkextra-private.h 2001/09/15 18:51:48 1.1.1.1 --- pygtkextra-private.h 2002/01/03 22:44:04 1.2 *************** *** 162,165 **** --- 162,168 ---- PyObject *, PyObject *); + extern gboolean pygtkextra_plot_data_register_plot_iterator(GtkPlotData *, + PyObject *, + PyObject *); extern gdouble pygtkextra_plot_data_call_plot_function(GtkPlot *, GtkPlotData *, *************** *** 169,172 **** --- 172,183 ---- gdouble, gdouble, gboolean *); + extern void pygtkextra_plot_data_call_plot_iterator(GtkPlot *, + GtkPlotData *, + gint, gdouble *, + gdouble *, gdouble *, + gdouble *, gdouble *, + gdouble *, gdouble *, + gdouble *, gchar **, + gboolean *); extern PyObject *pygtkextra_plot_data_set_points(GtkPlotData *, PyObject *, PyObject *, PyObject *, |