Skip to content

Instantly share code, notes, and snippets.

@ursetto
Created April 23, 2012 04:31
Show Gist options
  • Save ursetto/2468876 to your computer and use it in GitHub Desktop.
Save ursetto/2468876 to your computer and use it in GitHub Desktop.
Allow dia database shapes to change start arrow type
diff --git a/objects/Database/reference.c b/objects/Database/reference.c
index 616d106..562c1dd 100644
--- a/objects/Database/reference.c
+++ b/objects/Database/reference.c
@@ -107,7 +107,8 @@ static PropDescription reference_props[] =
PROP_STD_LINE_STYLE_OPTIONAL,
{ "corner_radius", PROP_TYPE_REAL, PROP_FLAG_VISIBLE,
N_("Corner radius"), NULL, &reference_corner_radius_data },
- PROP_STD_START_ARROW,
+ { "start_arrow", PROP_TYPE_ARROW, PROP_FLAG_VISIBLE|PROP_FLAG_STANDARD|PROP_FLAG_OPTIONAL, \
+ N_("Start arrow"), NULL, NULL }
PROP_STD_END_ARROW,
{ "start_point_desc", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
N_("Start description"), NULL, NULL },
From a0f297b004109da16d72260288aacb0762fdaf7c Mon Sep 17 00:00:00 2001
From: Jim Ursetto <[email protected]>
Date: Sun, 22 Apr 2012 23:58:18 -0500
Subject: [PATCH] Add start_arrow attribute to database table reference object
---
objects/Database/database.h | 1 +
objects/Database/reference.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/objects/Database/database.h b/objects/Database/database.h
index f7fda38..42e4f33 100644
--- a/objects/Database/database.h
+++ b/objects/Database/database.h
@@ -146,6 +146,7 @@ struct _TableReference {
gchar * start_point_desc;
gchar * end_point_desc;
+ Arrow start_arrow;
Arrow end_arrow;
real corner_radius;
diff --git a/objects/Database/reference.c b/objects/Database/reference.c
index 891a6e2..616d106 100644
--- a/objects/Database/reference.c
+++ b/objects/Database/reference.c
@@ -107,6 +107,7 @@ static PropDescription reference_props[] =
PROP_STD_LINE_STYLE_OPTIONAL,
{ "corner_radius", PROP_TYPE_REAL, PROP_FLAG_VISIBLE,
N_("Corner radius"), NULL, &reference_corner_radius_data },
+ PROP_STD_START_ARROW,
PROP_STD_END_ARROW,
{ "start_point_desc", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
N_("Start description"), NULL, NULL },
@@ -131,6 +132,7 @@ static PropOffset reference_offsets[] =
{ PROP_STDNAME_LINE_WIDTH, PROP_STDTYPE_LINE_WIDTH, offsetof(TableReference, line_width) },
{ "line_style", PROP_TYPE_LINESTYLE, offsetof(TableReference, line_style),
offsetof(TableReference, dashlength) },
+ { "start_arrow", PROP_TYPE_ARROW, offsetof(TableReference, start_arrow) },
{ "end_arrow", PROP_TYPE_ARROW, offsetof(TableReference, end_arrow) },
{ "corner_radius", PROP_TYPE_REAL, offsetof(TableReference, corner_radius) },
{ "normal_font", PROP_TYPE_FONT, offsetof(TableReference, normal_font) },
@@ -183,6 +185,7 @@ reference_create (Point *startpoint,
attributes_get_default_line_style (&ref->line_style, &ref->dashlength);
ref->text_color = color_black;
ref->line_color = attributes_get_foreground ();
+ ref->start_arrow = attributes_get_default_start_arrow ();
ref->end_arrow = attributes_get_default_end_arrow ();
ref->corner_radius = 0.0;
ref->start_point_desc = g_strdup ("1");
@@ -232,7 +235,7 @@ reference_draw (TableReference *ref, DiaRenderer *renderer)
renderer_ops->draw_rounded_polyline_with_arrows
(renderer, points, num_points, ref->line_width,
- &ref->line_color, NULL, &ref->end_arrow, ref->corner_radius);
+ &ref->line_color, &ref->start_arrow, &ref->end_arrow, ref->corner_radius);
renderer_ops->set_font (renderer, ref->normal_font, ref->normal_font_height);
--
1.7.6.1
@ursetto
Copy link
Author

ursetto commented Apr 28, 2012

Second ("optional") patch makes start arrow attribute optional so warnings don't occur on load.

But either way, if missing, the start arrow is taken from the toolbox at load time. Alternatively if we force the start arrow to NULL in the creation function, you can never set a default in the toolbox.

Unfortunately there doesn't seem to be any way to set a separate "default if missing" value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment