changed drag source stuff to allow multiple data types. Changed DND source

2003-11-20  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpdnd.[ch]: changed drag source stuff to allow
	multiple data types. Changed DND source API to speak in terms of
	add()/remove() instead of set()/unset(). Added GimpDndDragFileFunc
	typedef and gimp_dnd_file_source_add().

	Unfortunately GTK+'s DND API lacks symmetry here (no GtkTargetList
	based API for drag sources), so we cannot really change drag
	sources on-the-fly and need to set GtkTargetEntry arrays manually.

	* app/widgets/gimpcolormapeditor.c
	* app/widgets/gimpcontainertreeview.c
	* app/widgets/gimpmenuitem.c
	* app/widgets/gimppaletteeditor.c
	* app/widgets/gimppreview.c
	* app/widgets/gimptoolbox-color-area.c: changed accordingly.

	* app/widgets/gimpdocumentview.c: ditto. Additionally offer
	"text/uri-list" so it's possible to drag images from the document
	history to the file manager or browser.
This commit is contained in:
Michael Natterer
2003-11-20 16:26:15 +00:00
committed by Michael Natterer
parent b86143f2e8
commit c5865e497c
11 changed files with 419 additions and 186 deletions

View File

@ -76,6 +76,8 @@ static void gimp_document_view_activate_item (GimpContainerEditor *editor,
GimpViewable *viewable);
static void gimp_document_view_open_image (GimpDocumentView *view,
GimpImagefile *imagefile);
static GList * gimp_document_view_drag_file (GtkWidget *widget,
gpointer data);
static GimpContainerEditorClass *parent_class = NULL;
@ -214,6 +216,24 @@ gimp_document_view_new (GimpViewType view_type,
GTK_BUTTON (document_view->remove_button),
GIMP_TYPE_IMAGEFILE);
if (view_type == GIMP_VIEW_TYPE_LIST)
{
static const GtkTargetEntry document_view_target_entries[] =
{
GIMP_TARGET_IMAGEFILE,
GIMP_TARGET_URI_LIST
};
gtk_drag_source_set (editor->view->dnd_widget,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
document_view_target_entries,
G_N_ELEMENTS (document_view_target_entries),
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_file_source_add (editor->view->dnd_widget,
gimp_document_view_drag_file,
editor);
}
return GTK_WIDGET (document_view);
}
@ -357,7 +377,7 @@ gimp_document_view_delete_dangling_foreach (GimpImagefile *imagefile,
if (imagefile->state == GIMP_IMAGEFILE_STATE_NOT_FOUND)
{
gimp_container_remove (container_view->container,
gimp_container_remove (container_view->container,
GIMP_OBJECT (imagefile));
}
}
@ -461,3 +481,20 @@ gimp_document_view_open_image (GimpDocumentView *view,
}
}
static GList *
gimp_document_view_drag_file (GtkWidget *widget,
gpointer data)
{
GimpViewable *viewable;
viewable = gimp_dnd_get_drag_data (widget);
if (viewable)
{
GList *list = NULL;
return g_list_append (list, g_strdup (gimp_object_get_name (GIMP_OBJECT (viewable))));
}
return NULL;
}