[perl-Gtk3] Add overrides for Pango::Layout::set_text



commit 3ba5f0243e0485b034b186e69f9c6ea0d4f45997
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Sat Dec 7 00:18:43 2013 +0100

    Add overrides for Pango::Layout::set_text

 NEWS          |    1 +
 lib/Gtk3.pm   |    8 ++++++++
 t/overrides.t |   14 +++++++++++++-
 3 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index bbb25d8..e4af7a9 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@
 
 * Add overrides for Gtk3::RadioAction, Gtk3::RadioButton, Gtk3::RadioMenuItem
   and Gtk3::RadioToolButton.
+* Add overrides for Pango::Layout::set_text.
 * Require Test::Simple >= 0.96.
 
 Overview of changes in Gtk3 0.014 [2013-10-18]
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index 2ff6f69..c8b407f 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -1455,6 +1455,14 @@ sub Gtk3::Gdk::Pixbuf::save_to_callback {
     $pixbuf, $save_func, $user_data, $type, $keys, $values);
 }
 
+# Pango
+
+sub Pango::Layout::set_text {
+  return Glib::Object::Introspection->invoke (
+    $_PANGO_BASENAME, 'Layout', 'set_text',
+    @_ == 3 ? @_ : (@_[0,1], -1)); # wants length in bytes
+}
+
 # - Helpers ----------------------------------------------------------------- #
 
 sub _common_tree_model_new {
diff --git a/t/overrides.t b/t/overrides.t
index 79a9358..b61d0db 100644
--- a/t/overrides.t
+++ b/t/overrides.t
@@ -7,7 +7,7 @@ use warnings;
 use utf8;
 use Encode;
 
-plan tests => 159;
+plan tests => 161;
 
 # Gtk3::CHECK_VERSION and check_version
 {
@@ -654,3 +654,15 @@ SKIP: {
   isa_ok ($error, 'Glib::Error');
   is ($error->message, 'buzz');
 }
+
+# Pango::Layout
+{
+  my $label = Gtk3::Label->new ('Bla');
+  my $layout = $label->create_pango_layout ('Bla');
+
+  $layout->set_text('Bla bla.', 3);
+  is ($layout->get_text, 'Bla');
+
+  $layout->set_text('Bla bla.');
+  is ($layout->get_text, 'Bla bla.');
+}


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