[perl-Gtk2] Wrap gdk 2.22 API
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Gtk2] Wrap gdk 2.22 API
- Date: Fri, 31 Dec 2010 01:37:55 +0000 (UTC)
commit 0ba15a3b935f5da016dbb5911fb15050dfa64b8c
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Fri Dec 31 01:28:08 2010 +0100
Wrap gdk 2.22 API
NEWS | 2 +-
t/GdkCairo.t | 32 ++++++++++++++++++++++++--------
t/GdkCursor.t | 15 ++++++++++++---
t/GdkDisplay.t | 12 ++++++++++--
t/GdkDnd.t | 18 ++++++++++++++++--
t/GdkInput.t | 24 +++++++++++++++++++++---
t/GdkScreen.t | 13 ++-----------
t/GdkVisual.t | 22 +++++++++++++++++++++-
t/GdkWindow.t | 22 ++++++++++++++++++++--
xs/GdkCairo.xs | 15 +++++++++++++--
xs/GdkCursor.xs | 6 ++++++
xs/GdkDisplay.xs | 6 ++++++
xs/GdkDnd.xs | 25 +++++++++++++++++++++++++
xs/GdkInput.xs | 16 ++++++++++++++++
xs/GdkVisual.xs | 20 ++++++++++++++++++++
xs/GdkWindow.xs | 26 ++++++++++++++++++++++++++
16 files changed, 239 insertions(+), 35 deletions(-)
---
diff --git a/NEWS b/NEWS
index 038908b..ab8c263 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@ Overview of changes in the next unstable release
================================================
* Wrap missing gtk+ 2.8, 2.10, 2.12, 2.14, 2.16, 2.18 and 2.20 API.
-* Wrap gtk+ 2.22 API.
+* Wrap gtk+ and gdk 2.22 API.
* Gtk2::Notebook: fix invocation of window creation hooks.
* Fix length of Gtk2::Gdk::Pixbuf->get_pixels() return.
* Allow Gtk2::Buildable implementations to return undef from
diff --git a/t/GdkCairo.t b/t/GdkCairo.t
index 4a10656..441251e 100644
--- a/t/GdkCairo.t
+++ b/t/GdkCairo.t
@@ -11,7 +11,7 @@ if (! (UNIVERSAL::can("Gtk2::Gdk::Cairo::Context", "create") &&
} elsif (! Gtk2->init_check) {
plan skip_all => "Gtk2->init_check failed, probably unable to open DISPLAY";
} else {
- plan tests => 2;
+ plan tests => 6;
}
# $Id$
@@ -40,18 +40,34 @@ $context -> set_operator("clear");
$context -> rectangle(0, 0, 10, 10);
SKIP: {
- skip "set_source_pixmap is new in gtk+ 2.10", 0
- unless Gtk2 -> CHECK_VERSION(2, 10, 0);
+ skip "new 2.10 stuff", 2
+ unless Gtk2 -> CHECK_VERSION(2, 10, 0);
- my $pixmap = Gtk2::Gdk::Pixmap -> new($window->window, 20, 20, -1);
- $context -> set_source_pixmap($pixmap, 10, 10);
+ my $pixmap = Gtk2::Gdk::Pixmap -> new($window->window, 20, 20, -1);
+ $context -> set_source_pixmap($pixmap, 10, 10);
+
+ my $screen = Gtk2::Gdk::Screen->get_default;
+ my $options = Cairo::FontOptions->create;
+ $screen->set_font_options (undef);
+ is ($screen->get_font_options, undef);
+ $screen->set_font_options ($options);
+ isa_ok ($screen->get_font_options, "Cairo::FontOptions");
+}
+
+SKIP: {
+ skip "reset_clip is new in gtk+ 2.18", 0
+ unless Gtk2 -> CHECK_VERSION(2, 18, 0);
+
+ $context->reset_clip ($window->window);
}
SKIP: {
- skip "reset_clip is new in gtk+ 2.18", 0
- unless Gtk2 -> CHECK_VERSION(2, 18, 0);
+ skip 'new 2.22 stuff', 2
+ unless Gtk2->CHECK_VERSION(2, 22, 0);
- $context->reset_clip ($window->window);
+ my $window = Gtk2::Gdk::Window -> new(undef, { window_type => 'toplevel' });
+ isa_ok ($window->create_similar_surface ('color', 23, 42), 'Cairo::Surface');
+ isa_ok ($window->get_background_pattern, 'Cairo::Pattern');
}
__END__
diff --git a/t/GdkCursor.t b/t/GdkCursor.t
index 2e4d3ed..1f7cd98 100644
--- a/t/GdkCursor.t
+++ b/t/GdkCursor.t
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Gtk2::TestHelper tests => 8;
+use Gtk2::TestHelper tests => 9;
# $Id$
@@ -46,8 +46,7 @@ SKIP: {
my $display = Gtk2::Gdk::Display -> get_default();
my $pixbuf = Gtk2::Gdk::Pixbuf -> new("rgb", 0, 8, 10, 10);
-
- $cursor = Gtk2::Gdk::Cursor -> new_from_pixbuf($display, $pixbuf, 5, 5);
+ my $cursor = Gtk2::Gdk::Cursor -> new_from_pixbuf($display, $pixbuf, 5, 5);
isa_ok($cursor, "Gtk2::Gdk::Cursor");
}
@@ -68,6 +67,16 @@ SKIP: {
ok(!defined $pixbuf || UNIVERSAL::isa($pixbuf, "Gtk2::Gdk::Pixbuf"));
}
+SKIP: {
+ skip 'new 2.22 stuff', 1
+ unless Gtk2->CHECK_VERSION(2, 22, 0);
+
+ my $display = Gtk2::Gdk::Display -> get_default();
+ my $pixbuf = Gtk2::Gdk::Pixbuf -> new("rgb", 0, 8, 10, 10);
+ my $cursor = Gtk2::Gdk::Cursor -> new_from_pixbuf($display, $pixbuf, 5, 5);
+ ok(defined $cursor -> get_cursor_type());
+}
+
__END__
Copyright (C) 2003-2005 by the gtk2-perl team (see the file AUTHORS for the
diff --git a/t/GdkDisplay.t b/t/GdkDisplay.t
index 9dce71b..41118ec 100644
--- a/t/GdkDisplay.t
+++ b/t/GdkDisplay.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
use Gtk2::TestHelper
- tests => 25,
+ tests => 26,
at_least_version => [2, 2, 0, "GdkDisplay is new in 2.2"];
# $Id$
@@ -107,7 +107,7 @@ SKIP: {
}
SKIP: {
- skip("new 2.11 stuff", 1)
+ skip("new 2.12 stuff", 1)
unless Gtk2->CHECK_VERSION(2, 12, 0);
ok (defined $display->supports_composite);
@@ -116,6 +116,14 @@ SKIP: {
# FIXME: currently segfaults for me. see #85715.
# $display -> close();
+SKIP: {
+ skip 'new 2.22 stuff', 1
+ unless Gtk2->CHECK_VERSION(2, 22, 0);
+
+ my $display = Gtk2::Gdk::Display -> get_default();
+ ok (defined $display->is_closed);
+}
+
__END__
Copyright (C) 2003-2005 by the gtk2-perl team (see the file AUTHORS for the
diff --git a/t/GdkDnd.t b/t/GdkDnd.t
index b839894..c7a0c9b 100644
--- a/t/GdkDnd.t
+++ b/t/GdkDnd.t
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Gtk2::TestHelper tests => 20;
+use Gtk2::TestHelper tests => 26;
# $Id$
@@ -41,7 +41,8 @@ isa_ok($context, "Gtk2::Gdk::DragContext");
ok($context -> protocol());
is($context -> is_source(), 1);
is($context -> source_window(), $window -> window());
-# is_deeply([$context -> targets()], \ targets);
+is_deeply([map { $_ -> name() } $context -> targets()],
+ [map { $_ -> name() } @targets]);
isa_ok(($context -> targets())[0], "Gtk2::Gdk::Atom");
($destination, $protocol) = $context -> find_window($window -> window(), 0, 0);
@@ -101,6 +102,19 @@ SKIP: {
$context -> abort(0);
}
+SKIP: {
+ skip 'new 2.22 stuff', 5
+ unless Gtk2->CHECK_VERSION(2, 22, 0);
+
+ my $context = Gtk2::Gdk::DragContext -> begin($window -> window(), @targets);
+ ok(defined $context -> get_actions());
+ ok(defined $context -> get_selected_action());
+ ok(defined $context -> get_suggested_action());
+ is($context -> get_source_window(), $window -> window());
+ is_deeply([map { $_ -> name() } $context -> list_targets()],
+ [map { $_ -> name() } @targets]);
+}
+
__END__
Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS for the
diff --git a/t/GdkInput.t b/t/GdkInput.t
index 392008f..05af131 100644
--- a/t/GdkInput.t
+++ b/t/GdkInput.t
@@ -1,16 +1,16 @@
#!/usr/bin/perl -w
use strict;
-use Gtk2::TestHelper tests => 14;
+use Gtk2::TestHelper tests => 20;
# $Id$
use Gtk2::Gdk::Keysyms;
my @devices = Gtk2::Gdk -> devices_list();
-isa_ok ($devices[0], "Gtk2::Gdk::Device");
+isa_ok($devices[0], "Gtk2::Gdk::Device");
my $device = Gtk2::Gdk::Device -> get_core_pointer();
-isa_ok ($device, "Gtk2::Gdk::Device");
+isa_ok($device, "Gtk2::Gdk::Device");
is($device -> name, "Core Pointer");
is($device -> source, "mouse");
is($device -> mode, "screen");
@@ -46,6 +46,24 @@ delta_ok($device -> get_axis("x", 1.23, 2, 3, 4), 1.23);
Gtk2::Gdk::Input -> set_extension_events($window -> window(), [qw/pointer-motion-mask/], "all");
+SKIP: {
+ skip 'new 2.22 stuff', 6
+ unless Gtk2->CHECK_VERSION(2, 22, 0);
+
+ my $device = Gtk2::Gdk::Device -> get_core_pointer();
+ ok(defined $device->get_axis_use(0));
+ ok(defined $device->get_mode());
+ ok(defined $device->get_name());
+ ok(defined $device->get_n_axes());
+ ok(defined $device->get_source());
+
+ skip 'no keys on device', 1
+ unless $device -> keys();
+
+ my ($keyval, $modifiers) = $device->get_key(0);
+ ok(defined $keyval && defined $modifiers);
+}
+
__END__
Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS for the
diff --git a/t/GdkScreen.t b/t/GdkScreen.t
index c3a5fb7..2f26fed 100644
--- a/t/GdkScreen.t
+++ b/t/GdkScreen.t
@@ -2,7 +2,7 @@
# vim: set ft=perl :
use strict;
use Gtk2::TestHelper
- tests => 28,
+ tests => 26,
at_least_version => [2, 2, 0, "GdkScreen is new in 2.2"];
# $Id$
@@ -56,7 +56,7 @@ SKIP: {
}
SKIP: {
- skip "new 2.10 stuff", 4
+ skip "new 2.10 stuff", 2
unless Gtk2->CHECK_VERSION (2, 10, 0);
my $dpi = $screen->get_resolution;
@@ -69,15 +69,6 @@ SKIP: {
} else {
ok (1);
}
-
- skip "cairo stuff", 2
- unless UNIVERSAL::can("Cairo::FontOptions", "create");
-
- my $options = Cairo::FontOptions->create;
- $screen->set_font_options (undef);
- is ($screen->get_font_options, undef);
- $screen->set_font_options ($options);
- isa_ok ($screen->get_font_options, "Cairo::FontOptions");
}
SKIP: {
diff --git a/t/GdkVisual.t b/t/GdkVisual.t
index b8c28c9..eae5906 100644
--- a/t/GdkVisual.t
+++ b/t/GdkVisual.t
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Gtk2::TestHelper tests => 24;
+use Gtk2::TestHelper tests => 32;
# $Id$
@@ -54,6 +54,26 @@ like($visual -> blue_mask, qr/^\d+$/);
like($visual -> blue_shift, qr/^\d+$/);
like($visual -> blue_prec, qr/^\d+$/);
+SKIP: {
+ skip 'new 2.22 stuff', 8
+ unless Gtk2->CHECK_VERSION(2, 22, 0);
+
+ my $visual = Gtk2::Gdk::Visual -> get_system();
+
+ my ($mask, $shift, $precision) = $visual -> get_blue_pixel_details();
+ ok(defined $mask && defined $shift && defined $precision);
+ ($mask, $shift, $precision) = $visual -> get_green_pixel_details();
+ ok(defined $mask && defined $shift && defined $precision);
+ ($mask, $shift, $precision) = $visual -> get_red_pixel_details();
+ ok(defined $mask && defined $shift && defined $precision);
+
+ ok(defined $visual -> get_bits_per_rgb());
+ ok(defined $visual -> get_byte_order());
+ ok(defined $visual -> get_colormap_size());
+ ok(defined $visual -> get_depth());
+ ok(defined $visual -> get_visual_type());
+}
+
__END__
Copyright (C) 2004 by the gtk2-perl team (see the file AUTHORS for the
diff --git a/t/GdkWindow.t b/t/GdkWindow.t
index 546a816..e5d9949 100644
--- a/t/GdkWindow.t
+++ b/t/GdkWindow.t
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use strict;
-use Gtk2::TestHelper tests => 45;
+use Gtk2::TestHelper tests => 56;
# $Id$
@@ -326,6 +326,8 @@ SKIP: {
$window -> remove_redirection();
}
+$window -> hide();
+
SKIP: {
skip 'new 2.18 stuff', 5
unless Gtk2->CHECK_VERSION(2, 18, 0);
@@ -352,7 +354,23 @@ SKIP: {
isa_ok($offscreen->get_embedder,'Gtk2::Gdk::Window');
}
-$window -> hide();
+SKIP: {
+ skip 'new 2.22 stuff', 11
+ unless Gtk2->CHECK_VERSION(2, 22, 0);
+
+ my $window = Gtk2::Gdk::Window -> new(undef, { window_type => 'toplevel' });
+ is_deeply ([$window->coords_from_parent (0, 0)], [0, 0]);
+ is_deeply ([$window->coords_to_parent (0, 0)], [0, 0]);
+ ok (defined $window->get_accept_focus);
+ ok (defined $window->get_composited);
+ isa_ok ($window->get_effective_parent, 'Gtk2::Gdk::Window');
+ isa_ok ($window->get_effective_toplevel, 'Gtk2::Gdk::Window');
+ ok (defined $window->get_focus_on_map);
+ ok (defined $window->get_modal_hint);
+ ok (defined $window->has_native);
+ ok (defined $window->is_input_only);
+ ok (defined $window->is_shaped);
+}
__END__
diff --git a/xs/GdkCairo.xs b/xs/GdkCairo.xs
index efb9a0d..427b46e 100644
--- a/xs/GdkCairo.xs
+++ b/xs/GdkCairo.xs
@@ -69,13 +69,24 @@ void gdk_cairo_reset_clip (cairo_t *cr, GdkDrawable *drawable);
# ---------------------------------------------------------------------------- #
-MODULE = Gtk2::Gdk::Cairo PACKAGE = Gtk2::Gdk::Screen PREFIX = gdk_screen_
-
#if GTK_CHECK_VERSION (2, 10, 0)
+MODULE = Gtk2::Gdk::Cairo PACKAGE = Gtk2::Gdk::Screen PREFIX = gdk_screen_
+
const cairo_font_options_t_ornull* gdk_screen_get_font_options (GdkScreen *screen);
void gdk_screen_set_font_options (GdkScreen *screen, const cairo_font_options_t_ornull *options);
#endif
+# ---------------------------------------------------------------------------- #
+
+MODULE = Gtk2::Gdk::Cairo PACKAGE = Gtk2::Gdk::Window PREFIX = gdk_window_
+
+#if GTK_CHECK_VERSION (2, 22, 0)
+
+cairo_surface_t * gdk_window_create_similar_surface (GdkWindow *window, cairo_content_t content, int width, int height);
+
+cairo_pattern_t * gdk_window_get_background_pattern (GdkWindow *window);
+
+#endif
diff --git a/xs/GdkCursor.xs b/xs/GdkCursor.xs
index e6525de..5dacdd7 100644
--- a/xs/GdkCursor.xs
+++ b/xs/GdkCursor.xs
@@ -111,3 +111,9 @@ gdk_cursor_new_from_name (class, display, name)
GdkPixbuf_noinc* gdk_cursor_get_image (GdkCursor *cursor);
#endif
+
+#if GTK_CHECK_VERSION (2, 22, 0)
+
+GdkCursorType gdk_cursor_get_cursor_type (GdkCursor *cursor);
+
+#endif /* 2.22 */
diff --git a/xs/GdkDisplay.xs b/xs/GdkDisplay.xs
index 26634e6..f558f1d 100644
--- a/xs/GdkDisplay.xs
+++ b/xs/GdkDisplay.xs
@@ -221,3 +221,9 @@ gboolean gdk_display_supports_input_shapes (GdkDisplay *display);
gboolean gdk_display_supports_composite (GdkDisplay *display);
#endif
+
+#if GTK_CHECK_VERSION (2, 22, 0)
+
+gboolean gdk_display_is_closed (GdkDisplay *display);
+
+#endif /* 2.22 */
diff --git a/xs/GdkDnd.xs b/xs/GdkDnd.xs
index a22adb2..808c14a 100644
--- a/xs/GdkDnd.xs
+++ b/xs/GdkDnd.xs
@@ -74,6 +74,29 @@ gdk_drag_context_new (class)
## void gdk_drag_context_ref (GdkDragContext *context)
## void gdk_drag_context_unref (GdkDragContext *context)
+#if GTK_CHECK_VERSION (2, 22, 0)
+
+GdkDragAction gdk_drag_context_get_actions (GdkDragContext *context);
+
+GdkDragAction gdk_drag_context_get_selected_action (GdkDragContext *context);
+
+GdkDragAction gdk_drag_context_get_suggested_action (GdkDragContext *context);
+
+# GList * gdk_drag_context_list_targets (GdkDragContext *context);
+void
+gdk_drag_context_list_targets (GdkDragContext *context)
+ PREINIT:
+ GList * i;
+ PPCODE:
+ for (i = gdk_drag_context_list_targets (context); i != NULL ; i = i->next)
+ XPUSHs (sv_2mortal (newSVGdkAtom ((GdkAtom)i->data)));
+
+GdkWindow * gdk_drag_context_get_source_window (GdkDragContext *context);
+
+#endif /* 2.22 */
+
+# --------------------------------------------------------------------------- #
+
MODULE = Gtk2::Gdk::Dnd PACKAGE = Gtk2::Gdk::DragContext PREFIX = gdk_drag_
## void gdk_drag_status (GdkDragContext *context, GdkDragAction action, guint32 time_)
@@ -217,6 +240,8 @@ gdk_drag_abort (context, time_)
GdkDragContext *context
guint32 time_
+# --------------------------------------------------------------------------- #
+
MODULE = Gtk2::Gdk::Dnd PACKAGE = Gtk2::Gdk::DragContext PREFIX = gdk_
## void gdk_drop_reply (GdkDragContext *context, gboolean ok, guint32 time_)
diff --git a/xs/GdkInput.xs b/xs/GdkInput.xs
index a32717d..0021e6d 100644
--- a/xs/GdkInput.xs
+++ b/xs/GdkInput.xs
@@ -247,6 +247,22 @@ gdk_device_get_core_pointer (class)
#endif /* ! GDK_MULTIHEAD_SAFE */
+#if GTK_CHECK_VERSION (2, 22, 0)
+
+GdkAxisUse gdk_device_get_axis_use (GdkDevice *device, guint index);
+
+void gdk_device_get_key (GdkDevice *device, guint index, OUTLIST guint keyval, OUTLIST GdkModifierType modifiers);
+
+GdkInputMode gdk_device_get_mode (GdkDevice *device);
+
+const gchar * gdk_device_get_name (GdkDevice *device);
+
+gint gdk_device_get_n_axes (GdkDevice *device);
+
+GdkInputSource gdk_device_get_source (GdkDevice *device);
+
+#endif /* 2.22 */
+
MODULE = Gtk2::Gdk::Device PACKAGE = Gtk2::Gdk::Input PREFIX = gdk_input_
## void gdk_input_set_extension_events (GdkWindow *window, gint mask, GdkExtensionMode mode)
diff --git a/xs/GdkVisual.xs b/xs/GdkVisual.xs
index dcf67ad..e254f2a 100644
--- a/xs/GdkVisual.xs
+++ b/xs/GdkVisual.xs
@@ -179,3 +179,23 @@ red_mask (visual)
}
OUTPUT:
RETVAL
+
+#if GTK_CHECK_VERSION (2, 22, 0)
+
+void gdk_visual_get_blue_pixel_details (GdkVisual *visual, OUTLIST guint32 mask, OUTLIST gint shift, OUTLIST gint precision);
+
+void gdk_visual_get_green_pixel_details (GdkVisual *visual, OUTLIST guint32 mask, OUTLIST gint shift, OUTLIST gint precision);
+
+void gdk_visual_get_red_pixel_details (GdkVisual *visual, OUTLIST guint32 mask, OUTLIST gint shift, OUTLIST gint precision);
+
+gint gdk_visual_get_bits_per_rgb (GdkVisual *visual);
+
+GdkByteOrder gdk_visual_get_byte_order (GdkVisual *visual);
+
+gint gdk_visual_get_colormap_size (GdkVisual *visual);
+
+gint gdk_visual_get_depth (GdkVisual *visual);
+
+GdkVisualType gdk_visual_get_visual_type (GdkVisual *visual);
+
+#endif /* 2.22 */
diff --git a/xs/GdkWindow.xs b/xs/GdkWindow.xs
index 3f9a76b..63c51ba 100644
--- a/xs/GdkWindow.xs
+++ b/xs/GdkWindow.xs
@@ -1041,6 +1041,32 @@ void gdk_window_geometry_changed (GdkWindow *window);
#endif /* 2.18 */
+#if GTK_CHECK_VERSION (2, 22, 0)
+
+void gdk_window_coords_from_parent (GdkWindow *window, gdouble parent_x, gdouble parent_y, OUTLIST gdouble x, OUTLIST gdouble y);
+
+void gdk_window_coords_to_parent (GdkWindow *window, gdouble x, gdouble y, OUTLIST gdouble parent_x, OUTLIST gdouble parent_y);
+
+gboolean gdk_window_get_accept_focus (GdkWindow *window);
+
+gboolean gdk_window_get_composited (GdkWindow *window);
+
+GdkWindow * gdk_window_get_effective_parent (GdkWindow *window);
+
+GdkWindow * gdk_window_get_effective_toplevel (GdkWindow *window);
+
+gboolean gdk_window_get_focus_on_map (GdkWindow *window);
+
+gboolean gdk_window_get_modal_hint (GdkWindow *window);
+
+gboolean gdk_window_has_native (GdkWindow *window);
+
+gboolean gdk_window_is_input_only (GdkWindow *window);
+
+gboolean gdk_window_is_shaped (GdkWindow *window);
+
+#endif /* 2.22 */
+
#if GTK_CHECK_VERSION (2, 18, 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]