1/* GTK - The GIMP Toolkit
2 * Copyright (C) 2000 Red Hat, Inc.
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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Global clipboard abstraction.
20 */
21
22#ifndef __GTK_CLIPBOARD_H__
23#define __GTK_CLIPBOARD_H__
24
25#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
26#error "Only <gtk/gtk.h> can be included directly."
27#endif
28
29#include <gtk/gtkselection.h>
30
31G_BEGIN_DECLS
32
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))
36
37typedef void (* GtkClipboardReceivedFunc) (GtkClipboard *clipboard,
38 GtkSelectionData *selection_data,
39 gpointer data);
40typedef void (* GtkClipboardTextReceivedFunc) (GtkClipboard *clipboard,
41 const gchar *text,
42 gpointer data);
43typedef void (* GtkClipboardRichTextReceivedFunc) (GtkClipboard *clipboard,
44 GdkAtom format,
45 const guint8 *text,
46 gsize length,
47 gpointer data);
48typedef void (* GtkClipboardImageReceivedFunc) (GtkClipboard *clipboard,
49 GdkPixbuf *pixbuf,
50 gpointer data);
51typedef void (* GtkClipboardURIReceivedFunc) (GtkClipboard *clipboard,
52 gchar **uris,
53 gpointer data);
54typedef void (* GtkClipboardTargetsReceivedFunc) (GtkClipboard *clipboard,
55 GdkAtom *atoms,
56 gint n_atoms,
57 gpointer data);
58
59/* Should these functions have GtkClipboard *clipboard as the first argument?
60 * right now for ClearFunc, you may have trouble determining _which_ clipboard
61 * was cleared, if you reuse your ClearFunc for multiple clipboards.
62 */
63typedef void (* GtkClipboardGetFunc) (GtkClipboard *clipboard,
64 GtkSelectionData *selection_data,
65 guint info,
66 gpointer user_data_or_owner);
67typedef void (* GtkClipboardClearFunc) (GtkClipboard *clipboard,
68 gpointer user_data_or_owner);
69
70GType gtk_clipboard_get_type (void) G_GNUC_CONST;
71
72GtkClipboard *gtk_clipboard_get_for_display (GdkDisplay *display,
73 GdkAtom selection);
74#ifndef GDK_MULTIHEAD_SAFE
75GtkClipboard *gtk_clipboard_get (GdkAtom selection);
76#endif
77
78GdkDisplay *gtk_clipboard_get_display (GtkClipboard *clipboard);
79
80
81gboolean gtk_clipboard_set_with_data (GtkClipboard *clipboard,
82 const GtkTargetEntry *targets,
83 guint n_targets,
84 GtkClipboardGetFunc get_func,
85 GtkClipboardClearFunc clear_func,
86 gpointer user_data);
87gboolean gtk_clipboard_set_with_owner (GtkClipboard *clipboard,
88 const GtkTargetEntry *targets,
89 guint n_targets,
90 GtkClipboardGetFunc get_func,
91 GtkClipboardClearFunc clear_func,
92 GObject *owner);
93GObject *gtk_clipboard_get_owner (GtkClipboard *clipboard);
94void gtk_clipboard_clear (GtkClipboard *clipboard);
95void gtk_clipboard_set_text (GtkClipboard *clipboard,
96 const gchar *text,
97 gint len);
98void gtk_clipboard_set_image (GtkClipboard *clipboard,
99 GdkPixbuf *pixbuf);
100
101void gtk_clipboard_request_contents (GtkClipboard *clipboard,
102 GdkAtom target,
103 GtkClipboardReceivedFunc callback,
104 gpointer user_data);
105void gtk_clipboard_request_text (GtkClipboard *clipboard,
106 GtkClipboardTextReceivedFunc callback,
107 gpointer user_data);
108void gtk_clipboard_request_rich_text (GtkClipboard *clipboard,
109 GtkTextBuffer *buffer,
110 GtkClipboardRichTextReceivedFunc callback,
111 gpointer user_data);
112void gtk_clipboard_request_image (GtkClipboard *clipboard,
113 GtkClipboardImageReceivedFunc callback,
114 gpointer user_data);
115void gtk_clipboard_request_uris (GtkClipboard *clipboard,
116 GtkClipboardURIReceivedFunc callback,
117 gpointer user_data);
118void gtk_clipboard_request_targets (GtkClipboard *clipboard,
119 GtkClipboardTargetsReceivedFunc callback,
120 gpointer user_data);
121
122GtkSelectionData *gtk_clipboard_wait_for_contents (GtkClipboard *clipboard,
123 GdkAtom target);
124gchar * gtk_clipboard_wait_for_text (GtkClipboard *clipboard);
125guint8 * gtk_clipboard_wait_for_rich_text (GtkClipboard *clipboard,
126 GtkTextBuffer *buffer,
127 GdkAtom *format,
128 gsize *length);
129GdkPixbuf * gtk_clipboard_wait_for_image (GtkClipboard *clipboard);
130gchar ** gtk_clipboard_wait_for_uris (GtkClipboard *clipboard);
131gboolean gtk_clipboard_wait_for_targets (GtkClipboard *clipboard,
132 GdkAtom **targets,
133 gint *n_targets);
134
135gboolean gtk_clipboard_wait_is_text_available (GtkClipboard *clipboard);
136gboolean gtk_clipboard_wait_is_rich_text_available (GtkClipboard *clipboard,
137 GtkTextBuffer *buffer);
138gboolean gtk_clipboard_wait_is_image_available (GtkClipboard *clipboard);
139gboolean gtk_clipboard_wait_is_uris_available (GtkClipboard *clipboard);
140gboolean gtk_clipboard_wait_is_target_available (GtkClipboard *clipboard,
141 GdkAtom target);
142
143
144void gtk_clipboard_set_can_store (GtkClipboard *clipboard,
145 const GtkTargetEntry *targets,
146 gint n_targets);
147
148void gtk_clipboard_store (GtkClipboard *clipboard);
149
150/* private */
151void _gtk_clipboard_handle_event (GdkEventOwnerChange *event);
152
153void _gtk_clipboard_store_all (void);
154
155G_END_DECLS
156
157#endif /* __GTK_CLIPBOARD_H__ */
158