Gtk2
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
gtk-demo/assistant.pl view on Meta::CPAN
#!/usr/bin/perl -w
#
# Assistant
#
# Demonstrates a sample multistep assistant. Assistants are used to divide
# an operation into several simpler sequential steps, and to guide the user
# through these steps.
#
package assistant;
use strict;
use warnings;
use Glib ':constants';
use Gtk2;
#include "demo-common.h"
my $assistant = undef;
my $progress_bar = undef;
sub apply_changes_gradually($) {
my $fraction;
# Work, work, work...
Gtk2::Gdk::Threads->leave();
$fraction = $progress_bar->get_fraction();
$fraction += 0.05;
my $cont = TRUE;
if ($fraction < 1.0) {
$progress_bar->set_fraction($fraction);
} else {
# Close automatically once changes are fully applied.
$assistant->destroy();
undef $assistant;
$cont = FALSE;
}
Gtk2::Gdk::Threads->enter();
return $cont;
}
sub on_assistant_apply($$)
{
my ($widget, $data) = @_;
# Start a timer to simulate changes taking a few seconds to apply.
Glib::Timeout->add(100, \&apply_changes_gradually, undef);
}
sub on_assistant_close_cancel($$)
{
my ($widget, $assistant) = @_;
$$assistant->destroy();
undef $$assistant;
}
sub on_assistant_prepare($$$)
{
my ($widget, $page, $data) = @_;
my ($current_page, $n_pages, $title);
$current_page = $widget->get_current_page();
$n_pages = $widget->get_n_pages();
$title = sprintf("Sample assistant (%d of %d)", $current_page + 1, $n_pages);
$widget->window()->set_title($title);
# The fourth page (counting from zero) is the progress page. The
# user clicked Apply to get here so we tell the assistant to commit,
# which means the changes up to this point are permanent and cannot
# be cancelled or revisited.
if ($current_page == 3) {
$widget->commit();
}
}
sub on_entry_changed($$)
{
my ($widget, $data) = @_;
my $assistant = $data;
my ($current_page, $page_number, $text);
$page_number = $assistant->get_current_page();
$current_page = $assistant->get_nth_page($page_number);
$text = $widget->get_text();
if ($text && $text ne '') {
$assistant->set_page_complete($current_page, TRUE);
} else {
$assistant->set_page_complete($current_page, FALSE);
}
}
sub create_page1($)
{
my $assistant = shift;
my ($box, $label, $entry, $pixbuf);
$box = Gtk2::HBox->new(FALSE, 12);
$box->set_border_width(12);
$label = Gtk2::Label->new("You must fill out this entry to continue:");
$box->pack_start($label, FALSE, FALSE, 0);
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.859 second using v1.00-cache-2.02-grep-82fe00e-cpan-503542c4f10 )