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> 2006-02-22 Simon Budig <simon@gimp.org>
* app/vectors/gimpvectors-import.c: fix the import of svg circles. * app/vectors/gimpvectors-import.c: fix the import of svg circles.

View File

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

View File

@ -23,6 +23,8 @@
#include <glib.h> #include <glib.h>
#include <libgimpcolor/gimpcolortypes.h>
#include "gimpwire.h" #include "gimpwire.h"
@ -428,6 +430,18 @@ _gimp_wire_read_string (GIOChannel *channel,
return TRUE; 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 gboolean
_gimp_wire_write_int32 (GIOChannel *channel, _gimp_wire_write_int32 (GIOChannel *channel,
const guint32 *data, const guint32 *data,
@ -570,6 +584,18 @@ _gimp_wire_write_string (GIOChannel *channel,
return TRUE; 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 static guint
gimp_wire_hash (const guint32 *key) gimp_wire_hash (const guint32 *key)
{ {

View File

@ -101,6 +101,10 @@ gboolean _gimp_wire_read_string (GIOChannel *channel,
gchar **data, gchar **data,
gint count, gint count,
gpointer user_data) G_GNUC_INTERNAL; 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, gboolean _gimp_wire_write_int32 (GIOChannel *channel,
const guint32 *data, const guint32 *data,
gint count, gint count,
@ -121,6 +125,10 @@ gboolean _gimp_wire_write_string (GIOChannel *channel,
gchar **data, gchar **data,
gint count, gint count,
gpointer user_data) G_GNUC_INTERNAL; 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 G_END_DECLS