[perl-Gtk3] Add an override for Gtk3::Widget::style_get
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Gtk3] Add an override for Gtk3::Widget::style_get
- Date: Tue, 25 Oct 2016 15:51:12 +0000 (UTC)
commit 3f7dbbd38fdcd2f0c7400c676be50378628ca601
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Tue Oct 25 16:59:57 2016 +0200
Add an override for Gtk3::Widget::style_get
lib/Gtk3.pm | 20 ++++++++++++++++++++
t/overrides.t | 11 ++++++++++-
2 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index afeaf8f..ca0d267 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -1837,6 +1837,26 @@ sub Gtk3::Widget::render_icon {
$_GTK_ICON_SIZE_NICK_TO_ID->($size), $detail);
}
+=item * A Perl reimplementation of C<Gtk3::Widget::style_get> is provided.
+
+=cut
+
+sub Gtk3::Widget::style_get {
+ my ($widget, @rest) = @_;
+ my $properties = _rest_to_ref (\@rest);
+ my @values;
+ foreach my $property (@$properties) {
+ my $pspec = Gtk3::WidgetClass::find_style_property ($widget, $property);
+ croak "Cannot find type information for property '$property' on $widget"
+ unless defined $pspec;
+ my $value_wrapper = Glib::Object::Introspection::GValueWrapper->new (
+ $pspec->get_value_type, undef);
+ $widget->style_get_property ($property, $value_wrapper);
+ push @values, $value_wrapper->get_value;
+ }
+ return @values[0..$#values];
+}
+
=item * C<Gtk3::Window::new> uses the default type = 'toplevel'.
=cut
diff --git a/t/overrides.t b/t/overrides.t
index b8047bd..808d3d8 100644
--- a/t/overrides.t
+++ b/t/overrides.t
@@ -7,7 +7,7 @@ use warnings;
use utf8;
use Encode;
-plan tests => 215;
+plan tests => 216;
note('Gtk3::CHECK_VERSION and check_version');
{
@@ -572,6 +572,15 @@ SKIP: {
isa_ok ($pixbuf, "Gtk3::Gdk::Pixbuf");
}
+{
+ my $widget = Gtk3::Label->new ("Test");
+ my @values = $widget->style_get (qw/cursor-aspect-ratio
+ cursor-color
+ focus-line-width
+ focus-padding/);
+ is (@values, 4);
+}
+
SKIP: {
skip 'atom stuff; missing annotations', 2
unless Gtk3::CHECK_VERSION(3, 2, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]