{
PROP_0,
PROP_TABLE,
- PROP_KEY
+ PROP_KEY,
+ PROP_QUOTE
};
static void gtk_form_class_init (GtkFormClass *class);
gchar *table;
GSList *fields;
GtkFormKey *key;
+ gchar quote;
};
G_DEFINE_TYPE (GtkForm, gtk_form, G_TYPE_OBJECT)
"Table name",
"GtkForm's table name",
"",
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_KEY,
g_param_spec_object ("key",
TYPE_GTK_FORM_KEY,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_QUOTE,
+ g_param_spec_char ("quote",
+ "Quoting character",
+ "Character to use to quote fields name",
+ G_MININT8, G_MAXINT8, '"',
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+
g_type_class_add_private (object_class, sizeof (GtkFormPrivate));
}
{
GtkFormPrivate *priv = GTK_FORM_GET_PRIVATE (form);
- priv->table = g_strdup ("");
priv->fields = NULL;
priv->key = NULL;
}
field_name = gtk_form_field_get_field_name (field);
- if (field_name != NULL && g_strcmp0 (field_name, "") != 0
- && g_strstr_len (fields_names, -1, field_name) == NULL)
+ if (field_name != NULL && g_strcmp0 (field_name, "") != 0)
{
- switch (type)
+ field_name = g_strconcat (&priv->quote, field_name, &priv->quote, NULL);
+ if (g_strstr_len (fields_names, -1, field_name) == NULL)
{
- case GTK_FORM_SQL_SELECT:
- fields_names = g_strconcat (fields_names, field_name, ", ", NULL);
- break;
-
- case GTK_FORM_SQL_INSERT:
- if (gtk_form_field_is_to_save (field))
- {
- value = gtk_form_field_get_value_sql (field);
- if (value != NULL)
+ switch (type)
+ {
+ case GTK_FORM_SQL_SELECT:
+ fields_names = g_strconcat (fields_names, field_name, ", ", NULL);
+ break;
+
+ case GTK_FORM_SQL_INSERT:
+ if (gtk_form_field_is_to_save (field))
{
- fields_names = g_strconcat (fields_names, field_name, ", ", NULL);
- values = g_strconcat (values, value, ", ", NULL);
+ value = gtk_form_field_get_value_sql (field);
+ if (value != NULL)
+ {
+ fields_names = g_strconcat (fields_names, field_name, ", ", NULL);
+ values = g_strconcat (values, value, ", ", NULL);
+ }
}
- }
- break;
-
- case GTK_FORM_SQL_UPDATE:
- if (gtk_form_field_is_to_save (field)
- && (!IS_GTK_FORM_KEY (priv->key) ||
- !gtk_form_key_field_is_key (priv->key, field)))
- {
- value = gtk_form_field_get_value_sql (field);
- if (value != NULL)
+ break;
+
+ case GTK_FORM_SQL_UPDATE:
+ if (gtk_form_field_is_to_save (field)
+ && (!IS_GTK_FORM_KEY (priv->key) ||
+ !gtk_form_key_field_is_key (priv->key, field)))
{
- fields_names = g_strconcat (fields_names, field_name, " = ", value, ", ", NULL);
+ value = gtk_form_field_get_value_sql (field);
+ if (value != NULL)
+ {
+ fields_names = g_strconcat (fields_names, field_name, " = ", value, ", ", NULL);
+ }
}
- }
- break;
+ break;
+ }
}
}
gtk_form_set_key (form, GTK_FORM_KEY (g_value_get_object (value)));
break;
+ case PROP_QUOTE:
+ priv->quote = g_value_get_char (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
g_value_set_object (value, gtk_form_get_key (form));
break;
+ case PROP_QUOTE:
+ g_value_set_char (value, priv->quote);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;