[dia/zbrown/object-change: 7/16] lib: port to DiaObjectChange
- From: Zander Brown <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia/zbrown/object-change: 7/16] lib: port to DiaObjectChange
- Date: Sat, 10 Oct 2020 22:05:56 +0000 (UTC)
commit 848b06a257875b4bd326198da509a553155f8e04
Author: Zander Brown <zbrown gnome org>
Date: Sat Oct 10 22:03:09 2020 +0100
lib: port to DiaObjectChange
lib/connpoint_line.c | 68 +++++++++++++++++++--------------
lib/connpoint_line.h | 35 +++++++++++------
lib/dummy_dep.h | 5 ++-
lib/element.c | 1 -
lib/group.c | 1 -
lib/objchange.c | 62 +++++++++++++++++++-----------
lib/objchange.h | 25 ++++++++----
lib/object.c | 31 ++++++++-------
lib/object.h | 13 +++++--
lib/orth_conn.c | 106 ++++++++++++++++++++++++++++++---------------------
lib/orth_conn.h | 22 +++++++++++
lib/poly_conn.c | 45 +++++++++++++---------
lib/poly_conn.h | 15 ++++++--
lib/polyshape.c | 86 ++++++++++++++++++++++++-----------------
lib/polyshape.h | 15 ++++++--
lib/properties.h | 7 ++++
lib/propobject.c | 48 ++++++++++++++---------
lib/standard-path.c | 69 +++++++++++++++++++++++----------
lib/standard-path.h | 21 ++++++++--
lib/text.c | 31 ++++++++-------
lib/text.h | 16 ++++++--
21 files changed, 469 insertions(+), 253 deletions(-)
---
diff --git a/lib/connpoint_line.c b/lib/connpoint_line.c
index 4bcb44f9c..d3ea0fb09 100644
--- a/lib/connpoint_line.c
+++ b/lib/connpoint_line.c
@@ -23,7 +23,6 @@
#include "connpoint_line.h"
#include "connectionpoint.h"
#include "dia_xml.h"
-#include "dia-object-change-legacy.h"
#define DEBUG_PARENT 0
@@ -425,8 +424,9 @@ cpl_get_pointbefore(ConnPointLine *cpl, Point *clickedpoint)
return pos;
}
-typedef struct {
- ObjectChange obj_change;
+
+struct _DiaConnPointLineObjectChange {
+ DiaObjectChange obj_change;
int add; /* How much to add or remove */
int applied; /* 1 if the event has been applied. */
@@ -434,51 +434,65 @@ typedef struct {
ConnPointLine *cpl;
int pos; /* Position where the change happened. */
ConnectionPoint **cp; /* The removed connection point. */
-} CPLChange;
+};
+
+
+DIA_DEFINE_OBJECT_CHANGE (DiaConnPointLineObjectChange,
+ dia_conn_point_line_object_change)
+
static void
-cpl_change_addremove(CPLChange *change, ConnPointLine *cpl,
- int action, int resultingapplied)
+dia_conn_point_line_object_change_addremove (DiaConnPointLineObjectChange *change,
+ ConnPointLine *cpl,
+ int action,
+ int resultingapplied)
{
if (action != 0) {
if (action > 0) { /* We should add */
while (action--) {
- cpl_add_connectionpoint_at(cpl,change->pos,change->cp[action]);
- change->cp[action] = NULL;
+ cpl_add_connectionpoint_at (cpl, change->pos, change->cp[action]);
+ change->cp[action] = NULL;
}
cpl_reorder_connections(cpl);
} else { /* We should remove. Warning, action is negative. */
while (action++) {
- change->cp[-action] = cpl_remove_connpoint(cpl,change->pos);
+ change->cp[-action] = cpl_remove_connpoint (cpl, change->pos);
}
}
} else {
- g_warning("cpl_change_addremove(): null action !");
+ g_warning ("cpl_change_addremove(): null action !");
}
change->applied = resultingapplied;
}
+
static void
-cpl_change_apply(CPLChange *change, ConnPointLine *probablynotcpl)
+dia_conn_point_line_object_change_apply (DiaObjectChange *self, DiaObject *probablynotcpl)
{
- cpl_change_addremove(change,change->cpl,change->add,1);
+ DiaConnPointLineObjectChange *change = DIA_CONN_POINT_LINE_OBJECT_CHANGE (self);
+
+ dia_conn_point_line_object_change_addremove (change, change->cpl, change->add, 1);
}
+
static void
-cpl_change_revert(CPLChange *change, ConnPointLine *probablynotcpl)
+dia_conn_point_line_object_change_revert (DiaObjectChange *self, DiaObject *probablynotcpl)
{
- cpl_change_addremove(change,change->cpl,-(change->add),0);
+ DiaConnPointLineObjectChange *change = DIA_CONN_POINT_LINE_OBJECT_CHANGE (self);
+
+ dia_conn_point_line_object_change_addremove (change, change->cpl, -(change->add), 0);
}
static void
-cpl_change_free (CPLChange *change)
+dia_conn_point_line_object_change_free (DiaObjectChange *self)
{
- int i = ABS(change->add);
+ DiaConnPointLineObjectChange *change = DIA_CONN_POINT_LINE_OBJECT_CHANGE (self);
+ int i = ABS (change->add);
while (i--) {
if (change->cp[i]) {
- del_connpoint(change->cp[i]);
+ del_connpoint (change->cp[i]);
}
}
g_clear_pointer (&change->cp, g_free);
@@ -488,27 +502,23 @@ cpl_change_free (CPLChange *change)
static DiaObjectChange *
-cpl_create_change(ConnPointLine *cpl, int pos, int add)
+dia_conn_point_line_object_change_new (ConnPointLine *cpl, int pos, int add)
{
- CPLChange *change;
-
- change = g_new0(CPLChange,1);
+ DiaConnPointLineObjectChange *change;
- change->obj_change.apply = (ObjectChangeApplyFunc) cpl_change_apply;
- change->obj_change.revert = (ObjectChangeRevertFunc) cpl_change_revert;
- change->obj_change.free = (ObjectChangeFreeFunc) cpl_change_free;
+ change = dia_object_change_new (DIA_TYPE_CONN_POINT_LINE_OBJECT_CHANGE);
change->cpl = cpl;
change->applied = 0;
change->add = add;
change->pos = pos;
- change->cp = g_malloc0(sizeof(ConnectionPoint *) * ABS(add));
+ change->cp = g_new0 (ConnectionPoint *, ABS (add));
while (add-- > 0) {
- change->cp[add] = new_connpoint(cpl->parent);
+ change->cp[add] = new_connpoint (cpl->parent);
}
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
@@ -521,7 +531,7 @@ connpointline_add_points (ConnPointLine *cpl,
DiaObjectChange *change;
pos = cpl_get_pointbefore (cpl, clickedpoint);
- change = cpl_create_change (cpl, pos, count);
+ change = dia_conn_point_line_object_change_new (cpl, pos, count);
dia_object_change_apply (change, DIA_OBJECT (cpl));
@@ -538,7 +548,7 @@ connpointline_remove_points (ConnPointLine *cpl,
DiaObjectChange *change;
pos = cpl_get_pointbefore (cpl, clickedpoint);
- change = cpl_create_change (cpl, pos, -count);
+ change = dia_conn_point_line_object_change_new (cpl, pos, -count);
dia_object_change_apply (change, DIA_OBJECT (cpl));
diff --git a/lib/connpoint_line.h b/lib/connpoint_line.h
index 4ad853290..87d4825e0 100644
--- a/lib/connpoint_line.h
+++ b/lib/connpoint_line.h
@@ -16,9 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
-#ifndef __CONNPOINT_LINE_H
-#define __CONNPOINT_LINE_H
+#pragma once
#include <stdio.h>
#include <stdlib.h>
@@ -30,6 +28,14 @@
#include "object.h"
#include "dia_xml.h"
+G_BEGIN_DECLS
+
+#define DIA_TYPE_CONN_POINT_LINE_OBJECT_CHANGE dia_conn_point_line_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaConnPointLineObjectChange,
+ dia_conn_point_line_object_change,
+ DIA, CONN_POINT_LINE_OBJECT_CHANGE,
+ DiaObjectChange)
+
typedef struct _ConnPointLine {
/*! Placement of the line. */
@@ -59,14 +65,19 @@ DiaObjectChange *connpointline_add_points (ConnPointLine *cpl,
DiaObjectChange *connpointline_remove_points (ConnPointLine *cpl,
Point *clickedpoint,
int count);
-ConnPointLine *connpointline_load(DiaObject *obj,ObjectNode obj_node,
- const gchar *name, int default_nc,
- int *realconncount,
- DiaContext *ctx);
-void connpointline_save(ConnPointLine *cpl,ObjectNode obj_node,
- const gchar *name, DiaContext *ctx);
-ConnPointLine *connpointline_copy(DiaObject *newobj,ConnPointLine *cpl,
- int *realconncount);
+ConnPointLine *connpointline_load (DiaObject *obj,
+ ObjectNode obj_node,
+ const char *name,
+ int default_nc,
+ int *realconncount,
+ DiaContext *ctx);
+void connpointline_save (ConnPointLine *cpl,
+ ObjectNode obj_node,
+ const char *name,
+ DiaContext *ctx);
+ConnPointLine *connpointline_copy (DiaObject *newobj,
+ ConnPointLine *cpl,
+ int *realconncount);
#define connpointline_add_point(cpl, clickedpoint) \
connpointline_add_points(cpl, clickedpoint, 1)
@@ -76,4 +87,4 @@ ConnPointLine *connpointline_copy(DiaObject *newobj,ConnPointLine *cpl,
int connpointline_adjust_count(ConnPointLine *cpl,
int newcount, Point *where);
-#endif /* __CONNPOINT_LINE_H */
+G_END_DECLS
diff --git a/lib/dummy_dep.h b/lib/dummy_dep.h
index 0d10b75c6..bb458f9fb 100644
--- a/lib/dummy_dep.h
+++ b/lib/dummy_dep.h
@@ -34,13 +34,14 @@
#include "dynamic_obj.h"
#include "connectionpoint.h"
#include "diafontselector.h"
+#include "objchange.h"
/* This is a file with dummy dependencies so that all
object files will be linked into the app.
*/
#ifndef __sgi
-static
+static
#endif
void *dummy_dep[] G_GNUC_UNUSED = {
connection_move_handle,
@@ -55,7 +56,7 @@ void *dummy_dep[] G_GNUC_UNUSED = {
nearest_pow,
arrow_draw,
dia_font_selector_new, /* widgets.o */
- new_object_state_change, /* objchange.o */
+ dia_state_object_change_new, /* objchange.o */
intl_score_locale, /* intl.o */
connpointline_create, /* connpoint_line.o */
object_create_props_dialog, /* properties.o */
diff --git a/lib/element.c b/lib/element.c
index e64bad590..e9c7f862d 100644
--- a/lib/element.c
+++ b/lib/element.c
@@ -35,7 +35,6 @@
#include "element.h"
#include "properties.h"
-#include "dia-object-change-legacy.h"
#ifdef G_OS_WIN32
diff --git a/lib/group.c b/lib/group.c
index de5dd9e14..d19542a54 100644
--- a/lib/group.c
+++ b/lib/group.c
@@ -25,7 +25,6 @@
#include "group.h"
#include "properties.h"
#include "diarenderer.h"
-#include "dia-object-change-legacy.h"
/*!
diff --git a/lib/objchange.c b/lib/objchange.c
index 88217a06e..bc341d3df 100644
--- a/lib/objchange.c
+++ b/lib/objchange.c
@@ -18,14 +18,18 @@
#include <config.h>
-#include "object.h"
-#include "dia-object-change-legacy.h"
+#include "objchange.h"
-/******** ObjectChange for object that just need to get/set state: *****/
-typedef struct _ObjectStateChange ObjectStateChange;
-struct _ObjectStateChange {
- ObjectChange obj_change;
+/**
+ * SECTION:dia-state-object-change
+ *
+ * #DiaObjectChange for object that just need to get/set state
+ */
+
+
+struct _DiaStateObjectChange {
+ DiaObjectChange obj_change;
GetStateFunc get_state;
SetStateFunc set_state;
@@ -35,8 +39,11 @@ struct _ObjectStateChange {
};
+DIA_DEFINE_OBJECT_CHANGE (DiaStateObjectChange, dia_state_object_change)
+
+
static void
-object_state_change_apply_revert (ObjectStateChange *change, DiaObject *obj)
+object_state_change_apply_revert (DiaStateObjectChange *change, DiaObject *obj)
{
ObjectState *old_state;
@@ -49,34 +56,43 @@ object_state_change_apply_revert (ObjectStateChange *change, DiaObject *obj)
static void
-object_state_change_free (ObjectStateChange *change)
+dia_state_object_change_apply (DiaObjectChange *self, DiaObject *obj)
+{
+ object_state_change_apply_revert (DIA_STATE_OBJECT_CHANGE (self), obj);
+}
+
+
+static void
+dia_state_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
+ object_state_change_apply_revert (DIA_STATE_OBJECT_CHANGE (self), obj);
+}
+
+
+static void
+dia_state_object_change_free (DiaObjectChange *self)
+{
+ DiaStateObjectChange *change = DIA_STATE_OBJECT_CHANGE (self);
+
if ((change) && (change->saved_state)) {
if (change->saved_state->free)
- (*change->saved_state->free)(change->saved_state);
+ (*change->saved_state->free) (change->saved_state);
g_clear_pointer (&change->saved_state, g_free);
}
}
DiaObjectChange *
-new_object_state_change (DiaObject *obj,
- ObjectState *old_state,
- GetStateFunc get_state,
- SetStateFunc set_state)
+dia_state_object_change_new (DiaObject *obj,
+ ObjectState *old_state,
+ GetStateFunc get_state,
+ SetStateFunc set_state)
{
- ObjectStateChange *change;
+ DiaStateObjectChange *change;
g_return_val_if_fail (get_state != NULL && set_state != NULL, NULL);
- change = g_new(ObjectStateChange, 1);
-
- change->obj_change.apply =
- (ObjectChangeApplyFunc) object_state_change_apply_revert;
- change->obj_change.revert =
- (ObjectChangeRevertFunc) object_state_change_apply_revert;
- change->obj_change.free =
- (ObjectChangeFreeFunc) object_state_change_free;
+ change = dia_object_change_new (DIA_TYPE_STATE_OBJECT_CHANGE);
change->get_state = get_state;
change->set_state = set_state;
@@ -84,5 +100,5 @@ new_object_state_change (DiaObject *obj,
change->obj = obj;
change->saved_state = old_state;
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
diff --git a/lib/objchange.h b/lib/objchange.h
index df6831d05..8c1b8f3cc 100644
--- a/lib/objchange.h
+++ b/lib/objchange.h
@@ -24,18 +24,27 @@
* \brief Object implementations need some effort to support undo/redo
* \ingroup ObjectParts
*/
-#ifndef OBJCHANGE_H
-#define OBJCHANGE_H
+
+#pragma once
#include "diatypes.h"
#include "dia-object-change.h"
G_BEGIN_DECLS
+#define DIA_TYPE_STATE_OBJECT_CHANGE dia_state_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaStateObjectChange,
+ dia_state_object_change,
+ DIA, STATE_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
+typedef struct _ObjectChange ObjectChange;
typedef void (*ObjectChangeApplyFunc)(ObjectChange *change, DiaObject *obj);
typedef void (*ObjectChangeRevertFunc)(ObjectChange *change, DiaObject *obj);
typedef void (*ObjectChangeFreeFunc)(ObjectChange *change);
+
/*!
\brief Return value of object changing functions and methods of DiaObject
@@ -54,6 +63,8 @@ struct _ObjectChange {
ObjectChangeFreeFunc free; /*!< Remove extra data. Then this object is freed */
};
+
+
/******** Helper functions of objects: *************/
struct _ObjectState {
@@ -90,11 +101,9 @@ typedef void (*SetStateFunc) (DiaObject* obj, ObjectState *state);
/*! Create a single change from the ObjectState
* \ingroup ObjChange
*/
-DiaObjectChange *new_object_state_change (DiaObject *obj,
- ObjectState *old_state,
- GetStateFunc get_state,
- SetStateFunc set_state);
+DiaObjectChange *dia_state_object_change_new (DiaObject *obj,
+ ObjectState *old_state,
+ GetStateFunc get_state,
+ SetStateFunc set_state);
G_END_DECLS
-
-#endif /* OBJCHANGE_H */
diff --git a/lib/object.c b/lib/object.c
index c8793e6ca..7e4a53f0f 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -490,32 +490,35 @@ _object_exchange (ObjectChange *change, DiaObject *obj)
}
}
+
/* It is adviced to not use the passed in object at all */
static void
-_object_exchange_apply (ObjectChange *change, DiaObject *obj)
+dia_exchange_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
- ObjectChangeExchange *c = (ObjectChangeExchange *)change;
+ DiaExchangeObjectChange *c = DIA_EXCHANGE_OBJECT_CHANGE (self);
g_return_if_fail (c->applied == 0);
- _object_exchange (change, c->orig);
+ _object_exchange (self, c->orig);
c->applied = 1;
}
+
/* It is adviced to not use the passed in object at all */
static void
-_object_exchange_revert (ObjectChange *change, DiaObject *obj)
+dia_exchange_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
- ObjectChangeExchange *c = (ObjectChangeExchange *)change;
+ DiaExchangeObjectChange *c = DIA_EXCHANGE_OBJECT_CHANGE (self);
g_return_if_fail (c->applied != 0);
- _object_exchange (change, c->subst);
+ _object_exchange (self, c->subst);
c->applied = 0;
}
+
static void
-_object_exchange_free (ObjectChange *change)
+dia_exchange_object_change_free (DiaObjectChange *self)
{
- ObjectChangeExchange *c = (ObjectChangeExchange *)change;
+ DiaExchangeObjectChange *c = DIA_EXCHANGE_OBJECT_CHANGE (self);
DiaObject *obj = c->applied ? c->orig : c->subst;
if (obj) {
@@ -524,6 +527,7 @@ _object_exchange_free (ObjectChange *change)
}
}
+
/**
* object_substitute:
* @obj: the original object which will be replace
@@ -541,17 +545,16 @@ _object_exchange_free (ObjectChange *change)
DiaObjectChange *
object_substitute (DiaObject *obj, DiaObject *subst)
{
- ObjectChangeExchange *change = g_new0 (ObjectChangeExchange, 1);
+ DiaExchangeObjectChange *change;
+
+ change = dia_object_change_new (DIA_TYPE_EXCHANGE_OBJECT_CHANGE);
- change->change.apply = _object_exchange_apply;
- change->change.revert = _object_exchange_revert;
- change->change.free = _object_exchange_free;
change->orig = obj;
change->subst = subst;
- _object_exchange_apply ((ObjectChange *) change, obj);
+ dia_object_change_apply (DIA_OBJECT_CHANGE (change), obj);
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
diff --git a/lib/object.h b/lib/object.h
index f5332e751..dd32716a3 100644
--- a/lib/object.h
+++ b/lib/object.h
@@ -20,8 +20,8 @@
* Definitions for Dia objects, in particular the 'virtual'
* functions and the object and type structures.
*/
-#ifndef DIA_OBJECT_H
-#define DIA_OBJECT_H
+
+#pragma once
#include "diatypes.h"
#include <gtk/gtk.h>
@@ -38,6 +38,13 @@
G_BEGIN_DECLS
+#define DIA_TYPE_EXCHANGE_OBJECT_CHANGE dia_exchange_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaExchangeObjectChange,
+ dia_exchange_object_change,
+ DIA, EXCHANGE_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
/**
* DiaObjectFlags:
*
@@ -565,5 +572,3 @@ void object_copy_style(DiaObject *dest, const DiaObject *src);
GdkPixbuf *dia_object_type_get_icon (const DiaObjectType *type);
G_END_DECLS
-
-#endif /* DIA_OBJECT_H */
diff --git a/lib/orth_conn.c b/lib/orth_conn.c
index 10be62ebb..0be707a90 100644
--- a/lib/orth_conn.c
+++ b/lib/orth_conn.c
@@ -30,7 +30,6 @@
#include "handle.h"
#include "diarenderer.h"
#include "autoroute.h"
-#include "dia-object-change-legacy.h"
static void place_handle_by_swapping(OrthConn *orth,
@@ -51,8 +50,9 @@ midsegment_create_change (OrthConn *orth,
Handle *handle1,
Handle *handle2);
-struct MidSegmentChange {
- ObjectChange obj_change;
+
+struct _DiaOrthConnMidSegmentObjectChange {
+ DiaObjectChange obj_change;
/* All additions and deletions of segments in the middle
* of the orthconn must delete/add two segments to keep
@@ -73,6 +73,10 @@ struct MidSegmentChange {
};
+DIA_DEFINE_OBJECT_CHANGE (DiaOrthConnMidSegmentObjectChange,
+ dia_orth_conn_mid_segment_object_change)
+
+
static DiaObjectChange *
endsegment_create_change (OrthConn *orth,
enum change_type type,
@@ -83,8 +87,8 @@ endsegment_create_change (OrthConn *orth,
static void
place_handle_by_swapping(OrthConn *orth, int index, Handle *handle);
-struct EndSegmentChange {
- ObjectChange obj_change;
+struct _DiaOrthConnEndSegmentObjectChange {
+ DiaObjectChange obj_change;
/* Additions and deletions of segments of at the endpoints
* of the orthconn.
@@ -109,15 +113,26 @@ struct EndSegmentChange {
DiaObjectChange *cplchange;
};
+
+DIA_DEFINE_OBJECT_CHANGE (DiaOrthConnEndSegmentObjectChange,
+ dia_orth_conn_end_segment_object_change)
+
+
static DiaObjectChange *autoroute_create_change (OrthConn *orth, gboolean on);
-struct AutorouteChange {
- ObjectChange obj_change;
+
+struct _DiaOrthConnAutorouteObjectChange {
+ DiaObjectChange obj_change;
gboolean on;
int num_points;
Point *points;
};
+
+DIA_DEFINE_OBJECT_CHANGE (DiaOrthConnAutorouteObjectChange,
+ dia_orth_conn_autoroute_object_change)
+
+
static void set_midpoint(Point *point, OrthConn *orth, int segment)
{
int i = segment;
@@ -975,8 +990,10 @@ insert_handle(OrthConn *orth, int segment,
static void
-endsegment_change_free (struct EndSegmentChange *change)
+dia_orth_conn_end_segment_object_change_free (DiaObjectChange *self)
{
+ DiaOrthConnEndSegmentObjectChange *change = DIA_ORTH_CONN_END_SEGMENT_OBJECT_CHANGE (self);
+
if ( (change->type==TYPE_ADD_SEGMENT && !change->applied) ||
(change->type==TYPE_REMOVE_SEGMENT && change->applied) ){
g_clear_pointer (&change->handle, g_free);
@@ -987,8 +1004,9 @@ endsegment_change_free (struct EndSegmentChange *change)
static void
-endsegment_change_apply (struct EndSegmentChange *change, DiaObject *obj)
+dia_orth_conn_end_segment_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
+ DiaOrthConnEndSegmentObjectChange *change = DIA_ORTH_CONN_END_SEGMENT_OBJECT_CHANGE (self);
OrthConn *orth = (OrthConn *)obj;
change->applied = 1;
@@ -1041,8 +1059,9 @@ endsegment_change_apply (struct EndSegmentChange *change, DiaObject *obj)
static void
-endsegment_change_revert (struct EndSegmentChange *change, DiaObject *obj)
+dia_orth_conn_end_segment_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
+ DiaOrthConnEndSegmentObjectChange *change = DIA_ORTH_CONN_END_SEGMENT_OBJECT_CHANGE (self);
OrthConn *orth = (OrthConn *) obj;
dia_object_change_revert (change->cplchange, obj);
@@ -1099,32 +1118,31 @@ endsegment_create_change (OrthConn *orth,
Point *point,
Handle *handle)
{
- struct EndSegmentChange *change;
-
- change = g_new0 (struct EndSegmentChange, 1);
+ DiaOrthConnEndSegmentObjectChange *change;
- change->obj_change.apply = (ObjectChangeApplyFunc) endsegment_change_apply;
- change->obj_change.revert = (ObjectChangeRevertFunc) endsegment_change_revert;
- change->obj_change.free = (ObjectChangeFreeFunc) endsegment_change_free;
+ change = dia_object_change_new (DIA_TYPE_ORTH_CONN_END_SEGMENT_OBJECT_CHANGE);
change->type = type;
change->applied = 0;
change->segment = segment;
change->point = *point;
change->handle = handle;
- if (segment == 0)
+ if (segment == 0) {
change->old_end_handle = orth->handles[0];
- else
- change->old_end_handle = orth->handles[orth->numpoints-2];
+ } else {
+ change->old_end_handle = orth->handles[orth->numpoints - 2];
+ }
change->cp = change->old_end_handle->connected_to;
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
static void
-midsegment_change_free(struct MidSegmentChange *change)
+dia_orth_conn_mid_segment_object_change_free (DiaObjectChange *self)
{
+ DiaOrthConnMidSegmentObjectChange *change = DIA_ORTH_CONN_MID_SEGMENT_OBJECT_CHANGE (self);
+
if ( (change->type==TYPE_ADD_SEGMENT && !change->applied) ||
(change->type==TYPE_REMOVE_SEGMENT && change->applied) ){
g_clear_pointer (&change->handles[0], g_free);
@@ -1137,8 +1155,9 @@ midsegment_change_free(struct MidSegmentChange *change)
static void
-midsegment_change_apply (struct MidSegmentChange *change, DiaObject *obj)
+dia_orth_conn_mid_segment_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
+ DiaOrthConnMidSegmentObjectChange *change = DIA_ORTH_CONN_MID_SEGMENT_OBJECT_CHANGE (self);
OrthConn *orth = (OrthConn *)obj;
int seg;
@@ -1183,8 +1202,9 @@ midsegment_change_apply (struct MidSegmentChange *change, DiaObject *obj)
static void
-midsegment_change_revert (struct MidSegmentChange *change, DiaObject *obj)
+dia_orth_conn_mid_segment_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
+ DiaOrthConnMidSegmentObjectChange *change = DIA_ORTH_CONN_MID_SEGMENT_OBJECT_CHANGE (self);
OrthConn *orth = (OrthConn *)obj;
dia_object_change_revert (change->cplchange[0], obj);
@@ -1226,13 +1246,9 @@ midsegment_create_change (OrthConn *orth,
Handle *handle1,
Handle *handle2)
{
- struct MidSegmentChange *change;
+ DiaOrthConnMidSegmentObjectChange *change;
- change = g_new0 (struct MidSegmentChange, 1);
-
- change->obj_change.apply = (ObjectChangeApplyFunc) midsegment_change_apply;
- change->obj_change.revert = (ObjectChangeRevertFunc) midsegment_change_revert;
- change->obj_change.free = (ObjectChangeFreeFunc) midsegment_change_free;
+ change = dia_object_change_new (DIA_TYPE_ORTH_CONN_MID_SEGMENT_OBJECT_CHANGE);
change->type = type;
change->applied = 0;
@@ -1242,18 +1258,23 @@ midsegment_create_change (OrthConn *orth,
change->handles[0] = handle1;
change->handles[1] = handle2;
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
+
static void
-autoroute_change_free(struct AutorouteChange *change)
+dia_orth_conn_autoroute_object_change_free (DiaObjectChange *self)
{
+ DiaOrthConnAutorouteObjectChange *change = DIA_ORTH_CONN_AUTOROUTE_OBJECT_CHANGE (self);
+
g_clear_pointer (&change->points, g_free);
}
+
static void
-autoroute_change_apply(struct AutorouteChange *change, DiaObject *obj)
+dia_orth_conn_autoroute_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
+ DiaOrthConnAutorouteObjectChange *change = DIA_ORTH_CONN_AUTOROUTE_OBJECT_CHANGE (self);
OrthConn *orth = (OrthConn*)obj;
if (change->on) {
@@ -1267,9 +1288,11 @@ autoroute_change_apply(struct AutorouteChange *change, DiaObject *obj)
}
}
+
static void
-autoroute_change_revert(struct AutorouteChange *change, DiaObject *obj)
+dia_orth_conn_autoroute_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
+ DiaOrthConnAutorouteObjectChange *change = DIA_ORTH_CONN_AUTOROUTE_OBJECT_CHANGE (self);
OrthConn *orth = (OrthConn*)obj;
if (change->on) {
@@ -1286,22 +1309,19 @@ autoroute_change_revert(struct AutorouteChange *change, DiaObject *obj)
static DiaObjectChange *
autoroute_create_change (OrthConn *orth, gboolean on)
{
- struct AutorouteChange *change;
- int i;
+ DiaOrthConnAutorouteObjectChange *change;
- change = g_new(struct AutorouteChange, 1);
-
- change->obj_change.apply = (ObjectChangeApplyFunc) autoroute_change_apply;
- change->obj_change.revert = (ObjectChangeRevertFunc) autoroute_change_revert;
- change->obj_change.free = (ObjectChangeFreeFunc) autoroute_change_free;
+ change = dia_object_change_new (DIA_TYPE_ORTH_CONN_AUTOROUTE_OBJECT_CHANGE);
change->on = on;
change->num_points = orth->numpoints;
- change->points = g_new(Point, orth->numpoints);
- for (i = 0; i < orth->numpoints; i++)
+ change->points = g_new0 (Point, orth->numpoints);
+
+ for (int i = 0; i < orth->numpoints; i++) {
change->points[i] = orth->points[i];
+ }
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
diff --git a/lib/orth_conn.h b/lib/orth_conn.h
index 39ebf1b45..b6dd0e430 100644
--- a/lib/orth_conn.h
+++ b/lib/orth_conn.h
@@ -25,6 +25,28 @@
G_BEGIN_DECLS
+
+#define DIA_TYPE_ORTH_CONN_MID_SEGMENT_OBJECT_CHANGE dia_orth_conn_mid_segment_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaOrthConnMidSegmentObjectChange,
+ dia_orth_conn_mid_segment_object_change,
+ DIA, ORTH_CONN_MID_SEGMENT_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
+#define DIA_TYPE_ORTH_CONN_END_SEGMENT_OBJECT_CHANGE dia_orth_conn_end_segment_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaOrthConnEndSegmentObjectChange,
+ dia_orth_conn_end_segment_object_change,
+ DIA, ORTH_CONN_END_SEGMENT_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
+#define DIA_TYPE_ORTH_CONN_AUTOROUTE_OBJECT_CHANGE dia_orth_conn_autoroute_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaOrthConnAutorouteObjectChange,
+ dia_orth_conn_autoroute_object_change,
+ DIA, ORTH_CONN_AUTOROUTE_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
typedef enum {
HORIZONTAL,
VERTICAL
diff --git a/lib/poly_conn.c b/lib/poly_conn.c
index c1573dae2..5f65f0155 100644
--- a/lib/poly_conn.c
+++ b/lib/poly_conn.c
@@ -26,7 +26,6 @@
#include "poly_conn.h"
#include "diarenderer.h"
-#include "dia-object-change-legacy.h"
enum change_type {
@@ -35,8 +34,8 @@ enum change_type {
};
-struct PointChange {
- ObjectChange obj_change;
+struct _DiaPolyConnObjectChange {
+ DiaObjectChange obj_change;
enum change_type type;
int applied;
@@ -50,6 +49,9 @@ struct PointChange {
};
+DIA_DEFINE_OBJECT_CHANGE (DiaPolyConnObjectChange, dia_poly_conn_object_change)
+
+
static DiaObjectChange *polyconn_create_change (PolyConn *poly,
enum change_type type,
Point *point,
@@ -509,23 +511,31 @@ polyconn_load(PolyConn *poly, ObjectNode obj_node, DiaContext *ctx) /* NOTE: Doe
polyconn_update_data(poly);
}
+
static void
-polyconn_change_free(struct PointChange *change)
+dia_poly_conn_object_change_free (DiaObjectChange *self)
{
- if ( (change->type==TYPE_ADD_POINT && !change->applied) ||
- (change->type==TYPE_REMOVE_POINT && change->applied) ){
+ DiaPolyConnObjectChange *change = DIA_POLY_CONN_OBJECT_CHANGE (self);
+
+ if ((change->type == TYPE_ADD_POINT && !change->applied) ||
+ (change->type == TYPE_REMOVE_POINT && change->applied) ){
g_clear_pointer (&change->handle, g_free);
}
}
static void
-polyconn_change_apply (struct PointChange *change, DiaObject *obj)
+dia_poly_conn_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
+ DiaPolyConnObjectChange *change = DIA_POLY_CONN_OBJECT_CHANGE (self);
+
change->applied = 1;
+
switch (change->type) {
case TYPE_ADD_POINT:
- add_handle ((PolyConn *) obj, change->pos, &change->point,
+ add_handle ((PolyConn *) obj,
+ change->pos,
+ &change->point,
change->handle);
break;
case TYPE_REMOVE_POINT:
@@ -539,14 +549,18 @@ polyconn_change_apply (struct PointChange *change, DiaObject *obj)
static void
-polyconn_change_revert (struct PointChange *change, DiaObject *obj)
+dia_poly_conn_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
+ DiaPolyConnObjectChange *change = DIA_POLY_CONN_OBJECT_CHANGE (self);
+
switch (change->type) {
case TYPE_ADD_POINT:
remove_handle ((PolyConn *) obj, change->pos);
break;
case TYPE_REMOVE_POINT:
- add_handle ((PolyConn *) obj, change->pos, &change->point,
+ add_handle ((PolyConn *) obj,
+ change->pos,
+ &change->point,
change->handle);
if (change->connected_to) {
@@ -557,6 +571,7 @@ polyconn_change_revert (struct PointChange *change, DiaObject *obj)
default:
g_return_if_reached ();
}
+
change->applied = 0;
}
@@ -569,13 +584,9 @@ polyconn_create_change (PolyConn *poly,
Handle *handle,
ConnectionPoint *connected_to)
{
- struct PointChange *change;
-
- change = g_new0 (struct PointChange, 1);
+ DiaPolyConnObjectChange *change;
- change->obj_change.apply = (ObjectChangeApplyFunc) polyconn_change_apply;
- change->obj_change.revert = (ObjectChangeRevertFunc) polyconn_change_revert;
- change->obj_change.free = (ObjectChangeFreeFunc) polyconn_change_free;
+ change = dia_object_change_new (DIA_TYPE_POLY_CONN_OBJECT_CHANGE);
change->type = type;
change->applied = 1;
@@ -584,5 +595,5 @@ polyconn_create_change (PolyConn *poly,
change->handle = handle;
change->connected_to = connected_to;
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
diff --git a/lib/poly_conn.h b/lib/poly_conn.h
index 40f3bc587..b0c0c250f 100644
--- a/lib/poly_conn.h
+++ b/lib/poly_conn.h
@@ -15,13 +15,22 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef POLY_CONN_H
-#define POLY_CONN_H
+
+#pragma once
#include "diatypes.h"
#include "object.h"
#include "boundingbox.h"
+G_BEGIN_DECLS
+
+#define DIA_TYPE_POLY_CONN_OBJECT_CHANGE dia_poly_conn_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaPolyConnObjectChange,
+ dia_poly_conn_object_change,
+ DIA, POLY_CONN_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
#define HANDLE_CORNER (HANDLE_CUSTOM1)
/*!
@@ -79,4 +88,4 @@ int polyconn_closest_segment(PolyConn *poly, Point *point,
{ "poly_points", PROP_TYPE_POINTARRAY, \
offsetof(PolyConn,points), offsetof(PolyConn,numpoints)} \
-#endif /* POLY_CONN_H */
+G_END_DECLS
diff --git a/lib/polyshape.c b/lib/polyshape.c
index 6b3460d68..b1a703ad7 100644
--- a/lib/polyshape.c
+++ b/lib/polyshape.c
@@ -27,8 +27,6 @@
#include "polyshape.h"
#include "message.h"
#include "diarenderer.h"
-#include "dia-object-change-legacy.h"
-
#define NUM_CONNECTIONS(poly) ((poly)->numpoints * 2 + 1)
@@ -37,8 +35,9 @@ enum change_type {
TYPE_REMOVE_POINT
};
-struct PointChange {
- ObjectChange obj_change;
+
+struct _DiaPolyShapeObjectChange {
+ DiaObjectChange obj_change;
enum change_type type;
int applied;
@@ -52,6 +51,9 @@ struct PointChange {
};
+DIA_DEFINE_OBJECT_CHANGE (DiaPolyShapeObjectChange, dia_poly_shape_object_change)
+
+
static DiaObjectChange *polyshape_create_change (PolyShape *poly,
enum change_type type,
Point *point,
@@ -220,22 +222,28 @@ polyshape_add_point (PolyShape *poly, int segment, Point *point)
ConnectionPoint *new_cp1, *new_cp2;
if (point == NULL) {
- realpoint.x = (poly->points[segment].x+poly->points[segment+1].x)/2;
- realpoint.y = (poly->points[segment].y+poly->points[segment+1].y)/2;
+ realpoint.x = (poly->points[segment].x + poly->points[segment + 1].x) / 2;
+ realpoint.y = (poly->points[segment].y + poly->points[segment + 1].y) / 2;
} else {
realpoint = *point;
}
- new_handle = g_new(Handle, 1);
- new_cp1 = g_new0(ConnectionPoint, 1);
+ new_handle = g_new (Handle, 1);
+ new_cp1 = g_new0 (ConnectionPoint, 1);
new_cp1->object = &poly->object;
- new_cp2 = g_new0(ConnectionPoint, 1);
+ new_cp2 = g_new0 (ConnectionPoint, 1);
new_cp2->object = &poly->object;
- setup_handle(new_handle);
- add_handle(poly, segment+1, &realpoint, new_handle, new_cp1, new_cp2);
- return polyshape_create_change(poly, TYPE_ADD_POINT,
- &realpoint, segment+1, new_handle,
- new_cp1, new_cp2);
+
+ setup_handle (new_handle);
+ add_handle (poly, segment + 1, &realpoint, new_handle, new_cp1, new_cp2);
+
+ return polyshape_create_change (poly,
+ TYPE_ADD_POINT,
+ &realpoint,
+ segment + 1,
+ new_handle,
+ new_cp1,
+ new_cp2);
}
@@ -248,20 +256,25 @@ polyshape_remove_point (PolyShape *poly, int pos)
old_handle = poly->object.handles[pos];
old_point = poly->points[pos];
- old_cp1 = poly->object.connections[2*pos];
- old_cp2 = poly->object.connections[2*pos+1];
+ old_cp1 = poly->object.connections[2 * pos];
+ old_cp2 = poly->object.connections[2 * pos + 1];
- object_unconnect((DiaObject *)poly, old_handle);
+ object_unconnect (DIA_OBJECT (poly), old_handle);
- remove_handle(poly, pos);
+ remove_handle (poly, pos);
- polyshape_update_data(poly);
+ polyshape_update_data (poly);
- return polyshape_create_change(poly, TYPE_REMOVE_POINT,
- &old_point, pos, old_handle,
- old_cp1, old_cp2);
+ return polyshape_create_change (poly,
+ TYPE_REMOVE_POINT,
+ &old_point,
+ pos,
+ old_handle,
+ old_cp1,
+ old_cp2);
}
+
/** Returns the first clockwise direction in dirs
* (as returned from find_slope_directions) */
static gint
@@ -564,11 +577,14 @@ polyshape_load(PolyShape *poly, ObjectNode obj_node, DiaContext *ctx) /* NOTE: D
polyshape_update_data(poly);
}
+
static void
-polyshape_change_free(struct PointChange *change)
+dia_poly_shape_object_change_free (DiaObjectChange *self)
{
- if ( (change->type==TYPE_ADD_POINT && !change->applied) ||
- (change->type==TYPE_REMOVE_POINT && change->applied) ){
+ DiaPolyShapeObjectChange *change = DIA_POLY_SHAPE_OBJECT_CHANGE (self);
+
+ if ((change->type == TYPE_ADD_POINT && !change->applied) ||
+ (change->type == TYPE_REMOVE_POINT && change->applied) ){
g_clear_pointer (&change->handle, g_free);
g_clear_pointer (&change->cp1, g_free);
g_clear_pointer (&change->cp2, g_free);
@@ -577,9 +593,12 @@ polyshape_change_free(struct PointChange *change)
static void
-polyshape_change_apply (struct PointChange *change, DiaObject *obj)
+dia_poly_shape_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
+ DiaPolyShapeObjectChange *change = DIA_POLY_SHAPE_OBJECT_CHANGE (self);
+
change->applied = 1;
+
switch (change->type) {
case TYPE_ADD_POINT:
add_handle ((PolyShape *) obj, change->pos, &change->point,
@@ -596,8 +615,10 @@ polyshape_change_apply (struct PointChange *change, DiaObject *obj)
static void
-polyshape_change_revert (struct PointChange *change, DiaObject *obj)
+dia_poly_shape_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
+ DiaPolyShapeObjectChange *change = DIA_POLY_SHAPE_OBJECT_CHANGE (self);
+
switch (change->type) {
case TYPE_ADD_POINT:
remove_handle ((PolyShape *)obj, change->pos);
@@ -609,6 +630,7 @@ polyshape_change_revert (struct PointChange *change, DiaObject *obj)
default:
g_return_if_reached ();
}
+
change->applied = 0;
}
@@ -622,13 +644,9 @@ polyshape_create_change (PolyShape *poly,
ConnectionPoint *cp1,
ConnectionPoint *cp2)
{
- struct PointChange *change;
-
- change = g_new0 (struct PointChange, 1);
+ DiaPolyShapeObjectChange *change;
- change->obj_change.apply = (ObjectChangeApplyFunc) polyshape_change_apply;
- change->obj_change.revert = (ObjectChangeRevertFunc) polyshape_change_revert;
- change->obj_change.free = (ObjectChangeFreeFunc) polyshape_change_free;
+ change = dia_object_change_new (DIA_TYPE_POLY_SHAPE_OBJECT_CHANGE);
change->type = type;
change->applied = 1;
@@ -638,5 +656,5 @@ polyshape_create_change (PolyShape *poly,
change->cp1 = cp1;
change->cp2 = cp2;
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
diff --git a/lib/polyshape.h b/lib/polyshape.h
index 7d3e91a4e..a45da9d8f 100644
--- a/lib/polyshape.h
+++ b/lib/polyshape.h
@@ -15,13 +15,22 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef POLYSHAPE_H
-#define POLYSHAPE_H
+
+#pragma once
#include "diatypes.h"
#include "object.h"
#include "boundingbox.h"
+G_BEGIN_DECLS
+
+#define DIA_TYPE_POLY_SHAPE_OBJECT_CHANGE dia_poly_shape_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaPolyShapeObjectChange,
+ dia_poly_shape_object_change,
+ DIA, POLY_SHAPE_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
#define HANDLE_CORNER (HANDLE_CUSTOM1)
/*!
@@ -78,4 +87,4 @@ int polyshape_closest_segment(PolyShape *poly, Point *point,
{ "poly_points", PROP_TYPE_POINTARRAY, \
offsetof(PolyShape,points), offsetof(PolyShape,numpoints)} \
-#endif /* POLY_CONN_H */
+G_END_DECLS
diff --git a/lib/properties.h b/lib/properties.h
index f2dac2cdc..118e56949 100644
--- a/lib/properties.h
+++ b/lib/properties.h
@@ -54,6 +54,13 @@
G_BEGIN_DECLS
+#define DIA_TYPE_PROP_OBJECT_CHANGE dia_prop_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaPropObjectChange,
+ dia_prop_object_change,
+ DIA, PROP_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
typedef gboolean (*PropDescToPropPredicate)(const PropDescription *pdesc);
struct _PropWidgetAssoc {
diff --git a/lib/propobject.c b/lib/propobject.c
index 9882cc5c6..ec0856a1e 100644
--- a/lib/propobject.c
+++ b/lib/propobject.c
@@ -35,7 +35,6 @@
#include "properties.h"
#include "propinternals.h"
#include "object.h"
-#include "dia-object-change-legacy.h"
#include "dia-object-change-list.h"
@@ -105,17 +104,20 @@ object_get_props(DiaObject *obj, GPtrArray *props)
/* ------------------------------------------------------ */
/* Change management */
-/* an ObjectChange structure for setting of properties */
-typedef struct _ObjectPropChange ObjectPropChange;
-struct _ObjectPropChange {
- ObjectChange obj_change;
+/* an DiaObjectChange structure for setting of properties */
+struct _DiaPropObjectChange {
+ DiaObjectChange obj_change;
DiaObject *obj;
GPtrArray *saved_props;
};
+
+DIA_DEFINE_OBJECT_CHANGE (DiaPropObjectChange, dia_prop_object_change)
+
+
static void
-object_prop_change_apply_revert (ObjectPropChange *change, DiaObject *obj)
+dia_prop_object_change_apply_revert (DiaPropObjectChange *change, DiaObject *obj)
{
GPtrArray *old_props;
@@ -131,27 +133,37 @@ object_prop_change_apply_revert (ObjectPropChange *change, DiaObject *obj)
change->saved_props = old_props;
}
+
+static void
+dia_prop_object_change_apply (DiaObjectChange *self, DiaObject *obj)
+{
+ dia_prop_object_change_apply_revert (DIA_PROP_OBJECT_CHANGE (self), obj);
+}
+
+
static void
-object_prop_change_free(ObjectPropChange *change)
+dia_prop_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
- prop_list_free(change->saved_props);
+ dia_prop_object_change_apply_revert (DIA_PROP_OBJECT_CHANGE (self), obj);
+}
+
+
+static void
+dia_prop_object_change_free (DiaObjectChange *self)
+{
+ DiaPropObjectChange *change = DIA_PROP_OBJECT_CHANGE (self);
+
+ prop_list_free (change->saved_props);
}
DiaObjectChange *
object_apply_props (DiaObject *obj, GPtrArray *props)
{
- ObjectPropChange *change;
+ DiaPropObjectChange *change;
GPtrArray *old_props;
- change = g_new0 (ObjectPropChange, 1);
-
- change->obj_change.apply =
- (ObjectChangeApplyFunc) object_prop_change_apply_revert;
- change->obj_change.revert =
- (ObjectChangeRevertFunc) object_prop_change_apply_revert;
- change->obj_change.free =
- (ObjectChangeFreeFunc) object_prop_change_free;
+ change = dia_object_change_new (DIA_TYPE_PROP_OBJECT_CHANGE);
change->obj = obj;
@@ -165,7 +177,7 @@ object_apply_props (DiaObject *obj, GPtrArray *props)
change->saved_props = old_props;
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
diff --git a/lib/standard-path.c b/lib/standard-path.c
index 33b32a7b7..747e92cee 100644
--- a/lib/standard-path.c
+++ b/lib/standard-path.c
@@ -43,7 +43,6 @@
#include "create.h"
#include "bezier-common.h"
#include "pattern.h"
-#include "dia-object-change-legacy.h"
#include "dia-object-change-list.h"
@@ -496,9 +495,30 @@ _invert_path_callback (DiaObject *obj, Point *clicked, gpointer data)
}
-/* a very simple undo function, complete reversible function */
+struct _DiaPathObjectChange {
+ DiaObjectChange parent;
+};
+
+
+DIA_DEFINE_OBJECT_CHANGE (DiaPathObjectChange, dia_path_object_change)
+
+
+static void
+dia_path_object_change_free (DiaObjectChange *self)
+{
+
+}
+
+
+static void
+dia_path_object_change_apply (DiaObjectChange *self, DiaObject *obj)
+{
+ _stdpath_invert ((StdPath *) obj);
+}
+
+
static void
-_apply_invert (ObjectChange *change, DiaObject *obj)
+dia_path_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
_stdpath_invert ((StdPath *) obj);
}
@@ -507,11 +527,7 @@ _apply_invert (ObjectChange *change, DiaObject *obj)
static DiaObjectChange *
_path_object_invert_change_create (DiaObject *obj)
{
- ObjectChange *change = g_new0 (ObjectChange, 1);
- change->apply = _apply_invert;
- change->revert = _apply_invert;
- change->free = NULL;
- return dia_object_change_legacy_new (change);
+ return dia_object_change_new (DIA_TYPE_PATH_OBJECT_CHANGE);
}
@@ -529,16 +545,27 @@ _path_transform (StdPath *sp, const DiaMatrix *m)
}
-typedef struct _PathTransformChange {
- ObjectChange change;
- DiaMatrix matrix;
-} PathTransformChange;
+struct _DiaPathTransformObjectChange {
+ DiaObjectChange change;
+ DiaMatrix matrix;
+};
+
+
+DIA_DEFINE_OBJECT_CHANGE (DiaPathTransformObjectChange,
+ dia_path_transform_object_change)
+
+
+static void
+dia_path_transform_object_change_free (DiaObjectChange *self)
+{
+
+}
static void
-_ptc_apply (ObjectChange *change, DiaObject *obj)
+dia_path_transform_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
- PathTransformChange *ptc = (PathTransformChange *)change;
+ DiaPathTransformObjectChange *ptc = DIA_PATH_TRANSFORM_OBJECT_CHANGE (self);
StdPath *sp = (StdPath *) obj;
_path_transform (sp, &ptc->matrix);
@@ -546,10 +573,10 @@ _ptc_apply (ObjectChange *change, DiaObject *obj)
static void
-_ptc_revert (ObjectChange *change, DiaObject *obj)
+dia_path_transform_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
StdPath *sp = (StdPath *) obj;
- PathTransformChange *ptc = (PathTransformChange *) change;
+ DiaPathTransformObjectChange *ptc = DIA_PATH_TRANSFORM_OBJECT_CHANGE (self);
DiaMatrix mi = ptc->matrix;
if (cairo_matrix_invert ((cairo_matrix_t *) &mi) != CAIRO_STATUS_SUCCESS) {
@@ -562,13 +589,13 @@ _ptc_revert (ObjectChange *change, DiaObject *obj)
static DiaObjectChange *
_path_object_transform_change_create (DiaObject *obj, DiaMatrix *matrix)
{
- PathTransformChange *ptc = g_new0 (PathTransformChange, 1);
+ DiaPathTransformObjectChange *ptc;
+
+ ptc = dia_object_change_new (DIA_TYPE_PATH_TRANSFORM_OBJECT_CHANGE);
- ptc->change.apply = _ptc_apply;
- ptc->change.revert = _ptc_revert;
- ptc->change.free = NULL;
ptc->matrix = *matrix;
- return dia_object_change_legacy_new (&ptc->change);
+
+ return DIA_OBJECT_CHANGE (ptc);
}
diff --git a/lib/standard-path.h b/lib/standard-path.h
index a5ec7dd14..39ed56f91 100644
--- a/lib/standard-path.h
+++ b/lib/standard-path.h
@@ -19,14 +19,29 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef STANDARD_PATH_H
-#define STANDARD_PATH_H
+#pragma once
#include "diarenderer.h"
+G_BEGIN_DECLS
+
+#define DIA_TYPE_PATH_OBJECT_CHANGE dia_path_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaPathObjectChange,
+ dia_path_object_change,
+ DIA, PATH_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
+#define DIA_TYPE_PATH_TRANSFORM_OBJECT_CHANGE dia_path_transform_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaPathTransformObjectChange,
+ dia_path_transform_object_change,
+ DIA, PATH_TRANSFORM_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
/* there should be no need to use DIAVAR */
extern DiaObjectType stdpath_type;
gboolean text_to_path (const Text *text, GArray *points);
-#endif /* STANDARD_PATH_H */
+G_END_DECLS
diff --git a/lib/text.c b/lib/text.c
index 61b33e883..f0c894a42 100644
--- a/lib/text.c
+++ b/lib/text.c
@@ -33,7 +33,6 @@
#include "textline.h"
#include "attributes.h"
#include "object.h"
-#include "dia-object-change-legacy.h"
#include "dia-object-change-list.h"
@@ -54,8 +53,9 @@ typedef enum {
TYPE_DELETE_ALL
} TextChangeType;
-struct TextObjectChange {
- ObjectChange obj_change;
+
+struct _DiaTextObjectChange {
+ DiaObjectChange obj_change;
Text *text;
TextChangeType type;
@@ -72,6 +72,10 @@ struct TextObjectChange {
GPtrArray *props;
};
+
+DIA_DEFINE_OBJECT_CHANGE (DiaTextObjectChange, dia_text_object_change)
+
+
#define CURSOR_HEIGHT_RATIO 20
@@ -1322,8 +1326,9 @@ text_set_attributes (Text *text, TextAttributes *attr)
static void
-text_change_apply (struct TextObjectChange *change, DiaObject *obj)
+dia_text_object_change_apply (DiaObjectChange *self, DiaObject *obj)
{
+ DiaTextObjectChange *change = DIA_TEXT_OBJECT_CHANGE (self);
Text *text = change->text;
dia_object_get_properties (change->obj, change->props);
@@ -1364,9 +1369,11 @@ text_change_apply (struct TextObjectChange *change, DiaObject *obj)
static void
-text_change_revert (struct TextObjectChange *change, DiaObject *obj)
+dia_text_object_change_revert (DiaObjectChange *self, DiaObject *obj)
{
+ DiaTextObjectChange *change = DIA_TEXT_OBJECT_CHANGE (self);
Text *text = change->text;
+
switch (change->type) {
case TYPE_INSERT_CHAR:
text->cursor_pos = change->pos;
@@ -1407,8 +1414,10 @@ text_change_revert (struct TextObjectChange *change, DiaObject *obj)
static void
-text_change_free (struct TextObjectChange *change)
+dia_text_object_change_free (DiaObjectChange *self)
{
+ DiaTextObjectChange *change = DIA_TEXT_OBJECT_CHANGE (self);
+
g_clear_pointer (&change->str, g_free);
prop_list_free (change->props);
}
@@ -1447,19 +1456,15 @@ text_create_change (Text *text,
int row,
DiaObject *obj)
{
- struct TextObjectChange *change;
+ DiaTextObjectChange *change;
- change = g_new0 (struct TextObjectChange, 1);
+ change = dia_object_change_new (DIA_TYPE_TEXT_OBJECT_CHANGE);
change->obj = obj;
change->props = make_posision_and_size_prop_list ();
/* remember previous position/size */
dia_object_get_properties (change->obj, change->props);
- change->obj_change.apply = (ObjectChangeApplyFunc) text_change_apply;
- change->obj_change.revert = (ObjectChangeRevertFunc) text_change_revert;
- change->obj_change.free = (ObjectChangeFreeFunc) text_change_free;
-
change->text = text;
change->type = type;
change->ch = ch;
@@ -1472,7 +1477,7 @@ text_create_change (Text *text,
change->str = NULL;
}
- return dia_object_change_legacy_new ((ObjectChange *) change);
+ return DIA_OBJECT_CHANGE (change);
}
diff --git a/lib/text.h b/lib/text.h
index 6796cfcfb..e328d6a8c 100644
--- a/lib/text.h
+++ b/lib/text.h
@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef TEXT_H
-#define TEXT_H
+
+#pragma once
typedef enum {
TEXT_EDIT_START,
@@ -32,6 +32,15 @@ typedef enum {
#include "diarenderer.h"
#include "dia-object-change.h"
+G_BEGIN_DECLS
+
+#define DIA_TYPE_TEXT_OBJECT_CHANGE dia_text_object_change_get_type ()
+G_DECLARE_FINAL_TYPE (DiaTextObjectChange,
+ dia_text_object_change,
+ DIA, TEXT_OBJECT_CHANGE,
+ DiaObjectChange)
+
+
/*!
* \brief Multiline text representation
*
@@ -124,6 +133,5 @@ gboolean apply_textattr_properties(GPtrArray *props,
gboolean apply_textstr_properties(GPtrArray *props,
Text *text, const gchar *textname,
const gchar *str);
-#endif /* TEXT_H */
-
+G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]