#!/usr/bin/perl use warnings; use strict; use Glib qw(TRUE FALSE); use Gtk2 '-init'; my $dialog = Gtk2::Dialog->new ('Confirmation Dialog', undef, 'modal', 'gtk-ok' => 'ok', # response ids may be one of the built-in enums... '_Cancel' => 2, # or any positive integer. 'gtk-undo' => 'reject', 'gtk-save' => 'accept', 'gtk-cancel' => 'cancel', 'Do it' => 'ok', ); # put an hbox with a label and entry into the dialog's vbox area. my $hbox = Gtk2::HBox->new (FALSE, 6); $hbox->pack_start (Gtk2::Label->new ('Continue Real Transfer? '), TRUE, TRUE, 0); $hbox->show_all; $dialog->vbox->pack_start ($hbox, TRUE, TRUE, 0); # Set which response is the default: $dialog->set_default_response ('ok'); # connect a signal to the dialog's response signal. $dialog->signal_connect (response => sub { print "@_\n"; # get our params shift; # we don't need the dialog my $response = shift; # the clicked button print "The user clicked: $response\n"; if ($response eq 'ok'){ Gtk2->main_quit; } if ($response eq 'cancel'){ return } #more if's and elsif's...... }); # show the dialog $dialog->show; Gtk2->main;