From baed5ee4bd2dd04e49df650b07278a8ceb900cab Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Mon, 14 Feb 2011 10:14:28 +0100 Subject: Allow rotation of symbols. Bind this action to the right mouse button. Due to limitations of json-glib, we can't store rotation as an enum. --- liblogdiag/ld-diagram-symbol.c | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'liblogdiag/ld-diagram-symbol.c') diff --git a/liblogdiag/ld-diagram-symbol.c b/liblogdiag/ld-diagram-symbol.c index 8307ef4..01c0172 100644 --- a/liblogdiag/ld-diagram-symbol.c +++ b/liblogdiag/ld-diagram-symbol.c @@ -23,7 +23,8 @@ enum { PROP_0, - PROP_CLASS + PROP_CLASS, + PROP_ROTATION }; static void ld_diagram_symbol_get_property (GObject *object, guint property_id, @@ -53,6 +54,16 @@ ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass) "The class of this symbol.", "", G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_CLASS, pspec); + +/** + * LdDiagramSymbol:rotation: + * + * Rotation of this symbol. + */ + pspec = g_param_spec_int ("rotation", "Rotation", + "Rotation of this symbol.", + 0, 3, 0, G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_ROTATION, pspec); } static void @@ -70,6 +81,7 @@ ld_diagram_symbol_get_property (GObject *object, guint property_id, switch (property_id) { case PROP_CLASS: + case PROP_ROTATION: ld_diagram_object_get_data_for_param (self, value, pspec); break; default: @@ -87,6 +99,7 @@ ld_diagram_symbol_set_property (GObject *object, guint property_id, switch (property_id) { case PROP_CLASS: + case PROP_ROTATION: ld_diagram_object_set_data_for_param (self, value, pspec); break; default: @@ -139,3 +152,33 @@ ld_diagram_symbol_set_class (LdDiagramSymbol *self, const gchar *klass) g_return_if_fail (LD_IS_DIAGRAM_SYMBOL (self)); g_object_set (self, "class", klass, NULL); } + +/** + * ld_diagram_symbol_get_rotation: + * @self: an #LdDiagramSymbol object. + * + * Return value: rotation of the symbol. + */ +gint +ld_diagram_symbol_get_rotation (LdDiagramSymbol *self) +{ + gint rotation; + + g_return_val_if_fail (LD_IS_DIAGRAM_SYMBOL (self), 0); + g_object_get (self, "rotation", &rotation, NULL); + return rotation; +} + +/** + * ld_diagram_symbol_set_rotation: + * @self: an #LdDiagramSymbol object. + * @rotation: the rotation. + * + * Set rotation of the symbol. + */ +void +ld_diagram_symbol_set_rotation (LdDiagramSymbol *self, gint rotation) +{ + g_return_if_fail (LD_IS_DIAGRAM_SYMBOL (self)); + g_object_set (self, "rotation", rotation, NULL); +} -- cgit v1.2.3-54-g00ecf