1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2000 Red Hat, Inc.
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.
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.
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.
19 * Global clipboard abstraction.
22 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23 #error "Only <gtk/gtk.h> can be included directly."
26 #ifndef __GTK_CLIPBOARD_H__
27 #define __GTK_CLIPBOARD_H__
29 #include <gtk/gtkselection.h>
33 #define GTK_TYPE_CLIPBOARD (gtk_clipboard_get_type ())
34 #define GTK_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CLIPBOARD, GtkClipboard))
35 #define GTK_IS_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CLIPBOARD))
38 * GtkClipboardReceivedFunc:
39 * @clipboard: the #GtkClipboard
40 * @selection_data: a #GtkSelectionData containing the data was received.
41 * If retrieving the data failed, then then length field
42 * of @selection_data will be negative.
43 * @data: the @user_data supplied to gtk_clipboard_request_contents().
45 * A function to be called when the results of gtk_clipboard_request_contents()
46 * are received, or when the request fails.
48 typedef void (* GtkClipboardReceivedFunc) (GtkClipboard *clipboard,
49 GtkSelectionData *selection_data,
53 * GtkClipboardTextReceivedFunc:
54 * @clipboard: the #GtkClipboard
55 * @text: the text received, as a UTF-8 encoded string, or %NULL
56 * if retrieving the data failed.
57 * @data: the @user_data supplied to gtk_clipboard_request_text().
59 * A function to be called when the results of gtk_clipboard_request_text()
60 * are received, or when the request fails.
62 typedef void (* GtkClipboardTextReceivedFunc) (GtkClipboard *clipboard,
66 typedef void (* GtkClipboardRichTextReceivedFunc) (GtkClipboard *clipboard,
73 * GtkClipboardImageReceivedFunc:
74 * @clipboard: the #GtkClipboard
75 * @pixbuf: the received image
76 * @data: the @user_data supplied to gtk_clipboard_request_image().
78 * A function to be called when the results of gtk_clipboard_request_image()
79 * are received, or when the request fails.
83 typedef void (* GtkClipboardImageReceivedFunc) (GtkClipboard *clipboard,
87 typedef void (* GtkClipboardURIReceivedFunc) (GtkClipboard *clipboard,
92 * GtkClipboardTargetsReceivedFunc:
93 * @clipboard: the #GtkClipboard
94 * @atoms: the supported targets, as array of #GdkAtom, or %NULL
95 * if retrieving the data failed.
96 * @n_atoms: the length of the @atoms array.
97 * @data: the @user_data supplied to gtk_clipboard_request_targets().
99 * A function to be called when the results of gtk_clipboard_request_targets()
100 * are received, or when the request fails.
104 typedef void (* GtkClipboardTargetsReceivedFunc) (GtkClipboard *clipboard,
109 /* Should these functions have GtkClipboard *clipboard as the first argument?
110 * right now for ClearFunc, you may have trouble determining _which_ clipboard
111 * was cleared, if you reuse your ClearFunc for multiple clipboards.
114 * GtkClipboardGetFunc:
115 * @clipboard: the #GtkClipboard
116 * @selection_data: a #GtkSelectionData argument in which the requested
117 * data should be stored.
118 * @info: the info field corresponding to the requested target from the
119 * #GtkTargetEntry array passed to gtk_clipboard_set_with_data() or
120 * gtk_clipboard_set_with_owner().
121 * @user_data_or_owner: the @user_data argument passed to
122 * gtk_clipboard_set_with_data(), or the @owner argument passed to
123 * gtk_clipboard_set_with_owner()
125 * A function that will be called to provide the contents of the selection.
126 * If multiple types of data were advertised, the requested type can
127 * be determined from the @info parameter or by checking the target field
128 * of @selection_data. If the data could successfully be converted into
129 * then it should be stored into the @selection_data object by
130 * calling gtk_selection_data_set() (or related functions such
131 * as gtk_selection_data_set_text()). If no data is set, the requestor
132 * will be informed that the attempt to get the data failed.
134 typedef void (* GtkClipboardGetFunc) (GtkClipboard *clipboard,
135 GtkSelectionData *selection_data,
137 gpointer user_data_or_owner);
140 * GtkClipboardClearFunc:
141 * @clipboard: the #GtkClipboard
142 * @user_data_or_owner: the @user_data argument passed to gtk_clipboard_set_with_data(),
143 * or the @owner argument passed to gtk_clipboard_set_with_owner()
145 * A function that will be called when the contents of the clipboard are changed
146 * or cleared. Once this has called, the @user_data_or_owner argument
147 * will not be used again.
149 typedef void (* GtkClipboardClearFunc) (GtkClipboard *clipboard,
150 gpointer user_data_or_owner);
152 GType gtk_clipboard_get_type (void) G_GNUC_CONST;
154 GtkClipboard *gtk_clipboard_get_for_display (GdkDisplay *display,
156 #ifndef GDK_MULTIHEAD_SAFE
157 GtkClipboard *gtk_clipboard_get (GdkAtom selection);
160 GdkDisplay *gtk_clipboard_get_display (GtkClipboard *clipboard);
163 gboolean gtk_clipboard_set_with_data (GtkClipboard *clipboard,
164 const GtkTargetEntry *targets,
166 GtkClipboardGetFunc get_func,
167 GtkClipboardClearFunc clear_func,
169 gboolean gtk_clipboard_set_with_owner (GtkClipboard *clipboard,
170 const GtkTargetEntry *targets,
172 GtkClipboardGetFunc get_func,
173 GtkClipboardClearFunc clear_func,
175 GObject *gtk_clipboard_get_owner (GtkClipboard *clipboard);
176 void gtk_clipboard_clear (GtkClipboard *clipboard);
177 void gtk_clipboard_set_text (GtkClipboard *clipboard,
180 void gtk_clipboard_set_image (GtkClipboard *clipboard,
183 void gtk_clipboard_request_contents (GtkClipboard *clipboard,
185 GtkClipboardReceivedFunc callback,
187 void gtk_clipboard_request_text (GtkClipboard *clipboard,
188 GtkClipboardTextReceivedFunc callback,
190 void gtk_clipboard_request_rich_text (GtkClipboard *clipboard,
191 GtkTextBuffer *buffer,
192 GtkClipboardRichTextReceivedFunc callback,
194 void gtk_clipboard_request_image (GtkClipboard *clipboard,
195 GtkClipboardImageReceivedFunc callback,
197 void gtk_clipboard_request_uris (GtkClipboard *clipboard,
198 GtkClipboardURIReceivedFunc callback,
200 void gtk_clipboard_request_targets (GtkClipboard *clipboard,
201 GtkClipboardTargetsReceivedFunc callback,
204 GtkSelectionData *gtk_clipboard_wait_for_contents (GtkClipboard *clipboard,
206 gchar * gtk_clipboard_wait_for_text (GtkClipboard *clipboard);
207 guint8 * gtk_clipboard_wait_for_rich_text (GtkClipboard *clipboard,
208 GtkTextBuffer *buffer,
211 GdkPixbuf * gtk_clipboard_wait_for_image (GtkClipboard *clipboard);
212 gchar ** gtk_clipboard_wait_for_uris (GtkClipboard *clipboard);
213 gboolean gtk_clipboard_wait_for_targets (GtkClipboard *clipboard,
217 gboolean gtk_clipboard_wait_is_text_available (GtkClipboard *clipboard);
218 gboolean gtk_clipboard_wait_is_rich_text_available (GtkClipboard *clipboard,
219 GtkTextBuffer *buffer);
220 gboolean gtk_clipboard_wait_is_image_available (GtkClipboard *clipboard);
221 gboolean gtk_clipboard_wait_is_uris_available (GtkClipboard *clipboard);
222 gboolean gtk_clipboard_wait_is_target_available (GtkClipboard *clipboard,
226 void gtk_clipboard_set_can_store (GtkClipboard *clipboard,
227 const GtkTargetEntry *targets,
230 void gtk_clipboard_store (GtkClipboard *clipboard);
233 void _gtk_clipboard_handle_event (GdkEventOwnerChange *event);
235 void _gtk_clipboard_store_all (void);
239 #endif /* __GTK_CLIPBOARD_H__ */