added utility functions to send GimpRGB values over the wire.

2006-02-23  Sven Neumann  <sven@gimp.org>

	* libgimpbase/gimpwire.[ch]: added utility functions to send
	GimpRGB values over the wire.

	* libgimpbase/gimpprotocol.c: use the functions.
This commit is contained in:
Sven Neumann 2006-02-23 13:53:32 +00:00 committed by Sven Neumann
parent b3c3846ef1
commit 3343baa84c
4 changed files with 47 additions and 27 deletions

View File

@ -1,3 +1,10 @@
2006-02-23 Sven Neumann <sven@gimp.org>
* libgimpbase/gimpwire.[ch]: added utility functions to send
GimpRGB values over the wire.
* libgimpbase/gimpprotocol.c: use the functions.
2006-02-22 Simon Budig <simon@gimp.org>
* app/vectors/gimpvectors-import.c: fix the import of svg circles.

View File

@ -1396,21 +1396,9 @@ _gp_params_read (GIOChannel *channel,
break;
case GIMP_PDB_COLOR:
if (! _gimp_wire_read_double (channel,
&(*params)[i].data.d_color.r, 1,
user_data))
goto cleanup;
if (! _gimp_wire_read_double (channel,
&(*params)[i].data.d_color.g, 1,
user_data))
goto cleanup;
if (! _gimp_wire_read_double (channel,
&(*params)[i].data.d_color.b, 1,
user_data))
goto cleanup;
if (! _gimp_wire_read_double (channel,
&(*params)[i].data.d_color.a, 1,
user_data))
if (! _gimp_wire_read_color (channel,
&(*params)[i].data.d_color, 1,
user_data))
goto cleanup;
break;
@ -1626,18 +1614,9 @@ _gp_params_write (GIOChannel *channel,
break;
case GIMP_PDB_COLOR:
{
GimpRGB *color = (GimpRGB *) &params[i].data.d_color;
if (! _gimp_wire_write_double (channel, &color->r, 1, user_data))
return;
if (! _gimp_wire_write_double (channel, &color->g, 1, user_data))
return;
if (! _gimp_wire_write_double (channel, &color->b, 1, user_data))
return;
if (! _gimp_wire_write_double (channel, &color->a, 1, user_data))
return;
}
if (! _gimp_wire_write_color (channel,
&params[i].data.d_color, 1, user_data))
return;
break;
case GIMP_PDB_REGION:

View File

@ -23,6 +23,8 @@
#include <glib.h>
#include <libgimpcolor/gimpcolortypes.h>
#include "gimpwire.h"
@ -428,6 +430,18 @@ _gimp_wire_read_string (GIOChannel *channel,
return TRUE;
}
gboolean
_gimp_wire_read_color (GIOChannel *channel,
GimpRGB *data,
gint count,
gpointer user_data)
{
g_return_val_if_fail (count >= 0, FALSE);
return _gimp_wire_read_double (channel,
(gdouble *) data, 4 * count, user_data);
}
gboolean
_gimp_wire_write_int32 (GIOChannel *channel,
const guint32 *data,
@ -570,6 +584,18 @@ _gimp_wire_write_string (GIOChannel *channel,
return TRUE;
}
gboolean
_gimp_wire_write_color (GIOChannel *channel,
const GimpRGB *data,
gint count,
gpointer user_data)
{
g_return_val_if_fail (count >= 0, FALSE);
return _gimp_wire_write_double (channel,
(gdouble *) data, 4 * count, user_data);
}
static guint
gimp_wire_hash (const guint32 *key)
{

View File

@ -101,6 +101,10 @@ gboolean _gimp_wire_read_string (GIOChannel *channel,
gchar **data,
gint count,
gpointer user_data) G_GNUC_INTERNAL;
gboolean _gimp_wire_read_color (GIOChannel *channel,
GimpRGB *data,
gint count,
gpointer user_data) G_GNUC_INTERNAL;
gboolean _gimp_wire_write_int32 (GIOChannel *channel,
const guint32 *data,
gint count,
@ -121,6 +125,10 @@ gboolean _gimp_wire_write_string (GIOChannel *channel,
gchar **data,
gint count,
gpointer user_data) G_GNUC_INTERNAL;
gboolean _gimp_wire_write_color (GIOChannel *channel,
const GimpRGB *data,
gint count,
gpointer user_data) G_GNUC_INTERNAL;
G_END_DECLS