added gimp_dnd_get_component_icon().

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

	* app/widgets/gimpdnd.c: added gimp_dnd_get_component_icon().

	* app/widgets/gimpcomponenteditor.c: allow to drag
	components. They can't be dropped anywhere yet.
This commit is contained in:
Michael Natterer 2005-01-15 14:55:15 +00:00 committed by Michael Natterer
parent 022b3532f8
commit bfa7335635
3 changed files with 62 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2005-01-15 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdnd.c: added gimp_dnd_get_component_icon().
* app/widgets/gimpcomponenteditor.c: allow to drag
components. They can't be dropped anywhere yet.
2005-01-15 Sven Neumann <sven@gimp.org>
* libgimp/gimptile.c (gimp_tile_put)

View File

@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcomponenteditor.c
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2003-2005 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -33,6 +33,7 @@
#include "gimpcellrendererviewable.h"
#include "gimpcomponenteditor.h"
#include "gimpdnd.h"
#include "gimpmenufactory.h"
#include "gimpviewrendererimage.h"
#include "gimpwidgets-utils.h"
@ -84,6 +85,9 @@ static void gimp_component_editor_visibility_changed(GimpImage *gimage
static void gimp_component_editor_active_changed (GimpImage *gimage,
GimpChannelType channel,
GimpComponentEditor *editor);
static GimpImage * gimp_component_editor_drag_component (GtkWidget *widget,
GimpChannelType *channel,
gpointer data);
static GimpImageEditorClass *parent_class = NULL;
@ -193,6 +197,10 @@ gimp_component_editor_init (GimpComponentEditor *editor)
gtk_tree_selection_set_select_function (editor->selection,
gimp_component_editor_select,
editor, NULL);
gimp_dnd_component_source_add (GTK_WIDGET (editor->view),
gimp_component_editor_drag_component,
editor);
}
static void
@ -626,3 +634,22 @@ gimp_component_editor_active_changed (GimpImage *gimage,
}
}
}
static GimpImage *
gimp_component_editor_drag_component (GtkWidget *widget,
GimpChannelType *channel,
gpointer data)
{
GimpComponentEditor *editor = GIMP_COMPONENT_EDITOR (data);
if (GIMP_IMAGE_EDITOR (editor)->gimage &&
editor->clicked_component != -1)
{
if (channel)
*channel = editor->clicked_component;
return GIMP_IMAGE_EDITOR (editor)->gimage;
}
return NULL;
}

View File

@ -48,6 +48,7 @@
#include "gimpdnd.h"
#include "gimpview.h"
#include "gimpselectiondata.h"
#include "gimpviewrendererimage.h"
#include "gimp-intl.h"
@ -101,6 +102,9 @@ struct _GimpDndDataDef
static GtkWidget * gimp_dnd_get_viewable_icon (GtkWidget *widget,
GCallback get_viewable_func,
gpointer get_viewable_data);
static GtkWidget * gimp_dnd_get_component_icon (GtkWidget *widget,
GCallback get_comp_func,
gpointer get_comp_data);
static GtkWidget * gimp_dnd_get_color_icon (GtkWidget *widget,
GCallback get_color_func,
gpointer get_color_data);
@ -374,7 +378,7 @@ static GimpDndDataDef dnd_data_defs[] =
"gimp-dnd-set-component-func",
"gimp-dnd-set-component-data",
gimp_dnd_get_viewable_icon,
gimp_dnd_get_component_icon,
gimp_dnd_get_component_data,
gimp_dnd_set_component_data,
},
@ -1270,6 +1274,28 @@ gimp_dnd_svg_dest_remove (GtkWidget *widget)
/* component dnd functions */
/*****************************/
static GtkWidget *
gimp_dnd_get_component_icon (GtkWidget *widget,
GCallback get_comp_func,
gpointer get_comp_data)
{
GtkWidget *view;
GimpImage *image;
GimpChannelType channel;
image = (* (GimpDndDragComponentFunc) get_comp_func) (widget, &channel,
get_comp_data);
if (! image)
return NULL;
view = gimp_view_new (GIMP_VIEWABLE (image), DRAG_PREVIEW_SIZE, 0, TRUE);
GIMP_VIEW_RENDERER_IMAGE (GIMP_VIEW (view)->renderer)->channel = channel;
return view;
}
static void
gimp_dnd_get_component_data (GtkWidget *widget,
GCallback get_comp_func,