]> Pileus Git - ~andy/gtk/blob - gtk/gtkclipboard.h
Practically everything changed.
[~andy/gtk] / gtk / gtkclipboard.h
1 /* GTK - The GTK+ 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 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23 #error "Only <gtk/gtk.h> can be included directly."
24 #endif
25
26 #ifndef __GTK_CLIPBOARD_H__
27 #define __GTK_CLIPBOARD_H__
28
29 #include <gtk/gtkselection.h>
30
31 G_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
37 typedef void (* GtkClipboardReceivedFunc)         (GtkClipboard     *clipboard,
38                                                    GtkSelectionData *selection_data,
39                                                    gpointer          data);
40 typedef void (* GtkClipboardTextReceivedFunc)     (GtkClipboard     *clipboard,
41                                                    const gchar      *text,
42                                                    gpointer          data);
43 typedef void (* GtkClipboardRichTextReceivedFunc) (GtkClipboard     *clipboard,
44                                                    GdkAtom           format,
45                                                    const guint8     *text,
46                                                    gsize             length,
47                                                    gpointer          data);
48 typedef void (* GtkClipboardImageReceivedFunc)    (GtkClipboard     *clipboard,
49                                                    GdkPixbuf        *pixbuf,
50                                                    gpointer          data);
51 typedef void (* GtkClipboardURIReceivedFunc)      (GtkClipboard     *clipboard,
52                                                    gchar           **uris,
53                                                    gpointer          data);
54 typedef 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  */
63 typedef void (* GtkClipboardGetFunc)          (GtkClipboard     *clipboard,
64                                                GtkSelectionData *selection_data,
65                                                guint             info,
66                                                gpointer          user_data_or_owner);
67 typedef void (* GtkClipboardClearFunc)        (GtkClipboard     *clipboard,
68                                                gpointer          user_data_or_owner);
69
70 GType         gtk_clipboard_get_type (void) G_GNUC_CONST;
71
72 GtkClipboard *gtk_clipboard_get_for_display (GdkDisplay   *display,
73                                              GdkAtom       selection);
74 #ifndef GDK_MULTIHEAD_SAFE
75 GtkClipboard *gtk_clipboard_get             (GdkAtom       selection);
76 #endif
77
78 GdkDisplay   *gtk_clipboard_get_display     (GtkClipboard *clipboard);
79
80
81 gboolean 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);
87 gboolean 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);
93 GObject *gtk_clipboard_get_owner      (GtkClipboard          *clipboard);
94 void     gtk_clipboard_clear          (GtkClipboard          *clipboard);
95 void     gtk_clipboard_set_text       (GtkClipboard          *clipboard,
96                                        const gchar           *text,
97                                        gint                   len);
98 void     gtk_clipboard_set_image      (GtkClipboard          *clipboard,
99                                        GdkPixbuf             *pixbuf);
100
101 void gtk_clipboard_request_contents  (GtkClipboard                     *clipboard,
102                                       GdkAtom                           target,
103                                       GtkClipboardReceivedFunc          callback,
104                                       gpointer                          user_data);
105 void gtk_clipboard_request_text      (GtkClipboard                     *clipboard,
106                                       GtkClipboardTextReceivedFunc      callback,
107                                       gpointer                          user_data);
108 void gtk_clipboard_request_rich_text (GtkClipboard                     *clipboard,
109                                       GtkTextBuffer                    *buffer,
110                                       GtkClipboardRichTextReceivedFunc  callback,
111                                       gpointer                          user_data);
112 void gtk_clipboard_request_image     (GtkClipboard                     *clipboard,
113                                       GtkClipboardImageReceivedFunc     callback,
114                                       gpointer                          user_data);
115 void gtk_clipboard_request_uris      (GtkClipboard                     *clipboard,
116                                       GtkClipboardURIReceivedFunc       callback,
117                                       gpointer                          user_data);
118 void gtk_clipboard_request_targets   (GtkClipboard                     *clipboard,
119                                       GtkClipboardTargetsReceivedFunc   callback,
120                                       gpointer                          user_data);
121
122 GtkSelectionData *gtk_clipboard_wait_for_contents  (GtkClipboard  *clipboard,
123                                                     GdkAtom        target);
124 gchar *           gtk_clipboard_wait_for_text      (GtkClipboard  *clipboard);
125 guint8 *          gtk_clipboard_wait_for_rich_text (GtkClipboard  *clipboard,
126                                                     GtkTextBuffer *buffer,
127                                                     GdkAtom       *format,
128                                                     gsize         *length);
129 GdkPixbuf *       gtk_clipboard_wait_for_image     (GtkClipboard  *clipboard);
130 gchar **          gtk_clipboard_wait_for_uris      (GtkClipboard  *clipboard);
131 gboolean          gtk_clipboard_wait_for_targets   (GtkClipboard  *clipboard,
132                                                     GdkAtom      **targets,
133                                                     gint          *n_targets);
134
135 gboolean gtk_clipboard_wait_is_text_available      (GtkClipboard  *clipboard);
136 gboolean gtk_clipboard_wait_is_rich_text_available (GtkClipboard  *clipboard,
137                                                     GtkTextBuffer *buffer);
138 gboolean gtk_clipboard_wait_is_image_available     (GtkClipboard  *clipboard);
139 gboolean gtk_clipboard_wait_is_uris_available      (GtkClipboard  *clipboard);
140 gboolean gtk_clipboard_wait_is_target_available    (GtkClipboard  *clipboard,
141                                                     GdkAtom        target);
142
143
144 void gtk_clipboard_set_can_store (GtkClipboard         *clipboard,
145                                   const GtkTargetEntry *targets,
146                                   gint                  n_targets);
147
148 void gtk_clipboard_store         (GtkClipboard   *clipboard);
149
150 /* private */
151 void     _gtk_clipboard_handle_event    (GdkEventOwnerChange *event);
152
153 void     _gtk_clipboard_store_all       (void);
154
155 G_END_DECLS
156
157 #endif /* __GTK_CLIPBOARD_H__ */