Commit c5865e49 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

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.
parent b86143f2
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.
2003-11-20 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdnd.c: cleanup before doing real changes.
......@@ -138,11 +138,6 @@ static guint editor_signals[LAST_SIGNAL] = { 0 };
static GimpImageEditorClass *parent_class = NULL;
static GtkTargetEntry color_palette_target_table[] =
{
GIMP_TARGET_COLOR
};
GType
gimp_colormap_editor_get_type (void)
......@@ -367,13 +362,7 @@ gimp_colormap_editor_new (GimpImage *gimage,
G_CALLBACK (gimp_colormap_preview_button_press),
editor);
/* dnd stuff */
gtk_drag_source_set (editor->palette,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
color_palette_target_table,
G_N_ELEMENTS (color_palette_target_table),
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (editor->palette, gimp_colormap_preview_drag_color,
gimp_dnd_color_source_add (editor->palette, gimp_colormap_preview_drag_color,
editor);
gimp_dnd_color_dest_add (editor->palette, gimp_colormap_preview_drop_color,
editor);
......
......@@ -442,8 +442,8 @@ gimp_container_tree_view_set_container (GimpContainerView *view,
if (! container)
{
if (gimp_dnd_viewable_source_unset (GTK_WIDGET (tree_view->view),
view->container->children_type))
if (gimp_dnd_viewable_source_remove (GTK_WIDGET (tree_view->view),
view->container->children_type))
{
gtk_drag_source_unset (GTK_WIDGET (tree_view->view));
}
......@@ -460,7 +460,7 @@ gimp_container_tree_view_set_container (GimpContainerView *view,
container->children_type,
GDK_ACTION_COPY))
{
gimp_dnd_viewable_source_set (GTK_WIDGET (tree_view->view),
gimp_dnd_viewable_source_add (GTK_WIDGET (tree_view->view),
container->children_type,
gimp_container_tree_view_drag_viewable,
tree_view);
......
This diff is collapsed.
......@@ -116,33 +116,42 @@ void gimp_dnd_init (Gimp *gimp);
/* file / url dnd functions */
typedef void (* GimpDndDropFileFunc) (GtkWidget *widget,
GList *files,
gpointer data);
void gimp_dnd_file_dest_add (GtkWidget *widget,
GimpDndDropFileFunc set_file_func,
gpointer data);
void gimp_dnd_file_dest_remove (GtkWidget *widget);
typedef GList * (* GimpDndDragFileFunc) (GtkWidget *widget,
gpointer data);
typedef void (* GimpDndDropFileFunc) (GtkWidget *widget,
GList *files,
gpointer data);
void gimp_dnd_file_source_add (GtkWidget *widget,
GimpDndDragFileFunc get_file_func,
gpointer data);
void gimp_dnd_file_source_remove (GtkWidget *widget);
void gimp_dnd_file_dest_add (GtkWidget *widget,
GimpDndDropFileFunc set_file_func,
gpointer data);
void gimp_dnd_file_dest_remove (GtkWidget *widget);
/* standard callback */
void gimp_dnd_open_files (GtkWidget *widget,
GList *files,
gpointer data);
void gimp_dnd_open_files (GtkWidget *widget,
GList *files,
gpointer data);
/* color dnd functions */
typedef void (* GimpDndDropColorFunc) (GtkWidget *widget,
const GimpRGB *color,
gpointer data);
typedef void (* GimpDndDragColorFunc) (GtkWidget *widget,
GimpRGB *color,
gpointer data);
typedef void (* GimpDndDropColorFunc) (GtkWidget *widget,
const GimpRGB *color,
gpointer data);
void gimp_dnd_color_source_set (GtkWidget *widget,
void gimp_dnd_color_source_add (GtkWidget *widget,
GimpDndDragColorFunc get_color_func,
gpointer data);
void gimp_dnd_color_source_remove (GtkWidget *widget);
void gimp_dnd_color_dest_add (GtkWidget *widget,
GimpDndDropColorFunc set_color_func,
gpointer data);
......@@ -151,22 +160,22 @@ void gimp_dnd_color_dest_remove (GtkWidget *widget);
/* GimpViewable (by GType) dnd functions */
typedef GimpViewable * (* GimpDndDragViewableFunc) (GtkWidget *widget,
gpointer data);
typedef void (* GimpDndDropViewableFunc) (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
typedef GimpViewable * (* GimpDndDragViewableFunc) (GtkWidget *widget,
gpointer data);
gboolean gimp_dnd_drag_source_set_by_type (GtkWidget *widget,
GdkModifierType start_button_mask,
GType type,
GdkDragAction actions);
gboolean gimp_dnd_viewable_source_set (GtkWidget *widget,
gboolean gimp_dnd_viewable_source_add (GtkWidget *widget,
GType type,
GimpDndDragViewableFunc get_viewable_func,
gpointer data);
gboolean gimp_dnd_viewable_source_unset (GtkWidget *widget,
gboolean gimp_dnd_viewable_source_remove (GtkWidget *widget,
GType type);
gboolean gimp_dnd_drag_dest_set_by_type (GtkWidget *widget,
......
......@@ -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;
}
......@@ -165,14 +165,16 @@ gimp_menu_item_real_set_viewable (GimpMenuItem *menu_item,
G_CALLBACK (gimp_menu_item_name_changed),
menu_item, 0);
gimp_dnd_drag_source_set_by_type (GTK_WIDGET (menu_item),
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
G_TYPE_FROM_INSTANCE (viewable),
GDK_ACTION_MOVE | GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (GTK_WIDGET (menu_item),
G_TYPE_FROM_INSTANCE (viewable),
gimp_menu_item_drag_viewable,
NULL);
if (gimp_dnd_drag_source_set_by_type (GTK_WIDGET (menu_item),
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
G_TYPE_FROM_INSTANCE (viewable),
GDK_ACTION_MOVE | GDK_ACTION_COPY))
{
gimp_dnd_viewable_source_add (GTK_WIDGET (menu_item),
G_TYPE_FROM_INSTANCE (viewable),
gimp_menu_item_drag_viewable,
NULL);
}
}
static void
......
......@@ -146,13 +146,6 @@ static void palette_editor_color_notebook_callback (ColorNotebook *color_not
gpointer data);
/* dnd stuff */
static GtkTargetEntry color_palette_target_table[] =
{
GIMP_TARGET_COLOR
};
static GimpDataEditorClass *parent_class = NULL;
static GimpDockedInterface *parent_docked_iface = NULL;
......@@ -271,16 +264,9 @@ gimp_palette_editor_init (GimpPaletteEditor *editor)
G_CALLBACK (palette_editor_color_area_button_press),
editor);
/* dnd stuff */
gtk_drag_source_set (editor->color_area,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
color_palette_target_table,
G_N_ELEMENTS (color_palette_target_table),
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (editor->color_area,
gimp_dnd_color_source_add (editor->color_area,
palette_editor_drag_color,
editor);
gimp_dnd_color_dest_add (eventbox, palette_editor_drop_color, editor);
gimp_dnd_viewable_dest_add (eventbox, GIMP_TYPE_PALETTE,
palette_editor_drop_palette,
......
......@@ -712,8 +712,8 @@ gimp_preview_set_viewable (GimpPreview *preview,
if (! viewable && ! preview->renderer->is_popup)
{
if (gimp_dnd_viewable_source_unset (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (preview->viewable)))
if (gimp_dnd_viewable_source_remove (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (preview->viewable)))
{
gtk_drag_source_unset (GTK_WIDGET (preview));
}
......@@ -726,7 +726,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
viewable_type,
GDK_ACTION_COPY))
{
gimp_dnd_viewable_source_set (GTK_WIDGET (preview),
gimp_dnd_viewable_source_add (GTK_WIDGET (preview),
viewable_type,
gimp_preview_drag_viewable,
NULL);
......
......@@ -100,12 +100,6 @@ static gint edit_color;
static GimpRGB revert_fg;
static GimpRGB revert_bg;
/* dnd stuff */
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
};
/* public functions */
......@@ -136,14 +130,7 @@ gimp_toolbox_color_area_create (GimpToolbox *toolbox,
G_CALLBACK (color_area_expose_event),
context);
/* dnd stuff */
gtk_drag_source_set (color_area,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
color_area_target_table,
G_N_ELEMENTS (color_area_target_table),
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (color_area, color_area_drag_color, context);
gimp_dnd_color_source_add (color_area, color_area_drag_color, context);
gimp_dnd_color_dest_add (color_area, color_area_drop_color, context);
g_signal_connect_swapped (context, "foreground_changed",
......
......@@ -712,8 +712,8 @@ gimp_preview_set_viewable (GimpPreview *preview,
if (! viewable && ! preview->renderer->is_popup)
{
if (gimp_dnd_viewable_source_unset (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (preview->viewable)))
if (gimp_dnd_viewable_source_remove (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (preview->viewable)))
{
gtk_drag_source_unset (GTK_WIDGET (preview));
}
......@@ -726,7 +726,7 @@ gimp_preview_set_viewable (GimpPreview *preview,
viewable_type,
GDK_ACTION_COPY))
{
gimp_dnd_viewable_source_set (GTK_WIDGET (preview),
gimp_dnd_viewable_source_add (GTK_WIDGET (preview),
viewable_type,
gimp_preview_drag_viewable,
NULL);
......
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