Rename ld_diagram_object_{get,set}_data().

Make small corrections.
This commit is contained in:
Přemysl Eric Janouch 2011-01-26 13:00:13 +01:00
parent b782dae4b2
commit 17bf37ceba
3 changed files with 30 additions and 30 deletions

View File

@ -113,7 +113,7 @@ ld_diagram_object_get_property (GObject *object, guint property_id,
break; break;
case PROP_X: case PROP_X:
case PROP_Y: case PROP_Y:
ld_diagram_object_get_data (self, value, pspec); ld_diagram_object_get_data_for_param (self, value, pspec);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -134,7 +134,7 @@ ld_diagram_object_set_property (GObject *object, guint property_id,
break; break;
case PROP_X: case PROP_X:
case PROP_Y: case PROP_Y:
ld_diagram_object_set_data (self, value, pspec); ld_diagram_object_set_data_for_param (self, value, pspec);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -212,16 +212,16 @@ ld_diagram_object_set_storage (LdDiagramObject *self, JsonObject *storage)
} }
/** /**
* ld_diagram_object_get_data: * ld_diagram_object_get_data_for_param:
* @self: An #LdDiagramObject object. * @self: An #LdDiagramObject object.
* @value: (out): Where the data will be stored. * @data: (out): Where the data will be stored.
* @pspec: The parameter to read data for. * @pspec: The parameter to read data for.
* *
* Retrieve data from internal storage. * Retrieve data for a parameter from internal storage.
*/ */
void void
ld_diagram_object_get_data (LdDiagramObject *self, ld_diagram_object_get_data_for_param (LdDiagramObject *self,
GValue *value, GParamSpec *pspec) GValue *data, GParamSpec *pspec)
{ {
JsonObject *storage; JsonObject *storage;
JsonNode *node; JsonNode *node;
@ -230,7 +230,7 @@ ld_diagram_object_get_data (LdDiagramObject *self,
gboolean result; gboolean result;
g_return_if_fail (LD_IS_DIAGRAM_OBJECT (self)); g_return_if_fail (LD_IS_DIAGRAM_OBJECT (self));
g_return_if_fail (G_IS_VALUE (value)); g_return_if_fail (G_IS_VALUE (data));
g_return_if_fail (G_IS_PARAM_SPEC (pspec)); g_return_if_fail (G_IS_PARAM_SPEC (pspec));
storage = ld_diagram_object_get_storage (self); storage = ld_diagram_object_get_storage (self);
@ -243,48 +243,47 @@ ld_diagram_object_get_data (LdDiagramObject *self,
memset (&json_value, 0, sizeof (json_value)); memset (&json_value, 0, sizeof (json_value));
json_node_get_value (node, &json_value); json_node_get_value (node, &json_value);
result = g_param_value_convert (pspec, &json_value, value, FALSE); result = g_param_value_convert (pspec, &json_value, data, FALSE);
g_value_unset (&json_value); g_value_unset (&json_value);
if (!result) if (result)
goto ld_diagram_object_get_data_warn; return;
return;
ld_diagram_object_get_data_warn: ld_diagram_object_get_data_warn:
g_warning ("%s: unable to set property `%s' of type `%s'" g_warning ("%s: unable to get parameter `%s' of type `%s'"
" from node of type `%s'; setting the property to it's default value", " from node of type `%s'; setting the parameter to it's default value",
G_STRFUNC, name, G_PARAM_SPEC_TYPE_NAME (pspec), G_STRFUNC, name, G_PARAM_SPEC_TYPE_NAME (pspec),
json_node_type_name (node)); json_node_type_name (node));
ld_diagram_object_get_data_default: ld_diagram_object_get_data_default:
g_param_value_set_default (pspec, value); g_param_value_set_default (pspec, data);
g_object_set_property (G_OBJECT (self), name, value); g_object_set_property (G_OBJECT (self), name, data);
} }
/** /**
* ld_diagram_object_set_data: * ld_diagram_object_set_data_for_param:
* @self: An #LdDiagramObject object. * @self: An #LdDiagramObject object.
* @value: The data. * @data: The data.
* @pspec: The parameter to set data for. * @pspec: The parameter to put data for.
* *
* Set data in internal storage. * Put data for a parameter into internal storage.
*/ */
void void
ld_diagram_object_set_data (LdDiagramObject *self, ld_diagram_object_set_data_for_param (LdDiagramObject *self,
const GValue *value, GParamSpec *pspec) const GValue *data, GParamSpec *pspec)
{ {
JsonObject *storage; JsonObject *storage;
const gchar *name; const gchar *name;
JsonNode *node; JsonNode *node;
g_return_if_fail (LD_IS_DIAGRAM_OBJECT (self)); g_return_if_fail (LD_IS_DIAGRAM_OBJECT (self));
g_return_if_fail (G_IS_VALUE (value)); g_return_if_fail (G_IS_VALUE (data));
g_return_if_fail (G_IS_PARAM_SPEC (pspec)); g_return_if_fail (G_IS_PARAM_SPEC (pspec));
storage = ld_diagram_object_get_storage (self); storage = ld_diagram_object_get_storage (self);
name = g_param_spec_get_name (pspec); name = g_param_spec_get_name (pspec);
node = json_node_new (JSON_NODE_VALUE); node = json_node_new (JSON_NODE_VALUE);
json_node_set_value (node, value); json_node_set_value (node, data);
/* We have to remove it first due to a bug in json-glib. */ /* We have to remove it first due to a bug in json-glib. */
json_object_remove_member (storage, name); json_object_remove_member (storage, name);
json_object_set_member (storage, name, node); json_object_set_member (storage, name, node);

View File

@ -56,10 +56,11 @@ GType ld_diagram_object_get_type (void) G_GNUC_CONST;
LdDiagramObject *ld_diagram_object_new (JsonObject *storage); LdDiagramObject *ld_diagram_object_new (JsonObject *storage);
JsonObject *ld_diagram_object_get_storage (LdDiagramObject *self); JsonObject *ld_diagram_object_get_storage (LdDiagramObject *self);
void ld_diagram_object_set_storage (LdDiagramObject *self, JsonObject *storage); void ld_diagram_object_set_storage (LdDiagramObject *self, JsonObject *storage);
void ld_diagram_object_get_data (LdDiagramObject *self, void ld_diagram_object_get_data_for_param (LdDiagramObject *self,
GValue *value, GParamSpec *pspec); GValue *data, GParamSpec *pspec);
void ld_diagram_object_set_data (LdDiagramObject *self, void ld_diagram_object_set_data_for_param (LdDiagramObject *self,
const GValue *value, GParamSpec *pspec); const GValue *data, GParamSpec *pspec);
gdouble ld_diagram_object_get_x (LdDiagramObject *self); gdouble ld_diagram_object_get_x (LdDiagramObject *self);
gdouble ld_diagram_object_get_y (LdDiagramObject *self); gdouble ld_diagram_object_get_y (LdDiagramObject *self);
void ld_diagram_object_set_x (LdDiagramObject *self, gdouble x); void ld_diagram_object_set_x (LdDiagramObject *self, gdouble x);

View File

@ -70,7 +70,7 @@ ld_diagram_symbol_get_property (GObject *object, guint property_id,
switch (property_id) switch (property_id)
{ {
case PROP_CLASS: case PROP_CLASS:
ld_diagram_object_get_data (self, value, pspec); ld_diagram_object_get_data_for_param (self, value, pspec);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -87,7 +87,7 @@ ld_diagram_symbol_set_property (GObject *object, guint property_id,
switch (property_id) switch (property_id)
{ {
case PROP_CLASS: case PROP_CLASS:
ld_diagram_object_set_data (self, value, pspec); ld_diagram_object_set_data_for_param (self, value, pspec);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);