[perl-Gtk3] Add overrides for Gtk3::Editable
- From: Torsten SchÃnfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Gtk3] Add overrides for Gtk3::Editable
- Date: Tue, 8 Jan 2013 22:11:45 +0000 (UTC)
commit 7992537ac8c8df624b3255474ca5bd827d641f8f
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date: Tue Jan 8 22:55:05 2013 +0100
Add overrides for Gtk3::Editable
Specifically, its insert_text method and signal.
NEWS | 2 +-
lib/Gtk3.pm | 17 ++++++++++++++++-
t/overrides.t | 36 +++++++++++++++++++++++++++++++++++-
3 files changed, 52 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 067daee..73fe8c0 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
{{$NEXT}}
-* Add overrides for Gtk3::Container.
+* Add overrides for Gtk3::Container and Gtk3::Editable.
* Add Gtk3::EVENT_PROPAGATE and Gtk3::EVENT_STOP.
* Test that no double-frees occur for custom Gtk3::Widget subclasses.
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index ee886bd..91cf3e0 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -57,6 +57,9 @@ my @_GTK_HANDLE_SENTINEL_BOOLEAN_FOR = qw/
Gtk3::TreeModelSort::convert_child_iter_to_iter
Gtk3::TreeSelection::get_selected
/;
+my @_GTK_USE_GENERIC_SIGNAL_MARSHALLER_FOR = (
+ ['Gtk3::Editable', 'insert-text'],
+);
# - gdk customization ------------------------------------------------------- #
@@ -152,7 +155,8 @@ sub import {
package => $_GTK_PACKAGE,
name_corrections => \%_GTK_NAME_CORRECTIONS,
flatten_array_ref_return_for => \ _GTK_FLATTEN_ARRAY_REF_RETURN_FOR,
- handle_sentinel_boolean_for => \ _GTK_HANDLE_SENTINEL_BOOLEAN_FOR);
+ handle_sentinel_boolean_for => \ _GTK_HANDLE_SENTINEL_BOOLEAN_FOR,
+ use_generic_signal_marshaller_for => \ _GTK_USE_GENERIC_SIGNAL_MARSHALLER_FOR);
Glib::Object::Introspection->setup (
basename => $_GDK_BASENAME,
@@ -593,6 +597,12 @@ sub Gtk3::CssProvider::load_from_data {
$self, _unpack_unless_array_ref ($data));
}
+sub Gtk3::Editable::insert_text {
+ return Glib::Object::Introspection->invoke (
+ $_GTK_BASENAME, 'Editable', 'insert_text',
+ @_ == 4 ? @_ : (@_[0,1], length $_[1], $_[2]));
+}
+
sub Gtk3::HBox::new {
my ($class, $homogeneous, $spacing) = @_;
$homogeneous = 5 unless defined $homogeneous;
@@ -1047,6 +1057,11 @@ keys 'width', 'height', 'x' and 'y'.
=item * The Gtk3::Menu menu position callback passed to popup() does not
receive x and y parameters anymore.
+=item * Callbacks connected to Gtk3::Editable's "insert-text" signal do not
+have as many options anymore as they had in Gtk2. Changes to arguments will
+not be propagated to the next signal handler, and only the updated position can
+and must be returned.
+
=back
Note also that Gtk3::CHECK_VERSION will always fail when passed 2.y.z, so if
diff --git a/t/overrides.t b/t/overrides.t
index aa267f6..876dc8e 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 => 87;
+plan tests => 95;
# Gtk3::CHECK_VERSION and check_version
{
@@ -68,6 +68,40 @@ plan tests => 87;
like ($p->to_string, $expect);
}
+# Gtk3::Editable::insert_text
+{
+ my $entry = Gtk3::Entry->new;
+ my $orig_text = 'aeiou';
+ $entry->set_text ($orig_text);
+ my ($new_text, $pos) = ('0123456789', length $orig_text);
+ is ($entry->insert_text ($new_text, $pos),
+ $pos + length $new_text);
+ $pos = 0;
+ is ($entry->insert_text ($new_text, length $new_text, $pos),
+ $pos + length $new_text);
+ is ($entry->get_text, $new_text . $orig_text . $new_text);
+}
+
+# GtkEditable.insert-text signal
+{
+ my $entry = Gtk3::Entry->new;
+ my $orig_text = 'ÃÃÃ';
+ $entry->set_text ($orig_text);
+
+ my ($my_text, $my_pos) = ('123', 2);
+ $entry->signal_connect ('insert-text' => sub {
+ my ($entry, $new_text, $new_text_length, $position, $data) = @_;
+ is ($new_text, $my_text);
+ is ($new_text_length, length $my_text);
+ is ($position, $my_pos);
+ # Disregard $position and move the text to the end.
+ return length $entry->get_text;
+ });
+ is ($entry->insert_text ($my_text, $my_pos),
+ length ($orig_text) + length ($my_text));
+ is ($entry->get_text, $orig_text . $my_text);
+}
+
# 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]