Debian Codegraph @

attic/scripts/Tk/Config.pm

raw
1 #!/usr/bin/perl -w
2 ######################################################################
3 ## TkAtoms configuration module for Atoms 3.0beta9
4 ## copyright (c) 1999 Bruce Ravel
5 ## [email protected]
6 ## http://feff.phys.washington.edu/~ravel/
7 ##
8 ## The latest version of Atoms can always be found at
9 ## http://feff.phys.washington.edu/~ravel/atoms/
10 ##
11 ## -------------------------------------------------------------------
12 ## All rights reserved. This program is free software; you can
13 ## redistribute it and/or modify it under the same terms as Perl
14 ## itself.
15 ##
16 ## This program is distributed in the hope that it will be useful,
17 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ## Artistic License for more details.
20 ## -------------------------------------------------------------------
21 ######################################################################
22
23 package Xray::Tk::Config;
24 use strict;
25 use vars qw($VERSION $cvs_info @ISA @EXPORT @EXPORT_OK);
26
27 require Exporter;
28
29 @ISA = qw(Exporter AutoLoader);
30 @EXPORT_OK = qw(atoms_config);
31 $cvs_info = '$Id: Config.pm,v 1.7 2001/09/20 17:54:19 bruce Exp $ ';
32 $VERSION = (split(' ', $cvs_info))[2] || 'pre_release';
33
34 use Tk;
35 use Tk::widgets qw/ColorEditor/;
36 my $is_windows = (($^O eq 'MSWin32') or ($^O eq 'cygwin'));
37
38 my (%values, %initial);
39 my @variables = ( ## variables
40 ['write_to_pwd', 'boolean'],
41 ['prefer_feff_eight', 'boolean'],
42 ['always_write_feff', 'boolean'],
43 ['display_balloons', 'boolean'],
44 ['no_crystal_warnings', 'boolean'],
45 ['one_frame', 'boolean'],
46 #['convolve_dafs', 'boolean'],
47 ['never_ask_to_save', 'boolean'],
48 ['atoms_language', 'list', \&Xray::Atoms::available_languages],
49 ['absorption_tables', 'list', \&Xray::Absorption::available],
50 ['dafs_default', 'list', \&Xray::Absorption::scattering],
51 ['unused_modifier', 'list',
52 sub{return ('Shift', 'Alt', 'Control', 'Meta')}],
53 ['default_filepath', 'directory'],
54 #['plotting_hook', 'string'],
55 ['ADB_location', 'string'],
56 ## colors
57 ['foreground', 'colors'],
58 ['background', 'colors'],
59 ['trough', 'colors'],
60 ['entry', 'colors'],
61 ['label', 'colors'],
62 ['balloon', 'colors'],
63 ['button', 'colors'],
64 ['buttonActive', 'colors'],
65 ['radio', 'colors'],
66 ['sgbActive', 'colors'],
67 ['sgbGroup', 'colors'],
68 #['done', 'colors'],
69 ['todo', 'colors'],
70 ['plot', 'colors'],
71 ## fonts
72 ['f_balloon', 'fonts'],
73 ['f_label', 'fonts'],
74 ['f_menu', 'fonts'],
75 ['f_button', 'fonts'],
76 ['f_header', 'fonts'],
77 ['f_entry', 'fonts'],
78 ['f_sgb', 'fonts'],
79 );
80
81
82 my @label_args = ('-justify', 'left', '-width', 17, '-anchor', 'w',
83 '-foreground', $::colors{label},
84 '-font', $::fonts{label}, );
85 my @menu_args = (-foreground=>$::colors{label},
86 -activeforeground=>$::colors{label},
87 -font=>$::fonts{menu}, );
88 my @entry_args = (-background=>$::colors{entry},
89 -font=>$::fonts{entry},
90 -insertbackground=>$::colors{foreground}, );
91 my @button_args = (-foreground => $::colors{entry},
92 -background => $::colors{button},
93 -activeforeground => $::colors{entry},
94 -activebackground => $::colors{buttonActive},
95 -font=>$::fonts{button},);
96
97 my ($count_colors, $count_variables) = (0,0);
98 my $force_restore = 0;
99 my ($top, $notebook, $ce); # some widgets
100 my %color_button;
101 my $max_var_rows = 7;
102
103 sub atoms_config {
104 my $parent = $_[0];
105 ## if ($^O eq 'MSWin32') {
106 ## my $dialog = $parent -> DialogBox(-title=>'TkAtoms: warning',
107 ## -buttons=>['OK'],);
108 ## $dialog -> add("Label", qw/-padx .25c -pady .25c -text/,
109 ## "The preferences selector has a high probability of$/" .
110 ## "hanging Windows 95 and 98, so it is currently disabled.$/" .
111 ## "on all Windows platforms. Sorry. Something to$/" .
112 ## "look forward to...")
113 ## -> pack(-side=>'left');
114 ## $dialog -> Show;
115 ## return;
116 ## };
117 if (not Exists $top) {
118 $top = $parent -> Toplevel(-class=>'horae');
119 $top -> iconbitmap('@'.File::Spec->catfile($Xray::Atoms::lib_dir, "tkatoms3.xbm"))
120 unless $is_windows;
121 $top ->resizable(0,0);
122 $notebook = $top -> NoteBook(-backpagecolor=>$::colors{background},
123 -inactivebackground=>$::colors{background},);
124 $top -> bind('<Control-d>' => \&dump_values);
125 my %pages;
126 ($count_colors, $count_variables) = (0,0);
127 my @note_args = (-anchor=>'center',);
128 foreach my $f0 ('variables', 'colors', 'fonts') {
129 $pages{$f0} = $notebook -> add($f0, -label=>$$::config{$f0}, @note_args);
130 };
131 $notebook->pack(-expand => 'y', -side => 'top');
132
133 my $button_frame = $top -> Frame(-relief=>'ridge', '-border'=>2)
134 -> pack(-side=>'bottom', -fill=>'x');
135 my $save_button = $button_frame
136 -> Button(-text=>$$::config{'save_values'}, @button_args,
137 -command=>\&write_new_rcfile)
138 -> pack(-side=>'left', -fill=>'x', -padx=>2, -pady=>2, );
139 &::manage($save_button, "button");
140 exists ($$::config{'save_values_help'}) and
141 $::balloon -> attach($save_button, -msg=>$$::config{'save_values_help'});
142 my $dismiss_button = $button_frame -> Button(-text=>$$::config{dismiss},
143 @button_args,
144 -command=>sub{
145 $top->withdraw})
146 -> pack(-side=>'right', -fill=>'x', -padx=>2, -pady=>2);
147 &::manage($dismiss_button, "button");
148 exists ($$::config{'dismiss_help'}) and
149 $::balloon -> attach($dismiss_button, -msg=>$$::config{'dismiss_help'});
150
151 ## ----- set up page of colors ---------------------------------------
152 my $top_frame = $pages{'colors'} ->
153 Frame(-border=>2, -relief=>'ridge') ->
154 pack(-side=>'top',-fill=>'x', -expand=>1);
155 my $palette_button = $top_frame ->
156 Button(-text=>$$::config{'set_palette'},
157 @button_args,
158 -command=>[\&atoms_set_palette,$parent])
159 -> pack(-side=>'left');
160 &::manage($palette_button, "button");
161 exists ($$::config{'set_palette_help'}) and
162 $::balloon -> attach($palette_button, -msg=>$$::config{'set_palette_help'});
163 my $restore_button = $top_frame ->
164 Button(-text=>$$::config{'restore'},
165 @button_args,
166 -command=>[\&reset_values,'colors'])
167 -> pack(-side=>'left');
168 &::manage($restore_button, "button");
169 exists ($$::config{'restore_palette_help'}) and
170 $::balloon -> attach($restore_button,
171 -msg=>$$::config{'restore_palette_help'});
172 my $color_explain = $top_frame ->
173 Label(#-width=>100,
174 -foreground=>$::colors{label},
175 -text=>$$::config{'explain_colors'}) ->
176 pack(-side=>'left');
177 &::manage($color_explain, "label");
178 my $color_frame = $pages{'colors'} -> Frame() -> pack(-side=>'right');
179 $ce = $color_frame -> ColorSelect() -> pack();
180 ## yipes!!! Rearrange some stuff in the color selector
181 ##push @::all_menus, (($ce->children())[3]->children())[0]->children();
182 ($ce->children())[1] -> configure('-width'=>18);
183 unless ($^O eq 'MSWin32') {
184 ($ce->children())[5] -> configure('-length'=>'4c');
185 ($ce->children())[7] -> configure('-length'=>'4c');
186 ($ce->children())[9] -> configure('-length'=>'4c');
187 ((($ce->children())[3]->children())[0]->children())[0]
188 -> invoke('RGB color space');
189 };
190 ## need to load color selector widgets into all_ arrays (ugh!)
191 my $color_list_frame = $pages{'colors'} ->
192 Frame(-border=>1, -relief=>'groove') ->
193 pack(-side=>'left');
194
195 ## ----- set up page of variables ------------------------------------
196 $top_frame = $pages{'variables'} ->
197 Frame(-border=>2, -relief=>'ridge') ->
198 pack(-side=>'top',-fill=>'x', -expand=>1, -anchor=>'n');
199 my $variables_frame = $pages{'variables'} ->
200 Frame(-border=>2, -relief=>'groove') ->
201 pack(-side=>'left', -padx=>2, -pady=>2, -fill=>'y');
202
203 my $set_button = $top_frame ->
204 Button(-text=>$$::config{'set_variables'}, @button_args,
205 -command=>[\&::set_variables, \%values])
206 -> pack(-side=>'left');
207 &::manage($set_button, "button");
208 exists ($$::config{'set_variables_help'}) and
209 $::balloon -> attach($set_button, -msg=>$$::config{'set_variables_help'});
210
211 $restore_button = $top_frame ->
212 Button(-text=>$$::config{'restore'},
213 @button_args,
214 -command=>[\&reset_values,'variables'])
215 -> pack(-side=>'left');
216 &::manage($restore_button, "button");
217 exists ($$::config{'restore_variables_help'}) and
218 $::balloon -> attach($restore_button,
219 -msg=>$$::config{'restore_variables_help'});
220
221 foreach my $v (@variables) {
222 if ($v->[1] eq 'colors') {
223 &add_color($color_list_frame, $v->[0]);
224 } elsif ($v->[1] eq 'fonts') {
225 &add_font($pages{'fonts'}, $v->[0]);
226 } elsif ($v->[1] eq 'boolean') {
227 &add_boolean($variables_frame, $v->[0]);
228 ++$count_variables;
229 } elsif ($v->[1] eq 'directory') {
230 &add_directory($variables_frame, $v->[0]);
231 ++$count_variables;
232 } elsif ($v->[1] eq 'string') {
233 &add_string($variables_frame, $v->[0]);
234 ++$count_variables;
235 } elsif ($v->[1] eq 'list') {
236 &add_list($variables_frame, $v->[0], $v->[2]);
237 ++$count_variables;
238 };
239 };
240
241
242 ## ----- set up page of fonts ----------------------------------------
243 my $label = $pages{'fonts'} ->
244 Label(-text=>'Sorry. No font configuration yet.')
245 ->pack();
246 &::manage($label, "label");
247
248 $top -> title($$::config{config_title});
249 $top -> iconname($$::config{config_title});
250 $top -> bind('<Control-q>' => sub{$top->destroy});
251 } else {
252 $top->deiconify;
253 $top->raise;
254 }
255 foreach my $k (keys %values) {
256 $initial{$k} = $values{$k};
257 };
258 return ($top, $notebook);
259 };
260
261
262 ######################################################################
263 ## subroutines for filling configuration notecards
264
265 sub display_name {
266 my $name = $_[0];
267 my @name = split(/_/, $name);
268 ($name[0] =~ /^[fc]$/i) and shift @name;
269 @name = map {ucfirst($_)} @name;
270 return join(" ", @name);
271 };
272
273 sub add_list {
274 my ($parent, $name, $r_function) = @_;
275 my $this_row = $count_variables % $max_var_rows;
276 my $col_add = int($count_variables / $max_var_rows);
277 $col_add &&= $col_add*3+1;
278 my $current = $::meta{$name};
279 $current = ucfirst($current);
280 ($current eq 'Cl') and $current = 'CL';
281 ($current eq 'Mcmaster') and $current = 'McMaster';
282 $values{$name} = $current;
283 my $space = $parent -> Label(-text=>' ') ->
284 grid(-row=>$this_row, -column=>0+$col_add, -sticky=>'w');
285 my $label = $parent -> Label(-text=>&display_name($name), @label_args) ->
286 grid(-row=>$this_row, -column=>1+$col_add, -sticky=>'w');
287 &::manage($label, "label");
288 exists ($$::config{$name}) and
289 $::balloon -> attach($label, -msg=>$$::config{$name});
290 my $menu = $parent
291 -> Optionmenu(-textvariable => \$current,
292 -background => $::colors{entry},
293 -activeforeground => $::colors{label},
294 -activebackground => $::colors{entry},
295 -width=>10, -font=>$::fonts{label},
296 -relief=>'groove')
297 -> grid(-row=>$this_row, -column=>2+$col_add, -sticky=>'we');
298 &::manage($menu, "menu");
299 foreach my $s (&$r_function) {
300 my $this = $menu -> command(-label => $s, @menu_args,
301 -command=>sub{$values{$name}=$s; $current=$s});
302 &::manage($menu, "menu");
303 };
304 };
305
306
307 sub add_string {
308 my ($parent, $name) = @_;
309 my $this_row = $count_variables % $max_var_rows;
310 my $col_add = int($count_variables / $max_var_rows);
311 $col_add &&= $col_add*3+1;
312 my $current = $::meta{$name};
313 $values{$name} = $current;
314 my $space = $parent -> Label(-text=>' ') ->
315 grid(-row=>$this_row, -column=>0+$col_add, -sticky=>'w');
316 my $label = $parent -> Label(-text=>&display_name($name), @label_args)
317 -> grid(-row=>$this_row, -column=>1+$col_add, -sticky=>'w');
318 &::manage($label, "label");
319 exists ($$::config{$name}) and
320 $::balloon -> attach($label, -msg=>$$::config{$name});
321 my $entry = $parent -> Entry(-textvariable=>\$values{$name}, @entry_args)
322 -> grid(-row=>$this_row, -column=>2+$col_add);
323 #$entry -> delete(qw/0 end/);
324 #$entry -> insert(0,$current);
325 &::manage($entry, "entry");
326 };
327
328 sub add_directory {
329 my ($parent, $name) = @_;
330 my $this_row = $count_variables % $max_var_rows;
331 my $col_add = int($count_variables / $max_var_rows);
332 $col_add &&= $col_add*3+1;
333 my $current = $::meta{$name};
334 $values{$name} = $current;
335 my $space = $parent -> Label(-text=>' ') ->
336 grid(-row=>$this_row, -column=>0+$col_add, -sticky=>'w');
337 my $label = $parent -> Label(-text=>&display_name($name), @label_args)
338 -> grid(-row=>$this_row, -column=>1+$col_add, -sticky=>'w');
339 &::manage($label, "label");
340 exists ($$::config{$name}) and
341 $::balloon -> attach($label, -msg=>$$::config{$name});
342 my $entry = $parent -> Entry(-textvariable=>$current, @entry_args)
343 -> grid(-row=>$this_row, -column=>2+$col_add);
344 &::manage($entry, "entry");
345 my $home;
346 eval '$home = $ENV{"HOME"} || $ENV{"LOGDIR"} || (getpwuid($<))[7];'
347 or $home = "";
348 my $button = $parent ->
349 Button(-text=>$$::config{'browse'},
350 @button_args,
351 -command=>sub{
352 local $Tk::FBox::a;
353 local $Tk::FBox::b;
354 my $types = [['All Files', '*'],];
355 my $path = $::meta{default_filepath} || Cwd::cwd();
356 $current = $top ->
357 getOpenFile(-defaultextension=>'inp',
358 -filetypes=>$types,
359 #(not $is_windows) ?
360 # (-sortcmd=>sub{$Tk::FBox::a cmp $Tk::FBox::b}) : (),
361 -initialdir=>$path,
362 -title => "Configure TkAtoms");
363 $values{$name}=$current;
364 $entry -> delete(0,'end');
365 $entry -> insert(0,$current);
366 return 0;
367 })
368 -> grid(-row=>$this_row, -column=>3+$col_add, -padx=>2, -sticky=>'w');
369 exists ($$::config{browse_help}) and
370 $::balloon -> attach($button, -msg=>$$::config{browse_help});
371 &::manage($button, "button");
372 }
373
374 sub add_boolean {
375 my ($parent, $name) = @_;
376 my @args = qw/-offvalue 0 -onvalue 1/;
377 my $this_row = $count_variables % $max_var_rows;
378 my $col_add = int($count_variables / $max_var_rows);
379 $col_add &&= $col_add*3+1;
380 my $current = $::meta{$name};
381 $values{$name} = $current;
382 my $space = $parent -> Label(-text=>' ') ->
383 grid(-row=>$this_row, -column=>0+$col_add, -sticky=>'w');
384 my $button = $parent -> Checkbutton(@args, -text=>&display_name($name),
385 -selectcolor=>$::colors{radio},
386 -variable=>\$current, @label_args,
387 -command=>sub{$values{$name}=$current} )
388 -> grid(-row=>$this_row, -column=>1+$col_add, -sticky=>'w');
389 &::manage($button, "check");
390 exists ($$::config{$name}) and
391 $::balloon -> attach($button, -msg=>$$::config{$name});
392 };
393
394 sub add_color {
395 my ($parent, $name) = @_;
396 my $frame = $parent -> Frame(-borderwidth=>1, -relief=>'sunken')
397 -> grid(-column=>($count_colors%2), -row=>int($count_colors/2));
398 ++$count_colors;
399 my $current = $::colors{$name};
400 $values{$name} = $current;
401 $color_button{$name} = $frame -> Label(-text=>' ', -background=>$current,
402 -borderwidth=>1, -relief=>'raised')
403 -> pack(-side=>'left', -padx=>4);
404 my $label = $frame -> Label(-text=>&display_name($name),
405 -width=>12, @label_args)
406 -> pack(-side=>'left');
407 &::manage($label, "label");
408 exists ($$::config{$name}) and
409 $::balloon -> attach($label, -msg=>$$::config{$name});
410 my $button = $frame ->
411 Button(-text=>$$::config{'set'},
412 @button_args,
413 -command=>sub{
414 $current = ($ce->children())[11] -> get();
415 $values{$name} = $current;
416 $color_button{$name} -> configure(-background=>$current);
417 })
418 -> pack(-side=>'left');
419 &::manage($button, "button");
420 exists ($$::config{set_color_help}) and
421 $::balloon -> attach($button, -msg=>$$::config{set_color_help});
422 }
423
424 sub add_font {
425 my ($parent, $name) = @_;
426 my $n = substr($name, 2);
427 my $current = $::fonts{$n};
428 $values{$name} = $current;
429 1;
430 }
431
432 sub reset_values {
433 my $which = $_[0];
434 $force_restore = 1;
435 foreach my $k (keys %values) {
436 if ( (($which eq 'colors') or ($which eq 'all'))
437 and
438 ($k =~ /^c_/) ) {
439 $values{$k} = $initial{$k};
440 $color_button{$k} -> configure(-background=>$values{$k});
441 };
442 if ( (($which eq 'variables') or ($which eq 'all'))
443 and
444 ($k !~ /^[cf]_/) ) {
445 $values{$k} = $initial{$k};
446 eval "\$$k = $values{$k};";
447 };
448 ## fonts
449 };
450 };
451
452
453 sub atoms_set_palette {
454 my @palette = (background => $values{background},
455 foreground => $values{foreground},
456 troughColor => $values{trough},);
457 ## set $colors hash to its new values for future widgets
458 my $noisy = 0;
459
460 ## set overall palette stuff (if necessary)
461 my $do_palette = ( $force_restore
462 or
463 (lc($values{background}) ne lc($initial{background}))
464 or
465 (lc($values{foreground}) ne lc($initial{foreground}))
466 or
467 (lc($values{trough}) ne lc($initial{trough}))
468 );
469 $do_palette and $::top -> setPalette(@palette);
470 $force_restore = 0;
471 ## balloon colors
472 $::balloon -> configure(-background=>$values{balloon},
473 -foreground=>$values{balloon});
474
475 ## labels
476 $noisy and print "labels\n";
477 foreach my $w (@::all_labels) {
478 next unless (Exists($w));
479 $w -> configure(-foreground => $values{label});
480 };
481 ## buttons
482 $noisy and print "buttons\n";
483 foreach my $w (@::all_buttons) {
484 next unless (Exists($w));
485 $w -> configure(-foreground => $values{entry},
486 -background => $values{button},
487 -activeforeground => $values{entry},
488 -activebackground => $values{buttonActive},);
489 };
490 ## entries
491 $noisy and print "entries\n";
492 foreach my $w (@::all_entries) {
493 next unless (Exists($w));
494 $w -> configure(-background=>$values{entry},
495 #-font=>$values{f_entry},
496 -insertbackground=>$values{foreground},);
497 };
498 ## radio buttons (menu)
499 $noisy and print "radio\n";
500 foreach my $w (@::all_radio) {
501 #next unless (Exists($w));
502 $w -> configure(-selectcolor => $values{button},
503 -foreground=>$values{label},
504 -activeforeground=>$values{label},
505 -activebackground => $values{entry},
506 );
507 };
508 ## check buttons (label)
509 $noisy and print "check\n";
510 foreach my $w (@::all_check) {
511 next unless (Exists($w));
512 $w -> configure(-selectcolor => $values{button},
513 -foreground => $values{label}
514 );
515 };
516 ## headers
517 $noisy and print "headers\n";
518 foreach my $w (@::all_headers) {
519 next unless (Exists($w));
520 $w -> configure(-foreground=>$values{button},
521 #-font=>$values{f_header},
522 );
523 };
524 ## menu buttons and entries
525 $noisy and print "menus\n";
526 foreach my $w (@::all_menus) {
527 ## next unless (("$w" !~ /cascade|command/i) and Exists($w));
528 $w -> configure(-foreground => $values{label},
529 -activeforeground => $values{label},
530 -activebackground => $values{entry},
531 -background => $values{background},
532 ##-font=>$$fonts{menu},
533 );
534 ($w =~ /Option/) and
535 $w -> configure(-background => $values{background},
536 -activebackground => $values{entry},);
537 ($w =~ /Menu::[CR]/) and
538 $w -> configure(-background => $values{background},
539 -activebackground => $values{entry},);
540 };
541 ## separators
542 ## $noisy and print "separators\n";
543 ## foreach my $w (@::all_separators) {
544 ## print $w -> configure(), $/; #-background => $values{background});
545 ## };
546 ## LabFrames
547 $noisy and print "labframes\n";
548 foreach my $w (@::all_labframes) {
549 next unless (Exists($w));
550 $w -> configure(-foreground=>$values{label});
551 };
552 ## scales
553 $noisy and print "scales\n";
554 foreach my $w (@::all_scales) {
555 next unless (Exists($w));
556 $w -> configure(-foreground=>$values{label});
557 };
558 ## canvases
559 $noisy and print "canvases\n";
560 foreach my $w (@::all_canvas) {
561 next unless (Exists($w));
562 $w -> configure(-background=>$values{todo});
563 };
564 my @toss = @::all_progress;
565 while (@toss) {
566 my $w = shift(@toss);
567 next unless (Exists($w));
568 my $id = shift(@toss);
569 $w -> itemconfigure($id, -fill=>$values{done});
570 };
571
572 ## set $::colors hash to this set of values
573 foreach my $c (qw/foreground background trough entry label
574 balloon button buttonActive sgbActive
575 sgbGroup done todo plot/) {
576 my $t = substr($c, 2);
577 $::colors{$t} = $values{$c};
578 };
579 &::set_arg_arrays;
580
581 };
582
583
584 sub write_new_rcfile {
585 my $file = &Xray::Atoms::rcfile_name;
586 die "could not determine config file\n", return if ($file =~ /\?/);
587 if (-e $file) { rename ($file, $file.".bak") or die $!; };
588 open RC, ">".$file or die $!;
589 print RC <<EOH
590 ## -*- mode: perl -*-
591 ## This atomsrc file was generated automatically by TkAtoms $Xray::Atoms::VERSION
592 ## using Tk/Config.pm $VERSION
593
594 EOH
595 ;
596
597 print RC $/, '[meta]', $/;
598 foreach my $v (@variables) {
599 my $key = $v->[0];
600 if (($v->[1] ne 'colors') and ($v->[1] ne 'fonts')) {
601 printf RC " %-20s = %s$/", $key, $values{$key};
602 };
603 };
604 print RC $/, '[colors]', $/;
605 foreach my $v (@variables) {
606 my $key = $v->[0];
607 if ($v->[1] eq 'colors') {
608 printf RC " %-20s = %s$/", $key, $values{$key};
609 };
610 };
611 print RC $/, '[fonts]', $/;
612 foreach my $v (@variables) {
613 my $key = $v->[0];
614 if ($v->[1] eq 'fonts') {
615 printf RC " %-20s = %s$/", substr($key,2), $values{$key};
616 };
617 };
618 close RC;
619 my $text = "Saved configurations to $file.
620 Saved old rcfile to $file.bak.";
621 &main::tkatoms_text_dialog (\$top, $text, 'left');
622 $top->update;
623 };
624
625 sub dump_values {
626 my $string = <<EOH
627 ## This is what your atomsrc file would like if you were to push the
628 ## "Save values" button now.
629
630 EOH
631 ;
632
633 $string .= $/ . '[meta]' . $/;
634 foreach my $v (@variables) {
635 my $key = $v->[0];
636 if (($v->[1] ne 'colors') and ($v->[1] ne 'fonts')) {
637 $string .= sprintf(" %-20s = %s$/", $key, $values{$key});
638 };
639 };
640 $string .= $/ . '[colors]' . $/;
641 foreach my $v (@variables) {
642 my $key = $v->[0];
643 if ($v->[1] eq 'colors') {
644 $string .= sprintf(" %-20s = %s$/", $key, $values{$key});
645 };
646 };
647 $string .= $/ . '[fonts]' . $/;
648 foreach my $v (@variables) {
649 my $key = $v->[0];
650 if ($v->[1] eq 'fonts') {
651 $string .= sprintf(" %-20s = %s$/", substr($key,2), $values{$key});
652 };
653 };
654 &::display_in_frame($top, \$string,);
655 };
656
657 1;
658 __END__