]> Pileus Git - ~andy/gtk/blob - gtk/gtkselection.h
Fixing popup menus to have "Paste" sensitized correctly. Original patches
[~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 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39 typedef struct _GtkTargetList    GtkTargetList;
40 typedef struct _GtkTargetEntry   GtkTargetEntry;
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 };
62
63 struct _GtkTargetEntry {
64   gchar *target;
65   guint  flags;
66   guint  info;
67 };
68
69 /* These structures not public, and are here only for the convenience of
70  * gtkdnd.c 
71  */
72
73 typedef struct _GtkTargetPair GtkTargetPair;
74
75 /* This structure is a list of destinations, and associated guint id's */
76 struct _GtkTargetList {
77   GList *list;
78   guint ref_count;
79 };
80
81 struct _GtkTargetPair {
82   GdkAtom   target;
83   guint     flags;
84   guint     info;
85 };
86
87 GtkTargetList *gtk_target_list_new       (const GtkTargetEntry *targets,
88                                           guint                 ntargets);
89 void           gtk_target_list_ref       (GtkTargetList  *list);
90 void           gtk_target_list_unref     (GtkTargetList  *list);
91 void           gtk_target_list_add       (GtkTargetList  *list,
92                                           GdkAtom         target,
93                                           guint           flags,
94                                           guint           info);
95 void           gtk_target_list_add_table (GtkTargetList        *list,
96                                           const GtkTargetEntry *targets,
97                                           guint                 ntargets);
98 void           gtk_target_list_remove    (GtkTargetList  *list,
99                                           GdkAtom         target);
100 gboolean       gtk_target_list_find      (GtkTargetList  *list,
101                                           GdkAtom         target,
102                                           guint          *info);
103
104 /* Public interface */
105
106 gboolean gtk_selection_owner_set     (GtkWidget            *widget,
107                                       GdkAtom               selection,
108                                       guint32               time);
109 void     gtk_selection_add_target    (GtkWidget            *widget,
110                                       GdkAtom               selection,
111                                       GdkAtom               target,
112                                       guint                 info);
113 void     gtk_selection_add_targets   (GtkWidget            *widget,
114                                       GdkAtom               selection,
115                                       const GtkTargetEntry *targets,
116                                       guint                 ntargets);
117 void     gtk_selection_clear_targets (GtkWidget            *widget,
118                                       GdkAtom               selection);
119 gboolean gtk_selection_convert       (GtkWidget            *widget,
120                                       GdkAtom               selection,
121                                       GdkAtom               target,
122                                       guint32               time);
123 void     gtk_selection_data_set      (GtkSelectionData     *selection_data,
124                                       GdkAtom               type,
125                                       gint                  format,
126                                       const guchar         *data,
127                                       gint                  length);
128 gboolean gtk_selection_data_set_text (GtkSelectionData     *selection_data,
129                                       const guchar         *str);
130 guchar * gtk_selection_data_get_text (GtkSelectionData     *selection_data);
131
132 gboolean gtk_selection_data_get_targets          (GtkSelectionData  *selection_data,
133                                                   GdkAtom          **targets,
134                                                   gint              *n_atoms);
135 gboolean gtk_selection_data_targets_include_text (GtkSelectionData  *selection_data);
136
137 /* Called when a widget is destroyed */
138
139 void gtk_selection_remove_all      (GtkWidget *widget);
140
141 /* Event handlers */
142
143 gboolean gtk_selection_clear              (GtkWidget         *widget,
144                                            GdkEventSelection *event);
145 gboolean gtk_selection_request            (GtkWidget         *widget,
146                                            GdkEventSelection *event);
147 gboolean gtk_selection_incr_event         (GdkWindow         *window,
148                                            GdkEventProperty  *event);
149 gboolean gtk_selection_notify             (GtkWidget         *widget,
150                                            GdkEventSelection *event);
151 gboolean gtk_selection_property_notify    (GtkWidget         *widget,
152                                            GdkEventProperty  *event);
153 GtkSelectionData *gtk_selection_data_copy (GtkSelectionData *data);
154 void              gtk_selection_data_free (GtkSelectionData *data);
155
156
157
158 #ifdef __cplusplus
159 }
160 #endif /* __cplusplus */
161
162
163 #endif /* __GTK_SELECTION_H__ */