gtkdnd.h 9.23 KB
Newer Older
1
/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
Cody Russell's avatar
Cody Russell committed
2
/* GTK - The GIMP Toolkit
3 4 5
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7 8 9 10 11 12
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
16
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17
 */
18 19

/*
20
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
21 22
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
23
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
24 25
 */

26 27 28
#ifndef __GTK_DND_H__
#define __GTK_DND_H__

29

30 31 32 33
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif

34 35 36
#include <gtk/gtkwidget.h>
#include <gtk/gtkselection.h>

37

38
G_BEGIN_DECLS
39

40 41 42
/**
 * GtkDestDefaults:
 * @GTK_DEST_DEFAULT_MOTION: If set for a widget, GTK+, during a drag over this
43
 *   widget will check if the drag matches this widget’s list of possible targets
44 45 46 47 48 49
 *   and actions.
 *   GTK+ will then call gdk_drag_status() as appropriate.
 * @GTK_DEST_DEFAULT_HIGHLIGHT: If set for a widget, GTK+ will draw a highlight on
 *   this widget as long as a drag is over this widget and the widget drag format
 *   and action are acceptable.
 * @GTK_DEST_DEFAULT_DROP: If set for a widget, when a drop occurs, GTK+ will
50
 *   will check if the drag matches this widget’s list of possible targets and
51 52 53 54 55 56 57 58 59 60 61
 *   actions. If so, GTK+ will call gtk_drag_get_data() on behalf of the widget.
 *   Whether or not the drop is successful, GTK+ will call gtk_drag_finish(). If
 *   the action was a move, then if the drag was successful, then %TRUE will be
 *   passed for the @delete parameter to gtk_drag_finish().
 * @GTK_DEST_DEFAULT_ALL: If set, specifies that all default actions should
 *   be taken.
 *
 * The #GtkDestDefaults enumeration specifies the various
 * types of action that will be taken on behalf
 * of the user for a drag destination site.
 */
62
typedef enum {
63 64 65
  GTK_DEST_DEFAULT_MOTION     = 1 << 0,
  GTK_DEST_DEFAULT_HIGHLIGHT  = 1 << 1,
  GTK_DEST_DEFAULT_DROP       = 1 << 2,
66 67 68
  GTK_DEST_DEFAULT_ALL        = 0x07
} GtkDestDefaults;

69 70 71 72 73 74 75 76 77 78 79 80
/**
 * GtkTargetFlags:
 * @GTK_TARGET_SAME_APP: If this is set, the target will only be selected
 *   for drags within a single application.
 * @GTK_TARGET_SAME_WIDGET: If this is set, the target will only be selected
 *   for drags within a single widget.
 * @GTK_TARGET_OTHER_APP: If this is set, the target will not be selected
 *   for drags within a single application.
 * @GTK_TARGET_OTHER_WIDGET: If this is set, the target will not be selected
 *   for drags withing a single widget.
 *
 * The #GtkTargetFlags enumeration is used to specify
81
 * constraints on a #GtkTargetEntry.
82 83 84
 */
typedef enum {
  GTK_TARGET_SAME_APP = 1 << 0,    /*< nick=same-app >*/
85 86 87
  GTK_TARGET_SAME_WIDGET = 1 << 1, /*< nick=same-widget >*/
  GTK_TARGET_OTHER_APP = 1 << 2,   /*< nick=other-app >*/
  GTK_TARGET_OTHER_WIDGET = 1 << 3 /*< nick=other-widget >*/
88 89
} GtkTargetFlags;

90 91
/* Destination side */

92
GDK_AVAILABLE_IN_ALL
93 94 95
void gtk_drag_get_data (GtkWidget      *widget,
			GdkDragContext *context,
			GdkAtom         target,
96
			guint32         time_);
97
GDK_AVAILABLE_IN_ALL
98 99
void gtk_drag_finish   (GdkDragContext *context,
			gboolean        success,
100
			gboolean        del,
101
			guint32         time_);
102

103
GDK_AVAILABLE_IN_ALL
104 105
GtkWidget *gtk_drag_get_source_widget (GdkDragContext *context);

106
GDK_AVAILABLE_IN_ALL
107
void gtk_drag_highlight   (GtkWidget  *widget);
108
GDK_AVAILABLE_IN_ALL
109 110
void gtk_drag_unhighlight (GtkWidget  *widget);

111
GDK_AVAILABLE_IN_ALL
112 113 114 115 116
void gtk_drag_dest_set   (GtkWidget            *widget,
			  GtkDestDefaults       flags,
  		          const GtkTargetEntry *targets,
			  gint                  n_targets,
			  GdkDragAction         actions);
117

118
GDK_AVAILABLE_IN_ALL
119 120 121 122 123
void gtk_drag_dest_set_proxy (GtkWidget      *widget,
			      GdkWindow      *proxy_window,
			      GdkDragProtocol protocol,
			      gboolean        use_coordinates);

124
GDK_AVAILABLE_IN_ALL
125 126
void gtk_drag_dest_unset (GtkWidget          *widget);

127
GDK_AVAILABLE_IN_ALL
Havoc Pennington's avatar
Havoc Pennington committed
128 129 130
GdkAtom        gtk_drag_dest_find_target     (GtkWidget      *widget,
                                              GdkDragContext *context,
                                              GtkTargetList  *target_list);
131
GDK_AVAILABLE_IN_ALL
Havoc Pennington's avatar
Havoc Pennington committed
132
GtkTargetList* gtk_drag_dest_get_target_list (GtkWidget      *widget);
133
GDK_AVAILABLE_IN_ALL
Havoc Pennington's avatar
Havoc Pennington committed
134 135
void           gtk_drag_dest_set_target_list (GtkWidget      *widget,
                                              GtkTargetList  *target_list);
136
GDK_AVAILABLE_IN_ALL
137
void           gtk_drag_dest_add_text_targets  (GtkWidget    *widget);
138
GDK_AVAILABLE_IN_ALL
139
void           gtk_drag_dest_add_image_targets (GtkWidget    *widget);
140
GDK_AVAILABLE_IN_ALL
141
void           gtk_drag_dest_add_uri_targets   (GtkWidget    *widget);
Havoc Pennington's avatar
Havoc Pennington committed
142

143
GDK_AVAILABLE_IN_ALL
144 145
void           gtk_drag_dest_set_track_motion  (GtkWidget *widget,
						gboolean   track_motion);
146
GDK_AVAILABLE_IN_ALL
147 148
gboolean       gtk_drag_dest_get_track_motion  (GtkWidget *widget);

149 150
/* Source side */

151
GDK_AVAILABLE_IN_ALL
152 153 154 155 156
void gtk_drag_source_set  (GtkWidget            *widget,
			   GdkModifierType       start_button_mask,
			   const GtkTargetEntry *targets,
			   gint                  n_targets,
			   GdkDragAction         actions);
157

158
GDK_AVAILABLE_IN_ALL
159 160
void gtk_drag_source_unset (GtkWidget        *widget);

161
GDK_AVAILABLE_IN_ALL
162
GtkTargetList* gtk_drag_source_get_target_list (GtkWidget     *widget);
163
GDK_AVAILABLE_IN_ALL
164 165
void           gtk_drag_source_set_target_list (GtkWidget     *widget,
                                                GtkTargetList *target_list);
166
GDK_AVAILABLE_IN_ALL
167
void           gtk_drag_source_add_text_targets  (GtkWidget     *widget);
168
GDK_AVAILABLE_IN_ALL
169
void           gtk_drag_source_add_image_targets (GtkWidget    *widget);
170
GDK_AVAILABLE_IN_ALL
171
void           gtk_drag_source_add_uri_targets   (GtkWidget    *widget);
172

173
GDK_AVAILABLE_IN_ALL
174 175
void gtk_drag_source_set_icon_pixbuf  (GtkWidget       *widget,
				       GdkPixbuf       *pixbuf);
176
GDK_DEPRECATED_IN_3_10_FOR(gtk_drag_source_set_icon_name)
177 178
void gtk_drag_source_set_icon_stock   (GtkWidget       *widget,
				       const gchar     *stock_id);
179
GDK_AVAILABLE_IN_ALL
180 181
void gtk_drag_source_set_icon_name    (GtkWidget       *widget,
				       const gchar     *icon_name);
182
GDK_AVAILABLE_IN_3_2
183 184
void gtk_drag_source_set_icon_gicon   (GtkWidget       *widget,
				       GIcon           *icon);
185 186 187 188 189

/* There probably should be functions for setting the targets
 * as a GtkTargetList
 */

190 191 192 193 194 195 196 197 198 199
GDK_AVAILABLE_IN_3_10
GdkDragContext *gtk_drag_begin_with_coordinates (GtkWidget         *widget,
                                                 GtkTargetList     *targets,
                                                 GdkDragAction      actions,
                                                 gint               button,
                                                 GdkEvent          *event,
                                                 gint               x,
                                                 gint               y);

GDK_DEPRECATED_IN_3_10_FOR(gtk_drag_begin_with_coordinates)
200 201 202 203 204 205 206 207
GdkDragContext *gtk_drag_begin (GtkWidget         *widget,
				GtkTargetList     *targets,
				GdkDragAction      actions,
				gint               button,
				GdkEvent          *event);

/* Set the image being dragged around
 */
208
GDK_AVAILABLE_IN_ALL
209 210 211 212
void gtk_drag_set_icon_widget (GdkDragContext *context,
			       GtkWidget      *widget,
			       gint            hot_x,
			       gint            hot_y);
213
GDK_AVAILABLE_IN_ALL
214 215 216 217
void gtk_drag_set_icon_pixbuf (GdkDragContext *context,
			       GdkPixbuf      *pixbuf,
			       gint            hot_x,
			       gint            hot_y);
218
GDK_DEPRECATED_IN_3_10_FOR(gtk_drag_set_icon_name)
219 220 221 222
void gtk_drag_set_icon_stock  (GdkDragContext *context,
			       const gchar    *stock_id,
			       gint            hot_x,
			       gint            hot_y);
223
GDK_AVAILABLE_IN_ALL
224 225
void gtk_drag_set_icon_surface(GdkDragContext *context,
			       cairo_surface_t *surface);
226
GDK_AVAILABLE_IN_ALL
227 228 229 230
void gtk_drag_set_icon_name   (GdkDragContext *context,
			       const gchar    *icon_name,
			       gint            hot_x,
			       gint            hot_y);
231
GDK_AVAILABLE_IN_3_2
232 233 234 235
void gtk_drag_set_icon_gicon  (GdkDragContext *context,
			       GIcon          *icon,
			       gint            hot_x,
			       gint            hot_y);
236

237
GDK_AVAILABLE_IN_ALL
238 239
void gtk_drag_set_icon_default (GdkDragContext    *context);

240
GDK_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
241 242 243 244 245 246
gboolean gtk_drag_check_threshold (GtkWidget *widget,
				   gint       start_x,
				   gint       start_y,
				   gint       current_x,
				   gint       current_y);

247
/* Internal functions */
248 249 250 251 252
void _gtk_drag_source_handle_event (GtkWidget *widget,
				    GdkEvent  *event);
void _gtk_drag_dest_handle_event (GtkWidget *toplevel,
				  GdkEvent  *event);

253
G_END_DECLS
254 255

#endif /* __GTK_DND_H__ */