[build] Removed config.h.in
[adg.git] / adg / adg-model.c
blob233938c64a275cdbb1db6eee5c57c11434e673e0
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.
21 /**
22 * SECTION:model
23 * @title: AdgModel
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
33 * or AdgHatch.
34 **/
36 /**
37 * AdgModel:
39 * All fields are private and should not be used directly.
40 * Use its public methods instead.
41 **/
44 #include "adg-model.h"
45 #include "adg-model-private.h"
46 #include "adg-intl.h"
49 enum {
50 PROP_0
53 enum {
54 CHANGED,
55 LAST_SIGNAL
59 static void get_property (GObject *object,
60 guint prop_id,
61 GValue *value,
62 GParamSpec *pspec);
63 static void set_property (GObject *object,
64 guint prop_id,
65 const GValue *value,
66 GParamSpec *pspec);
67 static void changed (AdgModel *model);
69 static guint signals[LAST_SIGNAL] = { 0 };
72 G_DEFINE_ABSTRACT_TYPE(AdgModel, adg_model, G_TYPE_OBJECT);
75 static void
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;
89 /**
90 * AdgModel::changed:
91 * @model: an #AdgModel
93 * Notificates that the model has changed. By default, the model
94 * cache is invalidated.
95 **/
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),
99 NULL, NULL,
100 g_cclosure_marshal_VOID__VOID,
101 G_TYPE_NONE, 0);
104 static void
105 adg_model_init(AdgModel *model)
107 AdgModelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(model, ADG_TYPE_MODEL,
108 AdgModelPrivate);
109 model->priv = priv;
112 static void
113 get_property(GObject *object,
114 guint prop_id, GValue *value, GParamSpec *pspec)
116 /* TODO: this is only a placeholder */
118 switch (prop_id) {
119 default:
120 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
121 break;
125 static void
126 set_property(GObject *object,
127 guint prop_id, const GValue *value, GParamSpec *pspec)
129 /* TODO: this is only a placeholder */
131 switch (prop_id) {
132 default:
133 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
134 break;
140 * adg_model_changed:
141 * @model: an #AdgModel
143 * Emits the "changed" signal on @model.
145 * This function is only useful in model implementations.
147 void
148 adg_model_changed(AdgModel *model)
150 g_return_if_fail(ADG_IS_MODEL(model));
152 g_signal_emit(model, signals[CHANGED], 0);
156 static void
157 changed(AdgModel *model)