gdk3 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/Rakefile +53 -0
  2. data/ext/gdk3/depend +11 -0
  3. data/ext/gdk3/extconf.rb +127 -0
  4. data/ext/gdk3/gdk3.def +12 -0
  5. data/ext/gdk3/init.c +35 -0
  6. data/ext/gdk3/rbgdk.c +540 -0
  7. data/ext/gdk3/rbgdk3.h +71 -0
  8. data/ext/gdk3/rbgdk3conversions.h +118 -0
  9. data/ext/gdk3/rbgdk3private.h +93 -0
  10. data/ext/gdk3/rbgdkatom.c +122 -0
  11. data/ext/gdk3/rbgdkcairo.c +95 -0
  12. data/ext/gdk3/rbgdkcolor.c +137 -0
  13. data/ext/gdk3/rbgdkconst.c +33 -0
  14. data/ext/gdk3/rbgdkcursor.c +99 -0
  15. data/ext/gdk3/rbgdkdevice.c +197 -0
  16. data/ext/gdk3/rbgdkdisplay.c +482 -0
  17. data/ext/gdk3/rbgdkdisplaymanager.c +55 -0
  18. data/ext/gdk3/rbgdkdragcontext.c +191 -0
  19. data/ext/gdk3/rbgdkdraw.c +520 -0
  20. data/ext/gdk3/rbgdkevent.c +926 -0
  21. data/ext/gdk3/rbgdkgeometry.c +252 -0
  22. data/ext/gdk3/rbgdkkeymap.c +151 -0
  23. data/ext/gdk3/rbgdkkeyval.c +108 -0
  24. data/ext/gdk3/rbgdkpango.c +197 -0
  25. data/ext/gdk3/rbgdkpangorenderer.c +144 -0
  26. data/ext/gdk3/rbgdkpixbuf.c +176 -0
  27. data/ext/gdk3/rbgdkproperty.c +305 -0
  28. data/ext/gdk3/rbgdkrectangle.c +140 -0
  29. data/ext/gdk3/rbgdkrgb.c +199 -0
  30. data/ext/gdk3/rbgdkrgba.c +142 -0
  31. data/ext/gdk3/rbgdkscreen.c +443 -0
  32. data/ext/gdk3/rbgdkselection.c +146 -0
  33. data/ext/gdk3/rbgdkthreads.c +77 -0
  34. data/ext/gdk3/rbgdktimecoord.c +133 -0
  35. data/ext/gdk3/rbgdkvisual.c +251 -0
  36. data/ext/gdk3/rbgdkwindow.c +1044 -0
  37. data/ext/gdk3/rbgdkwindowattr.c +191 -0
  38. data/ext/gdk3/rbgdkx11.c +102 -0
  39. data/ext/gdk3/rbgdkx11x11window.c +66 -0
  40. data/extconf.rb +49 -0
  41. data/lib/gdk3.rb +3 -0
  42. data/lib/gdk3/base.rb +50 -0
  43. data/lib/gdk3/deprecated.rb +152 -0
  44. metadata +156 -0
@@ -0,0 +1,482 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002-2005 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #include "rbgdk3private.h"
23
+
24
+ #define RG_TARGET_NAMESPACE cDisplay
25
+ #define _SELF(i) RVAL2GDKDISPLAYOBJECT(i)
26
+
27
+ static VALUE
28
+ rg_close(VALUE self)
29
+ {
30
+ gdk_display_close(_SELF(self));
31
+ return self;
32
+ }
33
+
34
+ static VALUE
35
+ rg_s_open(G_GNUC_UNUSED VALUE self, VALUE display_name)
36
+ {
37
+ GdkDisplay* gdisplay = gdk_display_open(RVAL2CSTR(display_name));
38
+ if (! gdisplay) {
39
+ rb_raise(rb_eRuntimeError, "The display `%s' could not be opened.",
40
+ RVAL2CSTR(display_name));
41
+ } else {
42
+ VALUE display;
43
+ g_object_ref(gdisplay);
44
+ display = GOBJ2RVAL(gdisplay);
45
+
46
+ if (rb_block_given_p()) {
47
+ rb_ensure(rb_yield, display, rg_close, display);
48
+ return Qnil;
49
+ } else {
50
+ return display;
51
+ }
52
+ }
53
+ }
54
+
55
+ static VALUE
56
+ rg_s_default(G_GNUC_UNUSED VALUE self)
57
+ {
58
+ GdkDisplay* gdisplay = gdk_display_get_default();
59
+ if (! gdisplay)
60
+ rb_raise(rb_eRuntimeError, "No default display is found.");
61
+
62
+ return GOBJ2RVAL(gdisplay);
63
+ }
64
+
65
+ static VALUE
66
+ rg_name(VALUE self)
67
+ {
68
+ return CSTR2RVAL(gdk_display_get_name(_SELF(self)));
69
+ }
70
+
71
+ static VALUE
72
+ rg_n_screens(VALUE self)
73
+ {
74
+ return INT2NUM(gdk_display_get_n_screens(_SELF(self)));
75
+ }
76
+
77
+ static VALUE
78
+ rg_get_screen(VALUE self, VALUE num)
79
+ {
80
+ return GOBJ2RVAL(gdk_display_get_screen(_SELF(self), NUM2INT(num)));
81
+ }
82
+
83
+ static VALUE
84
+ rg_default_screen(VALUE self)
85
+ {
86
+ return GOBJ2RVAL(gdk_display_get_default_screen(_SELF(self)));
87
+ }
88
+
89
+ static VALUE
90
+ rg_pointer_ungrab(VALUE self, VALUE time)
91
+ {
92
+ gdk_display_pointer_ungrab(_SELF(self), NUM2ULONG(time));
93
+ return self;
94
+ }
95
+
96
+ static VALUE
97
+ rg_keyboard_ungrab(VALUE self, VALUE time)
98
+ {
99
+ gdk_display_keyboard_ungrab(_SELF(self), NUM2ULONG(time));
100
+ return self;
101
+ }
102
+
103
+ static VALUE
104
+ rg_pointer_grabbed_p(VALUE self)
105
+ {
106
+ return CBOOL2RVAL(gdk_display_pointer_is_grabbed(_SELF(self)));
107
+ }
108
+
109
+ static VALUE
110
+ rg_beep(VALUE self)
111
+ {
112
+ gdk_display_beep(_SELF(self));
113
+ return self;
114
+ }
115
+
116
+ static VALUE
117
+ rg_sync(VALUE self)
118
+ {
119
+ gdk_display_sync(_SELF(self));
120
+ return self;
121
+ }
122
+
123
+ static VALUE
124
+ rg_flush(VALUE self)
125
+ {
126
+ gdk_display_flush(_SELF(self));
127
+ return self;
128
+ }
129
+
130
+ static VALUE
131
+ rg_devices(VALUE self)
132
+ {
133
+ return rbgutil_glist2ary(gdk_display_list_devices(_SELF(self)));
134
+ }
135
+
136
+ static VALUE
137
+ rg_event(VALUE self)
138
+ {
139
+ return GEV2RVAL(gdk_display_get_event(_SELF(self)));
140
+ }
141
+
142
+ static VALUE
143
+ rg_peek_event(VALUE self)
144
+ {
145
+ return GEV2RVAL(gdk_display_peek_event(_SELF(self)));
146
+ }
147
+
148
+ static VALUE
149
+ rg_put_event(VALUE self, VALUE event)
150
+ {
151
+ gdk_display_put_event(_SELF(self), RVAL2GEV(event));
152
+ return self;
153
+ }
154
+
155
+ /* Don't implement this.
156
+ static GdkFilterReturn
157
+ filter_func(GdkXEvent xevent, GdkEvent event, gpointer func)
158
+ {
159
+ return GENUM2RVAL(rb_funcall((VALUE)func, id_call, 2,
160
+ ????, GEV2RVAL(event)),
161
+ GDK_TYPE_FILTER_RETURN);
162
+ }
163
+
164
+ static VALUE
165
+ gdkdisplay_add_client_message_filter(VALUE self, VALUE message_type)
166
+ {
167
+ VALUE func = RB_BLOCK_PROC();
168
+ G_RELATIVE(self, func);
169
+ gdk_display_add_client_message_filter(_SELF(self), RVAL2ATOM(message_type),
170
+ filter_func, func);
171
+ return self;
172
+ }
173
+ */
174
+
175
+ static VALUE
176
+ rg_set_double_click_time(VALUE self, VALUE msec)
177
+ {
178
+ gdk_display_set_double_click_time(_SELF(self), NUM2UINT(msec));
179
+ return self;
180
+ }
181
+
182
+ static VALUE
183
+ rg_closed_p(VALUE self)
184
+ {
185
+ return CBOOL2RVAL(gdk_display_is_closed(_SELF(self)));
186
+ }
187
+
188
+ static VALUE
189
+ rg_set_double_click_distance(VALUE self, VALUE distance)
190
+ {
191
+ gdk_display_set_double_click_distance(_SELF(self), NUM2UINT(distance));
192
+ return self;
193
+ }
194
+
195
+ static VALUE
196
+ rg_pointer(VALUE self)
197
+ {
198
+ GdkScreen *screen;
199
+ int x,y;
200
+ GdkModifierType mask;
201
+
202
+ gdk_display_get_pointer(_SELF(self), &screen, &x, &y, &mask);
203
+
204
+ return rb_ary_new3(4, GOBJ2RVAL(screen), INT2NUM(x), INT2NUM(y), INT2NUM(mask));
205
+ }
206
+ static VALUE
207
+ rg_window_at_pointer(VALUE self)
208
+ {
209
+ GdkWindow *window;
210
+ int x,y;
211
+
212
+ window = gdk_display_get_window_at_pointer(_SELF(self), &x, &y);
213
+
214
+ return rb_ary_new3(3, GOBJ2RVAL(window), INT2NUM(x), INT2NUM(y));
215
+ }
216
+
217
+ /* Don't implement this.
218
+ GdkDisplayPointerHooks* gdk_display_set_pointer_hooks
219
+ (GdkDisplay *display,
220
+ const GdkDisplayPointerHooks *new_hooks);
221
+ */
222
+
223
+ static VALUE
224
+ rg_supports_cursor_color_p(VALUE self)
225
+ {
226
+ return CBOOL2RVAL(gdk_display_supports_cursor_color(_SELF(self)));
227
+ }
228
+
229
+ static VALUE
230
+ rg_supports_cursor_alpha_p(VALUE self)
231
+ {
232
+ return CBOOL2RVAL(gdk_display_supports_cursor_alpha(_SELF(self)));
233
+ }
234
+
235
+ static VALUE
236
+ rg_default_cursor_size(VALUE self)
237
+ {
238
+ return UINT2NUM(gdk_display_get_default_cursor_size(_SELF(self)));
239
+ }
240
+
241
+ static VALUE
242
+ rg_maximal_cursor_size(VALUE self)
243
+ {
244
+ guint width, height;
245
+ gdk_display_get_maximal_cursor_size(_SELF(self), &width, &height);
246
+ return rb_assoc_new(UINT2NUM(width), UINT2NUM(height));
247
+ }
248
+
249
+ static VALUE
250
+ rg_default_group(VALUE self)
251
+ {
252
+ return GOBJ2RVAL(gdk_display_get_default_group(_SELF(self)));
253
+ }
254
+
255
+ static VALUE
256
+ rg_supports_selection_notification_p(VALUE self)
257
+ {
258
+ return CBOOL2RVAL(gdk_display_supports_selection_notification(_SELF(self)));
259
+ }
260
+
261
+ static VALUE
262
+ rg_request_selection_notification_p(VALUE self, VALUE selection)
263
+ {
264
+ return CBOOL2RVAL(gdk_display_request_selection_notification(_SELF(self),
265
+ RVAL2ATOM(selection)));
266
+ }
267
+
268
+ static VALUE
269
+ rg_supports_clipboard_persistence_p(VALUE self)
270
+ {
271
+ return CBOOL2RVAL(gdk_display_supports_clipboard_persistence(_SELF(self)));
272
+ }
273
+
274
+ static VALUE
275
+ rg_store_clipboard(VALUE self, VALUE rbclipboard_window, VALUE rbtime_, VALUE rbtargets)
276
+ {
277
+ GdkDisplay *display = _SELF(self);
278
+ GdkWindow *clipboard_window = RVAL2GDKWINDOW(rbclipboard_window);
279
+ guint32 time_ = NUM2UINT(rbtime_);
280
+ long n;
281
+ GdkAtom *targets = RVAL2GDKATOMS(rbtargets, &n);
282
+
283
+ gdk_display_store_clipboard(display, clipboard_window, time_, targets, n);
284
+
285
+ g_free(targets);
286
+
287
+ return self;
288
+ }
289
+
290
+ /* deprecated
291
+ static VALUE
292
+ rg_core_pointer(VALUE self)
293
+ {
294
+ return GOBJ2RVAL(gdk_display_get_core_pointer(_SELF(self)));
295
+ }
296
+ */
297
+
298
+ static VALUE
299
+ rg_warp_pointer(VALUE self, VALUE screen, VALUE x, VALUE y)
300
+ {
301
+ gdk_display_warp_pointer(_SELF(self), RVAL2GDKSCREEN(screen), NUM2INT(x), NUM2INT(y));
302
+ return self;
303
+ }
304
+
305
+ #ifdef GDK_WINDOWING_X11
306
+ static VALUE
307
+ rg_grab(VALUE self)
308
+ {
309
+ gdk_x11_display_grab(_SELF(self));
310
+ return self;
311
+ }
312
+ static VALUE
313
+ rg_ungrab(VALUE self)
314
+ {
315
+ gdk_x11_display_ungrab(_SELF(self));
316
+ return self;
317
+ }
318
+
319
+ static VALUE
320
+ rg_register_standard_event_type(VALUE self, VALUE event_base, VALUE n_events)
321
+ {
322
+ gdk_x11_register_standard_event_type(_SELF(self),
323
+ NUM2INT(event_base), NUM2INT(n_events));
324
+ return self;
325
+ }
326
+
327
+ static VALUE
328
+ rg_user_time(VALUE self)
329
+ {
330
+ return UINT2NUM(gdk_x11_display_get_user_time(_SELF(self)));
331
+ }
332
+
333
+ static VALUE
334
+ rg_set_cursor_theme(VALUE self, VALUE theme, VALUE size)
335
+ {
336
+ gdk_x11_display_set_cursor_theme(_SELF(self), RVAL2CSTR(theme), NUM2INT(size));
337
+ return self;
338
+ }
339
+
340
+ /*
341
+ *** need gdk_x11_display_broadcast_startup_messagev() ***
342
+
343
+ typedef struct _StartupMessageParameterData {
344
+ gchar **parameters;
345
+ guint i;
346
+ } StartupMessageParameterData;
347
+
348
+ static int
349
+ collect_parameter(VALUE key, VALUE value, VALUE data)
350
+ {
351
+ StartupMessageParameterData *parameter_data;
352
+ parameter_data = (StartupMessageParameterData *)data;
353
+
354
+ parameter_data->parameters[parameter_data->i] = RVAL2CSTR(key);
355
+ parameter_data->i++;
356
+ parameter_data->parameters[parameter_data->i] = RVAL2CSTR(value);
357
+ parameter_data->i++;
358
+
359
+ return ST_CONTINUE;
360
+ }
361
+
362
+ static VALUE
363
+ rg_broadcast_startup_message(int argc, VALUE *argv, VALUE self)
364
+ {
365
+ VALUE rb_message_type, rb_parameters;
366
+ char *message_type;
367
+ guint n_parameters;
368
+ gchar **parameters;
369
+
370
+ rb_scan_args(argc, argv, "11", &rb_message_type, &rb_parameters);
371
+
372
+ message_type = RVAL2CSTR(rb_message_type);
373
+ if (NIL_P(rb_parameters)) {
374
+ n_parameters = 0;
375
+ parameters = NULL;
376
+ }
377
+ else {
378
+ StartupMessageParameterData data;
379
+
380
+ Check_Type(rb_parameters, T_HASH);
381
+ n_parameters = NUM2UINT(rb_funcall(rb_parameters, rb_intern("size"), 0));
382
+ parameters = ALLOCA_N(gchar *, n_parameters * 2);
383
+ data.i = 0;
384
+ data.parameters = parameters;
385
+ rb_hash_foreach(rb_parameters, collect_parameter, (VALUE)&data);
386
+ }
387
+
388
+ gdk_x11_display_broadcast_startup_messagev(_SELF(self),
389
+ message_type,
390
+ n_parameters,
391
+ parameters);
392
+
393
+ return self;
394
+ }
395
+ */
396
+
397
+ static VALUE
398
+ rg_startup_notification_id(VALUE self)
399
+ {
400
+ return CSTR2RVAL(gdk_x11_display_get_startup_notification_id(_SELF(self)));
401
+ }
402
+ #endif
403
+
404
+ static VALUE
405
+ rg_supports_shapes_p(VALUE self)
406
+ {
407
+ return CBOOL2RVAL(gdk_display_supports_shapes(_SELF(self)));
408
+ }
409
+
410
+ static VALUE
411
+ rg_supports_input_shapes_p(VALUE self)
412
+ {
413
+ return CBOOL2RVAL(gdk_display_supports_input_shapes(_SELF(self)));
414
+ }
415
+
416
+ static VALUE
417
+ rg_supports_composite_p(VALUE self)
418
+ {
419
+ return CBOOL2RVAL(gdk_display_supports_composite(_SELF(self)));
420
+ }
421
+
422
+ void
423
+ Init_gdk_display(VALUE mGdk)
424
+ {
425
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DISPLAY, "Display", mGdk);
426
+
427
+ RG_DEF_SMETHOD(open, 1);
428
+ RG_DEF_SMETHOD(default, 0);
429
+ RG_DEF_METHOD(name, 0);
430
+ RG_DEF_METHOD(n_screens, 0);
431
+ RG_DEF_METHOD(get_screen, 1);
432
+ RG_DEF_ALIAS("[]", "get_screen");
433
+ RG_DEF_METHOD(default_screen, 0);
434
+
435
+ RG_DEF_METHOD(pointer_ungrab, 1);
436
+ RG_DEF_METHOD(keyboard_ungrab, 1);
437
+ RG_DEF_METHOD_P(pointer_grabbed, 0);
438
+
439
+ RG_DEF_METHOD(beep, 0);
440
+ RG_DEF_METHOD(sync, 0);
441
+ RG_DEF_METHOD(flush, 0);
442
+ RG_DEF_METHOD(close, 0);
443
+
444
+ RG_DEF_METHOD(devices, 0);
445
+ RG_DEF_METHOD(event, 0);
446
+ RG_DEF_METHOD(peek_event, 0);
447
+ RG_DEF_METHOD(put_event, 1);
448
+ RG_DEF_METHOD(set_double_click_time, 1);
449
+ RG_DEF_METHOD_P(closed, 0);
450
+ RG_DEF_METHOD(set_double_click_distance, 1);
451
+ RG_DEF_METHOD(pointer, 0);
452
+ RG_DEF_METHOD(window_at_pointer, 0);
453
+ RG_DEF_METHOD_P(supports_cursor_color, 0);
454
+ RG_DEF_METHOD_P(supports_cursor_alpha, 0);
455
+ RG_DEF_METHOD(default_cursor_size, 0);
456
+ RG_DEF_METHOD(maximal_cursor_size, 0);
457
+ RG_DEF_METHOD(default_group, 0);
458
+ RG_DEF_METHOD_P(supports_selection_notification, 0);
459
+ RG_DEF_METHOD_P(request_selection_notification, 1);
460
+ RG_DEF_METHOD_P(supports_clipboard_persistence, 0);
461
+ RG_DEF_METHOD(store_clipboard, 3);
462
+ /* deprecated
463
+ RG_DEF_METHOD(core_pointer, 0);
464
+ */
465
+ RG_DEF_METHOD(warp_pointer, 3);
466
+ #ifdef GDK_WINDOWING_X11
467
+ RG_DEF_METHOD(grab, 0);
468
+ RG_DEF_METHOD(ungrab, 0);
469
+ RG_DEF_METHOD(register_standard_event_type, 2);
470
+ RG_DEF_METHOD(user_time, 0);
471
+ RG_DEF_METHOD(set_cursor_theme, 2);
472
+ /*
473
+ RG_DEF_METHOD(broadcast_startup_message, -1);
474
+ */
475
+ RG_DEF_METHOD(startup_notification_id, 0);
476
+ G_DEF_CLASS3("GdkDisplayX11", "DisplayX11", mGdk);
477
+ #endif
478
+
479
+ RG_DEF_METHOD_P(supports_shapes, 0);
480
+ RG_DEF_METHOD_P(supports_input_shapes, 0);
481
+ RG_DEF_METHOD_P(supports_composite, 0);
482
+ }