hide the GimpParamSpecRGB struct again. Added getter for the has_alpha

2006-04-27  Sven Neumann  <sven@gimp.org>

	* libgimpcolor/gimprgb.[ch]: hide the GimpParamSpecRGB struct
	again.  Added getter for the has_alpha field.

	* libgimpcolor/gimpcolor.def: updated.

	* app/config/gimpconfig-dump.c
	* libgimpconfig/gimpconfig-serialize.c: use
	gimp_param_spec_rgb_has_alpha() instead of accessing the
	GimpParamSpecRGB struct directly.
This commit is contained in:
Sven Neumann 2006-04-27 16:01:16 +00:00 committed by Sven Neumann
parent e779cf0b0f
commit 0b9a9e4e88
7 changed files with 65 additions and 31 deletions

View File

@ -1,3 +1,15 @@
2006-04-27 Sven Neumann <sven@gimp.org>
* libgimpcolor/gimprgb.[ch]: hide the GimpParamSpecRGB struct
again. Added getter for the has_alpha field.
* libgimpcolor/gimpcolor.def: updated.
* app/config/gimpconfig-dump.c
* libgimpconfig/gimpconfig-serialize.c: use
gimp_param_spec_rgb_has_alpha() instead of accessing the
GimpParamSpecRGB struct directly.
2006-04-27 Sven Neumann <sven@gimp.org>
* libgimpcolor/gimprgb.[ch]: added "has_alpha" to GimpParamSpecRGB.

View File

@ -21,8 +21,9 @@
#include "config.h"
#include "stdlib.h"
#include "string.h"
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@ -335,14 +336,14 @@ dump_describe_param (GParamSpec *param_spec)
if (GIMP_IS_PARAM_SPEC_RGB (param_spec))
{
if (GIMP_PARAM_SPEC_RGB (param_spec)->has_alpha)
if (gimp_param_spec_rgb_has_alpha (param_spec))
values =
"The color is specified in the form (color-rgba red green blue "
"alpha) with channel values as floats between 0.0 and 1.0.";
"alpha) with channel values as floats in the range of 0.0 to 1.0.";
else
values =
"The color is specified in the form (color-rgb red green blue) "
"with channel values as floats between 0.0 and 1.0.";
"with channel values as floats in the range of 0.0 to 1.0.";
}
else if (GIMP_IS_PARAM_SPEC_MEMSIZE (param_spec))
{

View File

@ -87,6 +87,7 @@ GIMP_RGB_INTENSITY_BLUE
GIMP_TYPE_RGB
GIMP_TYPE_PARAM_RGB
gimp_param_spec_rgb
gimp_param_spec_rgb_has_alpha
GIMP_VALUE_HOLDS_RGB
<SUBSECTION Standard>
GIMP_IS_PARAM_SPEC_RGB

View File

@ -26,6 +26,7 @@ EXPORTS
gimp_hwb_to_rgb
gimp_param_rgb_get_type
gimp_param_spec_rgb
gimp_param_spec_rgb_has_alpha
gimp_rgb_add
gimp_rgb_clamp
gimp_rgb_composite

View File

@ -497,6 +497,18 @@ gimp_rgba_distance (const GimpRGB *rgba1,
* GIMP_TYPE_PARAM_RGB
*/
#define GIMP_PARAM_SPEC_RGB(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_RGB, GimpParamSpecRGB))
typedef struct _GimpParamSpecRGB GimpParamSpecRGB;
struct _GimpParamSpecRGB
{
GParamSpecBoxed parent_instance;
gboolean has_alpha;
GimpRGB default_value;
};
static void gimp_param_rgb_class_init (GParamSpecClass *class);
static void gimp_param_rgb_init (GParamSpec *pspec);
static void gimp_param_rgb_set_default (GParamSpec *pspec,
@ -676,3 +688,19 @@ gimp_param_spec_rgb (const gchar *name,
return G_PARAM_SPEC (cspec);
}
/**
* gimp_param_spec_rgb:
* @pspec: a #GParamSpec to hold an #GimpRGB value.
*
* Returns: %TRUE if the alpha channel is relevant.
*
* Since: GIMP 2.4
**/
gboolean
gimp_param_spec_rgb_has_alpha (GParamSpec *pspec)
{
g_return_val_if_fail (GIMP_IS_PARAM_SPEC_RGB (pspec), FALSE);
return GIMP_PARAM_SPEC_RGB (pspec)->has_alpha;
}

View File

@ -29,15 +29,15 @@ G_BEGIN_DECLS
* GIMP_TYPE_RGB
*/
#define GIMP_TYPE_RGB (gimp_rgb_get_type ())
#define GIMP_VALUE_HOLDS_RGB(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_RGB))
#define GIMP_TYPE_RGB (gimp_rgb_get_type ())
#define GIMP_VALUE_HOLDS_RGB(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_RGB))
GType gimp_rgb_get_type (void) G_GNUC_CONST;
GType gimp_rgb_get_type (void) G_GNUC_CONST;
void gimp_value_get_rgb (const GValue *value,
GimpRGB *rgb);
void gimp_value_set_rgb (GValue *value,
const GimpRGB *rgb);
void gimp_value_get_rgb (const GValue *value,
GimpRGB *rgb);
void gimp_value_set_rgb (GValue *value,
const GimpRGB *rgb);
/*
@ -46,27 +46,18 @@ void gimp_value_set_rgb (GValue *value,
#define GIMP_TYPE_PARAM_RGB (gimp_param_rgb_get_type ())
#define GIMP_IS_PARAM_SPEC_RGB(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_RGB))
#define GIMP_PARAM_SPEC_RGB(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_RGB, GimpParamSpecRGB))
typedef struct _GimpParamSpecRGB GimpParamSpecRGB;
struct _GimpParamSpecRGB
{
GParamSpecBoxed parent_instance;
gboolean has_alpha;
GimpRGB default_value;
};
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);
/* RGB and RGBA color types and operations taken from LibGCK */

View File

@ -262,7 +262,7 @@ gimp_config_serialize_property (GimpConfig *config,
if (GIMP_VALUE_HOLDS_RGB (&value))
{
gboolean has_alpha = GIMP_PARAM_SPEC_RGB (param_spec)->has_alpha;
gboolean has_alpha = gimp_param_spec_rgb_has_alpha (param_spec);
success = gimp_config_serialize_rgb (&value, str, has_alpha);
}