]> Pileus Git - ~andy/gtk/blob - gtk/gtkdnd.h
gtkdnd: Add API that takes GIcon
[~andy/gtk] / gtk / gtkdnd.h
1 /* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
2 /* GTK - The GIMP Toolkit
3  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * 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
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 /*
22  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
23  * file for a list of people on the GTK+ Team.  See the ChangeLog
24  * files for a list of changes.  These files are distributed with
25  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
26  */
27
28 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
29 #error "Only <gtk/gtk.h> can be included directly."
30 #endif
31
32 #ifndef __GTK_DND_H__
33 #define __GTK_DND_H__
34
35
36 #include <gtk/gtkwidget.h>
37 #include <gtk/gtkselection.h>
38
39
40 G_BEGIN_DECLS
41
42 /**
43  * GtkDestDefaults:
44  * @GTK_DEST_DEFAULT_MOTION: If set for a widget, GTK+, during a drag over this
45  *   widget will check if the drag matches this widget's list of possible targets
46  *   and actions.
47  *   GTK+ will then call gdk_drag_status() as appropriate.
48  * @GTK_DEST_DEFAULT_HIGHLIGHT: If set for a widget, GTK+ will draw a highlight on
49  *   this widget as long as a drag is over this widget and the widget drag format
50  *   and action are acceptable.
51  * @GTK_DEST_DEFAULT_DROP: If set for a widget, when a drop occurs, GTK+ will
52  *   will check if the drag matches this widget's list of possible targets and
53  *   actions. If so, GTK+ will call gtk_drag_get_data() on behalf of the widget.
54  *   Whether or not the drop is successful, GTK+ will call gtk_drag_finish(). If
55  *   the action was a move, then if the drag was successful, then %TRUE will be
56  *   passed for the @delete parameter to gtk_drag_finish().
57  * @GTK_DEST_DEFAULT_ALL: If set, specifies that all default actions should
58  *   be taken.
59  *
60  * The #GtkDestDefaults enumeration specifies the various
61  * types of action that will be taken on behalf
62  * of the user for a drag destination site.
63  */
64 typedef enum {
65   GTK_DEST_DEFAULT_MOTION     = 1 << 0, /* respond to "drag_motion" */
66   GTK_DEST_DEFAULT_HIGHLIGHT  = 1 << 1, /* auto-highlight */
67   GTK_DEST_DEFAULT_DROP       = 1 << 2, /* respond to "drag_drop" */
68   GTK_DEST_DEFAULT_ALL        = 0x07
69 } GtkDestDefaults;
70
71 /**
72  * GtkTargetFlags:
73  * @GTK_TARGET_SAME_APP: If this is set, the target will only be selected
74  *   for drags within a single application.
75  * @GTK_TARGET_SAME_WIDGET: If this is set, the target will only be selected
76  *   for drags within a single widget.
77  * @GTK_TARGET_OTHER_APP: If this is set, the target will not be selected
78  *   for drags within a single application.
79  * @GTK_TARGET_OTHER_WIDGET: If this is set, the target will not be selected
80  *   for drags withing a single widget.
81  *
82  * The #GtkTargetFlags enumeration is used to specify
83  * constraints on an entry in a #GtkTargetTable.
84  */
85 typedef enum {
86   GTK_TARGET_SAME_APP = 1 << 0,    /*< nick=same-app >*/
87   GTK_TARGET_SAME_WIDGET = 1 << 1, /*< nick=same-widget >*/
88   GTK_TARGET_OTHER_APP = 1 << 2,   /*< nick=other-app >*/
89   GTK_TARGET_OTHER_WIDGET = 1 << 3 /*< nick=other-widget >*/
90 } GtkTargetFlags;
91
92 /* Destination side */
93
94 void gtk_drag_get_data (GtkWidget      *widget,
95                         GdkDragContext *context,
96                         GdkAtom         target,
97                         guint32         time_);
98 void gtk_drag_finish   (GdkDragContext *context,
99                         gboolean        success,
100                         gboolean        del,
101                         guint32         time_);
102
103 GtkWidget *gtk_drag_get_source_widget (GdkDragContext *context);
104
105 void gtk_drag_highlight   (GtkWidget  *widget);
106 void gtk_drag_unhighlight (GtkWidget  *widget);
107
108 void gtk_drag_dest_set   (GtkWidget            *widget,
109                           GtkDestDefaults       flags,
110                           const GtkTargetEntry *targets,
111                           gint                  n_targets,
112                           GdkDragAction         actions);
113
114 void gtk_drag_dest_set_proxy (GtkWidget      *widget,
115                               GdkWindow      *proxy_window,
116                               GdkDragProtocol protocol,
117                               gboolean        use_coordinates);
118
119 void gtk_drag_dest_unset (GtkWidget          *widget);
120
121 GdkAtom        gtk_drag_dest_find_target     (GtkWidget      *widget,
122                                               GdkDragContext *context,
123                                               GtkTargetList  *target_list);
124 GtkTargetList* gtk_drag_dest_get_target_list (GtkWidget      *widget);
125 void           gtk_drag_dest_set_target_list (GtkWidget      *widget,
126                                               GtkTargetList  *target_list);
127 void           gtk_drag_dest_add_text_targets  (GtkWidget    *widget);
128 void           gtk_drag_dest_add_image_targets (GtkWidget    *widget);
129 void           gtk_drag_dest_add_uri_targets   (GtkWidget    *widget);
130
131 void           gtk_drag_dest_set_track_motion  (GtkWidget *widget,
132                                                 gboolean   track_motion);
133 gboolean       gtk_drag_dest_get_track_motion  (GtkWidget *widget);
134
135 /* Source side */
136
137 void gtk_drag_source_set  (GtkWidget            *widget,
138                            GdkModifierType       start_button_mask,
139                            const GtkTargetEntry *targets,
140                            gint                  n_targets,
141                            GdkDragAction         actions);
142
143 void gtk_drag_source_unset (GtkWidget        *widget);
144
145 GtkTargetList* gtk_drag_source_get_target_list (GtkWidget     *widget);
146 void           gtk_drag_source_set_target_list (GtkWidget     *widget,
147                                                 GtkTargetList *target_list);
148 void           gtk_drag_source_add_text_targets  (GtkWidget     *widget);
149 void           gtk_drag_source_add_image_targets (GtkWidget    *widget);
150 void           gtk_drag_source_add_uri_targets   (GtkWidget    *widget);
151
152 void gtk_drag_source_set_icon_pixbuf  (GtkWidget       *widget,
153                                        GdkPixbuf       *pixbuf);
154 void gtk_drag_source_set_icon_stock   (GtkWidget       *widget,
155                                        const gchar     *stock_id);
156 void gtk_drag_source_set_icon_name    (GtkWidget       *widget,
157                                        const gchar     *icon_name);
158 void gtk_drag_source_set_icon_gicon   (GtkWidget       *widget,
159                                        GIcon           *icon);
160
161 /* There probably should be functions for setting the targets
162  * as a GtkTargetList
163  */
164
165 GdkDragContext *gtk_drag_begin (GtkWidget         *widget,
166                                 GtkTargetList     *targets,
167                                 GdkDragAction      actions,
168                                 gint               button,
169                                 GdkEvent          *event);
170
171 /* Set the image being dragged around
172  */
173 void gtk_drag_set_icon_widget (GdkDragContext *context,
174                                GtkWidget      *widget,
175                                gint            hot_x,
176                                gint            hot_y);
177 void gtk_drag_set_icon_pixbuf (GdkDragContext *context,
178                                GdkPixbuf      *pixbuf,
179                                gint            hot_x,
180                                gint            hot_y);
181 void gtk_drag_set_icon_stock  (GdkDragContext *context,
182                                const gchar    *stock_id,
183                                gint            hot_x,
184                                gint            hot_y);
185 void gtk_drag_set_icon_surface(GdkDragContext *context,
186                                cairo_surface_t *surface);
187 void gtk_drag_set_icon_name   (GdkDragContext *context,
188                                const gchar    *icon_name,
189                                gint            hot_x,
190                                gint            hot_y);
191 void gtk_drag_set_icon_gicon  (GdkDragContext *context,
192                                GIcon          *icon,
193                                gint            hot_x,
194                                gint            hot_y);
195
196 void gtk_drag_set_icon_default (GdkDragContext    *context);
197
198 gboolean gtk_drag_check_threshold (GtkWidget *widget,
199                                    gint       start_x,
200                                    gint       start_y,
201                                    gint       current_x,
202                                    gint       current_y);
203
204 /* Internal functions */
205 void _gtk_drag_source_handle_event (GtkWidget *widget,
206                                     GdkEvent  *event);
207 void _gtk_drag_dest_handle_event (GtkWidget *toplevel,
208                                   GdkEvent  *event);
209
210 G_END_DECLS
211
212 #endif /* __GTK_DND_H__ */