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