[perl-Gtk3] Gtk3::Dialog, Gtk3::InfoBar: correctly pass user data to 'response' handlers
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Gtk3] Gtk3::Dialog, Gtk3::InfoBar: correctly pass user data to 'response' handlers
- Date: Fri, 17 Jun 2016 16:19:33 +0000 (UTC)
commit 9cecc2118141e4d8971ce637fe00de904ab5841a
Author: Maximilian Lika <max augsburg gmx de>
Date: Fri Jun 17 14:26:37 2016 +0200
Gtk3::Dialog, Gtk3::InfoBar: correctly pass user data to 'response' handlers
lib/Gtk3.pm | 4 ++--
t/zz-GtkDialog.t | 20 +++++++++++++++++++-
t/zz-GtkInfoBar.t | 18 ++++++++++++++----
3 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index c661d8d..c1f3f41 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -296,8 +296,8 @@ my $_GTK_RESPONSE_NICK_TO_ID = sub {
# Converter for GtkDialog's "response" signal.
sub Gtk3::Dialog::_gtk3_perl_response_converter {
- my ($dialog, $id) = @_;
- return ($dialog, $_GTK_RESPONSE_ID_TO_NICK->($id));
+ my ($dialog, $id, $data) = @_;
+ return ($dialog, $_GTK_RESPONSE_ID_TO_NICK->($id), $data);
}
=item * Values of type Gtk3::IconSize are converted to and from nick names if
diff --git a/t/zz-GtkDialog.t b/t/zz-GtkDialog.t
index b11ead5..efdaf38 100644
--- a/t/zz-GtkDialog.t
+++ b/t/zz-GtkDialog.t
@@ -7,7 +7,7 @@ BEGIN { require './t/inc/setup.pl' };
use strict;
use warnings;
-plan tests => 15;
+plan tests => 17;
my $win = Gtk3::Window->new ('toplevel');
@@ -50,6 +50,24 @@ $d3->get_action_area->pack_start (Gtk3::Label->new ('<- Actions'), 0, 0, 0);
$d3->signal_connect (response => sub { is ($_[1], 44); 1; });
$btn3->clicked;
+# test whether user data are passed to the callback functions
+{
+ my $d = Gtk3::Dialog->new;
+ $d->set_transient_for ($win);
+ my $b = $d->add_button ('First Button', 'ok');
+ # pass user data to the callback function
+ $d->signal_connect('response'=> sub {
+ is ($_[2], 'DATA', 'user data are passed to the callback function');
+ Gtk3::EVENT_STOP;
+ }, 'DATA');
+ Glib::Idle->add( sub {
+ $b->clicked;
+ Glib::SOURCE_REMOVE;
+ });
+ is ($d->run, 'ok');
+ $d->hide;
+}
+
# make sure that known response types are converted to strings for the reponse
# signal of Gtk3::Dialog and its ancestors
SKIP: {
diff --git a/t/zz-GtkInfoBar.t b/t/zz-GtkInfoBar.t
index 2f164b4..3880124 100644
--- a/t/zz-GtkInfoBar.t
+++ b/t/zz-GtkInfoBar.t
@@ -8,7 +8,7 @@ BEGIN { require './t/inc/setup.pl' }
use strict;
use warnings;
-plan tests => 15;
+plan tests => 16;
ok (my $win = Gtk3::Window->new ('toplevel'));
@@ -43,15 +43,25 @@ is ($infobar->get_message_type, 'error', '[gs]et_message_type');
$infobar->set_default_response (4);
ok (1, 'set_default_response');
+{
+ my $infobar = Gtk3::InfoBar->new;
+ $infobar->signal_connect (response => sub {
+ is ($_[2], 'DATA', 'user data made it through');
+ Gtk3::EVENT_STOP;
+ }, 'DATA');
+ $infobar->response ('ok');
+}
+
SKIP: {
skip 'Need generic signal marshaller', 2
unless check_gi_version (1, 33, 10);
+ my $infobar = Gtk3::InfoBar->new;
$infobar->signal_connect (response => sub {
- my ($infobar,$response) = @_;
+ my ($infobar, $response) = @_;
my $expected = $infobar->{expected_response};
- ok ($response eq $expected, "response '$expected'");
- 1;
+ is ($response, $expected, "response '$expected'");
+ Gtk3::EVENT_STOP;
});
$infobar->response ($infobar->{expected_response} = 5);
$infobar->response ($infobar->{expected_response} = 'ok');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]