Commit 114f747f authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

renamed the SVG related functions so that they deal with an anonymous data

2004-06-30  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpselectiondata.[ch]: renamed the SVG related
	functions so that they deal with an anonymous data stream that
	could as well be a PNG image.

	* app/widgets/gimpdnd.[ch]
	* app/widgets/gimpcontainertreeview-dnd.c: changed accordingly.

	* app/display/gimpdisplayshell-dnd.[ch]
	* app/vectors/gimpvectors-import.[ch]
	* app/widgets/gimpcontainertreeview-dnd.c
	* app/widgets/gimpvectorstreeview.c: use gsize for the length of
	the buffer.

	* app/widgets/gimpdnd.[ch]
	* app/widgets/widgets-enums.[ch]: added GIMP_DND_TYPE_PNG which isn't
	used yet.
parent 12355969
2004-06-30 Sven Neumann <sven@gimp.org>
* app/widgets/gimpselectiondata.[ch]: renamed the SVG related
functions so that they deal with an anonymous data stream that
could as well be a PNG image.
* app/widgets/gimpdnd.[ch]
* app/widgets/gimpcontainertreeview-dnd.c: changed accordingly.
* app/display/gimpdisplayshell-dnd.[ch]
* app/vectors/gimpvectors-import.[ch]
* app/widgets/gimpcontainertreeview-dnd.c
* app/widgets/gimpvectorstreeview.c: use gsize for the length of
the buffer.
* app/widgets/gimpdnd.[ch]
* app/widgets/widgets-enums.[ch]: added GIMP_DND_TYPE_PNG which isn't
used yet.
2004-06-30 Michael Natterer <mitch@gimp.org>
* app/core/gimppalette.[ch] (gimp_palette_add_entry): take
......
......@@ -152,7 +152,7 @@ gimp_display_shell_drop_vectors (GtkWidget *widget,
void
gimp_display_shell_drop_svg (GtkWidget *widget,
const gchar *svg_data,
gint svg_data_len,
gsize svg_data_len,
gpointer data)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
......
......@@ -28,7 +28,7 @@ void gimp_display_shell_drop_vectors (GtkWidget *widget,
gpointer data);
void gimp_display_shell_drop_svg (GtkWidget *widget,
const gchar *svg_data,
gint svg_data_length,
gsize svg_data_length,
gpointer data);
void gimp_display_shell_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
......
......@@ -90,7 +90,7 @@ typedef struct
static gboolean gimp_vectors_import (GimpImage *image,
const gchar *filename,
const gchar *str,
gint len,
gsize len,
gboolean merge,
gboolean scale,
gint position,
......@@ -197,7 +197,7 @@ gimp_vectors_import_file (GimpImage *image,
gboolean
gimp_vectors_import_buffer (GimpImage *image,
const gchar *buffer,
gint len,
gsize len,
gboolean merge,
gboolean scale,
gint position,
......@@ -215,7 +215,7 @@ static gboolean
gimp_vectors_import (GimpImage *image,
const gchar *filename,
const gchar *str,
gint len,
gsize len,
gboolean merge,
gboolean scale,
gint position,
......
......@@ -31,7 +31,7 @@ gboolean gimp_vectors_import_file (GimpImage *image,
GError **error);
gboolean gimp_vectors_import_buffer (GimpImage *image,
const gchar *buffer,
gint len,
gsize len,
gboolean merge,
gboolean scale,
gint position,
......
......@@ -386,16 +386,17 @@ gimp_container_tree_view_drag_data_received (GtkWidget *widget,
case GIMP_DND_TYPE_SVG_XML:
if (tree_view_class->drop_svg)
{
const gchar *svg_data;
gint svg_data_length;
const guchar *stream;
gsize stream_length;
svg_data = gimp_selection_data_get_svg (selection_data,
&svg_data_length);
stream = gimp_selection_data_get_stream (selection_data,
&stream_length);
if (svg_data)
if (stream)
{
tree_view_class->drop_svg (tree_view,
svg_data, svg_data_length,
(const gchar *) stream,
stream_length,
dest_viewable, drop_pos);
success = TRUE;
......
......@@ -93,7 +93,7 @@ struct _GimpContainerTreeViewClass
GtkTreeViewDropPosition drop_pos);
void (* drop_svg) (GimpContainerTreeView *tree_view,
const gchar *svg_data,
gint svg_data_length,
gsize svg_data_length,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos);
};
......
......@@ -123,14 +123,14 @@ static gboolean gimp_dnd_set_color_data (GtkWidget *widget,
gpointer set_color_data,
GtkSelectionData *selection);
static void gimp_dnd_get_svg_data (GtkWidget *widget,
GCallback get_svg_func,
gpointer get_svg_data,
static void gimp_dnd_get_stream_data (GtkWidget *widget,
GCallback get_stream_func,
gpointer get_stream_data,
GtkSelectionData *selection,
GdkAtom atom);
static gboolean gimp_dnd_set_svg_data (GtkWidget *widget,
GCallback set_svg_func,
gpointer set_svg_data,
static gboolean gimp_dnd_set_stream_data (GtkWidget *widget,
GCallback set_stream_func,
gpointer set_stream_data,
GtkSelectionData *selection);
static void gimp_dnd_get_image_data (GtkWidget *widget,
......@@ -267,6 +267,20 @@ static GimpDndDataDef dnd_data_defs[] =
gimp_dnd_set_color_data
},
{
GIMP_TARGET_PNG,
"gimp-dnd-get-png-func",
"gimp-dnd-get-png-data",
"gimp-dnd-set-png-func",
"gimp-dnd-set-png-data",
gimp_dnd_get_viewable_icon,
gimp_dnd_get_stream_data,
gimp_dnd_set_stream_data
},
{
GIMP_TARGET_SVG,
......@@ -277,8 +291,8 @@ static GimpDndDataDef dnd_data_defs[] =
"gimp-dnd-set-svg-data",
gimp_dnd_get_viewable_icon,
gimp_dnd_get_svg_data,
gimp_dnd_set_svg_data
gimp_dnd_get_stream_data,
gimp_dnd_set_stream_data
},
{
......@@ -291,8 +305,8 @@ static GimpDndDataDef dnd_data_defs[] =
"gimp-dnd-set-svg-xml-data",
gimp_dnd_get_viewable_icon,
gimp_dnd_get_svg_data,
gimp_dnd_set_svg_data
gimp_dnd_get_stream_data,
gimp_dnd_set_stream_data
},
{
......@@ -1088,56 +1102,55 @@ gimp_dnd_color_dest_remove (GtkWidget *widget)
}
/***********************/
/* svg dnd functions */
/***********************/
/**************************/
/* stream dnd functions */
/**************************/
static void
gimp_dnd_get_svg_data (GtkWidget *widget,
GCallback get_svg_func,
gpointer get_svg_data,
GtkSelectionData *selection,
GdkAtom atom)
gimp_dnd_get_stream_data (GtkWidget *widget,
GCallback get_stream_func,
gpointer get_stream_data,
GtkSelectionData *selection,
GdkAtom atom)
{
gchar *svg_data;
gint svg_data_length;
guchar *stream;
gsize stream_length;
svg_data = (* (GimpDndDragSvgFunc) get_svg_func) (widget, &svg_data_length,
get_svg_data);
stream = (* (GimpDndDragStreamFunc) get_stream_func) (widget, &stream_length,
get_stream_data);
if (svg_data)
if (stream)
{
gimp_selection_data_set_svg (selection, atom,
svg_data, svg_data_length);
g_free (svg_data);
gimp_selection_data_set_stream (selection, atom, stream, stream_length);
g_free (stream);
}
}
static gboolean
gimp_dnd_set_svg_data (GtkWidget *widget,
GCallback set_svg_func,
gpointer set_svg_data,
GtkSelectionData *selection)
gimp_dnd_set_stream_data (GtkWidget *widget,
GCallback set_stream_func,
gpointer set_stream_data,
GtkSelectionData *selection)
{
const gchar *svg_data;
gint svg_data_length;
const guchar *stream;
gsize stream_length;
svg_data = gimp_selection_data_get_svg (selection, &svg_data_length);
stream = gimp_selection_data_get_stream (selection, &stream_length);
if (! svg_data)
if (! stream)
return FALSE;
(* (GimpDndDropSvgFunc) set_svg_func) (widget, svg_data,
svg_data_length,
set_svg_data);
(* (GimpDndDropStreamFunc) set_stream_func) (widget,
stream, stream_length,
set_stream_data);
return TRUE;
}
void
gimp_dnd_svg_source_add (GtkWidget *widget,
GimpDndDragSvgFunc get_svg_func,
gpointer data)
gimp_dnd_svg_source_add (GtkWidget *widget,
GimpDndDragStreamFunc get_svg_func,
gpointer data)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
......@@ -1159,9 +1172,9 @@ gimp_dnd_svg_source_remove (GtkWidget *widget)
}
void
gimp_dnd_svg_dest_add (GtkWidget *widget,
GimpDndDropSvgFunc set_svg_func,
gpointer data)
gimp_dnd_svg_dest_add (GtkWidget *widget,
GimpDndDropStreamFunc set_svg_func,
gpointer data)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
......
......@@ -32,6 +32,9 @@
#define GIMP_TARGET_COLOR \
{ "application/x-color", 0, GIMP_DND_TYPE_COLOR }
#define GIMP_TARGET_PNG \
{ "image/png", 0, GIMP_DND_TYPE_PNG }
#define GIMP_TARGET_SVG \
{ "image/svg", 0, GIMP_DND_TYPE_SVG }
......@@ -131,25 +134,25 @@ void gimp_dnd_color_dest_add (GtkWidget *widget,
void gimp_dnd_color_dest_remove (GtkWidget *widget);
/* svg dnd functions */
/* stream dnd functions */
typedef gchar * (* GimpDndDragSvgFunc) (GtkWidget *widget,
gint *svg_data_len,
gpointer data);
typedef void (* GimpDndDropSvgFunc) (GtkWidget *widget,
const gchar *svg_data,
gint svg_data_len,
gpointer data);
typedef guchar * (* GimpDndDragStreamFunc) (GtkWidget *widget,
gsize *stream_len,
gpointer data);
typedef void (* GimpDndDropStreamFunc) (GtkWidget *widget,
const guchar *stream,
gsize stream_len,
gpointer data);
void gimp_dnd_svg_source_add (GtkWidget *widget,
GimpDndDragSvgFunc get_svg_func,
gpointer data);
void gimp_dnd_svg_source_remove (GtkWidget *widget);
void gimp_dnd_svg_source_add (GtkWidget *widget,
GimpDndDragStreamFunc get_svg_func,
gpointer data);
void gimp_dnd_svg_source_remove (GtkWidget *widget);
void gimp_dnd_svg_dest_add (GtkWidget *widget,
GimpDndDropSvgFunc set_svg_func,
gpointer data);
void gimp_dnd_svg_dest_remove (GtkWidget *widget);
void gimp_dnd_svg_dest_add (GtkWidget *widget,
GimpDndDropStreamFunc set_svg_func,
gpointer data);
void gimp_dnd_svg_dest_remove (GtkWidget *widget);
/* GimpViewable (by GType) dnd functions */
......
......@@ -376,36 +376,36 @@ gimp_selection_data_get_color (GtkSelectionData *selection,
}
void
gimp_selection_data_set_svg (GtkSelectionData *selection,
GdkAtom atom,
const gchar *svg_data,
gint svg_data_length)
gimp_selection_data_set_stream (GtkSelectionData *selection,
GdkAtom atom,
const guchar *stream,
gsize stream_length)
{
g_return_if_fail (selection != NULL);
g_return_if_fail (atom != GDK_NONE);
g_return_if_fail (svg_data != NULL);
g_return_if_fail (svg_data_length > 0);
g_return_if_fail (stream != NULL);
g_return_if_fail (stream_length > 0);
gtk_selection_data_set (selection, atom,
8, (guchar *) svg_data, svg_data_length);
8, (guchar *) stream, stream_length);
}
const gchar *
gimp_selection_data_get_svg (GtkSelectionData *selection,
gint *svg_data_length)
const guchar *
gimp_selection_data_get_stream (GtkSelectionData *selection,
gsize *stream_length)
{
g_return_val_if_fail (selection != NULL, NULL);
g_return_val_if_fail (svg_data_length != NULL, NULL);
g_return_val_if_fail (stream_length != NULL, NULL);
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid SVG data!");
g_warning ("Received invalid data stream!");
return NULL;
}
*svg_data_length = selection->length;
*stream_length = selection->length;
return (const gchar *) selection->data;
return (const guchar *) selection->data;
}
void
......
......@@ -37,14 +37,14 @@ gboolean gimp_selection_data_get_color (GtkSelectionData *selection,
GimpRGB *color);
/* svg */
/* stream (svg/png) */
void gimp_selection_data_set_svg (GtkSelectionData *selection,
void gimp_selection_data_set_stream (GtkSelectionData *selection,
GdkAtom atom,
const gchar *svg_data,
gint svg_data_length);
const gchar * gimp_selection_data_get_svg (GtkSelectionData *selection,
gint *svg_data_length);
const guchar *stream,
gsize stream_length);
const guchar * gimp_selection_data_get_stream (GtkSelectionData *selection,
gsize *stream_length);
/* image */
......
......@@ -59,11 +59,11 @@ static void gimp_vectors_tree_view_set_container (GimpContainerView *view,
GimpContainer *container);
static void gimp_vectors_tree_view_drop_svg (GimpContainerTreeView *tree_view,
const gchar *svg_data,
gint svg_data_len,
gsize svg_data_len,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos);
static gchar * gimp_vectors_tree_view_drag_svg (GtkWidget *widget,
gint *svg_data_len,
gsize *svg_data_len,
gpointer data);
......@@ -277,7 +277,7 @@ gimp_vectors_tree_view_set_container (GimpContainerView *view,
static void
gimp_vectors_tree_view_drop_svg (GimpContainerTreeView *tree_view,
const gchar *svg_data,
gint svg_data_len,
gsize svg_data_len,
GimpViewable *dest_viewable,
GtkTreeViewDropPosition drop_pos)
{
......@@ -307,7 +307,7 @@ gimp_vectors_tree_view_drop_svg (GimpContainerTreeView *tree_view,
static gchar *
gimp_vectors_tree_view_drag_svg (GtkWidget *widget,
gint *svg_data_len,
gsize *svg_data_len,
gpointer data)
{
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (data);
......
......@@ -49,7 +49,7 @@ gimp_aspect_type_get_type (void)
static const GEnumValue gimp_color_frame_mode_enum_values[] =
{
{ GIMP_COLOR_FRAME_MODE_PIXEL, N_("Pixel values"), "pixel" },
{ GIMP_COLOR_FRAME_MODE_PIXEL, N_("Pixel Values"), "pixel" },
{ GIMP_COLOR_FRAME_MODE_RGB, N_("RGB"), "rgb" },
{ GIMP_COLOR_FRAME_MODE_HSV, N_("HSV"), "hsv" },
{ GIMP_COLOR_FRAME_MODE_CMYK, N_("CMYK"), "cmyk" },
......@@ -70,7 +70,7 @@ gimp_color_frame_mode_get_type (void)
static const GEnumValue gimp_cursor_format_enum_values[] =
{
{ GIMP_CURSOR_FORMAT_BITMAP, N_("Black & white"), "bitmap" },
{ GIMP_CURSOR_FORMAT_BITMAP, N_("Black & White"), "bitmap" },
{ GIMP_CURSOR_FORMAT_PIXBUF, N_("Fancy"), "pixbuf" },
{ 0, NULL, NULL }
};
......@@ -90,7 +90,7 @@ gimp_cursor_format_get_type (void)
static const GEnumValue gimp_help_browser_type_enum_values[] =
{
{ GIMP_HELP_BROWSER_GIMP, N_("Internal"), "gimp" },
{ GIMP_HELP_BROWSER_WEB_BROWSER, N_("Web browser"), "web-browser" },
{ GIMP_HELP_BROWSER_WEB_BROWSER, N_("Web Browser"), "web-browser" },
{ 0, NULL, NULL }
};
......@@ -128,13 +128,13 @@ gimp_histogram_scale_get_type (void)
static const GEnumValue gimp_tab_style_enum_values[] =
{
{ GIMP_TAB_STYLE_ICON, N_("Icon"), "icon" },
{ GIMP_TAB_STYLE_PREVIEW, N_("Current status"), "preview" },
{ GIMP_TAB_STYLE_PREVIEW, N_("Current Status"), "preview" },
{ GIMP_TAB_STYLE_NAME, N_("Text"), "name" },
{ GIMP_TAB_STYLE_BLURB, N_("Description"), "blurb" },
{ GIMP_TAB_STYLE_ICON_NAME, N_("Icon & text"), "icon-name" },
{ GIMP_TAB_STYLE_ICON_BLURB, N_("Icon & desc"), "icon-blurb" },
{ GIMP_TAB_STYLE_PREVIEW_NAME, N_("Status & text"), "preview-name" },
{ GIMP_TAB_STYLE_PREVIEW_BLURB, N_("Status & desc"), "preview-blurb" },
{ GIMP_TAB_STYLE_ICON_NAME, N_("Icon & Text"), "icon-name" },
{ GIMP_TAB_STYLE_ICON_BLURB, N_("Icon & Desc"), "icon-blurb" },
{ GIMP_TAB_STYLE_PREVIEW_NAME, N_("Status & Text"), "preview-name" },
{ GIMP_TAB_STYLE_PREVIEW_BLURB, N_("Status & Desc"), "preview-blurb" },
{ 0, NULL, NULL }
};
......@@ -152,8 +152,8 @@ gimp_tab_style_get_type (void)
static const GEnumValue gimp_view_type_enum_values[] =
{
{ GIMP_VIEW_TYPE_LIST, N_("View as list"), "list" },
{ GIMP_VIEW_TYPE_GRID, N_("View as grid"), "grid" },
{ GIMP_VIEW_TYPE_LIST, N_("View as List"), "list" },
{ GIMP_VIEW_TYPE_GRID, N_("View as Grid"), "grid" },
{ 0, NULL, NULL }
};
......@@ -171,9 +171,9 @@ gimp_view_type_get_type (void)
static const GEnumValue gimp_window_hint_enum_values[] =
{
{ GIMP_WINDOW_HINT_NORMAL, N_("Normal window"), "normal" },
{ GIMP_WINDOW_HINT_UTILITY, N_("Utility window"), "utility" },
{ GIMP_WINDOW_HINT_KEEP_ABOVE, N_("Keep above"), "keep-above" },
{ GIMP_WINDOW_HINT_NORMAL, N_("Normal Window"), "normal" },
{ GIMP_WINDOW_HINT_UTILITY, N_("Utility Window"), "utility" },
{ GIMP_WINDOW_HINT_KEEP_ABOVE, N_("Keep Above"), "keep-above" },
{ 0, NULL, NULL }
};
......
......@@ -170,24 +170,25 @@ typedef enum /*< skip >*/
GIMP_DND_TYPE_TEXT_PLAIN = 2,
GIMP_DND_TYPE_NETSCAPE_URL = 3,
GIMP_DND_TYPE_COLOR = 4,
GIMP_DND_TYPE_SVG = 5,
GIMP_DND_TYPE_SVG_XML = 6,
GIMP_DND_TYPE_IMAGE = 7,
GIMP_DND_TYPE_LAYER = 8,
GIMP_DND_TYPE_CHANNEL = 9,
GIMP_DND_TYPE_LAYER_MASK = 10,
GIMP_DND_TYPE_COMPONENT = 11,
GIMP_DND_TYPE_VECTORS = 12,
GIMP_DND_TYPE_BRUSH = 13,
GIMP_DND_TYPE_PATTERN = 14,
GIMP_DND_TYPE_GRADIENT = 15,
GIMP_DND_TYPE_PALETTE = 16,
GIMP_DND_TYPE_FONT = 17,
GIMP_DND_TYPE_BUFFER = 18,
GIMP_DND_TYPE_IMAGEFILE = 19,
GIMP_DND_TYPE_TEMPLATE = 20,
GIMP_DND_TYPE_TOOL = 21,
GIMP_DND_TYPE_DIALOG = 22,
GIMP_DND_TYPE_PNG = 5,
GIMP_DND_TYPE_SVG = 6,
GIMP_DND_TYPE_SVG_XML = 7,
GIMP_DND_TYPE_IMAGE = 8,
GIMP_DND_TYPE_LAYER = 9,
GIMP_DND_TYPE_CHANNEL = 10,
GIMP_DND_TYPE_LAYER_MASK = 11,
GIMP_DND_TYPE_COMPONENT = 12,
GIMP_DND_TYPE_VECTORS = 13,
GIMP_DND_TYPE_BRUSH = 14,
GIMP_DND_TYPE_PATTERN = 15,
GIMP_DND_TYPE_GRADIENT = 16,
GIMP_DND_TYPE_PALETTE = 17,
GIMP_DND_TYPE_FONT = 18,
GIMP_DND_TYPE_BUFFER = 19,
GIMP_DND_TYPE_IMAGEFILE = 20,
GIMP_DND_TYPE_TEMPLATE = 21,
GIMP_DND_TYPE_TOOL = 22,
GIMP_DND_TYPE_DIALOG = 23,
GIMP_DND_TYPE_LAST = GIMP_DND_TYPE_DIALOG
} GimpDndType;
......
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