]> Pileus Git - ~andy/gtk/blob - gtk/gtkselection.h
Move GtkSelectionData to a private header
[~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_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 <gtk/gtkwidget.h>
36 #include <gtk/gtktextiter.h>
37
38
39 G_BEGIN_DECLS
40
41 typedef struct _GtkTargetList    GtkTargetList;
42 typedef struct _GtkTargetEntry   GtkTargetEntry;
43
44 #define GTK_TYPE_SELECTION_DATA (gtk_selection_data_get_type ())
45 #define GTK_TYPE_TARGET_LIST    (gtk_target_list_get_type ())
46
47 struct _GtkTargetEntry
48 {
49   gchar *target;
50   guint  flags;
51   guint  info;
52 };
53
54 /* These structures not public, and are here only for the convenience of
55  * gtkdnd.c
56  */
57
58 typedef struct _GtkTargetPair GtkTargetPair;
59
60 /* This structure is a list of destinations, and associated guint id's */
61 struct _GtkTargetList {
62   GList *list;
63   guint ref_count;
64 };
65
66 struct _GtkTargetPair {
67   GdkAtom   target;
68   guint     flags;
69   guint     info;
70 };
71
72 GtkTargetList *gtk_target_list_new       (const GtkTargetEntry *targets,
73                                           guint                 ntargets);
74 GtkTargetList *gtk_target_list_ref       (GtkTargetList  *list);
75 void           gtk_target_list_unref     (GtkTargetList  *list);
76 void           gtk_target_list_add       (GtkTargetList  *list,
77                                           GdkAtom         target,
78                                           guint           flags,
79                                           guint           info);
80 void           gtk_target_list_add_text_targets      (GtkTargetList  *list,
81                                                       guint           info);
82 void           gtk_target_list_add_rich_text_targets (GtkTargetList  *list,
83                                                       guint           info,
84                                                       gboolean        deserializable,
85                                                       GtkTextBuffer  *buffer);
86 void           gtk_target_list_add_image_targets     (GtkTargetList  *list,
87                                                       guint           info,
88                                                       gboolean        writable);
89 void           gtk_target_list_add_uri_targets       (GtkTargetList  *list,
90                                                       guint           info);
91 void           gtk_target_list_add_table (GtkTargetList        *list,
92                                           const GtkTargetEntry *targets,
93                                           guint                 ntargets);
94 void           gtk_target_list_remove    (GtkTargetList  *list,
95                                           GdkAtom         target);
96 gboolean       gtk_target_list_find      (GtkTargetList  *list,
97                                           GdkAtom         target,
98                                           guint          *info);
99
100 GtkTargetEntry * gtk_target_table_new_from_list (GtkTargetList  *list,
101                                                  gint           *n_targets);
102 void             gtk_target_table_free          (GtkTargetEntry *targets,
103                                                  gint            n_targets);
104
105 /* Public interface */
106
107 gboolean gtk_selection_owner_set             (GtkWidget  *widget,
108                                               GdkAtom     selection,
109                                               guint32     time_);
110 gboolean gtk_selection_owner_set_for_display (GdkDisplay *display,
111                                               GtkWidget  *widget,
112                                               GdkAtom     selection,
113                                               guint32     time_);
114
115 void     gtk_selection_add_target    (GtkWidget            *widget,
116                                       GdkAtom               selection,
117                                       GdkAtom               target,
118                                       guint                 info);
119 void     gtk_selection_add_targets   (GtkWidget            *widget,
120                                       GdkAtom               selection,
121                                       const GtkTargetEntry *targets,
122                                       guint                 ntargets);
123 void     gtk_selection_clear_targets (GtkWidget            *widget,
124                                       GdkAtom               selection);
125 gboolean gtk_selection_convert       (GtkWidget            *widget,
126                                       GdkAtom               selection,
127                                       GdkAtom               target,
128                                       guint32               time_);
129
130 GdkAtom       gtk_selection_data_get_selection (const GtkSelectionData *selection_data);
131 GdkAtom       gtk_selection_data_get_target    (const GtkSelectionData *selection_data);
132 GdkAtom       gtk_selection_data_get_data_type (const GtkSelectionData *selection_data);
133 gint          gtk_selection_data_get_format    (const GtkSelectionData *selection_data);
134 const guchar *gtk_selection_data_get_data      (const GtkSelectionData *selection_data);
135 gint          gtk_selection_data_get_length    (const GtkSelectionData *selection_data);
136 GdkDisplay   *gtk_selection_data_get_display   (const GtkSelectionData *selection_data);
137
138 void     gtk_selection_data_set      (GtkSelectionData     *selection_data,
139                                       GdkAtom               type,
140                                       gint                  format,
141                                       const guchar         *data,
142                                       gint                  length);
143 gboolean gtk_selection_data_set_text (GtkSelectionData     *selection_data,
144                                       const gchar          *str,
145                                       gint                  len);
146 guchar * gtk_selection_data_get_text (const GtkSelectionData     *selection_data);
147 gboolean gtk_selection_data_set_pixbuf   (GtkSelectionData  *selection_data,
148                                           GdkPixbuf         *pixbuf);
149 GdkPixbuf *gtk_selection_data_get_pixbuf (const GtkSelectionData  *selection_data);
150 gboolean gtk_selection_data_set_uris (GtkSelectionData     *selection_data,
151                                       gchar               **uris);
152 gchar  **gtk_selection_data_get_uris (const GtkSelectionData     *selection_data);
153
154 gboolean gtk_selection_data_get_targets          (const GtkSelectionData  *selection_data,
155                                                   GdkAtom          **targets,
156                                                   gint              *n_atoms);
157 gboolean gtk_selection_data_targets_include_text (const GtkSelectionData  *selection_data);
158 gboolean gtk_selection_data_targets_include_rich_text (const GtkSelectionData *selection_data,
159                                                        GtkTextBuffer    *buffer);
160 gboolean gtk_selection_data_targets_include_image (const GtkSelectionData  *selection_data,
161                                                    gboolean           writable);
162 gboolean gtk_selection_data_targets_include_uri  (const GtkSelectionData  *selection_data);
163 gboolean gtk_targets_include_text                (GdkAtom       *targets,
164                                                   gint           n_targets);
165 gboolean gtk_targets_include_rich_text           (GdkAtom       *targets,
166                                                   gint           n_targets,
167                                                   GtkTextBuffer *buffer);
168 gboolean gtk_targets_include_image               (GdkAtom       *targets,
169                                                   gint           n_targets,
170                                                   gboolean       writable);
171 gboolean gtk_targets_include_uri                 (GdkAtom       *targets,
172                                                   gint           n_targets);
173
174 /* Called when a widget is destroyed */
175
176 void gtk_selection_remove_all      (GtkWidget *widget);
177
178 /* Event handlers */
179 gboolean _gtk_selection_clear             (GtkWidget         *widget,
180                                            GdkEventSelection *event);
181 gboolean _gtk_selection_request           (GtkWidget         *widget,
182                                            GdkEventSelection *event);
183 gboolean _gtk_selection_incr_event        (GdkWindow         *window,
184                                            GdkEventProperty  *event);
185 gboolean _gtk_selection_notify            (GtkWidget         *widget,
186                                            GdkEventSelection *event);
187 gboolean _gtk_selection_property_notify   (GtkWidget         *widget,
188                                            GdkEventProperty  *event);
189
190 GType             gtk_selection_data_get_type (void) G_GNUC_CONST;
191 GtkSelectionData *gtk_selection_data_copy     (const GtkSelectionData *data);
192 void              gtk_selection_data_free     (GtkSelectionData *data);
193
194 GType             gtk_target_entry_get_type    (void) G_GNUC_CONST;
195
196 GtkTargetEntry   *gtk_target_entry_new        (const char *target, guint flags, guint info);
197 GtkTargetEntry   *gtk_target_entry_copy       (GtkTargetEntry *data);
198 void              gtk_target_entry_free       (GtkTargetEntry *data);
199
200 GType             gtk_target_list_get_type    (void) G_GNUC_CONST;
201
202 G_END_DECLS
203
204 #endif /* __GTK_SELECTION_H__ */