Commit 9cecc211 authored by Maximilian Lika's avatar Maximilian Lika Committed by Torsten Schönfeld

Gtk3::Dialog, Gtk3::InfoBar: correctly pass user data to 'response' handlers

parent 8135c500
......@@ -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
......
......@@ -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: {
......
......@@ -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');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment