From 3597e92a20095ba49b0dca1442b62d5beb5ddd46 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 27 Jul 2019 16:10:24 +0200 Subject: [PATCH] libgimpcolor: add gimp_param_spec_rgb_get_default() --- libgimpcolor/gimpcolor.def | 1 + libgimpcolor/gimprgb.c | 21 +++++++++++++++++++++ libgimpcolor/gimprgb.h | 18 ++++++++++-------- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def index 505baf7211..47dbb99c57 100644 --- a/libgimpcolor/gimpcolor.def +++ b/libgimpcolor/gimpcolor.def @@ -69,6 +69,7 @@ EXPORTS gimp_hsva_set gimp_param_rgb_get_type gimp_param_spec_rgb + gimp_param_spec_rgb_get_default gimp_param_spec_rgb_has_alpha gimp_pixbuf_create_buffer gimp_pixbuf_get_format diff --git a/libgimpcolor/gimprgb.c b/libgimpcolor/gimprgb.c index 5bdc20e6f3..913b83974a 100644 --- a/libgimpcolor/gimprgb.c +++ b/libgimpcolor/gimprgb.c @@ -765,10 +765,31 @@ gimp_param_spec_rgb (const gchar *name, if (default_value) cspec->default_value = *default_value; + else + gimp_rgba_set (&cspec->default_value, 0.0, 0.0, 0.0, 1.0); return G_PARAM_SPEC (cspec); } +/** + * gimp_param_spec_rgb_get_default: + * @pspec: a #GimpParamSpecRGB. + * @default_value: return location for @pspec's default value + * + * Returns the @pspec's default color value. + * + * Since: 2.10.12 + **/ +void +gimp_param_spec_rgb_get_default (GParamSpec *pspec, + GimpRGB *default_value) +{ + g_return_if_fail (GIMP_IS_PARAM_SPEC_RGB (pspec)); + g_return_if_fail (default_value != NULL); + + *default_value = GIMP_PARAM_SPEC_RGB (pspec)->default_value; +} + /** * gimp_param_spec_rgb_has_alpha: * @pspec: a #GParamSpec to hold an #GimpRGB value. diff --git a/libgimpcolor/gimprgb.h b/libgimpcolor/gimprgb.h index 485ecce022..0bb0791bad 100644 --- a/libgimpcolor/gimprgb.h +++ b/libgimpcolor/gimprgb.h @@ -51,16 +51,18 @@ void gimp_value_set_rgb (GValue *value, #define GIMP_IS_PARAM_SPEC_RGB(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_RGB)) -GType gimp_param_rgb_get_type (void) G_GNUC_CONST; +GType gimp_param_rgb_get_type (void) G_GNUC_CONST; -GParamSpec * gimp_param_spec_rgb (const gchar *name, - const gchar *nick, - const gchar *blurb, - gboolean has_alpha, - const GimpRGB *default_value, - GParamFlags flags); +GParamSpec * gimp_param_spec_rgb (const gchar *name, + const gchar *nick, + const gchar *blurb, + gboolean has_alpha, + const GimpRGB *default_value, + GParamFlags flags); -gboolean gimp_param_spec_rgb_has_alpha (GParamSpec *pspec); +void gimp_param_spec_rgb_get_default (GParamSpec *pspec, + GimpRGB *default_value); +gboolean gimp_param_spec_rgb_has_alpha (GParamSpec *pspec); /* RGB and RGBA color types and operations taken from LibGCK */