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 | |
35 | G_BEGIN_DECLS |
36 | |
37 | typedef 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 | */ |
52 | struct _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 | */ |
66 | typedef struct _GtkTargetList GtkTargetList; |
67 | typedef 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 | */ |
86 | typedef 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 | */ |
106 | struct _GtkTargetEntry |
107 | { |
108 | gchar *target; |
109 | guint flags; |
110 | guint info; |
111 | }; |
112 | |
113 | GDK_AVAILABLE_IN_ALL |
114 | GType gtk_target_list_get_type (void) G_GNUC_CONST; |
115 | GDK_AVAILABLE_IN_ALL |
116 | GtkTargetList *gtk_target_list_new (const GtkTargetEntry *targets, |
117 | guint ntargets); |
118 | GDK_AVAILABLE_IN_ALL |
119 | GtkTargetList *gtk_target_list_ref (GtkTargetList *list); |
120 | GDK_AVAILABLE_IN_ALL |
121 | void gtk_target_list_unref (GtkTargetList *list); |
122 | GDK_AVAILABLE_IN_ALL |
123 | void gtk_target_list_add (GtkTargetList *list, |
124 | GdkAtom target, |
125 | guint flags, |
126 | guint info); |
127 | GDK_AVAILABLE_IN_ALL |
128 | void gtk_target_list_add_text_targets (GtkTargetList *list, |
129 | guint info); |
130 | GDK_AVAILABLE_IN_ALL |
131 | void gtk_target_list_add_rich_text_targets (GtkTargetList *list, |
132 | guint info, |
133 | gboolean deserializable, |
134 | GtkTextBuffer *buffer); |
135 | GDK_AVAILABLE_IN_ALL |
136 | void gtk_target_list_add_image_targets (GtkTargetList *list, |
137 | guint info, |
138 | gboolean writable); |
139 | GDK_AVAILABLE_IN_ALL |
140 | void gtk_target_list_add_uri_targets (GtkTargetList *list, |
141 | guint info); |
142 | GDK_AVAILABLE_IN_ALL |
143 | void gtk_target_list_add_table (GtkTargetList *list, |
144 | const GtkTargetEntry *targets, |
145 | guint ntargets); |
146 | GDK_AVAILABLE_IN_ALL |
147 | void gtk_target_list_remove (GtkTargetList *list, |
148 | GdkAtom target); |
149 | GDK_AVAILABLE_IN_ALL |
150 | gboolean gtk_target_list_find (GtkTargetList *list, |
151 | GdkAtom target, |
152 | guint *info); |
153 | |
154 | GDK_AVAILABLE_IN_ALL |
155 | GtkTargetEntry * gtk_target_table_new_from_list (GtkTargetList *list, |
156 | gint *n_targets); |
157 | GDK_AVAILABLE_IN_ALL |
158 | void gtk_target_table_free (GtkTargetEntry *targets, |
159 | gint n_targets); |
160 | |
161 | GDK_AVAILABLE_IN_ALL |
162 | gboolean gtk_selection_owner_set (GtkWidget *widget, |
163 | GdkAtom selection, |
164 | guint32 time_); |
165 | GDK_AVAILABLE_IN_ALL |
166 | gboolean gtk_selection_owner_set_for_display (GdkDisplay *display, |
167 | GtkWidget *widget, |
168 | GdkAtom selection, |
169 | guint32 time_); |
170 | |
171 | GDK_AVAILABLE_IN_ALL |
172 | void gtk_selection_add_target (GtkWidget *widget, |
173 | GdkAtom selection, |
174 | GdkAtom target, |
175 | guint info); |
176 | GDK_AVAILABLE_IN_ALL |
177 | void gtk_selection_add_targets (GtkWidget *widget, |
178 | GdkAtom selection, |
179 | const GtkTargetEntry *targets, |
180 | guint ntargets); |
181 | GDK_AVAILABLE_IN_ALL |
182 | void gtk_selection_clear_targets (GtkWidget *widget, |
183 | GdkAtom selection); |
184 | GDK_AVAILABLE_IN_ALL |
185 | gboolean gtk_selection_convert (GtkWidget *widget, |
186 | GdkAtom selection, |
187 | GdkAtom target, |
188 | guint32 time_); |
189 | GDK_AVAILABLE_IN_ALL |
190 | void gtk_selection_remove_all (GtkWidget *widget); |
191 | |
192 | GDK_AVAILABLE_IN_ALL |
193 | GdkAtom gtk_selection_data_get_selection (const GtkSelectionData *selection_data); |
194 | GDK_AVAILABLE_IN_ALL |
195 | GdkAtom gtk_selection_data_get_target (const GtkSelectionData *selection_data); |
196 | GDK_AVAILABLE_IN_ALL |
197 | GdkAtom gtk_selection_data_get_data_type (const GtkSelectionData *selection_data); |
198 | GDK_AVAILABLE_IN_ALL |
199 | gint gtk_selection_data_get_format (const GtkSelectionData *selection_data); |
200 | GDK_AVAILABLE_IN_ALL |
201 | const guchar *gtk_selection_data_get_data (const GtkSelectionData *selection_data); |
202 | GDK_AVAILABLE_IN_ALL |
203 | gint gtk_selection_data_get_length (const GtkSelectionData *selection_data); |
204 | GDK_AVAILABLE_IN_ALL |
205 | const guchar *gtk_selection_data_get_data_with_length |
206 | (const GtkSelectionData *selection_data, |
207 | gint *length); |
208 | |
209 | GDK_AVAILABLE_IN_ALL |
210 | GdkDisplay *gtk_selection_data_get_display (const GtkSelectionData *selection_data); |
211 | |
212 | GDK_AVAILABLE_IN_ALL |
213 | void gtk_selection_data_set (GtkSelectionData *selection_data, |
214 | GdkAtom type, |
215 | gint format, |
216 | const guchar *data, |
217 | gint length); |
218 | GDK_AVAILABLE_IN_ALL |
219 | gboolean gtk_selection_data_set_text (GtkSelectionData *selection_data, |
220 | const gchar *str, |
221 | gint len); |
222 | GDK_AVAILABLE_IN_ALL |
223 | guchar * gtk_selection_data_get_text (const GtkSelectionData *selection_data); |
224 | GDK_AVAILABLE_IN_ALL |
225 | gboolean gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data, |
226 | GdkPixbuf *pixbuf); |
227 | GDK_AVAILABLE_IN_ALL |
228 | GdkPixbuf *gtk_selection_data_get_pixbuf (const GtkSelectionData *selection_data); |
229 | GDK_AVAILABLE_IN_ALL |
230 | gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data, |
231 | gchar **uris); |
232 | GDK_AVAILABLE_IN_ALL |
233 | gchar **gtk_selection_data_get_uris (const GtkSelectionData *selection_data); |
234 | |
235 | GDK_AVAILABLE_IN_ALL |
236 | gboolean gtk_selection_data_get_targets (const GtkSelectionData *selection_data, |
237 | GdkAtom **targets, |
238 | gint *n_atoms); |
239 | GDK_AVAILABLE_IN_ALL |
240 | gboolean gtk_selection_data_targets_include_text (const GtkSelectionData *selection_data); |
241 | GDK_AVAILABLE_IN_ALL |
242 | gboolean gtk_selection_data_targets_include_rich_text (const GtkSelectionData *selection_data, |
243 | GtkTextBuffer *buffer); |
244 | GDK_AVAILABLE_IN_ALL |
245 | gboolean gtk_selection_data_targets_include_image (const GtkSelectionData *selection_data, |
246 | gboolean writable); |
247 | GDK_AVAILABLE_IN_ALL |
248 | gboolean gtk_selection_data_targets_include_uri (const GtkSelectionData *selection_data); |
249 | GDK_AVAILABLE_IN_ALL |
250 | gboolean gtk_targets_include_text (GdkAtom *targets, |
251 | gint n_targets); |
252 | GDK_AVAILABLE_IN_ALL |
253 | gboolean gtk_targets_include_rich_text (GdkAtom *targets, |
254 | gint n_targets, |
255 | GtkTextBuffer *buffer); |
256 | GDK_AVAILABLE_IN_ALL |
257 | gboolean gtk_targets_include_image (GdkAtom *targets, |
258 | gint n_targets, |
259 | gboolean writable); |
260 | GDK_AVAILABLE_IN_ALL |
261 | gboolean gtk_targets_include_uri (GdkAtom *targets, |
262 | gint n_targets); |
263 | |
264 | |
265 | GDK_AVAILABLE_IN_ALL |
266 | GType gtk_selection_data_get_type (void) G_GNUC_CONST; |
267 | GDK_AVAILABLE_IN_ALL |
268 | GtkSelectionData *gtk_selection_data_copy (const GtkSelectionData *data); |
269 | GDK_AVAILABLE_IN_ALL |
270 | void gtk_selection_data_free (GtkSelectionData *data); |
271 | |
272 | GDK_AVAILABLE_IN_ALL |
273 | GType gtk_target_entry_get_type (void) G_GNUC_CONST; |
274 | GDK_AVAILABLE_IN_ALL |
275 | GtkTargetEntry *gtk_target_entry_new (const gchar *target, |
276 | guint flags, |
277 | guint info); |
278 | GDK_AVAILABLE_IN_ALL |
279 | GtkTargetEntry *gtk_target_entry_copy (GtkTargetEntry *data); |
280 | GDK_AVAILABLE_IN_ALL |
281 | void gtk_target_entry_free (GtkTargetEntry *data); |
282 | |
283 | G_END_DECLS |
284 | |
285 | #endif /* __GTK_SELECTION_H__ */ |
286 | |