[anjuta] project-wizard: bgo #655584 - Implement completely integer property in project wizard templates
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] project-wizard: bgo #655584 - Implement completely integer property in project wizard templates
- Date: Fri, 29 Jul 2011 16:01:14 +0000 (UTC)
commit 31f940be96787be4d18d7797a5af2617d617bca9
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Fri Jul 29 18:01:26 2011 +0200
project-wizard: bgo #655584 - Implement completely integer property in project wizard templates
.../reference/libanjuta/project-wizard-format.sgml | 14 +++++++++++
plugins/project-wizard/parser.c | 24 ++++++++++++++++++++
plugins/project-wizard/property.c | 19 +++++++++++++++-
plugins/project-wizard/property.h | 9 +++++++
4 files changed, 65 insertions(+), 1 deletions(-)
---
diff --git a/manuals/reference/libanjuta/project-wizard-format.sgml b/manuals/reference/libanjuta/project-wizard-format.sgml
index 35e27b7..a0011f0 100644
--- a/manuals/reference/libanjuta/project-wizard-format.sgml
+++ b/manuals/reference/libanjuta/project-wizard-format.sgml
@@ -336,6 +336,20 @@
specified the property is empty.
</para>
<para>
+ minimum is the minimum value for an integer property.
+ If none is specified the minimum value is 0.
+ </para>
+ <para>
+ maximum is the maximum value for an integer property.
+ If none is specified the maximum value is 10000.
+ </para>
+ <para>
+ step is the increment step when clicking on the arrow buttons or
+ using the cursor key, you can always write another value in the
+ allowed range.
+ If none is specified the value is incremented or decremented by 1.
+ </para>
+ <para>
mandatory allow you to define if an empty value is
acceptable, by default it is allowed. If you set it to
yes and the user does not enter a value, he will get an
diff --git a/plugins/project-wizard/parser.c b/plugins/project-wizard/parser.c
index 9c54982..b5d50e7 100644
--- a/plugins/project-wizard/parser.c
+++ b/plugins/project-wizard/parser.c
@@ -97,6 +97,9 @@ typedef enum {
NPW_LABEL_ATTRIBUTE,
NPW_DESCRIPTION_ATTRIBUTE,
NPW_VALUE_ATTRIBUTE,
+ NPW_MIN_ATTRIBUTE,
+ NPW_MAX_ATTRIBUTE,
+ NPW_STEP_ATTRIBUTE,
NPW_SUMMARY_ATTRIBUTE,
NPW_TYPE_ATTRIBUTE,
NPW_RESTRICTION_ATTRIBUTE,
@@ -123,6 +126,9 @@ static NPWStringMapping npw_attribute_mapping [] = {
{"description", NPW_DESCRIPTION_ATTRIBUTE},
{"default", NPW_VALUE_ATTRIBUTE},
{"value", NPW_VALUE_ATTRIBUTE},
+ {"minimum", NPW_MIN_ATTRIBUTE},
+ {"maximum", NPW_MAX_ATTRIBUTE},
+ {"step", NPW_STEP_ATTRIBUTE},
{"type", NPW_TYPE_ATTRIBUTE},
{"restriction", NPW_RESTRICTION_ATTRIBUTE},
{"summary", NPW_SUMMARY_ATTRIBUTE},
@@ -767,6 +773,24 @@ parse_property (NPWPageParser* parser,
case NPW_VALUE_ATTRIBUTE:
npw_property_set_default (parser->property, *values);
break;
+ case NPW_MIN_ATTRIBUTE:
+ if (!npw_property_set_range (parser->property, NPW_MIN_MARK, *values))
+ {
+ parser_warning (parser->ctx, "Invalid minimum attribute \"%s\"", *values);
+ }
+ break;
+ case NPW_MAX_ATTRIBUTE:
+ if (!npw_property_set_range (parser->property, NPW_MAX_MARK, *values))
+ {
+ parser_warning (parser->ctx, "Invalid maximum attribute \"%s\"", *values);
+ }
+ break;
+ case NPW_STEP_ATTRIBUTE:
+ if (!npw_property_set_range (parser->property, NPW_STEP_MARK, *values))
+ {
+ parser_warning (parser->ctx, "Invalid step attribute \"%s\"", *values);
+ }
+ break;
case NPW_SUMMARY_ATTRIBUTE:
npw_property_set_summary_option (parser->property, parse_boolean_string (*values));
break;
diff --git a/plugins/project-wizard/property.c b/plugins/project-wizard/property.c
index 3be5e8e..a35810c 100644
--- a/plugins/project-wizard/property.c
+++ b/plugins/project-wizard/property.c
@@ -58,6 +58,7 @@ struct _NPWProperty {
NPWPropertyType type;
NPWPropertyType restriction;
NPWPropertyOptions options;
+ gdouble range[3];
gchar* label;
gchar* description;
gchar* defvalue;
@@ -455,7 +456,9 @@ npw_property_create_widget (NPWProperty* prop)
}
break;
case NPW_INTEGER_PROPERTY:
- entry = gtk_spin_button_new (NULL, 1, 0);
+ if (prop->range[1] == 0) prop->range[1] = 10000;
+ if (prop->range[2] == 0) prop->range[2] = 1;
+ entry = gtk_spin_button_new_with_range (prop->range[0], prop->range[1], prop->range[2]);
if (value)
{
gtk_spin_button_set_value (GTK_SPIN_BUTTON (entry), atoi (value));
@@ -620,6 +623,20 @@ npw_property_set_default (NPWProperty* prop, const gchar* value)
}
}
+gboolean
+npw_property_set_range (NPWProperty* prop, NPWPropertyRangeMark mark, const gchar* value)
+{
+ char *end;
+ double d;
+ gboolean ok;
+
+ d = strtod (value, &end);
+ ok = (*end == ':') || (*end == '\0');
+ if (ok) prop->range[mark] = d;
+
+ return ok;
+}
+
static gboolean
npw_property_set_value_from_widget (NPWProperty* prop, NPWValueTag tag)
{
diff --git a/plugins/project-wizard/property.h b/plugins/project-wizard/property.h
index 03ca515..5c4633c 100644
--- a/plugins/project-wizard/property.h
+++ b/plugins/project-wizard/property.h
@@ -72,6 +72,13 @@ typedef enum {
NPW_TRUE = 1
} NPWPropertyBooleanValue;
+typedef enum
+{
+ NPW_MIN_MARK = 0,
+ NPW_MAX_MARK = 1,
+ NPW_STEP_MARK = 2
+} NPWPropertyRangeMark;
+
NPWProperty* npw_property_new (void);
void npw_property_free (NPWProperty* prop);
@@ -100,6 +107,8 @@ GtkWidget* npw_property_get_widget (const NPWProperty* prop);
void npw_property_set_default (NPWProperty* prop, const gchar* value);
+gboolean npw_property_set_range (NPWProperty* prop, NPWPropertyRangeMark mark, const gchar* value);
+
gboolean npw_property_update_value_from_widget (NPWProperty* prop);
gboolean npw_property_save_value_from_widget (NPWProperty* prop);
gboolean npw_property_remove_value (NPWProperty* prop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]