Gtk2

 view release on metacpan or  search on metacpan

examples/assistant.pl  view on Meta::CPAN

  my %pdata = (
    assistant => $assistant,
    page => $page,
  );
  $check->signal_connect (toggled => \&complete_cb, \%pdata);

  $page->show_all if $visible;

  $assistant->append_page ($page);
  $assistant->set_page_title ($page, $text);
  $assistant->set_page_complete ($page, $complete);

  return $page;
}

sub cancel_callback {
  my $widget = shift;
  print "cancel\n";
  $widget->hide;
}

sub close_callback {
  my $widget = shift;
  print "close\n";
  $widget->hide;
}

sub apply_callback {
  my $widget = shift;
  print "apply\n";
}

sub progress_timeout {
  my $assistant = shift;

  my $current_page = $assistant->get_current_page;
  my $page = $assistant->get_nth_page ($current_page);
  my $progress = $page->child;

  my $value  = $progress->get_fraction;
  $value += 0.1;
  $progress->set_fraction ($value);

  if ($value >= 1.0) {
    $assistant->set_page_complete ($page, TRUE);
    return FALSE;
  }

  return TRUE;
}

sub prepare_callback {
  my ($assistant, $page) = @_;

  if ($page->isa ('Gtk2::Label')) {
    print "prepare: ".$page->get_text."\n";
  } elsif ($assistant->get_page_type ($page) eq 'progress') {
    my $progress = $page->child;
    $assistant->set_page_complete ($page, FALSE);
    $progress->set_fraction (0.0);
    Glib::Timeout->add (300, \&progress_timeout, $assistant);
  } else {
    print "prepare: ".$assistant->get_current_page,"\n";
  }
}

sub create_simple_assistant {
  my $widget = shift;

  my $assistant = $widget->{assistant};

  if (!$assistant)
    {
      $assistant = Gtk2::Assistant->new;
      $assistant->set_default_size (400, 300);

      $assistant->signal_connect (cancel => \&cancel_callback);
      $assistant->signal_connect (close => \&close_callback);
      $assistant->signal_connect (apply => \&apply_callback);
      $assistant->signal_connect (prepare => \&prepare_callback);

      my $page = get_test_page ("Page 1");
      $page->show;
      $assistant->append_page ($page);
      $assistant->set_page_title ($page, "Page 1");
      $assistant->set_page_complete ($page, TRUE);

      $page = get_test_page ("Page 2");
      $page->show;
      $assistant->append_page ($page);
      $assistant->set_page_title ($page, "Page 2");
      $assistant->set_page_type ($page, 'confirm');
      $assistant->set_page_complete ($page, TRUE);
    }

  if (!$assistant->visible) {
    $assistant->show;
  } else {
    $assistant->destroy;
    $assistant = undef;
  }

  $widget->{assistant} = $assistant;
}

sub visible_cb {
  my ($check, $page) = @_;
  $page->set (visible => $check->get_active);
}

sub create_generous_assistant {
  my ($widget) = @_;

  my $assistant = $widget->{assistant};

  if (!$assistant)
    {
      $assistant = Gtk2::Assistant->new;
      $assistant->set_default_size (400, 300);

      $assistant->signal_connect (cancel => \&cancel_callback);

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.021 second using v1.00-cache-1.14-grep-28634ff-cpan-fadd93f81bc )