1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
use Gtk;
use Gnome;
use Getopt::Long;
#TITLE: Druid example
#REQUIRES: Gtk GdkImlib Gnome
@options = (
# argspec => description
# argspec = long_arg_name[|single_char_name][=s|i|f] (see Getopt::Long)
"message|m=s", "Message to display in the druid",
"burp=i", "Just a different argument type",
"yadda|y", "Yet another one for testing",
"urka!", "Urka option",
"verbose+", "Be verbose",
);
$message = "This is a test";
Gnome->init('druid', 0.1, {
callback => \&options,
remove => 1, #remove options from the command line
options => [@options]
});
# same as above without callback and remove=0
#Gnome->init('druid', 0.1, [@options ]);
sub options {
my ($name, $val) = @_;
$val = '' unless defined $val;
$message = $val if $name eq 'message';
}
# you could use Getopt::Long here if you didn't set a callback in Gnome::init
print "Remaining args: @ARGV\n";
GetOptions(undef, Gnome->getopt_options,
# should get the arg names from the options array to avoid duplication
"message|m=s", \$message,
"burp=i", \$dummy,
"yadda|y", \$dummy,
"urka!", \$dummy,
"verbose+", \$dummy,
) || die "Wrong options: ";
$logo = load_image Gtk::Gdk::ImlibImage ('../../Gtk/samples/xpm/3DRings.xpm');
#$logo2 = load_image Gtk::Gdk::ImlibImage ('../../Gtk/samples/xpm/Modeller.xpm');
$logo2 = load_image Gtk::Gdk::ImlibImage ('save.xpm');
my $win = new Gtk::Window("toplevel");
$win->signal_connect( "destroy", \&Gtk::main_quit );
my $vbox = new Gtk::VBox( 0, 2 );
$win->add($vbox);
$vbox->show;
my $druid = new Gnome::Druid;
$druid->signal_connect("cancel", \&Gtk::main_quit);
$vbox->pack_start($druid,0,0,0);
$druid_start = new Gnome::DruidPageStart();
$druid_start->set_title("test");
$druid_start->set_text($message);
$druid_start->set_watermark($logo);
$druid_start->show;
$druid->append_page($druid_start);
$druid_finish = new Gnome::DruidPageFinish();
$druid_finish->set_title("Test Finished.");
$druid_finish->set_text("This test is over.");
$druid_finish->set_logo($logo2);
$druid_finish->signal_connect("finish", \&Gtk::main_quit);
$druid_finish->show;
$druid->append_page($druid_finish);
$druid->show;
$win->show;
main Gtk;
|