1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
24 * @short_description: The base class of the ADG model infrastructure
26 * A model is a conceptual representation of something. From an ADG
27 * user point of view, it is a collection of data and rules that
28 * defines how an object should be represented on a drawing.
30 * Because #AdgModel instances are only a conceptual idea, they are
31 * not renderable (that is, #AdgModel is not derived from #AdgEntity).
32 * Instead, it must be passed as subject to entities such as AdgStroke
39 * All fields are private and should not be used directly.
40 * Use its public methods instead.
44 #include "adg-model.h"
45 #include "adg-model-private.h"
59 static void get_property (GObject
*object
,
63 static void set_property (GObject
*object
,
67 static void changed (AdgModel
*model
);
69 static guint signals
[LAST_SIGNAL
] = { 0 };
72 G_DEFINE_ABSTRACT_TYPE(AdgModel
, adg_model
, G_TYPE_OBJECT
);
76 adg_model_class_init(AdgModelClass
*klass
)
78 GObjectClass
*gobject_class
;
80 gobject_class
= (GObjectClass
*) klass
;
82 g_type_class_add_private(klass
, sizeof(AdgModelPrivate
));
84 gobject_class
->get_property
= get_property
;
85 gobject_class
->set_property
= set_property
;
87 klass
->changed
= changed
;
91 * @model: an #AdgModel
93 * Notificates that the model has changed. By default, the model
94 * cache is invalidated.
96 signals
[CHANGED
] = g_signal_new("changed", ADG_TYPE_MODEL
,
97 G_SIGNAL_RUN_LAST
|G_SIGNAL_NO_RECURSE
,
98 G_STRUCT_OFFSET(AdgModelClass
, changed
),
100 g_cclosure_marshal_VOID__VOID
,
105 adg_model_init(AdgModel
*model
)
107 AdgModelPrivate
*priv
= G_TYPE_INSTANCE_GET_PRIVATE(model
, ADG_TYPE_MODEL
,
113 get_property(GObject
*object
,
114 guint prop_id
, GValue
*value
, GParamSpec
*pspec
)
116 /* TODO: this is only a placeholder */
120 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
126 set_property(GObject
*object
,
127 guint prop_id
, const GValue
*value
, GParamSpec
*pspec
)
129 /* TODO: this is only a placeholder */
133 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
141 * @model: an #AdgModel
143 * Emits the "changed" signal on @model.
145 * This function is only useful in model implementations.
148 adg_model_changed(AdgModel
*model
)
150 g_return_if_fail(ADG_IS_MODEL(model
));
152 g_signal_emit(model
, signals
[CHANGED
], 0);
157 changed(AdgModel
*model
)