[dia/dia-0-97] Inconsistent line endings
- From: Hans Breuer <hans src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dia/dia-0-97] Inconsistent line endings
- Date: Sat, 7 Nov 2009 20:41:19 +0000 (UTC)
commit 3ba26d4ba2da552997fdcb7f42e2c3f0734e8d74
Author: Hans Breuer <hans breuer org>
Date: Sat Nov 7 21:39:03 2009 +0100
Inconsistent line endings
bindings/dia.swig | 738 +++++++++++++++---------------
objects/custom_lines/custom_linetypes.c | 546 ++++++++++++------------
2 files changed, 642 insertions(+), 642 deletions(-)
---
diff --git a/bindings/dia.swig b/bindings/dia.swig
index f7a6501..42450f1 100644
--- a/bindings/dia.swig
+++ b/bindings/dia.swig
@@ -1,372 +1,372 @@
-%module dia
-%{
-#include "object.h"
-#include "diarenderer.h"
-#include "diagramdata.h"
-#include "filter.h"
-#include "plug-ins.h"
-#include "properties.h"
-
-// helper functions
-#ifdef SWIGPYTHON
-#include "dia-python-extra.h"
-#endif
-#include "dia-extra.h"
-
-// the wrapper headers
-#include "dia-properties.h"
-#include "dia-object.h"
-#include "dia-renderer.h"
-#include "dia-diagramdata.h"
-%}
-
-#define G_GNUC_CONST
-#define G_BEGIN_DECLS
-#define G_END_DECLS
-#define G_INLINE_FUNC
-// for SWIG these are the same types
-typedef char gchar;
-
-%ignore TYPES_H;
-%include "diatypes.h"
-
-// the renaming needs to be done before SWIG sees the declarations
-%rename(Rectangle) _Rectangle;
-// this should be merged with rectangle somehow
-%rename(IntRectangle) _IntRectangle;
-%rename(Point) _Point;
-%rename(BezPoint) _BezPoint;
-
-%ignore GEOMETRY_H;
-// and a bunch of other stuff not yet needed
-%ignore point_add;
-%ignore point_sub;
-%ignore point_dot;
-%ignore point_len;
-%ignore point_scale;
-%ignore point_rotate;
-%ignore point_normalize;
-%ignore point_get_perp;
-%ignore point_copy;
-%ignore point_add_scaled;
-%ignore point_convex;
-%ignore point_get_normed;
-%ignore point_copy_add_scaled;
-%ignore point_in_rectangle;
-%ignore rectangle_in_rectangle;
-%ignore rectangle_union;
-%ignore int_rectangle_union;
-%ignore rectangle_intersection;
-%ignore rectangle_intersects;
-%ignore rectangle_add_point;
-%ignore rectangle_equals;
-%ignore closest_to;
-%ignore distance_bez_seg_point;
-%ignore distance_point_point;
-%ignore distance_point_point_manhattan;
-%ignore distance_rectangle_point;
-%ignore distance_line_point;
-%ignore distance_polygon_point;
-%ignore distance_bez_line_point;
-%ignore distance_bez_shape_point;
-%ignore distance_ellipse_point;
-%ignore identity_matrix;
-%ignore mult_matrix;
-%ignore translate_matrix;
-%ignore rotate_matrix;
-%ignore transform_point;
-%ignore scale_matrix;
-%ignore xshear_matrix;
-%ignore yshear_matrix;
-%ignore dot2;
-%ignore line_coef;
-%ignore line_to_point;
-%ignore point_perp;
-%ignore fillet;
-%ignore point_cross;
-%ignore calculate_object_edge;
-%include "geometry.h"
-
-// again using the original header
-%nodefaultctor; // Don't create default constructors
-%rename(ImportFilter) _DiaImportFilter;
-%rename(ExportFilter) _DiaExportFilter;
-%rename(CallbackFilter) _DiaCallbackFilter;
-%immutable; // the following are all read-only
-%include "filter.h"
-%clearnodefaultctor; // Re-enable default constructors
-%mutable;
-
-%rename(Color) _Color;
-// redefinition - the original header 'color.h' is too ugly to parse
-struct _Color
-{
- float red;
- float green;
- float blue;
-};
-
-#if 0 /* works for vc7.1, but not with vc6 and *not* for const char* ?
- * All the partial specialization needs to be avoided with vc6, no compiler support!
- */
-%include "std_vector.i"
-using namespace std;
-namespace std {
- %template(vectorString) vector<char*>;
-}
-#else
-# ifdef SWIGPYTHON
-// after hours of trying starting with 'const std::vector<const char*>&' this one seems to work ...
-%typemap (out) std::vector<char*> {
- int size = $1.size();
- $result = PyList_New(size);
- for (int i=0; i<size; i++)
- PyList_SetItem($result,i,PyString_FromString ($1[i]));
-}
-# endif
-#endif
-
-// hide the internal helper of all our wrapper clsses
-%ignore *::Self;
-
-%ignore dia::Property;
-%rename(Property) dia::IProperty;
-%include attribute.i
-%attribute(dia::IProperty, char*, type, get_type);
-%attribute(dia::IProperty, char*, name, get_name);
-%nodefaultctor; // Don't create default constructors
-%include "dia-properties.h"
-%clearnodefaultctor; // Re-enable default constructors
-
-// in general we can't handle any of our objects being NULL
-%include "constraints.i"
-%apply Pointer NONNULL { dia::IProperty * };
-%apply Pointer NONNULL { dia::Object * };
-%apply Pointer NONNULL { dia::Layer * };
-%apply Pointer NONNULL { dia::DiagramData * };
-
-// this is needed to make iteration via __getitem__ work, i.e. not returning None objects.
-// It tells SWIG to check every such pointer return and set/do the appropriate error/return.
-%typemap(ret) dia::Object*, dia::Handle*, dia::ConnectionPoint*, dia::Layer* {
- if ($1 == NULL) {
- PyErr_SetString (PyExc_IndexError, "not in list");
- return NULL;
- }
-}
-%typemap(ret) dia::IProperty*, dia::ObjectType* {
- if ($1 == NULL) {
- PyErr_SetString (PyExc_KeyError, "none such");
- return NULL;
- }
-}
-
-#ifdef SWIGPYTHON
-%extend dia::IProperty {
- %immutable;
- PyObject* value;
- %mutable;
-};
-%inline %{
-PyObject* dia_IProperty_value_get (dia::IProperty* self) {
- int vi;
- if (self->get (&vi)) return PyInt_FromLong(vi);
- double vd;
- if (self->get (&vd)) return PyFloat_FromDouble(vd);
- const char* vcs;
- if (self->get (&vcs)) return PyString_FromString(vcs);
- char* vs; // not sure if this duplication const char* vs. char* is really needed
- if (self->get (&vs)) return PyString_FromString(vs);
- ::_Point vp;
- if (self->get (&vp)) return SWIG_NewPointerObj(&vp, SWIGTYPE_p__Point, 0);
- ::_Rectangle vr;
- if (self->get (&vr)) return SWIG_NewPointerObj(&vr, SWIGTYPE_p__Rectangle, 0);
- ::_Color vc;
- if (self->get (&vc)) return SWIG_NewPointerObj(&vc, SWIGTYPE_p__Color, 0);
- const std::vector<dia::IProperty*>* vecProp;
- if (self->get (&vecProp)) {
- const size_t n = vecProp->size();
- PyObject* ret = PyTuple_New(n);
- for (int i = 0; i < n; ++i)
- PyTuple_SetItem(ret, i, SWIG_NewPointerObj((*vecProp)[i], SWIGTYPE_p_dia__IProperty, 0));
- return ret;
- }
-
- // generic fallback - not of much use if one is interested in value
- return SWIG_NewPointerObj(self, SWIGTYPE_p_dia__IProperty, 0);
-}
-%}
-#endif
-
-// must do this 'by hand' cause all the std::map stuff doesn't work with msvc6
-%extend dia::Properties {
- dia::IProperty* __getitem__(const char* s) { return self->getitem(s); }
-
- void __setitem__(const char* s, int v) { self->setitem(s, v); }
- void __setitem__(const char* s, double v) { self->setitem(s, v); }
- void __setitem__(const char* s, const char* v) { self->setitem(s, v); }
-#ifdef SWIGPYTHON
- void __setitem__(const char* s, PyObject* v) {
- std::vector<double> vecDouble;
- std::vector<dia::IProperty*> vecProp;
- if (DiaPythonExtra_ToVector (v, vecDouble))
- self->setitem (s, vecDouble);
- else if (DiaPythonExtra_ToVector (v, vecProp))
- self->setitem (s, vecProp);
- else {
- PyObject* vs = PyObject_Str (v);
- printf ("NOT assigning '%s' = %s\n", s, PyString_AsString (vs));
- }
- }
-#endif
-};
-
-%nodefaultctor; // Don't create default constructors
-%include "dia-connections.h"
-%clearnodefaultctor; // Re-enable default constructors
-// again by hand: provide a Python compatible sequence interface
-%extend dia::Connections {
- int __len__ () { return self->len(); }
- dia::ConnectionPoint* __getitem__ (int n) { return self->getitem(n); }
-};
-%extend dia::Handles {
- int __len__ () { return self->len(); }
- dia::Handle* __getitem__ (int n) { return self->getitem(n); }
-};
-
-%attribute(dia::Handle, dia::ConnectionPoint*, connected_to, get_connected_to);
-%attribute(dia::ConnectionPoint, dia::Object*, object, get_object);
-%extend dia::Objects {
- int __len__ () { return self->len(); }
- dia::Object* __getitem__ (int n) { return self->getitem(n); }
-};
-
-%nodefaultctor; // Don't create default constructors
-%ignore dia::Object::bbox;
-%include "dia-object.h"
-%clearnodefaultctor; // Re-enable default constructors
-#ifdef SWIGPYTHON
-// there may be a target language independent way to do this but not w/o understanding typemaps ;)
-%extend dia::ObjectType {
- // not only creates the object but also two handles to be returned
- PyObject* create (double x, double y) {
- PyObject* ret = PyTuple_New(3);
- dia::Handle *h1, *h2;
- dia::Object *o = self->create (x,y, &h1, &h2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(o, SWIGTYPE_p_dia__Object, 0));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(h1, SWIGTYPE_p_dia__Handle, 0));
- PyTuple_SetItem(ret,2,SWIG_NewPointerObj(h2, SWIGTYPE_p_dia__Handle, 0));
- return ret;
- }
-};
-%include attribute.i
-%attribute(dia::Object, _Rectangle, bounding_box, bbox);
-%extend dia::Object {
- // convenience/compatibility taking the position as tuple
- PyObject* move_handle (dia::Handle* h, PyObject* pos, int reason, int modifiers)
- {
- double x = PyFloat_AsDouble(PyTuple_GetItem (pos, 0));
- double y = PyFloat_AsDouble(PyTuple_GetItem (pos, 1));
- self->move_handle (h, x, y, (HandleMoveReason)reason, (ModifierKeys)modifiers);
- Py_INCREF(Py_None);
- return Py_None;
- }
-};
-#endif
-
-%nodefaultctor; // Don't create default constructors
-%include "dia-diagramdata.h"
-%clearnodefaultctor; // Re-enable default constructors
-
-#if 0 // again no partial templates with msvc6
-%include "std_vector.i"
-%template(Layers) std::vector<const dia::Layer*>;
-#else
-%extend dia::Layers {
- int __len__ () { return self->len(); }
- dia::Layer* __getitem__ (int n) { return self->getitem(n); }
-};
-#endif
-
-%nodefaultctor; // Don't create default constructors
-%include "dia-renderer.h"
-%clearnodefaultctor; // Re-enable default constructors
-
-// afaik SWIG does not support cross language callbacks; so let's build one
-// NOTE: although renamed above we need to use the old name here
-%extend _DiaExportFilter {
- // don't use 'export' as this produces nothing w/o warning
+%module dia
+%{
+#include "object.h"
+#include "diarenderer.h"
+#include "diagramdata.h"
+#include "filter.h"
+#include "plug-ins.h"
+#include "properties.h"
+
+// helper functions
+#ifdef SWIGPYTHON
+#include "dia-python-extra.h"
+#endif
+#include "dia-extra.h"
+
+// the wrapper headers
+#include "dia-properties.h"
+#include "dia-object.h"
+#include "dia-renderer.h"
+#include "dia-diagramdata.h"
+%}
+
+#define G_GNUC_CONST
+#define G_BEGIN_DECLS
+#define G_END_DECLS
+#define G_INLINE_FUNC
+// for SWIG these are the same types
+typedef char gchar;
+
+%ignore TYPES_H;
+%include "diatypes.h"
+
+// the renaming needs to be done before SWIG sees the declarations
+%rename(Rectangle) _Rectangle;
+// this should be merged with rectangle somehow
+%rename(IntRectangle) _IntRectangle;
+%rename(Point) _Point;
+%rename(BezPoint) _BezPoint;
+
+%ignore GEOMETRY_H;
+// and a bunch of other stuff not yet needed
+%ignore point_add;
+%ignore point_sub;
+%ignore point_dot;
+%ignore point_len;
+%ignore point_scale;
+%ignore point_rotate;
+%ignore point_normalize;
+%ignore point_get_perp;
+%ignore point_copy;
+%ignore point_add_scaled;
+%ignore point_convex;
+%ignore point_get_normed;
+%ignore point_copy_add_scaled;
+%ignore point_in_rectangle;
+%ignore rectangle_in_rectangle;
+%ignore rectangle_union;
+%ignore int_rectangle_union;
+%ignore rectangle_intersection;
+%ignore rectangle_intersects;
+%ignore rectangle_add_point;
+%ignore rectangle_equals;
+%ignore closest_to;
+%ignore distance_bez_seg_point;
+%ignore distance_point_point;
+%ignore distance_point_point_manhattan;
+%ignore distance_rectangle_point;
+%ignore distance_line_point;
+%ignore distance_polygon_point;
+%ignore distance_bez_line_point;
+%ignore distance_bez_shape_point;
+%ignore distance_ellipse_point;
+%ignore identity_matrix;
+%ignore mult_matrix;
+%ignore translate_matrix;
+%ignore rotate_matrix;
+%ignore transform_point;
+%ignore scale_matrix;
+%ignore xshear_matrix;
+%ignore yshear_matrix;
+%ignore dot2;
+%ignore line_coef;
+%ignore line_to_point;
+%ignore point_perp;
+%ignore fillet;
+%ignore point_cross;
+%ignore calculate_object_edge;
+%include "geometry.h"
+
+// again using the original header
+%nodefaultctor; // Don't create default constructors
+%rename(ImportFilter) _DiaImportFilter;
+%rename(ExportFilter) _DiaExportFilter;
+%rename(CallbackFilter) _DiaCallbackFilter;
+%immutable; // the following are all read-only
+%include "filter.h"
+%clearnodefaultctor; // Re-enable default constructors
+%mutable;
+
+%rename(Color) _Color;
+// redefinition - the original header 'color.h' is too ugly to parse
+struct _Color
+{
+ float red;
+ float green;
+ float blue;
+};
+
+#if 0 /* works for vc7.1, but not with vc6 and *not* for const char* ?
+ * All the partial specialization needs to be avoided with vc6, no compiler support!
+ */
+%include "std_vector.i"
+using namespace std;
+namespace std {
+ %template(vectorString) vector<char*>;
+}
+#else
+# ifdef SWIGPYTHON
+// after hours of trying starting with 'const std::vector<const char*>&' this one seems to work ...
+%typemap (out) std::vector<char*> {
+ int size = $1.size();
+ $result = PyList_New(size);
+ for (int i=0; i<size; i++)
+ PyList_SetItem($result,i,PyString_FromString ($1[i]));
+}
+# endif
+#endif
+
+// hide the internal helper of all our wrapper clsses
+%ignore *::Self;
+
+%ignore dia::Property;
+%rename(Property) dia::IProperty;
+%include attribute.i
+%attribute(dia::IProperty, char*, type, get_type);
+%attribute(dia::IProperty, char*, name, get_name);
+%nodefaultctor; // Don't create default constructors
+%include "dia-properties.h"
+%clearnodefaultctor; // Re-enable default constructors
+
+// in general we can't handle any of our objects being NULL
+%include "constraints.i"
+%apply Pointer NONNULL { dia::IProperty * };
+%apply Pointer NONNULL { dia::Object * };
+%apply Pointer NONNULL { dia::Layer * };
+%apply Pointer NONNULL { dia::DiagramData * };
+
+// this is needed to make iteration via __getitem__ work, i.e. not returning None objects.
+// It tells SWIG to check every such pointer return and set/do the appropriate error/return.
+%typemap(ret) dia::Object*, dia::Handle*, dia::ConnectionPoint*, dia::Layer* {
+ if ($1 == NULL) {
+ PyErr_SetString (PyExc_IndexError, "not in list");
+ return NULL;
+ }
+}
+%typemap(ret) dia::IProperty*, dia::ObjectType* {
+ if ($1 == NULL) {
+ PyErr_SetString (PyExc_KeyError, "none such");
+ return NULL;
+ }
+}
+
+#ifdef SWIGPYTHON
+%extend dia::IProperty {
+ %immutable;
+ PyObject* value;
+ %mutable;
+};
+%inline %{
+PyObject* dia_IProperty_value_get (dia::IProperty* self) {
+ int vi;
+ if (self->get (&vi)) return PyInt_FromLong(vi);
+ double vd;
+ if (self->get (&vd)) return PyFloat_FromDouble(vd);
+ const char* vcs;
+ if (self->get (&vcs)) return PyString_FromString(vcs);
+ char* vs; // not sure if this duplication const char* vs. char* is really needed
+ if (self->get (&vs)) return PyString_FromString(vs);
+ ::_Point vp;
+ if (self->get (&vp)) return SWIG_NewPointerObj(&vp, SWIGTYPE_p__Point, 0);
+ ::_Rectangle vr;
+ if (self->get (&vr)) return SWIG_NewPointerObj(&vr, SWIGTYPE_p__Rectangle, 0);
+ ::_Color vc;
+ if (self->get (&vc)) return SWIG_NewPointerObj(&vc, SWIGTYPE_p__Color, 0);
+ const std::vector<dia::IProperty*>* vecProp;
+ if (self->get (&vecProp)) {
+ const size_t n = vecProp->size();
+ PyObject* ret = PyTuple_New(n);
+ for (int i = 0; i < n; ++i)
+ PyTuple_SetItem(ret, i, SWIG_NewPointerObj((*vecProp)[i], SWIGTYPE_p_dia__IProperty, 0));
+ return ret;
+ }
+
+ // generic fallback - not of much use if one is interested in value
+ return SWIG_NewPointerObj(self, SWIGTYPE_p_dia__IProperty, 0);
+}
+%}
+#endif
+
+// must do this 'by hand' cause all the std::map stuff doesn't work with msvc6
+%extend dia::Properties {
+ dia::IProperty* __getitem__(const char* s) { return self->getitem(s); }
+
+ void __setitem__(const char* s, int v) { self->setitem(s, v); }
+ void __setitem__(const char* s, double v) { self->setitem(s, v); }
+ void __setitem__(const char* s, const char* v) { self->setitem(s, v); }
+#ifdef SWIGPYTHON
+ void __setitem__(const char* s, PyObject* v) {
+ std::vector<double> vecDouble;
+ std::vector<dia::IProperty*> vecProp;
+ if (DiaPythonExtra_ToVector (v, vecDouble))
+ self->setitem (s, vecDouble);
+ else if (DiaPythonExtra_ToVector (v, vecProp))
+ self->setitem (s, vecProp);
+ else {
+ PyObject* vs = PyObject_Str (v);
+ printf ("NOT assigning '%s' = %s\n", s, PyString_AsString (vs));
+ }
+ }
+#endif
+};
+
+%nodefaultctor; // Don't create default constructors
+%include "dia-connections.h"
+%clearnodefaultctor; // Re-enable default constructors
+// again by hand: provide a Python compatible sequence interface
+%extend dia::Connections {
+ int __len__ () { return self->len(); }
+ dia::ConnectionPoint* __getitem__ (int n) { return self->getitem(n); }
+};
+%extend dia::Handles {
+ int __len__ () { return self->len(); }
+ dia::Handle* __getitem__ (int n) { return self->getitem(n); }
+};
+
+%attribute(dia::Handle, dia::ConnectionPoint*, connected_to, get_connected_to);
+%attribute(dia::ConnectionPoint, dia::Object*, object, get_object);
+%extend dia::Objects {
+ int __len__ () { return self->len(); }
+ dia::Object* __getitem__ (int n) { return self->getitem(n); }
+};
+
+%nodefaultctor; // Don't create default constructors
+%ignore dia::Object::bbox;
+%include "dia-object.h"
+%clearnodefaultctor; // Re-enable default constructors
+#ifdef SWIGPYTHON
+// there may be a target language independent way to do this but not w/o understanding typemaps ;)
+%extend dia::ObjectType {
+ // not only creates the object but also two handles to be returned
+ PyObject* create (double x, double y) {
+ PyObject* ret = PyTuple_New(3);
+ dia::Handle *h1, *h2;
+ dia::Object *o = self->create (x,y, &h1, &h2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(o, SWIGTYPE_p_dia__Object, 0));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(h1, SWIGTYPE_p_dia__Handle, 0));
+ PyTuple_SetItem(ret,2,SWIG_NewPointerObj(h2, SWIGTYPE_p_dia__Handle, 0));
+ return ret;
+ }
+};
+%include attribute.i
+%attribute(dia::Object, _Rectangle, bounding_box, bbox);
+%extend dia::Object {
+ // convenience/compatibility taking the position as tuple
+ PyObject* move_handle (dia::Handle* h, PyObject* pos, int reason, int modifiers)
+ {
+ double x = PyFloat_AsDouble(PyTuple_GetItem (pos, 0));
+ double y = PyFloat_AsDouble(PyTuple_GetItem (pos, 1));
+ self->move_handle (h, x, y, (HandleMoveReason)reason, (ModifierKeys)modifiers);
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+};
+#endif
+
+%nodefaultctor; // Don't create default constructors
+%include "dia-diagramdata.h"
+%clearnodefaultctor; // Re-enable default constructors
+
+#if 0 // again no partial templates with msvc6
+%include "std_vector.i"
+%template(Layers) std::vector<const dia::Layer*>;
+#else
+%extend dia::Layers {
+ int __len__ () { return self->len(); }
+ dia::Layer* __getitem__ (int n) { return self->getitem(n); }
+};
+#endif
+
+%nodefaultctor; // Don't create default constructors
+%include "dia-renderer.h"
+%clearnodefaultctor; // Re-enable default constructors
+
+// afaik SWIG does not support cross language callbacks; so let's build one
+// NOTE: although renamed above we need to use the old name here
+%extend _DiaExportFilter {
+ // don't use 'export' as this produces nothing w/o warning
void do_export (dia::DiagramData *dia, const gchar *filename) {
- if (dia)
+ if (dia)
self->export_func (dia->Self(), filename, filename, self->user_data);
else
- g_warning ( "%s no data", G_STRFUNC);
- }
-};
-
-%include "dia-extra.h"
-
-%ignore _ot_item;
-#ifdef SWIGPYTHON
-%inline %{
-// compatibility functions, just to leave the original plug-ins unchanged
-void register_import (const char* name, const char* ext, PyObject* user)
-{
- printf ("dia.register_import ('%s', '%s', ...) faked.\n", name, ext);
-}
-void register_callback (const char* desc, const char* menu, PyObject* user)
-{
- printf ("dia.register_import ('%s', '%s', ...) faked.\n", desc, menu);
-}
-void register_action (const char* desc, const char* action, const char* menu, PyObject* user)
-{
- printf ("dia.register_action ('%s', <%s>'%s', ...) faked.\n", desc, action, menu);
-}
-//! callback to be applied on every object in the map
-static void
-_ot_item (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- gchar *name = (gchar *)key;
- DiaObjectType *type = (DiaObjectType *)value;
- PyObject *dict = (PyObject *)user_data;
- PyObject *k, *v;
-
- k = PyString_FromString(name);
- v = SWIG_NewPointerObj(type, SWIGTYPE_p_dia__ObjectType, 0);
- if (k && v)
- PyDict_SetItem(dict, k, v);
- Py_XDECREF(k);
- Py_XDECREF(v);
-}
-PyObject* registered_types ()
-{
- PyObject *dict = PyDict_New();
-
- object_registry_foreach(_ot_item, dict);
-
- return dict;
-}
-%}
-#endif
-
-// as long as we are not dependending on app/* - which we dont want! - we need to
-// fake Display to some extent to make old pydia plug-ins work
-%pythoncode %{
-class Display :
- def add_update_all (self) :
- pass
-class Diagram :
- def __init__ (self) :
- self.data = DiagramData ()
- def display (self) :
- return Display ()
- def update_extents (self) :
- self.data.update_extents ()
- def flush (self) :
- pass
-def new (s) :
- return Diagram()
-def active_display () :
- return None
-%}
+ g_warning ( "%s no data", G_STRFUNC);
+ }
+};
+
+%include "dia-extra.h"
+
+%ignore _ot_item;
+#ifdef SWIGPYTHON
+%inline %{
+// compatibility functions, just to leave the original plug-ins unchanged
+void register_import (const char* name, const char* ext, PyObject* user)
+{
+ printf ("dia.register_import ('%s', '%s', ...) faked.\n", name, ext);
+}
+void register_callback (const char* desc, const char* menu, PyObject* user)
+{
+ printf ("dia.register_import ('%s', '%s', ...) faked.\n", desc, menu);
+}
+void register_action (const char* desc, const char* action, const char* menu, PyObject* user)
+{
+ printf ("dia.register_action ('%s', <%s>'%s', ...) faked.\n", desc, action, menu);
+}
+//! callback to be applied on every object in the map
+static void
+_ot_item (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ gchar *name = (gchar *)key;
+ DiaObjectType *type = (DiaObjectType *)value;
+ PyObject *dict = (PyObject *)user_data;
+ PyObject *k, *v;
+
+ k = PyString_FromString(name);
+ v = SWIG_NewPointerObj(type, SWIGTYPE_p_dia__ObjectType, 0);
+ if (k && v)
+ PyDict_SetItem(dict, k, v);
+ Py_XDECREF(k);
+ Py_XDECREF(v);
+}
+PyObject* registered_types ()
+{
+ PyObject *dict = PyDict_New();
+
+ object_registry_foreach(_ot_item, dict);
+
+ return dict;
+}
+%}
+#endif
+
+// as long as we are not dependending on app/* - which we dont want! - we need to
+// fake Display to some extent to make old pydia plug-ins work
+%pythoncode %{
+class Display :
+ def add_update_all (self) :
+ pass
+class Diagram :
+ def __init__ (self) :
+ self.data = DiagramData ()
+ def display (self) :
+ return Display ()
+ def update_extents (self) :
+ self.data.update_extents ()
+ def flush (self) :
+ pass
+def new (s) :
+ return Diagram()
+def active_display () :
+ return None
+%}
diff --git a/objects/custom_lines/custom_linetypes.c b/objects/custom_lines/custom_linetypes.c
index 39dda04..68b6758 100644
--- a/objects/custom_lines/custom_linetypes.c
+++ b/objects/custom_lines/custom_linetypes.c
@@ -1,273 +1,273 @@
-/* Dia -- an diagram creation/manipulation program
- * Copyright (C) 1998, 1999 Alexander Larsson
- *
- * Custom Lines -- line shapes defined in XML rather than C.
- * Based on the original Custom Objects plugin.
- * Copyright (C) 1999 James Henstridge.
- *
- * Adapted for Custom Lines plugin by Marcel Toele.
- * Modifications (C) 2007 Kern Automatiseringsdiensten BV.
- *
- * Rewrite to use only public API (C) 2008 Hans Breuer
- *
- * 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.
- */
-
-#include <assert.h>
-#include <gmodule.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-
-#include "object.h"
-
-#include "line_info.h"
-#include "custom_linetypes.h"
-
-#include "properties.h"
-#include "propinternals.h"
-
-#include "pixmaps/default.xpm"
-
-static void customline_apply_properties( DiaObject* line, LineInfo* info );
-static DiaObject* customline_create(Point *startpoint,
- void *user_data,
- Handle **handle1,
- Handle **handle2);
-static DiaObject *custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename);
-static DiaObject *custom_polyline_load (ObjectNode obj_node, int version, const char *filename);
-static DiaObject *custom_bezierline_load (ObjectNode obj_node, int version, const char *filename);
-
-static void customline_save (DiaObject *object, ObjectNode obj_node, const char *filename);
-
-static ObjectTypeOps
-custom_zigzagline_type_ops = {
- (CreateFunc)customline_create, /* create */
- (LoadFunc) custom_zigzagline_load, /* load */
- (SaveFunc) customline_save, /* save */
- (GetDefaultsFunc) NULL /* get_defaults*/,
- (ApplyDefaultsFunc) NULL /* apply_defaults*/
-};
-
-static ObjectTypeOps
-custom_polyline_type_ops = {
- (CreateFunc)customline_create, /* create */
- (LoadFunc) custom_polyline_load, /* load */
- (SaveFunc) customline_save, /* save */
- (GetDefaultsFunc) NULL /* get_defaults*/,
- (ApplyDefaultsFunc) NULL /* apply_defaults*/
-};
-
-static ObjectTypeOps
-custom_bezierline_type_ops = {
- (CreateFunc)customline_create, /* create */
- (LoadFunc) custom_bezierline_load, /* load */
- (SaveFunc) customline_save, /* save */
- (GetDefaultsFunc) NULL /* get_defaults*/,
- (ApplyDefaultsFunc) NULL /* apply_defaults*/
-};
-
-/* our delegates types, intialized on demand */
-static DiaObjectType *polyline_ot = NULL;
-static DiaObjectType *bezier_ot = NULL;
-static DiaObjectType *zigzag_ot = NULL;
-
-
-static gboolean
-ensure_standard_types (void)
-{
- if (!zigzag_ot)
- zigzag_ot = object_get_type ("Standard - ZigZagLine");
- if (!polyline_ot)
- polyline_ot = object_get_type ("Standard - PolyLine");
- if (!bezier_ot)
- bezier_ot = object_get_type ("Standard - BezierLine");
-
- return (polyline_ot && bezier_ot && zigzag_ot);
-}
-
-static DiaObject *
-custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename)
-{
- ensure_standard_types ();
-
- if (!zigzag_ot) {
- g_warning ("Can't delegate to 'Standard - ZigZagLine'");
- return NULL;
- }
- return zigzag_ot->ops->load (obj_node, version, filename);
-}
-static DiaObject *
-custom_polyline_load (ObjectNode obj_node, int version, const char *filename)
-{
- ensure_standard_types ();
-
- if (!polyline_ot) {
- g_warning ("Can't delegate to 'Standard - PolyLine'");
- return NULL;
- }
- return polyline_ot->ops->load (obj_node, version, filename);
-}
-static DiaObject *
-custom_bezierline_load (ObjectNode obj_node, int version, const char *filename)
-{
- ensure_standard_types ();
-
- if (!bezier_ot) {
- g_warning ("Can't delegate to 'Standard - BezierLine'");
- return NULL;
- }
- return bezier_ot->ops->load (obj_node, version, filename);
-}
-
-static void
-customline_save (DiaObject *object, ObjectNode obj_node, const char *filename)
-{
- g_assert (object->type && object->type->ops && object->type->ops->save);
-
- if (!ensure_standard_types()) {
- g_warning ("Can't create standard types");
- return;
- }
-
- if (object->type->ops == &custom_zigzagline_type_ops)
- zigzag_ot->ops->save (object, obj_node, filename);
- else if (object->type->ops == &custom_polyline_type_ops)
- polyline_ot->ops->save (object, obj_node, filename);
- else if (object->type->ops == &custom_bezierline_type_ops)
- bezier_ot->ops->save (object, obj_node, filename);
- else
- g_warning ("customline_save() no delegate");
-}
-
-/* the order here must match the one in customline_apply_properties */
-static PropDescription
-_customline_prop_descs[] = {
- { "line_colour", PROP_TYPE_COLOUR },
- { "line_style", PROP_TYPE_LINESTYLE },
- { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH },
- { "corner_radius", PROP_TYPE_REAL },
- { "start_arrow", PROP_TYPE_ARROW },
- { "end_arrow", PROP_TYPE_ARROW },
- PROP_DESC_END
-};
-
-void
-customline_apply_properties( DiaObject* line, LineInfo* info )
-{
- GPtrArray *props;
- LinestyleProperty *lsprop;
- ColorProperty *cprop;
- RealProperty *rprop;
- ArrowProperty *aprop;
-
- props = prop_list_from_descs( _customline_prop_descs, pdtpp_true );
- g_assert( props->len == 6 );
-
- /* order/index/type must match _customline_prop_descs */
- cprop = g_ptr_array_index( props, 0 );
- cprop->color_data = info->line_color;
-
- lsprop = g_ptr_array_index( props, 1 );
- lsprop->style = info->line_style;
- lsprop->dash = info->dashlength;
-
- rprop = g_ptr_array_index( props, 2 );
- rprop->real_data = info->line_width;
-
- rprop = g_ptr_array_index( props, 3 );
- rprop->real_data = info->corner_radius;
-
- aprop = g_ptr_array_index( props, 4 );
- aprop->arrow_data = info->start_arrow;
-
- aprop = g_ptr_array_index( props, 5 );
- aprop->arrow_data = info->end_arrow;
-
- line->ops->set_props( line, props );
-
- prop_list_free(props);
-}
-
-DiaObject *
-customline_create(Point *startpoint,
- void *user_data,
- Handle **handle1,
- Handle **handle2)
-{
- DiaObject* res = NULL;
- LineInfo* line_info = (LineInfo*)user_data;
-
- if (!ensure_standard_types()) {
- g_warning ("Can't create standar types.");
- return NULL;
- }
-
- if (line_info->type == CUSTOM_LINETYPE_ZIGZAGLINE)
- res = zigzag_ot->ops->create( startpoint, user_data, handle1, handle2 );
- else if (line_info->type == CUSTOM_LINETYPE_POLYLINE)
- res = polyline_ot->ops->create( startpoint, NULL, handle1, handle2 );
- else if (line_info->type == CUSTOM_LINETYPE_BEZIERLINE)
- res = bezier_ot->ops->create( startpoint, NULL, handle1, handle2 );
- else
- g_warning(_("INTERNAL: CustomLines: Illegal line type in LineInfo object."));
-
- if (res) {
- customline_apply_properties (res, line_info);
- res->type = line_info->object_type;
- }
-
- return( res );
-}
-
-void
-custom_linetype_new(LineInfo *info, DiaObjectType **otype)
-{
- DiaObjectType *obj = g_new0(DiaObjectType, 1);
-
- obj->version = 1;
- obj->pixmap = default_xpm;
-
- if (info->type == CUSTOM_LINETYPE_ZIGZAGLINE)
- obj->ops = &custom_zigzagline_type_ops;
- else if (info->type == CUSTOM_LINETYPE_POLYLINE)
- obj->ops = &custom_polyline_type_ops;
- else if (info->type == CUSTOM_LINETYPE_BEZIERLINE)
- obj->ops = &custom_bezierline_type_ops;
- else
- g_warning(_("INTERNAL: CustomLines: Illegal line type in LineInfo object %s."),
- obj->name);
-
- obj->name = info->name;
- obj->default_user_data = info;
-
- if (info->icon_filename) {
- struct stat buf;
- if (0==stat(info->icon_filename,&buf)) {
- obj->pixmap = NULL;
- obj->pixmap_file = info->icon_filename;
- } else {
- g_warning(_("Cannot open icon file %s for object type '%s'."),
- info->icon_filename, obj->name);
- }
- }
-
- info->object_type = obj; /* <-- Reciproce type linking */
-
- obj->default_user_data = (void*)info;
-
- *otype = obj;
-}
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998, 1999 Alexander Larsson
+ *
+ * Custom Lines -- line shapes defined in XML rather than C.
+ * Based on the original Custom Objects plugin.
+ * Copyright (C) 1999 James Henstridge.
+ *
+ * Adapted for Custom Lines plugin by Marcel Toele.
+ * Modifications (C) 2007 Kern Automatiseringsdiensten BV.
+ *
+ * Rewrite to use only public API (C) 2008 Hans Breuer
+ *
+ * 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.
+ */
+
+#include <assert.h>
+#include <gmodule.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include "object.h"
+
+#include "line_info.h"
+#include "custom_linetypes.h"
+
+#include "properties.h"
+#include "propinternals.h"
+
+#include "pixmaps/default.xpm"
+
+static void customline_apply_properties( DiaObject* line, LineInfo* info );
+static DiaObject* customline_create(Point *startpoint,
+ void *user_data,
+ Handle **handle1,
+ Handle **handle2);
+static DiaObject *custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename);
+static DiaObject *custom_polyline_load (ObjectNode obj_node, int version, const char *filename);
+static DiaObject *custom_bezierline_load (ObjectNode obj_node, int version, const char *filename);
+
+static void customline_save (DiaObject *object, ObjectNode obj_node, const char *filename);
+
+static ObjectTypeOps
+custom_zigzagline_type_ops = {
+ (CreateFunc)customline_create, /* create */
+ (LoadFunc) custom_zigzagline_load, /* load */
+ (SaveFunc) customline_save, /* save */
+ (GetDefaultsFunc) NULL /* get_defaults*/,
+ (ApplyDefaultsFunc) NULL /* apply_defaults*/
+};
+
+static ObjectTypeOps
+custom_polyline_type_ops = {
+ (CreateFunc)customline_create, /* create */
+ (LoadFunc) custom_polyline_load, /* load */
+ (SaveFunc) customline_save, /* save */
+ (GetDefaultsFunc) NULL /* get_defaults*/,
+ (ApplyDefaultsFunc) NULL /* apply_defaults*/
+};
+
+static ObjectTypeOps
+custom_bezierline_type_ops = {
+ (CreateFunc)customline_create, /* create */
+ (LoadFunc) custom_bezierline_load, /* load */
+ (SaveFunc) customline_save, /* save */
+ (GetDefaultsFunc) NULL /* get_defaults*/,
+ (ApplyDefaultsFunc) NULL /* apply_defaults*/
+};
+
+/* our delegates types, intialized on demand */
+static DiaObjectType *polyline_ot = NULL;
+static DiaObjectType *bezier_ot = NULL;
+static DiaObjectType *zigzag_ot = NULL;
+
+
+static gboolean
+ensure_standard_types (void)
+{
+ if (!zigzag_ot)
+ zigzag_ot = object_get_type ("Standard - ZigZagLine");
+ if (!polyline_ot)
+ polyline_ot = object_get_type ("Standard - PolyLine");
+ if (!bezier_ot)
+ bezier_ot = object_get_type ("Standard - BezierLine");
+
+ return (polyline_ot && bezier_ot && zigzag_ot);
+}
+
+static DiaObject *
+custom_zigzagline_load (ObjectNode obj_node, int version, const char *filename)
+{
+ ensure_standard_types ();
+
+ if (!zigzag_ot) {
+ g_warning ("Can't delegate to 'Standard - ZigZagLine'");
+ return NULL;
+ }
+ return zigzag_ot->ops->load (obj_node, version, filename);
+}
+static DiaObject *
+custom_polyline_load (ObjectNode obj_node, int version, const char *filename)
+{
+ ensure_standard_types ();
+
+ if (!polyline_ot) {
+ g_warning ("Can't delegate to 'Standard - PolyLine'");
+ return NULL;
+ }
+ return polyline_ot->ops->load (obj_node, version, filename);
+}
+static DiaObject *
+custom_bezierline_load (ObjectNode obj_node, int version, const char *filename)
+{
+ ensure_standard_types ();
+
+ if (!bezier_ot) {
+ g_warning ("Can't delegate to 'Standard - BezierLine'");
+ return NULL;
+ }
+ return bezier_ot->ops->load (obj_node, version, filename);
+}
+
+static void
+customline_save (DiaObject *object, ObjectNode obj_node, const char *filename)
+{
+ g_assert (object->type && object->type->ops && object->type->ops->save);
+
+ if (!ensure_standard_types()) {
+ g_warning ("Can't create standard types");
+ return;
+ }
+
+ if (object->type->ops == &custom_zigzagline_type_ops)
+ zigzag_ot->ops->save (object, obj_node, filename);
+ else if (object->type->ops == &custom_polyline_type_ops)
+ polyline_ot->ops->save (object, obj_node, filename);
+ else if (object->type->ops == &custom_bezierline_type_ops)
+ bezier_ot->ops->save (object, obj_node, filename);
+ else
+ g_warning ("customline_save() no delegate");
+}
+
+/* the order here must match the one in customline_apply_properties */
+static PropDescription
+_customline_prop_descs[] = {
+ { "line_colour", PROP_TYPE_COLOUR },
+ { "line_style", PROP_TYPE_LINESTYLE },
+ { PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH },
+ { "corner_radius", PROP_TYPE_REAL },
+ { "start_arrow", PROP_TYPE_ARROW },
+ { "end_arrow", PROP_TYPE_ARROW },
+ PROP_DESC_END
+};
+
+void
+customline_apply_properties( DiaObject* line, LineInfo* info )
+{
+ GPtrArray *props;
+ LinestyleProperty *lsprop;
+ ColorProperty *cprop;
+ RealProperty *rprop;
+ ArrowProperty *aprop;
+
+ props = prop_list_from_descs( _customline_prop_descs, pdtpp_true );
+ g_assert( props->len == 6 );
+
+ /* order/index/type must match _customline_prop_descs */
+ cprop = g_ptr_array_index( props, 0 );
+ cprop->color_data = info->line_color;
+
+ lsprop = g_ptr_array_index( props, 1 );
+ lsprop->style = info->line_style;
+ lsprop->dash = info->dashlength;
+
+ rprop = g_ptr_array_index( props, 2 );
+ rprop->real_data = info->line_width;
+
+ rprop = g_ptr_array_index( props, 3 );
+ rprop->real_data = info->corner_radius;
+
+ aprop = g_ptr_array_index( props, 4 );
+ aprop->arrow_data = info->start_arrow;
+
+ aprop = g_ptr_array_index( props, 5 );
+ aprop->arrow_data = info->end_arrow;
+
+ line->ops->set_props( line, props );
+
+ prop_list_free(props);
+}
+
+DiaObject *
+customline_create(Point *startpoint,
+ void *user_data,
+ Handle **handle1,
+ Handle **handle2)
+{
+ DiaObject* res = NULL;
+ LineInfo* line_info = (LineInfo*)user_data;
+
+ if (!ensure_standard_types()) {
+ g_warning ("Can't create standar types.");
+ return NULL;
+ }
+
+ if (line_info->type == CUSTOM_LINETYPE_ZIGZAGLINE)
+ res = zigzag_ot->ops->create( startpoint, user_data, handle1, handle2 );
+ else if (line_info->type == CUSTOM_LINETYPE_POLYLINE)
+ res = polyline_ot->ops->create( startpoint, NULL, handle1, handle2 );
+ else if (line_info->type == CUSTOM_LINETYPE_BEZIERLINE)
+ res = bezier_ot->ops->create( startpoint, NULL, handle1, handle2 );
+ else
+ g_warning(_("INTERNAL: CustomLines: Illegal line type in LineInfo object."));
+
+ if (res) {
+ customline_apply_properties (res, line_info);
+ res->type = line_info->object_type;
+ }
+
+ return( res );
+}
+
+void
+custom_linetype_new(LineInfo *info, DiaObjectType **otype)
+{
+ DiaObjectType *obj = g_new0(DiaObjectType, 1);
+
+ obj->version = 1;
+ obj->pixmap = default_xpm;
+
+ if (info->type == CUSTOM_LINETYPE_ZIGZAGLINE)
+ obj->ops = &custom_zigzagline_type_ops;
+ else if (info->type == CUSTOM_LINETYPE_POLYLINE)
+ obj->ops = &custom_polyline_type_ops;
+ else if (info->type == CUSTOM_LINETYPE_BEZIERLINE)
+ obj->ops = &custom_bezierline_type_ops;
+ else
+ g_warning(_("INTERNAL: CustomLines: Illegal line type in LineInfo object %s."),
+ obj->name);
+
+ obj->name = info->name;
+ obj->default_user_data = info;
+
+ if (info->icon_filename) {
+ struct stat buf;
+ if (0==stat(info->icon_filename,&buf)) {
+ obj->pixmap = NULL;
+ obj->pixmap_file = info->icon_filename;
+ } else {
+ g_warning(_("Cannot open icon file %s for object type '%s'."),
+ info->icon_filename, obj->name);
+ }
+ }
+
+ info->object_type = obj; /* <-- Reciproce type linking */
+
+ obj->default_user_data = (void*)info;
+
+ *otype = obj;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]