]> Pileus Git - ~andy/gtk/blob - gdk/quartz/gdkdnd-quartz.c
Do not use deprecated gdk_display_get_core_pointer()
[~andy/gtk] / gdk / quartz / gdkdnd-quartz.c
1 /* gdkdnd-quartz.c
2  *
3  * Copyright (C) 2005 Imendio AB
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include "gdkdnd.h"
22 #include "gdkprivate-quartz.h"
23
24 static gpointer parent_class = NULL;
25
26 static void
27 gdk_drag_context_finalize (GObject *object)
28 {
29   GdkDragContext *context = GDK_DRAG_CONTEXT (object);
30   GdkDragContextPrivate *private = GDK_DRAG_CONTEXT_PRIVATE (context);
31  
32   g_free (private);
33   
34   G_OBJECT_CLASS (parent_class)->finalize (object);
35 }
36
37 static void
38 gdk_drag_context_init (GdkDragContext *dragcontext)
39 {
40   GdkDragContextPrivate *priv = g_new0 (GdkDragContextPrivate, 1);
41
42   dragcontext->windowing_data = priv;
43 }
44
45 static void
46 gdk_drag_context_class_init (GdkDragContextClass *klass)
47 {
48   GObjectClass *object_class = G_OBJECT_CLASS (klass);
49   
50   parent_class = g_type_class_peek_parent (klass);
51
52   object_class->finalize = gdk_drag_context_finalize;
53 }
54
55 GType
56 gdk_drag_context_get_type (void)
57 {
58   static GType object_type = 0;
59
60   if (!object_type)
61     {
62       const GTypeInfo object_info =
63       {
64         sizeof (GdkDragContextClass),
65         (GBaseInitFunc) NULL,
66         (GBaseFinalizeFunc) NULL,
67         (GClassInitFunc) gdk_drag_context_class_init,
68         NULL,           /* class_finalize */
69         NULL,           /* class_data */
70         sizeof (GdkDragContext),
71         0,              /* n_preallocs */
72         (GInstanceInitFunc) gdk_drag_context_init,
73       };
74       
75       object_type = g_type_register_static (G_TYPE_OBJECT,
76                                             "GdkDragContext",
77                                             &object_info,
78                                             0);
79     }
80   
81   return object_type;
82 }
83
84 GdkDragContext *
85 gdk_drag_context_new (void)
86 {
87   return (GdkDragContext *)g_object_new (gdk_drag_context_get_type (), NULL);
88 }
89
90 /**
91  * gdk_drag_context_set_device:
92  * @context: a #GdkDragContext
93  * @device: a #GdkDevice
94  *
95  * Associates a #GdkDevice to @context, so all Drag and Drop events
96  * for @context are emitted as if they came from this device.
97  **/
98 void
99 gdk_drag_context_set_device (GdkDragContext *context,
100                              GdkDevice      *device)
101 {
102   GdkDragContextPrivate *private;
103
104   g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
105   g_return_if_fail (GDK_IS_DEVICE (device));
106
107   private = GDK_DRAG_CONTEXT_PRIVATE (context);
108
109   if (private->device)
110     {
111       g_object_unref (private->device);
112       private->device = NULL;
113     }
114
115   if (device)
116     private->device = g_object_ref (device);
117 }
118
119 /**
120  * gdk_drag_context_get_device:
121  * @context: a #GdkDragContext
122  *
123  * Returns the #GdkDevice associated to the drag context.
124  *
125  * Returns: The #GdkDevice associated to @context.
126  **/
127 GdkDevice *
128 gdk_drag_context_get_device (GdkDragContext *context)
129 {
130   GdkDragContextPrivate *private;
131
132   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
133
134   private = GDK_DRAG_CONTEXT_PRIVATE (context);
135
136   return private->device;
137 }
138
139
140 GdkDragContext *_gdk_quartz_drag_source_context = NULL;
141
142 GdkDragContext *
143 gdk_quartz_drag_source_context ()
144 {
145   return _gdk_quartz_drag_source_context;
146 }
147
148 GdkDragContext * 
149 gdk_drag_begin (GdkWindow     *window,
150                 GList         *targets)
151 {
152   GdkDeviceManager *device_manager;
153
154   g_assert (_gdk_quartz_drag_source_context == NULL);
155   
156   /* Create fake context */
157   _gdk_quartz_drag_source_context = gdk_drag_context_new ();
158   _gdk_quartz_drag_source_context->is_source = TRUE;
159
160   device_manager = gdk_display_get_device_manager (gdk_display_get_default ());
161   gdk_drag_context_set_device (_gdk_quartz_drag_source_context,
162                                gdk_device_manager_get_client_pointer (device_manager));
163
164   return _gdk_quartz_drag_source_context;
165 }
166
167 gboolean        
168 gdk_drag_motion (GdkDragContext *context,
169                  GdkWindow      *dest_window,
170                  GdkDragProtocol protocol,
171                  gint            x_root, 
172                  gint            y_root,
173                  GdkDragAction   suggested_action,
174                  GdkDragAction   possible_actions,
175                  guint32         time)
176 {
177   /* FIXME: Implement */
178   return FALSE;
179 }
180
181 guint32
182 gdk_drag_get_protocol_for_display (GdkDisplay      *display,
183                                    guint32          xid,
184                                    GdkDragProtocol *protocol)
185 {
186   /* FIXME: Implement */
187   return 0;
188 }
189
190 void
191 gdk_drag_find_window_for_screen (GdkDragContext  *context,
192                                  GdkWindow       *drag_window,
193                                  GdkScreen       *screen,
194                                  gint             x_root,
195                                  gint             y_root,
196                                  GdkWindow      **dest_window,
197                                  GdkDragProtocol *protocol)
198 {
199   /* FIXME: Implement */
200 }
201
202 void
203 gdk_drag_drop (GdkDragContext *context,
204                guint32         time)
205 {
206   /* FIXME: Implement */
207 }
208
209 void
210 gdk_drag_abort (GdkDragContext *context,
211                 guint32         time)
212 {
213   g_return_if_fail (context != NULL);
214   
215   /* FIXME: Implement */
216 }
217
218 void             
219 gdk_drag_status (GdkDragContext   *context,
220                  GdkDragAction     action,
221                  guint32           time)
222 {
223   context->action = action;
224 }
225
226 void 
227 gdk_drop_reply (GdkDragContext   *context,
228                 gboolean          ok,
229                 guint32           time)
230 {
231   g_return_if_fail (context != NULL);
232
233   /* FIXME: Implement */
234 }
235
236 void             
237 gdk_drop_finish (GdkDragContext   *context,
238                  gboolean          success,
239                  guint32           time)
240 {
241   /* FIXME: Implement */
242 }
243
244 void            
245 gdk_window_register_dnd (GdkWindow *window)
246 {
247   /* FIXME: Implement */
248 }
249
250 GdkAtom       
251 gdk_drag_get_selection (GdkDragContext *context)
252 {
253   /* FIXME: Implement */
254   return GDK_NONE;
255 }
256
257 gboolean 
258 gdk_drag_drop_succeeded (GdkDragContext *context)
259 {
260   /* FIXME: Implement */
261   return FALSE;
262 }
263
264 id
265 gdk_quartz_drag_context_get_dragging_info_libgtk_only (GdkDragContext *context)
266 {
267   return GDK_DRAG_CONTEXT_PRIVATE (context)->dragging_info;
268 }