[dia/zbrown/object-change: 9/16] standard: port to DiaObjectChange
- From: Zander Brown <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia/zbrown/object-change: 9/16] standard: port to DiaObjectChange
- Date: Sat, 10 Oct 2020 22:05:56 +0000 (UTC)
commit 45898035a618a736fe67f52c2ef9e756cf8b10c6
Author: Zander Brown <zbrown gnome org>
Date: Sat Oct 10 22:12:54 2020 +0100
standard: port to DiaObjectChange
objects/standard/box.c | 48 +++++++++++++++++++++++++++------------------
objects/standard/ellipse.c | 49 ++++++++++++++++++++++++++++------------------
2 files changed, 59 insertions(+), 38 deletions(-)
---
diff --git a/objects/standard/box.c b/objects/standard/box.c
index 9371d508a..ffdb36953 100644
--- a/objects/standard/box.c
+++ b/objects/standard/box.c
@@ -31,7 +31,6 @@
#include "create.h"
#include "message.h"
#include "pattern.h"
-#include "dia-object-change-legacy.h"
#define DEFAULT_WIDTH 2.0
@@ -720,53 +719,64 @@ box_load(ObjectNode obj_node, int version, DiaContext *ctx)
}
-struct AspectChange {
- ObjectChange obj_change;
+#define DIA_TYPE_BOX_ASPECT_OBJECT_CHANGE dia_box_aspect_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaBoxAspectObjectChange,
+ dia_box_aspect_object_change,
+ DIA, BOX_ASPECT_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
+struct _DiaBoxAspectObjectChange {
+ DiaObjectChange obj_change;
AspectType old_type, new_type;
/* The points before this got applied. Afterwards, all points can be
* calculated.
*/
Point topleft;
- real width, height;
+ double width, height;
};
+
+DIA_DEFINE_OBJECT_CHANGE (DiaBoxAspectObjectChange, dia_box_aspect_object_change)
+
+
static void
-aspect_change_free(struct AspectChange *change)
+dia_box_aspect_object_change_free (DiaObjectChange *self)
{
}
+
static void
-aspect_change_apply(struct AspectChange *change, DiaObject *obj)
+dia_box_aspect_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
- Box *box = (Box*)obj;
+ DiaBoxAspectObjectChange *change = DIA_BOX_ASPECT_OBJECT_CHANGE (self);
+ Box *box = (Box *) obj;
box->aspect = change->new_type;
- box_update_data(box);
+ box_update_data (box);
}
+
static void
-aspect_change_revert(struct AspectChange *change, DiaObject *obj)
+dia_box_aspect_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
- Box *box = (Box*)obj;
+ DiaBoxAspectObjectChange *change = DIA_BOX_ASPECT_OBJECT_CHANGE (self);
+ Box *box = (Box *) obj;
box->aspect = change->old_type;
box->element.corner = change->topleft;
box->element.width = change->width;
box->element.height = change->height;
- box_update_data(box);
+ box_update_data (box);
}
static DiaObjectChange *
-aspect_create_change(Box *box, AspectType aspect)
+aspect_create_change (Box *box, AspectType aspect)
{
- struct AspectChange *change;
-
- change = g_new0(struct AspectChange, 1);
+ DiaBoxAspectObjectChange *change;
- change->obj_change.apply = (ObjectChangeApplyFunc) aspect_change_apply;
- change->obj_change.revert = (ObjectChangeRevertFunc) aspect_change_revert;
- change->obj_change.free = (ObjectChangeFreeFunc) aspect_change_free;
+ change = dia_object_change_new (DIA_TYPE_BOX_ASPECT_OBJECT_CHANGE);
change->old_type = box->aspect;
change->new_type = aspect;
@@ -774,7 +784,7 @@ aspect_create_change(Box *box, AspectType aspect)
change->width = box->element.width;
change->height = box->element.height;
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
diff --git a/objects/standard/ellipse.c b/objects/standard/ellipse.c
index 83244431b..ad7518371 100644
--- a/objects/standard/ellipse.c
+++ b/objects/standard/ellipse.c
@@ -31,7 +31,6 @@
#include "pattern.h"
#include "diapathrenderer.h"
#include "message.h"
-#include "dia-object-change-legacy.h"
#define DEFAULT_WIDTH 2.0
@@ -721,53 +720,65 @@ static DiaObject *ellipse_load(ObjectNode obj_node, int version, DiaContext *ctx
return &ellipse->element.object;
}
-struct AspectChange {
- ObjectChange obj_change;
+
+#define DIA_TYPE_ELLIPES_ASPECT_OBJECT_CHANGE dia_ellipse_aspect_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaEllipseAspectObjectChange,
+ dia_ellipse_aspect_object_change,
+ DIA, ELLIPES_ASPECT_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
+struct _DiaEllipseAspectObjectChange {
+ DiaObjectChange obj_change;
AspectType old_type, new_type;
/* The points before this got applied. Afterwards, all points can be
* calculated.
*/
Point topleft;
- real width, height;
+ double width, height;
};
+
+DIA_DEFINE_OBJECT_CHANGE (DiaEllipseAspectObjectChange, dia_ellipse_aspect_object_change)
+
+
static void
-aspect_change_free(struct AspectChange *change)
+dia_ellipse_aspect_object_change_free (DiaObjectChange *self)
{
}
+
static void
-aspect_change_apply(struct AspectChange *change, DiaObject *obj)
+dia_ellipse_aspect_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
- Ellipse *ellipse = (Ellipse*)obj;
+ DiaEllipseAspectObjectChange *change = DIA_ELLIPES_ASPECT_OBJECT_CHANGE (self);
+ Ellipse *ellipse = (Ellipse*) obj;
ellipse->aspect = change->new_type;
- ellipse_update_data(ellipse);
+ ellipse_update_data (ellipse);
}
+
static void
-aspect_change_revert(struct AspectChange *change, DiaObject *obj)
+dia_ellipse_aspect_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
- Ellipse *ellipse = (Ellipse*)obj;
+ DiaEllipseAspectObjectChange *change = DIA_ELLIPES_ASPECT_OBJECT_CHANGE (self);
+ Ellipse *ellipse = (Ellipse*) obj;
ellipse->aspect = change->old_type;
ellipse->element.corner = change->topleft;
ellipse->element.width = change->width;
ellipse->element.height = change->height;
- ellipse_update_data(ellipse);
+ ellipse_update_data (ellipse);
}
static DiaObjectChange *
-aspect_create_change(Ellipse *ellipse, AspectType aspect)
+aspect_create_change (Ellipse *ellipse, AspectType aspect)
{
- struct AspectChange *change;
-
- change = g_new0(struct AspectChange, 1);
+ DiaEllipseAspectObjectChange *change;
- change->obj_change.apply = (ObjectChangeApplyFunc) aspect_change_apply;
- change->obj_change.revert = (ObjectChangeRevertFunc) aspect_change_revert;
- change->obj_change.free = (ObjectChangeFreeFunc) aspect_change_free;
+ change = dia_object_change_new (DIA_TYPE_ELLIPES_ASPECT_OBJECT_CHANGE);
change->old_type = ellipse->aspect;
change->new_type = aspect;
@@ -775,7 +786,7 @@ aspect_create_change(Ellipse *ellipse, AspectType aspect)
change->width = ellipse->element.width;
change->height = ellipse->element.height;
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]