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