some minor code cleanup.

2003-10-17  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpdnd.c: some minor code cleanup.

	* libgimpcolor/gimpcolorspace.c: removed trailing whitespace.
This commit is contained in:
Sven Neumann 2003-10-16 22:03:20 +00:00 committed by Sven Neumann
parent 2d1bb81d13
commit 4c695c22bb
3 changed files with 96 additions and 97 deletions

View File

@ -1,3 +1,9 @@
2003-10-17 Sven Neumann <sven@gimp.org>
* app/widgets/gimpdnd.c: some minor code cleanup.
* libgimpcolor/gimpcolorspace.c: removed trailing whitespace.
2003-10-16 Dave Neary <bolsh@gimp.org> 2003-10-16 Dave Neary <bolsh@gimp.org>
* libgimpcolor/gimpcolorspace.c: Corrected mistake - two * libgimpcolor/gimpcolorspace.c: Corrected mistake - two

View File

@ -765,13 +765,13 @@ gimp_dnd_set_file_data (GtkWidget *widget,
if (format != 8) if (format != 8)
{ {
g_warning ("Received invalid file data\n"); g_warning ("Received invalid file data!");
return; return;
} }
buffer = (gchar *) vals; buffer = (gchar *) vals;
g_print ("%s: raw buffer >>%s<<\n", G_GNUC_FUNCTION, buffer); g_print ("gimp_dnd_set_file_data: raw buffer >>%s<<\n", buffer);
{ {
gchar name_buffer[1024]; gchar name_buffer[1024];
@ -781,7 +781,7 @@ gimp_dnd_set_file_data (GtkWidget *widget,
gchar *name = name_buffer; gchar *name = name_buffer;
gint len = 0; gint len = 0;
while ((*buffer != 0) && (*buffer != '\n') && len < 1024) while (len < sizeof (name_buffer) && *buffer && *buffer != '\n')
{ {
*name++ = *buffer++; *name++ = *buffer++;
len++; len++;
@ -790,14 +790,10 @@ gimp_dnd_set_file_data (GtkWidget *widget,
break; break;
if (*(name - 1) == 0xd) /* gmc uses RETURN+NEWLINE as delimiter */ if (*(name - 1) == 0xd) /* gmc uses RETURN+NEWLINE as delimiter */
*(name - 1) = '\0'; len--;
else
*name = '\0';
name = name_buffer; if (len > 2)
files = g_list_append (files, g_strndup (name_buffer, len));
if (name && strlen (name) > 2)
files = g_list_append (files, g_strdup (name));
if (*buffer) if (*buffer)
buffer++; buffer++;
@ -806,8 +802,7 @@ gimp_dnd_set_file_data (GtkWidget *widget,
if (files) if (files)
{ {
(* (GimpDndDropFileFunc) set_file_func) (widget, files, (* (GimpDndDropFileFunc) set_file_func) (widget, files, set_file_data);
set_file_data);
g_list_foreach (files, (GFunc) g_free, NULL); g_list_foreach (files, (GFunc) g_free, NULL);
g_list_free (files); g_list_free (files);
@ -929,13 +924,14 @@ gimp_dnd_open_files (GtkWidget *widget,
for (list = files; list; list = g_list_next (list)) for (list = files; list; list = g_list_next (list))
{ {
const gchar *dnd_crap; const gchar *dnd_crap = list->data;
gchar *filename; gchar *filename;
gchar *uri = NULL; gchar *uri = NULL;
dnd_crap = (const gchar *) list->data; if (!dnd_crap)
continue;
g_print ("%s: trying to convert \"%s\" to an uri...\n", G_GNUC_FUNCTION, g_print ("gimp_dnd_open_files: trying to convert \"%s\" to an uri...\n",
dnd_crap); dnd_crap);
filename = g_filename_from_uri (dnd_crap, NULL, NULL); filename = g_filename_from_uri (dnd_crap, NULL, NULL);
@ -948,31 +944,30 @@ gimp_dnd_open_files (GtkWidget *widget,
} }
else /* else to evil things... */ else /* else to evil things... */
{ {
filename = (gchar *) dnd_crap; const gchar *start = dnd_crap;
if (! strncmp (dnd_crap, "file://", strlen ("file://"))) if (! strncmp (dnd_crap, "file://", strlen ("file://")))
{ {
filename += strlen ("file://"); start += strlen ("file://");
} }
else if (! strncmp (dnd_crap, "file:", strlen ("file:"))) else if (! strncmp (dnd_crap, "file:", strlen ("file:")))
{ {
filename += strlen ("file:"); start += strlen ("file:");
} }
if (filename != (gchar *) dnd_crap) if (start != dnd_crap)
{ {
/* try if we got a "file:" uri in the local filename encoding */ /* try if we got a "file:" uri in the local filename encoding */
gchar *unescaped_filename; gchar *unescaped_filename;
if (strstr (filename, "%")) if (strstr (filename, "%"))
{ {
unescaped_filename = gimp_unescape_uri_string (filename, -1, unescaped_filename = gimp_unescape_uri_string (start, -1,
"/", FALSE); "/", FALSE);
} }
else else
{ {
unescaped_filename = g_strdup (filename); unescaped_filename = g_strdup (start);
} }
uri = g_filename_to_uri (unescaped_filename, NULL, NULL); uri = g_filename_to_uri (unescaped_filename, NULL, NULL);
@ -988,27 +983,24 @@ gimp_dnd_open_files (GtkWidget *widget,
} }
} }
g_print ("%s: ...trying to open resulting uri \"%s\"\n", g_print ("gimp_dnd_open_files: ...trying to open resulting uri \"%s\"\n",
G_GNUC_FUNCTION, uri); uri);
{ {
GimpImage *gimage; GimpImage *gimage;
GimpPDBStatusType status; GimpPDBStatusType status;
GError *error = NULL; GError *error = NULL;
gimage = file_open_with_display (the_gimp, uri, gimage = file_open_with_display (the_gimp, uri, &status, &error);
&status, &error);
if (! gimage && status != GIMP_PDB_CANCEL) if (! gimage && status != GIMP_PDB_CANCEL)
{ {
gchar *filename; gchar *filename = file_utils_uri_to_utf8_filename (uri);
filename = file_utils_uri_to_utf8_filename (uri);
g_message (_("Opening '%s' failed:\n\n%s"), g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message); filename, error->message);
g_clear_error (&error);
g_clear_error (&error);
g_free (filename); g_free (filename);
} }
} }
@ -1081,7 +1073,7 @@ gimp_dnd_set_color_data (GtkWidget *widget,
if ((format != 16) || (length != 8)) if ((format != 16) || (length != 8))
{ {
g_warning ("Received invalid color data\n"); g_warning ("Received invalid color data!");
return; return;
} }
@ -1413,12 +1405,11 @@ gimp_dnd_set_image_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("%s(): received invalid image ID data", G_GNUC_FUNCTION); g_warning ("Received invalid image ID data!");
return; return;
} }
id = (gchar *) vals; id = (gchar *) vals;
ID = atoi (id); ID = atoi (id);
if (! ID) if (! ID)
@ -1475,7 +1466,7 @@ gimp_dnd_set_item_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid item ID data"); g_warning ("Received invalid item ID data!");
return; return;
} }
@ -1544,7 +1535,7 @@ gimp_dnd_set_brush_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid brush data\n"); g_warning ("Received invalid brush data!");
return; return;
} }
@ -1583,7 +1574,7 @@ gimp_dnd_set_pattern_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid pattern data\n"); g_warning ("Received invalid pattern data!");
return; return;
} }
@ -1620,7 +1611,7 @@ gimp_dnd_set_gradient_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid gradient data\n"); g_warning ("Received invalid gradient data!");
return; return;
} }
@ -1657,7 +1648,7 @@ gimp_dnd_set_palette_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid palette data\n"); g_warning ("Received invalid palette data!");
return; return;
} }
@ -1694,7 +1685,7 @@ gimp_dnd_set_font_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid font data\n"); g_warning ("Received invalid font data!");
return; return;
} }
@ -1730,7 +1721,7 @@ gimp_dnd_set_buffer_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid buffer data\n"); g_warning ("Received invalid buffer data!");
return; return;
} }
@ -1763,7 +1754,7 @@ gimp_dnd_set_imagefile_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid buffer data\n"); g_warning ("Received invalid buffer data!");
return; return;
} }
@ -1796,7 +1787,7 @@ gimp_dnd_set_template_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid buffer data\n"); g_warning ("Received invalid buffer data!");
return; return;
} }
@ -1829,7 +1820,7 @@ gimp_dnd_set_tool_data (GtkWidget *widget,
if ((format != 8) || (length < 1)) if ((format != 8) || (length < 1))
{ {
g_warning ("Received invalid tool data\n"); g_warning ("Received invalid tool data!");
return; return;
} }

View File

@ -307,7 +307,8 @@ gimp_hsl_to_rgb (const GimpHSL *hsl,
/** /**
* gimp_rgb_to_cmyk: * gimp_rgb_to_cmyk:
* @rgb: A value in the RGB colorspace * @rgb: A value in the RGB colorspace
* @pullout: A scaling value (0-1) indicating how much black should be pulled out * @pullout: A scaling value (0-1) indicating how much black should be
* pulled out
* @cmyk: The input value naively converted to the CMYK colorspace * @cmyk: The input value naively converted to the CMYK colorspace
* *
* Does a naive conversion from RGB to CMYK colorspace. A simple * Does a naive conversion from RGB to CMYK colorspace. A simple
@ -395,11 +396,11 @@ gimp_cmyk_to_rgb (const GimpCMYK *cmyk,
#define GIMP_RETURN_RGB(x, y, z) { rgb->r = x; rgb->g = y; rgb->b = z; return; } #define GIMP_RETURN_RGB(x, y, z) { rgb->r = x; rgb->g = y; rgb->b = z; return; }
/***************************************************************************** /****************************************************************************
* Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. * Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms.
* Pure red always maps to 6 in this implementation. Therefore UNDEFINED can * Pure red always maps to 6 in this implementation. Therefore UNDEFINED can
* be defined as 0 in situations where only unsigned numbers are desired. * be defined as 0 in situations where only unsigned numbers are desired.
*****************************************************************************/ ****************************************************************************/
/** /**
* gimp_rgb_to_hwb: * gimp_rgb_to_hwb:
@ -522,11 +523,12 @@ gimp_hwb_to_rgb (gdouble hue,
* @green: The green channel value, returns the Saturation channel * @green: The green channel value, returns the Saturation channel
* @blue: The blue channel value, returns the Value channel * @blue: The blue channel value, returns the Value channel
* *
* The arguments are pointers to int representing channel values in the * The arguments are pointers to int representing channel values in
* RGB colorspace, and the values pointed to are all in the range [0, 255]. * the RGB colorspace, and the values pointed to are all in the range
* [0, 255].
* *
* The function changes the arguments to point to the HSV value corresponding, * The function changes the arguments to point to the HSV value
* with the returned values in the following * corresponding, with the returned values in the following
* ranges: H [0, 360], S [0, 255], V [0, 255]. * ranges: H [0, 360], S [0, 255], V [0, 255].
**/ **/
void void