Commit 607f2ef3 authored by Torsten Schönfeld's avatar Torsten Schönfeld

Add overrides for Gtk3::Gdk::RGBA

parent 5f7c9a3a
......@@ -8,6 +8,7 @@
* Add overrides for Gtk3::RecentChooserDialog.
* Add overrides for Gtk3::TextBuffer.
* Add an override for Gtk3::main_level.
* Add overrides for Gtk3::Gdk::RGBA.
* Add Gtk3::EVENT_PROPAGATE and Gtk3::EVENT_STOP.
* Test that no double-frees occur for custom Gtk3::Widget subclasses.
......
......@@ -18,7 +18,7 @@ copyright_year = 2011
Carp = 0 ; core
Exporter = 0 ; core
Cairo::GObject = 1.000
Glib::Object::Introspection = 0.013_001 ; FIXME
Glib::Object::Introspection = 0.013_001 ; FIXME: 0.014
[NextRelease]
filename = NEWS
......
......@@ -1085,6 +1085,38 @@ sub Gtk3::Window::new {
# Gdk
sub Gtk3::Gdk::RGBA::new {
my ($class, @rest) = @_;
# Handle Gtk3::Gdk::RGBA->new (r, g, b, a) specially.
if (4 == @rest) {
my %data;
@data{qw/red green blue alpha/} = @rest;
return Glib::Boxed::new ($class, \%data);
}
# Fall back to Glib::Boxed::new.
return Glib::Boxed::new ($class, @rest);
}
sub Gtk3::Gdk::RGBA::parse {
my $have_instance;
{
local $@;
$have_instance = eval { $_[0]->isa ('Gtk3::Gdk::RGBA') };
}
# This needs to be switched around if/when
# <https://bugzilla.gnome.org/show_bug.cgi?id=682125> is fixed.
if ($have_instance) {
return Glib::Object::Introspection->invoke (
$_GDK_BASENAME, 'RGBA', 'parse', @_);
} else {
my $instance = Gtk3::Gdk::RGBA->new;
my $success = Glib::Object::Introspection->invoke (
$_GDK_BASENAME, 'RGBA', 'parse',
$instance, @_);
return $success ? $instance : undef;
}
}
sub Gtk3::Gdk::Window::new {
my ($class, $parent, $attr, $attr_mask) = @_;
if (not defined $attr_mask) {
......
......@@ -5,7 +5,7 @@ BEGIN { require './t/inc/setup.pl' };
use strict;
use warnings;
plan tests => 98;
plan tests => 108;
# Gtk3::CHECK_VERSION and check_version
{
......@@ -337,6 +337,28 @@ __EOD__
isa_ok ($menubars[1], "Gtk3::MenuBar");
}
# Gtk3::Gdk::RGBA
{
my $rgba = Gtk3::Gdk::RGBA->new ({red => 0.0, green => 0.5, blue => 0.5, alpha => 0.5});
isa_ok ($rgba, 'Gtk3::Gdk::RGBA');
is ($rgba->red, 0.0);
$rgba = Gtk3::Gdk::RGBA->new (red => 0.5, green => 0.0, blue => 0.5, alpha => 0.5);
isa_ok ($rgba, 'Gtk3::Gdk::RGBA');
is ($rgba->green, 0.0);
$rgba = Gtk3::Gdk::RGBA->new (0.5, 0.5, 0.0, 0.5);
isa_ok ($rgba, 'Gtk3::Gdk::RGBA');
is ($rgba->blue, 0.0);
$rgba = Gtk3::Gdk::RGBA::parse ('rgba(0.5, 0.5, 0.5, 0.0)');
isa_ok ($rgba, 'Gtk3::Gdk::RGBA');
is ($rgba->alpha, 0.0);
ok ($rgba->parse ('rgba(0.5, 0.5, 0.5, 1.0)'));
is ($rgba->alpha, 1.0);
}
# Gtk3::Gdk::Window::new
SKIP: {
# https://bugzilla.gnome.org/show_bug.cgi?id=670369
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment