Commit ca601f5b authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

* gladeui/Makefile.am, gladeui/glade-editor.c, gladeui/glade-property-class.[ch],

	gladeui/glade-property.c, gladeui/glade-xml-utils.h, po/POTFILES.in:
	Completely removed GladeParameter, a legacy unused mechanism to store parameters in
	the glade catalog for later retrieval from the plugin.
parent 3a779ba7
......@@ -19,6 +19,11 @@
* gladeui/glade-project.[ch], gladeui/glade-widget.c, gladeui/glade-command.c:
Removing legacy 'old_project' argument from glade_project_add_object().
* gladeui/Makefile.am, gladeui/glade-editor.c, gladeui/glade-property-class.[ch],
gladeui/glade-property.c, gladeui/glade-xml-utils.h, po/POTFILES.in:
Completely removed GladeParameter, a legacy unused mechanism to store parameters in
the glade catalog for later retrieval from the plugin.
2010-12-31 Tristan Van Berkom <tristanvb@openismus.com>
* gladeui/glade-project.c: Further fixing project dispose cycle, still leaking a little
......
......@@ -51,7 +51,6 @@ libgladeui_2_la_SOURCES = \
glade-widget-adaptor.c \
glade-debug.c \
glade-project.c \
glade-parameter.c \
glade-placeholder.c \
glade-inspector.c \
glade-xml-utils.c \
......@@ -114,7 +113,6 @@ libgladeuiinclude_HEADERS = \
glade-debug.h \
glade-project.h \
glade-inspector.h \
glade-parameter.h \
glade-placeholder.h \
glade-editor.h \
glade-editor-property.h \
......
......@@ -43,7 +43,6 @@
#include "glade-widget-adaptor.h"
#include "glade-editor.h"
#include "glade-signal-editor.h"
#include "glade-parameter.h"
#include "glade-property.h"
#include "glade-property-class.h"
#include "glade-command.h"
......
/*
* Copyright (C) 2001 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Authors:
* Chema Celorio <chema@celorio.com>
*/
#include "config.h"
/**
* SECTION:glade-parameter
* @Title: Glade Parameter
* @Short_Description: Parameters set in the catalog retrievable from the plugin.
*
* Parameters can be set in your catalog file that may determine how
* your plugin will treat certain widget classes.
*/
#include <stdlib.h> /* for atoi and atof */
#include <string.h>
#include "glade.h"
#include "glade-xml-utils.h"
#include "glade-parameter.h"
#include "glade-property-class.h"
/**
* glade_parameter_get_integer:
* @parameters: a #GList of #GladeParameters
* @key: a string containing the parameter name
* @value: a pointer to a #gint
*
* Searches through @parameters looking for a #GladeParameter named @key. If
* found, it stores a #gint representation of its value into @value.
*/
void
glade_parameter_get_integer (GList * parameters, const gchar * key,
gint * value)
{
GladeParameter *parameter;
GList *list;
list = parameters;
for (; list != NULL; list = list->next)
{
parameter = list->data;
if (strcmp (key, parameter->key) == 0)
{
*value = g_ascii_strtoll (parameter->value, NULL, 10);
return;
}
}
}
/**
* glade_parameter_get_float:
* @parameters: a #GList of #GladeParameters
* @key: a string containing the parameter name
* @value: a pointer to a #gfloat
*
* Searches through @parameters looking for a #GladeParameter named @key. If
* found, it stores a #gfloat representation of its value into @value.
*/
void
glade_parameter_get_float (GList * parameters, const gchar * key,
gfloat * value)
{
GladeParameter *parameter;
GList *list;
list = parameters;
for (; list != NULL; list = list->next)
{
parameter = list->data;
if (strcmp (key, parameter->key) == 0)
{
*value = (float) g_ascii_strtod (parameter->value, NULL);
return;
}
}
}
/**
* glade_parameter_get_boolean:
* @parameters: a #GList of #GladeParameters
* @key: a string containing the parameter name
* @value: a pointer to a #gboolean
*
* Searches through @parameters looking for a #GladeParameter named @key. If
* found, it stores a #gboolean representation of its value into @value.
*/
void
glade_parameter_get_boolean (GList * parameters, const gchar * key,
gboolean * value)
{
GladeParameter *parameter;
GList *list;
list = parameters;
for (; list != NULL; list = list->next)
{
parameter = list->data;
if (strcmp (key, parameter->key) == 0)
{
if (strcmp (parameter->value, GLADE_TAG_TRUE) == 0)
*value = TRUE;
else if (strcmp (parameter->value, GLADE_TAG_FALSE) == 0)
*value = FALSE;
else
g_warning ("Invalid boolean parameter *%s* (%s/%s)",
parameter->value, GLADE_TAG_TRUE, GLADE_TAG_FALSE);
return;
}
}
}
/**
* glade_parameter_get_string:
* @parameters: a #GList of #GladeParameters
* @key: a string containing the parameter name
* @value: a pointer to an string
*
* Searches through @parameters looking for a #GladeParameter named @key. If
* found, it stores a newly copied string representation of its value into
* @value.
*/
void
glade_parameter_get_string (GList * parameters, const gchar * key,
gchar ** value)
{
GladeParameter *parameter;
GList *list;
list = parameters;
for (; list != NULL; list = list->next)
{
parameter = list->data;
if (strcmp (key, parameter->key) == 0)
{
if (*value != NULL)
g_free (*value);
*value = g_strdup (parameter->value);
return;
}
}
}
/**
* glade_parameter_free:
* @parameter: a #GladeParameter
*
* Frees @parameter and its associated memory.
*/
void
glade_parameter_free (GladeParameter * parameter)
{
if (!parameter)
return;
g_free (parameter->key);
g_free (parameter->value);
g_free (parameter);
}
/**
* glade_parameter_new:
*
* Returns: a new #GladeParameter
*/
GladeParameter *
glade_parameter_new (void)
{
GladeParameter *parameter;
parameter = g_new0 (GladeParameter, 1);
return parameter;
}
/**
* glade_parameter_clone:
* @parameter: a #GladeParameter
*
* Returns: a new #GladeParameter cloned from @parameter
*/
GladeParameter *
glade_parameter_clone (GladeParameter * parameter)
{
GladeParameter *clone;
if (parameter == NULL)
return NULL;
clone = glade_parameter_new ();
clone->key = g_strdup (parameter->key);
clone->value = g_strdup (parameter->value);
return clone;
}
static GladeParameter *
glade_parameter_new_from_node (GladeXmlNode * node)
{
GladeParameter *parameter;
if (!glade_xml_node_verify (node, GLADE_TAG_PARAMETER))
return NULL;
parameter = glade_parameter_new ();
parameter->key =
glade_xml_get_property_string_required (node, GLADE_TAG_KEY, NULL);
parameter->value =
glade_xml_get_property_string_required (node, GLADE_TAG_VALUE, NULL);
if (!parameter->key || !parameter->value)
return NULL;
return parameter;
}
/**
* glade_parameter_list_find_by_key:
* @list: a #GList containing #GladeParameters
* @key: a string used as a parameter key
*
* Searches through @list looking for a node which contains a
* #GladeParameter matching @key
*
* Returns: the #GList node containing the located #GladeParameter,
* or %NULL if none is found
*/
static GList *
glade_parameter_list_find_by_key (GList * list, const gchar * key)
{
GladeParameter *parameter;
for (; list != NULL; list = list->next)
{
parameter = list->data;
g_return_val_if_fail (parameter->key != NULL, NULL);
if (strcmp (parameter->key, key) == 0)
return list;
}
return NULL;
}
/**
* glade_parameter_list_new_from_node:
* @list: a #GList node
* @node: a #GladeXmlNode
*
* TODO: write me
*
* Returns:
*/
GList *
glade_parameter_list_new_from_node (GList * list, GladeXmlNode * node)
{
GladeParameter *parameter;
GladeXmlNode *child;
GList *findme;
if (!glade_xml_node_verify (node, GLADE_TAG_PARAMETERS))
return NULL;
child = glade_xml_search_child (node, GLADE_TAG_PARAMETER);
if (child == NULL)
return NULL;
child = glade_xml_node_get_children (node);
for (; child != NULL; child = glade_xml_node_next (child))
{
if (!glade_xml_node_verify (child, GLADE_TAG_PARAMETER))
return NULL;
parameter = glade_parameter_new_from_node (child);
if (parameter == NULL)
return NULL;
/* Is this parameter already there ? just replace
* the pointer and free the old one
*/
findme = glade_parameter_list_find_by_key (list, parameter->key);
if (findme)
{
glade_parameter_free (findme->data);
findme->data = parameter;
continue;
}
list = g_list_prepend (list, parameter);
}
list = g_list_reverse (list);
return list;
}
#ifndef __GLADE_PARAMETER_H__
#define __GLADE_PARAMETER_H__
G_BEGIN_DECLS
/* The GladeParameter is a pair of a key and a value. It is used by the
* GladeSetting object. We store in a string the value no matter the
* type of the paramter it is. This adds "extra" information to a
* GladeProperty that we can blindly parse/set/query
* The valid parameter keys depend on the type of the property
<Property>
<Type>Integer</Type>
.....
<Parameters>
<Parameter Key="Min" Value="0"/>
<Parameter Key="Max" Value="10000"/>
<Parameter Key="Default" Value="0"/>
<Parameter Key="StepIncrement" Value="1"/>
<Parameter Key="PageIncrement" Value="10"/>
<Parameter Key="ClimbRate" Value="1"/>
</Parameters>
</Property>
*/
typedef struct _GladeParameter GladeParameter;
struct _GladeParameter {
gchar *key; /* The name of the parameter */
gchar *value; /* The textual representation of the parameter */
};
GladeParameter *glade_parameter_new (void);
GladeParameter *glade_parameter_clone (GladeParameter *parameter);
void glade_parameter_free (GladeParameter *parameter);
void glade_parameter_get_float (GList *parameters, const gchar *key, gfloat *value);
void glade_parameter_get_integer (GList *parameters, const gchar *key, gint *value);
void glade_parameter_get_boolean (GList *parameters, const gchar *key, gboolean *value);
void glade_parameter_get_string (GList *parameters, const gchar *key, gchar **value);
GList * glade_parameter_list_new_from_node (GList *list, GladeXmlNode *node);
G_END_DECLS
#endif /* __GLADE_PARAMETER_H__ */
......@@ -42,7 +42,6 @@
#include "glade.h"
#include "glade-widget.h"
#include "glade-parameter.h"
#include "glade-property.h"
#include "glade-property-class.h"
#include "glade-editor-property.h"
......@@ -76,7 +75,6 @@ glade_property_class_new (gpointer handle)
property_class->tooltip = NULL;
property_class->def = NULL;
property_class->orig_def = NULL;
property_class->parameters = NULL;
property_class->query = FALSE;
property_class->optional = FALSE;
property_class->optional_default = FALSE;
......@@ -144,17 +142,6 @@ glade_property_class_clone (GladePropertyClass * property_class)
g_value_copy (property_class->orig_def, clone->orig_def);
}
if (clone->parameters)
{
GList *parameter;
clone->parameters = g_list_copy (clone->parameters);
for (parameter = clone->parameters;
parameter != NULL; parameter = parameter->next)
parameter->data =
glade_parameter_clone ((GladeParameter *) parameter->data);
}
return clone;
}
......@@ -187,9 +174,6 @@ glade_property_class_free (GladePropertyClass * property_class)
g_value_unset (property_class->def);
g_free (property_class->def);
}
g_list_foreach (property_class->parameters, (GFunc) glade_parameter_free,
NULL);
g_list_free (property_class->parameters);
g_free (property_class);
}
......@@ -1572,11 +1556,6 @@ glade_property_class_update_from_node (GladeXmlNode * node,
glade_xml_get_value_int (node, GLADE_TAG_VISIBLE_LINES,
&klass->visible_lines);
/* Get the Parameters */
if ((child = glade_xml_search_child (node, GLADE_TAG_PARAMETERS)) != NULL)
klass->parameters =
glade_parameter_list_new_from_node (klass->parameters, child);
klass->construct_only =
glade_xml_get_property_boolean (node, GLADE_TAG_CONSTRUCT_ONLY,
klass->construct_only);
......
......@@ -102,14 +102,6 @@ struct _GladePropertyClass
* correctly); all property classes have and orig_def.
*/
GList *parameters; /* list of GladeParameter objects. This list
* provides with an extra set of key-value
* pairs to specify aspects of this property.
*
* This is unused by glade and only maintained
* to be of possible use in plugin code.
*/
gint visible_lines; /* When this pspec calls for a text editor, how many
* lines should be visible in the editor.
*/
......
......@@ -48,7 +48,6 @@
#include "glade-widget.h"
#include "glade-property.h"
#include "glade-property-class.h"
#include "glade-parameter.h"
#include "glade-project.h"
#include "glade-widget-adaptor.h"
#include "glade-debug.h"
......
......@@ -127,8 +127,6 @@ typedef enum {
#define GLADE_TAG_MIN_VALUE "min"
#define GLADE_TAG_VALUE_TYPE "value-type"
#define GLADE_TAG_TOOLTIP "tooltip"
#define GLADE_TAG_PARAMETERS "parameters"
#define GLADE_TAG_PARAMETER "parameter"
#define GLADE_TAG_SET_FUNCTION "set-property-function"
#define GLADE_TAG_GET_FUNCTION "get-property-function"
#define GLADE_TAG_VERIFY_FUNCTION "verify-function"
......
......@@ -25,7 +25,6 @@ gladeui/glade-editor-table.c
gladeui/glade-editor.c
gladeui/glade-fixed.c
gladeui/glade-palette.c
gladeui/glade-parameter.c
gladeui/glade-placeholder.c
gladeui/glade-popup.c
gladeui/glade-project.c
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment