Commit 2bea01ca authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

libgimp/gimpbrushmenu.c libgimp/gimpfontmenu.c libgimp/gimpgradientmenu.c

2005-03-23  Sven Neumann  <sven@gimp.org>

	* libgimp/gimpbrushmenu.c
	* libgimp/gimpfontmenu.c
	* libgimp/gimpgradientmenu.c
	* libgimp/gimppalettemenu.c
	* libgimp/gimppatternmenu.c: accept names passed over DND no matter
	whether they are NULL-terminated or not.

	* app/widgets/gimpselectiondata.c: same change here, also
	UTF8-validate the selection data before accepting it.
parent d3b0374e
2005-03-23 Sven Neumann <sven@gimp.org>
* libgimp/gimpbrushmenu.c
* libgimp/gimpfontmenu.c
* libgimp/gimpgradientmenu.c
* libgimp/gimppalettemenu.c
* libgimp/gimppatternmenu.c: accept names passed over DND no matter
whether they are NULL-terminated or not.
* app/widgets/gimpselectiondata.c: same change here, also
UTF8-validate the selection data before accepting it.
2005-03-23 Sven Neumann <sven@gimp.org>
* libgimp/gimpbrushmenu.c
......
......@@ -181,7 +181,7 @@ gimp_selection_data_get_uri_list (GtkSelectionData *selection)
GList *crap_list = NULL;
GList *uri_list = NULL;
GList *list;
gchar *buffer;
const gchar *buffer;
g_return_val_if_fail (selection != NULL, NULL);
......@@ -191,7 +191,7 @@ gimp_selection_data_get_uri_list (GtkSelectionData *selection)
return NULL;
}
buffer = (gchar *) selection->data;
buffer = (const gchar *) selection->data;
D (g_print ("%s: raw buffer >>%s<<\n", G_STRFUNC, buffer));
......@@ -658,6 +658,19 @@ gimp_selection_data_set_viewable (GtkSelectionData *selection,
8, (const guchar *) name, strlen (name) + 1);
}
static gchar *
gimp_selection_data_get_name (GtkSelectionData *selection)
{
gchar *name = g_strndup (selection->data, selection->length);
if (g_utf8_validate (name, -1, NULL))
return name;
g_free (name);
return NULL;
}
GimpBrush *
gimp_selection_data_get_brush (GtkSelectionData *selection,
Gimp *gimp)
......@@ -674,7 +687,9 @@ gimp_selection_data_get_brush (GtkSelectionData *selection,
return NULL;
}
name = (gchar *) selection->data;
name = gimp_selection_data_get_name (selection);
if (! name)
return NULL;
if (strcmp (name, "Standard") == 0)
brush = GIMP_BRUSH (gimp_brush_get_standard ());
......@@ -682,6 +697,8 @@ gimp_selection_data_get_brush (GtkSelectionData *selection,
brush = (GimpBrush *)
gimp_container_get_child_by_name (gimp->brush_factory->container, name);
g_free (name);
return brush;
}
......@@ -701,7 +718,9 @@ gimp_selection_data_get_pattern (GtkSelectionData *selection,
return NULL;
}
name = (gchar *) selection->data;
name = gimp_selection_data_get_name (selection);
if (! name)
return NULL;
if (strcmp (name, "Standard") == 0)
pattern = GIMP_PATTERN (gimp_pattern_get_standard ());
......@@ -709,6 +728,8 @@ gimp_selection_data_get_pattern (GtkSelectionData *selection,
pattern = (GimpPattern *)
gimp_container_get_child_by_name (gimp->pattern_factory->container, name);
g_free (name);
return pattern;
}
......@@ -728,7 +749,9 @@ gimp_selection_data_get_gradient (GtkSelectionData *selection,
return NULL;
}
name = (gchar *) selection->data;
name = gimp_selection_data_get_name (selection);
if (! name)
return NULL;
if (strcmp (name, "Standard") == 0)
gradient = GIMP_GRADIENT (gimp_gradient_get_standard ());
......@@ -736,6 +759,8 @@ gimp_selection_data_get_gradient (GtkSelectionData *selection,
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container, name);
g_free (name);
return gradient;
}
......@@ -755,7 +780,9 @@ gimp_selection_data_get_palette (GtkSelectionData *selection,
return NULL;
}
name = (gchar *) selection->data;
name = gimp_selection_data_get_name (selection);
if (! name)
return NULL;
if (strcmp (name, "Standard") == 0)
palette = GIMP_PALETTE (gimp_palette_get_standard ());
......@@ -763,6 +790,8 @@ gimp_selection_data_get_palette (GtkSelectionData *selection,
palette = (GimpPalette *)
gimp_container_get_child_by_name (gimp->palette_factory->container, name);
g_free (name);
return palette;
}
......@@ -782,7 +811,9 @@ gimp_selection_data_get_font (GtkSelectionData *selection,
return NULL;
}
name = (gchar *) selection->data;
name = gimp_selection_data_get_name (selection);
if (! name)
return NULL;
if (strcmp (name, "Standard") == 0)
font = gimp_font_get_standard ();
......@@ -790,6 +821,8 @@ gimp_selection_data_get_font (GtkSelectionData *selection,
font = (GimpFont *)
gimp_container_get_child_by_name (gimp->fonts, name);
g_free (name);
return font;
}
......@@ -809,11 +842,15 @@ gimp_selection_data_get_buffer (GtkSelectionData *selection,
return NULL;
}
name = (gchar *) selection->data;
name = gimp_selection_data_get_name (selection);
if (! name)
return NULL;
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, name);
g_free (name);
return buffer;
}
......@@ -833,11 +870,15 @@ gimp_selection_data_get_imagefile (GtkSelectionData *selection,
return NULL;
}
name = (gchar *) selection->data;
name = gimp_selection_data_get_name (selection);
if (! name)
return NULL;
imagefile = (GimpImagefile *)
gimp_container_get_child_by_name (gimp->documents, name);
g_free (name);
return imagefile;
}
......@@ -857,11 +898,15 @@ gimp_selection_data_get_template (GtkSelectionData *selection,
return NULL;
}
name = (gchar *) selection->data;
name = gimp_selection_data_get_name (selection);
if (! name)
return NULL;
template = (GimpTemplate *)
gimp_container_get_child_by_name (gimp->templates, name);
g_free (name);
return template;
}
......@@ -881,7 +926,9 @@ gimp_selection_data_get_tool (GtkSelectionData *selection,
return NULL;
}
name = (gchar *) selection->data;
name = gimp_selection_data_get_name (selection);
if (! name)
return NULL;
if (strcmp (name, "gimp-standard-tool") == 0)
tool_info = gimp_tool_info_get_standard (gimp);
......@@ -889,5 +936,7 @@ gimp_selection_data_get_tool (GtkSelectionData *selection,
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list, name);
g_free (name);
return tool_info;
}
......@@ -604,18 +604,18 @@ gimp_brush_select_drag_data_received (GtkWidget *preview,
guint time,
GtkWidget *widget)
{
gchar *name;
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid brush data!");
return;
}
if (g_utf8_validate (selection->data, selection->length - 1, NULL))
{
gchar *name = g_strndup (selection->data, selection->length - 1);
name = g_strndup (selection->data, selection->length);
if (g_utf8_validate (name, -1, NULL))
gimp_brush_select_widget_set (widget, name, -1.0, -1, -1);
g_free (name);
}
}
......@@ -257,18 +257,18 @@ gimp_font_select_drag_data_received (GtkWidget *widget,
guint info,
guint time)
{
gchar *name;
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid font data!");
return;
}
if (g_utf8_validate (selection->data, selection->length - 1, NULL))
{
gchar *name = g_strndup (selection->data, selection->length - 1);
name = g_strndup (selection->data, selection->length);
if (g_utf8_validate (name, -1, NULL))
gimp_font_select_widget_set (widget, name);
g_free (name);
}
}
......@@ -257,18 +257,18 @@ gimp_font_select_drag_data_received (GtkWidget *widget,
guint info,
guint time)
{
gchar *name;
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid font data!");
return;
}
if (g_utf8_validate (selection->data, selection->length - 1, NULL))
{
gchar *name = g_strndup (selection->data, selection->length - 1);
name = g_strndup (selection->data, selection->length);
if (g_utf8_validate (name, -1, NULL))
gimp_font_select_widget_set (widget, name);
g_free (name);
}
}
......@@ -414,18 +414,18 @@ gimp_gradient_select_drag_data_received (GtkWidget *widget,
guint info,
guint time)
{
gchar *name;
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid gradient data!");
return;
}
if (g_utf8_validate (selection->data, selection->length - 1, NULL))
{
gchar *name = g_strndup (selection->data, selection->length - 1);
name = g_strndup (selection->data, selection->length);
if (g_utf8_validate (name, -1, NULL))
gimp_gradient_select_widget_set (widget, name);
g_free (name);
}
}
......@@ -264,18 +264,18 @@ gimp_palette_select_drag_data_received (GtkWidget *widget,
guint info,
guint time)
{
gchar *name;
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid palette data!");
return;
}
if (g_utf8_validate (selection->data, selection->length - 1, NULL))
{
gchar *name = g_strndup (selection->data, selection->length - 1);
name = g_strndup (selection->data, selection->length);
if (g_utf8_validate (name, -1, NULL))
gimp_palette_select_widget_set (widget, name);
g_free (name);
}
}
......@@ -498,18 +498,18 @@ gimp_pattern_select_drag_data_received (GtkWidget *preview,
guint time,
GtkWidget *widget)
{
gchar *name;
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid pattern data!");
return;
}
if (g_utf8_validate (selection->data, selection->length - 1, NULL))
{
gchar *name = g_strndup (selection->data, selection->length - 1);
name = g_strndup (selection->data, selection->length);
if (g_utf8_validate (name, -1, NULL))
gimp_pattern_select_widget_set (widget, name);
g_free (name);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment