| 1 |
# -*- cperl -*- |
| 2 |
## This file is part of Artemis, copyright (c) 2002-2006 Bruce Ravel |
| 3 |
## |
| 4 |
|
| 5 |
###=================================================================== |
| 6 |
### preferences subsystem |
| 7 |
###=================================================================== |
| 8 |
|
| 9 |
sub prefs { |
| 10 |
|
| 11 |
my %prefs_params = (); |
| 12 |
&read_config(\%prefs_params); |
| 13 |
|
| 14 |
#$Data::Dumper::Indent = 2; |
| 15 |
#print Data::Dumper->Dump([\%prefs_params], [qw/prefs_params/]); |
| 16 |
#$Data::Dumper::Indent = 0; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
map {$_ -> configure(-state=>'disabled')} |
| 21 |
($gsd_menu, $feff_menu, $paths_menu, $data_menu, $sum_menu, $fit_menu); #, $settings_menu); |
| 22 |
$edit_menu -> menu -> entryconfigure(13, -state=>'disabled'); |
| 23 |
SWITCH: { |
| 24 |
$opparams -> packForget(), last SWITCH if ($current_canvas eq 'op'); |
| 25 |
$gsd -> packForget(), last SWITCH if ($current_canvas eq 'gsd'); |
| 26 |
$feff -> packForget(), last SWITCH if ($current_canvas eq 'feff'); |
| 27 |
$path -> packForget(), last SWITCH if ($current_canvas eq 'path'); |
| 28 |
$logviewer -> packForget(), last SWITCH if ($current_canvas eq 'logview'); |
| 29 |
}; |
| 30 |
$current_canvas = 'prefs'; |
| 31 |
|
| 32 |
my $prefs = $fat -> Frame(-relief=>'flat', |
| 33 |
-borderwidth=>0, |
| 34 |
-highlightcolor=>$config{colors}{background}) |
| 35 |
-> pack(-expand=>1, -fill=>'both'); |
| 36 |
|
| 37 |
|
| 38 |
$prefs_params{save} = 0; |
| 39 |
$prefs -> Label(-text => "Edit Preferences", |
| 40 |
@title2, |
| 41 |
-background => $config{colors}{background2}, |
| 42 |
-borderwidth => 2, |
| 43 |
-relief => 'groove', |
| 44 |
-anchor => 'center') |
| 45 |
-> pack(-side=>'top', -anchor=>'w', -padx=>0, -fill=>'x'); |
| 46 |
|
| 47 |
|
| 48 |
my $labframe = $prefs -> LabFrame(-label=>'All parameters', |
| 49 |
-labelside=>'acrosstop') |
| 50 |
-> pack(-side=>'left', -expand=>1, -fill=>'both'); |
| 51 |
my $tree; |
| 52 |
$tree = $labframe -> Scrolled('Tree', -scrollbars=>'se', -width=>15, |
| 53 |
-background=>'white', |
| 54 |
-browsecmd=>sub{&browse_variable($tree, \%prefs_params)}, |
| 55 |
) |
| 56 |
-> pack(-expand=>1, -fill=>'both'); |
| 57 |
$tree->Subwidget("xscrollbar")->configure(-background=>$config{colors}{background}); |
| 58 |
$tree->Subwidget("yscrollbar")->configure(-background=>$config{colors}{background}); |
| 59 |
|
| 60 |
$prefs -> Button(-text=>'Return to the main window', @button3_list, |
| 61 |
#-background=>$config{colors}{background}, |
| 62 |
#-activebackground=>$config{colors}{activebackground}, |
| 63 |
-command=>sub{ |
| 64 |
my $response = 'No'; |
| 65 |
if ($prefs_params{save}) { |
| 66 |
my $message = ($prefs_params{save} eq -1) ? |
| 67 |
"You have applied the preferences, but have not saved them for future sessions. Would you like to save your new preference selections?" : |
| 68 |
"Would you like to apply and save your new preference selections?"; |
| 69 |
my $dialog = |
| 70 |
$top -> Dialog(-bitmap => 'questhead', |
| 71 |
-text => $message, |
| 72 |
-title => 'Artemis: preferences...', |
| 73 |
-buttons => [qw/Yes No/], |
| 74 |
-default_button => 'Yes', |
| 75 |
-font => $config{fonts}{med}, |
| 76 |
-popover => 'cursor'); |
| 77 |
&posted_Dialog; |
| 78 |
$response = $dialog->Show(); |
| 79 |
} |
| 80 |
if ($response eq 'Yes') { |
| 81 |
&prefs_apply(\%prefs_params); |
| 82 |
&prefs_save(\%prefs_params); |
| 83 |
}; |
| 84 |
Echo("Your preferences were applied and saved to $personal_rcfile") |
| 85 |
if ($response eq 'Yes'); |
| 86 |
$prefs->packForget; |
| 87 |
$current_canvas = ""; |
| 88 |
$edit_menu -> menu -> entryconfigure(13, -state=>'normal'); |
| 89 |
&display_properties; |
| 90 |
Echo("Restored normal view") unless ($response eq 'Yes'); |
| 91 |
}) |
| 92 |
-> pack(-side=>'bottom', -fill=>'x'); |
| 93 |
$prefs_params{future} = $prefs -> Button(-text=>'Save changes for future sessions', @button2_list, |
| 94 |
-state=>'disabled', |
| 95 |
-command=>sub{ |
| 96 |
&prefs_apply(\%prefs_params); |
| 97 |
&prefs_save(\%prefs_params); |
| 98 |
$prefs_params{apply} ->configure(-state=>'disabled'); |
| 99 |
$prefs_params{future}->configure(-state=>'disabled'); |
| 100 |
} ) |
| 101 |
-> pack(-side=>'bottom', -fill=>'x'); |
| 102 |
$prefs_params{apply} = $prefs -> Button(-text=>'Apply changes to this session', @button2_list, |
| 103 |
-state=>'disabled', |
| 104 |
-command=>sub{ |
| 105 |
&prefs_apply(\%prefs_params); |
| 106 |
$prefs_params{apply} ->configure(-state=>'disabled'); |
| 107 |
} ) |
| 108 |
-> pack(-side=>'bottom', -fill=>'x'); |
| 109 |
## need a restore all values button |
| 110 |
|
| 111 |
|
| 112 |
my $frame = $prefs -> Frame(-relief=>'flat') |
| 113 |
-> pack(-side=>'right');#, -fill=>'both'); |
| 114 |
|
| 115 |
my $subfr = $frame -> Frame() |
| 116 |
-> pack(-side=>'top'); |
| 117 |
$prefs_params{parameter_label} = $subfr -> Label(-text=>'Parameter: ', |
| 118 |
-justify=>'right', |
| 119 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 120 |
-> grid(-row=>0, -column=>0, -sticky=>'e'); |
| 121 |
$prefs_params{parameter} = $subfr -> Label(-text=>'', -justify=>'left') |
| 122 |
-> grid(-row=>0, -column=>1, -sticky=>'ew'); |
| 123 |
$subfr -> Label(-text=>'Type: ', |
| 124 |
-justify=>'right', |
| 125 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 126 |
-> grid(-row=>1, -column=>0, -sticky=>'e'); |
| 127 |
$prefs_params{type} = $subfr -> Label(-text=>'', -width=>15, -justify=>'left') |
| 128 |
-> grid(-row=>1, -column=>1, -sticky=>'ew'); |
| 129 |
$subfr -> Label(-text=>"Artemis' Default: ", |
| 130 |
-justify=>'right', |
| 131 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 132 |
-> grid(-row=>2, -column=>0, -sticky=>'e'); |
| 133 |
$prefs_params{default} = $subfr -> Label(-text=>'', -justify=>'left') |
| 134 |
-> grid(-row=>2, -column=>1, -sticky=>'ew'); |
| 135 |
$subfr -> Label(-text=>'Value: ', |
| 136 |
-justify=>'right', |
| 137 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 138 |
-> grid(-row=>3, -column=>0, -sticky=>'e'); |
| 139 |
$prefs_params{values} = $subfr -> Label(-text=>'', -justify=>'left') |
| 140 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 141 |
|
| 142 |
|
| 143 |
$frame -> Button(-text=>"Set ALL parameters to Artemis' defaults", @button2_list, |
| 144 |
-command=>[\&prefs_restore_all, \%prefs_params, $tree]) |
| 145 |
-> pack(-side=>'bottom', -expand=>1, -fill=>'x', -padx=>4, -pady=>4); |
| 146 |
|
| 147 |
$labframe = $frame -> LabFrame(-label=>'Description', -labelside=>'acrosstop') |
| 148 |
-> pack(-side=>'top', -expand=>1, -fill=>'both'); |
| 149 |
$prefs_params{description} = $labframe -> Scrolled('ROText', -scrollbars=>'oe', |
| 150 |
-wrap=>'word', |
| 151 |
#-width=>35, -height=>15 |
| 152 |
) |
| 153 |
-> pack(-expand=>1, -fill=>'both'); |
| 154 |
$prefs_params{description}->Subwidget("yscrollbar")->configure(-background=>$config{colors}{background}); |
| 155 |
&disable_mouse3($prefs_params{description}->Subwidget('rotext')); |
| 156 |
$prefs_params{description} -> tagConfigure('descr', -rmargin=>2, -spacing1=>1, |
| 157 |
-lmargin1=>2, -lmargin2=>2,); |
| 158 |
$prefs_params{description} -> tagConfigure('warn', -rmargin=>2, -spacing1=>1, |
| 159 |
-lmargin1=>2, -lmargin2=>2, |
| 160 |
-foreground=>'red3',); |
| 161 |
$prefs_params{description} -> tagConfigure('units', -rmargin=>2, -spacing1=>1, |
| 162 |
-lmargin1=>2, -lmargin2=>2, |
| 163 |
-foreground=>'green4',); |
| 164 |
$prefs_params{description} -> tagConfigure('restart', -rmargin=>2, -spacing1=>1, |
| 165 |
-lmargin1=>2, -lmargin2=>2, |
| 166 |
-foreground=>'darkviolet',); |
| 167 |
|
| 168 |
foreach my $s (@{$prefs_params{order}}) { |
| 169 |
##next if (($s eq 'Histogram') and ($use_histo)); |
| 170 |
$tree -> add($s, -text=>$s); |
| 171 |
foreach my $v (@{$prefs_params{$s}{order}}) { |
| 172 |
my $this = $s.".".$v; |
| 173 |
$tree -> add($this, -text=>$v); |
| 174 |
$tree -> setmode($this, 'none'); |
| 175 |
$prefs_params{$s}{$v}{new} = $config{$s}{$v}; |
| 176 |
}; |
| 177 |
$tree -> setmode($s, 'close'); |
| 178 |
$tree -> close($s); |
| 179 |
}; |
| 180 |
$tree->autosetmode(); |
| 181 |
|
| 182 |
##Echo("Showing preferences dialog"); |
| 183 |
$top -> update; |
| 184 |
}; |
| 185 |
|
| 186 |
|
| 187 |
sub browse_variable { |
| 188 |
my ($tree, $rhash) = @_; |
| 189 |
my $this = $tree->infoAnchor; |
| 190 |
return unless $this; |
| 191 |
my ($s, $v) = split(/\./, $this); |
| 192 |
|
| 193 |
my $frame = $$rhash{values}->parent; |
| 194 |
return unless $s; |
| 195 |
unless ($v) { |
| 196 |
$$rhash{parameter_label} -> configure(-text=>"Section: "); |
| 197 |
$$rhash{parameter} -> configure(-text=>$s); |
| 198 |
$$rhash{type} -> configure(-text=>""); |
| 199 |
$$rhash{default} -> configure(-text=>""); |
| 200 |
$$rhash{description} -> delete(qw(1.0 end)); |
| 201 |
$$rhash{description} -> insert('end', $$rhash{$s}{description}, 'descr'); |
| 202 |
$$rhash{default} -> gridForget(); |
| 203 |
$$rhash{default} = $frame -> Label(-text=>'', -justify=>'left') |
| 204 |
-> grid(-row=>2, -column=>1, -sticky=>'ew'); |
| 205 |
$$rhash{values} -> gridForget(); |
| 206 |
$$rhash{values} = $frame -> Label(-text=>'',) |
| 207 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 208 |
return; |
| 209 |
}; |
| 210 |
|
| 211 |
$$rhash{parameter_label} -> configure(-text=>"Parameter: "); |
| 212 |
$$rhash{parameter} -> configure(-text=>$v); |
| 213 |
$$rhash{type} -> configure(-text=>$$rhash{$s}{$v}{type}); |
| 214 |
$$rhash{default} -> gridForget(); |
| 215 |
$$rhash{default} = $frame -> Button(-text=>"", -borderwidth=>1, |
| 216 |
-command=>sub{ |
| 217 |
## restore the default value |
| 218 |
$$rhash{$s}{$v}{new} = $$rhash{$s}{$v}{default}; |
| 219 |
$$rhash{$s}{$v}{new} = $$rhash{$s}{$v}{windows} |
| 220 |
if (exists $$rhash{$s}{$v}{windows} and $is_windows); |
| 221 |
if ($$rhash{$s}{$v}{type} eq 'boolean') { |
| 222 |
$$rhash{$s}{$v}{new} = ($$rhash{$s}{$v}{new} eq 'true') ? $$rhash{$s}{$v}{onvalue} : 0; |
| 223 |
}; |
| 224 |
$$rhash{save} = 1; |
| 225 |
$$rhash{apply} ->configure(-state=>'normal'); |
| 226 |
$$rhash{future}->configure(-state=>'normal'); |
| 227 |
## and make sure it is displayed properly |
| 228 |
$tree -> KeyboardBrowse; |
| 229 |
}) |
| 230 |
-> grid(-row=>2, -column=>1, -sticky=>'ew'); |
| 231 |
|
| 232 |
my ($small, $med) = ($config{fonts}{small}, $config{fonts}{med}); |
| 233 |
$$rhash{default} -> configure(-font=>($$rhash{$s}{$v}{type} eq 'folder') ? |
| 234 |
$small : $med); |
| 235 |
if (exists $$rhash{$s}{$v}{windows} and $is_windows) { |
| 236 |
$$rhash{default} -> configure(-text=>$$rhash{$s}{$v}{windows}); |
| 237 |
} else { |
| 238 |
$$rhash{default} -> configure(-text=>$$rhash{$s}{$v}{default}); |
| 239 |
}; |
| 240 |
if ($$rhash{$s}{$v}{type} eq 'folder') { |
| 241 |
my $text = $$rhash{default} -> cget('-text'); |
| 242 |
($text = substr($text, 0, 7) . "..." . substr($text, -7)) if (length($text) > 15); |
| 243 |
$$rhash{default} -> configure(-text=>$text); |
| 244 |
}; |
| 245 |
|
| 246 |
#$$rhash{parameter} -> configure(-text=>$v); |
| 247 |
$$rhash{description} -> delete(qw(1.0 end)); |
| 248 |
$$rhash{description} -> insert('end', $$rhash{$s}{$v}{description}, 'descr'); |
| 249 |
if (($s eq 'fonts') or ($$rhash{$s}{$v}{type} eq 'font')) { |
| 250 |
my $rcfile = $setup -> find('artemis', 'rc_personal'); |
| 251 |
$$rhash{description} -> insert('end', "\n\nFonts cannot currently be changed interactively. You will need to edit $rcfile by hand.", 'warn'); |
| 252 |
##} elsif (($s eq 'gds') and ($$rhash{$s}{$v}{type} eq 'color')) { |
| 253 |
## $$rhash{description} -> insert('end', "\n\nColor changes on the parameters page will take effect the next time you start Artemis.", 'warn'); |
| 254 |
} elsif ($$rhash{$s}{$v}{type} eq 'color') { |
| 255 |
$$rhash{description} -> insert('end', "\n\nPress the colored \"Value\" button to change this color.", 'descr'); |
| 256 |
} elsif ($$rhash{$s}{$v}{type} eq 'regex') { |
| 257 |
$$rhash{description} -> insert('end', "\n\nThis parameter must be a valid Perl regular expression if the match_as parameter is set to \"perl\".", 'warn'); |
| 258 |
}; |
| 259 |
|
| 260 |
$$rhash{description} -> insert('end', "\n\nColor changes do not currently take effect until the next time Artemis is started. That will eventually be fixed.", 'descr') |
| 261 |
if ($s eq 'colors'); |
| 262 |
|
| 263 |
if (($s eq 'general') and ($v eq 'workspace')) { |
| 264 |
$$rhash{description} -> insert('end', "\n\nThe current project will be deleted when you change this parameter. If you want to change this parameter, you should first return to the main menu and save your current project.\n", 'warn'); |
| 265 |
$$rhash{description} -> insert('end', "\n\nThe fully resolved path is currently\n$$rhash{$s}{$v}{new}", 'descr'); |
| 266 |
}; |
| 267 |
$$rhash{description} -> insert('end', "\n\nThe units of this parameter are $$rhash{$s}{$v}{units}", 'units') |
| 268 |
if (exists $$rhash{$s}{$v}{units}); |
| 269 |
$$rhash{description} -> insert('end', "\n\nYou must restart Artemis to see the effect of changing this parameter.", 'restart') |
| 270 |
if (exists $$rhash{$s}{$v}{restart} and (not (($s eq 'fonts') or ($$rhash{$s}{$v}{type} eq 'font')))); |
| 271 |
|
| 272 |
$$rhash{description} -> insert('end', "\n\nPress the \"Default\" button to restore Artemis' default value for this variable.", 'descr'); |
| 273 |
|
| 274 |
$$rhash{values} -> gridForget(); |
| 275 |
SWITCH: { |
| 276 |
|
| 277 |
($$rhash{$s}{$v}{type} eq 'string') and do { |
| 278 |
$$rhash{values} = $frame -> Entry(-width=>12, -validate=>'key', |
| 279 |
-validatecommand=>[\&prefs_string, join(".", $s,$v), $rhash]) |
| 280 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 281 |
$$rhash{values} -> configure(-validate=>'none'); |
| 282 |
$$rhash{values} -> insert('end', $$rhash{$s}{$v}{new}); |
| 283 |
$$rhash{values} -> configure(-validate=>'key'); |
| 284 |
last SWITCH; |
| 285 |
}; |
| 286 |
|
| 287 |
($$rhash{$s}{$v}{type} eq 'regex') and do { |
| 288 |
$$rhash{values} = $frame -> Entry(-width=>12, -validate=>'key', |
| 289 |
-validatecommand=>[\&prefs_string, join(".", $s,$v), $rhash]) |
| 290 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 291 |
$$rhash{values} -> configure(-validate=>'none'); |
| 292 |
$$rhash{values} -> insert('end', $$rhash{$s}{$v}{new}); |
| 293 |
$$rhash{values} -> configure(-validate=>'key'); |
| 294 |
last SWITCH; |
| 295 |
}; |
| 296 |
|
| 297 |
($$rhash{$s}{$v}{type} eq 'folder') and do { |
| 298 |
my $text = $$rhash{$s}{$v}{new}; |
| 299 |
($text = substr($text, 0, 7) . "..." . substr($text, -7)) if (length($text) > 15); |
| 300 |
$$rhash{values} = $frame -> Button(-foreground=>'black', |
| 301 |
-borderwidth=>1, |
| 302 |
-text=>$text, |
| 303 |
-font=>$config{fonts}{small}, |
| 304 |
-command=> |
| 305 |
sub{ |
| 306 |
my $dir; |
| 307 |
if ($Tk::VERSION < 804) { |
| 308 |
$top -> Dialog(-bitmap => 'error', |
| 309 |
-text => "Changing folders using this dialog requires perl/Tk 804. You are using perl/Tk $Tk::VERSION.", |
| 310 |
-title => 'Artemis: Unable to change folders', |
| 311 |
-buttons => ['OK'], |
| 312 |
-font => $config{fonts}{med}, |
| 313 |
-default_button => "OK", ) |
| 314 |
-> Show(); |
| 315 |
return; |
| 316 |
# $dir = $top -> DirSelect(-width=>40, -dir=>$$rhash{$s}{$v}{new}, |
| 317 |
# -title=> "Artemis: Select a directory", |
| 318 |
# -text => "Select the path to your workspace", |
| 319 |
# ) -> Show; |
| 320 |
} else { |
| 321 |
$dir = $top -> chooseDirectory; |
| 322 |
}; |
| 323 |
return unless ($dir and (-d $dir)); |
| 324 |
$$rhash{$s}{$v}{new}=$dir; |
| 325 |
($dir = substr($dir, 0, 7) . "..." . substr($dir, -7)) if (length($dir) > 15); |
| 326 |
$$rhash{values}->configure(-text=>$dir); |
| 327 |
$$rhash{save} = 1; |
| 328 |
$$rhash{apply} ->configure(-state=>'normal'); |
| 329 |
$$rhash{future}->configure(-state=>'normal'); |
| 330 |
}) |
| 331 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 332 |
last SWITCH; |
| 333 |
}; |
| 334 |
|
| 335 |
($$rhash{$s}{$v}{type} eq 'file') and do { |
| 336 |
my $text = $$rhash{$s}{$v}{new}; |
| 337 |
($text = substr($text, 0, 7) . "..." . substr($text, -7)) if (length($text) > 15); |
| 338 |
$$rhash{values} = $frame -> Button(-foreground=>'black', |
| 339 |
-borderwidth=>1, |
| 340 |
-text=>$text, |
| 341 |
-font=>$config{fonts}{small}, |
| 342 |
-command=> |
| 343 |
sub { |
| 344 |
my $path = $current_data_dir || cwd; |
| 345 |
my $types = [['Executables', '*.exe'], ['All files', '*'],]; |
| 346 |
my $file = $top -> |
| 347 |
getOpenFile(-filetypes => $types, |
| 348 |
##(not $is_windows) ? |
| 349 |
## (-sortcmd=>sub{$Tk::FBox::a cmp $Tk::FBox::b}) : () , |
| 350 |
-multiple => 0, |
| 351 |
-initialdir =>$path, |
| 352 |
-title => "Artemis: Select Feff executable"); |
| 353 |
return unless ($file and (-e $file)); |
| 354 |
$$rhash{$s}{$v}{new}=$file; |
| 355 |
($file = substr($file, 0, 7) . "..." . substr($file, -7)) if (length($file) > 15); |
| 356 |
$$rhash{values}->configure(-text=>$file); |
| 357 |
$$rhash{save} = 1; |
| 358 |
$$rhash{apply} ->configure(-state=>'normal'); |
| 359 |
$$rhash{future}->configure(-state=>'normal'); |
| 360 |
}) |
| 361 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 362 |
}; |
| 363 |
|
| 364 |
($$rhash{$s}{$v}{type} eq 'real') and do { |
| 365 |
$$rhash{values} = $frame -> Entry(-width=>12, -validate=>'key', |
| 366 |
-validatecommand=>[\&prefs_real, join(".", $s,$v), $rhash]) |
| 367 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 368 |
$$rhash{values} -> configure(-validate=>'none'); |
| 369 |
$$rhash{values} -> insert('end', $$rhash{$s}{$v}{new}); |
| 370 |
$$rhash{values} -> configure(-validate=>'key'); |
| 371 |
last SWITCH; |
| 372 |
}; |
| 373 |
|
| 374 |
## need to set the save flag |
| 375 |
($$rhash{$s}{$v}{type} eq 'positive integer') and do { |
| 376 |
$$rhash{values} = $frame -> NumEntry(-width=>4, |
| 377 |
-orient=>'horizontal', |
| 378 |
-foreground=>$config{colors}{foreground}, |
| 379 |
-textvariable=>\$$rhash{$s}{$v}{new}, |
| 380 |
-minvalue=>$$rhash{$s}{$v}{minint}||0, |
| 381 |
-maxvalue=>$$rhash{$s}{$v}{maxint}, |
| 382 |
) |
| 383 |
-> grid(-row=>3, -column=>1, -sticky=>'w'); |
| 384 |
$$rhash{values} -> configure( -value=>$$rhash{$s}{$v}{new}); |
| 385 |
## crufty solution to the lack of a callback for NumEntry |
| 386 |
$$rhash{apply} -> configure(-state=>'normal'); |
| 387 |
$$rhash{future} -> configure(-state=>'normal'); |
| 388 |
last SWITCH; |
| 389 |
}; |
| 390 |
|
| 391 |
($$rhash{$s}{$v}{type} eq 'integer') and do { |
| 392 |
$$rhash{values} = $frame -> NumEntry(-width=>4, |
| 393 |
-orient=>'horizontal', |
| 394 |
-foreground=>$config{colors}{foreground}, |
| 395 |
-textvariable=>\$$rhash{$s}{$v}{new}, |
| 396 |
-minvalue=>$$rhash{$s}{$v}{minint}, |
| 397 |
-maxvalue=>$$rhash{$s}{$v}{maxint}, |
| 398 |
) |
| 399 |
-> grid(-row=>3, -column=>1, -sticky=>'w'); |
| 400 |
$$rhash{values} -> configure( -value=>$$rhash{$s}{$v}{new}); |
| 401 |
## crufty solution to the lack of a callback for NumEntry |
| 402 |
$$rhash{apply} -> configure(-state=>'normal'); |
| 403 |
$$rhash{future} -> configure(-state=>'normal'); |
| 404 |
last SWITCH; |
| 405 |
}; |
| 406 |
|
| 407 |
($$rhash{$s}{$v}{type} eq 'list') and do { |
| 408 |
my @vals = split(" ", $$rhash{$s}{$v}{values}); |
| 409 |
$$rhash{values} = $frame -> Optionmenu(-font=>$config{fonts}{med}, |
| 410 |
-borderwidth=>1, |
| 411 |
-textvariable=>\$$rhash{$s}{$v}{new} |
| 412 |
) |
| 413 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 414 |
foreach my $vl (@vals) { |
| 415 |
$$rhash{values} -> command(-label => $vl, |
| 416 |
-command=>sub{$$rhash{$s}{$v}{new}=$vl; |
| 417 |
$$rhash{save} = 1; |
| 418 |
$$rhash{apply} ->configure(-state=>'normal'); |
| 419 |
$$rhash{future}->configure(-state=>'normal'); |
| 420 |
} ); |
| 421 |
}; |
| 422 |
last SWITCH; |
| 423 |
}; |
| 424 |
|
| 425 |
($$rhash{$s}{$v}{type} eq 'atp') and do { |
| 426 |
my $atpdir = $paths{data0} -> find('atoms', 'atp_personal'); |
| 427 |
opendir A, $atpdir; |
| 428 |
my @use = (); |
| 429 |
|
| 430 |
my @personal = grep {/atp$/} readdir A; |
| 431 |
closedir A; |
| 432 |
@personal = map {s/\.atp$//; $_} @personal; |
| 433 |
foreach (@personal) { |
| 434 |
local $/ = undef; |
| 435 |
my $this = $_ . ".atp"; |
| 436 |
next unless open F, File::Spec->catfile($atpdir, $this); |
| 437 |
my $snarf = <F>; |
| 438 |
close F; |
| 439 |
push @use, $_ if ($snarf =~ /meta.*:feff/); |
| 440 |
}; |
| 441 |
|
| 442 |
opendir S, $Xray::Atoms::atp_dir; |
| 443 |
my @system = grep {/atp$/} readdir S; |
| 444 |
closedir S; |
| 445 |
@system = map {s/\.atp$//; $_} @system; |
| 446 |
foreach (@system) { |
| 447 |
local $/ = undef; |
| 448 |
my $this = $_ . ".atp"; |
| 449 |
next unless open F, File::Spec->catfile($Xray::Atoms::atp_dir, $this); |
| 450 |
my $snarf = <F>; |
| 451 |
close F; |
| 452 |
push @use, $_ if ($snarf =~ /meta.*:feff/); |
| 453 |
}; |
| 454 |
|
| 455 |
## see Perl Cookbook, recipe 4.6; |
| 456 |
my %seen = (); |
| 457 |
foreach my $item (@use) { |
| 458 |
$seen{$item}++; |
| 459 |
}; |
| 460 |
my @vals = sort(keys %seen); |
| 461 |
|
| 462 |
$$rhash{values} = $frame -> Optionmenu(-font=>$config{fonts}{med}, |
| 463 |
-borderwidth=>1, |
| 464 |
-textvariable=>\$$rhash{$s}{$v}{new} |
| 465 |
) |
| 466 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 467 |
foreach my $vl (@vals) { |
| 468 |
$$rhash{values} -> command(-label => $vl, |
| 469 |
-command=>sub{$$rhash{$s}{$v}{new}=$vl; |
| 470 |
$$rhash{save} = 1; |
| 471 |
$$rhash{apply} ->configure(-state=>'normal'); |
| 472 |
$$rhash{future}->configure(-state=>'normal'); |
| 473 |
} ); |
| 474 |
}; |
| 475 |
last SWITCH; |
| 476 |
}; |
| 477 |
|
| 478 |
($$rhash{$s}{$v}{type} eq 'boolean') and do { |
| 479 |
$$rhash{values} = $frame -> Checkbutton(-text=>$v, |
| 480 |
-onvalue=>$$rhash{$s}{$v}{onvalue}, |
| 481 |
-offvalue=>$$rhash{$s}{$v}{offvalue}||0, |
| 482 |
-selectcolor=> $config{colors}{check}, |
| 483 |
-variable=>\$$rhash{$s}{$v}{new}, |
| 484 |
-command=> |
| 485 |
sub{ |
| 486 |
$$rhash{apply} ->configure(-state=>'normal'); |
| 487 |
$$rhash{future}->configure(-state=>'normal'); |
| 488 |
$$rhash{save} = 1; |
| 489 |
}) |
| 490 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 491 |
last SWITCH; |
| 492 |
}; |
| 493 |
($$rhash{$s}{$v}{type} eq 'color') and do { |
| 494 |
my $color = $$rhash{$s}{$v}{new} || 'black'; |
| 495 |
my ($r, $g, $b) = $frame -> rgb($color); |
| 496 |
my $acolor = sprintf("#%4.4x%4.4x%4.4x", int($r*0.85), int($g*0.85), int($b*0.85)); |
| 497 |
($acolor = "#300030003000") if ($acolor eq "#000000000000"); |
| 498 |
$$rhash{values} = $frame -> Button(-background=>$color, |
| 499 |
-activebackground=>$acolor, |
| 500 |
-borderwidth=>1, |
| 501 |
-command=>sub{ |
| 502 |
my $color = ""; |
| 503 |
#$top->Busy(); |
| 504 |
$color = $$rhash{values}->chooseColor(-initialcolor=>$$rhash{$s}{$v}{new}); |
| 505 |
#$top->Unbusy; |
| 506 |
return unless defined($color); |
| 507 |
$$rhash{values}->configure(-background=>$color, |
| 508 |
-activebackground=>$color); |
| 509 |
$$rhash{$s}{$v}{new}=$color; |
| 510 |
$$rhash{save} = 1; |
| 511 |
$$rhash{apply} ->configure(-state=>'normal'); |
| 512 |
$$rhash{future}->configure(-state=>'normal'); |
| 513 |
}) |
| 514 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 515 |
last SWITCH; |
| 516 |
}; |
| 517 |
|
| 518 |
($$rhash{$s}{$v}{type} eq 'font') and do { |
| 519 |
$$rhash{values} = $frame -> Button(-foreground=>'black', |
| 520 |
-borderwidth=>1, |
| 521 |
-text=>'abc ABC 123', |
| 522 |
-font=>$$rhash{$s}{$v}{new}, |
| 523 |
-command=>sub{Error("Changing fonts interactively is not yet supported. You can edit ".$setup -> find('artemis', 'rc_personal')." by hand.")}) |
| 524 |
-> grid(-row=>3, -column=>1, -sticky=>'ew'); |
| 525 |
last SWITCH; |
| 526 |
}; |
| 527 |
|
| 528 |
}; |
| 529 |
}; |
| 530 |
|
| 531 |
|
| 532 |
## validate command for a string type variable (no restrictions) |
| 533 |
sub prefs_string { |
| 534 |
my ($k, $hash, $entry) = (shift, shift, shift); |
| 535 |
my ($s, $v) = split(/\./, $k); |
| 536 |
$$hash{$s}{$v}{new} = $entry; |
| 537 |
$$hash{save} = 1; |
| 538 |
$$hash{apply} ->configure(-state=>'normal'); |
| 539 |
$$hash{future}->configure(-state=>'normal'); |
| 540 |
#print join(" ", ">>>", $s, $v, $$hash{save}, $$hash{$s}{$v}, $/); |
| 541 |
return 1; |
| 542 |
}; |
| 543 |
|
| 544 |
## validate command for a real type variable (must be a +/-real) |
| 545 |
sub prefs_real { |
| 546 |
my ($k, $hash, $entry) = (shift, shift, shift); |
| 547 |
my ($s, $v) = split(/\./, $k); |
| 548 |
#print join(" ", $s, $v, $entry, $hash, $/); |
| 549 |
($entry =~ /^\s*$/) and ($entry = 0); # error checking ... |
| 550 |
($entry =~ /^\s*-$/) and return 1; # error checking ... |
| 551 |
($entry =~ /^\s*-?(\d+\.?\d*|\.\d+)\s*$/) or return 0; |
| 552 |
$$hash{$s}{$v}{new} = $entry; |
| 553 |
$$hash{save} = 1; |
| 554 |
$$hash{apply} ->configure(-state=>'normal'); |
| 555 |
$$hash{future}->configure(-state=>'normal'); |
| 556 |
#print join(" ", ">>>", $s, $v, $$hash{save}, $$hash{$s}{$v}, $/); |
| 557 |
return 1; |
| 558 |
}; |
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
sub prefs_restore_all { |
| 563 |
my ($rhash, $tree) = @_; |
| 564 |
|
| 565 |
my $message = "Are you sure that you wish to restore ALL the default values, overwriting any configuration you may have already made to Artemis? Doing so will only restore them within this dialog. You will then need to click the buttons below to apply or save the default values."; |
| 566 |
my $dialog = |
| 567 |
$top -> Dialog(-bitmap => 'questhead', |
| 568 |
-text => $message, |
| 569 |
-title => 'Artemis: preferences...', |
| 570 |
-buttons => [qw/Yes No/], |
| 571 |
-default_button => 'Yes', |
| 572 |
-font => $config{fonts}{med}, |
| 573 |
-popover => 'cursor'); |
| 574 |
&posted_Dialog; |
| 575 |
my $response = $dialog->Show(); |
| 576 |
unless ($response eq 'Yes') { |
| 577 |
Echo("Not restoring defaults for preferences."); |
| 578 |
return; |
| 579 |
}; |
| 580 |
foreach my $s (@{$$rhash{order}}) { |
| 581 |
foreach my $v (@{$$rhash{$s}{order}}) { |
| 582 |
$$rhash{$s}{$v}{new} = $$rhash{$s}{$v}{default}; |
| 583 |
$$rhash{$s}{$v}{new} = $$rhash{$s}{$v}{windows} |
| 584 |
if (exists $$rhash{$s}{$v}{windows} and $is_windows); |
| 585 |
if ($$rhash{$s}{$v}{type} eq 'boolean') { |
| 586 |
$$rhash{$s}{$v}{new} = ($$rhash{$s}{$v}{new} eq 'true') ? $$rhash{$s}{$v}{onvalue} : 0; |
| 587 |
}; |
| 588 |
}; |
| 589 |
}; |
| 590 |
$$rhash{save} = 1; |
| 591 |
$$rhash{apply} ->configure(-state=>'normal'); |
| 592 |
$$rhash{future}->configure(-state=>'normal'); |
| 593 |
## and make sure it is displayed properly |
| 594 |
$tree -> KeyboardBrowse; |
| 595 |
Echo("Restored ALL parameter defaults. Click the apply or save buttons to use these defaults."); |
| 596 |
}; |
| 597 |
|
| 598 |
|
| 599 |
sub prefs_apply { |
| 600 |
my %old = (charsize => $config{plot}{charsize}, |
| 601 |
charfont => $config{plot}{charfont}, |
| 602 |
workspace => $config{general}{workspace}, |
| 603 |
logstyle => $config{log}{style}, |
| 604 |
layout => $config{general}{layout}, |
| 605 |
mru_display => $config{general}{mru_display}, |
| 606 |
); |
| 607 |
|
| 608 |
my $rhash = $_[0]; |
| 609 |
foreach my $s (@{$$rhash{order}}) { |
| 610 |
foreach my $v (@{$$rhash{$s}{order}}) { |
| 611 |
$config{$s}{$v} = $$rhash{$s}{$v}{new}; |
| 612 |
}; |
| 613 |
}; |
| 614 |
$$rhash{save} = -1; |
| 615 |
## certain parameters need to take effect immediately and so require |
| 616 |
## some special care |
| 617 |
|
| 618 |
## sanity checks for cormin, rmin, rmax, others |
| 619 |
($config{data}{cormin} = 0) if ($config{data}{cormin} < 0); |
| 620 |
($config{data}{cormin} = 1) if ($config{data}{cormin} > 1); |
| 621 |
(($config{data}{rmin}, $config{data}{rmax}) = ($config{data}{rmax}, $config{data}{rmin})) |
| 622 |
if ($config{data}{rmin} > $config{data}{rmax}); |
| 623 |
($config{warnings}{reff_margin} = 1) if ($config{warnings}{reff_margin} <= 0); |
| 624 |
|
| 625 |
## set default analysis parameter values |
| 626 |
$setup -> SetDefault(fit_space => $config{data}{fit_space}, |
| 627 |
do_bkg => ($config{data}{fit_bkg}) ? 'yes' : 'no', |
| 628 |
kmin => $config{data}{kmin}, |
| 629 |
kmax => $config{data}{kmax}, |
| 630 |
dk => $config{data}{dk}, |
| 631 |
k1 => ($config{data}{kweight} == 1), |
| 632 |
k2 => ($config{data}{kweight} == 2), |
| 633 |
k3 => ($config{data}{kweight} == 3), |
| 634 |
rmin => $config{data}{rmin}, |
| 635 |
rmax => $config{data}{rmax}, |
| 636 |
dr => $config{data}{dr}, |
| 637 |
kwindow => $config{data}{kwindow}, |
| 638 |
rwindow => $config{data}{rwindow}, |
| 639 |
cormin => $config{data}{cormin}, |
| 640 |
); |
| 641 |
|
| 642 |
foreach my $k (qw(window_multiplier bg fg grid showgrid |
| 643 |
c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 |
| 644 |
datastyle fitstyle partsstyle |
| 645 |
key_x key_y key_dy |
| 646 |
)) { |
| 647 |
$plot_features{$k} = $config{plot}{$k}; |
| 648 |
}; |
| 649 |
$plot_features{rmax_out} = $config{data}{rmax_out}; |
| 650 |
Ifeffit::put_scalar('&plot_key_x', $config{plot}{key_x}); |
| 651 |
Ifeffit::put_scalar('&plot_key_y0', $config{plot}{'key_y'}); |
| 652 |
Ifeffit::put_scalar('&plot_key_dy', $config{plot}{key_dy}); |
| 653 |
|
| 654 |
#$log_params{prefer} = $config{logview}{prefer}; |
| 655 |
|
| 656 |
unless ($config{general}{layout} eq $old{layout}) { |
| 657 |
map {$_->packForget} ($fat, $skinny, $skinny2); |
| 658 |
&layout; |
| 659 |
}; |
| 660 |
&set_recent_menu if ($old{mru_display} ne $config{general}{mru_display}); |
| 661 |
|
| 662 |
## handle general.projectbar parameter |
| 663 |
if ($config{general}{projectbar} eq 'none') { |
| 664 |
$projectbar -> packForget; |
| 665 |
} elsif ($config{general}{projectbar} eq 'file') { |
| 666 |
$project_label -> configure(-textvariable=>\$project_name); |
| 667 |
$projectbar -> pack(-side=>"top", -anchor=>'nw', -fill=>'x'); #, -after=>$menubar) |
| 668 |
} elsif ($config{general}{projectbar} eq 'title') { |
| 669 |
$project_label -> configure(-textvariable=>\$props{'Project title'}); |
| 670 |
$projectbar -> pack(-side=>"top", -anchor=>'nw', -fill=>'x'); #, -after=>$menubar) |
| 671 |
}; |
| 672 |
## handle general.workspace parameter |
| 673 |
##($config{general}{workspace} =~ s/\~/$ENV{HOME}/) unless ($is_windows); |
| 674 |
##$stash_dir = $config{general}{workspace}; |
| 675 |
##&delete_project unless (same_directory($old{workspace}, $config{general}{workspace})); |
| 676 |
|
| 677 |
## default log style |
| 678 |
@log_type = set_log_style($config{log}{style}) unless ($old{logstyle} eq $config{log}{style}); |
| 679 |
|
| 680 |
$paths{data0} -> dispose("plot(charsize=$config{plot}{charsize}, charfont=$config{plot}{charfont})", $dmode) |
| 681 |
if (($old{charsize} != $config{plot}{charsize}) or ($old{charfont} != $config{plot}{charfont})); |
| 682 |
|
| 683 |
$file_menu -> menu -> entryconfigure(5, -state=>($config{general}{import_feffit}) ? 'normal' : 'disabled'); |
| 684 |
|
| 685 |
## manage_geometry($config{geometry}{main_width}, $config{geometry}{main_height}); |
| 686 |
&manage_extended_params; |
| 687 |
Echo("Applied new preferences to current session."); |
| 688 |
}; |
| 689 |
|
| 690 |
sub prefs_save { |
| 691 |
my $rhash = $_[0]; |
| 692 |
rename $personal_rcfile, $personal_rcfile.".bak"; |
| 693 |
my $config_ref = tied %config; |
| 694 |
$config_ref -> WriteConfig($personal_rcfile); |
| 695 |
$$rhash{save} = 0; |
| 696 |
Echo("Saved preferences to \"$personal_rcfile\""); |
| 697 |
}; |
| 698 |
|
| 699 |
|
| 700 |
sub manage_geometry { |
| 701 |
my ($w, $h) = @_; |
| 702 |
# $skinny2 -> packPropagate(0); |
| 703 |
$fat -> packPropagate(1); |
| 704 |
$fat -> pack(-expand => 1); |
| 705 |
$fat -> configure(-width => $w.'c', -height => $h.'c',); |
| 706 |
$top -> update; |
| 707 |
$fat -> pack(-expand => 0); |
| 708 |
$fat -> packPropagate(0); |
| 709 |
# $skinny2 -> packPropagate(1); |
| 710 |
|
| 711 |
my @geom = split(/[+x]/, $top->geometry); |
| 712 |
print join(" ", @geom), $/; |
| 713 |
my $extrabit = ($Tk::VERSION < 804) ? 30 : 0; |
| 714 |
($extrabit = 0) if ($is_windows); |
| 715 |
$top -> minsize($geom[0], $geom[1]+$extrabit); |
| 716 |
}; |
| 717 |
|
| 718 |
|
| 719 |
sub read_config { |
| 720 |
my $rhash = $_[0]; |
| 721 |
my $config_file = $paths{data0} -> find('artemis', 'config'); |
| 722 |
return -1 unless (-e $config_file); |
| 723 |
|
| 724 |
$$rhash{order} = []; |
| 725 |
my ($current_section, $current_variable) = ("", ""); |
| 726 |
Echo("Reading master configuration file ..."); |
| 727 |
open C, $config_file or die "could not open $config_file for reading\n"; |
| 728 |
while (<C>) { |
| 729 |
next if (/^\s*$/); # blank line |
| 730 |
next if (/^\s*\#/); # comment line |
| 731 |
chomp; |
| 732 |
SWITCH: { |
| 733 |
## recognize a new section of variables |
| 734 |
(/^section=/) and do { |
| 735 |
my @line = split(/=/, $_); |
| 736 |
push @{$$rhash{order}}, $line[1]; |
| 737 |
$$rhash{$line[1]} = {}; |
| 738 |
$current_section = $line[1]; |
| 739 |
last SWITCH; |
| 740 |
}; |
| 741 |
## read the description of the current section of variables |
| 742 |
(/^section_description/) and do { |
| 743 |
$$rhash{$current_section}{description} = ""; |
| 744 |
my $next = <C>; |
| 745 |
while ($next !~ /^\s*$/) { |
| 746 |
chomp $next; |
| 747 |
$$rhash{$current_section}{description} .= substr($next, 1); |
| 748 |
$next = <C>; |
| 749 |
}; |
| 750 |
$$rhash{$current_section}{description} = |
| 751 |
substr($$rhash{$current_section}{description}, 1); |
| 752 |
last SWITCH; |
| 753 |
}; |
| 754 |
## recognize a new variable |
| 755 |
(/^variable=/) and do { |
| 756 |
my @line = split(/=/, $_); |
| 757 |
push @{$$rhash{$current_section}{order}}, $line[1]; |
| 758 |
$$rhash{$current_section}{$line[1]} = {}; |
| 759 |
$current_variable = $line[1]; |
| 760 |
last SWITCH; |
| 761 |
}; |
| 762 |
## read the description of the current variable |
| 763 |
(/^description/) and do { |
| 764 |
$$rhash{$current_section}{$current_variable}{description} = ""; |
| 765 |
my $next = <C>; |
| 766 |
while ($next !~ /^\s*$/) { |
| 767 |
chomp $next; |
| 768 |
$next =~ s/^ *\./\n\n /; |
| 769 |
$$rhash{$current_section}{$current_variable}{description} .= substr($next, 1); |
| 770 |
$next = <C>; |
| 771 |
}; |
| 772 |
$$rhash{$current_section}{$current_variable}{description} = |
| 773 |
substr($$rhash{$current_section}{$current_variable}{description}, 1); |
| 774 |
last SWITCH; |
| 775 |
}; |
| 776 |
## the type (i.e. string, boolean, etc) of the current variable |
| 777 |
(/^type=/) and do { |
| 778 |
my @line = split(/=/, $_); |
| 779 |
($line[1] = " ") if ($line[1] eq '""'); |
| 780 |
$$rhash{$current_section}{$current_variable}{type} = $line[1]; |
| 781 |
last SWITCH; |
| 782 |
}; |
| 783 |
## default value |
| 784 |
(/^default=/) and do { |
| 785 |
my @line = split(/=/, $_); |
| 786 |
($line[1] = " ") if ($line[1] eq '""'); |
| 787 |
$$rhash{$current_section}{$current_variable}{default} = $line[1]; |
| 788 |
last SWITCH; |
| 789 |
}; |
| 790 |
## list values |
| 791 |
(/^values=/) and do { |
| 792 |
my @line = split(/=/, $_); |
| 793 |
($line[1] = " ") if ($line[1] eq '""'); |
| 794 |
$$rhash{$current_section}{$current_variable}{values} = $line[1]; |
| 795 |
last SWITCH; |
| 796 |
}; |
| 797 |
## special treatment for windows |
| 798 |
(/^windows=/) and do { |
| 799 |
my @line = split(/=/, $_); |
| 800 |
($line[1] = " ") if ($line[1] eq '""'); |
| 801 |
$line[1] =~ s/ENV___(\w*)___/$ENV{$1}/ if $is_windows; |
| 802 |
$$rhash{$current_section}{$current_variable}{windows} = $line[1]; |
| 803 |
last SWITCH; |
| 804 |
}; |
| 805 |
## max value for integer or positive integer |
| 806 |
(/^maxint=/) and do { |
| 807 |
my @line = split(/=/, $_); |
| 808 |
($line[1] = " ") if ($line[1] eq '""'); |
| 809 |
$$rhash{$current_section}{$current_variable}{maxint} = $line[1]; |
| 810 |
last SWITCH; |
| 811 |
}; |
| 812 |
## min value for integer |
| 813 |
(/^minint=/) and do { |
| 814 |
my @line = split(/=/, $_); |
| 815 |
($line[1] = " ") if ($line[1] eq '""'); |
| 816 |
$$rhash{$current_section}{$current_variable}{minint} = $line[1]; |
| 817 |
last SWITCH; |
| 818 |
}; |
| 819 |
## boolean for whether a font may be variable width |
| 820 |
(/^variable_width=/) and do { |
| 821 |
my @line = split(/=/, $_); |
| 822 |
($line[1] = " ") if ($line[1] eq '""'); |
| 823 |
$$rhash{$current_section}{$current_variable}{variable_width} = $line[1]; |
| 824 |
last SWITCH; |
| 825 |
}; |
| 826 |
## value for boolean true |
| 827 |
(/^onvalue=/) and do { |
| 828 |
my @line = split(/=/, $_); |
| 829 |
($line[1] = " ") if ($line[1] eq '""'); |
| 830 |
$$rhash{$current_section}{$current_variable}{onvalue} = $line[1]; |
| 831 |
last SWITCH; |
| 832 |
}; |
| 833 |
## value for boolean false if not 0 |
| 834 |
(/^offvalue=/) and do { |
| 835 |
my @line = split(/=/, $_); |
| 836 |
($line[1] = " ") if ($line[1] eq '""'); |
| 837 |
$$rhash{$current_section}{$current_variable}{offvalue} = $line[1]; |
| 838 |
last SWITCH; |
| 839 |
}; |
| 840 |
## restart required |
| 841 |
(/^restart=/) and do { |
| 842 |
my @line = split(/=/, $_); |
| 843 |
($line[1] = 0) if ($line[1] eq '""'); |
| 844 |
$$rhash{$current_section}{$current_variable}{restart} = $line[1]; |
| 845 |
last SWITCH; |
| 846 |
}; |
| 847 |
## parameter units |
| 848 |
(/^units=/) and do { |
| 849 |
my @line = split(/=/, $_); |
| 850 |
($line[1] = " ") if ($line[1] eq '""'); |
| 851 |
$$rhash{$current_section}{$current_variable}{units} = $line[1]; |
| 852 |
last SWITCH; |
| 853 |
}; |
| 854 |
## callback string for list or boolean |
| 855 |
(/^callback=/) and do { |
| 856 |
my @line = split(/=/, $_); |
| 857 |
($line[1] = " ") if ($line[1] eq '""'); |
| 858 |
$$rhash{$current_section}{$current_variable}{callback} = $line[1]; |
| 859 |
last SWITCH; |
| 860 |
}; |
| 861 |
}; |
| 862 |
}; |
| 863 |
|
| 864 |
close C; |
| 865 |
Echo("Read master configuration file $config_file"); |
| 866 |
|
| 867 |
}; |
| 868 |
|
| 869 |
## END OF THE PREFERENCES SUBSYSTEM |
| 870 |
|