Commit 6dda0d82 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

reordered so COMPONENT is after IMAGE.

2005-01-15  Michael Natterer  <mitch@gimp.org>

	* app/widgets/widgets-enums.h (enum GimpDndType): reordered so
	COMPONENT is after IMAGE.

	* app/widgets/gimpdnd.[ch]
	* app/widgets/gimpselectiondata.[ch]: added API for passing
	components around via DND. Speaks in terms of a
	(GimpImage,GimpChannelType) tuple.
parent eca7176e
2005-01-15 Michael Natterer <mitch@gimp.org>
* app/widgets/widgets-enums.h (enum GimpDndType): reordered so
COMPONENT is after IMAGE.
* app/widgets/gimpdnd.[ch]
* app/widgets/gimpselectiondata.[ch]: added API for passing
components around via DND. Speaks in terms of a
(GimpImage,GimpChannelType) tuple.
2005-01-15 Sven Neumann <sven@gimp.org>
* plug-ins/common/psd_save.c: fixed array out-of-bounds access and
......
......@@ -141,6 +141,18 @@ static gboolean gimp_dnd_set_stream_data (GtkWidget *widget,
gpointer set_stream_data,
GtkSelectionData *selection);
static void gimp_dnd_get_component_data (GtkWidget *widget,
GCallback get_comp_func,
gpointer get_comp_data,
GtkSelectionData *selection,
GdkAtom atom);
static gboolean gimp_dnd_set_component_data (GtkWidget *widget,
gint x,
gint y,
GCallback set_comp_func,
gpointer set_comp_data,
GtkSelectionData *selection);
static void gimp_dnd_get_image_data (GtkWidget *widget,
GCallback get_image_func,
gpointer get_image_data,
......@@ -353,6 +365,20 @@ static GimpDndDataDef dnd_data_defs[] =
gimp_dnd_set_image_data,
},
{
GIMP_TARGET_COMPONENT,
"gimp-dnd-get-component-func",
"gimp-dnd-get-component-data",
"gimp-dnd-set-component-func",
"gimp-dnd-set-component-data",
gimp_dnd_get_viewable_icon,
gimp_dnd_get_component_data,
gimp_dnd_set_component_data,
},
{
GIMP_TARGET_LAYER,
......@@ -395,20 +421,6 @@ static GimpDndDataDef dnd_data_defs[] =
gimp_dnd_set_item_data,
},
{
GIMP_TARGET_COMPONENT,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
},
{
GIMP_TARGET_VECTORS,
......@@ -1254,6 +1266,92 @@ gimp_dnd_svg_dest_remove (GtkWidget *widget)
}
/*****************************/
/* component dnd functions */
/*****************************/
static void
gimp_dnd_get_component_data (GtkWidget *widget,
GCallback get_comp_func,
gpointer get_comp_data,
GtkSelectionData *selection,
GdkAtom atom)
{
GimpImage *image;
GimpChannelType channel = 0;
image = (* (GimpDndDragComponentFunc) get_comp_func) (widget, &channel,
get_comp_data);
if (image)
gimp_selection_data_set_component (selection, atom, image, channel);
}
static gboolean
gimp_dnd_set_component_data (GtkWidget *widget,
gint x,
gint y,
GCallback set_comp_func,
gpointer set_comp_data,
GtkSelectionData *selection)
{
GimpImage *image;
GimpChannelType channel = 0;
image = gimp_selection_data_get_component (selection, the_dnd_gimp,
&channel);
if (! image)
return FALSE;
(* (GimpDndDropComponentFunc) set_comp_func) (widget, x, y,
image, channel,
set_comp_data);
return TRUE;
}
void
gimp_dnd_component_source_add (GtkWidget *widget,
GimpDndDragComponentFunc get_comp_func,
gpointer data)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
gimp_dnd_data_source_add (GIMP_DND_TYPE_COMPONENT, widget,
G_CALLBACK (get_comp_func),
data);
}
void
gimp_dnd_component_source_remove (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
gimp_dnd_data_source_remove (GIMP_DND_TYPE_COMPONENT, widget);
}
void
gimp_dnd_component_dest_add (GtkWidget *widget,
GimpDndDropComponentFunc set_comp_func,
gpointer data)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
gimp_dnd_data_dest_add (GIMP_DND_TYPE_COMPONENT, widget,
G_CALLBACK (set_comp_func),
data);
}
void
gimp_dnd_component_dest_remove (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
gimp_dnd_data_dest_remove (GIMP_DND_TYPE_COMPONENT, widget);
}
/*******************************************/
/* GimpViewable (by GType) dnd functions */
/*******************************************/
......
......@@ -44,6 +44,9 @@
#define GIMP_TARGET_IMAGE \
{ "application/x-gimp-image-id", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_IMAGE }
#define GIMP_TARGET_COMPONENT \
{ "application/x-gimp-component", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_COMPONENT }
#define GIMP_TARGET_LAYER \
{ "application/x-gimp-layer-id", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_LAYER }
......@@ -53,9 +56,6 @@
#define GIMP_TARGET_LAYER_MASK \
{ "application/x-gimp-layer-mask-id", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_LAYER_MASK }
#define GIMP_TARGET_COMPONENT \
{ "application/x-gimp-component", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_COMPONENT }
#define GIMP_TARGET_VECTORS \
{ "application/x-gimp-vectors-id", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_VECTORS }
......@@ -161,6 +161,29 @@ void gimp_dnd_svg_dest_add (GtkWidget *widget,
void gimp_dnd_svg_dest_remove (GtkWidget *widget);
/* component dnd functions */
typedef GimpImage * (* GimpDndDragComponentFunc) (GtkWidget *widget,
GimpChannelType *channel,
gpointer data);
typedef void (* GimpDndDropComponentFunc) (GtkWidget *widget,
gint x,
gint y,
GimpImage *image,
GimpChannelType channel,
gpointer data);
void gimp_dnd_component_source_add (GtkWidget *widget,
GimpDndDragComponentFunc get_comp_func,
gpointer data);
void gimp_dnd_component_source_remove (GtkWidget *widget);
void gimp_dnd_component_dest_add (GtkWidget *widget,
GimpDndDropComponentFunc set_comp_func,
gpointer data);
void gimp_dnd_component_dest_remove (GtkWidget *widget);
/* GimpViewable (by GType) dnd functions */
typedef GimpViewable * (* GimpDndDragViewableFunc) (GtkWidget *widget,
......
......@@ -541,6 +541,58 @@ gimp_selection_data_get_image (GtkSelectionData *selection,
return gimp_image_get_by_ID (gimp, ID);
}
void
gimp_selection_data_set_component (GtkSelectionData *selection,
GdkAtom atom,
GimpImage *gimage,
GimpChannelType channel)
{
gchar *id;
g_return_if_fail (selection != NULL);
g_return_if_fail (atom != GDK_NONE);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
id = g_strdup_printf ("%d:%d", gimp_image_get_ID (gimage), (gint) channel);
gtk_selection_data_set (selection, atom,
8, (guchar *) id, strlen (id) + 1);
g_free (id);
}
GimpImage *
gimp_selection_data_get_component (GtkSelectionData *selection,
Gimp *gimp,
GimpChannelType *channel)
{
gchar *id;
gint ID;
gint ch;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (selection != NULL, NULL);
if ((selection->format != 8) || (selection->length < 1))
{
g_warning ("Received invalid image ID data!");
return NULL;
}
id = (gchar *) selection->data;
if (sscanf (id, "%i:%i", &ID, &ch) != 2)
return NULL;
if (! ID)
return NULL;
if (channel)
*channel = ch;
return gimp_image_get_by_ID (gimp, ID);
}
void
gimp_selection_data_set_item (GtkSelectionData *selection,
GdkAtom atom,
......
......@@ -65,6 +65,17 @@ GimpImage * gimp_selection_data_get_image (GtkSelectionData *selection,
Gimp *gimp);
/* component */
void gimp_selection_data_set_component (GtkSelectionData *selection,
GdkAtom atom,
GimpImage *gimage,
GimpChannelType channel);
GimpImage * gimp_selection_data_get_component (GtkSelectionData *selection,
Gimp *gimp,
GimpChannelType *channel);
/* item */
void gimp_selection_data_set_item (GtkSelectionData *selection,
......
......@@ -197,10 +197,10 @@ typedef enum /*< skip >*/
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_COMPONENT = 9,
GIMP_DND_TYPE_LAYER = 10,
GIMP_DND_TYPE_CHANNEL = 11,
GIMP_DND_TYPE_LAYER_MASK = 12,
GIMP_DND_TYPE_VECTORS = 13,
GIMP_DND_TYPE_BRUSH = 14,
GIMP_DND_TYPE_PATTERN = 15,
......
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