Commit de5af18f authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

rewrote so gcc-3.0 doesn't complain.

2001-10-29  Sven Neumann  <sven@gimp.org>

	* app/base/temp-buf.c (temp_buf_to_gray): rewrote so gcc-3.0 doesn't
	complain.

	* app/widgets/gimpfontselection-dialog.c: use g_ascii_strcasecmp().

	* libgimp/gimpintl.h
	* libgimp/stdplugins-intl.h
	* plug-ins/script-fu/script-fu-intl.h: don't call gtk_set_locale()
	since gtk_init() does it for us now. Don't set LC_NUMERIC to "C".
	INIT_I18N_UI() is the same as INIT_I18N_UI() now.

	* app/devices.c
	* app/gimprc.c
	* app/core/gimpbrushgenerated.c
	* app/core/gimpgradient.c
	* app/gui/color-notebook.c
	* app/gui/gradients-commands.c
	* plug-ins/gfig/gfig.c
	* plug-ins/gflare/gflare.c
	* plug-ins/gimpressionist/presets.c
	* plug-ins/ifscompose/ifscompose_storage.c: use g_ascii_formatd() and
	g_ascii_strtod() to serialize and deserialize floats. These functions
	are locale-independent. There are probably more places that need to be
	fixed in this fashion.

	* plug-ins/script-fu/script-fu-console.c
	* plug-ins/script-fu/script-fu-scripts.c
	* plug-ins/script-fu/script-fu-server.c
	* plug-ins/script-fu/script-fu.c: s/INIT_I18N_UI/INIT_I18N/

	* tools/gimp-remote.c
	* app/widgets/gimpwidgets-utils.c
	* app/core/gimpimage-contiguous-region.c
	* app/paint-funcs/paint-funcs-indexeda.c
	* app/paint-funcs/paint-funcs.c
	* app/tools/gimppathtool.c
	* app/tools/path_tool.c
	* modules/colorsel_triangle.c
	* plug-ins/common/mpeg.c
	* plug-ins/imagemap/imap_csim_parse.c: cleanups
parent 05e15eb1
2001-10-29 Sven Neumann <sven@gimp.org>
* app/base/temp-buf.c (temp_buf_to_gray): rewrote so gcc-3.0 doesn't
complain.
* app/widgets/gimpfontselection-dialog.c: use g_ascii_strcasecmp().
* libgimp/gimpintl.h
* libgimp/stdplugins-intl.h
* plug-ins/script-fu/script-fu-intl.h: don't call gtk_set_locale()
since gtk_init() does it for us now. Don't set LC_NUMERIC to "C".
INIT_I18N_UI() is the same as INIT_I18N_UI() now.
* app/devices.c
* app/gimprc.c
* app/core/gimpbrushgenerated.c
* app/core/gimpgradient.c
* app/gui/color-notebook.c
* app/gui/gradients-commands.c
* plug-ins/gfig/gfig.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/presets.c
* plug-ins/ifscompose/ifscompose_storage.c: use g_ascii_formatd() and
g_ascii_strtod() to serialize and deserialize floats. These functions
are locale-independent. There are probably more places that need to be
fixed in this fashion.
* plug-ins/script-fu/script-fu-console.c
* plug-ins/script-fu/script-fu-scripts.c
* plug-ins/script-fu/script-fu-server.c
* plug-ins/script-fu/script-fu.c: s/INIT_I18N_UI/INIT_I18N/
* tools/gimp-remote.c
* app/widgets/gimpwidgets-utils.c
* app/core/gimpimage-contiguous-region.c
* app/paint-funcs/paint-funcs-indexeda.c
* app/paint-funcs/paint-funcs.c
* app/tools/gimppathtool.c
* app/tools/path_tool.c
* modules/colorsel_triangle.c
* plug-ins/common/mpeg.c
* plug-ins/imagemap/imap_csim_parse.c: cleanups
2001-10-29 Michael Natterer <mitch@gimp.org>
Cleanup weekend...
......@@ -141,7 +184,8 @@
* app/*/makefile.msc : updated
* app/file/makefile.msc app/display/makefile.msc : new files
* app/user_install.c : make the G_OS_WIN32 part compile again (fn -> filename)
* app/user_install.c : make the G_OS_WIN32 part compile again
(fn -> filename)
* app/core/gimptoolinfo.c (gimp_tool_info_init) : cosmetic change,
make implementation signature static like the local prototype
......
......@@ -159,6 +159,7 @@ gradients_save_as_pov_ok_callback (GtkWidget *widget,
const gchar *filename;
FILE *file;
GimpGradientSegment *seg;
gchar buf[3][G_ASCII_DTOSTR_BUF_SIZE];
filesel = GTK_FILE_SELECTION (gtk_widget_get_toplevel (widget));
filename = gtk_file_selection_get_filename (filesel);
......@@ -179,28 +180,46 @@ gradients_save_as_pov_ok_callback (GtkWidget *widget,
for (seg = gradient->segments; seg; seg = seg->next)
{
/* Left */
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->left_color.r);
g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->left_color.g);
g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->left_color.b);
g_ascii_formatd (buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f",
1.0 - seg->left_color.a);
fprintf (file, "\t[%f color rgbt <%s, %s, %s, %s>]\n",
seg->left,
seg->left_color.r,
seg->left_color.g,
seg->left_color.b,
1.0 - seg->left_color.a);
buf[0], buf[1], buf[2], buf[3]);
/* Middle */
g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f",
(seg->left_color.r + seg->right_color.r) / 2.0);
g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f",
(seg->left_color.g + seg->right_color.g) / 2.0);
g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f",
(seg->left_color.b + seg->right_color.b) / 2.0);
g_ascii_formatd (buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f",
1.0 - (seg->left_color.a + seg->right_color.a) / 2.0);
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
seg->middle,
(seg->left_color.r + seg->right_color.r) / 2.0,
(seg->left_color.g + seg->right_color.g) / 2.0,
(seg->left_color.b + seg->right_color.b) / 2.0,
1.0 - (seg->left_color.a + seg->right_color.a) / 2.0);
buf[0], buf[1], buf[2], buf[3]);
/* Right */
g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->right_color.r);
g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->right_color.g);
g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->right_color.b);
g_ascii_formatd (buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f",
1.0 - seg->right_color.a);
fprintf (file, "\t[%f color rgbt <%f, %f, %f, %f>]\n",
seg->right,
seg->right_color.r,
seg->right_color.g,
seg->right_color.b,
1.0 - seg->right_color.a);
buf[0], buf[1], buf[2], buf[3]);
}
fprintf (file, "} /* color_map */\n");
......
......@@ -107,11 +107,12 @@ temp_buf_to_gray (TempBuf *src_buf,
while (num_bytes--)
{
*dest++ = *src++; /* alpha channel */
pix = INTENSITY (*src++, *src++, *src++);
*dest++ = src[0]; /* alpha channel */
pix = INTENSITY (src[1], src[2], src[3]);
*dest++ = (guchar) pix;
src += 4;
}
}
......
......@@ -114,6 +114,7 @@ gimp_brush_generated_save (GimpData *data)
{
GimpBrushGenerated *brush;
FILE *fp;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (data), FALSE);
......@@ -137,19 +138,29 @@ gimp_brush_generated_save (GimpData *data)
fprintf (fp, "%.255s\n", GIMP_OBJECT (brush)->name);
/* write brush spacing */
fprintf (fp, "%f\n", (gfloat) GIMP_BRUSH (brush)->spacing);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
GIMP_BRUSH (brush)->spacing));
/* write brush radius */
fprintf (fp, "%f\n", brush->radius);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->radius));
/* write brush hardness */
fprintf (fp, "%f\n", brush->hardness);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->hardness));
/* write brush aspect_ratio */
fprintf (fp, "%f\n", brush->aspect_ratio);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->aspect_ratio));
/* write brush angle */
fprintf (fp, "%f\n", brush->angle);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->angle));
fclose (fp);
......@@ -351,8 +362,6 @@ gimp_brush_generated_load (const gchar *filename)
GimpBrushGenerated *brush;
FILE *fp;
gchar string[256];
gfloat fl;
gfloat version;
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
......@@ -365,8 +374,8 @@ gimp_brush_generated_load (const gchar *filename)
/* make sure we are reading a compatible version */
fgets (string, 255, fp);
sscanf (string, "%f", &version);
g_return_val_if_fail (version < 2.0, NULL);
if (strncmp (string, "1.0", 3))
return NULL;
/* create new brush */
brush = GIMP_BRUSH_GENERATED (g_object_new (GIMP_TYPE_BRUSH_GENERATED, NULL));
......@@ -382,24 +391,24 @@ gimp_brush_generated_load (const gchar *filename)
gimp_object_set_name (GIMP_OBJECT (brush), string);
/* read brush spacing */
fscanf (fp, "%f", &fl);
GIMP_BRUSH (brush)->spacing = fl;
fgets (string, 255, fp);
GIMP_BRUSH (brush)->spacing = g_ascii_strtod (string, NULL);
/* read brush radius */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_radius (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_radius (brush, g_ascii_strtod (string, NULL));
/* read brush hardness */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_hardness (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_hardness (brush, g_ascii_strtod (string, NULL));
/* read brush aspect_ratio */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_aspect_ratio (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_aspect_ratio (brush, g_ascii_strtod (string, NULL));
/* read brush angle */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_angle (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_angle (brush, g_ascii_strtod (string, NULL));
fclose (fp);
......
......@@ -114,6 +114,7 @@ gimp_brush_generated_save (GimpData *data)
{
GimpBrushGenerated *brush;
FILE *fp;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (data), FALSE);
......@@ -137,19 +138,29 @@ gimp_brush_generated_save (GimpData *data)
fprintf (fp, "%.255s\n", GIMP_OBJECT (brush)->name);
/* write brush spacing */
fprintf (fp, "%f\n", (gfloat) GIMP_BRUSH (brush)->spacing);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
GIMP_BRUSH (brush)->spacing));
/* write brush radius */
fprintf (fp, "%f\n", brush->radius);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->radius));
/* write brush hardness */
fprintf (fp, "%f\n", brush->hardness);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->hardness));
/* write brush aspect_ratio */
fprintf (fp, "%f\n", brush->aspect_ratio);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->aspect_ratio));
/* write brush angle */
fprintf (fp, "%f\n", brush->angle);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->angle));
fclose (fp);
......@@ -351,8 +362,6 @@ gimp_brush_generated_load (const gchar *filename)
GimpBrushGenerated *brush;
FILE *fp;
gchar string[256];
gfloat fl;
gfloat version;
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
......@@ -365,8 +374,8 @@ gimp_brush_generated_load (const gchar *filename)
/* make sure we are reading a compatible version */
fgets (string, 255, fp);
sscanf (string, "%f", &version);
g_return_val_if_fail (version < 2.0, NULL);
if (strncmp (string, "1.0", 3))
return NULL;
/* create new brush */
brush = GIMP_BRUSH_GENERATED (g_object_new (GIMP_TYPE_BRUSH_GENERATED, NULL));
......@@ -382,24 +391,24 @@ gimp_brush_generated_load (const gchar *filename)
gimp_object_set_name (GIMP_OBJECT (brush), string);
/* read brush spacing */
fscanf (fp, "%f", &fl);
GIMP_BRUSH (brush)->spacing = fl;
fgets (string, 255, fp);
GIMP_BRUSH (brush)->spacing = g_ascii_strtod (string, NULL);
/* read brush radius */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_radius (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_radius (brush, g_ascii_strtod (string, NULL));
/* read brush hardness */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_hardness (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_hardness (brush, g_ascii_strtod (string, NULL));
/* read brush aspect_ratio */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_aspect_ratio (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_aspect_ratio (brush, g_ascii_strtod (string, NULL));
/* read brush angle */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_angle (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_angle (brush, g_ascii_strtod (string, NULL));
fclose (fp);
......
......@@ -114,6 +114,7 @@ gimp_brush_generated_save (GimpData *data)
{
GimpBrushGenerated *brush;
FILE *fp;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_BRUSH_GENERATED (data), FALSE);
......@@ -137,19 +138,29 @@ gimp_brush_generated_save (GimpData *data)
fprintf (fp, "%.255s\n", GIMP_OBJECT (brush)->name);
/* write brush spacing */
fprintf (fp, "%f\n", (gfloat) GIMP_BRUSH (brush)->spacing);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
GIMP_BRUSH (brush)->spacing));
/* write brush radius */
fprintf (fp, "%f\n", brush->radius);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->radius));
/* write brush hardness */
fprintf (fp, "%f\n", brush->hardness);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->hardness));
/* write brush aspect_ratio */
fprintf (fp, "%f\n", brush->aspect_ratio);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->aspect_ratio));
/* write brush angle */
fprintf (fp, "%f\n", brush->angle);
fprintf (fp, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
brush->angle));
fclose (fp);
......@@ -351,8 +362,6 @@ gimp_brush_generated_load (const gchar *filename)
GimpBrushGenerated *brush;
FILE *fp;
gchar string[256];
gfloat fl;
gfloat version;
if ((fp = fopen (filename, "rb")) == NULL)
return NULL;
......@@ -365,8 +374,8 @@ gimp_brush_generated_load (const gchar *filename)
/* make sure we are reading a compatible version */
fgets (string, 255, fp);
sscanf (string, "%f", &version);
g_return_val_if_fail (version < 2.0, NULL);
if (strncmp (string, "1.0", 3))
return NULL;
/* create new brush */
brush = GIMP_BRUSH_GENERATED (g_object_new (GIMP_TYPE_BRUSH_GENERATED, NULL));
......@@ -382,24 +391,24 @@ gimp_brush_generated_load (const gchar *filename)
gimp_object_set_name (GIMP_OBJECT (brush), string);
/* read brush spacing */
fscanf (fp, "%f", &fl);
GIMP_BRUSH (brush)->spacing = fl;
fgets (string, 255, fp);
GIMP_BRUSH (brush)->spacing = g_ascii_strtod (string, NULL);
/* read brush radius */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_radius (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_radius (brush, g_ascii_strtod (string, NULL));
/* read brush hardness */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_hardness (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_hardness (brush, g_ascii_strtod (string, NULL));
/* read brush aspect_ratio */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_aspect_ratio (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_aspect_ratio (brush, g_ascii_strtod (string, NULL));
/* read brush angle */
fscanf (fp, "%f", &fl);
gimp_brush_generated_set_angle (brush, fl);
fgets (string, 255, fp);
gimp_brush_generated_set_angle (brush, g_ascii_strtod (string, NULL));
fclose (fp);
......
......@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <glib-object.h>
......@@ -360,6 +361,8 @@ gimp_gradient_load (const gchar *filename)
for (i = 0; i < num_segments; i++)
{
gchar *end;
seg = gimp_gradient_segment_new ();
seg->prev = prev;
......@@ -371,27 +374,42 @@ gimp_gradient_load (const gchar *filename)
fgets (line, 1024, file);
if (sscanf (line, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%d%d",
&(seg->left), &(seg->middle), &(seg->right),
&(seg->left_color.r),
&(seg->left_color.g),
&(seg->left_color.b),
&(seg->left_color.a),
&(seg->right_color.r),
&(seg->right_color.g),
&(seg->right_color.b),
&(seg->right_color.a),
&type, &color) != 13)
{
seg->left = g_ascii_strtod (line, &end);
if (end && errno != ERANGE)
seg->middle = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->right = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->left_color.r = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->left_color.g = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->left_color.b = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->left_color.a = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->right_color.r = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->right_color.g = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->right_color.b = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->right_color.a = g_ascii_strtod (end, &end);
if (errno != ERANGE &&
sscanf (end, "%d %d", &type, &color) == 2)
{
seg->type = (GimpGradientSegmentType) type;
seg->color = (GimpGradientSegmentColor) color;
}
else
{
g_message ("%s(): badly formatted gradient segment %d in \"%s\" --- "
"bad things may happen soon",
G_GNUC_FUNCTION, i, filename);
}
else
{
seg->type = (GimpGradientSegmentType) type;
seg->color = (GimpGradientSegmentColor) color;
}
prev = seg;
}
......@@ -463,16 +481,23 @@ gimp_gradient_save (GimpData *data)
for (seg = gradient->segments; seg; seg = seg->next)
{
fprintf (file, "%f %f %f %f %f %f %f %f %f %f %f %d %d\n",
seg->left, seg->middle, seg->right,
seg->left_color.r,
seg->left_color.g,
seg->left_color.b,
seg->left_color.a,
seg->right_color.r,
seg->right_color.g,
seg->right_color.b,
seg->right_color.a,
gchar buf[11][G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->left);
g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->middle);
g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->right);
g_ascii_formatd (buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->left_color.r);
g_ascii_formatd (buf[4], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->left_color.g);
g_ascii_formatd (buf[5], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->left_color.b);
g_ascii_formatd (buf[6], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->left_color.a);
g_ascii_formatd (buf[7], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->right_color.r);
g_ascii_formatd (buf[8], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->right_color.g);
g_ascii_formatd (buf[9], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->right_color.b);
g_ascii_formatd (buf[10], G_ASCII_DTOSTR_BUF_SIZE, "%f", seg->right_color.a);
fprintf (file, "%s %s %s %s %s %s %s %s %s %s %s %d %d\n",
buf[0], buf[1], buf[2], buf[3], buf[4],
buf[5], buf[6], buf[7], buf[8], buf[9], buf[10],
(gint) seg->type,
(gint) seg->color);
}
......
......@@ -18,6 +18,8 @@
#include "config.h"
#include <stdlib.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"
......
......@@ -665,16 +665,25 @@ devices_write_rc_device (DeviceInfo *device_info,
{
GimpRGB color;
gchar buf[3][G_ASCII_DTOSTR_BUF_SIZE];
gimp_context_get_foreground (device_info->context, &color);
fprintf (fp, "\n (foreground (color-rgb %f %f %f))",
color.r, color.g, color.b);
g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.r);
g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.g);
g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.b);
fprintf (fp, "\n (foreground (color-rgb %s %s %s))",
buf[0], buf[1], buf[2]);
gimp_context_get_background (device_info->context, &color);
fprintf (fp, "\n (background (color-rgb %f %f %f))",
color.r, color.g, color.b);
g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.r);
g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.g);
g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.b);
fprintf (fp, "\n (background (color-rgb %s %s %s))",
buf[0], buf[1], buf[2]);
}
if (gimp_context_get_brush (device_info->context))
......
......@@ -1290,11 +1290,19 @@ color_history_write (FILE *fp)
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
{
fprintf (fp, "\n (color-rgba %f %f %f %f)",
color_history[i].r,
color_history[i].g,
color_history[i].b,
color_history[i].a);
gchar buf[4][G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_formatd (buf[0],
G_ASCII_DTOSTR_BUF_SIZE, "%f", color_history[i].r);
g_ascii_formatd (buf[1],
G_ASCII_DTOSTR_BUF_SIZE, "%f", color_history[i].g);
g_ascii_formatd (buf[2],
G_ASCII_DTOSTR_BUF_SIZE, "%f", color_history[i].b);
g_ascii_formatd (buf[3],
G_ASCII_DTOSTR_BUF_SIZE, "%f", color_history[i].a);
fprintf (fp, "\n (color-rgba %s %s %s %s)",
buf[0], buf[1], buf[2], buf[3]);
}
fprintf (fp, ")\n\n");
......
......@@ -166,7 +166,6 @@ static gint parse_unknown (gchar *token_sym);
static inline gchar * string_to_str (gpointer val1p, gpointer val2p);
static inline gchar * path_to_str (gpointer val1p, gpointer val2p);
static inline gchar * double_to_str (gpointer val1p, gpointer val2p);
static inline gchar * float_to_str (gpointer val1p, gpointer val2p);
static inline gchar * int_to_str (gpointer val1p, gpointer val2p);
static inline gchar * boolean_to_str (gpointer val1p, gpointer val2p);
static inline gchar * position_to_str (gpointer val1p, gpointer val2p);
......@@ -2857,9 +2856,8 @@ gimprc_value_to_str (const gchar *name)
case TT_PATH:
return path_to_str (func->val1p, func->val2p);
case TT_DOUBLE:
return double_to_str (func->val1p, func->val2p);
case TT_FLOAT:
return float_to_str (func->val1p, func->val2p);
return double_to_str (func->val1p, func->val2p);
case TT_INT:
return int_to_str (func->val1p, func->val2p);
case TT_BOOLEAN:
......@@ -2924,14 +2922,10 @@ static inline gchar *
double_to_str (gpointer val1p,
gpointer val2p)
{
return g_strdup_printf ("%f", *((gdouble *)val1p));
}
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
static inline gchar *
float_to_str (gpointer val1p,
gpointer val2p)
{
return g_strdup_printf ("%f", (gdouble)(*((float *)val1p)));
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", *((gdouble *)val1p));
return g_strdup (buf);
}
static inline gchar *
......
......@@ -1290,11 +1290,19 @@ color_history_write (FILE *fp)
for (i = 0; i < COLOR_HISTORY_SIZE; i++)
{
fprintf (fp, "\n (color-rgba %f %f %f %f)",
color_history[i].r,
color_history[i].g,
color_history[i].b,
color_history[i].a);
gchar buf[4][G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_formatd (buf[0],
G_ASCII_DTOSTR_BUF_SIZE, "%f", color_history[i].r);
g_ascii_formatd (buf[1],
G_ASCII_DTOSTR_BUF_SIZE, "%f", color_history[i].g);
g_ascii_formatd (buf[2],
G_ASCII_DTOSTR_BUF_SIZE, "%f", color_history[i].b);
g_ascii_formatd (buf[3],
G_ASCII_DTOSTR_BUF_SIZE, "%f", color_history[i].a);
fprintf (fp, "\n (color-rgba %s %s %s %s)",
buf[0], buf[1], buf[2], buf[3]);
}
fprintf (fp, ")\n\n");
......
......@@ -665,16 +665,25 @@ devices_write_rc_device (DeviceInfo *device_info,
{
GimpRGB color;
gchar buf[3][G_ASCII_DTOSTR_BUF_SIZE];
gimp_context_get_foreground (device_info->context, &color);
fprintf (fp, "\n (foreground (color-rgb %f %f %f))",
color.r, color.g, color.b);
g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.r);
g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.g);
g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.b);
fprintf (fp, "\n (foreground (color-rgb %s %s %s))",
buf[0], buf[1], buf[2]);
gimp_context_get_background (device_info->context, &color);
fprintf (fp, "\n (background (color-rgb %f %f %f))",
color.r, color.g, color.b);
g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", color.r);