[gimp] app: add "precision" member and API to GimpTemplate
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add "precision" member and API to GimpTemplate
- Date: Wed, 2 May 2012 16:41:32 +0000 (UTC)
commit acda2b06fc3381d54c2da260069d10a4661dfb7b
Author: Michael Natterer <mitch gimp org>
Date: Sun Apr 22 17:42:39 2012 +0200
app: add "precision" member and API to GimpTemplate
app/core/gimpimage-new.c | 2 +-
app/core/gimptemplate.c | 29 +++++++++++++++++++++++++++--
app/core/gimptemplate.h | 2 ++
3 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index a24e6ce..2e3d5e4 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -98,7 +98,7 @@ gimp_image_new_from_template (Gimp *gimp,
gimp_template_get_width (template),
gimp_template_get_height (template),
gimp_template_get_base_type (template),
- GIMP_PRECISION_U8, /* XXX add to template */
+ gimp_template_get_precision (template),
FALSE);
gimp_image_undo_disable (image);
diff --git a/app/core/gimptemplate.c b/app/core/gimptemplate.c
index a55a0b2..af6946f 100644
--- a/app/core/gimptemplate.c
+++ b/app/core/gimptemplate.c
@@ -50,6 +50,7 @@ enum
PROP_YRESOLUTION,
PROP_RESOLUTION_UNIT,
PROP_BASE_TYPE,
+ PROP_PRECISION,
PROP_FILL_TYPE,
PROP_COMMENT,
PROP_FILENAME
@@ -69,6 +70,7 @@ struct _GimpTemplatePrivate
GimpUnit resolution_unit;
GimpImageBaseType base_type;
+ GimpPrecision precision;
GimpFillType fill_type;
@@ -155,6 +157,12 @@ gimp_template_class_init (GimpTemplateClass *klass)
NULL,
GIMP_TYPE_IMAGE_BASE_TYPE, GIMP_RGB,
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,
"fill-type",
NULL,
@@ -232,6 +240,9 @@ gimp_template_set_property (GObject *object,
case PROP_BASE_TYPE:
private->base_type = g_value_get_enum (value);
break;
+ case PROP_PRECISION:
+ private->precision = g_value_get_enum (value);
+ break;
case PROP_FILL_TYPE:
private->fill_type = g_value_get_enum (value);
break;
@@ -282,6 +293,9 @@ gimp_template_get_property (GObject *object,
case PROP_BASE_TYPE:
g_value_set_enum (value, private->base_type);
break;
+ case PROP_PRECISION:
+ g_value_set_enum (value, private->precision);
+ break;
case PROP_FILL_TYPE:
g_value_set_enum (value, private->fill_type);
break;
@@ -307,11 +321,13 @@ gimp_template_notify (GObject *object,
if (G_OBJECT_CLASS (parent_class)->notify)
G_OBJECT_CLASS (parent_class)->notify (object, pspec);
- channels = ((private->base_type == GIMP_RGB ? 3 : 1) /* color */ +
+ channels = ((private->base_type == GIMP_RGB ? 3 : 1) /* color */ +
(private->fill_type == GIMP_TRANSPARENT_FILL) /* alpha */ +
1 /* selection */);
- private->initial_size = ((guint64) channels *
+ /* XXX todo honor precision */
+
+ private->initial_size = ((guint64) channels *
(guint64) private->width *
(guint64) private->height);
@@ -368,6 +384,7 @@ gimp_template_set_from_image (GimpTemplate *template,
"yresolution", yresolution,
"resolution-unit", gimp_image_get_unit (image),
"image-type", base_type,
+ "precision", gimp_image_get_precision (image),
"comment", comment,
NULL);
@@ -431,6 +448,14 @@ gimp_template_get_base_type (GimpTemplate *template)
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
gimp_template_get_fill_type (GimpTemplate *template)
{
diff --git a/app/core/gimptemplate.h b/app/core/gimptemplate.h
index 08032c0..3164828 100644
--- a/app/core/gimptemplate.h
+++ b/app/core/gimptemplate.h
@@ -78,6 +78,8 @@ gdouble gimp_template_get_resolution_y (GimpTemplate *template);
GimpUnit gimp_template_get_resolution_unit (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);
const gchar * gimp_template_get_comment (GimpTemplate *template);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]