]> Pileus Git - ~andy/gtk/blob - gtk/gtkselection.h
Revert name change
[~andy/gtk] / gtk / gtkselection.h
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
29 #endif
30
31 #ifndef __GTK_SELECTION_H__
32 #define __GTK_SELECTION_H__
33
34 #include <gtk/gtkenums.h>
35 #include <gtk/gtkwidget.h>
36 #include <gtk/gtktextiter.h>
37
38 G_BEGIN_DECLS
39
40 typedef struct _GtkTargetList    GtkTargetList;
41 typedef struct _GtkTargetEntry   GtkTargetEntry;
42
43 #define GTK_TYPE_SELECTION_DATA (gtk_selection_data_get_type ())
44 #define GTK_TYPE_TARGET_LIST    (gtk_target_list_get_type ())
45
46 /* The contents of a selection are returned in a GtkSelectionData
47  * structure. selection/target identify the request.  type specifies
48  * the type of the return; if length < 0, and the data should be
49  * ignored. This structure has object semantics - no fields should be
50  * modified directly, they should not be created directly, and
51  * pointers to them should not be stored beyond the duration of a
52  * callback. (If the last is changed, we'll need to add reference
53  * counting.) The time field gives the timestamp at which the data was
54  * sent.
55  */
56
57 struct _GtkSelectionData
58 {
59   GdkAtom       GSEAL (selection);
60   GdkAtom       GSEAL (target);
61   GdkAtom       GSEAL (type);
62   gint          GSEAL (format);
63   guchar       *GSEAL (data);
64   gint          GSEAL (length);
65   GdkDisplay   *GSEAL (display);
66 };
67
68 struct _GtkTargetEntry {
69   gchar *target;
70   guint  flags;
71   guint  info;
72 };
73
74 /* These structures not public, and are here only for the convenience of
75  * gtkdnd.c
76  */
77
78 typedef struct _GtkTargetPair GtkTargetPair;
79
80 /* This structure is a list of destinations, and associated guint id's */
81 struct _GtkTargetList {
82   GList *list;
83   guint ref_count;
84 };
85
86 struct _GtkTargetPair {
87   GdkAtom   target;
88   guint     flags;
89   guint     info;
90 };
91
92 GtkTargetList *gtk_target_list_new       (const GtkTargetEntry *targets,
93                                           guint                 ntargets);
94 GtkTargetList *gtk_target_list_ref       (GtkTargetList  *list);
95 void           gtk_target_list_unref     (GtkTargetList  *list);
96 void           gtk_target_list_add       (GtkTargetList  *list,
97                                           GdkAtom         target,
98                                           guint           flags,
99                                           guint           info);
100 void           gtk_target_list_add_text_targets      (GtkTargetList  *list,
101                                                       guint           info);
102 void           gtk_target_list_add_rich_text_targets (GtkTargetList  *list,
103                                                       guint           info,
104                                                       gboolean        deserializable,
105                                                       GtkTextBuffer  *buffer);
106 void           gtk_target_list_add_image_targets     (GtkTargetList  *list,
107                                                       guint           info,
108                                                       gboolean        writable);
109 void           gtk_target_list_add_uri_targets       (GtkTargetList  *list,
110                                                       guint           info);
111 void           gtk_target_list_add_table (GtkTargetList        *list,
112                                           const GtkTargetEntry *targets,
113                                           guint                 ntargets);
114 void           gtk_target_list_remove    (GtkTargetList  *list,
115                                           GdkAtom         target);
116 gboolean       gtk_target_list_find      (GtkTargetList  *list,
117                                           GdkAtom         target,
118                                           guint          *info);
119
120 GtkTargetEntry * gtk_target_table_new_from_list (GtkTargetList  *list,
121                                                  gint           *n_targets);
122 void             gtk_target_table_free          (GtkTargetEntry *targets,
123                                                  gint            n_targets);
124
125 /* Public interface */
126
127 gboolean gtk_selection_owner_set             (GtkWidget  *widget,
128                                               GdkAtom     selection,
129                                               guint32     time_);
130 gboolean gtk_selection_owner_set_for_display (GdkDisplay *display,
131                                               GtkWidget  *widget,
132                                               GdkAtom     selection,
133                                               guint32     time_);
134
135 void     gtk_selection_add_target    (GtkWidget            *widget,
136                                       GdkAtom               selection,
137                                       GdkAtom               target,
138                                       guint                 info);
139 void     gtk_selection_add_targets   (GtkWidget            *widget,
140                                       GdkAtom               selection,
141                                       const GtkTargetEntry *targets,
142                                       guint                 ntargets);
143 void     gtk_selection_clear_targets (GtkWidget            *widget,
144                                       GdkAtom               selection);
145 gboolean gtk_selection_convert       (GtkWidget            *widget,
146                                       GdkAtom               selection,
147                                       GdkAtom               target,
148                                       guint32               time_);
149
150 GdkAtom       gtk_selection_data_get_target    (GtkSelectionData *selection_data);
151 GdkAtom       gtk_selection_data_get_data_type (GtkSelectionData *selection_data);
152 gint          gtk_selection_data_get_format    (GtkSelectionData *selection_data);
153 const guchar *gtk_selection_data_get_data      (GtkSelectionData *selection_data,
154                                                 guint            *length);
155 GdkDisplay   *gtk_selection_data_get_display   (GtkSelectionData *selection_data);
156
157 void     gtk_selection_data_set      (GtkSelectionData     *selection_data,
158                                       GdkAtom               type,
159                                       gint                  format,
160                                       const guchar         *data,
161                                       gint                  length);
162 gboolean gtk_selection_data_set_text (GtkSelectionData     *selection_data,
163                                       const gchar          *str,
164                                       gint                  len);
165 guchar * gtk_selection_data_get_text (GtkSelectionData     *selection_data);
166 gboolean gtk_selection_data_set_pixbuf   (GtkSelectionData  *selection_data,
167                                           GdkPixbuf         *pixbuf);
168 GdkPixbuf *gtk_selection_data_get_pixbuf (GtkSelectionData  *selection_data);
169 gboolean gtk_selection_data_set_uris (GtkSelectionData     *selection_data,
170                                       gchar               **uris);
171 gchar  **gtk_selection_data_get_uris (GtkSelectionData     *selection_data);
172
173 gboolean gtk_selection_data_get_targets          (GtkSelectionData  *selection_data,
174                                                   GdkAtom          **targets,
175                                                   gint              *n_atoms);
176 gboolean gtk_selection_data_targets_include_text (GtkSelectionData  *selection_data);
177 gboolean gtk_selection_data_targets_include_rich_text (GtkSelectionData *selection_data,
178                                                        GtkTextBuffer    *buffer);
179 gboolean gtk_selection_data_targets_include_image (GtkSelectionData  *selection_data,
180                                                    gboolean           writable);
181 gboolean gtk_selection_data_targets_include_uri  (GtkSelectionData  *selection_data);
182 gboolean gtk_targets_include_text                (GdkAtom       *targets,
183                                                   gint           n_targets);
184 gboolean gtk_targets_include_rich_text           (GdkAtom       *targets,
185                                                   gint           n_targets,
186                                                   GtkTextBuffer *buffer);
187 gboolean gtk_targets_include_image               (GdkAtom       *targets,
188                                                   gint           n_targets,
189                                                   gboolean       writable);
190 gboolean gtk_targets_include_uri                 (GdkAtom       *targets,
191                                                   gint           n_targets);
192
193 /* Called when a widget is destroyed */
194
195 void gtk_selection_remove_all      (GtkWidget *widget);
196
197 /* Event handlers */
198 #if !defined(GTK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION)
199 gboolean gtk_selection_clear              (GtkWidget         *widget,
200                                            GdkEventSelection *event);
201 #endif
202 gboolean _gtk_selection_request           (GtkWidget         *widget,
203                                            GdkEventSelection *event);
204 gboolean _gtk_selection_incr_event        (GdkWindow         *window,
205                                            GdkEventProperty  *event);
206 gboolean _gtk_selection_notify            (GtkWidget         *widget,
207                                            GdkEventSelection *event);
208 gboolean _gtk_selection_property_notify   (GtkWidget         *widget,
209                                            GdkEventProperty  *event);
210
211 GType             gtk_selection_data_get_type (void) G_GNUC_CONST;
212 GtkSelectionData *gtk_selection_data_copy     (GtkSelectionData *data);
213 void              gtk_selection_data_free     (GtkSelectionData *data);
214
215 GType             gtk_target_list_get_type    (void) G_GNUC_CONST;
216
217 G_END_DECLS
218
219 #endif /* __GTK_SELECTION_H__ */