App-USBKeyCopyCon

 view release on metacpan or  search on metacpan

lib/App/USBKeyCopyCon.pm  view on Meta::CPAN

    my $vendor_combo = Gtk2::ComboBox->new_text;
    $vendor_combo->append_text('Exactly match vendor');
    $vendor_combo->append_text('Pattern match vendor');
    $vendor_combo->append_text('Match any vendor');
    $vendor_combo->set_active(VENDOR_EXACT);
    #$vendor_combo->signal_connect(changed => sub { $self->apply_filter(); });
    $box->pack_start($vendor_combo, FALSE, FALSE, 10);
    $self->vendor_combo($vendor_combo);

    my $vendor_entry = Gtk2::Entry->new;
    $vendor_entry->set_width_chars(11);
    $vendor_entry->set_text('');
    $box->pack_start($vendor_entry, FALSE, FALSE, 0);
    $self->vendor_entry($vendor_entry);

    my $capacity_combo = Gtk2::ComboBox->new_text;
    $capacity_combo->append_text('Exactly match capacity');
    $capacity_combo->append_text('Match minimum capacity');
    $capacity_combo->append_text('Match any capacity');
    $capacity_combo->set_active(CAPACITY_EXACT);
    #$capacity_combo->signal_connect(changed => sub { $self->apply_filter(); });
    $box->pack_start($capacity_combo, FALSE, FALSE, 10);
    $self->capacity_combo($capacity_combo);

    my $capacity_entry = Gtk2::Entry->new;
    $capacity_entry->set_width_chars(11);
    $capacity_entry->set_text('');
    $box->pack_start($capacity_entry, FALSE, FALSE, 0);
    $self->capacity_entry($capacity_entry);

    return $box;
}


sub disable_filter_inputs { shift->_set_filter_sensitive(FALSE) }
sub enable_filter_inputs  { shift->_set_filter_sensitive(TRUE)  }


sub _set_filter_sensitive {
    my($self, $state) = @_;

    $self->vendor_combo->set_sensitive($state);
    $self->vendor_entry->set_sensitive($state);
    $self->capacity_combo->set_sensitive($state);
    $self->capacity_entry->set_sensitive($state);
}


sub build_console {
    my $self = shift;

    my $scrolled_window = Gtk2::ScrolledWindow->new;
    $scrolled_window->set_policy('automatic', 'automatic');
    $scrolled_window->set_shadow_type('in');

    my $buffer = Gtk2::TextBuffer->new(undef);
    $buffer->delete($buffer->get_bounds);

    my $console = Gtk2::TextView->new_with_buffer($buffer);
    $console->set_editable(FALSE);
    $console->set_cursor_visible(FALSE);
    $console->set_wrap_mode('char');

    my $end_mark = $buffer->create_mark( 'end', $buffer->get_end_iter, FALSE);
    $buffer->signal_connect(
        insert_text => sub {
            $console->scroll_to_mark( $end_mark, 0.0, TRUE, 0.0, 0.0 );
        }
    );

    $self->console($console);

    $scrolled_window->add($console);

    return $scrolled_window;
}


sub say {
    my($self, $msg) = @_;

    my $console = $self->console;
    my $buffer = $console->get_buffer;
    my $end = $buffer->get_end_iter;
    $buffer->insert ($end, $msg);
}


sub play_sound_file {
    my($self, $sound_file) = @_;

    $sound_file ||= $self->selected_sound;

    if(-r $sound_file) {
        system("play $sound_file >/dev/null 2>&1 &");
    }
}


sub confirm_master_dialog {
    my($self, $key_info) = @_;

    my $dialog = Gtk2::Dialog->new(
        "USB Master Key",
        $self->app_win,
        [qw/modal destroy-with-parent/],
        'gtk-cancel'      => 'cancel',
        'Read Master Key' => 'ok',
    );
    $dialog->set_default_size (90, 80);

    my $table = Gtk2::Table->new(1, 3, FALSE);

    my @pack_opts = ( ['expand', 'fill'], ['expand', 'fill'], 4, 2);
    my $row = 0;

    my $v_label = Gtk2::Label->new;
    $v_label->set_markup('<b>Vendor:</b>');
    $v_label->set_alignment(0, 0.5);
    $table->attach($v_label, 0, 1, $row, $row + 1, @pack_opts);



( run in 1.726 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )