Commit cd5fe234 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

fiji_scripts: connect design constant widgets correctly with FIJI::Settings instances

Fixes saving of design constants again.
parent 90e7eb1c
......@@ -104,6 +104,17 @@ BEGIN {
use constant \%fiumap;
use constant FIUMAP => \%fiumap;
sub ini2constkey {
my ($ini_name, $map_ref) = @_;
$map_ref = DESIGNMAP if !defined($map_ref);
foreach my $k (keys $map_ref) {
if ($ini_name eq $map_ref->{$k}->{'ini_name'}) {
return $k;
}
}
return undef;
}
use base 'Exporter';
# our @EXPORT = ();
......
......@@ -58,12 +58,37 @@ sub Populate {
#
sub update {
my $self = shift;
my $logger = get_logger();
################
# design panel #
################
# TODO
# Alternatively to below one could store the respective widgets separately.
# To limit the complexity elsewhere we jump though a few hoops here.
# 1. fetch the widgets comprising the GUI for the design constants
# 2. loop over the tuples that represent one constant each
# 3. fetch the internal constant name for the ini_name (stored in the first label)
# 4. set the reference to the value of that name within the current settings instance
# as textvariable of the respective widget.
my @design_widgets = ${${$fr_design->children}[0]->children}[1]->children;
my $const_cnt = @design_widgets;
for (my $i = 3; $i < $const_cnt; $i += 3) {
my ($namew, $unitw, $valw) = @design_widgets[$i..$i+3];
my $name = $namew->cget('-text');
my $k = FIJI::ini2constkey($name);
if (!defined($k)) {
my $msg = "Could not find FIJI definition for constant named \"$name\"";
$logger->error($msg);
$self->Dialog(
'-title' => 'Something went horribly wrong!',
'-text' => "$msg\n",
)->Show();
return;
}
$logger->trace("Connect widget ($name) with new settings instance hash ($k)");
$valw->configure('-textvariable' => \${$self->{'settings'}}->{'design'}->{$k});
}
##############
# FIUs panel #
......@@ -110,7 +135,6 @@ sub update {
my $fiu_ref = @{${$self->{'settings'}}->{'FIUs'}}[$i];
$self->_add_fiu($fiu_ref, $i);
}
}
......@@ -221,6 +245,7 @@ sub _add_fiu_panel {
$self->_add_fiu_frame($fr_fius_scroll);
}
sub _add_fiu_frame {
my($self, $parent) = @_;
$fr_fius = $parent->Frame()->pack(
......@@ -377,7 +402,6 @@ sub _set_fields_by_button {
sub _set_fields {
my($self, $bool, @fields) = @_;
my $logger = get_logger();
$logger->trace("toggling some fields to $bool");
foreach my $f (@fields) {
if ($bool) {
$f->configure('-state' => 'normal');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment