[perl-Gtk3] Gtk3::Clipboard::set_text: make length arg optional



commit 9aa1a85b5a87a5cee909166039b05fb53d3dfd0b
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Fri Jun 17 14:51:26 2016 +0200

    Gtk3::Clipboard::set_text: make length arg optional

 lib/Gtk3.pm   |   10 ++++++++++
 t/overrides.t |   11 ++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index c1f3f41..fd24047 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -924,6 +924,16 @@ sub Gtk3::CheckMenuItem::new {
     $_GTK_BASENAME, 'CheckMenuItem', 'new', @_);
 }
 
+=item * The C<length> argument of C<Gtk3::Clipboard::set_text> is optional.
+
+=cut
+
+sub Gtk3::Clipboard::set_text {
+  return Glib::Object::Introspection->invoke (
+    $_GTK_BASENAME, 'Clipboard', 'set_text',
+    @_ == 3 ? @_ : (@_[0,1], -1)); # wants length in bytes
+}
+
 =item * C<Gtk3::Container::get_focus_chain> returns a list of widgets, or an
 empty list.
 
diff --git a/t/overrides.t b/t/overrides.t
index 0488692..a33306b 100644
--- a/t/overrides.t
+++ b/t/overrides.t
@@ -7,7 +7,7 @@ use warnings;
 use utf8;
 use Encode;
 
-plan tests => 212;
+plan tests => 214;
 
 note('Gtk3::CHECK_VERSION and check_version');
 {
@@ -87,6 +87,15 @@ note('Gtk3::CheckButton::new');
   is ($button->get_label, '_Test');
 }
 
+note('Gtk3::Clipboard::set_text');
+{
+  my $clipboard = Gtk3::Clipboard::get (Gtk3::Gdk::Atom::intern ('PRIMARY', Glib::FALSE));
+  $clipboard->set_text ('→←');
+  is ($clipboard->wait_for_text, '→←');
+  $clipboard->set_text ('→←', 3); # wants length in bytes
+  is ($clipboard->wait_for_text, '→');
+}
+
 note('Gtk3::ColorButton::new');
 {
   my $button = Gtk3::ColorButton->new;


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