Commit acda2b06 authored by Michael Natterer's avatar Michael Natterer 😴

app: add "precision" member and API to GimpTemplate

parent 4dee9fa6
...@@ -98,7 +98,7 @@ gimp_image_new_from_template (Gimp *gimp, ...@@ -98,7 +98,7 @@ gimp_image_new_from_template (Gimp *gimp,
gimp_template_get_width (template), gimp_template_get_width (template),
gimp_template_get_height (template), gimp_template_get_height (template),
gimp_template_get_base_type (template), gimp_template_get_base_type (template),
GIMP_PRECISION_U8, /* XXX add to template */ gimp_template_get_precision (template),
FALSE); FALSE);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
......
...@@ -50,6 +50,7 @@ enum ...@@ -50,6 +50,7 @@ enum
PROP_YRESOLUTION, PROP_YRESOLUTION,
PROP_RESOLUTION_UNIT, PROP_RESOLUTION_UNIT,
PROP_BASE_TYPE, PROP_BASE_TYPE,
PROP_PRECISION,
PROP_FILL_TYPE, PROP_FILL_TYPE,
PROP_COMMENT, PROP_COMMENT,
PROP_FILENAME PROP_FILENAME
...@@ -69,6 +70,7 @@ struct _GimpTemplatePrivate ...@@ -69,6 +70,7 @@ struct _GimpTemplatePrivate
GimpUnit resolution_unit; GimpUnit resolution_unit;
GimpImageBaseType base_type; GimpImageBaseType base_type;
GimpPrecision precision;
GimpFillType fill_type; GimpFillType fill_type;
...@@ -155,6 +157,12 @@ gimp_template_class_init (GimpTemplateClass *klass) ...@@ -155,6 +157,12 @@ gimp_template_class_init (GimpTemplateClass *klass)
NULL, NULL,
GIMP_TYPE_IMAGE_BASE_TYPE, GIMP_RGB, GIMP_TYPE_IMAGE_BASE_TYPE, GIMP_RGB,
GIMP_PARAM_STATIC_STRINGS); GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_PRECISION,
"precision",
NULL,
GIMP_TYPE_PRECISION, GIMP_PRECISION_U8,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FILL_TYPE, GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FILL_TYPE,
"fill-type", "fill-type",
NULL, NULL,
...@@ -232,6 +240,9 @@ gimp_template_set_property (GObject *object, ...@@ -232,6 +240,9 @@ gimp_template_set_property (GObject *object,
case PROP_BASE_TYPE: case PROP_BASE_TYPE:
private->base_type = g_value_get_enum (value); private->base_type = g_value_get_enum (value);
break; break;
case PROP_PRECISION:
private->precision = g_value_get_enum (value);
break;
case PROP_FILL_TYPE: case PROP_FILL_TYPE:
private->fill_type = g_value_get_enum (value); private->fill_type = g_value_get_enum (value);
break; break;
...@@ -282,6 +293,9 @@ gimp_template_get_property (GObject *object, ...@@ -282,6 +293,9 @@ gimp_template_get_property (GObject *object,
case PROP_BASE_TYPE: case PROP_BASE_TYPE:
g_value_set_enum (value, private->base_type); g_value_set_enum (value, private->base_type);
break; break;
case PROP_PRECISION:
g_value_set_enum (value, private->precision);
break;
case PROP_FILL_TYPE: case PROP_FILL_TYPE:
g_value_set_enum (value, private->fill_type); g_value_set_enum (value, private->fill_type);
break; break;
...@@ -311,6 +325,8 @@ gimp_template_notify (GObject *object, ...@@ -311,6 +325,8 @@ gimp_template_notify (GObject *object,
(private->fill_type == GIMP_TRANSPARENT_FILL) /* alpha */ + (private->fill_type == GIMP_TRANSPARENT_FILL) /* alpha */ +
1 /* selection */); 1 /* selection */);
/* XXX todo honor precision */
private->initial_size = ((guint64) channels * private->initial_size = ((guint64) channels *
(guint64) private->width * (guint64) private->width *
(guint64) private->height); (guint64) private->height);
...@@ -368,6 +384,7 @@ gimp_template_set_from_image (GimpTemplate *template, ...@@ -368,6 +384,7 @@ gimp_template_set_from_image (GimpTemplate *template,
"yresolution", yresolution, "yresolution", yresolution,
"resolution-unit", gimp_image_get_unit (image), "resolution-unit", gimp_image_get_unit (image),
"image-type", base_type, "image-type", base_type,
"precision", gimp_image_get_precision (image),
"comment", comment, "comment", comment,
NULL); NULL);
...@@ -431,6 +448,14 @@ gimp_template_get_base_type (GimpTemplate *template) ...@@ -431,6 +448,14 @@ gimp_template_get_base_type (GimpTemplate *template)
return GET_PRIVATE (template)->base_type; return GET_PRIVATE (template)->base_type;
} }
GimpPrecision
gimp_template_get_precision (GimpTemplate *template)
{
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), GIMP_PRECISION_U8);
return GET_PRIVATE (template)->precision;
}
GimpFillType GimpFillType
gimp_template_get_fill_type (GimpTemplate *template) gimp_template_get_fill_type (GimpTemplate *template)
{ {
......
...@@ -78,6 +78,8 @@ gdouble gimp_template_get_resolution_y (GimpTemplate *template); ...@@ -78,6 +78,8 @@ gdouble gimp_template_get_resolution_y (GimpTemplate *template);
GimpUnit gimp_template_get_resolution_unit (GimpTemplate *template); GimpUnit gimp_template_get_resolution_unit (GimpTemplate *template);
GimpImageBaseType gimp_template_get_base_type (GimpTemplate *template); GimpImageBaseType gimp_template_get_base_type (GimpTemplate *template);
GimpPrecision gimp_template_get_precision (GimpTemplate *template);
GimpFillType gimp_template_get_fill_type (GimpTemplate *template); GimpFillType gimp_template_get_fill_type (GimpTemplate *template);
const gchar * gimp_template_get_comment (GimpTemplate *template); const gchar * gimp_template_get_comment (GimpTemplate *template);
......
Markdown is supported
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