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

dialog response signal class closure



The program below is an attempt to subclass Gtk2::Dialog and use a class
closure to get a new default response signal handler.  But it gets
response values as numbers like -5 for the button or -4 for a
delete-event, instead of the 'ok' and 'delete-event' strings which come
from an ordinary $dialog->signal_connect.  Is that meant to be so?  If
yes are there constants for GTK_RESPONSE_OK etc lurking around to test
the values against?

use strict;
use warnings;
use Gtk2 '-init';

package FooDialog;
use strict;
use warnings;
use Gtk2;
use Glib::Object::Subclass
  Gtk2::Dialog::,
  signals => { response => \&do_response };

sub do_response {
  my ($self, $resp) = @_;
  print "response $resp\n";
  print $resp eq 'ok' ? "equals ok\n" : "not equals ok\n";
  return $self->signal_chain_from_overridden ($resp);
}

package main;

my $dialog = FooDialog->new;
$dialog->add_button ("Press me" => 'ok');
$dialog->show;
Gtk2->main;


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