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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
package DBIShell::Gtk::conn;
use strict;
use Gtk;
use Gtk::Atoms;
use Gtk::Icon;
use DBIShell qw(:const);
use DBIShell::UTIL qw(:readmode TRUE FALSE);
use Gtk::Symbols (':func' ,
':gdk_win_type' ,
':gdk_ev_type' ,
':attach_opts' ,
);
use constant WINDOW_LABEL => 'connect';
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
@ISA = qw(DBIShell::Gtk);
@EXPORT = ();
@EXPORT_OK = ();
%EXPORT_TAGS = ();
$VERSION = 0.00_01;
sub panel ($;$)
{
my %conn;
my $y = 0;
my $sh = $_[0];
my $return = $_[1] || $sh->{OPT};
# my $label0 = Gtk::Label ->new( WINDOW_LABEL );
my $window = Gtk::Window->new( GDK_WIN_TYPE_TOPLEVEL );
# my $vbox_0 = Gtk::HBox ->new( FALSE, FALSE );
my $table0 = Gtk::Table ->new( 2, 1, FALSE );
$window->border_width ( 0 );
$window->set_policy ( TRUE, TRUE, TRUE );
$window->set_title ( WINDOW_LABEL . " 2 " );
$window->signal_connect( GDK_EV_TYPE_DESTROY, GTK__TRUE );
$window->signal_connect( GDK_EV_TYPE_DELETE, GTK__FALSE );
$table0->set_row_spacings( 2 );
$table0->set_col_spacings( 2 );
$table0->border_width ( 2 );
# $window->add( $vbox_0 );
# $vbox_0->pack_start( $table0, TRUE , TRUE , FALSE );
$table0->show();
$window->add( $table0 );
# $vbox_0->show();
$conn{driver} = Gtk::Combo->new();
CONN_OPT:
foreach ( DBI_OPT_SPEC )
{
my $name = $_->[ DBIOPT_NAME ];
my $prmt = $_->[ DBIOPT_PRMT ];
my $mode = $_->[ DBIOPT_MODE ];
$prmt =~ s/:.*/:/;
if( !$conn{$name} )
{
$conn{$name} = Gtk::Entry->new();
if( $mode == READMODE_NOECHO )
{
$conn{$name}->set_visibility( FALSE );
}
}
elsif( ref( $conn{$name} ) eq 'Gtk::Combo' )
{
if( $name ne 'driver' )
{
warn("Unknown option '$name'\n");
next CONN_OPT;
}
$conn{$name}->set_popdown_strings( DBI->available_drivers() );
}
else
{
warn("Unknown option '$name'\n");
next CONN_OPT;
}
my $label = Gtk::Label->new( $prmt );
$table0->resize( 2, $y + 1 );
$table0->attach( $label,
0, 1,
$y, $y + 1,
ATTACH_OPTS_SHRINK,
ATTACH_OPTS_SHRINK,
0, 0
);
$table0->attach( $conn{$name},
1, 2,
$y, $y + 1,
ATTACH_OPTS_SHRINK,
ATTACH_OPTS_SHRINK,
0, 0
);
$label ->show();
$conn{$name}->show();
$y++;
};
$window->show();
}
|