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