Code

From trunk
[inkscape.git] / src / sp-script.cpp
1 #define __SP_SCRIPT_C__
3 /*
4  * SVG <script> implementation
5  *
6  * Authors:
7  *   Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
8  *
9  * Copyright (C) 2008 authors
10  *
11  * Released under GNU GPL version 2 or later, read the file 'COPYING' for more information
12  */
14 #include "sp-script.h"
16 static void sp_script_class_init(SPScriptClass *sc);
17 static void sp_script_init(SPScript *script);
19 static void sp_script_release(SPObject *object);
20 static void sp_script_update(SPObject *object, SPCtx *ctx, guint flags);
21 static void sp_script_modified(SPObject *object, guint flags);
22 static Inkscape::XML::Node *sp_script_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
24 static SPObjectClass *parent_class;
26 GType sp_script_get_type(void)
27 {
28     static GType script_type = 0;
30     if (!script_type) {
31         GTypeInfo script_info = {
32             sizeof(SPScriptClass),
33             NULL,       /* base_init */
34             NULL,       /* base_finalize */
35             (GClassInitFunc) sp_script_class_init,
36             NULL,       /* class_finalize */
37             NULL,       /* class_data */
38             sizeof(SPScript),
39             16, /* n_preallocs */
40             (GInstanceInitFunc) sp_script_init,
41             NULL,       /* value_table */
42         };
43         script_type = g_type_register_static(SP_TYPE_OBJECT, "SPScript", &script_info, (GTypeFlags) 0);
44     }
46     return script_type;
47 }
49 static void sp_script_class_init(SPScriptClass *sc)
50 {
51     parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
52     SPObjectClass *sp_object_class = (SPObjectClass *) sc;
54     sp_object_class->release = sp_script_release;
55     sp_object_class->update = sp_script_update;
56     sp_object_class->modified = sp_script_modified;
57     sp_object_class->write = sp_script_write;
58 }
60 static void sp_script_init(SPScript */*script*/)
61 {
63 }
65 static void sp_script_release(SPObject *object)
66 {
67     if (((SPObjectClass *) (parent_class))->release) {
68         ((SPObjectClass *) (parent_class))->release(object);
69     }
70 }
72 static void sp_script_update(SPObject */*object*/, SPCtx */*ctx*/, guint /*flags*/)
73 {
74 }
76 static void sp_script_modified(SPObject */*object*/, guint /*flags*/)
77 {
78 }
80 static Inkscape::XML::Node *sp_script_write(SPObject */*object*/, Inkscape::XML::Document */*xml_doc*/, Inkscape::XML::Node *repr, guint /*flags*/)
81 {
82 /*
83 TODO:
84  code copied from sp-defs
85  decide what to do here!
87     if (flags & SP_OBJECT_WRITE_BUILD) {
89         if (!repr) {
90             repr = xml_doc->createElement("svg:script");
91         }
93         GSList *l = NULL;
94         for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
95             Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
96             if (crepr) l = g_slist_prepend(l, crepr);
97         }
99         while (l) {
100             repr->addChild((Inkscape::XML::Node *) l->data, NULL);
101             Inkscape::GC::release((Inkscape::XML::Node *) l->data);
102             l = g_slist_remove(l, l->data);
103         }
105     } else {
106         for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
107             child->updateRepr(flags);
108         }
109     }
111     if (((SPObjectClass *) (parent_class))->write) {
112         (* ((SPObjectClass *) (parent_class))->write)(object, xml_doc, repr, flags);
113     }
114 */
115     return repr;
118 /*
119   Local Variables:
120   mode:c++
121   c-file-style:"stroustrup"
122   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
123   indent-tabs-mode:nil
124   fill-column:99
125   End:
126 */
127 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :