[perl-Gtk3] Add overrides for Gtk3::CssProvider
- From: Torsten SchÃnfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Gtk3] Add overrides for Gtk3::CssProvider
- Date: Sat, 11 Aug 2012 19:22:55 +0000 (UTC)
commit d7b0ab48d62f658aaa53bb83dc49fb8f20b31146
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date: Sat Aug 11 21:21:51 2012 +0200
Add overrides for Gtk3::CssProvider
NEWS | 1 +
lib/Gtk3.pm | 32 +++++++++++++++++---------------
t/overrides.t | 15 ++++++++++++++-
3 files changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/NEWS b/NEWS
index 1a0f44a..b548a78 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@
* Add overrides for Gtk3::Gdk::Event.
* Add overrides for some Gtk3::RadioMenuItem constructors.
+* Add overrides for Gtk3::CssProvider.
Overview of changes in Gtk3 0.007 [2012-07-05]
==============================================
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index b688e8a..780e7a4 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -551,6 +551,13 @@ sub Gtk3::CheckMenuItem::new {
$_GTK_BASENAME, 'CheckMenuItem', 'new', @_);
}
+sub Gtk3::CssProvider::load_from_data {
+ my ($self, $data) = @_;
+ return Glib::Object::Introspection->invoke (
+ $_GTK_BASENAME, 'CssProvider', 'load_from_data',
+ $self, _unpack_unless_array_ref ($data));
+}
+
sub Gtk3::HBox::new {
my ($class, $homogeneous, $spacing) = @_;
$homogeneous = 5 unless defined $homogeneous;
@@ -784,13 +791,7 @@ sub Gtk3::Gdk::Pixbuf::new_from_data {
my ($class, $data, $colorspace, $has_alpha, $bits_per_sample, $width, $height, $rowstride) = @_;
# FIXME: do we need to keep $real_data alive and then release it in a destroy
# notify callback?
- my $real_data;
- {
- local $@;
- $real_data = (eval { @{$data} })
- ? $data
- : [unpack 'C*', $data];
- }
+ my $real_data = _unpack_unless_array_ref ($data);
return Glib::Object::Introspection->invoke (
$_GDK_PIXBUF_BASENAME, 'Pixbuf', 'new_from_data',
$class, $real_data, $colorspace, $has_alpha, $bits_per_sample, $width, $height, $rowstride,
@@ -800,16 +801,9 @@ sub Gtk3::Gdk::Pixbuf::new_from_data {
sub Gtk3::Gdk::Pixbuf::new_from_inline {
my ($class, $data, $copy_pixels) = @_;
$copy_pixels = Glib::TRUE unless defined $copy_pixels;
- my $real_data;
- {
- local $@;
- $real_data = (eval { @{$data} })
- ? $data
- : [unpack 'C*', $data];
- }
return Glib::Object::Introspection->invoke (
$_GDK_PIXBUF_BASENAME, 'Pixbuf', 'new_from_inline',
- $class, $real_data, $copy_pixels);
+ $class, _unpack_unless_array_ref ($data), $copy_pixels);
}
sub Gtk3::Gdk::Pixbuf::new_from_xpm_data {
@@ -921,6 +915,14 @@ sub _unpack_columns_and_values {
return (\ columns, \ values);
}
+sub _unpack_unless_array_ref {
+ my ($data) = @_;
+ local $@;
+ return defined eval { @{$data} }
+ ? $data
+ : [unpack 'C*', $data];
+}
+
sub _rest_to_ref {
my ($rest) = @_;
local $@;
diff --git a/t/overrides.t b/t/overrides.t
index 02cfce7..ca0d51a 100644
--- a/t/overrides.t
+++ b/t/overrides.t
@@ -5,7 +5,7 @@ BEGIN { require './t/inc/setup.pl' };
use strict;
use warnings;
-plan tests => 80;
+plan tests => 82;
# Gtk3::CHECK_VERSION and check_version
{
@@ -55,6 +55,19 @@ plan tests => 80;
is_deeply([$cell->get_cells], [$one, $two]);
}
+# Gtk3::CssProvider
+{
+ my $css = "GtkButton {font: Cantarelll 10}";
+ my $expect = qr/Cantarelll/;
+ my $p = Gtk3::CssProvider->new;
+
+ $p->load_from_data ($css);
+ like ($p->to_string, $expect);
+
+ $p->load_from_data ([unpack 'C*', $css]);
+ like ($p->to_string, $expect);
+}
+
# Gtk3::ListStore::new, set and get
SKIP: {
skip 'tree model ctors not properly supported', 5
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]