[perl-Gtk3] Add Gtk3::Gdk::Pixbuf::CHECK_VERSION
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Gtk3] Add Gtk3::Gdk::Pixbuf::CHECK_VERSION
- Date: Tue, 15 Sep 2015 19:04:54 +0000 (UTC)
commit 8f05c6f2702f5085477e6038a5726fec5d6379ab
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Mon Sep 14 18:55:57 2015 +0200
Add Gtk3::Gdk::Pixbuf::CHECK_VERSION
lib/Gtk3.pm | 57 ++++++++++++++++++++-------------------------------------
t/overrides.t | 4 ++--
2 files changed, 22 insertions(+), 39 deletions(-)
---
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index 023c925..959b9cb 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -1898,6 +1898,14 @@ sub Gtk3::Gdk::Window::new {
# --- GdkPixbuf ---
+sub Gtk3::Gdk::Pixbuf::CHECK_VERSION {
+ my ($major, $minor, $micro) = @_;
+ return
+ (Gtk3::Gdk::PIXBUF_MAJOR () > $major) ||
+ (Gtk3::Gdk::PIXBUF_MAJOR () == $major && Gtk3::Gdk::PIXBUF_MINOR () > $minor) ||
+ (Gtk3::Gdk::PIXBUF_MAJOR () == $major && Gtk3::Gdk::PIXBUF_MINOR () == $minor && Gtk3::Gdk::PIXBUF_MICRO
() >= $micro);
+}
+
=item * C<Gtk3::Gdk::Pixbuf::get_pixels> returns a byte string.
=cut
@@ -1943,13 +1951,15 @@ sub Gtk3::Gdk::Pixbuf::new_from_xpm_data {
# Version check for the new annotations described in
# <https://bugzilla.gnome.org/show_bug.cgi?id=670372>.
-my $HAVE_GDK_PIXBUF_2_31_2 = sub {
- return (Gtk3::Gdk::PIXBUF_MAJOR () == 2 && Gtk3::Gdk::PIXBUF_MINOR () > 31) ||
- (Gtk3::Gdk::PIXBUF_MAJOR () == 2 && Gtk3::Gdk::PIXBUF_MINOR () == 31 && Gtk3::Gdk::PIXBUF_MICRO ()
= 2);
-};
-my $HAVE_GDK_PIXBUF_2_31_3 = sub {
- return (Gtk3::Gdk::PIXBUF_MAJOR () == 2 && Gtk3::Gdk::PIXBUF_MINOR () > 31) ||
- (Gtk3::Gdk::PIXBUF_MAJOR () == 2 && Gtk3::Gdk::PIXBUF_MINOR () == 31 && Gtk3::Gdk::PIXBUF_MICRO ()
= 3);
+my $_GET_SAVE_VARIANT = sub {
+ my ($method) = @_;
+ if (Gtk3::Gdk::Pixbuf::CHECK_VERSION (2, 31, 3)) {
+ return $method . 'v';
+ } elsif (Gtk3::Gdk::Pixbuf::CHECK_VERSION (2, 31, 2)) {
+ return $method;
+ } else {
+ return $method . 'v';
+ }
};
=item * C<Gtk3::Gdk::Pixbuf::save>, C<save_to_buffer> and C<save_to_callback>
@@ -1965,16 +1975,7 @@ sub Gtk3::Gdk::Pixbuf::save {
croak ("Usage: \$pixbuf->save (\$filename, \$type, \\\ keys, \\\ values)\n",
" -or-: \$pixbuf->save (\$filename, \$type, \$key1 => \$value1, ...)");
}
- my $method;
- if ($HAVE_GDK_PIXBUF_2_31_3->()) {
- $method = 'savev';
- }
- elsif ($HAVE_GDK_PIXBUF_2_31_2->()) {
- $method = 'save';
- }
- else {
- $method = 'savev';
- }
+ my $method = $_GET_SAVE_VARIANT->('save');
Glib::Object::Introspection->invoke (
$_GDK_PIXBUF_BASENAME, 'Pixbuf', $method,
$pixbuf, $filename, $type, $keys, $values);
@@ -1987,16 +1988,7 @@ sub Gtk3::Gdk::Pixbuf::save_to_buffer {
croak ("Usage: \$pixbuf->save_to_buffer (\$type, \\\ keys, \\\ values)\n",
" -or-: \$pixbuf->save_to_buffer (\$type, \$key1 => \$value1, ...)");
}
- my $method;
- if ($HAVE_GDK_PIXBUF_2_31_3->()) {
- $method = 'save_to_bufferv';
- }
- elsif ($HAVE_GDK_PIXBUF_2_31_2->()) {
- $method = 'save_to_buffer';
- }
- else {
- $method = 'save_to_bufferv';
- }
+ my $method = $_GET_SAVE_VARIANT->('save_to_buffer');
my (undef, $buffer) =
Glib::Object::Introspection->invoke (
$_GDK_PIXBUF_BASENAME, 'Pixbuf', $method,
@@ -2011,16 +2003,7 @@ sub Gtk3::Gdk::Pixbuf::save_to_callback {
croak ("Usage: \$pixbuf->save_to_callback (\$save_func, \$user_data, \$type, \\\ keys, \\\ values)\n",
" -or-: \$pixbuf->save_to_callback (\$save_func, \$user_data, \$type, \$key1 => \$value1, ...)");
}
- my $method;
- if ($HAVE_GDK_PIXBUF_2_31_3->()) {
- $method = 'save_to_callbackv';
- }
- elsif ($HAVE_GDK_PIXBUF_2_31_2->()) {
- $method = 'save_to_callback';
- }
- else {
- $method = 'save_to_callbackv';
- }
+ my $method = $_GET_SAVE_VARIANT->('save_to_callback');
Glib::Object::Introspection->invoke (
$_GDK_PIXBUF_BASENAME, 'Pixbuf', $method,
$pixbuf, $save_func, $user_data, $type, $keys, $values);
diff --git a/t/overrides.t b/t/overrides.t
index 34afeab..141f53a 100644
--- a/t/overrides.t
+++ b/t/overrides.t
@@ -636,8 +636,8 @@ SKIP: {
SKIP: {
- skip 'pixbuf stuff; missing annotations', 19
- unless Gtk3::Gdk::PIXBUF_MINOR >= 25;
+ skip 'misc. pixbuf stuff; missing annotations', 19
+ unless Gtk3::Gdk::Pixbuf::CHECK_VERSION (2, 26, 0);
note('Gtk3::Gdk::Pixbuf::save, save_to_buffer, save_to_callback');
my ($width, $height) = (10, 5);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]