2010-12-16 11:34:02 +01:00
|
|
|
/*
|
|
|
|
* ld-diagram-symbol.c
|
|
|
|
*
|
|
|
|
* This file is a part of logdiag.
|
2011-01-09 07:30:01 +01:00
|
|
|
* Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
|
2010-12-16 11:34:02 +01:00
|
|
|
*
|
|
|
|
* See the file LICENSE for licensing information.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-10 11:20:14 +01:00
|
|
|
#include "liblogdiag.h"
|
2010-12-16 11:34:02 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:ld-diagram-symbol
|
2011-01-28 17:39:40 +01:00
|
|
|
* @short_description: A symbol object
|
2010-12-16 11:34:02 +01:00
|
|
|
* @see_also: #LdDiagramObject
|
|
|
|
*
|
|
|
|
* #LdDiagramSymbol is an implementation of #LdDiagramObject.
|
|
|
|
*/
|
|
|
|
|
2011-01-09 07:30:01 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2011-02-14 10:14:28 +01:00
|
|
|
PROP_CLASS,
|
|
|
|
PROP_ROTATION
|
2011-01-09 07:30:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static void ld_diagram_symbol_get_property (GObject *object, guint property_id,
|
|
|
|
GValue *value, GParamSpec *pspec);
|
|
|
|
static void ld_diagram_symbol_set_property (GObject *object, guint property_id,
|
|
|
|
const GValue *value, GParamSpec *pspec);
|
2010-12-16 11:34:02 +01:00
|
|
|
|
|
|
|
|
2011-01-04 14:52:57 +01:00
|
|
|
G_DEFINE_TYPE (LdDiagramSymbol, ld_diagram_symbol, LD_TYPE_DIAGRAM_OBJECT);
|
|
|
|
|
2010-12-16 11:34:02 +01:00
|
|
|
static void
|
|
|
|
ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
2011-01-09 07:30:01 +01:00
|
|
|
GParamSpec *pspec;
|
2010-12-16 11:34:02 +01:00
|
|
|
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
2011-01-09 07:30:01 +01:00
|
|
|
object_class->get_property = ld_diagram_symbol_get_property;
|
|
|
|
object_class->set_property = ld_diagram_symbol_set_property;
|
2010-12-16 11:34:02 +01:00
|
|
|
|
2011-01-09 07:30:01 +01:00
|
|
|
/**
|
|
|
|
* LdDiagramSymbol:class:
|
|
|
|
*
|
|
|
|
* The class of this symbol.
|
|
|
|
*/
|
|
|
|
pspec = g_param_spec_string ("class", "Class",
|
|
|
|
"The class of this symbol.",
|
|
|
|
"", G_PARAM_READWRITE);
|
|
|
|
g_object_class_install_property (object_class, PROP_CLASS, pspec);
|
2011-02-14 10:14:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
2010-12-16 11:34:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ld_diagram_symbol_init (LdDiagramSymbol *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-09 07:30:01 +01:00
|
|
|
static void
|
|
|
|
ld_diagram_symbol_get_property (GObject *object, guint property_id,
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
2011-01-15 15:31:01 +01:00
|
|
|
LdDiagramObject *self;
|
2011-01-09 07:30:01 +01:00
|
|
|
|
2011-01-15 15:31:01 +01:00
|
|
|
self = LD_DIAGRAM_OBJECT (object);
|
2011-01-09 07:30:01 +01:00
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CLASS:
|
2011-02-14 10:14:28 +01:00
|
|
|
case PROP_ROTATION:
|
2011-01-31 22:04:37 +01:00
|
|
|
ld_diagram_object_get_data_for_param (self, value, pspec);
|
2011-01-09 07:30:01 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ld_diagram_symbol_set_property (GObject *object, guint property_id,
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
2011-01-15 15:31:01 +01:00
|
|
|
LdDiagramObject *self;
|
2011-01-09 07:30:01 +01:00
|
|
|
|
2011-01-15 15:31:01 +01:00
|
|
|
self = LD_DIAGRAM_OBJECT (object);
|
2011-01-09 07:30:01 +01:00
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CLASS:
|
2011-02-14 10:14:28 +01:00
|
|
|
case PROP_ROTATION:
|
2011-01-26 13:00:13 +01:00
|
|
|
ld_diagram_object_set_data_for_param (self, value, pspec);
|
2011-01-09 07:30:01 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-16 11:34:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ld_diagram_symbol_new:
|
2011-01-28 17:39:40 +01:00
|
|
|
* @storage: a storage backend.
|
2010-12-16 11:34:02 +01:00
|
|
|
*
|
2011-01-28 17:39:40 +01:00
|
|
|
* Return value: a new #LdDiagramSymbol object.
|
2010-12-16 11:34:02 +01:00
|
|
|
*/
|
|
|
|
LdDiagramSymbol *
|
2011-01-15 15:31:01 +01:00
|
|
|
ld_diagram_symbol_new (JsonObject *storage)
|
2010-12-16 11:34:02 +01:00
|
|
|
{
|
|
|
|
LdDiagramSymbol *self;
|
|
|
|
|
2011-01-15 15:31:01 +01:00
|
|
|
self = g_object_new (LD_TYPE_DIAGRAM_SYMBOL, "storage", storage, NULL);
|
2010-12-16 11:34:02 +01:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-01-09 07:30:01 +01:00
|
|
|
/**
|
|
|
|
* ld_diagram_symbol_get_class:
|
2011-01-28 17:39:40 +01:00
|
|
|
* @self: an #LdDiagramSymbol object.
|
2011-01-09 07:30:01 +01:00
|
|
|
*
|
2011-01-28 17:39:40 +01:00
|
|
|
* Return value: the class of the symbol.
|
2011-01-09 07:30:01 +01:00
|
|
|
*/
|
2011-02-06 17:57:37 +01:00
|
|
|
gchar *
|
2010-12-16 11:34:02 +01:00
|
|
|
ld_diagram_symbol_get_class (LdDiagramSymbol *self)
|
|
|
|
{
|
2011-02-06 17:57:37 +01:00
|
|
|
gchar *klass;
|
2011-01-15 15:31:01 +01:00
|
|
|
|
2010-12-16 11:34:02 +01:00
|
|
|
g_return_val_if_fail (LD_IS_DIAGRAM_SYMBOL (self), NULL);
|
2011-01-15 15:31:01 +01:00
|
|
|
g_object_get (self, "class", &klass, NULL);
|
|
|
|
return klass;
|
2010-12-16 11:34:02 +01:00
|
|
|
}
|
|
|
|
|
2011-01-09 07:30:01 +01:00
|
|
|
/**
|
2011-01-15 15:31:01 +01:00
|
|
|
* ld_diagram_symbol_set_class:
|
2011-01-28 17:39:40 +01:00
|
|
|
* @self: an #LdDiagramSymbol object.
|
|
|
|
* @klass: the class.
|
2011-01-09 07:30:01 +01:00
|
|
|
*
|
|
|
|
* Set the class of the symbol.
|
|
|
|
*/
|
2010-12-16 11:34:02 +01:00
|
|
|
void
|
|
|
|
ld_diagram_symbol_set_class (LdDiagramSymbol *self, const gchar *klass)
|
|
|
|
{
|
|
|
|
g_return_if_fail (LD_IS_DIAGRAM_SYMBOL (self));
|
2011-01-15 15:31:01 +01:00
|
|
|
g_object_set (self, "class", klass, NULL);
|
2010-12-16 11:34:02 +01:00
|
|
|
}
|
2011-02-14 10:14:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|