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.
23 * @short_description: The base class of the ADG model infrastructure
25 * A model is a conceptual representation of something. From an ADG
26 * user point of view, it is a collection of data and rules that
27 * defines how an object should be represented on a drawing.
29 * Because #AdgModel instances are only a conceptual idea, they are
30 * not renderable (that is, #AdgModel is not derived from #AdgEntity).
31 * Instead, it must be passed as subject to entities such as AdgStroke
38 * All fields are private and should not be used directly.
39 * Use its public methods instead.
43 #include "adg-model.h"
44 #include "adg-model-private.h"
58 static void get_property (GObject
*object
,
62 static void set_property (GObject
*object
,
66 static void changed (AdgModel
*model
);
68 static guint signals
[LAST_SIGNAL
] = { 0 };
71 G_DEFINE_ABSTRACT_TYPE(AdgModel
, adg_model
, G_TYPE_OBJECT
);
75 adg_model_class_init(AdgModelClass
*klass
)
77 GObjectClass
*gobject_class
;
79 gobject_class
= (GObjectClass
*) klass
;
81 g_type_class_add_private(klass
, sizeof(AdgModelPrivate
));
83 gobject_class
->get_property
= get_property
;
84 gobject_class
->set_property
= set_property
;
86 klass
->changed
= changed
;
90 * @model: an #AdgModel
92 * Notificates that the model has changed. By default, the model
93 * cache is invalidated.
95 signals
[CHANGED
] = g_signal_new("changed", ADG_TYPE_MODEL
,
96 G_SIGNAL_RUN_LAST
|G_SIGNAL_NO_RECURSE
,
97 G_STRUCT_OFFSET(AdgModelClass
, changed
),
99 g_cclosure_marshal_VOID__VOID
,
104 adg_model_init(AdgModel
*model
)
106 AdgModelPrivate
*data
= G_TYPE_INSTANCE_GET_PRIVATE(model
, ADG_TYPE_MODEL
,
112 get_property(GObject
*object
,
113 guint prop_id
, GValue
*value
, GParamSpec
*pspec
)
115 /* TODO: this is only a placeholder */
119 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
125 set_property(GObject
*object
,
126 guint prop_id
, const GValue
*value
, GParamSpec
*pspec
)
128 /* TODO: this is only a placeholder */
132 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
140 * @model: an #AdgModel
142 * Emits the "changed" signal on @model.
144 * This function is only useful in model implementations.
147 adg_model_changed(AdgModel
*model
)
149 g_return_if_fail(ADG_IS_MODEL(model
));
151 g_signal_emit(model
, signals
[CHANGED
], 0);
156 changed(AdgModel
*model
)