[perl-Gtk3] Add an implementation of Gtk3::StyleContext::get



commit 6d4ea49e369cf7796c5d009be370af7e163216ba
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Fri Jun 17 14:57:58 2016 +0200

    Add an implementation of Gtk3::StyleContext::get

 lib/Gtk3.pm   |   10 ++++++++++
 t/overrides.t |   10 +++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index fd24047..9ffaa37 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -1493,6 +1493,16 @@ C<set_translate_func>.
   }
 }
 
+=item * A Perl reimplementation of C<Gtk3::StyleContext::get> is provided.
+
+=cut
+
+sub Gtk3::StyleContext::get {
+  my ($context, $state, @properties) = @_;
+  my @values = map { $context->get_property ($_, $state) } @properties;
+  return @values[0..$#values];
+}
+
 =item * A Perl reimplementation of C<Gtk3::TextBuffer::create_tag> is provided.
 
 =cut
diff --git a/t/overrides.t b/t/overrides.t
index a33306b..72fcfe4 100644
--- a/t/overrides.t
+++ b/t/overrides.t
@@ -7,7 +7,7 @@ use warnings;
 use utf8;
 use Encode;
 
-plan tests => 214;
+plan tests => 215;
 
 note('Gtk3::CHECK_VERSION and check_version');
 {
@@ -320,6 +320,14 @@ note('Gtk3::Stock');
   Gtk3::Stock::set_translate_func ('perl-domain', sub {}, 42);
 }
 
+note('Gtk3::StyleContext::get');
+{
+  my $l = Gtk3::Label->new ('Test');
+  my $c = $l->get_style_context;
+  my @v = $c->get ('normal', Gtk3::STYLE_PROPERTY_COLOR, Gtk3::STYLE_PROPERTY_FONT);
+  is (scalar @v, 2, 'two items returned');
+}
+
 note('Gtk3::ToggleButton::new');
 {
   my $button = Gtk3::ToggleButton->new;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]