dia r3958 - in trunk: . bindings lib objects/AADL objects/GRAFCET objects/Jackson objects/KAOS objects/UML objects/standard plug-ins/python
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r3958 - in trunk: . bindings lib objects/AADL objects/GRAFCET objects/Jackson objects/KAOS objects/UML objects/standard plug-ins/python
- Date: Sat, 26 Apr 2008 16:24:42 +0100 (BST)
Author: hans
Date: Sat Apr 26 15:24:41 2008
New Revision: 3958
URL: http://svn.gnome.org/viewvc/dia?rev=3958&view=rev
Log:
2008-04-26 Hans Breuer <hans breuer org>
[ there is an unwritten rule for std-props: same name, same type ]
* objects/AADL/aadlbox.c objects/Jackson/phenomenon.c
objects/UML/message.c objects/UML/node.c : what is called text
should be of type text
* objects/KAOS/metaandorrel.c objects/UML/implements.c : 'name' is
of type string
* objects/GRAFCET/step.c : font_size as fontsize not real
* objects/standard/box.c : corner_radius as real
* objects/UML/classicon.c : stereotype is a string
* plug-ins/python/allprops.py : creates a diagram extracting common
properties from all registered objects, warns about name/type clashes
* plug-ins/python/Makefile.am : add allprops.py, remove
diasvg_import.py from installed plug-ins
* plug-ins/python/pydia-properties.c : exclude PROP_FLAG_LOAD_ONLY
(compatibility) properties from the property dictionary
* bindings/test.py : added allprops test
* lib/propdialogs.c : use &= ~PXP_NOTSET to reset the property
experience flag
Added:
trunk/plug-ins/python/allprops.py (contents, props changed)
Modified:
trunk/ChangeLog
trunk/bindings/test.py
trunk/lib/propdialogs.c
trunk/objects/AADL/aadlbox.c
trunk/objects/GRAFCET/step.c
trunk/objects/Jackson/phenomenon.c
trunk/objects/KAOS/metaandorrel.c
trunk/objects/UML/association.c
trunk/objects/UML/classicon.c
trunk/objects/UML/implements.c
trunk/objects/UML/message.c
trunk/objects/UML/node.c
trunk/objects/standard/box.c
trunk/plug-ins/python/Makefile.am
trunk/plug-ins/python/pydia-properties.c
Modified: trunk/bindings/test.py
==============================================================================
--- trunk/bindings/test.py (original)
+++ trunk/bindings/test.py Sat Apr 26 15:24:41 2008
@@ -117,6 +117,11 @@
r.begin_render (data, "diaraw.dia")
r.end_render ()
+def Props () :
+ data = dia.DiagramData()
+ import allprops
+ allprops.allprops_cb(data,0)
+
def Self () :
data = dia.DiagramData()
r = data.extents
@@ -136,6 +141,7 @@
elif '--gen' == arg : Gen ()
elif '--self' == arg : Self ()
elif '--draw' == arg : DRaw ()
+ elif '--props' == arg : Props ()
elif '--all' == arg :
Dump()
Import()
Modified: trunk/lib/propdialogs.c
==============================================================================
--- trunk/lib/propdialogs.c (original)
+++ trunk/lib/propdialogs.c Sat Apr 26 15:24:41 2008
@@ -183,7 +183,7 @@
g_assert(obj->ops->set_props);
g_assert(obj->ops->get_props);
- prop->experience &= !PXP_NOTSET;
+ prop->experience &= ~PXP_NOTSET;
if (!prop->event_handler)
return;
Modified: trunk/objects/AADL/aadlbox.c
==============================================================================
--- trunk/objects/AADL/aadlbox.c (original)
+++ trunk/objects/AADL/aadlbox.c Sat Apr 26 15:24:41 2008
@@ -153,7 +153,10 @@
PROP_STD_TEXT_FONT,
PROP_STD_TEXT_HEIGHT,
PROP_STD_TEXT_COLOUR_OPTIONAL,
- { "name", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
+ /* backward compatibility */
+ { "name", PROP_TYPE_TEXT, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Text"), NULL, NULL },
+ /* new name matching "same name, same type" rule */
+ { "text", PROP_TYPE_TEXT, PROP_FLAG_OPTIONAL, N_("Text"), NULL, NULL },
PROP_DESC_END
};
@@ -172,7 +175,10 @@
{"declaration",PROP_TYPE_STRING,offsetof(Aadlbox,declaration)},
{"line_colour",PROP_TYPE_COLOUR,offsetof(Aadlbox,line_color)},
{"fill_colour",PROP_TYPE_COLOUR,offsetof(Aadlbox,fill_color)},
+ /* backward compatibility */
{"name",PROP_TYPE_TEXT,offsetof(Aadlbox,name)},
+ /* new name matching "same name, same type" rule */
+ {"text",PROP_TYPE_TEXT,offsetof(Aadlbox,name)},
{"text_font",PROP_TYPE_FONT,offsetof(Aadlbox,attrs.font)},
{PROP_STDNAME_TEXT_HEIGHT, PROP_STDTYPE_TEXT_HEIGHT,offsetof(Aadlbox,attrs.height)},
{"text_colour",PROP_TYPE_COLOUR,offsetof(Aadlbox,attrs.color)},
Modified: trunk/objects/GRAFCET/step.c
==============================================================================
--- trunk/objects/GRAFCET/step.c (original)
+++ trunk/objects/GRAFCET/step.c Sat Apr 26 15:24:41 2008
@@ -165,7 +165,7 @@
N_("Active"), N_("Shows a red dot to figure the step's activity")},
{ "font", PROP_TYPE_FONT, PROP_FLAG_VISIBLE,
N_("Font"),NULL},
- { "font_size", PROP_TYPE_REAL, PROP_FLAG_VISIBLE,
+ { "font_size", PROP_TYPE_FONTSIZE, PROP_FLAG_VISIBLE,
N_("Font size"), NULL, &prop_std_text_height_data},
{ "font_color", PROP_TYPE_COLOUR, PROP_FLAG_VISIBLE,
N_("Text color"), NULL },
@@ -189,7 +189,7 @@
{ "type", PROP_TYPE_ENUM, offsetof(Step,type)},
{ "active", PROP_TYPE_BOOL, offsetof(Step,active)},
{ "font", PROP_TYPE_FONT, offsetof(Step,font)},
- { "font_size", PROP_TYPE_REAL, offsetof(Step,font_size)},
+ { "font_size", PROP_TYPE_FONTSIZE, offsetof(Step,font_size)},
{ "font_color", PROP_TYPE_COLOUR, offsetof(Step,font_color)},
{ "north_pos", PROP_TYPE_POINT, offsetof(Step,north.pos)},
{ "south_pos", PROP_TYPE_POINT, offsetof(Step,south.pos)},
Modified: trunk/objects/Jackson/phenomenon.c
==============================================================================
--- trunk/objects/Jackson/phenomenon.c (original)
+++ trunk/objects/Jackson/phenomenon.c Sat Apr 26 15:24:41 2008
@@ -140,8 +140,10 @@
static PropDescription message_props[] = {
CONNECTION_COMMON_PROPERTIES,
- { "text", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
- N_("Message:"), NULL, NULL },
+ /* backward compatibility */
+ { "text", PROP_TYPE_STRING, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Message:"), NULL, NULL },
+ /* new name matching "same name, same type" rule */
+ { "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL, N_("Message:"), NULL, NULL },
{ "type", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE,
N_("Type:"), NULL, prop_message_type_data },
{ "text_pos", PROP_TYPE_POINT, 0,
@@ -160,7 +162,10 @@
static PropOffset message_offsets[] = {
CONNECTION_COMMON_PROPERTIES_OFFSETS,
+ /* backward compatibility */
{ "text", PROP_TYPE_STRING, offsetof(Message, text) },
+ /* new name matching "same name, same type" rule */
+ { "name", PROP_TYPE_STRING, offsetof(Message, text) },
{ "type", PROP_TYPE_ENUM, offsetof(Message, type) },
{ "text_pos", PROP_TYPE_POINT, offsetof(Message,text_pos) },
{ NULL, 0, 0 }
Modified: trunk/objects/KAOS/metaandorrel.c
==============================================================================
--- trunk/objects/KAOS/metaandorrel.c (original)
+++ trunk/objects/KAOS/metaandorrel.c Sat Apr 26 15:24:41 2008
@@ -159,8 +159,10 @@
static PropDescription maor_props[] = {
CONNECTION_COMMON_PROPERTIES,
- { "text", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
- N_("Text:"), NULL, NULL },
+ /* backward compatibility */
+ { "text", PROP_TYPE_STRING, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Text:"), NULL, NULL },
+ /* new name matching "same name, same type" rule */
+ { "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL, N_("Text:"), NULL, NULL },
{ "type", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE,
N_("Type:"), NULL, prop_maor_type_data },
@@ -181,7 +183,10 @@
static PropOffset maor_offsets[] = {
CONNECTION_COMMON_PROPERTIES_OFFSETS,
+ /* backward compatibility */
{ "text", PROP_TYPE_STRING, offsetof(Maor, text) },
+ /* new name matching "same name, same type" rule */
+ { "name", PROP_TYPE_STRING, offsetof(Maor, text) },
{ "type", PROP_TYPE_ENUM, offsetof(Maor,type)},
{ "text_pos", PROP_TYPE_POINT, offsetof(Maor,text_pos) },
{ NULL, 0, 0 }
Modified: trunk/objects/UML/association.c
==============================================================================
--- trunk/objects/UML/association.c (original)
+++ trunk/objects/UML/association.c Sat Apr 26 15:24:41 2008
@@ -53,7 +53,6 @@
#endif
#include <assert.h>
-#include <gtk/gtk.h>
#include <math.h>
#include <string.h>
@@ -70,6 +69,7 @@
#include "pixmaps/association.xpm"
extern char visible_char[]; /* The definitions are in UML.c. Used here to avoid getting out of sync */
+extern PropEnumData _uml_visibilities[];
typedef struct _Association Association;
typedef struct _AssociationState AssociationState;
@@ -77,14 +77,14 @@
typedef enum {
ASSOC_NODIR,
- ASSOC_RIGHT,
+ ASSOC_RIGHT, /* the diamond is on the left side and the arrow points right */
ASSOC_LEFT
} AssociationDirection;
typedef enum {
AGGREGATE_NONE,
- AGGREGATE_NORMAL,
- AGGREGATE_COMPOSITION
+ AGGREGATE_NORMAL, /* filled diamond */
+ AGGREGATE_COMPOSITION /* hollow diamond */
} AggregateType;
typedef struct _AssociationEnd {
@@ -131,31 +131,14 @@
gchar *name;
AssociationDirection direction;
+ AggregateType assoc_type;
+
+ gboolean show_direction;
AssociationEnd end[2];
Color text_color;
Color line_color;
-
- AssociationPropertiesDialog* properties_dialog;
-};
-
-struct _AssociationPropertiesDialog {
- GtkWidget *dialog;
-
- GtkEntry *name;
- GtkMenu *dir_menu;
- GtkOptionMenu *dir_omenu;
-
- struct {
- GtkEntry *role;
- GtkEntry *multiplicity;
- GtkMenu *attr_visible;
- GtkOptionMenu *attr_visible_button;
- GtkToggleButton *draw_arrow;
- GtkToggleButton *aggregate;
- GtkToggleButton *composition;
- } end[2];
};
#define ASSOCIATION_WIDTH 0.1
@@ -180,8 +163,6 @@
Handle **handle2);
static void association_destroy(Association *assoc);
static DiaObject *association_copy(Association *assoc);
-static GtkWidget *association_get_properties(Association *assoc, gboolean is_default);
-static ObjectChange *association_apply_properties(Association *assoc);
static DiaMenu *association_get_object_menu(Association *assoc,
Point *clickedpoint);
static PropDescription *association_describe_props(Association *assoc);
@@ -204,14 +185,15 @@
{
(CreateFunc) association_create,
(LoadFunc) association_load,
- (SaveFunc) association_save
+ (SaveFunc) object_save_using_properties
};
DiaObjectType association_type =
{
"UML - Association", /* name */
/* Version 0 had no autorouting and so shouldn't have it set by default. */
- 1, /* version */
+ /* Version 1 was saving both ends separately without using StdProps */
+ 2, /* version */
(char **) association_xpm, /* pixmap */
&association_type_ops, /* ops */
@@ -227,8 +209,8 @@
(CopyFunc) association_copy,
(MoveFunc) association_move,
(MoveHandleFunc) association_move_handle,
- (GetPropertiesFunc) association_get_properties,
- (ApplyPropertiesDialogFunc) association_apply_properties,
+ (GetPropertiesFunc) object_create_props_dialog,
+ (ApplyPropertiesDialogFunc) object_apply_props_from_dialog,
(ObjectMenuFunc) association_get_object_menu,
(DescribePropsFunc) association_describe_props,
(GetPropsFunc) association_get_props,
@@ -237,13 +219,87 @@
(ApplyPropertiesListFunc) object_apply_props,
};
+static PropEnumData prop_assoc_direction_data[] = {
+ { N_("None"), ASSOC_NODIR },
+ { N_("From A to B"), ASSOC_RIGHT },
+ { N_("From B to A"), ASSOC_LEFT },
+ { NULL, 0 }
+};
+static PropEnumData prop_assoc_type_data[] = {
+ { N_("None"), AGGREGATE_NONE },
+ { N_("Aggregation"), AGGREGATE_NORMAL },
+ { N_("Composition"), AGGREGATE_COMPOSITION },
+ { NULL, 0 }
+};
+
static PropDescription association_props[] = {
+ { "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE, N_("Name"), NULL, NULL },
+ { "direction", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE,
+ N_("Direction"), NULL, prop_assoc_direction_data },
+ { "show_direction", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_("Show direction"), N_("Show the small arrow denoting the reading direction"), 0 },
+ { "assoc_type", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_("Type"), NULL, prop_assoc_type_data },
+
+ PROP_MULTICOL_BEGIN("sides"),
+ PROP_MULTICOL_COLUMN("side_a"),
+ { "help", PROP_TYPE_STATIC, PROP_FLAG_VISIBLE|PROP_FLAG_DONT_SAVE|PROP_FLAG_DONT_MERGE,
+ N_(" "), N_("Side A") },
+ { "role_a", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_("Role"), NULL, NULL },
+ { "multipicity_a", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_("Multiplicity"), NULL, NULL },
+ { "visibility_a", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_("Visibility"), NULL, _uml_visibilities },
+ { "show_arrow_a", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_("Show arrow"), NULL, 0 },
+ PROP_MULTICOL_COLUMN("side_b"),
+ { "help", PROP_TYPE_STATIC, PROP_FLAG_VISIBLE|PROP_FLAG_DONT_SAVE|PROP_FLAG_DONT_MERGE,
+ N_(" "), N_("Side B") },
+ { "role_b", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_(" "), NULL, NULL },
+ { "multipicity_b", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_(" "), NULL, NULL },
+ { "visibility_b", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_(" "), NULL, _uml_visibilities },
+ { "show_arrow_b", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL,
+ N_(" "), NULL, 0 },
+ PROP_MULTICOL_END("sides"),
+
ORTHCONN_COMMON_PROPERTIES,
- { "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
- N_("Name:"), NULL, NULL },
+ /* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
+ PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
+ PROP_STD_LINE_COLOUR_OPTIONAL,
+
PROP_DESC_END
};
+static PropOffset association_offsets[] = {
+ { "name", PROP_TYPE_STRING, offsetof(Association, name) },
+ { "direction", PROP_TYPE_ENUM, offsetof(Association, direction) },
+ { "assoc_type", PROP_TYPE_ENUM, offsetof(Association, assoc_type) },
+ { "show_direction", PROP_TYPE_BOOL, offsetof(Association, show_direction) },
+
+ PROP_OFFSET_MULTICOL_BEGIN("sides"),
+ PROP_OFFSET_MULTICOL_COLUMN("side_a"),
+ { "role_a", PROP_TYPE_STRING, offsetof(Association, end[0].role) },
+ { "multipicity_a", PROP_TYPE_STRING, offsetof(Association, end[0].multiplicity) },
+ { "visibility_a", PROP_TYPE_ENUM, offsetof(Association, end[0].visibility) },
+ { "show_arrow_a", PROP_TYPE_BOOL, offsetof(Association, end[0].arrow) },
+
+ PROP_OFFSET_MULTICOL_COLUMN("side_a"),
+ { "role_b", PROP_TYPE_STRING, offsetof(Association, end[1].role) },
+ { "multipicity_b", PROP_TYPE_STRING, offsetof(Association, end[1].multiplicity) },
+ { "visibility_b", PROP_TYPE_ENUM, offsetof(Association, end[1].visibility) },
+ { "show_arrow_b", PROP_TYPE_BOOL, offsetof(Association, end[1].arrow) },
+ PROP_OFFSET_MULTICOL_END("sides"),
+
+ ORTHCONN_COMMON_PROPERTIES_OFFSETS,
+ { "line_colour",PROP_TYPE_COLOUR,offsetof(Association, line_color) },
+ { "text_colour", PROP_TYPE_COLOUR, offsetof(Association, text_color) },
+ { NULL, 0, 0 }
+};
+
static PropDescription *
association_describe_props(Association *assoc)
{
@@ -253,14 +309,6 @@
return association_props;
}
-static PropOffset association_offsets[] = {
- ORTHCONN_COMMON_PROPERTIES_OFFSETS,
- { "line_colour",PROP_TYPE_COLOUR,offsetof(Association, line_color) },
- { "text_colour", PROP_TYPE_COLOUR, offsetof(Association, text_color) },
- { "name", PROP_TYPE_STRING, offsetof(Association, name) },
- { NULL, 0, 0 }
-};
-
static void
association_get_props(Association *assoc, GPtrArray *props)
{
@@ -382,26 +430,30 @@
case ASSOC_NODIR:
break;
case ASSOC_RIGHT:
- poly[0].x = assoc->text_pos.x + assoc->text_width + 0.1;
- if (assoc->text_align == ALIGN_CENTER)
- poly[0].x -= assoc->text_width/2.0;
- poly[0].y = assoc->text_pos.y;
- poly[1].x = poly[0].x;
- poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
- poly[2].x = poly[0].x + ASSOCIATION_FONTHEIGHT*0.5;
- poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
- renderer_ops->fill_polygon(renderer, poly, 3, &assoc->line_color);
+ if (assoc->show_direction) {
+ poly[0].x = assoc->text_pos.x + assoc->text_width + 0.1;
+ if (assoc->text_align == ALIGN_CENTER)
+ poly[0].x -= assoc->text_width/2.0;
+ poly[0].y = assoc->text_pos.y;
+ poly[1].x = poly[0].x;
+ poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
+ poly[2].x = poly[0].x + ASSOCIATION_FONTHEIGHT*0.5;
+ poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
+ renderer_ops->fill_polygon(renderer, poly, 3, &assoc->line_color);
+ }
break;
case ASSOC_LEFT:
- poly[0].x = assoc->text_pos.x - 0.2;
- if (assoc->text_align == ALIGN_CENTER)
- poly[0].x -= assoc->text_width/2.0;
- poly[0].y = assoc->text_pos.y;
- poly[1].x = poly[0].x;
- poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
- poly[2].x = poly[0].x - ASSOCIATION_FONTHEIGHT*0.5;
- poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
- renderer_ops->fill_polygon(renderer, poly, 3, &assoc->line_color);
+ if (assoc->show_direction) {
+ poly[0].x = assoc->text_pos.x - 0.2;
+ if (assoc->text_align == ALIGN_CENTER)
+ poly[0].x -= assoc->text_width/2.0;
+ poly[0].y = assoc->text_pos.y;
+ poly[1].x = poly[0].x;
+ poly[1].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5;
+ poly[2].x = poly[0].x - ASSOCIATION_FONTHEIGHT*0.5;
+ poly[2].y = poly[0].y - ASSOCIATION_FONTHEIGHT*0.5*0.5;
+ renderer_ops->fill_polygon(renderer, poly, 3, &assoc->line_color);
+ }
break;
}
@@ -410,7 +462,7 @@
AssociationEnd *end = &assoc->end[i];
pos = end->text_pos;
- if (end->role != NULL) {
+ if (end->role != NULL && *end->role) {
gchar *role_name = g_strdup_printf ("%c%s", visible_char[(int) end->visibility], end->role);
renderer_ops->draw_string(renderer,
role_name,
@@ -503,7 +555,7 @@
end->role_descent = 0.0;
end->multi_ascent = 0.0;
end->multi_descent = 0.0;
- if (end->role != NULL) {
+ if (end->role != NULL && *end->role) {
end->text_width =
dia_font_string_width(end->role, assoc_font, ASSOCIATION_FONTHEIGHT);
end->role_ascent =
@@ -584,7 +636,7 @@
end->text_pos.y += end->role_ascent;
if (points[fp].y > points[sp].y) {
- if (end->role!=NULL)
+ if (end->role!=NULL && *end->role)
end->text_pos.y -= ASSOCIATION_FONTHEIGHT;
if (end->multiplicity!=NULL)
end->text_pos.y -= ASSOCIATION_FONTHEIGHT;
@@ -618,6 +670,19 @@
Orientation dir;
orthconn_update_data(orth);
+
+ /* translate new assoc state to old assoc ends */
+ if (assoc->direction == ASSOC_NODIR) {
+ assoc->end[0].aggregate = AGGREGATE_NONE;
+ assoc->end[1].aggregate = AGGREGATE_NONE;
+ } else if (assoc->direction == ASSOC_RIGHT) {
+ /* the diamond is at the start of the line */
+ assoc->end[0].aggregate = assoc->assoc_type;
+ assoc->end[1].aggregate = AGGREGATE_NONE;
+ } else {
+ assoc->end[1].aggregate = assoc->assoc_type;
+ assoc->end[0].aggregate = AGGREGATE_NONE;
+ }
extra->start_trans =
extra->start_long = (assoc->end[0].aggregate == AGGREGATE_NONE?
@@ -708,9 +773,8 @@
int i;
int user_d;
- if (assoc_font == NULL) {
+ if (assoc_font == NULL)
assoc_font = dia_font_new_from_style(DIA_FONT_MONOSPACE, ASSOCIATION_FONTHEIGHT);
- }
assoc = g_malloc0(sizeof(Association));
orth = &assoc->orth;
@@ -725,25 +789,29 @@
assoc->text_color = color_black;
assoc->line_color = attributes_get_foreground();
assoc->name = NULL;
- assoc->direction = ASSOC_NODIR;
+ assoc->assoc_type = AGGREGATE_NORMAL;
+ assoc->direction = ASSOC_RIGHT;
+ assoc->show_direction = FALSE;
for (i=0;i<2;i++) {
assoc->end[i].role = NULL;
assoc->end[i].multiplicity = NULL;
assoc->end[i].arrow = FALSE;
assoc->end[i].aggregate = AGGREGATE_NONE;
assoc->end[i].text_width = 0.0;
+ assoc->end[i].visibility = UML_IMPLEMENTATION;
}
assoc->text_width = 0.0;
- assoc->properties_dialog = NULL;
user_d = GPOINTER_TO_INT(user_data);
switch (user_d) {
case 0:
- /* Ok already. */
+ assoc->assoc_type = AGGREGATE_NONE;
+ assoc->show_direction = TRUE;
break;
case 1:
- assoc->end[1].aggregate = AGGREGATE_NORMAL;
+ assoc->assoc_type = AGGREGATE_NORMAL;
+ assoc->show_direction = FALSE;
break;
}
@@ -813,11 +881,6 @@
g_free(assoc->end[i].role);
g_free(assoc->end[i].multiplicity);
}
-
- if (assoc->properties_dialog != NULL) {
- gtk_widget_destroy(assoc->properties_dialog->dialog);
- g_free(assoc->properties_dialog);
- }
}
static DiaObject *
@@ -838,6 +901,10 @@
newassoc->name = g_strdup(assoc->name);
newassoc->direction = assoc->direction;
+ newassoc->show_direction = assoc->show_direction;
+ newassoc->assoc_type = assoc->assoc_type;
+ newassoc->text_color = assoc->text_color;
+ newassoc->line_color = assoc->line_color;
for (i=0;i<2;i++) {
newassoc->end[i] = assoc->end[i];
newassoc->end[i].role =
@@ -847,7 +914,6 @@
}
newassoc->text_width = assoc->text_width;
- newassoc->properties_dialog = NULL;
association_update_data(newassoc);
@@ -882,7 +948,7 @@
assoc->end[i].arrow);
data_add_enum(composite_add_attribute(composite, "aggregate"),
assoc->end[i].aggregate);
- data_add_enum(composite_add_attribute(composite, "visibility"),
+ data_add_enum(composite_add_attribute(composite, "visibility"),
assoc->end[i].visibility);
}
}
@@ -897,94 +963,86 @@
DiaObject *obj;
int i;
- if (assoc_font == NULL) {
- assoc_font = dia_font_new_from_style(DIA_FONT_MONOSPACE,
- ASSOCIATION_FONTHEIGHT);
- }
-
- assoc = g_new0(Association, 1);
-
+ /* first calls our _create() method */
+ obj = object_load_using_properties(&association_type, obj_node, version, filename);
+ assoc = (Association *)obj;
orth = &assoc->orth;
- obj = &orth->object;
-
- obj->type = &association_type;
- obj->ops = &association_ops;
-
- orthconn_load(orth, obj_node);
-
- assoc->name = NULL;
- attr = object_find_attribute(obj_node, "name");
- if (attr != NULL)
- assoc->name = data_string(attribute_first_data(attr));
-
- assoc->text_width = 0.0;
- if (assoc->name != NULL) {
- assoc->text_width =
- dia_font_string_width(assoc->name, assoc_font, ASSOCIATION_FONTHEIGHT);
- }
-
- assoc->direction = ASSOC_NODIR;
- attr = object_find_attribute(obj_node, "direction");
- if (attr != NULL)
- assoc->direction = data_enum(attribute_first_data(attr));
-
- attr = object_find_attribute(obj_node, "ends");
- composite = attribute_first_data(attr);
- for (i=0;i<2;i++) {
+ /* ... butnot orthconn_load() */
+ if (version < 1)
+ orth->autorouting = FALSE;
+
+ if (version < 2) {
+ attr = object_find_attribute(obj_node, "ends");
+ composite = attribute_first_data(attr);
+ for (i=0;i<2;i++) {
- assoc->end[i].role = NULL;
- attr = composite_find_attribute(composite, "role");
- if (attr != NULL) {
- assoc->end[i].role = data_string(attribute_first_data(attr));
- }
- if ( assoc->end[i].role != NULL
- && 0 == strcmp(assoc->end[i].role, "")) {
- g_free(assoc->end[i].role);
assoc->end[i].role = NULL;
- }
+ attr = composite_find_attribute(composite, "role");
+ if (attr != NULL) {
+ assoc->end[i].role = data_string(attribute_first_data(attr));
+ }
+ if ( assoc->end[i].role != NULL
+ && 0 == strcmp(assoc->end[i].role, "")) {
+ g_free(assoc->end[i].role);
+ assoc->end[i].role = NULL;
+ }
- assoc->end[i].multiplicity = NULL;
- attr = composite_find_attribute(composite, "multiplicity");
- if (attr != NULL) {
- assoc->end[i].multiplicity = data_string(attribute_first_data(attr));
- }
- if ( assoc->end[i].multiplicity != NULL
- && 0 == strcmp(assoc->end[i].multiplicity, "")) {
- g_free(assoc->end[i].multiplicity);
assoc->end[i].multiplicity = NULL;
- }
-
- assoc->end[i].arrow = FALSE;
- attr = composite_find_attribute(composite, "arrow");
- if (attr != NULL)
- assoc->end[i].arrow = data_boolean(attribute_first_data(attr));
-
- assoc->end[i].aggregate = AGGREGATE_NONE;
- attr = composite_find_attribute(composite, "aggregate");
- if (attr != NULL)
- assoc->end[i].aggregate = data_enum(attribute_first_data(attr));
-
- assoc->end[i].visibility = FALSE;
- attr = composite_find_attribute(composite, "visibility");
- if (attr != NULL)
- assoc->end[i].visibility = data_enum( attribute_first_data(attr) );
-
- assoc->end[i].text_width = 0.0;
- if (assoc->end[i].role != NULL) {
- assoc->end[i].text_width =
+ attr = composite_find_attribute(composite, "multiplicity");
+ if (attr != NULL) {
+ assoc->end[i].multiplicity = data_string(attribute_first_data(attr));
+ }
+ if ( assoc->end[i].multiplicity != NULL
+ && 0 == strcmp(assoc->end[i].multiplicity, "")) {
+ g_free(assoc->end[i].multiplicity);
+ assoc->end[i].multiplicity = NULL;
+ }
+
+ assoc->end[i].arrow = FALSE;
+ attr = composite_find_attribute(composite, "arrow");
+ if (attr != NULL)
+ assoc->end[i].arrow = data_boolean(attribute_first_data(attr));
+
+ assoc->end[i].aggregate = AGGREGATE_NONE;
+ attr = composite_find_attribute(composite, "aggregate");
+ if (attr != NULL)
+ assoc->end[i].aggregate = data_enum(attribute_first_data(attr));
+
+ assoc->end[i].visibility = FALSE;
+ attr = composite_find_attribute(composite, "visibility");
+ if (attr != NULL)
+ assoc->end[i].visibility = data_enum( attribute_first_data(attr) );
+
+ assoc->end[i].text_width = 0.0;
+ if (assoc->end[i].role != NULL) {
+ assoc->end[i].text_width =
dia_font_string_width(assoc->end[i].role, assoc_font,
ASSOCIATION_FONTHEIGHT);
- }
- if (assoc->end[i].multiplicity != NULL) {
- assoc->end[i].text_width =
+ }
+ if (assoc->end[i].multiplicity != NULL) {
+ assoc->end[i].text_width =
MAX(assoc->end[i].text_width,
dia_font_string_width(assoc->end[i].multiplicity,
assoc_font, ASSOCIATION_FONTHEIGHT) );
+ }
+ composite = data_next(composite);
}
- composite = data_next(composite);
- }
-
- assoc->properties_dialog = NULL;
+ /* derive new members state from ends */
+ assoc->show_direction = (assoc->direction != ASSOC_NODIR);
+ if (assoc->end[0].aggregate == AGGREGATE_NORMAL) {
+ assoc->assoc_type = AGGREGATE_NORMAL;
+ assoc->direction = ASSOC_RIGHT;
+ } else if (assoc->end[0].aggregate == AGGREGATE_COMPOSITION) {
+ assoc->assoc_type = AGGREGATE_COMPOSITION;
+ assoc->direction = ASSOC_RIGHT;
+ } else if (assoc->end[1].aggregate == AGGREGATE_NORMAL) {
+ assoc->assoc_type = AGGREGATE_NORMAL;
+ assoc->direction = ASSOC_LEFT;
+ } else if (assoc->end[1].aggregate == AGGREGATE_COMPOSITION) {
+ assoc->assoc_type = AGGREGATE_COMPOSITION;
+ assoc->direction = ASSOC_LEFT;
+ }
+ } /* version < 2 */
association_set_state(assoc, association_get_state(assoc));
@@ -994,372 +1052,18 @@
static ObjectChange *
association_apply_properties(Association *assoc)
{
- AssociationPropertiesDialog *prop_dialog;
const char *str;
GtkWidget *menuitem;
int i;
ObjectState *old_state;
-
- prop_dialog = assoc->properties_dialog;
old_state = (ObjectState *)association_get_state(assoc);
/* Read from dialog and put in object: */
- g_free(assoc->name);
- str = gtk_entry_get_text(prop_dialog->name);
- if (str && strlen (str) != 0)
- assoc->name = g_strdup (str);
- else
- assoc->name = NULL;
-
- assoc->text_width = 0.0;
-
- if (assoc->name != NULL) {
- assoc->text_width =
- dia_font_string_width(assoc->name, assoc_font, ASSOCIATION_FONTHEIGHT);
- }
-
- menuitem = gtk_menu_get_active(prop_dialog->dir_menu);
- assoc->direction =
- GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(menuitem)));
-
- for (i=0;i<2;i++) {
- AssociationEnd *end = &assoc->end[i];
-
- end->visibility = (UMLVisibility)
- GPOINTER_TO_INT (gtk_object_get_user_data (
- GTK_OBJECT (gtk_menu_get_active (prop_dialog->end[i].attr_visible))));
-
- /* Role: */
- g_free(end->role);
- str = gtk_entry_get_text(prop_dialog->end[i].role);
- if (str && strlen (str) != 0)
- end->role = g_strdup (str);
- else
- end->role = NULL;
-
- /* Multiplicity: */
- g_free(end->multiplicity);
- str = gtk_entry_get_text(prop_dialog->end[i].multiplicity);
- if (strlen (str) != 0)
- end->multiplicity = g_strdup(str);
- else
- end->multiplicity = NULL;
-
- end->text_width = 0.0;
-
- if (end->role != NULL) {
- end->text_width =
- dia_font_string_width(end->role, assoc_font, ASSOCIATION_FONTHEIGHT);
- }
- if (end->multiplicity != NULL) {
- end->text_width =
- MAX(end->text_width,
- dia_font_string_width(end->multiplicity,
- assoc_font, ASSOCIATION_FONTHEIGHT) );
- }
-
- end->arrow = prop_dialog->end[i].draw_arrow->active;
-
- end->aggregate = AGGREGATE_NONE;
- if (prop_dialog->end[i].aggregate->active)
- end->aggregate = AGGREGATE_NORMAL;
- if (prop_dialog->end[i].composition->active)
- end->aggregate = AGGREGATE_COMPOSITION;
-
- }
+ /* ... */
association_set_state(assoc, association_get_state(assoc));
return new_object_state_change(&assoc->orth.object, old_state,
(GetStateFunc)association_get_state,
(SetStateFunc)association_set_state);
}
-
-static void
-fill_in_dialog(Association *assoc)
-{
- AssociationPropertiesDialog *prop_dialog;
- int i;
-
- prop_dialog = assoc->properties_dialog;
-
- if (assoc->name != NULL)
- gtk_entry_set_text(prop_dialog->name, assoc->name);
- else
- gtk_entry_set_text(prop_dialog->name, "");
-
- gtk_option_menu_set_history(prop_dialog->dir_omenu, assoc->direction);
-
- for (i=0;i<2;i++) {
- if (assoc->end[i].role != NULL)
- gtk_entry_set_text(prop_dialog->end[i].role, assoc->end[i].role);
- else
- gtk_entry_set_text(prop_dialog->end[i].role, "");
-
- if (assoc->end[i].multiplicity != NULL)
- gtk_entry_set_text(prop_dialog->end[i].multiplicity,
- assoc->end[i].multiplicity);
- else
- gtk_entry_set_text(prop_dialog->end[i].multiplicity, "");
-
- gtk_option_menu_set_history(prop_dialog->end[i].attr_visible_button,
- (gint)assoc->end[i].visibility);
- gtk_toggle_button_set_active(prop_dialog->end[i].draw_arrow,
- assoc->end[i].arrow);
- gtk_toggle_button_set_active(prop_dialog->end[i].aggregate,
- assoc->end[i].aggregate == AGGREGATE_NORMAL);
- gtk_toggle_button_set_active(prop_dialog->end[i].composition,
- assoc->end[i].aggregate == AGGREGATE_COMPOSITION);
- }
-}
-
-static void
-mutex_aggregate_callback(GtkWidget *widget,
- AssociationPropertiesDialog *prop_dialog)
-{
- int i;
- GtkToggleButton *button;
-
- button = GTK_TOGGLE_BUTTON(widget);
-
- if (!button->active)
- return;
-
- for (i=0;i<2;i++) {
- if (prop_dialog->end[i].aggregate != button) {
- gtk_toggle_button_set_active(prop_dialog->end[i].aggregate, 0);
- }
- if (prop_dialog->end[i].composition != button) {
- gtk_toggle_button_set_active(prop_dialog->end[i].composition, 0);
- }
- }
-}
-
-static GtkWidget *
-association_get_properties(Association *assoc, gboolean is_default)
-{
- AssociationPropertiesDialog *prop_dialog;
- GtkWidget *dialog;
- GtkWidget *frame;
- GtkWidget *entry;
- GtkWidget *hbox;
- GtkWidget *split_hbox;
- GtkWidget *vbox;
- GtkWidget *label;
- GtkWidget *omenu;
- GtkWidget *menu;
- GtkWidget *submenu;
- GtkWidget *menuitem;
- GtkWidget *checkbox;
- GSList *group;
- int i;
-
- if (assoc->properties_dialog == NULL) {
-
- prop_dialog = g_new(AssociationPropertiesDialog, 1);
- assoc->properties_dialog = prop_dialog;
-
- dialog = gtk_vbox_new(FALSE, 0);
- gtk_object_ref(GTK_OBJECT(dialog));
- gtk_object_sink(GTK_OBJECT(dialog));
- prop_dialog->dialog = dialog;
-
- /* Name entry: */
- hbox = gtk_hbox_new(FALSE, 5);
- label = gtk_label_new(_("Name:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
- entry = gtk_entry_new();
- prop_dialog->name = GTK_ENTRY(entry);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_widget_grab_focus(entry);
- gtk_widget_show (label);
- gtk_widget_show (entry);
- gtk_box_pack_start (GTK_BOX (dialog), hbox, TRUE, TRUE, 0);
- gtk_widget_show(hbox);
-
- /* Direction entry: */
- hbox = gtk_hbox_new(FALSE, 5);
- label = gtk_label_new(_("Direction:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
-
- omenu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
- prop_dialog->dir_menu = GTK_MENU(menu);
- prop_dialog->dir_omenu = GTK_OPTION_MENU(omenu);
- submenu = NULL;
- group = NULL;
-
- menuitem = gtk_radio_menu_item_new_with_label (group, _("None"));
- gtk_object_set_user_data(GTK_OBJECT(menuitem),
- GINT_TO_POINTER(ASSOC_NODIR));
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_widget_show (menuitem);
-
- menuitem = gtk_radio_menu_item_new_with_label (group, _("From A to B"));
- gtk_object_set_user_data(GTK_OBJECT(menuitem),
- GINT_TO_POINTER(ASSOC_RIGHT));
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_widget_show (menuitem);
-
- menuitem = gtk_radio_menu_item_new_with_label (group, _("From B to A"));
- gtk_object_set_user_data(GTK_OBJECT(menuitem),
- GINT_TO_POINTER(ASSOC_LEFT));
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_widget_show (menuitem);
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
- gtk_box_pack_start (GTK_BOX (hbox), omenu, FALSE, TRUE, 0);
-
- gtk_widget_show (label);
- gtk_widget_show (omenu);
- gtk_box_pack_start (GTK_BOX (dialog), hbox, TRUE, TRUE, 0);
- gtk_widget_show(hbox);
-
- split_hbox = gtk_hbox_new(TRUE, 5);
- gtk_box_pack_start (GTK_BOX (dialog), split_hbox, TRUE, TRUE, 0);
- gtk_widget_show(split_hbox);
-
- group = NULL; /* For the radio-buttons */
-
- for (i=0;i<2;i++) {
- char *str;
- if (i==0)
- str = _("Side A");
- else
- str = _("Side B");
- frame = gtk_frame_new(str);
-
- vbox = gtk_vbox_new(FALSE, 5);
- /* End 'i' into vbox: */
- if (i==0)
- label = gtk_label_new(_("Side A"));
- else
- label = gtk_label_new(_("Side B"));
-
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
-
- /* Role entry: */
- hbox = gtk_hbox_new(FALSE, 5);
- label = gtk_label_new(_("Role:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
- entry = gtk_entry_new();
- prop_dialog->end[i].role = GTK_ENTRY(entry);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_widget_show (label);
- gtk_widget_show (entry);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show(hbox);
-
- /* Multiplicity entry: */
- hbox = gtk_hbox_new(FALSE, 5);
- label = gtk_label_new(_("Multiplicity:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
- entry = gtk_entry_new();
- prop_dialog->end[i].multiplicity = GTK_ENTRY(entry);
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_widget_show (label);
- gtk_widget_show (entry);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show(hbox);
-
- hbox = gtk_hbox_new(FALSE, 5);
- label = gtk_label_new(_("Visibility:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
-
- omenu = gtk_option_menu_new ();
- menu = gtk_menu_new ();
- prop_dialog->end[i].attr_visible = GTK_MENU(menu);
- prop_dialog->end[i].attr_visible_button = GTK_OPTION_MENU(omenu);
- submenu = NULL;
- group = NULL;
- menuitem = gtk_radio_menu_item_new_with_label (group, _("Public"));
-/*
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (attributes_update), umlclass);
-*/
- gtk_object_set_user_data(GTK_OBJECT(menuitem),
- GINT_TO_POINTER(UML_PUBLIC) );
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_widget_show (menuitem);
- menuitem = gtk_radio_menu_item_new_with_label (group, _("Private"));
-/*
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (attributes_update), umlclass);
-*/
- gtk_object_set_user_data(GTK_OBJECT(menuitem),
- GINT_TO_POINTER(UML_PRIVATE) );
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_widget_show (menuitem);
- menuitem = gtk_radio_menu_item_new_with_label (group, _("Protected"));
-/*
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (attributes_update), umlclass);
-*/
- gtk_object_set_user_data(GTK_OBJECT(menuitem),
- GINT_TO_POINTER(UML_PROTECTED) );
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_widget_show (menuitem);
- menuitem = gtk_radio_menu_item_new_with_label (group, _("Implementation"));
-/*
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (attributes_update), umlclass);
-*/
- gtk_object_set_user_data(GTK_OBJECT(menuitem),
- GINT_TO_POINTER(UML_IMPLEMENTATION) );
- group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_widget_show (menuitem);
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
- gtk_box_pack_start (GTK_BOX (hbox), omenu, FALSE, TRUE, 0);
- gtk_widget_show(label);
- gtk_widget_show(omenu);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show(hbox);
-
- /* Show arrow: */
- checkbox = gtk_check_button_new_with_label(_("Show arrow"));
- prop_dialog->end[i].draw_arrow = GTK_TOGGLE_BUTTON( checkbox );
- gtk_widget_show(checkbox);
- gtk_box_pack_start (GTK_BOX (vbox), checkbox, TRUE, TRUE, 0);
-
- /* Aggregate */
- checkbox = gtk_check_button_new_with_label(_("Aggregate"));
- prop_dialog->end[i].aggregate = GTK_TOGGLE_BUTTON( checkbox );
- gtk_signal_connect(GTK_OBJECT(checkbox), "toggled",
- (GtkSignalFunc) mutex_aggregate_callback, prop_dialog);
- gtk_widget_show(checkbox);
- gtk_box_pack_start (GTK_BOX (vbox), checkbox, TRUE, TRUE, 0);
-
- /* Composition */
- checkbox = gtk_check_button_new_with_label(_("Composition"));
- prop_dialog->end[i].composition = GTK_TOGGLE_BUTTON( checkbox );
- gtk_signal_connect(GTK_OBJECT(checkbox), "toggled",
- (GtkSignalFunc) mutex_aggregate_callback, prop_dialog);
- gtk_widget_show(checkbox);
- gtk_box_pack_start (GTK_BOX (vbox), checkbox, TRUE, TRUE, 0);
-
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_box_pack_start (GTK_BOX (split_hbox), frame, TRUE, TRUE, 0);
- gtk_widget_show(vbox);
- gtk_widget_show(frame);
- }
-
- }
- fill_in_dialog(assoc);
- gtk_widget_show (assoc->properties_dialog->dialog);
-
- return assoc->properties_dialog->dialog;
-}
-
-
-
-
-
Modified: trunk/objects/UML/classicon.c
==============================================================================
--- trunk/objects/UML/classicon.c (original)
+++ trunk/objects/UML/classicon.c Sat Apr 26 15:24:41 2008
@@ -136,8 +136,10 @@
ELEMENT_COMMON_PROPERTIES,
PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_STD_FILL_COLOUR_OPTIONAL,
- { "stereotype", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE,
- N_("Stereotype"), NULL, prop_classicon_type_data},
+ /* backward compatibility */
+ { "stereotype", PROP_TYPE_ENUM, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Stereotype"), NULL, prop_classicon_type_data},
+ /* one name, one type */
+ { "type", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL, N_("Stereotype"), NULL, prop_classicon_type_data},
{ "is_object", PROP_TYPE_BOOL, PROP_FLAG_VISIBLE,
N_("Is object"), NULL, NULL },
PROP_STD_TEXT_FONT,
@@ -161,7 +163,10 @@
ELEMENT_COMMON_PROPERTIES_OFFSETS,
{ "line_colour",PROP_TYPE_COLOUR,offsetof(Classicon,line_color) },
{ "fill_colour",PROP_TYPE_COLOUR,offsetof(Classicon,fill_color) },
+ /* backward compatibility */
{ "stereotype", PROP_TYPE_ENUM, offsetof(Classicon, stereotype) },
+ /* one name, one type! */
+ { "type", PROP_TYPE_ENUM, offsetof(Classicon, stereotype) },
{ "is_object", PROP_TYPE_BOOL, offsetof(Classicon, is_object) },
{ "text",PROP_TYPE_TEXT,offsetof(Classicon,text)},
{ "text_font",PROP_TYPE_FONT,offsetof(Classicon,attrs.font)},
Modified: trunk/objects/UML/implements.c
==============================================================================
--- trunk/objects/UML/implements.c (original)
+++ trunk/objects/UML/implements.c Sat Apr 26 15:24:41 2008
@@ -127,8 +127,10 @@
PROP_STD_LINE_COLOUR_OPTIONAL,
/* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
- { "text", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
- N_("Interface:"), NULL, NULL },
+ /* backward compatibility */
+ { "text", PROP_TYPE_STRING, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Interface:"), NULL, NULL },
+ /* new name matching "same name, same type" rule */
+ { "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL, N_("Interface:"), NULL, NULL },
{ "text_pos", PROP_TYPE_POINT, 0, NULL, NULL, NULL },
{ "diameter", PROP_TYPE_REAL, 0, NULL, NULL, NULL },
PROP_DESC_END
Modified: trunk/objects/UML/message.c
==============================================================================
--- trunk/objects/UML/message.c (original)
+++ trunk/objects/UML/message.c Sat Apr 26 15:24:41 2008
@@ -149,8 +149,10 @@
/* can't use PROP_STD_TEXT_COLOUR_OPTIONAL cause it has PROP_FLAG_DONT_SAVE. It is designed to fill the Text object - not some subset */
PROP_STD_TEXT_COLOUR_OPTIONS(PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL),
PROP_STD_LINE_COLOUR_OPTIONAL,
- { "text", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
- N_("Message:"), NULL, NULL },
+ /* backward compatibility */
+ { "text", PROP_TYPE_STRING, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Message:"), NULL, NULL },
+ /* new name matching "same name, same type" rule */
+ { "message", PROP_TYPE_STRING, PROP_FLAG_VISIBLE|PROP_FLAG_OPTIONAL, N_("Message:"), NULL, NULL },
{ "type", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE,
N_("Message type:"), NULL, prop_message_type_data },
{ "text_pos", PROP_TYPE_POINT, 0,
@@ -171,7 +173,10 @@
CONNECTION_COMMON_PROPERTIES_OFFSETS,
{ "line_colour",PROP_TYPE_COLOUR,offsetof(Message,line_color) },
{ "text_colour",PROP_TYPE_COLOUR,offsetof(Message,text_color) },
+ /* backward compatibility */
{ "text", PROP_TYPE_STRING, offsetof(Message, text) },
+ /* new name matching "same name, same type" rule */
+ { "message", PROP_TYPE_STRING, offsetof(Message, text) },
{ "type", PROP_TYPE_ENUM, offsetof(Message, type) },
{ "text_pos", PROP_TYPE_POINT, offsetof(Message,text_pos) },
{ NULL, 0, 0 }
Modified: trunk/objects/UML/node.c
==============================================================================
--- trunk/objects/UML/node.c (original)
+++ trunk/objects/UML/node.c Sat Apr 26 15:24:41 2008
@@ -126,8 +126,10 @@
PROP_STD_TEXT_FONT,
PROP_STD_TEXT_HEIGHT,
PROP_STD_TEXT_COLOUR_OPTIONAL,
- { "name", PROP_TYPE_TEXT, 0, N_("Text"), NULL, NULL },
-
+ /* backward compatibility */
+ { "name", PROP_TYPE_TEXT, PROP_FLAG_NO_DEFAULTS|PROP_FLAG_LOAD_ONLY|PROP_FLAG_OPTIONAL, N_("Text"), NULL, NULL },
+ /* new name matching "same name, same type" rule */
+ { "text", PROP_TYPE_TEXT, PROP_FLAG_OPTIONAL, N_("Text"), NULL, NULL },
PROP_DESC_END
};
@@ -145,7 +147,10 @@
ELEMENT_COMMON_PROPERTIES_OFFSETS,
{"line_colour",PROP_TYPE_COLOUR,offsetof(Node,line_color)},
{"fill_colour",PROP_TYPE_COLOUR,offsetof(Node,fill_color)},
+ /* backward compatibility */
{"name",PROP_TYPE_TEXT,offsetof(Node,name)},
+ /* new name matching "same name, same type" rule */
+ {"text",PROP_TYPE_TEXT,offsetof(Node,name)},
{"text_font",PROP_TYPE_FONT,offsetof(Node,attrs.font)},
{PROP_STDNAME_TEXT_HEIGHT,PROP_STDTYPE_TEXT_HEIGHT,offsetof(Node,attrs.height)},
{"text_colour",PROP_TYPE_COLOUR,offsetof(Node,attrs.color)},
Modified: trunk/objects/standard/box.c
==============================================================================
--- trunk/objects/standard/box.c (original)
+++ trunk/objects/standard/box.c Sat Apr 26 15:24:41 2008
@@ -148,7 +148,7 @@
PROP_STD_FILL_COLOUR,
PROP_STD_SHOW_BACKGROUND,
PROP_STD_LINE_STYLE,
- { "corner_radius", PROP_TYPE_LENGTH, PROP_FLAG_VISIBLE,
+ { "corner_radius", PROP_TYPE_REAL, PROP_FLAG_VISIBLE,
N_("Corner radius"), NULL, &corner_radius_data },
{ "aspect", PROP_TYPE_ENUM, PROP_FLAG_VISIBLE,
N_("Aspect ratio"), NULL, prop_aspect_data },
@@ -172,7 +172,7 @@
{ "aspect", PROP_TYPE_ENUM, offsetof(Box, aspect) },
{ "line_style", PROP_TYPE_LINESTYLE,
offsetof(Box, line_style), offsetof(Box, dashlength) },
- { "corner_radius", PROP_TYPE_LENGTH, offsetof(Box, corner_radius) },
+ { "corner_radius", PROP_TYPE_REAL, offsetof(Box, corner_radius) },
{ NULL, 0, 0 }
};
Modified: trunk/plug-ins/python/Makefile.am
==============================================================================
--- trunk/plug-ins/python/Makefile.am (original)
+++ trunk/plug-ins/python/Makefile.am Sat Apr 26 15:24:41 2008
@@ -61,9 +61,9 @@
pyplugindir = $(pkgdatadir)/python
pyplugin_DATA = \
aobjects.py \
+ allprops.py \
codegen.py \
diasvg.py \
- diasvg_import.py \
dot.py \
doxrev.py \
group_props.py \
Added: trunk/plug-ins/python/allprops.py
==============================================================================
--- (empty file)
+++ trunk/plug-ins/python/allprops.py Sat Apr 26 15:24:41 2008
@@ -0,0 +1,131 @@
+# PyDia Self Documentation Series - Part IV : All Objects Properties
+# Copyright (c) 2008, Hans Breuer <hans breuer org>
+#
+# generates a new diagram which contains all the currently
+# known std-props, that is iterates all objects for their properties
+#
+
+# 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, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import sys, dia, string
+
+def allprops_cb(data, flags) :
+
+ # copied from otypes.py
+ if data :
+ diagram = None # we may be running w/o GUI
+ else :
+ diagram = dia.new("All Object Properties.dia")
+ data = diagram.data
+ layer = data.active_layer
+
+ props_by_name = {}
+ otypes = dia.registered_types()
+ name_type_clashes = []
+
+ for oname in otypes :
+ try :
+ obj, h1, h2 = dia.get_object_type(oname).create (0, 0)
+ except :
+ print "Huh?", oname
+ continue
+ prop_keys = obj.properties.keys()
+ for k in prop_keys :
+ p = obj.properties[k]
+ if props_by_name.has_key(k) :
+ # check if it is the same type
+ p0, names = props_by_name[k]
+ try :
+ if p0.type != p.type :
+ # construct a unique name
+ uname = p.name + "<" + p.type + ">"
+ if props_by_name.has_key(uname) :
+ props_by_name[uname][1].append(oname)
+ else :
+ props_by_name[uname] = (p, [oname])
+ name_type_clashes.append (oname + " as " + p0.type + " and " + p.type)
+ else :
+ # remember the origin of the propety
+ props_by_name[k][1].append(oname)
+ except KeyError :
+ print oname, "::", k, p, "?"
+ else :
+ props_by_name[k] = (p, [oname])
+ obj.destroy() # unsave delete, any method call will fail/crash afterweards
+ obj = None
+
+ grid = {} # one type per row
+ dx = 1.0
+ dy = 5.0
+ ot = dia.get_object_type("UML - Class")
+
+ props_keys = props_by_name.keys()
+ # alpha-numeric sorting by type; than by number of users
+ props_keys.sort (lambda a,b : cmp(props_by_name[b][0].type, props_by_name[a][0].type))
+ props_keys.sort (lambda a,b : len(props_by_name[b][1]) - len(props_by_name[a][1]))
+
+ almost_all = 98 * len(otypes) / 100 # 98 %
+
+ for pname in props_keys :
+
+ p, names = props_by_name[pname]
+
+ x = 0.0
+ y = 0.0
+ if grid.has_key(p.type) :
+ x, y = grid[p.type]
+ else :
+ x = 0.0
+ y = len(grid.keys()) * dy
+ o, h1, h2 = ot.create (x,y)
+ o.properties["name"] = pname
+ o.properties["template"] = 1
+ o.properties["templates"] = [(p.type, '')]
+ # coloring depending on use
+ if len(names) > almost_all :
+ o.properties["fill_colour"] = "lightgreen"
+ elif len(names) > 100 :
+ o.properties["fill_colour"] = "lightblue"
+ elif len(names) > 2 :
+ o.properties["fill_colour"] = "lightcyan"
+ elif len(names) > 1 :
+ o.properties["fill_colour"] = "lightyellow"
+ # if there is only one user show it
+ if len(names) == 1 :
+ o.properties["comment"] = names[0]
+ o.properties["visible_comments"] = 1
+ o.properties["comment_line_length"] = 60
+ else :
+ o.properties["comment"] = string.join(names, "; ")
+ o.properties["visible_comments"] = 0
+ o.properties["comment_line_length"] = 60
+
+ # store position for next in row
+ x += (dx + o.properties["elem_width"].value)
+ grid[p.type] = (x,y)
+
+ layer.add_object(o)
+ layer.update_extents()
+ data.update_extents()
+ if diagram :
+ diagram.display()
+ diagram.flush()
+ if len(name_type_clashes) > 0 :
+ dia.message(0, "One name, one type?!\n" + string.join(name_type_clashes, "\n"))
+ return data
+
+dia.register_action ("HelpAllPropts", "All Object Properties",
+ "/ToolboxMenu/Help/HelpExtensionStart",
+ allprops_cb)
Modified: trunk/plug-ins/python/pydia-properties.c
==============================================================================
--- trunk/plug-ins/python/pydia-properties.c (original)
+++ trunk/plug-ins/python/pydia-properties.c Sat Apr 26 15:24:41 2008
@@ -156,8 +156,8 @@
if (desc) {
int i;
for (i = 0; desc[i].name; i++) {
- /* at the moment I see no use case to access these from Python */
- if ((desc[i].flags & PROP_FLAG_WIDGET_ONLY) == 0)
+ /* at the moment I see no use case to access widgets from Python, PROP_FLAG_LOAD_ONLY compatibility not anted here */
+ if ((desc[i].flags & (PROP_FLAG_WIDGET_ONLY|PROP_FLAG_LOAD_ONLY)) == 0)
PyList_Append(list, PyString_FromString(desc[i].name));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]