]> Pileus Git - ~andy/gtk/blob - gtk/gtkdnd.h
Support text/plain selection target (#55117, Owen Taylor)
[~andy/gtk] / gtk / gtkdnd.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #ifndef __GTK_DND_H__
28 #define __GTK_DND_H__
29
30 #include <gdk/gdk.h>
31 #include <gtk/gtkenums.h>
32 #include <gtk/gtkwidget.h>
33 #include <gtk/gtkselection.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39 typedef enum {
40   GTK_DEST_DEFAULT_MOTION     = 1 << 0, /* respond to "drag_motion" */
41   GTK_DEST_DEFAULT_HIGHLIGHT  = 1 << 1, /* auto-highlight */
42   GTK_DEST_DEFAULT_DROP       = 1 << 2, /* respond to "drag_drop" */
43   GTK_DEST_DEFAULT_ALL        = 0x07
44 } GtkDestDefaults;
45
46 /* Flags for the GtkTargetEntry on the destination side 
47  */
48 typedef enum {
49   GTK_TARGET_SAME_APP = 1 << 0,    /*< nick=same-app >*/
50   GTK_TARGET_SAME_WIDGET = 1 << 1  /*< nick=same-widget >*/
51 } GtkTargetFlags;
52
53 /* Destination side */
54
55 void gtk_drag_get_data (GtkWidget      *widget,
56                         GdkDragContext *context,
57                         GdkAtom         target,
58                         guint32         time_);
59 void gtk_drag_finish   (GdkDragContext *context,
60                         gboolean        success,
61                         gboolean        del,
62                         guint32         time_);
63
64 GtkWidget *gtk_drag_get_source_widget (GdkDragContext *context);
65
66 void gtk_drag_highlight   (GtkWidget  *widget);
67 void gtk_drag_unhighlight (GtkWidget  *widget);
68
69 void gtk_drag_dest_set   (GtkWidget            *widget,
70                           GtkDestDefaults       flags,
71                           const GtkTargetEntry *targets,
72                           gint                  n_targets,
73                           GdkDragAction         actions);
74
75 void gtk_drag_dest_set_proxy (GtkWidget      *widget,
76                               GdkWindow      *proxy_window,
77                               GdkDragProtocol protocol,
78                               gboolean        use_coordinates);
79
80 void gtk_drag_dest_unset (GtkWidget          *widget);
81
82 GdkAtom        gtk_drag_dest_find_target     (GtkWidget      *widget,
83                                               GdkDragContext *context,
84                                               GtkTargetList  *target_list);
85 GtkTargetList* gtk_drag_dest_get_target_list (GtkWidget      *widget);
86 void           gtk_drag_dest_set_target_list (GtkWidget      *widget,
87                                               GtkTargetList  *target_list);
88 void           gtk_drag_dest_add_text_targets (GtkWidget     *widget);
89
90 /* Source side */
91
92 void gtk_drag_source_set  (GtkWidget            *widget,
93                            GdkModifierType       start_button_mask,
94                            const GtkTargetEntry *targets,
95                            gint                  n_targets,
96                            GdkDragAction         actions);
97
98 void gtk_drag_source_unset (GtkWidget        *widget);
99
100 GtkTargetList* gtk_drag_source_get_target_list (GtkWidget     *widget);
101 void           gtk_drag_source_set_target_list (GtkWidget     *widget,
102                                                 GtkTargetList *target_list);
103 void           gtk_drag_source_add_text_targets (GtkWidget     *widget);
104
105 void gtk_drag_source_set_icon        (GtkWidget   *widget,
106                                       GdkColormap *colormap,
107                                       GdkPixmap   *pixmap,
108                                       GdkBitmap   *mask);
109 void gtk_drag_source_set_icon_pixbuf (GtkWidget   *widget,
110                                       GdkPixbuf   *pixbuf);
111 void gtk_drag_source_set_icon_stock  (GtkWidget   *widget,
112                                       const gchar *stock_id);
113
114 /* There probably should be functions for setting the targets
115  * as a GtkTargetList
116  */
117
118 GdkDragContext *gtk_drag_begin (GtkWidget         *widget,
119                                 GtkTargetList     *targets,
120                                 GdkDragAction      actions,
121                                 gint               button,
122                                 GdkEvent          *event);
123
124 /* Set the image being dragged around
125  */
126 void gtk_drag_set_icon_widget (GdkDragContext *context,
127                                GtkWidget      *widget,
128                                gint            hot_x,
129                                gint            hot_y);
130 void gtk_drag_set_icon_pixmap (GdkDragContext *context,
131                                GdkColormap    *colormap,
132                                GdkPixmap      *pixmap,
133                                GdkBitmap      *mask,
134                                gint            hot_x,
135                                gint            hot_y);
136 void gtk_drag_set_icon_pixbuf (GdkDragContext *context,
137                                GdkPixbuf      *pixbuf,
138                                gint            hot_x,
139                                gint            hot_y);
140 void gtk_drag_set_icon_stock  (GdkDragContext *context,
141                                const gchar    *stock_id,
142                                gint            hot_x,
143                                gint            hot_y);
144
145 void gtk_drag_set_icon_default (GdkDragContext    *context);
146
147 gboolean gtk_drag_check_threshold (GtkWidget *widget,
148                                    gint       start_x,
149                                    gint       start_y,
150                                    gint       current_x,
151                                    gint       current_y);
152
153 /* Internal functions */
154 void _gtk_drag_source_handle_event (GtkWidget *widget,
155                                     GdkEvent  *event);
156 void _gtk_drag_dest_handle_event (GtkWidget *toplevel,
157                                   GdkEvent  *event);
158
159 #ifndef GTK_DISABLE_DEPRECATED
160 void gtk_drag_set_default_icon (GdkColormap   *colormap,
161                                 GdkPixmap     *pixmap,
162                                 GdkBitmap     *mask,
163                                 gint           hot_x,
164                                 gint           hot_y);
165 #endif /* !GTK_DISABLE_DEPRECATED */
166
167 #ifdef __cplusplus
168 }
169 #endif /* __cplusplus */
170
171 #endif /* __GTK_DND_H__ */
172
173
174