]> Pileus Git - ~andy/gtk/blob - gtk/gtkdnd.h
stylecontext: Do invalidation on first resize container
[~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, see <http://www.gnu.org/licenses/>.
17  */
18
19 /*
20  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
21  * file for a list of people on the GTK+ Team.  See the ChangeLog
22  * files for a list of changes.  These files are distributed with
23  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
24  */
25
26 #ifndef __GTK_DND_H__
27 #define __GTK_DND_H__
28
29
30 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
31 #error "Only <gtk/gtk.h> can be included directly."
32 #endif
33
34 #include <gtk/gtkwidget.h>
35 #include <gtk/gtkselection.h>
36
37
38 G_BEGIN_DECLS
39
40 /**
41  * GtkDestDefaults:
42  * @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  *   and actions.
45  *   GTK+ will then call gdk_drag_status() as appropriate.
46  * @GTK_DEST_DEFAULT_HIGHLIGHT: If set for a widget, GTK+ will draw a highlight on
47  *   this widget as long as a drag is over this widget and the widget drag format
48  *   and action are acceptable.
49  * @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  *   actions. If so, GTK+ will call gtk_drag_get_data() on behalf of the widget.
52  *   Whether or not the drop is successful, GTK+ will call gtk_drag_finish(). If
53  *   the action was a move, then if the drag was successful, then %TRUE will be
54  *   passed for the @delete parameter to gtk_drag_finish().
55  * @GTK_DEST_DEFAULT_ALL: If set, specifies that all default actions should
56  *   be taken.
57  *
58  * The #GtkDestDefaults enumeration specifies the various
59  * types of action that will be taken on behalf
60  * of the user for a drag destination site.
61  */
62 typedef enum {
63   GTK_DEST_DEFAULT_MOTION     = 1 << 0, /* respond to "drag_motion" */
64   GTK_DEST_DEFAULT_HIGHLIGHT  = 1 << 1, /* auto-highlight */
65   GTK_DEST_DEFAULT_DROP       = 1 << 2, /* respond to "drag_drop" */
66   GTK_DEST_DEFAULT_ALL        = 0x07
67 } GtkDestDefaults;
68
69 /**
70  * GtkTargetFlags:
71  * @GTK_TARGET_SAME_APP: If this is set, the target will only be selected
72  *   for drags within a single application.
73  * @GTK_TARGET_SAME_WIDGET: If this is set, the target will only be selected
74  *   for drags within a single widget.
75  * @GTK_TARGET_OTHER_APP: If this is set, the target will not be selected
76  *   for drags within a single application.
77  * @GTK_TARGET_OTHER_WIDGET: If this is set, the target will not be selected
78  *   for drags withing a single widget.
79  *
80  * The #GtkTargetFlags enumeration is used to specify
81  * constraints on an entry in a #GtkTargetTable.
82  */
83 typedef enum {
84   GTK_TARGET_SAME_APP = 1 << 0,    /*< nick=same-app >*/
85   GTK_TARGET_SAME_WIDGET = 1 << 1, /*< nick=same-widget >*/
86   GTK_TARGET_OTHER_APP = 1 << 2,   /*< nick=other-app >*/
87   GTK_TARGET_OTHER_WIDGET = 1 << 3 /*< nick=other-widget >*/
88 } GtkTargetFlags;
89
90 /* Destination side */
91
92 void gtk_drag_get_data (GtkWidget      *widget,
93                         GdkDragContext *context,
94                         GdkAtom         target,
95                         guint32         time_);
96 void gtk_drag_finish   (GdkDragContext *context,
97                         gboolean        success,
98                         gboolean        del,
99                         guint32         time_);
100
101 GtkWidget *gtk_drag_get_source_widget (GdkDragContext *context);
102
103 void gtk_drag_highlight   (GtkWidget  *widget);
104 void gtk_drag_unhighlight (GtkWidget  *widget);
105
106 void gtk_drag_dest_set   (GtkWidget            *widget,
107                           GtkDestDefaults       flags,
108                           const GtkTargetEntry *targets,
109                           gint                  n_targets,
110                           GdkDragAction         actions);
111
112 void gtk_drag_dest_set_proxy (GtkWidget      *widget,
113                               GdkWindow      *proxy_window,
114                               GdkDragProtocol protocol,
115                               gboolean        use_coordinates);
116
117 void gtk_drag_dest_unset (GtkWidget          *widget);
118
119 GdkAtom        gtk_drag_dest_find_target     (GtkWidget      *widget,
120                                               GdkDragContext *context,
121                                               GtkTargetList  *target_list);
122 GtkTargetList* gtk_drag_dest_get_target_list (GtkWidget      *widget);
123 void           gtk_drag_dest_set_target_list (GtkWidget      *widget,
124                                               GtkTargetList  *target_list);
125 void           gtk_drag_dest_add_text_targets  (GtkWidget    *widget);
126 void           gtk_drag_dest_add_image_targets (GtkWidget    *widget);
127 void           gtk_drag_dest_add_uri_targets   (GtkWidget    *widget);
128
129 void           gtk_drag_dest_set_track_motion  (GtkWidget *widget,
130                                                 gboolean   track_motion);
131 gboolean       gtk_drag_dest_get_track_motion  (GtkWidget *widget);
132
133 /* Source side */
134
135 void gtk_drag_source_set  (GtkWidget            *widget,
136                            GdkModifierType       start_button_mask,
137                            const GtkTargetEntry *targets,
138                            gint                  n_targets,
139                            GdkDragAction         actions);
140
141 void gtk_drag_source_unset (GtkWidget        *widget);
142
143 GtkTargetList* gtk_drag_source_get_target_list (GtkWidget     *widget);
144 void           gtk_drag_source_set_target_list (GtkWidget     *widget,
145                                                 GtkTargetList *target_list);
146 void           gtk_drag_source_add_text_targets  (GtkWidget     *widget);
147 void           gtk_drag_source_add_image_targets (GtkWidget    *widget);
148 void           gtk_drag_source_add_uri_targets   (GtkWidget    *widget);
149
150 void gtk_drag_source_set_icon_pixbuf  (GtkWidget       *widget,
151                                        GdkPixbuf       *pixbuf);
152 void gtk_drag_source_set_icon_stock   (GtkWidget       *widget,
153                                        const gchar     *stock_id);
154 void gtk_drag_source_set_icon_name    (GtkWidget       *widget,
155                                        const gchar     *icon_name);
156 GDK_AVAILABLE_IN_3_2
157 void gtk_drag_source_set_icon_gicon   (GtkWidget       *widget,
158                                        GIcon           *icon);
159
160 /* There probably should be functions for setting the targets
161  * as a GtkTargetList
162  */
163
164 GdkDragContext *gtk_drag_begin (GtkWidget         *widget,
165                                 GtkTargetList     *targets,
166                                 GdkDragAction      actions,
167                                 gint               button,
168                                 GdkEvent          *event);
169
170 /* Set the image being dragged around
171  */
172 void gtk_drag_set_icon_widget (GdkDragContext *context,
173                                GtkWidget      *widget,
174                                gint            hot_x,
175                                gint            hot_y);
176 void gtk_drag_set_icon_pixbuf (GdkDragContext *context,
177                                GdkPixbuf      *pixbuf,
178                                gint            hot_x,
179                                gint            hot_y);
180 void gtk_drag_set_icon_stock  (GdkDragContext *context,
181                                const gchar    *stock_id,
182                                gint            hot_x,
183                                gint            hot_y);
184 void gtk_drag_set_icon_surface(GdkDragContext *context,
185                                cairo_surface_t *surface);
186 void gtk_drag_set_icon_name   (GdkDragContext *context,
187                                const gchar    *icon_name,
188                                gint            hot_x,
189                                gint            hot_y);
190 GDK_AVAILABLE_IN_3_2
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__ */