[gimp] libgimpcolor: add gimp_param_spec_rgb_get_default()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpcolor: add gimp_param_spec_rgb_get_default()
- Date: Sat, 27 Jul 2019 14:11:05 +0000 (UTC)
commit 3597e92a20095ba49b0dca1442b62d5beb5ddd46
Author: Michael Natterer <mitch gimp org>
Date: Sat Jul 27 16:10:24 2019 +0200
libgimpcolor: add gimp_param_spec_rgb_get_default()
libgimpcolor/gimpcolor.def | 1 +
libgimpcolor/gimprgb.c | 21 +++++++++++++++++++++
libgimpcolor/gimprgb.h | 22 ++++++++++++----------
3 files changed, 34 insertions(+), 10 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;
-
-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);
+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);
+
+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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]