diff --git a/lib/CA.pm b/lib/CA.pm index f1f2407..b83121a 100644 --- a/lib/CA.pm +++ b/lib/CA.pm @@ -99,6 +99,7 @@ sub open_ca { my ($i, $cnf, @lines, $oldca, $index, $bak, $t); + main::printd("Opening ca $opts->{'name'}"); GUI::HELPERS::set_status($main, _(" Opening CA: ").$opts->{'name'}); while(Gtk2->events_pending) { Gtk2->main_iteration; diff --git a/lib/GUI.pm b/lib/GUI.pm index e8d07af..83bb4b2 100644 --- a/lib/GUI.pm +++ b/lib/GUI.pm @@ -60,6 +60,8 @@ sub new { bless($self, $class); + my ($section, $x, $y, $w, $h); + $self->{'version'} = '0.7.6'; $self->{'words'} = GUI::WORDS->new(); @@ -111,7 +113,16 @@ sub new { $self->{'mw'}->set_title("TinyCA2 Management $self->{'version'}"); $self->{'mw'}->set_resizable(1); - $self->{'mw'}->set_default_size(850, 600); + $section = $self->{'init'}->{'cfg'}->{window}; + if(defined($section->{x}) && defined($section->{y})) { + # save position for later use after show_all() + $self->{'posx'} = $section->{x}; + $self->{'posy'} = $section->{y}; + } + $w = $section->{w} // 850; + $h = $section->{h} // 600; + main::printd("Sizing window to $w,$h"); + $self->{'mw'}->set_default_size($w, $h); $self->{'mw'}->signal_connect( 'delete_event', sub { HELPERS::exit_clean(0) }); @@ -1350,7 +1361,15 @@ sub show_req_dialog { $reqtable->attach_defaults($label, 0, 1, 13, 14); $radiobox = Gtk2::HBox->new(0, 0); - _fill_radiobox($radiobox, \$opts->{'bits'}, %bit_lengths); + # use config if present + main::printd("preparing radiobox for type " . $self->{'CA'}->{'cfg'}->{global}{default_req_type}); + my $bits = \$opts->{'bits'}; + if ($self->{'CA'}->{'cfg'}->{global}{default_req_type} eq 'user') { + $bits = $self->{'CA'}->{'cfg'}->{user}{default_bits} // \$opts->{'bits'}; + } elsif ($self->{'CA'}->{'cfg'}->{global}{default_req_type} eq 'server') { + $bits = $self->{'CA'}->{'cfg'}->{server}{default_bits}// \$opts->{'bits'}; + } + _fill_radiobox($radiobox, \$bits, %bit_lengths); $reqtable->attach_defaults($radiobox, 1, 2, 13, 14); $label = GUI::HELPERS::create_label( diff --git a/lib/GUI/HELPERS.pm b/lib/GUI/HELPERS.pm index 4b4ba15..daddc53 100644 --- a/lib/GUI/HELPERS.pm +++ b/lib/GUI/HELPERS.pm @@ -477,7 +477,8 @@ This functions returns nothing; opens a FileChooser dialog to select files or directories. $entry is a reference to the variable, where the selected path shall be stored. If $mode -is set to "open", then only files with appropriate suffixes are displyed. +is set to "open" or "key", then only files with appropriate suffixes are +displyed. =back diff --git a/lib/GUI/TCONFIG.pm b/lib/GUI/TCONFIG.pm index 150e241..3584ea1 100644 --- a/lib/GUI/TCONFIG.pm +++ b/lib/GUI/TCONFIG.pm @@ -86,6 +86,11 @@ sub show_configbox { $box->add($box->{'vbox'}); + # Experts warning top label + $label = Gtk2::Label->new(); + $label->set_markup("" . _("Experts only!"). ""); + $box->{'vbox'}->pack_start($label, 1, 1, 8); + $box->{'vbox'}->pack_start($box->{'nb'}, 1, 1, 0); $buttonbox = Gtk2::HButtonBox->new(); diff --git a/lib/HELPERS.pm b/lib/HELPERS.pm index 8070949..d0df3dd 100644 --- a/lib/HELPERS.pm +++ b/lib/HELPERS.pm @@ -53,6 +53,34 @@ sub read_user_cfg { return ($cfg); } +sub update_user_cfg { + my $gui = shift; + my ($section); + my ($x, $y, $w, $h); + + ($x, $y) = $gui->{'mw'}->get_position(); + ($w, $h) = $gui->{'mw'}->get_size(); + + if(defined($gui->{'init'}->{'cfg'})) { + $section = $gui->{'init'}->{'cfg'}->{window}; + $section->{x} = $x; + $section->{y} = $y; + $section->{w} = $w; + $section->{h} = $h; + $gui->{'init'}->{'cfg'}->write($ENV{HOME}."/.tinycarc", 'utf8'); + } else { + # no user config yet, create new one + my $newcfg = Config::Tiny->new(); + $newcfg->{window} = { + x => $x, + y => $y, + w => $w, + h => $h + }; + $newcfg->write($ENV{HOME}."/.tinycarc", 'utf8'); + } +} + # # generate filename from Subject-DN # diff --git a/tinyca2 b/tinyca2 index 1b39b3d..692303b 100755 --- a/tinyca2 +++ b/tinyca2 @@ -100,11 +100,20 @@ if( exists $ENV{'TINYCA_EXPORTDIR'}) { umask(0077); +# read user config +$init->{'cfg'} = HELPERS::read_user_cfg(); +$init->{'debug'} = (($cfg->{global}->{debug} // '') eq 'true') ? 1 : 0; +printd('Debug mode enabled'); + # create main object and initialize CA my $gui = GUI->new($init); # and now run... $gui->{'mw'}->show_all(); +if(defined($gui->{'posx'}) && defined($gui->{'posy'})) { + printd("Moving window to $gui->{'posx'},$gui->{'posy'}"); + $gui->{'mw'}->move($gui->{'posx'}, $gui->{'posy'}); +} # decide what to do on startup if(@{$gui->{'CA'}->{'calist'}}) { @@ -119,7 +128,14 @@ sub _ { return($s); } +sub printd { + print STDERR "DEBUG: @_\n" if $init->{'debug'}; +} + Gtk2->main(); +HELPERS::update_user_cfg($gui); + +printd("normal exit in main"); exit(0);