0cf6f95380866f43513bb9623749c8eb8e29954a
[clawsker.git] / clawsker
1 #!/usr/bin/perl -w
2 #
3 # Clawsker :: A Claws Mail Tweaker
4 #
5 use strict;
6 use encoding 'utf8';
7 use Glib qw(TRUE FALSE);
8 use Gtk2 -init;
9 use POSIX qw(setlocale);
10 use Locale::gettext;
11
12 my $NAME = 'clawsker';
13 my $PREFIX = '@PREFIX@';
14 my $LIBDIR = '@LIBDIR@';
15 my $VERSION = '@VERSION@';
16 my $VERBOSE = FALSE;
17 my $CLAWSV = undef;
18 my $main_window = undef;
19
20 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
21 $locale = "C" unless defined($locale);
22 setlocale (LC_ALL, $locale);
23 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
24 textdomain ($NAME);
25
26 my $SHOWHINTS = FALSE;
27 $SHOWHINTS = TRUE if ($Gtk2::VERSION >= 1.040 and Gtk2->CHECK_VERSION (2, 12, 0));
28
29 sub _ {
30     my $str = shift;
31     my %par = @_;
32     my $xla = gettext ($str);
33     if (scalar(keys(%par)) > 0) {
34         foreach my $key (keys %par) {
35             $xla =~ s/\{$key\}/$par{$key}/g;
36         }
37     }
38     return $xla;
39 }
40
41 # default messages
42 %xl::s = (
43     win_title => _('Claws Mail Hidden Preferences'),
44     about => _('About...'),
45     about_title => _('Clawsker :: A Claws Mail Tweaker'),
46     about_license => _('License:'),
47     about_version => _('Version:'),
48
49     tab_colours => _('Colours'),
50     tab_behaviour => _('Behaviour'),
51     tab_gui => _('GUI'),
52     tab_other => _('Other'),
53     tab_winpos => _('Windows'),
54
55     ab_frame => _('Addressbook'),
56     mem_frame => _('Memory'),
57     msgview_frame => _('Message View'),
58     log_frame => _('Log window'),
59     dnd_frame => _('Drag \'n\' drop'),
60     ssl_frame => _('Secure Sockets Layer'),
61     msgs_frame => _('Messages'),
62     stripes_frame => _('Coloured stripes'),
63     sbar_frame => _('Scroll bars'),
64     mlist_frame => _('Message List'),
65     mview_frame => _('Message View'),
66     compo_frame => _('Compose window'),
67     netm_frame => _('NetworkManager'),
68
69     l_oth_use_dlg => _('Use detached address book edit dialogue'),
70     h_oth_use_dlg => _('If true use a separate dialogue to edit a person\'s details. Otherwise will use a form embedded in the address book\'s main window.'),
71     l_oth_max_use => _('Maximum memory for message cache (kB)'),
72     h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
73     l_oth_min_time => _('Minimun time for cache elements (minutes)'),
74     h_oth_min_time => _('The minimum time in minutes to keep a cache in memory. Caches more recent than this time will not be freed, even if the memory usage is too high.'),
75     l_oth_use_netm => _('Use NetworkManager'),
76     h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
77     
78     l_gui_b_unread => _('Show unread messages with bold font'),
79     h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
80     l_gui_no_markup => _('Don\'t use markup in compose window'),
81     h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
82     l_gui_dot_lines => _('Use dotted lines in tree view components'),
83     h_gui_dot_lines => _('Use the old dotted line look in the main window tree views (Folder, Message and other lists) instead of the modern lineless look.'),
84     l_gui_h_scroll => _('Enable horizontal scrollbar'),
85     h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
86     l_gui_swp_from => _('Display To column instead From column in Sent folder'),
87     h_gui_swp_from => _('Display the recipient\'s email address in a To column of the Sent folder instead of the originator\'s one in a From column.'),
88     l_gui_v_scroll => _('Folder List scrollbar behaviour'),
89     h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
90     l_gui_v_scroll_show => _('Show always'),
91     l_gui_v_scroll_auto => _('Automatic'),
92     l_gui_v_scroll_hide => _('Hide always'),
93     l_gui_from_show => _('From column displays'),
94     h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both'),
95     l_gui_from_show_name => _('Name only'),
96     l_gui_from_show_addr => _('Address only'),
97     l_gui_from_show_both => _('Both name and address'),
98     l_gui_strip_off => _('Coloured lines contrast'),
99     h_gui_strip_off => _('Specify the value to use when creating alternately coloured lines in tree view components. The smaller the value, the less visible the difference in the alternating colours of the lines.'),
100     l_gui_cursor_v => _('Show cursor'),
101     h_gui_cursor_v => _('Display the cursor in the Message View.'),
102     l_gui_toolbar_d => _('Detachable toolbars'),
103     h_gui_toolbar_d => _('Show handles in the toolbars.'),
104     l_gui_strip_all => _('Use stripes in all tree view components'),
105     h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
106     l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
107     h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
108     l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
109     h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
110     l_gui_margin_co => _('Show compose margin'),
111     h_gui_margin_co => _('Shows a small margin in the Compose View.'),
112     l_gui_mview_date => _('Don\'t display localized date'),
113     h_gui_mview_date => _('Toggles localization of date format in Message View'),
114
115     l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
116     h_beh_hover_t => _('Time in milliseconds that will cause a folder tree to expand when the mouse cursor is held over it during drag and drop.'),
117     l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
118     h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
119     l_beh_flowed => _('Respect format=flowed in messages'),
120     h_beh_flowed => _('Respect format=flowed on text/plain message parts. This will cause some mails to have long lines, but will fix some URLs that would otherwise be wrapped.'),
121     l_beh_parts_rw => _('Allow writable temporary files'),
122     h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
123     l_beh_skip_ssl => _('Don\'t check SSL certificates'),
124     h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
125     l_beh_up_step => _('Progress bar update step (items)'),
126     h_beh_up_step => _('Update stepping in progress bars.'),
127     l_beh_thread_a => _('Maximum age when threading by subject (days)'),
128     h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
129     l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
130     h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
131     l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
132     h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
133     l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
134     h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
135     l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
136     h_beh_out_ascii => _('If content allows, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is enforced always.'),
137     l_beh_pp_unsel => _('Primary paste unselects selection'),
138     h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
139     l_beh_inline_at => _('Show inline attachments'),
140     h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view'),
141
142     l_col_emphasis => _('X-Mailer header'),
143     h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
144     l_col_log_err => _('Error messages'),
145     h_col_log_err => _('Colour for error messages in log window.'),
146     l_col_log_in => _('Server messages'),
147     h_col_log_in => _('Colour for messages received from servers in log window.'),
148     l_col_log_msg => _('Standard messages'),
149     h_col_log_msg => _('Colour for messages in log window.'),
150     l_col_log_out => _('Client messages'),
151     h_col_log_out => _('Colour for messages sent to servers in log window.'),
152     l_col_log_warn => _('Warnings'),
153     h_col_log_warn => _('Colour for warning messages in log window.'),
154
155     l_win_x => _('X position'),
156     h_win_x => _('X coordinate for window\'s top-left corner.'),
157     l_win_y => _('Y position'),
158     h_win_y => _('Y coordinate for window\'s top-left corner.'),
159     l_win_w => _('Width'),
160     h_win_w => _('Window\'s width in pixels.'),
161     l_win_h => _('Height'),
162     h_win_h => _('Window\'s height in pixels.'),
163
164     l_win_main_mx => _('Maximized'),
165     h_win_main_mx => _('Changes window maximized status.'),
166     l_win_main_fs => _('Full-screen'),
167     h_win_main_fs => _('Changes full screen status.'),
168
169     e_error => _('Error: '),
170     e_noclawsrc => _('resource file for Claws Mail was not found.'),
171     e_running => _('seems Claws Mail is currently running, close it first.'),
172     e_requireddir => _('option requires a directory name.'),
173     e_requiredfile => _('option requires a file name.'),
174     e_notadir => _('specified name is not a directory or does not exist.'),
175     e_notafile => _('specified name is not a file or does not exist.'),
176 );
177
178 # all preferences read by load_preferences
179 my %PREFS = ();
180 # values of all preferences handled by clawsker
181 my %HPVALUE = ();
182 # default config dir and file name
183 my $ALTCONFIGDIR = FALSE;
184 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
185 my $CONFIGRC = 'clawsrc';
186
187 # index constants for preference arrays
188 use constant NAME  => 0; # the name on the rc file
189 use constant LABEL => 1; # the label on the GUI
190 use constant DESC  => 2; # the description for the hint/help
191 use constant TYPE  => 3; # data type: bool, int, float, string, color
192 use constant CMVER => 4; # lowest Claws Mail version the feature exists
193 use constant CMDEF => 5; # default value for the preference in Claws Mail
194 use constant GUI   => 6; # GUI element
195
196 # constants for GUI spacing
197 use constant HBOX_SPC => 5;
198 use constant FRAME_SPC => 2;
199 use constant PAGE_SPC => 5;
200
201 # version functions
202
203 sub version_greater_or_equal() {
204     my ($version, $refvers) = @_;
205     my @version = split (/\./, $version);
206     my @refvers = split (/\./, $refvers);
207     while ($#version < $#refvers) {
208         push (@version, '0');
209     }
210     my $idx = 0;
211     while (($idx <= $#refvers) 
212             and (int ($version[$idx]) == int ($refvers[$idx]))) {
213         ++$idx;
214     }
215     return TRUE if (($idx > $#refvers)
216         or (int ($version[$idx]) >= int ($refvers[$idx])));
217     return FALSE;
218 }
219
220 sub get_claws_version() {
221     my @cmbin = (
222         'claws-mail',
223     );
224     my $res = "";
225     foreach my $bin (@cmbin) {
226         $_ = qx/which $bin/;
227         chomp;
228         last if ($_ ne "");
229     }
230     return "" unless ($_); # not installed
231     $_ = qx/$_ -v/;
232     chomp;
233     my @fver = split (/ /);
234     die "Invalid version string" unless ($fver[2] eq "version");
235     my @ver = split (/\./, $fver[3]);
236     $res .= "$ver[0].";
237     $res .= "$ver[1].";
238     if ($ver[2] =~ /(\d+)cvs(\d+)/) {
239         $res .= "$1.$2";
240     }
241     else {
242         $res .= "$ver[2].0";
243     }
244     return $res;
245 }
246
247 # data handlers and auxiliar functions
248
249 sub handle_bool_value {
250     my ($widget, $event, $dataref) = @_;
251     $$dataref = ($widget->get_active ())? '1': '0';
252 }
253
254 sub handle_int_value {
255     my ($widget, $event, $dataref) = @_;
256     $_ = $widget->get_text ();
257     s/^\s+//;
258     s/\s+$//;
259     if (/^[0-9]+$/) {
260         $$dataref = $_;
261         $widget->set_text ($_);
262     }
263     else {
264         $widget->set_text ($$dataref);
265     }
266 }
267
268 sub handle_string_value {
269     my ($widget, $event, $dataref) = @_;
270     $$dataref = $widget->get_text ();
271 }
272
273 sub gdk_color_from_str {
274     my ($str) = @_;
275     my ($rr, $gg, $bb) = (0, 0 ,0);
276     $_ = uc ($str);
277     if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
278         $rr = hex($1) * 256;
279         $gg = hex($2) * 256; 
280         $bb = hex($3) * 256;
281     }
282     my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
283     return $color;
284 }
285
286 sub str_from_gdk_color {
287     my ($color) = @_;
288     my $rr = $color->red / 256;
289     my $gg = $color->green / 256;
290     my $bb = $color->blue / 256;
291     my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
292     return $str;
293 }
294
295 sub handle_color_value {
296     my ($widget, $event, $dataref) = @_;
297     my $newcol = $widget->get_color;
298     $$dataref = &str_from_gdk_color ($newcol);
299 }
300
301 sub handle_selection_value {
302     my ($widget, $event, $dataref) = @_;
303     $$dataref = $widget->get_active;
304 }
305
306 sub get_rc_filename {
307     return $CONFIGDIR . $CONFIGRC;
308 }
309
310 sub set_rc_filename {
311     my ($fullname) = @_;
312     my @parts = split ('/', $fullname);
313     $CONFIGRC = $parts[$#parts];
314     $parts[$#parts] = '';
315     $CONFIGDIR = join ('/', @parts);
316 }
317
318 sub log_message {
319     my ($mesg, $fatal) = @_;
320     if (defined($fatal) && $fatal eq 'die') {
321         die "$NAME: $mesg\n";
322     }
323     if ($VERBOSE) {
324         print "$NAME: $mesg\n";
325     }
326 }
327
328 sub error_dialog {
329     my ($emsg) = @_;
330     my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
331     my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
332     $errordlg->set_title (_('Error message'));
333     $errordlg->run;
334     $errordlg->destroy;
335 }
336
337 sub check_claws_not_running() {
338     my $socket = (not $ALTCONFIGDIR)? "/tmp/": $CONFIGDIR;
339     $socket .= "claws-mail-$<";
340     -S $socket and do {
341         my $emsg = "$xl::s{e_error}$xl::s{e_running}";
342         log_message ($emsg);
343         error_dialog ($emsg);
344         return FALSE;
345      };
346      return TRUE;
347 }
348
349 sub check_rc_file() {
350     my ($rcfile) = @_;
351     (defined($rcfile) && -f $rcfile) or do {
352        my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
353         log_message ($emsg);
354         error_dialog ($emsg);
355         return FALSE;
356     };
357     return TRUE;
358 }
359
360 sub set_widget_hint() {
361     if ($SHOWHINTS) {
362         my ($wdgt, $hint) = @_;    
363         $wdgt->set_tooltip_text ($hint);
364         $wdgt->set_has_tooltip (TRUE);
365     }
366 }
367
368 sub set_widget_sens() {
369     my ($wdgt, $minver) = @_;
370     $wdgt->set_sensitive (&version_greater_or_equal ($CLAWSV, $minver));
371 }
372
373 # graphic element creation 
374
375 sub new_check_button_for {
376     my ($hash, $key) = @_;
377     my $name = $$hash{$key}[NAME];
378     my $label = $$hash{$key}[LABEL];
379     #
380     my $hbox = Gtk2::HBox->new (FALSE, 5);
381     my $cb = Gtk2::CheckButton->new ($label);
382     $$hash{$key}[GUI] = $cb;
383     if (defined ($HPVALUE{$name})) {
384         $cb->set_active ($HPVALUE{$name} eq '1');
385     }
386     $cb->signal_connect (clicked => sub {
387             my ($w, $e) = @_;
388             &handle_bool_value($w, $e, \$HPVALUE{$name});
389         });
390     &set_widget_hint ($cb, $$hash{$key}[DESC]);
391     &set_widget_sens ($cb, $$hash{$key}[CMVER]);
392     $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
393     #
394     return $hbox;
395 }
396
397 sub new_text_box_for_int {
398     my ($hash, $key) = @_;
399     my $name = $$hash{$key}[NAME];
400     my $label = $$hash{$key}[LABEL];
401     my @type = split (/,/, $$hash{$key}[TYPE]);
402     push (@type, 0), push (@type, 10000) unless ($#type > 0); 
403     #
404     my $hbox = Gtk2::HBox->new (FALSE, 5);
405     my $glabel = Gtk2::Label->new ($label);
406     my $pagei = int (($type[2] - $type[1]) / 10);
407     my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
408     $gentry->set_numeric (TRUE);
409     $gentry->set_value ($HPVALUE{$name});
410     $$hash{$key}[GUI] = $gentry;
411     $gentry->signal_connect('value-changed' => sub {
412             my ($w, $e) = @_;
413             &handle_int_value($w, $e, \$HPVALUE{$name});
414         });
415     &set_widget_hint ($gentry, $$hash{$key}[DESC]);
416     &set_widget_sens ($gentry, $$hash{$key}[CMVER]);
417     $glabel->set_sensitive ($gentry->sensitive);
418     $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
419     $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
420     #
421     return $hbox;
422 }
423
424 sub new_color_button_for {
425     my ($hash, $key) = @_;
426     my $name = $$hash{$key}[NAME];
427     my $label = $$hash{$key}[LABEL];
428     #
429     my $col = &gdk_color_from_str ($HPVALUE{$name});
430     my $hbox = Gtk2::HBox->new (FALSE, 5);
431     my $glabel = Gtk2::Label->new ($label);
432     my $button = Gtk2::ColorButton->new_with_color ($col);
433     $$hash{$key}[GUI] = $button;
434     $button->set_title ($label);
435     $button->set_relief ('none');
436     $button->signal_connect ('color-set' => sub {
437             my ($w, $e) = @_;
438             &handle_color_value($w, $e, \$HPVALUE{$name}); 
439         });
440     &set_widget_hint ($button, $$hash{$key}[DESC]);
441     &set_widget_sens ($button, $$hash{$key}[CMVER]);
442     $glabel->set_sensitive ($button->sensitive);
443     $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
444     $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
445     #
446     return $hbox;
447 }
448
449 sub new_selection_box_for {
450     my ($hash, $key) = @_;
451     my $name = $$hash{$key}[NAME];
452     my $label = $$hash{$key}[LABEL];
453     #
454     my $hbox = Gtk2::HBox->new (FALSE, 5);
455     my $glabel = Gtk2::Label->new ($label);
456     my $combo = Gtk2::ComboBox->new_text;
457     $$hash{$key}[GUI] = $combo;
458     my @options = split (';', $$hash{$key}[TYPE]);
459     foreach my $opt (@options) {
460         my ($index, $textkey) = split ('=', $opt);
461         $combo->insert_text ($index, $xl::s{$textkey});
462     }
463     $combo->signal_connect ('changed' => sub {
464             my ($w, $e) = @_;
465             &handle_selection_value($w, $e, \$HPVALUE{$name});
466         });
467     $combo->set_active ($HPVALUE{$name});
468     &set_widget_hint ($combo, $$hash{$key}[DESC]);
469     &set_widget_sens ($combo, $$hash{$key}[CMVER]);
470     $glabel->set_sensitive ($combo->sensitive);
471     $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
472     $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
473     #
474     return $hbox;
475 }
476
477 # more graphic helpers
478
479 sub new_hbox_pack() {
480     my $hbox = Gtk2::HBox->new (FALSE, 5);
481     $hbox->set_border_width (PAGE_SPC);
482     foreach my $item (@_) {
483         $hbox->pack_start ($item, FALSE, FALSE, 0);
484     }
485     return $hbox;
486 }    
487
488 sub new_vbox_pack() {
489     my $vbox = Gtk2::VBox->new (FALSE, 5);
490     $vbox->set_border_width (PAGE_SPC);
491     foreach my $item (@_) {
492         $vbox->pack_start ($item, FALSE, FALSE, 0);
493     }
494     return $vbox;
495 }    
496
497 sub new_vbox_pack_compact() {
498     my $vbox = Gtk2::VBox->new (FALSE, 0);
499     $vbox->set_border_width (0);
500     foreach my $item (@_) {
501         $vbox->pack_start ($item, FALSE, FALSE, 0);
502     }
503     return $vbox;
504 }    
505
506 sub new_subpage_frame () {
507     my ($box, $title, $notpacked) = @_;
508     my $frame = Gtk2::Frame->new ($title);
509     $frame->add ($box);    
510     return &new_vbox_pack ($frame) unless defined ($notpacked);
511     return $frame;
512 }
513
514 # preference maps and corresponding page creation subs
515
516 %pr::oth = ( # other preferences
517     use_dlg => [ 
518         'addressbook_use_editaddress_dialog',
519         $xl::s{l_oth_use_dlg},
520         $xl::s{h_oth_use_dlg},
521         'bool',
522         '2.7.0',
523         '0',
524         undef,
525     ],
526     max_use => [
527         'cache_max_mem_usage',
528         $xl::s{l_oth_max_use},
529         $xl::s{h_oth_max_use},
530         'int,0,262144', # 0 Kb - 256 Mb
531         '0.0.0',
532         '4096',
533         undef,
534     ],
535     min_time => [
536         'cache_min_keep_time',
537         $xl::s{l_oth_min_time},
538         $xl::s{h_oth_min_time},
539         'int,0,120', # 0 minutes - 2 hours
540         '0.0.0',
541         '15',
542         undef,
543     ],
544     use_netm => [
545         'use_networkmanager',
546         $xl::s{l_oth_use_netm},
547         $xl::s{h_oth_use_netm},
548         'bool',
549         '3.3.1',
550         '1',
551         undef,
552     ],
553 );
554
555 sub new_other_page() {
556     return &new_vbox_pack (
557                &new_subpage_frame (
558                    &new_vbox_pack (
559                        &new_check_button_for(\%pr::oth, 'use_dlg')),
560                    $xl::s{ab_frame}, 'not-packed'),
561                &new_subpage_frame (
562                    &new_vbox_pack (
563                        &new_text_box_for_int(\%pr::oth, 'max_use'),
564                        &new_text_box_for_int(\%pr::oth, 'min_time')),
565                    $xl::s{mem_frame}, 'not-packed'),
566                &new_subpage_frame (
567                    &new_vbox_pack (
568                        &new_check_button_for(\%pr::oth, 'use_netm')),
569                    $xl::s{netm_frame}, 'not-packed')
570            );
571 }
572
573 %pr::gui = ( # gui bells and whistles
574     b_unread => [ 
575         'bold_unread',
576         $xl::s{l_gui_b_unread},
577         $xl::s{h_gui_b_unread},
578         'bool',
579         '0.0.0',
580         '1',
581         undef,
582     ],
583     no_markup => [
584         'compose_no_markup',
585         $xl::s{l_gui_no_markup},
586         $xl::s{h_gui_no_markup},
587         'bool',
588         '0.0.0',
589         '0',
590         undef,
591     ],
592     dot_lines => [
593         'enable_dotted_lines',
594         $xl::s{l_gui_dot_lines},
595         $xl::s{h_gui_dot_lines},
596         'bool',
597         '0.0.0',
598         '0',
599         undef,
600     ],
601     h_scroll => [
602         'enable_hscrollbar',
603         $xl::s{l_gui_h_scroll},
604         $xl::s{h_gui_h_scroll},
605         'bool',
606         '0.0.0',
607         '1',
608         undef,
609     ],
610     swp_from => [
611         'enable_swap_from',
612         $xl::s{l_gui_swp_from},
613         $xl::s{h_gui_swp_from},
614         'bool',
615         '0.0.0',
616         '0',
617         undef,
618     ],
619     v_scroll => [
620         'folderview_vscrollbar_policy',
621         $xl::s{l_gui_v_scroll},
622         $xl::s{h_gui_v_scroll},
623         '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
624         '0.0.0',
625         '0',
626         undef,
627     ],
628     from_show => [
629         'summary_from_show',
630         $xl::s{l_gui_from_show},
631         $xl::s{h_gui_from_show},
632         '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
633         '3.7.10',
634         '0',
635         undef,
636     ],
637     strip_off => [
638         'stripes_color_offset',
639         $xl::s{l_gui_strip_off},
640         $xl::s{h_gui_strip_off},
641         'int,0,40000', # no idea what this number means
642         '0.0.0',
643         '4000',
644         undef,
645     ],
646     cursor_v => [
647         'textview_cursor_visible',
648         $xl::s{l_gui_cursor_v},
649         $xl::s{h_gui_cursor_v},
650         'bool',
651         '0.0.0',
652         '0',
653         undef,
654     ],
655     toolbar_d => [
656         'toolbar_detachable',
657         $xl::s{l_gui_toolbar_d},
658         $xl::s{h_gui_toolbar_d},
659         'bool',
660         '0.0.0',
661         '0',
662         undef,
663     ],
664     strip_all => [
665         'use_stripes_everywhere',
666         $xl::s{l_gui_strip_all},
667         $xl::s{h_gui_strip_all},
668         'bool',
669         '0.0.0',
670         '1',
671         undef,
672     ],
673     strip_sum => [
674         'use_stripes_in_summaries',
675         $xl::s{l_gui_strip_sum},
676         $xl::s{h_gui_strip_sum},
677         'bool',
678         '0.0.0',
679         '1',
680         undef,
681     ],
682     two_linev => [
683         'two_line_vertical',
684         $xl::s{l_gui_two_line_v},
685         $xl::s{h_gui_two_line_v},
686         'bool',
687         '3.4.0.7',
688         '0',
689         undef,
690     ],
691     margin_co => [
692         'show_compose_margin',
693         $xl::s{l_gui_margin_co},
694         $xl::s{h_gui_margin_co},
695         'bool',
696         '3.7.6.7',
697         '0',
698         undef,
699     ],
700     mview_date => [
701         'msgview_date_format',
702         $xl::s{l_gui_mview_date},
703         $xl::s{h_gui_mview_date},
704         'bool',
705         '3.7.8.42',
706         '0',
707         undef,
708     ],
709 );
710
711 sub new_gui_page() {
712     my $gf = Gtk2::VBox->new (FALSE, 5);
713     $gf->set_border_width (PAGE_SPC);
714
715     my $cb_dot_lines = &new_check_button_for (\%pr::gui, 'dot_lines'); 
716     my $cb_toolbar_d = &new_check_button_for (\%pr::gui, 'toolbar_d');
717
718     $gf->pack_start (&new_subpage_frame (
719                          &new_vbox_pack (
720                              &new_check_button_for (\%pr::gui, 'strip_all'),
721                              &new_check_button_for (\%pr::gui, 'strip_sum'),
722                              &new_text_box_for_int (\%pr::gui, 'strip_off')),
723                          $xl::s{stripes_frame}, 'not-packed'),
724                      FALSE, FALSE, FRAME_SPC);
725     $gf->pack_start (&new_subpage_frame (
726                          &new_vbox_pack (
727                              &new_check_button_for (\%pr::gui, 'b_unread'),
728                              &new_check_button_for (\%pr::gui, 'swp_from'),
729                              &new_check_button_for (\%pr::gui, 'two_linev'),
730                              &new_selection_box_for (\%pr::gui, 'from_show')),
731                          $xl::s{mlist_frame}, 'not-packed'), 
732                      FALSE, FALSE, FRAME_SPC);
733     $gf->pack_start (&new_subpage_frame (
734                          &new_hbox_pack (
735                              &new_check_button_for (\%pr::gui, 'cursor_v'),
736                              &new_check_button_for (\%pr::gui, 'mview_date')),
737                          $xl::s{mview_frame}, 'not-packed'), 
738                      FALSE, FALSE, FRAME_SPC);
739     $gf->pack_start (&new_subpage_frame (
740                          &new_hbox_pack (
741                              &new_check_button_for (\%pr::gui, 'no_markup'),
742                              &new_check_button_for (\%pr::gui, 'margin_co')),
743                          $xl::s{compo_frame}, 'not-packed'), 
744                      FALSE, FALSE, FRAME_SPC);
745     $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
746     $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
747     $gf->pack_start (&new_subpage_frame (
748                          &new_vbox_pack (
749                              &new_check_button_for (\%pr::gui, 'h_scroll'),
750                              &new_selection_box_for (\%pr::gui, 'v_scroll')),
751                          $xl::s{sbar_frame}, 'not-packed'),
752                      FALSE, FALSE, FRAME_SPC);
753
754     return $gf;
755 }
756
757 %pr::beh = ( # tweak some behaviour
758     hover_t => [
759         'hover_timeout',
760         $xl::s{l_beh_hover_t},
761         $xl::s{h_beh_hover_t},
762         'int,100,3000', # 0.1 seconds - 3 seconds
763         '0.0.0',
764         '500',
765         undef,
766     ],
767     dangerous => [
768         'live_dangerously',
769         $xl::s{l_beh_dangerous},
770         $xl::s{h_beh_dangerous},
771         'bool',
772         '0.0.0',
773         '0',
774         undef,
775     ],
776     flowed => [
777         'respect_flowed_format',
778         $xl::s{l_beh_flowed},
779         $xl::s{h_beh_flowed},
780         'bool',
781         '0.0.0',
782         '0',
783         undef,
784     ],
785     parts_rw => [
786         'save_parts_readwrite',
787         $xl::s{l_beh_parts_rw},
788         $xl::s{h_beh_parts_rw},
789         'bool',
790         '0.0.0',
791         '0',
792         undef,
793     ],
794     skip_ssl => [
795         'skip_ssl_cert_check',
796         $xl::s{l_beh_skip_ssl},
797         $xl::s{h_beh_skip_ssl},
798         'bool',
799         '0.0.0',
800         '0',
801         undef,
802     ],
803     up_step => [
804         'statusbar_update_step',
805         $xl::s{l_beh_up_step},
806         $xl::s{h_beh_up_step},
807         'int,1,200', # 1 item - 200 items
808         '0.0.0',
809         '10',
810         undef,
811     ],
812     thread_a => [
813         'thread_by_subject_max_age',
814         $xl::s{l_beh_thread_a},
815         $xl::s{h_beh_thread_a},
816         'int,1,30', # 1 day - 30 days
817         '0.0.0',
818         '10',
819         undef,
820     ],
821     unsafe_ssl => [
822         'unsafe_ssl_certs',
823         $xl::s{l_beh_unsafe_ssl},
824         $xl::s{h_beh_unsafe_ssl},
825         'bool',
826         '0.0.0',
827         '0',
828         undef,
829     ],
830     use_utf8 => [
831         'utf8_instead_of_locale_for_broken_mail',
832         $xl::s{l_beh_use_utf8},
833         $xl::s{h_beh_use_utf8},
834         'bool',
835         '0.0.0',
836         '0',
837         undef,
838     ],
839     warn_dnd => [
840         'warn_dnd',
841         $xl::s{l_beh_warn_dnd},
842         $xl::s{h_beh_warn_dnd},
843         'bool',
844         '0.0.0',
845         '1',
846         undef,
847     ],
848     out_ascii => [
849         'outgoing_fallback_to_ascii',
850         $xl::s{l_beh_out_ascii},
851         $xl::s{h_beh_out_ascii},
852         'bool',
853         '3.4.0.37',
854         '1',
855         undef,
856     ],
857     pp_unsel => [
858         'primary_paste_unselects',
859         $xl::s{l_beh_pp_unsel},
860         $xl::s{h_beh_pp_unsel},
861         'bool',
862         '3.6.1.35',
863         '0',
864         undef,
865     ],
866     inline_at => [
867         'show_inline_attachments',
868         $xl::s{l_beh_inline_at},
869         $xl::s{h_beh_inline_at},
870         'bool',
871         '3.7.8.48',
872         '1',
873         undef,
874     ],
875 );
876
877 sub new_behaviour_page() {
878     my $bf = Gtk2::VBox->new (FALSE, 5);
879     $bf->set_border_width (PAGE_SPC);
880
881     my $tb_up_step = &new_text_box_for_int (\%pr::beh, 'up_step');
882     my $tb_thread_a = &new_text_box_for_int (\%pr::beh, 'thread_a');
883
884     $bf->pack_start (&new_subpage_frame (
885                          &new_vbox_pack (
886                              &new_text_box_for_int (\%pr::beh, 'hover_t'),
887                              &new_check_button_for (\%pr::beh, 'warn_dnd')),
888                          $xl::s{dnd_frame}, 'not-packed'), 
889                      FALSE, FALSE, FRAME_SPC);
890     $bf->pack_start (&new_subpage_frame (
891                          &new_hbox_pack (
892                              &new_check_button_for (\%pr::beh, 'skip_ssl'),
893                              &new_check_button_for (\%pr::beh, 'unsafe_ssl')),
894                          $xl::s{ssl_frame}, 'not-packed'),
895                      FALSE, FALSE, FRAME_SPC);
896     $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
897     $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
898     $bf->pack_start (&new_subpage_frame (
899                          &new_vbox_pack (
900                              &new_check_button_for (\%pr::beh, 'flowed'),
901                              &new_check_button_for (\%pr::beh, 'parts_rw'),
902                              &new_check_button_for (\%pr::beh, 'use_utf8'),
903                              &new_check_button_for (\%pr::beh, 'dangerous'),
904                              &new_check_button_for (\%pr::beh, 'out_ascii'),
905                              &new_check_button_for (\%pr::beh, 'pp_unsel'),
906                              &new_check_button_for (\%pr::beh, 'inline_at')),
907                          $xl::s{msgs_frame}, 'not-packed'),
908                      FALSE, FALSE, FRAME_SPC);
909
910     return $bf;
911 }
912
913 %pr::col = ( # a variety of colours
914     emphasis => [
915         'emphasis_color',
916         $xl::s{l_col_emphasis},
917         $xl::s{h_col_emphasis},
918         'color',
919         '0.0.0',
920         '#0000cf',
921         undef,
922     ],
923     log_err => [
924         'log_error_color',
925         $xl::s{l_col_log_err},
926         $xl::s{h_col_log_err},
927         'color',
928         '0.0.0',
929         '#af0000',
930         undef,
931     ],
932     log_in => [
933         'log_in_color',
934         $xl::s{l_col_log_in},
935         $xl::s{h_col_log_in},
936         'color',
937         '0.0.0',
938         '#000000',
939         undef,
940     ],
941     log_msg => [
942         'log_msg_color',
943         $xl::s{l_col_log_msg},
944         $xl::s{h_col_log_msg},
945         'color',
946         '0.0.0',
947         '#00af00',
948         undef,
949     ],
950     log_out => [
951         'log_out_color',
952         $xl::s{l_col_log_out},
953         $xl::s{h_col_log_out},
954         'color',
955         '0.0.0',
956         '#0000ef',
957         undef,
958     ],
959     log_warn => [
960         'log_warn_color',
961         $xl::s{l_col_log_warn},
962         $xl::s{h_col_log_warn},
963         'color',
964         '0.0.0',
965         '#af0000',
966         undef,
967     ],
968 );
969
970 sub new_colours_page() {
971     return &new_vbox_pack (
972                &new_subpage_frame (
973                    &new_vbox_pack (
974                        &new_color_button_for (\%pr::col, 'emphasis')),
975                    $xl::s{msgview_frame}, 'not-packed'),
976                &new_subpage_frame (
977                    &new_vbox_pack (
978                        &new_color_button_for (\%pr::col, 'log_err'),
979                        &new_color_button_for (\%pr::col, 'log_in'),
980                        &new_color_button_for (\%pr::col, 'log_msg'),
981                        &new_color_button_for (\%pr::col, 'log_out'),
982                        &new_color_button_for (\%pr::col, 'log_warn')),
983                    $xl::s{log_frame}, 'not-packed')
984            );
985 }
986
987 %pr::win = ( # tweak window positions and/or sizes
988     main_x => [
989         'mainwin_x',
990         $xl::s{l_win_x},
991         $xl::s{h_win_x},
992         'int,0,3000', # 0 pixels - 3000 pixels
993         '0.0.0',
994         '16',
995         undef,
996     ],
997     main_y => [
998         'mainwin_y',
999         $xl::s{l_win_y},
1000         $xl::s{h_win_y},
1001         'int,0,3000', # 0 pixels - 3000 pixels
1002         '0.0.0',
1003         '16',
1004         undef,
1005     ],
1006     main_w => [
1007         'mainwin_width',
1008         $xl::s{l_win_w},
1009         $xl::s{h_win_w},
1010         'int,0,3000', # 0 pixels - 3000 pixels
1011         '0.0.0',
1012         '779',
1013         undef,
1014     ],
1015     main_h => [
1016         'mainwin_height',
1017         $xl::s{l_win_h},
1018         $xl::s{h_win_h},
1019         'int,0,3000', # 0 pixels - 3000 pixels
1020         '0.0.0',
1021         '568',
1022         undef,
1023     ],
1024     main_mx => [
1025         'mainwin_maximised',
1026         $xl::s{l_win_main_mx},
1027         $xl::s{h_win_main_mx},
1028         'bool',
1029         '0.0.0',
1030         '0',
1031         undef,
1032     ],
1033     main_fs => [
1034         'mainwin_fullscreen',
1035         $xl::s{l_win_main_fs},
1036         $xl::s{h_win_main_fs},
1037         'bool',
1038         '0.0.0',
1039         '0',
1040         undef,
1041     ],
1042     msgs_x => [
1043         'main_messagewin_x',
1044         $xl::s{l_win_x},
1045         $xl::s{h_win_x},
1046         'int,0,3000', # 0 pixels - 3000 pixels
1047         '0.0.0',
1048         '256',
1049         undef,
1050     ],
1051     msgs_y => [
1052         'main_messagewin_y',
1053         $xl::s{l_win_y},
1054         $xl::s{h_win_y},
1055         'int,0,3000', # 0 pixels - 3000 pixels
1056         '0.0.0',
1057         '210',
1058         undef,
1059     ],
1060     msgs_w => [
1061         'messagewin_width',
1062         $xl::s{l_win_w},
1063         $xl::s{h_win_w},
1064         'int,0,3000', # 0 pixels - 3000 pixels
1065         '0.0.0',
1066         '600',
1067         undef,
1068     ],
1069     msgs_h => [
1070         'messagewin_height',
1071         $xl::s{l_win_h},
1072         $xl::s{h_win_h},
1073         'int,0,3000', # 0 pixels - 3000 pixels
1074         '0.0.0',
1075         '540',
1076         undef,
1077     ],
1078     send_w => [
1079         'sendwin_width',
1080         $xl::s{l_win_w},
1081         $xl::s{h_win_w},
1082         'int,0,3000', # 0 pixels - 3000 pixels
1083         '0.0.0',
1084         '460',
1085         undef,
1086     ],
1087     send_h => [
1088         'sendwin_height',
1089         $xl::s{l_win_h},
1090         $xl::s{h_win_h},
1091         'int,0,3000', # 0 pixels - 3000 pixels
1092         '0.0.0',
1093         '-1',
1094         undef,
1095     ],
1096     recv_w => [
1097         'receivewin_width',
1098         $xl::s{l_win_w},
1099         $xl::s{h_win_w},
1100         'int,0,3000', # 0 pixels - 3000 pixels
1101         '0.0.0',
1102         '460',
1103         undef,
1104     ],
1105     recv_h => [
1106         'receivewin_height',
1107         $xl::s{l_win_h},
1108         $xl::s{h_win_h},
1109         'int,0,3000', # 0 pixels - 3000 pixels
1110         '0.0.0',
1111         '-1',
1112         undef,
1113     ],
1114     fold_x => [
1115         'folderwin_x',
1116         $xl::s{l_win_x},
1117         $xl::s{h_win_x},
1118         'int,0,3000', # 0 pixels - 3000 pixels
1119         '0.0.0',
1120         '16',
1121         undef,
1122     ],
1123     fold_y => [
1124         'folderwin_y',
1125         $xl::s{l_win_y},
1126         $xl::s{h_win_y},
1127         'int,0,3000', # 0 pixels - 3000 pixels
1128         '0.0.0',
1129         '16',
1130         undef,
1131     ],
1132     fold_w => [
1133         'folderitemwin_width',
1134         $xl::s{l_win_w},
1135         $xl::s{h_win_w},
1136         'int,0,3000', # 0 pixels - 3000 pixels
1137         '0.0.0',
1138         '500',
1139         undef,
1140     ],
1141     fold_h => [
1142         'folderitemwin_height',
1143         $xl::s{l_win_h},
1144         $xl::s{h_win_h},
1145         'int,0,3000', # 0 pixels - 3000 pixels
1146         '0.0.0',
1147         '-1',
1148         undef,
1149     ],
1150     fsel_w => [
1151         'folderselwin_width',
1152         $xl::s{l_win_w},
1153         $xl::s{h_win_w},
1154         'int,0,3000', # 0 pixels - 3000 pixels
1155         '0.0.0',
1156         '300',
1157         undef,
1158     ],
1159     fsel_h => [
1160         'folderselwin_height',
1161         $xl::s{l_win_h},
1162         $xl::s{h_win_h},
1163         'int,0,3000', # 0 pixels - 3000 pixels
1164         '0.0.0',
1165         '-1',
1166         undef,
1167     ],
1168     sour_w => [
1169         'sourcewin_width',
1170         $xl::s{l_win_w},
1171         $xl::s{h_win_w},
1172         'int,0,3000', # 0 pixels - 3000 pixels
1173         '0.0.0',
1174         '600',
1175         undef,
1176     ],
1177     sour_h => [
1178         'sourcewin_height',
1179         $xl::s{l_win_h},
1180         $xl::s{h_win_h},
1181         'int,0,3000', # 0 pixels - 3000 pixels
1182         '0.0.0',
1183         '500',
1184         undef,
1185     ],
1186     addr_w => [
1187         'addressbookwin_width',
1188         $xl::s{l_win_w},
1189         $xl::s{h_win_w},
1190         'int,0,3000', # 0 pixels - 3000 pixels
1191         '0.0.0',
1192         '520',
1193         undef,
1194     ],
1195     addr_h => [
1196         'addressbookwin_height',
1197         $xl::s{l_win_h},
1198         $xl::s{h_win_h},
1199         'int,0,3000', # 0 pixels - 3000 pixels
1200         '0.0.0',
1201         '-1',
1202         undef,
1203     ],
1204     adep_w => [
1205         'addressbookeditpersonwin_width',
1206         $xl::s{l_win_w},
1207         $xl::s{h_win_w},
1208         'int,0,3000', # 0 pixels - 3000 pixels
1209         '0.0.0',
1210         '640',
1211         undef,
1212     ],
1213     adep_h => [
1214         'addressbookeditpersonwin_height',
1215         $xl::s{l_win_h},
1216         $xl::s{h_win_h},
1217         'int,0,3000', # 0 pixels - 3000 pixels
1218         '0.0.0',
1219         '320',
1220         undef,
1221     ],
1222     adeg_w => [
1223         'addressbookeditgroupwin_width',
1224         $xl::s{l_win_w},
1225         $xl::s{h_win_w},
1226         'int,0,3000', # 0 pixels - 3000 pixels
1227         '0.0.0',
1228         '580',
1229         undef,
1230     ],
1231     adeg_h => [
1232         'addressbookeditgroupwin_height',
1233         $xl::s{l_win_h},
1234         $xl::s{h_win_h},
1235         'int,0,3000', # 0 pixels - 3000 pixels
1236         '0.0.0',
1237         '340',
1238         undef,
1239     ],
1240     adda_w => [
1241         'addressaddwin_width',
1242         $xl::s{l_win_w},
1243         $xl::s{h_win_w},
1244         'int,0,3000', # 0 pixels - 3000 pixels
1245         '0.0.0',
1246         '300',
1247         undef,
1248     ],
1249     adda_h => [
1250         'addressaddwin_height',
1251         $xl::s{l_win_h},
1252         $xl::s{h_win_h},
1253         'int,0,3000', # 0 pixels - 3000 pixels
1254         '0.0.0',
1255         '-1',
1256         undef,
1257     ],
1258     addf_w => [
1259         'addressbook_folderselwin_width',
1260         $xl::s{l_win_w},
1261         $xl::s{h_win_w},
1262         'int,0,3000', # 0 pixels - 3000 pixels
1263         '0.0.0',
1264         '300',
1265         undef,
1266     ],
1267     addf_h => [
1268         'addressbook_folderselwin_height',
1269         $xl::s{l_win_h},
1270         $xl::s{h_win_h},
1271         'int,0,3000', # 0 pixels - 3000 pixels
1272         '0.0.0',
1273         '-1',
1274         undef,
1275     ],
1276     acce_w => [
1277         'editaccountwin_width',
1278         $xl::s{l_win_w},
1279         $xl::s{h_win_w},
1280         'int,0,3000', # 0 pixels - 3000 pixels
1281         '0.0.0',
1282         '500',
1283         undef,
1284     ],
1285     acce_h => [
1286         'editaccountwin_height',
1287         $xl::s{l_win_h},
1288         $xl::s{h_win_h},
1289         'int,0,3000', # 0 pixels - 3000 pixels
1290         '0.0.0',
1291         '-1',
1292         undef,
1293     ],
1294     acco_w => [
1295         'accountswin_width',
1296         $xl::s{l_win_w},
1297         $xl::s{h_win_w},
1298         'int,0,3000', # 0 pixels - 3000 pixels
1299         '0.0.0',
1300         '500',
1301         undef,
1302     ],
1303     acco_h => [
1304         'accountswin_height',
1305         $xl::s{l_win_h},
1306         $xl::s{h_win_h},
1307         'int,0,3000', # 0 pixels - 3000 pixels
1308         '0.0.0',
1309         '-1',
1310         undef,
1311     ],
1312     filt_w => [
1313         'filteringwin_width',
1314         $xl::s{l_win_w},
1315         $xl::s{h_win_w},
1316         'int,0,3000', # 0 pixels - 3000 pixels
1317         '0.0.0',
1318         '500',
1319         undef,
1320     ],
1321     filt_h => [
1322         'filteringwin_height',
1323         $xl::s{l_win_h},
1324         $xl::s{h_win_h},
1325         'int,0,3000', # 0 pixels - 3000 pixels
1326         '0.0.0',
1327         '-1',
1328         undef,
1329     ],
1330     fila_w => [
1331         'filteringactionwin_width',
1332         $xl::s{l_win_w},
1333         $xl::s{h_win_w},
1334         'int,0,3000', # 0 pixels - 3000 pixels
1335         '0.0.0',
1336         '490',
1337         undef,
1338     ],
1339     fila_h => [
1340         'filteringactionwin_height',
1341         $xl::s{l_win_h},
1342         $xl::s{h_win_h},
1343         'int,0,3000', # 0 pixels - 3000 pixels
1344         '0.0.0',
1345         '-1',
1346         undef,
1347     ],
1348     fild_w => [
1349         'filtering_debugwin_width',
1350         $xl::s{l_win_w},
1351         $xl::s{h_win_w},
1352         'int,0,3000', # 0 pixels - 3000 pixels
1353         '0.0.0',
1354         '600',
1355         undef,
1356     ],
1357     fild_h => [
1358         'filtering_debugwin_height',
1359         $xl::s{l_win_h},
1360         $xl::s{h_win_h},
1361         'int,0,3000', # 0 pixels - 3000 pixels
1362         '0.0.0',
1363         '-1',
1364         undef,
1365     ],
1366     matc_w => [
1367         'matcherwin_width',
1368         $xl::s{l_win_w},
1369         $xl::s{h_win_w},
1370         'int,0,3000', # 0 pixels - 3000 pixels
1371         '0.0.0',
1372         '520',
1373         undef,
1374     ],
1375     matc_h => [
1376         'matcherwin_height',
1377         $xl::s{l_win_h},
1378         $xl::s{h_win_h},
1379         'int,0,3000', # 0 pixels - 3000 pixels
1380         '0.0.0',
1381         '-1',
1382         undef,
1383     ],
1384     pref_w => [
1385         'prefswin_width',
1386         $xl::s{l_win_w},
1387         $xl::s{h_win_w},
1388         'int,0,3000', # 0 pixels - 3000 pixels
1389         '0.0.0',
1390         '600',
1391         undef,
1392     ],
1393     pref_h => [
1394         'prefswin_height',
1395         $xl::s{l_win_h},
1396         $xl::s{h_win_h},
1397         'int,0,3000', # 0 pixels - 3000 pixels
1398         '0.0.0',
1399         '-1',
1400         undef,
1401     ],
1402     temp_w => [
1403         'templateswin_width',
1404         $xl::s{l_win_w},
1405         $xl::s{h_win_w},
1406         'int,0,3000', # 0 pixels - 3000 pixels
1407         '0.0.0',
1408         '480',
1409         undef,
1410     ],
1411     temp_h => [
1412         'templateswin_height',
1413         $xl::s{l_win_h},
1414         $xl::s{h_win_h},
1415         'int,0,3000', # 0 pixels - 3000 pixels
1416         '0.0.0',
1417         '-1',
1418         undef,
1419     ],
1420     acti_w => [
1421         'actionswin_width',
1422         $xl::s{l_win_w},
1423         $xl::s{h_win_w},
1424         'int,0,3000', # 0 pixels - 3000 pixels
1425         '0.0.0',
1426         '486',
1427         undef,
1428     ],
1429     acti_h => [
1430         'actionswin_height',
1431         $xl::s{l_win_h},
1432         $xl::s{h_win_h},
1433         'int,0,3000', # 0 pixels - 3000 pixels
1434         '0.0.0',
1435         '-1',
1436         undef,
1437     ],
1438     tags_w => [
1439         'tagswin_width',
1440         $xl::s{l_win_w},
1441         $xl::s{h_win_w},
1442         'int,0,3000', # 0 pixels - 3000 pixels
1443         '0.0.0',
1444         '486',
1445         undef,
1446     ],
1447     tags_h => [
1448         'tagswin_height',
1449         $xl::s{l_win_h},
1450         $xl::s{h_win_h},
1451         'int,0,3000', # 0 pixels - 3000 pixels
1452         '0.0.0',
1453         '-1',
1454         undef,
1455     ],
1456     plug_w => [
1457         'pluginswin_width',
1458         $xl::s{l_win_w},
1459         $xl::s{h_win_w},
1460         'int,0,3000', # 0 pixels - 3000 pixels
1461         '0.0.0',
1462         '-1',
1463         undef,
1464     ],
1465     plug_h => [
1466         'pluginswin_height',
1467         $xl::s{l_win_h},
1468         $xl::s{h_win_h},
1469         'int,0,3000', # 0 pixels - 3000 pixels
1470         '0.0.0',
1471         '-1',
1472         undef,
1473     ],
1474     logw_w => [
1475         'logwin_width',
1476         $xl::s{l_win_w},
1477         $xl::s{h_win_w},
1478         'int,0,3000', # 0 pixels - 3000 pixels
1479         '0.0.0',
1480         '520',
1481         undef,
1482     ],
1483     logw_h => [
1484         'logwin_height',
1485         $xl::s{l_win_h},
1486         $xl::s{h_win_h},
1487         'int,0,3000', # 0 pixels - 3000 pixels
1488         '0.0.0',
1489         '-1',
1490         undef,
1491     ],
1492     prin_w => [
1493         'print_previewwin_width',
1494         $xl::s{l_win_w},
1495         $xl::s{h_win_w},
1496         'int,0,3000', # 0 pixels - 3000 pixels
1497         '0.0.0',
1498         '600',
1499         undef,
1500     ],
1501     prin_h => [
1502         'print_previewwin_height',
1503         $xl::s{l_win_h},
1504         $xl::s{h_win_h},
1505         'int,0,3000', # 0 pixels - 3000 pixels
1506         '0.0.0',
1507         '-1',
1508         undef,
1509     ],
1510 );
1511
1512 sub new_winpos_subpage_main() {
1513     return &new_subpage_frame (
1514                &new_vbox_pack_compact (
1515                    &new_vbox_pack (
1516                        &new_text_box_for_int (\%pr::win, 'main_x'), 
1517                        &new_text_box_for_int (\%pr::win, 'main_y')), 
1518                    &new_hbox_pack (
1519                        &new_text_box_for_int (\%pr::win, 'main_w'), 
1520                        &new_text_box_for_int (\%pr::win, 'main_h')), 
1521                    &new_vbox_pack (
1522                        &new_check_button_for (\%pr::win, 'main_fs'), 
1523                        &new_check_button_for (\%pr::win, 'main_mx'))),
1524                _('Main window')
1525            );
1526 }
1527
1528 sub new_winpos_subpage_msgs() {
1529     return &new_subpage_frame (
1530                &new_vbox_pack_compact (
1531                    &new_vbox_pack (
1532                        &new_text_box_for_int (\%pr::win, 'msgs_x'),
1533                        &new_text_box_for_int (\%pr::win, 'msgs_y')),
1534                    &new_hbox_pack (
1535                        &new_text_box_for_int (\%pr::win, 'msgs_w'),
1536                        &new_text_box_for_int (\%pr::win, 'msgs_h'))),
1537                _('Message window')
1538            );
1539 }
1540
1541 sub new_winpos_subpage_sendrecv() {
1542     return &new_vbox_pack (
1543                &new_subpage_frame (
1544                    &new_hbox_pack (
1545                        &new_text_box_for_int (\%pr::win, 'send_w'),
1546                        &new_text_box_for_int (\%pr::win, 'send_h')),
1547                    _('Send window'), 'not-packed'),
1548                &new_subpage_frame (
1549                    &new_hbox_pack (
1550                        &new_text_box_for_int (\%pr::win, 'recv_w'),
1551                        &new_text_box_for_int (\%pr::win, 'recv_h')),
1552                    _('Receive window'), 'not-packed')
1553            );
1554 }
1555
1556 sub new_winpos_subpage_fold() {
1557     return &new_vbox_pack (
1558                &new_subpage_frame (
1559                    &new_vbox_pack_compact (
1560                        &new_vbox_pack (
1561                             &new_text_box_for_int (\%pr::win, 'fold_x'), 
1562                             &new_text_box_for_int (\%pr::win, 'fold_y')), 
1563                        &new_hbox_pack (
1564                            &new_text_box_for_int (\%pr::win, 'fold_w'), 
1565                            &new_text_box_for_int (\%pr::win, 'fold_h'))),
1566                    _('Folder window'), 'not-packed'),
1567                &new_subpage_frame (
1568                    &new_hbox_pack (
1569                        &new_text_box_for_int (\%pr::win, 'fsel_w'),
1570                        &new_text_box_for_int (\%pr::win, 'fsel_h')),
1571                    _('Folder selection window'), 'not-packed')
1572            );
1573 }
1574
1575 sub new_winpos_subpage_addrbook() {
1576     return &new_vbox_pack (
1577                 &new_subpage_frame (
1578                      &new_hbox_pack (
1579                           &new_text_box_for_int (\%pr::win, 'addr_w'),
1580                           &new_text_box_for_int (\%pr::win, 'addr_h')),
1581                      _('Addressbook main window'), 'not-packed'),
1582                 &new_subpage_frame (
1583                      &new_hbox_pack (
1584                           &new_text_box_for_int (\%pr::win, 'adep_w'),
1585                           &new_text_box_for_int (\%pr::win, 'adep_h')),
1586                      _('Edit person window'), 'not-packed'),
1587                 &new_subpage_frame (
1588                      &new_hbox_pack (
1589                           &new_text_box_for_int (\%pr::win, 'adeg_w'),
1590                           &new_text_box_for_int (\%pr::win, 'adeg_h')),
1591                      _('Edit group window'), 'not-packed'),
1592                 &new_subpage_frame (
1593                      &new_hbox_pack (
1594                           &new_text_box_for_int (\%pr::win, 'adda_w'),
1595                           &new_text_box_for_int (\%pr::win, 'adda_h')),
1596                      _('Add address window'), 'not-packed'),
1597                 &new_subpage_frame (
1598                      &new_hbox_pack (
1599                           &new_text_box_for_int (\%pr::win, 'addf_w'),
1600                           &new_text_box_for_int (\%pr::win, 'addf_h')),
1601                      _('Folder select window'), 'not-packed')
1602            );
1603 }
1604
1605 sub new_winpos_subpage_accounts() {
1606     return &new_vbox_pack (
1607                 &new_subpage_frame (
1608                      &new_hbox_pack (
1609                           &new_text_box_for_int (\%pr::win, 'acco_w'),
1610                           &new_text_box_for_int (\%pr::win, 'acco_h')),
1611                      _('Accounts window'), 'not-packed'),
1612                 &new_subpage_frame (
1613                      &new_hbox_pack (
1614                           &new_text_box_for_int (\%pr::win, 'acce_w'),
1615                           &new_text_box_for_int (\%pr::win, 'acce_h')),
1616                      _('Edit account window'), 'not-packed')
1617            );
1618 }
1619
1620 sub new_winpos_subpage_filtering() {
1621     return &new_vbox_pack (
1622                 &new_subpage_frame (
1623                      &new_hbox_pack (
1624                           &new_text_box_for_int (\%pr::win, 'filt_w'),
1625                           &new_text_box_for_int (\%pr::win, 'filt_h')),
1626                      _('Filtering window'), 'not-packed'),
1627                 &new_subpage_frame (
1628                      &new_hbox_pack (
1629                           &new_text_box_for_int (\%pr::win, 'fila_w'),
1630                           &new_text_box_for_int (\%pr::win, 'fila_h')),
1631                      _('Filtering actions window'), 'not-packed'),
1632                 &new_subpage_frame (
1633                      &new_hbox_pack (
1634                           &new_text_box_for_int (\%pr::win, 'fild_w'),
1635                           &new_text_box_for_int (\%pr::win, 'fild_h')),
1636                      _('Filtering debug window'), 'not-packed'),
1637                 &new_subpage_frame (
1638                      &new_hbox_pack (
1639                           &new_text_box_for_int (\%pr::win, 'matc_w'),
1640                           &new_text_box_for_int (\%pr::win, 'matc_h')),
1641                      _('Matcher window'), 'not-packed')
1642            );
1643 }
1644
1645 sub new_winpos_subpage_prefs() {
1646     return &new_vbox_pack (
1647                 &new_subpage_frame (
1648                      &new_hbox_pack (
1649                           &new_text_box_for_int (\%pr::win, 'pref_w'),
1650                           &new_text_box_for_int (\%pr::win, 'pref_h')),
1651                      _('Preferences window'), 'not-packed'),
1652                 &new_subpage_frame (
1653                      &new_hbox_pack (
1654                           &new_text_box_for_int (\%pr::win, 'temp_w'),
1655                           &new_text_box_for_int (\%pr::win, 'temp_h')),
1656                      _('Templates window'), 'not-packed'),
1657                 &new_subpage_frame (
1658                      &new_hbox_pack (
1659                           &new_text_box_for_int (\%pr::win, 'acti_w'),
1660                           &new_text_box_for_int (\%pr::win, 'acti_h')),
1661                      _('Actions window'), 'not-packed'),
1662                 &new_subpage_frame (
1663                      &new_hbox_pack (
1664                           &new_text_box_for_int (\%pr::win, 'tags_w'),
1665                           &new_text_box_for_int (\%pr::win, 'tags_h')),
1666                      _('Tags window'), 'not-packed'),
1667                 &new_subpage_frame (
1668                      &new_hbox_pack (
1669                           &new_text_box_for_int (\%pr::win, 'plug_w'),
1670                           &new_text_box_for_int (\%pr::win, 'plug_h')),
1671                      _('Plugins window'), 'not-packed')
1672            );
1673 }
1674
1675 sub new_winpos_subpage_misc() {
1676     return &new_vbox_pack (
1677                 &new_subpage_frame (
1678                      &new_hbox_pack (
1679                           &new_text_box_for_int (\%pr::win, 'logw_w'),
1680                           &new_text_box_for_int (\%pr::win, 'logw_h')),
1681                      _('Log window'), 'not-packed'),
1682                 &new_subpage_frame (
1683                      &new_hbox_pack (
1684                           &new_text_box_for_int (\%pr::win, 'prin_w'),
1685                           &new_text_box_for_int (\%pr::win, 'prin_h')),
1686                      _('Print preview window'), 'not-packed'),
1687                 &new_subpage_frame (
1688                      &new_hbox_pack (
1689                           &new_text_box_for_int (\%pr::win, 'sour_w'),
1690                           &new_text_box_for_int (\%pr::win, 'sour_h')),
1691                      _('View source window'), 'not-packed')
1692            );
1693 }
1694
1695 sub new_winpos_page() {
1696     my $winbook = Gtk2::Notebook->new;
1697     $winbook->set_tab_pos ('right');
1698     $winbook->append_page (&new_winpos_subpage_main, _('Main'));
1699     $winbook->append_page (&new_winpos_subpage_msgs, _('Message'));
1700     $winbook->append_page (&new_winpos_subpage_sendrecv, _('Send/Receive'));
1701     $winbook->append_page (&new_winpos_subpage_fold, _('Folder'));
1702     $winbook->append_page (&new_winpos_subpage_addrbook, _('Addressbook'));
1703     $winbook->append_page (&new_winpos_subpage_accounts, _('Accounts'));
1704     $winbook->append_page (&new_winpos_subpage_filtering, _('Filtering'));
1705     $winbook->append_page (&new_winpos_subpage_prefs, _('Preferences'));
1706     $winbook->append_page (&new_winpos_subpage_misc, _('Other'));
1707     return $winbook;
1708 }
1709
1710 # version info
1711 sub print_version() {
1712     print $xl::s{about_title} . "\n";
1713     print $xl::s{about_version} . " $VERSION\n";
1714     print "Perl-GLib " . $Glib::VERSION;
1715     # version info stuff appeared in 1.040
1716     if ($Glib::VERSION >= 1.040) {
1717         print _(", built for ") . join(".", Glib->GET_VERSION_INFO) 
1718               . _(", running with ") . join(".", &Glib::major_version, 
1719               &Glib::minor_version, &Glib::micro_version);
1720     }
1721     print "\n";
1722     print "Perl-GTK2 " . $Gtk2::VERSION;
1723     if ($Gtk2::VERSION >= 1.040) {
1724         print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
1725               . _(", running with ") . join(".", &Gtk2::major_version, 
1726               &Gtk2::minor_version, &Gtk2::micro_version);
1727     }
1728     print "\n";
1729     my $clawsver = ($CLAWSV eq "") ? 
1730                 _("was not found!") : 
1731                 (_("returned version ") . $CLAWSV);
1732     print "Claws Mail " . $clawsver . "\n";
1733 }
1734
1735 # the command line help
1736 sub print_help() {
1737     my $line = '-' x length ($xl::s{about_title}) . "\n";
1738     print $line;
1739     print $xl::s{about_title} . "\n";
1740     print $line;
1741     print _("Syntax:\n");
1742     print _("    clawsker [options]\n");
1743     print _("Options:\n");
1744     print _("    --help                         Prints this help screen.\n");
1745     print _("    --version                      Prints version infos.\n");
1746     print _("    --verbose                      More messages on standard output.\n");
1747     print _("    --alternate-config-dir <dir>   Uses <dir> as Claws Mail config dir.\n");
1748     print _("    --clawsrc <file>               Uses <file> as full resource name.\n");
1749 }
1750
1751 # handle errors which don't allow to run
1752 sub command_line_fatal() {
1753     my $reason = shift;
1754     my $emsg = $xl::s{e_error} . $reason;
1755     error_dialog ($emsg);
1756     log_message ("$emsg", 'die');
1757 }
1758
1759 # parse the command line
1760 sub parse_command_line() {
1761     $CLAWSV = &get_claws_version;
1762     my $arg = 0;
1763     while (defined($ARGV[$arg])) {
1764         for ($ARGV[$arg]) {
1765             /--help/ && do { 
1766                 &print_help; 
1767                 return FALSE;
1768             };
1769             /--version/ && do { 
1770                 &print_version; 
1771                 return FALSE;
1772             };
1773             /--verbose/ && do {
1774                 $VERBOSE = TRUE;
1775                 last;
1776             };
1777             /--use-claws-version/ && do {
1778                 ++$arg;
1779                 &command_line_fatal ("required version")
1780                     unless defined($ARGV[$arg]);
1781                 &command_line_fatal ("required a dotted numeric value")
1782                     unless ($ARGV[$arg] =~ /[\d\.]+/);
1783                 $CLAWSV = $ARGV[$arg];
1784                 last;
1785             };
1786             /--alternate-config-dir/ && do {
1787                 ++$arg;
1788                 &command_line_fatal ($xl::s{e_requireddir})
1789                     unless defined($ARGV[$arg]);
1790                 &command_line_fatal ($xl::s{e_notadir})
1791                     unless -d $ARGV[$arg];
1792                 $CONFIGDIR = $ARGV[$arg];
1793                 $CONFIGDIR .= "/" 
1794                     unless ($CONFIGDIR =~ /.*\/$/);
1795                 $ALTCONFIGDIR = TRUE;
1796                 last;
1797             };
1798             /--clawsrc/ && do {
1799                 ++$arg;
1800                 &command_line_fatal($xl::s{e_requiredfile}) 
1801                     unless defined($ARGV[$arg]);
1802                 &command_line_fatal($xl::s{e_notafile}) 
1803                     unless -f $ARGV[$arg];
1804                 &set_rc_filename ($ARGV[$arg]);
1805                 last;
1806             };
1807             /.*/ && &command_line_fatal (
1808                 _("unknown option '{opt}'.\n", opt => $ARGV[$arg]));
1809         }
1810         ++$arg;
1811     }
1812     # eveything continues...
1813     return TRUE;
1814 }
1815
1816 # update the hidden preferences status from loaded values
1817 sub init_hidden_preferences() {
1818     foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
1819         foreach my $key (keys %$hash) { 
1820             $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
1821         }
1822     }
1823     return TRUE;
1824 }
1825
1826 # load current status from disc
1827 sub load_preferences() {
1828     my $rc = &get_rc_filename;
1829     &log_message ("Loading preferences from $rc\n");
1830     return FALSE unless &check_rc_file ($rc);
1831     return FALSE unless &check_claws_not_running;
1832     open (RCF, "<$rc");
1833     while (<RCF>) {
1834         chomp;
1835         if (/^([8a-z_]+)=(.*)$/) {
1836             $PREFS{$1} = "$2";
1837         }
1838     }
1839     close (RCF);
1840     return TRUE;
1841 }
1842
1843 # save current preferences to disc
1844 sub save_preferences() {
1845     my $rc = &get_rc_filename;
1846     &log_message ("Saving preferences to $rc\n");
1847     return FALSE unless &check_rc_file ($rc);
1848     return FALSE unless &check_claws_not_running;
1849     my $rcbak = "$rc.backup";
1850     rename ($rc, $rcbak);
1851     open (RCF, ">$rc");
1852     open (RCB, "<$rcbak");
1853     while (<RCB>) {
1854         chomp;
1855         if (/^([8a-z_]+)=(.*)$/) {
1856             if (defined($HPVALUE{$1})) {
1857                 print RCF $1 . "=" . $HPVALUE{$1} . "\n";
1858             }
1859             else {
1860                 print RCF $_ . "\n";
1861             }
1862         }
1863         else {
1864             print RCF $_ . "\n";
1865         }
1866     }
1867     close (RCB);
1868     close (RCF);
1869     return TRUE;
1870 }
1871
1872 # create notebook
1873 sub new_notebook() {
1874     my $nb = Gtk2::Notebook->new;
1875     # 
1876     $nb->append_page (&new_behaviour_page, $xl::s{tab_behaviour});
1877     $nb->append_page (&new_colours_page, $xl::s{tab_colours});
1878     $nb->append_page (&new_gui_page, $xl::s{tab_gui});
1879     $nb->append_page (&new_other_page, $xl::s{tab_other});
1880     $nb->append_page (&new_winpos_page, $xl::s{tab_winpos});
1881
1882     return $nb;
1883 }
1884
1885 # create an about dialog
1886 sub new_about_dialog() {
1887     my ($parent) = @_;
1888     my $title = $xl::s{about_title};
1889     my $lic = $xl::s{about_license};
1890     my $vers = $xl::s{about_version} . " $VERSION";
1891     my $license = 
1892 "This program is free software: you can redistribute it and/or modify
1893 it under the terms of the GNU General Public License as published by
1894 the Free Software Foundation, either version 3 of the License, or
1895 (at your option) any later version.
1896
1897 This program is distributed in the hope that it will be useful,
1898 but WITHOUT ANY WARRANTY; without even the implied warranty of
1899 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1900 GNU General Public License for more details.
1901
1902 You should have received a copy of the GNU General Public License
1903 along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.";
1904     my $year = "2007-2011";
1905     my $holder = "Ricardo Mones &lt;ricardo\@mones.org&gt;";
1906     my $url = "http://www.claws-mail.org/clawsker";
1907
1908     my $dialog = Gtk2::MessageDialog->new_with_markup ($parent, 
1909                     [qw/modal destroy-with-parent/], 
1910                     'info', 'close', 
1911                     "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
1912                     . "<span size=\"large\">$vers</span>\n\n"
1913                     . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
1914                     . "<span>Copyright $year by $holder</span>\n\n"
1915                     . "<span size=\"large\">$lic</span>\n\n"
1916                     . "<span size=\"small\">$license</span>");
1917     $dialog->set_title ($xl::s{about});
1918     #
1919     return $dialog;
1920 }
1921
1922 # create buttons box
1923 sub new_button_box() {
1924     my ($parent, $adlg) = @_;
1925     my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
1926     my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
1927     my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
1928     # disable button until is really implemented
1929     # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
1930     my $hbox = Gtk2::HBox->new (FALSE, 5);
1931     # signal handlers 
1932     $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
1933     $b_apply->signal_connect (clicked => sub { &save_preferences ($parent) });
1934     # $b_undo->signal_connect (clicked => sub { &undo_current_changes });
1935     $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
1936     # package them
1937     $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
1938     $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
1939     # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
1940     $hbox->pack_start ($b_about, FALSE, FALSE, 0);
1941     #
1942     return $hbox;
1943 }
1944
1945 # initialise
1946 $main_window = Gtk2::Window->new ('toplevel');
1947 exit unless &parse_command_line;
1948 exit unless &load_preferences;
1949 exit unless &init_hidden_preferences;
1950 # create main GUI
1951 my $box = Gtk2::VBox->new (FALSE, 5);
1952 $box->set_border_width(3);
1953 my $about = &new_about_dialog;
1954 $box->pack_start (&new_notebook, FALSE, FALSE, 0);
1955 $box->pack_end (&new_button_box ($main_window, $about), FALSE, FALSE, 0);
1956 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
1957 $main_window->set_title ($xl::s{win_title});
1958 $main_window->add ($box);
1959 $main_window->show_all;
1960 Gtk2->main;
1961