]> Pileus Git - ~andy/gtk/blob - gtk/gtkdnd.h
Add GTK_TARGET_OTHER_{APP,WIDGET} to restrict drags within an
[~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 #ifndef __GTK_DND_H__
29 #define __GTK_DND_H__
30
31 #include <gdk/gdk.h>
32 #include <gtk/gtkenums.h>
33 #include <gtk/gtkwidget.h>
34 #include <gtk/gtkselection.h>
35
36 G_BEGIN_DECLS
37
38 typedef enum {
39   GTK_DEST_DEFAULT_MOTION     = 1 << 0, /* respond to "drag_motion" */
40   GTK_DEST_DEFAULT_HIGHLIGHT  = 1 << 1, /* auto-highlight */
41   GTK_DEST_DEFAULT_DROP       = 1 << 2, /* respond to "drag_drop" */
42   GTK_DEST_DEFAULT_ALL        = 0x07
43 } GtkDestDefaults;
44
45 /* Flags for the GtkTargetEntry on the destination side 
46  */
47 typedef enum {
48   GTK_TARGET_SAME_APP = 1 << 0,    /*< nick=same-app >*/
49   GTK_TARGET_SAME_WIDGET = 1 << 1, /*< nick=same-widget >*/
50   GTK_TARGET_OTHER_APP = 1 << 2,   /*< nick=other-app >*/
51   GTK_TARGET_OTHER_WIDGET = 1 << 3 /*< nick=other-widget >*/
52 } GtkTargetFlags;
53
54 /* Destination side */
55
56 void gtk_drag_get_data (GtkWidget      *widget,
57                         GdkDragContext *context,
58                         GdkAtom         target,
59                         guint32         time_);
60 void gtk_drag_finish   (GdkDragContext *context,
61                         gboolean        success,
62                         gboolean        del,
63                         guint32         time_);
64
65 GtkWidget *gtk_drag_get_source_widget (GdkDragContext *context);
66
67 void gtk_drag_highlight   (GtkWidget  *widget);
68 void gtk_drag_unhighlight (GtkWidget  *widget);
69
70 void gtk_drag_dest_set   (GtkWidget            *widget,
71                           GtkDestDefaults       flags,
72                           const GtkTargetEntry *targets,
73                           gint                  n_targets,
74                           GdkDragAction         actions);
75
76 void gtk_drag_dest_set_proxy (GtkWidget      *widget,
77                               GdkWindow      *proxy_window,
78                               GdkDragProtocol protocol,
79                               gboolean        use_coordinates);
80
81 void gtk_drag_dest_unset (GtkWidget          *widget);
82
83 GdkAtom        gtk_drag_dest_find_target     (GtkWidget      *widget,
84                                               GdkDragContext *context,
85                                               GtkTargetList  *target_list);
86 GtkTargetList* gtk_drag_dest_get_target_list (GtkWidget      *widget);
87 void           gtk_drag_dest_set_target_list (GtkWidget      *widget,
88                                               GtkTargetList  *target_list);
89 void           gtk_drag_dest_add_text_targets  (GtkWidget    *widget);
90 void           gtk_drag_dest_add_image_targets (GtkWidget    *widget);
91 void           gtk_drag_dest_add_uri_targets   (GtkWidget    *widget);
92
93 void           gtk_drag_dest_set_track_motion  (GtkWidget *widget,
94                                                 gboolean   track_motion);
95 gboolean       gtk_drag_dest_get_track_motion  (GtkWidget *widget);
96
97 /* Source side */
98
99 void gtk_drag_source_set  (GtkWidget            *widget,
100                            GdkModifierType       start_button_mask,
101                            const GtkTargetEntry *targets,
102                            gint                  n_targets,
103                            GdkDragAction         actions);
104
105 void gtk_drag_source_unset (GtkWidget        *widget);
106
107 GtkTargetList* gtk_drag_source_get_target_list (GtkWidget     *widget);
108 void           gtk_drag_source_set_target_list (GtkWidget     *widget,
109                                                 GtkTargetList *target_list);
110 void           gtk_drag_source_add_text_targets  (GtkWidget     *widget);
111 void           gtk_drag_source_add_image_targets (GtkWidget    *widget);
112 void           gtk_drag_source_add_uri_targets   (GtkWidget    *widget);
113
114 void gtk_drag_source_set_icon        (GtkWidget   *widget,
115                                       GdkColormap *colormap,
116                                       GdkPixmap   *pixmap,
117                                       GdkBitmap   *mask);
118 void gtk_drag_source_set_icon_pixbuf (GtkWidget   *widget,
119                                       GdkPixbuf   *pixbuf);
120 void gtk_drag_source_set_icon_stock  (GtkWidget   *widget,
121                                       const gchar *stock_id);
122 void gtk_drag_source_set_icon_name   (GtkWidget   *widget,
123                                       const gchar *icon_name);
124
125 /* There probably should be functions for setting the targets
126  * as a GtkTargetList
127  */
128
129 GdkDragContext *gtk_drag_begin (GtkWidget         *widget,
130                                 GtkTargetList     *targets,
131                                 GdkDragAction      actions,
132                                 gint               button,
133                                 GdkEvent          *event);
134
135 /* Set the image being dragged around
136  */
137 void gtk_drag_set_icon_widget (GdkDragContext *context,
138                                GtkWidget      *widget,
139                                gint            hot_x,
140                                gint            hot_y);
141 void gtk_drag_set_icon_pixmap (GdkDragContext *context,
142                                GdkColormap    *colormap,
143                                GdkPixmap      *pixmap,
144                                GdkBitmap      *mask,
145                                gint            hot_x,
146                                gint            hot_y);
147 void gtk_drag_set_icon_pixbuf (GdkDragContext *context,
148                                GdkPixbuf      *pixbuf,
149                                gint            hot_x,
150                                gint            hot_y);
151 void gtk_drag_set_icon_stock  (GdkDragContext *context,
152                                const gchar    *stock_id,
153                                gint            hot_x,
154                                gint            hot_y);
155 void gtk_drag_set_icon_name   (GdkDragContext *context,
156                                const gchar    *icon_name,
157                                gint            hot_x,
158                                gint            hot_y);
159
160 void gtk_drag_set_icon_default (GdkDragContext    *context);
161
162 gboolean gtk_drag_check_threshold (GtkWidget *widget,
163                                    gint       start_x,
164                                    gint       start_y,
165                                    gint       current_x,
166                                    gint       current_y);
167
168 /* Internal functions */
169 void _gtk_drag_source_handle_event (GtkWidget *widget,
170                                     GdkEvent  *event);
171 void _gtk_drag_dest_handle_event (GtkWidget *toplevel,
172                                   GdkEvent  *event);
173
174 #ifndef GTK_DISABLE_DEPRECATED
175 void gtk_drag_set_default_icon (GdkColormap   *colormap,
176                                 GdkPixmap     *pixmap,
177                                 GdkBitmap     *mask,
178                                 gint           hot_x,
179                                 gint           hot_y);
180 #endif /* !GTK_DISABLE_DEPRECATED */
181
182 G_END_DECLS
183
184 #endif /* __GTK_DND_H__ */
185
186
187