Crypt-IDA

 view release on metacpan or  search on metacpan

bin/SplitCombine.pl  view on Meta::CPAN

#!/usr/bin/perl -w

use threads;
use threads::shared;

use Gtk2 qw/-init -threads-init/;
#use Gtk2::GladeXML;

package main;

my $dir=$0;
$dir=~s|(.*)/.*|$1|;
my $app="$dir/SplitCombine.xml";

#$gladexml = Gtk2::GladeXML->new($app);

#ui_callbacks::init($gladexml);

#$gladexml->signal_autoconnect_from_package("ui_callbacks" );

my $builder=Gtk2::Builder->new;

$builder->add_from_file($app);
ui_callbacks::init($builder);
$builder->connect_signals(undef, ui_callbacks);

warn "builder is $builder\n";

Gtk2->main;


1;


package ui_callbacks;

# The Gtk2::GladeXML module doesn't pass the user_data information
# from the glade file, so we have to have a separate callback for each
# widget. Which is a pity, because if it did, we could just implement
# one callback for each type of widget and use the user_data field to
# determine what name to store the new data under in the %split_opts
# or %combine_opts structures...

# One way of cutting down on the number of functions that need to be
# written is to use Perl's AUTOLOAD feature. By encoding the variable
# name to be saved is in the signal name, we can extract that
# information and save it in the appropriate structure.

our %split_opts;
our %combine_opts;

use AutoLoader;
use vars ;
use Carp;

our $widgets=undef;

sub init {
  $widgets=shift;

  warn "Got widgets=$widgets\n";

  %split_opts=(
	       "shares" => 1,
	       "quorum" => 1,
	       "workers" => 1,
	       "bufsize" => 4096,
	       "key_choice" => "random",
	       "chunking_choice" => "Single file (1 chunk)",
	      );

  print $widgets->get_object("split_width"), "\n";

  # For some reason, the Glade 3 designer doesn't let you specify
  # default values for combo boxes. Do that here.
  $widgets->get_object("split_width")->set_active(0);
  $widgets->get_object("split_key_choice")->set_active(0);
  $widgets->get_object("split_chunking_choice")->set_active(0);
  $widgets->get_object("split_filespec_choice")->set_active(0);
  $widgets->get_object("split_random_choice")->set_active(0);

  # Also, Gtk2::Builder doesn't seem to allow setting default values
  # on spinbuttons (actually not true... see Alignment for widget)
  $widgets->get_object("split_shares")->set_value(1);
  $widgets->get_object("split_quorum")->set_value(1);
  $widgets->get_object("split_bufsize")->set_value(4096);
  $widgets->get_object("split_workers")->set_value(1);

}

sub AUTOLOAD {
  $AUTOLOAD=~/(\w+)::(\w+?)_(.*)/;
  my ($class,$struct,$key)=($1,$2,$3);
  my $obj=shift;
  my $val;



( run in 2.077 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )