~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/sp-object-group.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define __SP_OBJECTGROUP_C__
 
2
 
 
3
/*
 
4
 * Abstract base class for non-item groups
 
5
 *
 
6
 * Authors:
 
7
 *   Lauris Kaplinski <lauris@kaplinski.com>
 
8
 *
 
9
 * Copyright (C) 1999-2003 Authors
 
10
 * Copyright (C) 2001-2002 Ximian, Inc.
 
11
 *
 
12
 * Released under GNU GPL, read the file 'COPYING' for more information
 
13
 */
 
14
 
 
15
#include "sp-object-group.h"
 
16
#include "xml/repr.h"
 
17
#include "document.h"
 
18
 
 
19
static void sp_objectgroup_class_init (SPObjectGroupClass *klass);
 
20
static void sp_objectgroup_init (SPObjectGroup *objectgroup);
 
21
 
 
22
static void sp_objectgroup_child_added (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref);
 
23
static void sp_objectgroup_remove_child (SPObject * object, Inkscape::XML::Node * child);
 
24
static void sp_objectgroup_order_changed (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node * new_ref);
 
25
static Inkscape::XML::Node *sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 
26
 
 
27
static SPObjectClass *parent_class;
 
28
 
 
29
GType
 
30
sp_objectgroup_get_type (void)
 
31
{
 
32
        static GType objectgroup_type = 0;
 
33
        if (!objectgroup_type) {
 
34
                GTypeInfo objectgroup_info = {
 
35
                        sizeof (SPObjectGroupClass),
 
36
                        NULL,   /* base_init */
 
37
                        NULL,   /* base_finalize */
 
38
                        (GClassInitFunc) sp_objectgroup_class_init,
 
39
                        NULL,   /* class_finalize */
 
40
                        NULL,   /* class_data */
 
41
                        sizeof (SPObjectGroup),
 
42
                        16,     /* n_preallocs */
 
43
                        (GInstanceInitFunc) sp_objectgroup_init,
 
44
                        NULL,   /* value_table */
 
45
                };
 
46
                objectgroup_type = g_type_register_static (SP_TYPE_OBJECT, "SPObjectGroup", &objectgroup_info, (GTypeFlags)0);
 
47
        }
 
48
        return objectgroup_type;
 
49
}
 
50
 
 
51
static void
 
52
sp_objectgroup_class_init (SPObjectGroupClass *klass)
 
53
{
 
54
        GObjectClass * object_class;
 
55
        SPObjectClass * sp_object_class;
 
56
 
 
57
        object_class = (GObjectClass *) klass;
 
58
        sp_object_class = (SPObjectClass *) klass;
 
59
 
 
60
        parent_class = (SPObjectClass *)g_type_class_ref (SP_TYPE_OBJECT);
 
61
 
 
62
        sp_object_class->child_added = sp_objectgroup_child_added;
 
63
        sp_object_class->remove_child = sp_objectgroup_remove_child;
 
64
        sp_object_class->order_changed = sp_objectgroup_order_changed;
 
65
        sp_object_class->write = sp_objectgroup_write;
 
66
}
 
67
 
 
68
static void
 
69
sp_objectgroup_init (SPObjectGroup */*objectgroup*/)
 
70
{
 
71
}
 
72
 
 
73
static void
 
74
sp_objectgroup_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
 
75
{
 
76
        if (((SPObjectClass *) (parent_class))->child_added)
 
77
                (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref);
 
78
 
 
79
        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
 
80
}
 
81
 
 
82
static void
 
83
sp_objectgroup_remove_child (SPObject *object, Inkscape::XML::Node *child)
 
84
{
 
85
        if (((SPObjectClass *) (parent_class))->remove_child)
 
86
                (* ((SPObjectClass *) (parent_class))->remove_child) (object, child);
 
87
 
 
88
        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
 
89
}
 
90
 
 
91
static void
 
92
sp_objectgroup_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref)
 
93
{
 
94
        if (((SPObjectClass *) (parent_class))->order_changed)
 
95
                (* ((SPObjectClass *) (parent_class))->order_changed) (object, child, old_ref, new_ref);
 
96
 
 
97
        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
 
98
}
 
99
 
 
100
static Inkscape::XML::Node *
 
101
sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 
102
{
 
103
        SPObjectGroup *group;
 
104
        SPObject *child;
 
105
        Inkscape::XML::Node *crepr;
 
106
 
 
107
        group = SP_OBJECTGROUP (object);
 
108
 
 
109
        if (flags & SP_OBJECT_WRITE_BUILD) {
 
110
                GSList *l;
 
111
                if (!repr) {
 
112
                        repr = xml_doc->createElement("svg:g");
 
113
                }
 
114
                l = NULL;
 
115
                for ( child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
 
116
                        crepr = child->updateRepr(xml_doc, NULL, flags);
 
117
                        if (crepr) l = g_slist_prepend (l, crepr);
 
118
                }
 
119
                while (l) {
 
120
                        repr->addChild((Inkscape::XML::Node *) l->data, NULL);
 
121
                        Inkscape::GC::release((Inkscape::XML::Node *) l->data);
 
122
                        l = g_slist_remove (l, l->data);
 
123
                }
 
124
        } else {
 
125
                for ( child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
 
126
                        child->updateRepr(flags);
 
127
                }
 
128
        }
 
129
 
 
130
        if (((SPObjectClass *) (parent_class))->write)
 
131
                ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
 
132
 
 
133
        return repr;
 
134
}
 
135