1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef __GIMP_DND_H__ 19 #define __GIMP_DND_H__ 20 21 22 #define GIMP_TARGET_URI_LIST \ 23 { "text/uri-list", 0, GIMP_DND_TYPE_URI_LIST } 24 25 #define GIMP_TARGET_TEXT_PLAIN \ 26 { "text/plain", 0, GIMP_DND_TYPE_TEXT_PLAIN } 27 28 #define GIMP_TARGET_NETSCAPE_URL \ 29 { "_NETSCAPE_URL", 0, GIMP_DND_TYPE_NETSCAPE_URL } 30 31 #define GIMP_TARGET_XDS \ 32 { "XdndDirectSave0", 0, GIMP_DND_TYPE_XDS } 33 34 #define GIMP_TARGET_COLOR \ 35 { "application/x-color", 0, GIMP_DND_TYPE_COLOR } 36 37 #define GIMP_TARGET_SVG \ 38 { "image/svg", 0, GIMP_DND_TYPE_SVG } 39 40 #define GIMP_TARGET_SVG_XML \ 41 { "image/svg+xml", 0, GIMP_DND_TYPE_SVG_XML } 42 43 /* just here for documentation purposes, the actual list of targets 44 * is created dynamically from available GdkPixbuf loaders 45 */ 46 #define GIMP_TARGET_PIXBUF \ 47 { NULL, 0, GIMP_DND_TYPE_PIXBUF } 48 49 #define GIMP_TARGET_IMAGE \ 50 { "application/x-gimp-image-id", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_IMAGE } 51 52 #define GIMP_TARGET_COMPONENT \ 53 { "application/x-gimp-component", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_COMPONENT } 54 55 #define GIMP_TARGET_LAYER \ 56 { "application/x-gimp-layer-id", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_LAYER } 57 58 #define GIMP_TARGET_CHANNEL \ 59 { "application/x-gimp-channel-id", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_CHANNEL } 60 61 #define GIMP_TARGET_LAYER_MASK \ 62 { "application/x-gimp-layer-mask-id", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_LAYER_MASK } 63 64 #define GIMP_TARGET_VECTORS \ 65 { "application/x-gimp-vectors-id", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_VECTORS } 66 67 #define GIMP_TARGET_BRUSH \ 68 { "application/x-gimp-brush-name", 0, GIMP_DND_TYPE_BRUSH } 69 70 #define GIMP_TARGET_PATTERN \ 71 { "application/x-gimp-pattern-name", 0, GIMP_DND_TYPE_PATTERN } 72 73 #define GIMP_TARGET_GRADIENT \ 74 { "application/x-gimp-gradient-name", 0, GIMP_DND_TYPE_GRADIENT } 75 76 #define GIMP_TARGET_PALETTE \ 77 { "application/x-gimp-palette-name", 0, GIMP_DND_TYPE_PALETTE } 78 79 #define GIMP_TARGET_FONT \ 80 { "application/x-gimp-font-name", 0, GIMP_DND_TYPE_FONT } 81 82 #define GIMP_TARGET_BUFFER \ 83 { "application/x-gimp-buffer-name", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_BUFFER } 84 85 #define GIMP_TARGET_IMAGEFILE \ 86 { "application/x-gimp-imagefile-name", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_IMAGEFILE } 87 88 #define GIMP_TARGET_TEMPLATE \ 89 { "application/x-gimp-template-name", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_TEMPLATE } 90 91 #define GIMP_TARGET_TOOL_ITEM \ 92 { "application/x-gimp-tool-item-name", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_TOOL_ITEM } 93 94 #define GIMP_TARGET_DIALOG \ 95 { "application/x-gimp-dialog", GTK_TARGET_SAME_APP, GIMP_DND_TYPE_DIALOG } 96 97 98 /* dnd initialization */ 99 100 void gimp_dnd_init (Gimp *gimp); 101 102 103 /* uri list dnd functions */ 104 105 typedef GList * (* GimpDndDragUriListFunc) (GtkWidget *widget, 106 gpointer data); 107 typedef void (* GimpDndDropUriListFunc) (GtkWidget *widget, 108 gint x, 109 gint y, 110 GList *uri_list, 111 gpointer data); 112 113 void gimp_dnd_uri_list_source_add (GtkWidget *widget, 114 GimpDndDragUriListFunc get_uri_list_func, 115 gpointer data); 116 void gimp_dnd_uri_list_source_remove (GtkWidget *widget); 117 118 void gimp_dnd_uri_list_dest_add (GtkWidget *widget, 119 GimpDndDropUriListFunc set_uri_list_func, 120 gpointer data); 121 void gimp_dnd_uri_list_dest_remove (GtkWidget *widget); 122 123 124 /* color dnd functions */ 125 126 typedef void (* GimpDndDragColorFunc) (GtkWidget *widget, 127 GimpRGB *color, 128 gpointer data); 129 typedef void (* GimpDndDropColorFunc) (GtkWidget *widget, 130 gint x, 131 gint y, 132 const GimpRGB *color, 133 gpointer data); 134 135 void gimp_dnd_color_source_add (GtkWidget *widget, 136 GimpDndDragColorFunc get_color_func, 137 gpointer data); 138 void gimp_dnd_color_source_remove (GtkWidget *widget); 139 140 void gimp_dnd_color_dest_add (GtkWidget *widget, 141 GimpDndDropColorFunc set_color_func, 142 gpointer data); 143 void gimp_dnd_color_dest_remove (GtkWidget *widget); 144 145 146 /* stream dnd functions */ 147 148 typedef guchar * (* GimpDndDragStreamFunc) (GtkWidget *widget, 149 gsize *stream_len, 150 gpointer data); 151 typedef void (* GimpDndDropStreamFunc) (GtkWidget *widget, 152 gint x, 153 gint y, 154 const guchar *stream, 155 gsize stream_len, 156 gpointer data); 157 158 void gimp_dnd_svg_source_add (GtkWidget *widget, 159 GimpDndDragStreamFunc get_svg_func, 160 gpointer data); 161 void gimp_dnd_svg_source_remove (GtkWidget *widget); 162 163 void gimp_dnd_svg_dest_add (GtkWidget *widget, 164 GimpDndDropStreamFunc set_svg_func, 165 gpointer data); 166 void gimp_dnd_svg_dest_remove (GtkWidget *widget); 167 168 169 /* pixbuf dnd functions */ 170 171 typedef GdkPixbuf * (* GimpDndDragPixbufFunc) (GtkWidget *widget, 172 gpointer data); 173 typedef void (* GimpDndDropPixbufFunc) (GtkWidget *widget, 174 gint x, 175 gint y, 176 GdkPixbuf *pixbuf, 177 gpointer data); 178 179 void gimp_dnd_pixbuf_source_add (GtkWidget *widget, 180 GimpDndDragPixbufFunc get_pixbuf_func, 181 gpointer data); 182 void gimp_dnd_pixbuf_source_remove (GtkWidget *widget); 183 184 void gimp_dnd_pixbuf_dest_add (GtkWidget *widget, 185 GimpDndDropPixbufFunc set_pixbuf_func, 186 gpointer data); 187 void gimp_dnd_pixbuf_dest_remove (GtkWidget *widget); 188 189 190 /* component dnd functions */ 191 192 typedef GimpImage * (* GimpDndDragComponentFunc) (GtkWidget *widget, 193 GimpContext **context, 194 GimpChannelType *channel, 195 gpointer data); 196 typedef void (* GimpDndDropComponentFunc) (GtkWidget *widget, 197 gint x, 198 gint y, 199 GimpImage *image, 200 GimpChannelType channel, 201 gpointer data); 202 203 void gimp_dnd_component_source_add (GtkWidget *widget, 204 GimpDndDragComponentFunc get_comp_func, 205 gpointer data); 206 void gimp_dnd_component_source_remove (GtkWidget *widget); 207 208 void gimp_dnd_component_dest_add (GtkWidget *widget, 209 GimpDndDropComponentFunc set_comp_func, 210 gpointer data); 211 void gimp_dnd_component_dest_remove (GtkWidget *widget); 212 213 214 /* GimpViewable (by GType) dnd functions */ 215 216 typedef GimpViewable * (* GimpDndDragViewableFunc) (GtkWidget *widget, 217 GimpContext **context, 218 gpointer data); 219 typedef void (* GimpDndDropViewableFunc) (GtkWidget *widget, 220 gint x, 221 gint y, 222 GimpViewable *viewable, 223 gpointer data); 224 225 226 gboolean gimp_dnd_drag_source_set_by_type (GtkWidget *widget, 227 GdkModifierType start_button_mask, 228 GType type, 229 GdkDragAction actions); 230 gboolean gimp_dnd_viewable_source_add (GtkWidget *widget, 231 GType type, 232 GimpDndDragViewableFunc get_viewable_func, 233 gpointer data); 234 gboolean gimp_dnd_viewable_source_remove (GtkWidget *widget, 235 GType type); 236 237 gboolean gimp_dnd_drag_dest_set_by_type (GtkWidget *widget, 238 GtkDestDefaults flags, 239 GType type, 240 GdkDragAction actions); 241 242 gboolean gimp_dnd_viewable_dest_add (GtkWidget *widget, 243 GType type, 244 GimpDndDropViewableFunc set_viewable_func, 245 gpointer data); 246 gboolean gimp_dnd_viewable_dest_remove (GtkWidget *widget, 247 GType type); 248 249 GimpViewable * gimp_dnd_get_drag_data (GtkWidget *widget); 250 251 252 /* Direct Save Protocol (XDS) */ 253 254 void gimp_dnd_xds_source_add (GtkWidget *widget, 255 GimpDndDragViewableFunc get_image_func, 256 gpointer data); 257 void gimp_dnd_xds_source_remove (GtkWidget *widget); 258 259 260 #endif /* __GIMP_DND_H__ */ 261