<!ELEMENT widget-name (#PCDATA)>
-<!ELEMENT field (to-load?, to-save?, obligatory?, default?, is-key?, auto-increment?, datetime-type?, display-format?, trim?)>
+<!ELEMENT field (long-name?, to-load?, to-save?, obligatory?, default?, is-key?, auto-increment?, datetime-type?, display-format?, trim?)>
<!ATTLIST field
type (boolean | datetime | float | integer | text) #REQUIRED
name CDATA #REQUIRED
>
+<!ELEMENT long-name (#PCDATA)>
<!ELEMENT to-load (#PCDATA)>
<!ELEMENT to-save (#PCDATA)>
<!ELEMENT obligatory (#PCDATA)>
{
PROP_0,
PROP_FIELD,
+ PROP_LONG_NAME,
PROP_TO_LOAD,
PROP_TO_SAVE,
PROP_OBLIGATORY,
struct _GtkFormFieldPrivate
{
gchar *field;
+ gchar *long_name;
gboolean is_key;
gboolean to_load;
gboolean to_save;
g_object_class_install_property (object_class, PROP_FIELD,
g_param_spec_string ("field",
- "Field",
+ "Field's name",
"Field's name",
"",
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_LONG_NAME,
+ g_param_spec_string ("long-name",
+ "Field's long name",
+ "Field's long name",
+ "",
+ G_PARAM_READWRITE));
+
g_object_class_install_property (object_class, PROP_TO_LOAD,
g_param_spec_boolean ("to-load",
"Whether load the field or not",
return g_strdup (priv->field);
}
+/**
+ * gtk_form_field_get_field_long_name:
+ * @field: a #GtkFormField object.
+ *
+ * Returns: the field's long name.
+ */
+gchar
+*gtk_form_field_get_field_long_name (GtkFormField *field)
+{
+ GtkFormFieldPrivate *priv = GTK_FORM_FIELD_GET_PRIVATE (field);
+
+ return g_strdup (priv->long_name);
+}
+
/**
* gtk_form_field_get_form_widget:
* @field: a #GtkFormField object.
priv->field = g_strstrip (g_value_dup_string (value));
break;
+ case PROP_LONG_NAME:
+ priv->long_name = g_strstrip (g_value_dup_string (value));
+ break;
+
case PROP_TO_LOAD:
priv->to_load = g_value_get_boolean (value);
break;
g_value_set_string (value, gtk_form_field_get_field_name (field));
break;
+ case PROP_LONG_NAME:
+ g_value_set_string (value, gtk_form_field_get_field_long_name (field));
+ break;
+
case PROP_TO_LOAD:
g_value_set_boolean (value, priv->to_load);
break;
GtkFormField *gtk_form_field_new_from_gtk_form_widget (GtkFormWidget *fwidget);
gchar *gtk_form_field_get_field_name (GtkFormField *field);
+gchar *gtk_form_field_get_field_long_name (GtkFormField *field);
+
GtkFormWidget *gtk_form_field_get_form_widget (GtkFormField *field);
gchar *gtk_form_field_get_value_stringify (GtkFormField *field);
while (node_field != NULL)
{
prop = (gchar *)xmlNodeGetContent (node_field);
- if (xmlStrcmp (node_field->name, (const xmlChar *)"to-load") == 0)
+ if (xmlStrcmp (node_field->name, (const xmlChar *)"long-name") == 0)
+ {
+ g_object_set (G_OBJECT (field),
+ "long-name", prop,
+ NULL);
+ }
+ else if (xmlStrcmp (node_field->name, (const xmlChar *)"to-load") == 0)
{
g_object_set (G_OBJECT (field),
"to-load", gtk_form_field_boolean_str_to_boolean (prop),
{
GtkWidget *dialog;
GtkWidget *label;
- const gchar *label_text;
+ GtkFormField *field;
+
+ gchar *label_text;
g_return_if_fail (IS_GTK_FORM_WIDGET (fwidget));
g_return_if_fail (GTK_IS_WINDOW (parent_window));
+ label_text = NULL;
+
label = gtk_form_widget_get_label (fwidget);
if (GTK_IS_LABEL (label))
{
- label_text = gtk_label_get_text (GTK_LABEL (label));
+ label_text = (gchar *)gtk_label_get_text (GTK_LABEL (label));
}
- else if (GTK_IS_CHECK_BUTTON (label))
+ else
{
- label_text = gtk_button_get_label (GTK_BUTTON (label));
+ g_object_get (G_OBJECT (fwidget), "field", &field, NULL);
+ if (IS_GTK_FORM_FIELD (field))
+ {
+ label_text = gtk_form_field_get_field_long_name (field);
+ if (label_text == NULL || g_strcmp0 (g_strstrip (label_text), "") == 0)
+ {
+ label_text = gtk_form_field_get_field_name (field);
+ }
+ }
+
+ if ((label_text == NULL || g_strcmp0 (g_strstrip (label_text), "") == 0)
+ && GTK_IS_CHECK_BUTTON (label))
+ {
+ label_text = (gchar *)gtk_button_get_label (GTK_BUTTON (label));
+ }
}
- else
+
+ if (label_text == NULL || g_strcmp0 (g_strstrip (label_text), "") == 0)
{
label_text = gtk_form_widget_get_widget_name (fwidget);
}
</field>
</widget>
- <widget type="entry" name="txt_name" label="label2">
+ <widget type="entry" name="txt_name">
<field type="text" name="name">
+ <long-name>The person's name</long-name>
<obligatory>TRUE</obligatory>
</field>
</widget>