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, see <http://www.gnu.org/licenses/>.
17 * Global clipboard abstraction.
20 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
21 #error "Only <gtk/gtk.h> can be included directly."
24 #ifndef __GTK_CLIPBOARD_H__
25 #define __GTK_CLIPBOARD_H__
27 #include <gtk/gtkselection.h>
31 #define GTK_TYPE_CLIPBOARD (gtk_clipboard_get_type ())
32 #define GTK_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CLIPBOARD, GtkClipboard))
33 #define GTK_IS_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CLIPBOARD))
36 * GtkClipboardReceivedFunc:
37 * @clipboard: the #GtkClipboard
38 * @selection_data: a #GtkSelectionData containing the data was received.
39 * If retrieving the data failed, then then length field
40 * of @selection_data will be negative.
41 * @data: the @user_data supplied to gtk_clipboard_request_contents().
43 * A function to be called when the results of gtk_clipboard_request_contents()
44 * are received, or when the request fails.
46 typedef void (* GtkClipboardReceivedFunc) (GtkClipboard *clipboard,
47 GtkSelectionData *selection_data,
51 * GtkClipboardTextReceivedFunc:
52 * @clipboard: the #GtkClipboard
53 * @text: the text received, as a UTF-8 encoded string, or %NULL
54 * if retrieving the data failed.
55 * @data: the @user_data supplied to gtk_clipboard_request_text().
57 * A function to be called when the results of gtk_clipboard_request_text()
58 * are received, or when the request fails.
60 typedef void (* GtkClipboardTextReceivedFunc) (GtkClipboard *clipboard,
64 typedef void (* GtkClipboardRichTextReceivedFunc) (GtkClipboard *clipboard,
71 * GtkClipboardImageReceivedFunc:
72 * @clipboard: the #GtkClipboard
73 * @pixbuf: the received image
74 * @data: the @user_data supplied to gtk_clipboard_request_image().
76 * A function to be called when the results of gtk_clipboard_request_image()
77 * are received, or when the request fails.
81 typedef void (* GtkClipboardImageReceivedFunc) (GtkClipboard *clipboard,
85 typedef void (* GtkClipboardURIReceivedFunc) (GtkClipboard *clipboard,
90 * GtkClipboardTargetsReceivedFunc:
91 * @clipboard: the #GtkClipboard
92 * @atoms: the supported targets, as array of #GdkAtom, or %NULL
93 * if retrieving the data failed.
94 * @n_atoms: the length of the @atoms array.
95 * @data: the @user_data supplied to gtk_clipboard_request_targets().
97 * A function to be called when the results of gtk_clipboard_request_targets()
98 * are received, or when the request fails.
102 typedef void (* GtkClipboardTargetsReceivedFunc) (GtkClipboard *clipboard,
107 /* Should these functions have GtkClipboard *clipboard as the first argument?
108 * right now for ClearFunc, you may have trouble determining _which_ clipboard
109 * was cleared, if you reuse your ClearFunc for multiple clipboards.
112 * GtkClipboardGetFunc:
113 * @clipboard: the #GtkClipboard
114 * @selection_data: a #GtkSelectionData argument in which the requested
115 * data should be stored.
116 * @info: the info field corresponding to the requested target from the
117 * #GtkTargetEntry array passed to gtk_clipboard_set_with_data() or
118 * gtk_clipboard_set_with_owner().
119 * @user_data_or_owner: the @user_data argument passed to
120 * gtk_clipboard_set_with_data(), or the @owner argument passed to
121 * gtk_clipboard_set_with_owner()
123 * A function that will be called to provide the contents of the selection.
124 * If multiple types of data were advertised, the requested type can
125 * be determined from the @info parameter or by checking the target field
126 * of @selection_data. If the data could successfully be converted into
127 * then it should be stored into the @selection_data object by
128 * calling gtk_selection_data_set() (or related functions such
129 * as gtk_selection_data_set_text()). If no data is set, the requestor
130 * will be informed that the attempt to get the data failed.
132 typedef void (* GtkClipboardGetFunc) (GtkClipboard *clipboard,
133 GtkSelectionData *selection_data,
135 gpointer user_data_or_owner);
138 * GtkClipboardClearFunc:
139 * @clipboard: the #GtkClipboard
140 * @user_data_or_owner: the @user_data argument passed to gtk_clipboard_set_with_data(),
141 * or the @owner argument passed to gtk_clipboard_set_with_owner()
143 * A function that will be called when the contents of the clipboard are changed
144 * or cleared. Once this has called, the @user_data_or_owner argument
145 * will not be used again.
147 typedef void (* GtkClipboardClearFunc) (GtkClipboard *clipboard,
148 gpointer user_data_or_owner);
150 GType gtk_clipboard_get_type (void) G_GNUC_CONST;
152 GtkClipboard *gtk_clipboard_get_for_display (GdkDisplay *display,
154 #ifndef GDK_MULTIHEAD_SAFE
155 GtkClipboard *gtk_clipboard_get (GdkAtom selection);
158 GdkDisplay *gtk_clipboard_get_display (GtkClipboard *clipboard);
161 gboolean gtk_clipboard_set_with_data (GtkClipboard *clipboard,
162 const GtkTargetEntry *targets,
164 GtkClipboardGetFunc get_func,
165 GtkClipboardClearFunc clear_func,
167 gboolean gtk_clipboard_set_with_owner (GtkClipboard *clipboard,
168 const GtkTargetEntry *targets,
170 GtkClipboardGetFunc get_func,
171 GtkClipboardClearFunc clear_func,
173 GObject *gtk_clipboard_get_owner (GtkClipboard *clipboard);
174 void gtk_clipboard_clear (GtkClipboard *clipboard);
175 void gtk_clipboard_set_text (GtkClipboard *clipboard,
178 void gtk_clipboard_set_image (GtkClipboard *clipboard,
181 void gtk_clipboard_request_contents (GtkClipboard *clipboard,
183 GtkClipboardReceivedFunc callback,
185 void gtk_clipboard_request_text (GtkClipboard *clipboard,
186 GtkClipboardTextReceivedFunc callback,
188 void gtk_clipboard_request_rich_text (GtkClipboard *clipboard,
189 GtkTextBuffer *buffer,
190 GtkClipboardRichTextReceivedFunc callback,
192 void gtk_clipboard_request_image (GtkClipboard *clipboard,
193 GtkClipboardImageReceivedFunc callback,
195 void gtk_clipboard_request_uris (GtkClipboard *clipboard,
196 GtkClipboardURIReceivedFunc callback,
198 void gtk_clipboard_request_targets (GtkClipboard *clipboard,
199 GtkClipboardTargetsReceivedFunc callback,
202 GtkSelectionData *gtk_clipboard_wait_for_contents (GtkClipboard *clipboard,
204 gchar * gtk_clipboard_wait_for_text (GtkClipboard *clipboard);
205 guint8 * gtk_clipboard_wait_for_rich_text (GtkClipboard *clipboard,
206 GtkTextBuffer *buffer,
209 GdkPixbuf * gtk_clipboard_wait_for_image (GtkClipboard *clipboard);
210 gchar ** gtk_clipboard_wait_for_uris (GtkClipboard *clipboard);
211 gboolean gtk_clipboard_wait_for_targets (GtkClipboard *clipboard,
215 gboolean gtk_clipboard_wait_is_text_available (GtkClipboard *clipboard);
216 gboolean gtk_clipboard_wait_is_rich_text_available (GtkClipboard *clipboard,
217 GtkTextBuffer *buffer);
218 gboolean gtk_clipboard_wait_is_image_available (GtkClipboard *clipboard);
219 gboolean gtk_clipboard_wait_is_uris_available (GtkClipboard *clipboard);
220 gboolean gtk_clipboard_wait_is_target_available (GtkClipboard *clipboard,
224 void gtk_clipboard_set_can_store (GtkClipboard *clipboard,
225 const GtkTargetEntry *targets,
228 void gtk_clipboard_store (GtkClipboard *clipboard);
231 void _gtk_clipboard_handle_event (GdkEventOwnerChange *event);
233 void _gtk_clipboard_store_all (void);
237 #endif /* __GTK_CLIPBOARD_H__ */