diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index ccaf8164949532ca82b2df536344df214928c384..4fc5a0f85a474e996a34a3ea38dec4218b1d57b3 100644 (file)
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Peter Moulder <pmoulder@mail.csse.monash.edu.au>
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Peter Moulder <pmoulder@mail.csse.monash.edu.au>
+ * Johan Engelen
*
* Copyright (C) 2000-2002 authors
* Copyright (C) 2004 Monash University
*
* Copyright (C) 2000-2002 authors
* Copyright (C) 2004 Monash University
+ * Copyright (C) 2007 Johan Engelen
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
guide->hicolor = 0xff00007f;
}
guide->hicolor = 0xff00007f;
}
-static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/)
{
SPGuide &guide = *SP_GUIDE(object);
switch (prop_id) {
{
SPGuide &guide = *SP_GUIDE(object);
switch (prop_id) {
- case PROP_COLOR:
+ case PROP_COLOR:
guide.color = g_value_get_uint(value);
for (GSList *l = guide.views; l != NULL; l = l->next) {
sp_guideline_set_color(SP_GUIDELINE(l->data), guide.color);
}
break;
guide.color = g_value_get_uint(value);
for (GSList *l = guide.views; l != NULL; l = l->next) {
sp_guideline_set_color(SP_GUIDELINE(l->data), guide.color);
}
break;
- case PROP_HICOLOR:
+ case PROP_HICOLOR:
guide.hicolor = g_value_get_uint(value);
break;
}
}
guide.hicolor = g_value_get_uint(value);
break;
}
}
-static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec */*pspec*/)
{
SPGuide const &guide = *SP_GUIDE(object);
switch (prop_id) {
{
SPGuide const &guide = *SP_GUIDE(object);
switch (prop_id) {
- case PROP_COLOR:
+ case PROP_COLOR:
g_value_set_uint(value, guide.color);
break;
g_value_set_uint(value, guide.color);
break;
- case PROP_HICOLOR:
+ case PROP_HICOLOR:
g_value_set_uint(value, guide.hicolor);
break;
}
g_value_set_uint(value, guide.hicolor);
break;
}
@@ -172,7 +174,24 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
if (value && !strcmp(value, "horizontal")) {
/* Visual representation of a horizontal line, constrain vertically (y coordinate). */
guide->normal = component_vectors[NR::Y];
if (value && !strcmp(value, "horizontal")) {
/* Visual representation of a horizontal line, constrain vertically (y coordinate). */
guide->normal = component_vectors[NR::Y];
+ } else if (value && !strcmp(value, "vertical")) {
+ guide->normal = component_vectors[NR::X];
+ } else if (value) {
+ gchar ** strarray = g_strsplit(value, ",", 2);
+ double newx, newy;
+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
+ success += sp_svg_number_read_d(strarray[1], &newy);
+ g_strfreev (strarray);
+ if (success == 2) {
+ Geom::Point direction(newx, newy);
+ direction.normalize();
+ guide->normal = direction;
+ } else {
+ // default to vertical line for bad arguments
+ guide->normal = component_vectors[NR::X];
+ }
} else {
} else {
+ // default to vertical line for bad arguments
guide->normal = component_vectors[NR::X];
}
break;
guide->normal = component_vectors[NR::X];
}
break;
bool const vertical_line_p = ( guide->normal == component_vectors[NR::X] );
g_assert(( guide->normal == component_vectors[NR::X] ) ||
( guide->normal == component_vectors[NR::Y] ) );
bool const vertical_line_p = ( guide->normal == component_vectors[NR::X] );
g_assert(( guide->normal == component_vectors[NR::X] ) ||
( guide->normal == component_vectors[NR::Y] ) );
- SPCanvasItem *item = sp_guideline_new(group, guide->position, vertical_line_p);
+ SPCanvasItem *item = sp_guideline_new(group, guide->position, vertical_line_p ? Geom::Point(1.,0.) : Geom::Point(0.,1.));
sp_guideline_set_color(SP_GUIDELINE(item), guide->color);
g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), guide);
sp_guideline_set_color(SP_GUIDELINE(item), guide->color);
g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), guide);