>From fe79a1c1c583e64e0873fb049de07db7cc2ad8b8 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Wed, 17 Aug 2011 12:15:36 +0200 Subject: [PATCH 1/4] add property type for connection point --- lib/prop_connpoint.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/prop_connpoint.h | 32 ++++++++++++++++++++ lib/properties.c | 1 + lib/properties.h | 1 + lib/propinternals.h | 1 + 5 files changed, 115 insertions(+), 0 deletions(-) create mode 100644 lib/prop_connpoint.c create mode 100644 lib/prop_connpoint.h diff --git a/lib/prop_connpoint.c b/lib/prop_connpoint.c new file mode 100644 index 0000000..17822e5 --- /dev/null +++ b/lib/prop_connpoint.c @@ -0,0 +1,80 @@ +/* Dia -- a diagram creation/manipulation program -*- c -*- + * + * Property types for connection point type + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "properties.h" +#include "propinternals.h" +#include "prop_connpoint.h" +#include "prefs.h" + +/*********************************/ +/* The CONNPOINT property type. */ +/*********************************/ + +static ConnpointProperty * +connpointprop_new(const PropDescription *pdesc, PropDescToPropPredicate reason) +{ + ConnpointProperty *prop = g_new0(ConnpointProperty, 1); + initialize_property(&prop->common, pdesc, reason); + memset(&prop->connpoint_data, 0, sizeof(prop->connpoint_data)); + return prop; +} + +static ConnpointProperty * +connpointprop_copy(ConnpointProperty *src) +{ + ConnpointProperty *prop = + (ConnpointProperty *)src->common.ops->new_prop(src->common.descr, + src->common.reason); + copy_init_property(&prop->common,&src->common); + prop->connpoint_data = src->connpoint_data; + return prop; +} + +static void +connpointprop_get_from_offset(ConnpointProperty *prop, + void *base, guint offset, guint offset2) +{ + prop->connpoint_data = struct_member(base, offset, ConnectionPoint*); +} + +static const PropertyOps connpointprop_ops = { + (PropertyType_New) connpointprop_new, + (PropertyType_Free) noopprop_free, + (PropertyType_Copy) connpointprop_copy, + (PropertyType_Load) invalidprop_load, + (PropertyType_Save) invalidprop_save, + (PropertyType_GetWidget) invalidprop_get_widget, + (PropertyType_ResetWidget) invalidprop_reset_widget, + (PropertyType_SetFromWidget) invalidprop_set_from_widget, + + (PropertyType_CanMerge) noopprop_can_merge, + (PropertyType_GetFromOffset) connpointprop_get_from_offset, + (PropertyType_SetFromOffset) invalidprop_set_from_offset +}; + +void +prop_connpoint_register(void) +{ + prop_type_register(PROP_TYPE_CONNPOINT, &connpointprop_ops); +} diff --git a/lib/prop_connpoint.h b/lib/prop_connpoint.h new file mode 100644 index 0000000..fdb368c --- /dev/null +++ b/lib/prop_connpoint.h @@ -0,0 +1,32 @@ +/* Dia -- a diagram creation/manipulation program -*- c -*- + * + * Property types for connection point type + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#ifndef PROP_CONNPOINT_H +#define PROP_CONNPOINT_H + +#include "properties.h" +#include "connectionpoint.h" + +typedef struct { + Property common; + ConnectionPoint * connpoint_data; +} ConnpointProperty; + +void prop_connpoint_register(void); + +#endif diff --git a/lib/properties.c b/lib/properties.c index 2880ca1..cff1451 100644 --- a/lib/properties.c +++ b/lib/properties.c @@ -53,6 +53,7 @@ stdprops_init(void) prop_dicttypes_register(); prop_pixbuftypes_register(); prop_matrix_register(); + prop_connpoint_register(); } /* --------------------------------------- */ diff --git a/lib/properties.h b/lib/properties.h index a1127e2..7b8037c 100644 --- a/lib/properties.h +++ b/lib/properties.h @@ -199,6 +199,7 @@ typedef const gchar *PropertyType; #define PROP_TYPE_DICT "dict" /* DictProperty */ #define PROP_TYPE_PIXBUF "pixbuf" /* PixbufProperty */ #define PROP_TYPE_MATRIX "matrix" /* MatrixProperty */ +#define PROP_TYPE_CONNPOINT "connpoint" /* ConnpointProperty */ /* **************************************************************** */ diff --git a/lib/propinternals.h b/lib/propinternals.h index b4b1734..070919e 100644 --- a/lib/propinternals.h +++ b/lib/propinternals.h @@ -88,6 +88,7 @@ void do_get_props_from_offsets(void *base, GPtrArray *props, #include "prop_dict.h" #include "prop_pixbuf.h" #include "prop_matrix.h" +#include "prop_connpoint.h" #endif /* PROPINTERNALS_H */ -- 1.7.5.4