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, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25#ifndef __GTK_SELECTION_H__
26#define __GTK_SELECTION_H__
27
28#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
29#error "Only <gtk/gtk.h> can be included directly."
30#endif
31
32#include <gtk/gtkwidget.h>
33#include <gtk/gtktextiter.h>
34
35G_BEGIN_DECLS
36
37typedef struct _GtkTargetPair GtkTargetPair;
38
39/**
40 * GtkTargetPair:
41 * @target: #GdkAtom representation of the target type
42 * @flags: #GtkTargetFlags for DND
43 * @info: an application-assigned integer ID which will
44 * get passed as a parameter to e.g the #GtkWidget::selection-get
45 * signal. It allows the application to identify the target
46 * type without extensive string compares.
47 *
48 * A #GtkTargetPair is used to represent the same
49 * information as a table of #GtkTargetEntry, but in
50 * an efficient form.
51 */
52struct _GtkTargetPair
53{
54 GdkAtom target;
55 guint flags;
56 guint info;
57};
58
59/**
60 * GtkTargetList:
61 *
62 * A #GtkTargetList-struct is a reference counted list
63 * of #GtkTargetPair and should be treated as
64 * opaque.
65 */
66typedef struct _GtkTargetList GtkTargetList;
67typedef struct _GtkTargetEntry GtkTargetEntry;
68
69#define GTK_TYPE_SELECTION_DATA (gtk_selection_data_get_type ())
70#define GTK_TYPE_TARGET_LIST (gtk_target_list_get_type ())
71
72/**
73 * GtkTargetFlags:
74 * @GTK_TARGET_SAME_APP: If this is set, the target will only be selected
75 * for drags within a single application.
76 * @GTK_TARGET_SAME_WIDGET: If this is set, the target will only be selected
77 * for drags within a single widget.
78 * @GTK_TARGET_OTHER_APP: If this is set, the target will not be selected
79 * for drags within a single application.
80 * @GTK_TARGET_OTHER_WIDGET: If this is set, the target will not be selected
81 * for drags withing a single widget.
82 *
83 * The #GtkTargetFlags enumeration is used to specify
84 * constraints on a #GtkTargetEntry.
85 */
86typedef enum {
87 GTK_TARGET_SAME_APP = 1 << 0, /*< nick=same-app >*/
88 GTK_TARGET_SAME_WIDGET = 1 << 1, /*< nick=same-widget >*/
89 GTK_TARGET_OTHER_APP = 1 << 2, /*< nick=other-app >*/
90 GTK_TARGET_OTHER_WIDGET = 1 << 3 /*< nick=other-widget >*/
91} GtkTargetFlags;
92
93/**
94 * GtkTargetEntry:
95 * @target: a string representation of the target type
96 * @flags: #GtkTargetFlags for DND
97 * @info: an application-assigned integer ID which will
98 * get passed as a parameter to e.g the #GtkWidget::selection-get
99 * signal. It allows the application to identify the target
100 * type without extensive string compares.
101 *
102 * A #GtkTargetEntry represents a single type of
103 * data than can be supplied for by a widget for a selection
104 * or for supplied or received during drag-and-drop.
105 */
106struct _GtkTargetEntry
107{
108 gchar *target;
109 guint flags;
110 guint info;
111};
112
113GDK_AVAILABLE_IN_ALL
114GType gtk_target_list_get_type (void) G_GNUC_CONST;
115GDK_AVAILABLE_IN_ALL
116GtkTargetList *gtk_target_list_new (const GtkTargetEntry *targets,
117 guint ntargets);
118GDK_AVAILABLE_IN_ALL
119GtkTargetList *gtk_target_list_ref (GtkTargetList *list);
120GDK_AVAILABLE_IN_ALL
121void gtk_target_list_unref (GtkTargetList *list);
122GDK_AVAILABLE_IN_ALL
123void gtk_target_list_add (GtkTargetList *list,
124 GdkAtom target,
125 guint flags,
126 guint info);
127GDK_AVAILABLE_IN_ALL
128void gtk_target_list_add_text_targets (GtkTargetList *list,
129 guint info);
130GDK_AVAILABLE_IN_ALL
131void gtk_target_list_add_rich_text_targets (GtkTargetList *list,
132 guint info,
133 gboolean deserializable,
134 GtkTextBuffer *buffer);
135GDK_AVAILABLE_IN_ALL
136void gtk_target_list_add_image_targets (GtkTargetList *list,
137 guint info,
138 gboolean writable);
139GDK_AVAILABLE_IN_ALL
140void gtk_target_list_add_uri_targets (GtkTargetList *list,
141 guint info);
142GDK_AVAILABLE_IN_ALL
143void gtk_target_list_add_table (GtkTargetList *list,
144 const GtkTargetEntry *targets,
145 guint ntargets);
146GDK_AVAILABLE_IN_ALL
147void gtk_target_list_remove (GtkTargetList *list,
148 GdkAtom target);
149GDK_AVAILABLE_IN_ALL
150gboolean gtk_target_list_find (GtkTargetList *list,
151 GdkAtom target,
152 guint *info);
153
154GDK_AVAILABLE_IN_ALL
155GtkTargetEntry * gtk_target_table_new_from_list (GtkTargetList *list,
156 gint *n_targets);
157GDK_AVAILABLE_IN_ALL
158void gtk_target_table_free (GtkTargetEntry *targets,
159 gint n_targets);
160
161GDK_AVAILABLE_IN_ALL
162gboolean gtk_selection_owner_set (GtkWidget *widget,
163 GdkAtom selection,
164 guint32 time_);
165GDK_AVAILABLE_IN_ALL
166gboolean gtk_selection_owner_set_for_display (GdkDisplay *display,
167 GtkWidget *widget,
168 GdkAtom selection,
169 guint32 time_);
170
171GDK_AVAILABLE_IN_ALL
172void gtk_selection_add_target (GtkWidget *widget,
173 GdkAtom selection,
174 GdkAtom target,
175 guint info);
176GDK_AVAILABLE_IN_ALL
177void gtk_selection_add_targets (GtkWidget *widget,
178 GdkAtom selection,
179 const GtkTargetEntry *targets,
180 guint ntargets);
181GDK_AVAILABLE_IN_ALL
182void gtk_selection_clear_targets (GtkWidget *widget,
183 GdkAtom selection);
184GDK_AVAILABLE_IN_ALL
185gboolean gtk_selection_convert (GtkWidget *widget,
186 GdkAtom selection,
187 GdkAtom target,
188 guint32 time_);
189GDK_AVAILABLE_IN_ALL
190void gtk_selection_remove_all (GtkWidget *widget);
191
192GDK_AVAILABLE_IN_ALL
193GdkAtom gtk_selection_data_get_selection (const GtkSelectionData *selection_data);
194GDK_AVAILABLE_IN_ALL
195GdkAtom gtk_selection_data_get_target (const GtkSelectionData *selection_data);
196GDK_AVAILABLE_IN_ALL
197GdkAtom gtk_selection_data_get_data_type (const GtkSelectionData *selection_data);
198GDK_AVAILABLE_IN_ALL
199gint gtk_selection_data_get_format (const GtkSelectionData *selection_data);
200GDK_AVAILABLE_IN_ALL
201const guchar *gtk_selection_data_get_data (const GtkSelectionData *selection_data);
202GDK_AVAILABLE_IN_ALL
203gint gtk_selection_data_get_length (const GtkSelectionData *selection_data);
204GDK_AVAILABLE_IN_ALL
205const guchar *gtk_selection_data_get_data_with_length
206 (const GtkSelectionData *selection_data,
207 gint *length);
208
209GDK_AVAILABLE_IN_ALL
210GdkDisplay *gtk_selection_data_get_display (const GtkSelectionData *selection_data);
211
212GDK_AVAILABLE_IN_ALL
213void gtk_selection_data_set (GtkSelectionData *selection_data,
214 GdkAtom type,
215 gint format,
216 const guchar *data,
217 gint length);
218GDK_AVAILABLE_IN_ALL
219gboolean gtk_selection_data_set_text (GtkSelectionData *selection_data,
220 const gchar *str,
221 gint len);
222GDK_AVAILABLE_IN_ALL
223guchar * gtk_selection_data_get_text (const GtkSelectionData *selection_data);
224GDK_AVAILABLE_IN_ALL
225gboolean gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data,
226 GdkPixbuf *pixbuf);
227GDK_AVAILABLE_IN_ALL
228GdkPixbuf *gtk_selection_data_get_pixbuf (const GtkSelectionData *selection_data);
229GDK_AVAILABLE_IN_ALL
230gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data,
231 gchar **uris);
232GDK_AVAILABLE_IN_ALL
233gchar **gtk_selection_data_get_uris (const GtkSelectionData *selection_data);
234
235GDK_AVAILABLE_IN_ALL
236gboolean gtk_selection_data_get_targets (const GtkSelectionData *selection_data,
237 GdkAtom **targets,
238 gint *n_atoms);
239GDK_AVAILABLE_IN_ALL
240gboolean gtk_selection_data_targets_include_text (const GtkSelectionData *selection_data);
241GDK_AVAILABLE_IN_ALL
242gboolean gtk_selection_data_targets_include_rich_text (const GtkSelectionData *selection_data,
243 GtkTextBuffer *buffer);
244GDK_AVAILABLE_IN_ALL
245gboolean gtk_selection_data_targets_include_image (const GtkSelectionData *selection_data,
246 gboolean writable);
247GDK_AVAILABLE_IN_ALL
248gboolean gtk_selection_data_targets_include_uri (const GtkSelectionData *selection_data);
249GDK_AVAILABLE_IN_ALL
250gboolean gtk_targets_include_text (GdkAtom *targets,
251 gint n_targets);
252GDK_AVAILABLE_IN_ALL
253gboolean gtk_targets_include_rich_text (GdkAtom *targets,
254 gint n_targets,
255 GtkTextBuffer *buffer);
256GDK_AVAILABLE_IN_ALL
257gboolean gtk_targets_include_image (GdkAtom *targets,
258 gint n_targets,
259 gboolean writable);
260GDK_AVAILABLE_IN_ALL
261gboolean gtk_targets_include_uri (GdkAtom *targets,
262 gint n_targets);
263
264
265GDK_AVAILABLE_IN_ALL
266GType gtk_selection_data_get_type (void) G_GNUC_CONST;
267GDK_AVAILABLE_IN_ALL
268GtkSelectionData *gtk_selection_data_copy (const GtkSelectionData *data);
269GDK_AVAILABLE_IN_ALL
270void gtk_selection_data_free (GtkSelectionData *data);
271
272GDK_AVAILABLE_IN_ALL
273GType gtk_target_entry_get_type (void) G_GNUC_CONST;
274GDK_AVAILABLE_IN_ALL
275GtkTargetEntry *gtk_target_entry_new (const gchar *target,
276 guint flags,
277 guint info);
278GDK_AVAILABLE_IN_ALL
279GtkTargetEntry *gtk_target_entry_copy (GtkTargetEntry *data);
280GDK_AVAILABLE_IN_ALL
281void gtk_target_entry_free (GtkTargetEntry *data);
282
283G_END_DECLS
284
285#endif /* __GTK_SELECTION_H__ */
286