Strange interaction between Gtk2::Dialog and signal from Goo::Canvas
- From: jeffrey ratcliffe gmail com
- To: gtk-perl-list gnome org
- Subject: Strange interaction between Gtk2::Dialog and signal from Goo::Canvas
- Date: Fri, 10 Jul 2009 13:08:07 +0000
In the example below, whichever Goo::Canvas::Text object is clicked, only the signal from the first one clicked is fired. With Gtk2::Buttons, it works.
If I comment out the
if ($dialog->run eq 'ok') {}
line, then the Goo::Canvas example works too.
Does anyone have any insight why that might be?
Regards
Jeff
#!/usr/bin/perl
use warnings;
use strict;
use Goo::Canvas;
use Gtk2 '-init';
use Glib qw(TRUE FALSE);
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect('delete_event' => sub { Gtk2->main_quit; });
$window->set_default_size(640, 600);
my $canvas = Goo::Canvas->new();
$canvas->set_bounds(0, 0, 250, 250);
my $vbox = Gtk2::VBox->new;
$window->add($vbox);
$vbox->add($canvas);
my $root = $canvas->get_root_item();
for (my $i = 0; $i < 3; $i++) {
boxed_text($root, $i, $i*50, $i*50, $i*50+50, $i*50+50);
add_button($vbox, $i);
}
$window->show_all();
sub boxed_text {
my ($root, $char, $x1, $y1, $x2, $y2) = @_;
my $text = Goo::Canvas::Text->new($root, $char, $x1, $y1, $x2-$x1, 'nw', 'height' => $y2-$y1);
# clicking text box produces a dialog to edit the text
$text->signal_connect('button-press-event' => sub {
my ($widget, $target, $ev) = @_;
print "text $widget button-press-event\n", $widget->get('text'), "\n";
my $dialog = Gtk2::Dialog -> new ('Editing text...', $window,
'modal',
'gtk-ok' => 'ok',
'gtk-cancel' => 'cancel');
$dialog->set_default_response ('ok');
$dialog->show_all;
if ($dialog->run eq 'ok') {}
$dialog->destroy;
return TRUE;
});
}
sub add_button {
my ($vbox, $label) = @_;
my $button = Gtk2::Button->new($label);
$vbox->add($button);
$button->signal_connect('button-press-event' => sub {
my ($widget, $target, $ev) = @_;
print "text $widget button-press-event\n", $widget->get('label'), "\n";
my $dialog = Gtk2::Dialog -> new ('Editing text...', $window,
'modal',
'gtk-ok' => 'ok',
'gtk-cancel' => 'cancel');
$dialog->set_default_response ('ok');
$dialog->show_all;
if ($dialog->run eq 'ok') {}
$dialog->destroy;
return TRUE;
});
}
Gtk2->main;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]