3 # Clawsker :: A Claws Mail Tweaker
4 # Copyright 2007-2016 Ricardo Mones <ricardo@mones.org>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # See COPYING file for license details.
12 # See AUTHORS file for a complete list of contributors.
15 binmode STDOUT, ":encoding(utf8)";
20 use Glib qw(TRUE FALSE);
22 use POSIX qw(setlocale);
25 use Digest::MD5 qw(md5_hex);
28 my $NAME = 'clawsker';
29 my $PREFIX = '@PREFIX@';
30 my $LIBDIR = '@LIBDIR@';
31 my $DATADIR = '@DATADIR@';
32 my $VERSION = '@VERSION@';
36 my $main_window = undef;
38 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
39 $locale = "C" unless defined($locale);
40 setlocale (LC_ALL, $locale);
41 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
44 my $SHOWHINTS = FALSE;
45 $SHOWHINTS = TRUE if ($Gtk2::VERSION >= 1.040 and Gtk2->CHECK_VERSION (2, 12, 0));
50 my $xla = gettext ($str);
51 if (scalar(keys(%par)) > 0) {
52 foreach my $key (keys %par) {
53 $xla =~ s/\{$key\}/$par{$key}/g;
56 return decode_utf8($xla);
61 win_title => _('Claws Mail Hidden Preferences'),
62 about => _('About...'),
63 about_title => _('Clawsker :: A Claws Mail Tweaker'),
64 about_license => _('License:'),
65 about_version => _('Version:'),
67 tab_colours => _('Colours'),
68 tab_behaviour => _('Behaviour'),
70 tab_other => _('Other'),
71 tab_winpos => _('Windows'),
72 tab_accounts => _('Accounts'),
74 ab_frame => _('Addressbook'),
75 mem_frame => _('Memory'),
76 msgview_frame => _('Message View'),
77 log_frame => _('Log window'),
78 dnd_frame => _('Drag \'n\' drop'),
79 ssl_frame => _('Secure Sockets Layer'),
80 msgs_frame => _('Messages'),
81 swc_frame => _('Completion'),
82 stripes_frame => _('Coloured stripes'),
83 sbar_frame => _('Scroll bars'),
84 mlist_frame => _('Message List'),
85 mview_frame => _('Message View'),
86 compo_frame => _('Compose window'),
87 netm_frame => _('NetworkManager'),
88 diff_frame => _('Viewing patches'),
89 mpass_frame => _('Master passphrase'),
91 l_oth_use_dlg => _('Use detached address book edit dialogue'),
92 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.'),
93 l_oth_max_use => _('Maximum memory for message cache (kB)'),
94 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
95 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
96 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.'),
97 l_oth_use_netm => _('Use NetworkManager'),
98 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
99 l_oth_mp_rounds => _('Rounds for PBKDF2 function'),
100 h_oth_mp_rounds => _('Specify the number of iterations the key derivation function will be applied on master passphrase computation. Does not modify currently stored passphrase, only master passphrases computed after changing this value are affected.'),
102 l_gui_b_unread => _('Show unread messages with bold font'),
103 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
104 l_gui_no_markup => _('Don\'t use markup'),
105 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
106 l_gui_dot_lines => _('Use dotted lines in tree view components'),
107 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.'),
108 l_gui_h_scroll => _('Enable horizontal scrollbar'),
109 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
110 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
111 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.'),
112 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
113 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
114 l_gui_v_scroll_show => _('Show always'),
115 l_gui_v_scroll_auto => _('Automatic'),
116 l_gui_v_scroll_hide => _('Hide always'),
117 l_gui_from_show => _('From column displays'),
118 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both.'),
119 l_gui_from_show_name => _('Name only'),
120 l_gui_from_show_addr => _('Address only'),
121 l_gui_from_show_both => _('Both name and address'),
122 l_gui_strip_off => _('Coloured lines contrast'),
123 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.'),
124 l_gui_cursor_v => _('Show cursor'),
125 h_gui_cursor_v => _('Display the cursor in the Message View.'),
126 l_gui_toolbar_d => _('Detachable toolbars'),
127 h_gui_toolbar_d => _('Show handles in the toolbars.'),
128 l_gui_strip_all => _('Use stripes in all tree view components'),
129 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
130 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
131 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
132 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
133 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
134 l_gui_margin_co => _('Show margin'),
135 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
136 l_gui_mview_date => _('Don\'t display localized date'),
137 h_gui_mview_date => _('Toggles localization of date format in Message View.'),
138 l_gui_zero_char => _('Zero replacement character'),
139 h_gui_zero_char => _('Replaces \'0\' with the given character in Folder List.'),
140 l_gui_type_any => _('Editable headers'),
141 h_gui_type_any => _('Allows to manually type any value in Compose Window header entries or just select from the available choices in the associated dropdown list.'),
142 l_gui_next_del => _('Select next message on delete'),
143 h_gui_next_del => _('When deleting a message, toggles between selecting the next one (newer message) or the previous one (older message).'),
145 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
146 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.'),
147 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
148 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
149 l_beh_flowed => _('Respect format=flowed in messages'),
150 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.'),
151 l_beh_parts_rw => _('Allow writable temporary files'),
152 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
153 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
154 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
155 l_beh_up_step => _('Progress bar update step (items)'),
156 h_beh_up_step => _('Update stepping in progress bars.'),
157 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
158 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
159 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
160 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
161 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
162 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
163 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
164 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
165 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
166 h_beh_out_ascii => _('If content allows, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is enforced always.'),
167 l_beh_pp_unsel => _('Primary paste unselects selection'),
168 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
169 l_beh_inline_at => _('Show inline attachments'),
170 h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view.'),
171 l_beh_addr_swc => _('Address search in compose window matches any'),
172 h_beh_addr_swc => _('On Tab-key completion, address text will match any part of the string or only from the start.'),
173 l_beh_fold_swc => _('Folder search in folder selector matches any'),
174 h_beh_fold_swc => _('On folder name completion text will match any part of the string or only from the start.'),
176 l_col_emphasis => _('X-Mailer header'),
177 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
178 l_col_log_err => _('Error messages'),
179 h_col_log_err => _('Colour for error messages in log window.'),
180 l_col_log_in => _('Server messages'),
181 h_col_log_in => _('Colour for messages received from servers in log window.'),
182 l_col_log_msg => _('Standard messages'),
183 h_col_log_msg => _('Colour for messages in log window.'),
184 l_col_log_out => _('Client messages'),
185 h_col_log_out => _('Colour for messages sent to servers in log window.'),
186 l_col_log_warn => _('Warnings'),
187 h_col_log_warn => _('Colour for warning messages in log window.'),
189 l_col_diff_add => _('Added lines'),
190 h_col_diff_add => _('Colour for added lines in patches.'),
191 l_col_diff_del => _('Deleted lines'),
192 h_col_diff_del => _('Colour for deleted lines in patches.'),
193 l_col_diff_hunk => _('Hunk lines'),
194 h_col_diff_hunk => _('Color for hunk headers in patches.'),
196 l_win_x => _('X position'),
197 h_win_x => _('X coordinate for window\'s top-left corner.'),
198 l_win_y => _('Y position'),
199 h_win_y => _('Y coordinate for window\'s top-left corner.'),
200 l_win_w => _('Width'),
201 h_win_w => _('Window\'s width in pixels.'),
202 l_win_h => _('Height'),
203 h_win_h => _('Window\'s height in pixels.'),
205 l_win_main_mx => _('Maximized'),
206 h_win_main_mx => _('Changes window maximized status.'),
207 l_win_main_fs => _('Full-screen'),
208 h_win_main_fs => _('Changes full screen status.'),
210 l_acc_gtls_set => _('Use custom GnuTLS priority'),
211 h_acc_gtls_set => _('Enables using user provided GnuTLS priority string.'),
212 l_acc_gtls_pri => _('GnuTLS priority'),
213 h_acc_gtls_pri => _('Value to use as GnuTLS priority string if custom priority check is enabled. Otherwise this value is ignored.'),
215 e_error => _('Error: '),
216 e_noclawsrc => _('resource file for Claws Mail was not found.'),
217 e_running => _('seems Claws Mail is currently running, close it first.'),
220 # all preferences read by load_preferences
223 # values of all preferences handled by clawsker
226 # default config dir and file name
227 my $ALTCONFIGDIR = FALSE;
228 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
229 my $CONFIGRC = 'clawsrc';
230 my $ACCOUNTRC = 'accountrc';
232 # index constants for preference arrays
233 use constant NAME => 0; # the name on the rc file
234 use constant LABEL => 1; # the label on the GUI
235 use constant DESC => 2; # the description for the hint/help
236 use constant TYPE => 3; # data type: bool, int, float, string, color
237 use constant CMVER => 4; # lowest[,highest] Claws Mail version(s) the feature exists
238 use constant CMDEF => 5; # default value for the preference in Claws Mail
239 use constant GUI => 6; # GUI element
241 # constants for GUI spacing
242 use constant HBOX_SPC => 5;
243 use constant FRAME_SPC => 2;
244 use constant PAGE_SPC => 5;
248 sub version_greater_or_equal {
249 my ($version, $refvers) = @_;
250 my @version = split (/\./, $version);
251 my @refvers = split (/\./, $refvers);
252 while ($#version < $#refvers) {
253 push (@version, '0');
256 while (($idx <= $#refvers)
257 and (int ($version[$idx]) == int ($refvers[$idx]))) {
260 return TRUE if (($idx > $#refvers)
261 or (int ($version[$idx]) >= int ($refvers[$idx])));
265 sub get_claws_version {
266 $_ = qx/which claws-mail/;
268 return "" unless ($_); # not installed
272 my @fver = split (/ /);
273 die "Invalid version string" unless ($fver[2] eq "version");
274 my @ver = split (/\./, $fver[3]);
277 if ($ver[2] =~ /(\d+)git(\d+)/) {
286 # data handlers and auxiliar functions
288 sub handle_bool_value {
289 my ($widget, $event, $dataref) = @_;
290 $$dataref = ($widget->get_active ())? '1': '0';
293 sub handle_int_value {
294 my ($widget, $event, $dataref) = @_;
295 $_ = $widget->get_text ();
300 $widget->set_text ($_);
303 $widget->set_text ($$dataref);
307 sub handle_string_value {
308 my ($widget, $event, $dataref) = @_;
309 $$dataref = $widget->get_text ();
312 sub handle_nchar_value {
313 my ($widget, $event, $dataref, $minlen, $maxlen) = @_;
314 $_ = substr ($widget->get_text (), 0, $maxlen);
315 $widget->set_text ($_);
319 sub gdk_color_from_str {
321 my ($rr, $gg, $bb) = (0, 0 ,0);
323 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
328 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
332 sub str_from_gdk_color {
334 my $rr = $color->red / 256;
335 my $gg = $color->green / 256;
336 my $bb = $color->blue / 256;
337 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
341 sub handle_color_value {
342 my ($widget, $event, $dataref) = @_;
343 my $newcol = $widget->get_color;
344 $$dataref = str_from_gdk_color ($newcol);
347 sub handle_selection_value {
348 my ($widget, $event, $dataref) = @_;
349 $$dataref = $widget->get_active;
352 sub get_rc_filename {
353 return $CONFIGDIR . $CONFIGRC;
356 sub get_ac_rc_filename {
357 return $CONFIGDIR . $ACCOUNTRC;
360 sub set_rc_filename {
362 my @parts = split ('/', $fullname);
363 $CONFIGRC = $parts[$#parts];
364 $parts[$#parts] = '';
365 $CONFIGDIR = join ('/', @parts);
369 my ($mesg, $fatal) = @_;
370 if (defined($fatal) && $fatal eq 'die') {
371 die "$NAME: $mesg\n";
374 print "$NAME: $mesg\n";
380 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
381 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
382 $errordlg->set_title (_('Clawsker error'));
387 sub claws_is_running {
388 my $emsg = "$xl::s{e_error}$xl::s{e_running}";
390 error_dialog ($emsg);
394 sub check_claws_not_running {
395 return TRUE if $READONLY;
396 my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
397 $tmpdir = '/tmp' if ($tmpdir eq '');
398 my $lockdir = "$tmpdir/claws-mail-$<";
402 my $socket = "$lockdir/" . md5_hex ($_);
403 -S $socket and return claws_is_running ();
410 (defined($rcfile) && -f $rcfile) or do {
411 my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
413 error_dialog ($emsg);
419 sub set_widget_hint {
421 my ($wdgt, $hint) = @_;
422 $wdgt->set_tooltip_text ($hint);
423 $wdgt->set_has_tooltip (TRUE);
427 sub set_widget_sens {
428 my ($wdgt, $versions) = @_;
429 my @ver = split(/,/, $versions);
431 $wdgt->set_sensitive (
432 version_greater_or_equal ($CLAWSV, $ver[0])
433 and version_greater_or_equal ($ver[1], $CLAWSV)
436 $wdgt->set_sensitive (version_greater_or_equal ($CLAWSV, $ver[0]));
440 # graphic element creation
442 sub new_check_button_for($$$) {
443 my ($hash, $key, $vhash) = @_;
444 my $name = $$hash{$key}[NAME];
445 my $label = $$hash{$key}[LABEL];
447 my $hbox = Gtk2::HBox->new (FALSE, 5);
448 my $cb = Gtk2::CheckButton->new ($label);
449 my $value = $$vhash{$name};
450 $value //= $$hash{$key}[CMDEF];
451 $cb->set_active ($value eq '1');
452 $cb->signal_connect (clicked => sub {
454 handle_bool_value ($w, $e, \$$vhash{$name});
456 set_widget_hint ($cb, $$hash{$key}[DESC]);
457 set_widget_sens ($cb, $$hash{$key}[CMVER]);
458 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
463 sub new_text_box_for_int($$$) {
464 my ($hash, $key, $vhash) = @_;
465 my $name = $$hash{$key}[NAME];
466 my $label = $$hash{$key}[LABEL];
467 my @type = split (/,/, $$hash{$key}[TYPE]);
468 push (@type, 0), push (@type, 10000) unless ($#type > 0);
470 my $hbox = Gtk2::HBox->new (FALSE, 5);
471 my $glabel = Gtk2::Label->new ($label);
472 my $pagei = int (($type[2] - $type[1]) / 10);
473 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
474 my $value = $$vhash{$name};
475 $value //= $$hash{$key}[CMDEF];
476 $gentry->set_numeric (TRUE);
477 $gentry->set_value ($value);
478 $gentry->signal_connect('value-changed' => sub {
480 handle_int_value ($w, $e, \$$vhash{$name});
482 set_widget_hint ($gentry, $$hash{$key}[DESC]);
483 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
484 $glabel->set_sensitive ($gentry->sensitive);
485 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
486 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
491 sub new_text_box_for_nchar($$$) {
492 my ($hash, $key, $vhash) = @_;
493 my $name = $$hash{$key}[NAME];
494 my $label = $$hash{$key}[LABEL];
495 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen,width
496 my $hbox = Gtk2::HBox->new (FALSE, 5);
497 my $glabel = Gtk2::Label->new ($label);
498 my $gentry = Gtk2::Entry->new ();
499 $gentry->set_max_length($type[2]) if defined ($type[2]);
500 my $width = $type[3];
502 $gentry->set_width_chars(int ($width) + 2) if defined ($width);
503 my $value = $$vhash{$name};
504 $value //= $$hash{$key}[CMDEF];
505 $gentry->set_text ($value);
506 $gentry->signal_connect('key-release-event' => sub {
508 handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1], $type[2]);
510 set_widget_hint ($gentry, $$hash{$key}[DESC]);
511 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
512 $glabel->set_sensitive ($gentry->sensitive);
513 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
514 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
519 sub new_color_button_for($$$) {
520 my ($hash, $key, $vhash) = @_;
521 my $name = $$hash{$key}[NAME];
522 my $label = $$hash{$key}[LABEL];
524 my $value = $$vhash{$name};
525 $value //= $$hash{$key}[CMDEF];
526 my $col = gdk_color_from_str ($value);
527 my $hbox = Gtk2::HBox->new (FALSE, 5);
528 my $glabel = Gtk2::Label->new ($label);
529 my $button = Gtk2::ColorButton->new_with_color ($col);
530 $button->set_title ($label);
531 $button->set_relief ('none');
532 $button->signal_connect ('color-set' => sub {
534 handle_color_value ($w, $e, \$$vhash{$name});
536 set_widget_hint ($button, $$hash{$key}[DESC]);
537 set_widget_sens ($button, $$hash{$key}[CMVER]);
538 $glabel->set_sensitive ($button->sensitive);
539 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
540 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
545 sub new_selection_box_for($$$) {
546 my ($hash, $key, $vhash) = @_;
547 my $name = $$hash{$key}[NAME];
548 my $label = $$hash{$key}[LABEL];
550 my $hbox = Gtk2::HBox->new (FALSE, 5);
551 my $glabel = Gtk2::Label->new ($label);
552 my $combo = Gtk2::ComboBox->new_text;
553 my @options = split (';', $$hash{$key}[TYPE]);
554 foreach my $opt (@options) {
555 my ($index, $textkey) = split ('=', $opt);
556 $combo->insert_text ($index, $xl::s{$textkey});
558 $combo->signal_connect ('changed' => sub {
560 handle_selection_value ($w, $e, \$$vhash{$name});
562 my $value = $$vhash{$name};
563 $value //= $$hash{$key}[CMDEF];
564 $combo->set_active ($value);
565 set_widget_hint ($combo, $$hash{$key}[DESC]);
566 set_widget_sens ($combo, $$hash{$key}[CMVER]);
567 $glabel->set_sensitive ($combo->sensitive);
568 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
569 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
574 # more graphic helpers
577 my $hbox = Gtk2::HBox->new (FALSE, 5);
578 $hbox->set_border_width (PAGE_SPC);
579 foreach my $item (@_) {
580 $hbox->pack_start ($item, FALSE, FALSE, 0);
586 my $vbox = Gtk2::VBox->new (FALSE, 5);
587 $vbox->set_border_width (PAGE_SPC);
588 foreach my $item (@_) {
589 $vbox->pack_start ($item, FALSE, FALSE, 0);
594 sub new_vbox_pack_compact {
595 my $vbox = Gtk2::VBox->new (FALSE, 0);
596 $vbox->set_border_width (0);
597 foreach my $item (@_) {
598 $vbox->pack_start ($item, FALSE, FALSE, 0);
603 sub new_subpage_frame {
604 my ($box, $title, $notpacked) = @_;
605 my $frame = Gtk2::Frame->new ($title);
607 return new_vbox_pack ($frame) unless defined ($notpacked);
611 # preference maps and corresponding page creation subs
613 %pr::oth = ( # other preferences
615 'addressbook_use_editaddress_dialog',
616 $xl::s{l_oth_use_dlg},
617 $xl::s{h_oth_use_dlg},
624 'cache_max_mem_usage',
625 $xl::s{l_oth_max_use},
626 $xl::s{h_oth_max_use},
627 'int,0,262144', # 0 Kb - 256 Mb
633 'cache_min_keep_time',
634 $xl::s{l_oth_min_time},
635 $xl::s{h_oth_min_time},
636 'int,0,120', # 0 minutes - 2 hours
642 'use_networkmanager',
643 $xl::s{l_oth_use_netm},
644 $xl::s{h_oth_use_netm},
651 'master_passphrase_pbkdf2_rounds',
652 $xl::s{l_oth_mp_rounds},
653 $xl::s{h_oth_mp_rounds},
661 sub new_other_page() {
662 return new_vbox_pack (
665 new_check_button_for(\%pr::oth, 'use_dlg', \%HPVALUE)),
666 $xl::s{ab_frame}, 'not-packed'),
669 new_text_box_for_int(\%pr::oth, 'max_use', \%HPVALUE),
670 new_text_box_for_int(\%pr::oth, 'min_time', \%HPVALUE)),
671 $xl::s{mem_frame}, 'not-packed'),
674 new_check_button_for(\%pr::oth, 'use_netm', \%HPVALUE)),
675 $xl::s{netm_frame}, 'not-packed'),
678 new_text_box_for_int(\%pr::oth, 'mp_rounds', \%HPVALUE)),
679 $xl::s{mpass_frame}, 'not-packed')
683 %pr::gui = ( # gui bells and whistles
686 $xl::s{l_gui_b_unread},
687 $xl::s{h_gui_b_unread},
695 $xl::s{l_gui_no_markup},
696 $xl::s{h_gui_no_markup},
703 'enable_dotted_lines',
704 $xl::s{l_gui_dot_lines},
705 $xl::s{h_gui_dot_lines},
713 $xl::s{l_gui_h_scroll},
714 $xl::s{h_gui_h_scroll},
722 $xl::s{l_gui_swp_from},
723 $xl::s{h_gui_swp_from},
730 'folderview_vscrollbar_policy',
731 $xl::s{l_gui_v_scroll},
732 $xl::s{h_gui_v_scroll},
733 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
740 $xl::s{l_gui_from_show},
741 $xl::s{h_gui_from_show},
742 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
748 'stripes_color_offset',
749 $xl::s{l_gui_strip_off},
750 $xl::s{h_gui_strip_off},
751 'int,0,40000', # no idea what this number means
757 'textview_cursor_visible',
758 $xl::s{l_gui_cursor_v},
759 $xl::s{h_gui_cursor_v},
766 'toolbar_detachable',
767 $xl::s{l_gui_toolbar_d},
768 $xl::s{h_gui_toolbar_d},
775 'use_stripes_everywhere',
776 $xl::s{l_gui_strip_all},
777 $xl::s{h_gui_strip_all},
784 'use_stripes_in_summaries',
785 $xl::s{l_gui_strip_sum},
786 $xl::s{h_gui_strip_sum},
794 $xl::s{l_gui_two_line_v},
795 $xl::s{h_gui_two_line_v},
802 'show_compose_margin',
803 $xl::s{l_gui_margin_co},
804 $xl::s{h_gui_margin_co},
811 'msgview_date_format',
812 $xl::s{l_gui_mview_date},
813 $xl::s{h_gui_mview_date},
820 'zero_replacement_char',
821 $xl::s{l_gui_zero_char},
822 $xl::s{h_gui_zero_char},
830 $xl::s{l_gui_type_any},
831 $xl::s{h_gui_type_any},
839 $xl::s{l_gui_next_del},
840 $xl::s{h_gui_next_del},
849 my $gf = Gtk2::VBox->new (FALSE, 5);
850 $gf->set_border_width (PAGE_SPC);
852 my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines', \%HPVALUE);
853 my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d', \%HPVALUE);
854 my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char', \%HPVALUE);
856 $gf->pack_start (new_subpage_frame (
858 new_check_button_for (\%pr::gui, 'strip_all', \%HPVALUE),
859 new_check_button_for (\%pr::gui, 'strip_sum', \%HPVALUE),
860 new_text_box_for_int (\%pr::gui, 'strip_off', \%HPVALUE)),
861 $xl::s{stripes_frame}, 'not-packed'),
862 FALSE, FALSE, FRAME_SPC);
863 $gf->pack_start (new_subpage_frame (
865 new_check_button_for (\%pr::gui, 'b_unread', \%HPVALUE),
866 new_check_button_for (\%pr::gui, 'swp_from', \%HPVALUE),
867 new_check_button_for (\%pr::gui, 'two_linev', \%HPVALUE),
868 new_check_button_for (\%pr::gui, 'next_del', \%HPVALUE),
869 new_selection_box_for (\%pr::gui, 'from_show', \%HPVALUE)),
870 $xl::s{mlist_frame}, 'not-packed'),
871 FALSE, FALSE, FRAME_SPC);
872 $gf->pack_start (new_subpage_frame (
874 new_check_button_for (\%pr::gui, 'cursor_v', \%HPVALUE),
875 new_check_button_for (\%pr::gui, 'mview_date', \%HPVALUE)),
876 $xl::s{mview_frame}, 'not-packed'),
877 FALSE, FALSE, FRAME_SPC);
878 $gf->pack_start (new_subpage_frame (
880 new_check_button_for (\%pr::gui, 'no_markup', \%HPVALUE),
881 new_check_button_for (\%pr::gui, 'margin_co', \%HPVALUE),
882 new_check_button_for (\%pr::gui, 'type_any', \%HPVALUE)),
883 $xl::s{compo_frame}, 'not-packed'),
884 FALSE, FALSE, FRAME_SPC);
885 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
886 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
887 $gf->pack_start (new_subpage_frame (
889 new_check_button_for (\%pr::gui, 'h_scroll', \%HPVALUE),
890 new_selection_box_for (\%pr::gui, 'v_scroll', \%HPVALUE)),
891 $xl::s{sbar_frame}, 'not-packed'),
892 FALSE, FALSE, FRAME_SPC);
893 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
898 %pr::beh = ( # tweak some behaviour
901 $xl::s{l_beh_hover_t},
902 $xl::s{h_beh_hover_t},
903 'int,100,3000', # 0.1 seconds - 3 seconds
910 $xl::s{l_beh_dangerous},
911 $xl::s{h_beh_dangerous},
918 'respect_flowed_format',
919 $xl::s{l_beh_flowed},
920 $xl::s{h_beh_flowed},
927 'save_parts_readwrite',
928 $xl::s{l_beh_parts_rw},
929 $xl::s{h_beh_parts_rw},
936 'skip_ssl_cert_check',
937 $xl::s{l_beh_skip_ssl},
938 $xl::s{h_beh_skip_ssl},
945 'statusbar_update_step',
946 $xl::s{l_beh_up_step},
947 $xl::s{h_beh_up_step},
948 'int,1,200', # 1 item - 200 items
954 'thread_by_subject_max_age',
955 $xl::s{l_beh_thread_a},
956 $xl::s{h_beh_thread_a},
957 'int,1,30', # 1 day - 30 days
964 $xl::s{l_beh_unsafe_ssl},
965 $xl::s{h_beh_unsafe_ssl},
972 'utf8_instead_of_locale_for_broken_mail',
973 $xl::s{l_beh_use_utf8},
974 $xl::s{h_beh_use_utf8},
982 $xl::s{l_beh_warn_dnd},
983 $xl::s{h_beh_warn_dnd},
990 'outgoing_fallback_to_ascii',
991 $xl::s{l_beh_out_ascii},
992 $xl::s{h_beh_out_ascii},
999 'primary_paste_unselects',
1000 $xl::s{l_beh_pp_unsel},
1001 $xl::s{h_beh_pp_unsel},
1008 'show_inline_attachments',
1009 $xl::s{l_beh_inline_at},
1010 $xl::s{h_beh_inline_at},
1017 'address_search_wildcard',
1018 $xl::s{l_beh_addr_swc},
1019 $xl::s{h_beh_addr_swc},
1026 'folder_search_wildcard',
1027 $xl::s{l_beh_fold_swc},
1028 $xl::s{h_beh_fold_swc},
1036 sub new_behaviour_page() {
1037 my $bf = Gtk2::VBox->new (FALSE, 5);
1038 $bf->set_border_width (PAGE_SPC);
1040 my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step', \%HPVALUE);
1041 my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a', \%HPVALUE);
1043 $bf->pack_start (new_subpage_frame (
1045 new_text_box_for_int (\%pr::beh, 'hover_t', \%HPVALUE),
1046 new_check_button_for (\%pr::beh, 'warn_dnd', \%HPVALUE)),
1047 $xl::s{dnd_frame}, 'not-packed'),
1048 FALSE, FALSE, FRAME_SPC);
1049 $bf->pack_start (new_subpage_frame (
1051 new_check_button_for (\%pr::beh, 'skip_ssl', \%HPVALUE),
1052 new_check_button_for (\%pr::beh, 'unsafe_ssl', \%HPVALUE)),
1053 $xl::s{ssl_frame}, 'not-packed'),
1054 FALSE, FALSE, FRAME_SPC);
1055 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
1056 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
1057 $bf->pack_start (new_subpage_frame (
1059 new_check_button_for (\%pr::beh, 'flowed', \%HPVALUE),
1060 new_check_button_for (\%pr::beh, 'parts_rw', \%HPVALUE),
1061 new_check_button_for (\%pr::beh, 'use_utf8', \%HPVALUE),
1062 new_check_button_for (\%pr::beh, 'dangerous', \%HPVALUE),
1063 new_check_button_for (\%pr::beh, 'out_ascii', \%HPVALUE),
1064 new_check_button_for (\%pr::beh, 'pp_unsel', \%HPVALUE),
1065 new_check_button_for (\%pr::beh, 'inline_at', \%HPVALUE)),
1066 $xl::s{msgs_frame}, 'not-packed'),
1067 FALSE, FALSE, FRAME_SPC);
1068 $bf->pack_start (new_subpage_frame (
1070 new_check_button_for (\%pr::beh, 'addr_swc', \%HPVALUE),
1071 new_check_button_for (\%pr::beh, 'fold_swc', \%HPVALUE)),
1072 $xl::s{swc_frame}, 'not-packed'),
1073 FALSE, FALSE, FRAME_SPC);
1077 %pr::col = ( # a variety of colours
1080 $xl::s{l_col_emphasis},
1081 $xl::s{h_col_emphasis},
1089 $xl::s{l_col_log_err},
1090 $xl::s{h_col_log_err},
1098 $xl::s{l_col_log_in},
1099 $xl::s{h_col_log_in},
1107 $xl::s{l_col_log_msg},
1108 $xl::s{h_col_log_msg},
1116 $xl::s{l_col_log_out},
1117 $xl::s{h_col_log_out},
1125 $xl::s{l_col_log_warn},
1126 $xl::s{h_col_log_warn},
1134 $xl::s{l_col_diff_add},
1135 $xl::s{h_col_diff_add},
1142 'diff_deleted_color',
1143 $xl::s{l_col_diff_del},
1144 $xl::s{h_col_diff_del},
1152 $xl::s{l_col_diff_hunk},
1153 $xl::s{h_col_diff_hunk},
1161 sub new_colours_page() {
1162 return new_vbox_pack (
1165 new_color_button_for (\%pr::col, 'emphasis', \%HPVALUE)),
1166 $xl::s{msgview_frame}, 'not-packed'),
1169 new_color_button_for (\%pr::col, 'log_err', \%HPVALUE),
1170 new_color_button_for (\%pr::col, 'log_in', \%HPVALUE),
1171 new_color_button_for (\%pr::col, 'log_msg', \%HPVALUE),
1172 new_color_button_for (\%pr::col, 'log_out', \%HPVALUE),
1173 new_color_button_for (\%pr::col, 'log_warn', \%HPVALUE)),
1174 $xl::s{log_frame}, 'not-packed'),
1177 new_color_button_for (\%pr::col, 'diff_add', \%HPVALUE),
1178 new_color_button_for (\%pr::col, 'diff_del', \%HPVALUE),
1179 new_color_button_for (\%pr::col, 'diff_hunk', \%HPVALUE)),
1180 $xl::s{diff_frame}, 'not-packed')
1184 %pr::win = ( # tweak window positions and/or sizes
1189 'int,0,3000', # 0 pixels - 3000 pixels
1198 'int,0,3000', # 0 pixels - 3000 pixels
1207 'int,0,3000', # 0 pixels - 3000 pixels
1216 'int,0,3000', # 0 pixels - 3000 pixels
1222 'mainwin_maximised',
1223 $xl::s{l_win_main_mx},
1224 $xl::s{h_win_main_mx},
1231 'mainwin_fullscreen',
1232 $xl::s{l_win_main_fs},
1233 $xl::s{h_win_main_fs},
1240 'main_messagewin_x',
1243 'int,0,3000', # 0 pixels - 3000 pixels
1249 'main_messagewin_y',
1252 'int,0,3000', # 0 pixels - 3000 pixels
1261 'int,0,3000', # 0 pixels - 3000 pixels
1267 'messagewin_height',
1270 'int,0,3000', # 0 pixels - 3000 pixels
1279 'int,0,3000', # 0 pixels - 3000 pixels
1288 'int,0,3000', # 0 pixels - 3000 pixels
1297 'int,0,3000', # 0 pixels - 3000 pixels
1303 'receivewin_height',
1306 'int,0,3000', # 0 pixels - 3000 pixels
1315 'int,0,3000', # 0 pixels - 3000 pixels
1324 'int,0,3000', # 0 pixels - 3000 pixels
1330 'folderitemwin_width',
1333 'int,0,3000', # 0 pixels - 3000 pixels
1339 'folderitemwin_height',
1342 'int,0,3000', # 0 pixels - 3000 pixels
1348 'folderselwin_width',
1351 'int,0,3000', # 0 pixels - 3000 pixels
1357 'folderselwin_height',
1360 'int,0,3000', # 0 pixels - 3000 pixels
1369 'int,0,3000', # 0 pixels - 3000 pixels
1378 'int,0,3000', # 0 pixels - 3000 pixels
1384 'addressbookwin_width',
1387 'int,0,3000', # 0 pixels - 3000 pixels
1393 'addressbookwin_height',
1396 'int,0,3000', # 0 pixels - 3000 pixels
1402 'addressbookeditpersonwin_width',
1405 'int,0,3000', # 0 pixels - 3000 pixels
1411 'addressbookeditpersonwin_height',
1414 'int,0,3000', # 0 pixels - 3000 pixels
1420 'addressbookeditgroupwin_width',
1423 'int,0,3000', # 0 pixels - 3000 pixels
1429 'addressbookeditgroupwin_height',
1432 'int,0,3000', # 0 pixels - 3000 pixels
1438 'addressaddwin_width',
1441 'int,0,3000', # 0 pixels - 3000 pixels
1447 'addressaddwin_height',
1450 'int,0,3000', # 0 pixels - 3000 pixels
1456 'addressbook_folderselwin_width',
1459 'int,0,3000', # 0 pixels - 3000 pixels
1465 'addressbook_folderselwin_height',
1468 'int,0,3000', # 0 pixels - 3000 pixels
1474 'editaccountwin_width',
1477 'int,0,3000', # 0 pixels - 3000 pixels
1483 'editaccountwin_height',
1486 'int,0,3000', # 0 pixels - 3000 pixels
1492 'accountswin_width',
1495 'int,0,3000', # 0 pixels - 3000 pixels
1501 'accountswin_height',
1504 'int,0,3000', # 0 pixels - 3000 pixels
1510 'filteringwin_width',
1513 'int,0,3000', # 0 pixels - 3000 pixels
1519 'filteringwin_height',
1522 'int,0,3000', # 0 pixels - 3000 pixels
1528 'filteringactionwin_width',
1531 'int,0,3000', # 0 pixels - 3000 pixels
1537 'filteringactionwin_height',
1540 'int,0,3000', # 0 pixels - 3000 pixels
1546 'filtering_debugwin_width',
1549 'int,0,3000', # 0 pixels - 3000 pixels
1555 'filtering_debugwin_height',
1558 'int,0,3000', # 0 pixels - 3000 pixels
1567 'int,0,3000', # 0 pixels - 3000 pixels
1573 'matcherwin_height',
1576 'int,0,3000', # 0 pixels - 3000 pixels
1585 'int,0,3000', # 0 pixels - 3000 pixels
1594 'int,0,3000', # 0 pixels - 3000 pixels
1600 'templateswin_width',
1603 'int,0,3000', # 0 pixels - 3000 pixels
1609 'templateswin_height',
1612 'int,0,3000', # 0 pixels - 3000 pixels
1621 'int,0,3000', # 0 pixels - 3000 pixels
1627 'actionswin_height',
1630 'int,0,3000', # 0 pixels - 3000 pixels
1639 'int,0,3000', # 0 pixels - 3000 pixels
1648 'int,0,3000', # 0 pixels - 3000 pixels
1657 'int,0,3000', # 0 pixels - 3000 pixels
1663 'pluginswin_height',
1666 'int,0,3000', # 0 pixels - 3000 pixels
1675 'int,0,3000', # 0 pixels - 3000 pixels
1684 'int,0,3000', # 0 pixels - 3000 pixels
1690 'print_previewwin_width',
1693 'int,0,3000', # 0 pixels - 3000 pixels
1699 'print_previewwin_height',
1702 'int,0,3000', # 0 pixels - 3000 pixels
1709 sub new_winpos_subpage_main() {
1710 return new_subpage_frame (
1711 new_vbox_pack_compact (
1713 new_text_box_for_int (\%pr::win, 'main_x', \%HPVALUE),
1714 new_text_box_for_int (\%pr::win, 'main_y', \%HPVALUE)),
1716 new_text_box_for_int (\%pr::win, 'main_w', \%HPVALUE),
1717 new_text_box_for_int (\%pr::win, 'main_h', \%HPVALUE)),
1719 new_check_button_for (\%pr::win, 'main_fs', \%HPVALUE),
1720 new_check_button_for (\%pr::win, 'main_mx', \%HPVALUE))),
1725 sub new_winpos_subpage_msgs() {
1726 return new_subpage_frame (
1727 new_vbox_pack_compact (
1729 new_text_box_for_int (\%pr::win, 'msgs_x', \%HPVALUE),
1730 new_text_box_for_int (\%pr::win, 'msgs_y', \%HPVALUE)),
1732 new_text_box_for_int (\%pr::win, 'msgs_w', \%HPVALUE),
1733 new_text_box_for_int (\%pr::win, 'msgs_h', \%HPVALUE))),
1738 sub new_winpos_subpage_sendrecv() {
1739 return new_vbox_pack (
1742 new_text_box_for_int (\%pr::win, 'send_w', \%HPVALUE),
1743 new_text_box_for_int (\%pr::win, 'send_h', \%HPVALUE)),
1744 _('Send window'), 'not-packed'),
1747 new_text_box_for_int (\%pr::win, 'recv_w', \%HPVALUE),
1748 new_text_box_for_int (\%pr::win, 'recv_h', \%HPVALUE)),
1749 _('Receive window'), 'not-packed')
1753 sub new_winpos_subpage_fold() {
1754 return new_vbox_pack (
1756 new_vbox_pack_compact (
1758 new_text_box_for_int (\%pr::win, 'fold_x', \%HPVALUE),
1759 new_text_box_for_int (\%pr::win, 'fold_y', \%HPVALUE)),
1761 new_text_box_for_int (\%pr::win, 'fold_w', \%HPVALUE),
1762 new_text_box_for_int (\%pr::win, 'fold_h', \%HPVALUE))),
1763 _('Folder window'), 'not-packed'),
1766 new_text_box_for_int (\%pr::win, 'fsel_w', \%HPVALUE),
1767 new_text_box_for_int (\%pr::win, 'fsel_h', \%HPVALUE)),
1768 _('Folder selection window'), 'not-packed')
1772 sub new_winpos_subpage_addrbook() {
1773 return new_vbox_pack (
1776 new_text_box_for_int (\%pr::win, 'addr_w', \%HPVALUE),
1777 new_text_box_for_int (\%pr::win, 'addr_h', \%HPVALUE)),
1778 _('Addressbook main window'), 'not-packed'),
1781 new_text_box_for_int (\%pr::win, 'adep_w', \%HPVALUE),
1782 new_text_box_for_int (\%pr::win, 'adep_h', \%HPVALUE)),
1783 _('Edit person window'), 'not-packed'),
1786 new_text_box_for_int (\%pr::win, 'adeg_w', \%HPVALUE),
1787 new_text_box_for_int (\%pr::win, 'adeg_h', \%HPVALUE)),
1788 _('Edit group window'), 'not-packed'),
1791 new_text_box_for_int (\%pr::win, 'adda_w', \%HPVALUE),
1792 new_text_box_for_int (\%pr::win, 'adda_h', \%HPVALUE)),
1793 _('Add address window'), 'not-packed'),
1796 new_text_box_for_int (\%pr::win, 'addf_w', \%HPVALUE),
1797 new_text_box_for_int (\%pr::win, 'addf_h', \%HPVALUE)),
1798 _('Folder select window'), 'not-packed')
1802 sub new_winpos_subpage_accounts() {
1803 return new_vbox_pack (
1806 new_text_box_for_int (\%pr::win, 'acco_w', \%HPVALUE),
1807 new_text_box_for_int (\%pr::win, 'acco_h', \%HPVALUE)),
1808 _('Accounts window'), 'not-packed'),
1811 new_text_box_for_int (\%pr::win, 'acce_w', \%HPVALUE),
1812 new_text_box_for_int (\%pr::win, 'acce_h', \%HPVALUE)),
1813 _('Edit account window'), 'not-packed')
1817 sub new_winpos_subpage_filtering() {
1818 return new_vbox_pack (
1821 new_text_box_for_int (\%pr::win, 'filt_w', \%HPVALUE),
1822 new_text_box_for_int (\%pr::win, 'filt_h', \%HPVALUE)),
1823 _('Filtering window'), 'not-packed'),
1826 new_text_box_for_int (\%pr::win, 'fila_w', \%HPVALUE),
1827 new_text_box_for_int (\%pr::win, 'fila_h', \%HPVALUE)),
1828 _('Filtering actions window'), 'not-packed'),
1831 new_text_box_for_int (\%pr::win, 'fild_w', \%HPVALUE),
1832 new_text_box_for_int (\%pr::win, 'fild_h', \%HPVALUE)),
1833 _('Filtering debug window'), 'not-packed'),
1836 new_text_box_for_int (\%pr::win, 'matc_w', \%HPVALUE),
1837 new_text_box_for_int (\%pr::win, 'matc_h', \%HPVALUE)),
1838 _('Matcher window'), 'not-packed')
1842 sub new_winpos_subpage_prefs() {
1843 return new_vbox_pack (
1846 new_text_box_for_int (\%pr::win, 'pref_w', \%HPVALUE),
1847 new_text_box_for_int (\%pr::win, 'pref_h', \%HPVALUE)),
1848 _('Preferences window'), 'not-packed'),
1851 new_text_box_for_int (\%pr::win, 'temp_w', \%HPVALUE),
1852 new_text_box_for_int (\%pr::win, 'temp_h', \%HPVALUE)),
1853 _('Templates window'), 'not-packed'),
1856 new_text_box_for_int (\%pr::win, 'acti_w', \%HPVALUE),
1857 new_text_box_for_int (\%pr::win, 'acti_h', \%HPVALUE)),
1858 _('Actions window'), 'not-packed'),
1861 new_text_box_for_int (\%pr::win, 'tags_w', \%HPVALUE),
1862 new_text_box_for_int (\%pr::win, 'tags_h', \%HPVALUE)),
1863 _('Tags window'), 'not-packed'),
1866 new_text_box_for_int (\%pr::win, 'plug_w', \%HPVALUE),
1867 new_text_box_for_int (\%pr::win, 'plug_h', \%HPVALUE)),
1868 _('Plugins window'), 'not-packed')
1872 sub new_winpos_subpage_misc() {
1873 return new_vbox_pack (
1876 new_text_box_for_int (\%pr::win, 'logw_w', \%HPVALUE),
1877 new_text_box_for_int (\%pr::win, 'logw_h', \%HPVALUE)),
1878 _('Log window'), 'not-packed'),
1881 new_text_box_for_int (\%pr::win, 'prin_w', \%HPVALUE),
1882 new_text_box_for_int (\%pr::win, 'prin_h', \%HPVALUE)),
1883 _('Print preview window'), 'not-packed'),
1886 new_text_box_for_int (\%pr::win, 'sour_w', \%HPVALUE),
1887 new_text_box_for_int (\%pr::win, 'sour_h', \%HPVALUE)),
1888 _('View source window'), 'not-packed')
1892 sub new_winpos_page() {
1893 my $winbook = Gtk2::Notebook->new;
1894 $winbook->set_tab_pos ('right');
1895 $winbook->append_page (new_winpos_subpage_main, _('Main'));
1896 $winbook->append_page (new_winpos_subpage_msgs, _('Message'));
1897 $winbook->append_page (new_winpos_subpage_sendrecv, _('Send/Receive'));
1898 $winbook->append_page (new_winpos_subpage_fold, _('Folder'));
1899 $winbook->append_page (new_winpos_subpage_addrbook, _('Addressbook'));
1900 $winbook->append_page (new_winpos_subpage_accounts, _('Accounts'));
1901 $winbook->append_page (new_winpos_subpage_filtering, _('Filtering'));
1902 $winbook->append_page (new_winpos_subpage_prefs, _('Preferences'));
1903 $winbook->append_page (new_winpos_subpage_misc, _('Other'));
1907 %pr::acc = ( # per account hidden preferences
1909 'gnutls_set_priority',
1910 $xl::s{l_acc_gtls_set},
1911 $xl::s{h_acc_gtls_set},
1919 $xl::s{l_acc_gtls_pri},
1920 $xl::s{h_acc_gtls_pri},
1928 sub new_account_subpage($) {
1930 return new_vbox_pack (
1933 new_check_button_for (\%pr::acc, 'tls_set', $ACHPVALUE{$akey}),
1934 new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey})),
1935 _('GnuTLS priority'), 'not-packed')
1939 sub new_accounts_page() {
1940 my $accbook = Gtk2::Notebook->new;
1941 $accbook->set_tab_pos ('right');
1942 foreach (keys %ACPREFS) {
1943 my $name = $ACPREFS{$_}{'account_name'};
1944 $accbook->append_page (new_account_subpage ($_), $name);
1950 sub print_version() {
1951 print $xl::s{about_title} . "\n";
1952 print $xl::s{about_version} . " $VERSION\n";
1953 print "Perl-GLib " . $Glib::VERSION;
1954 # version info stuff appeared in 1.040
1955 if ($Glib::VERSION >= 1.040) {
1956 print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
1957 . _(", running with ") . join(".", &Glib::major_version,
1958 &Glib::minor_version, &Glib::micro_version);
1961 print "Perl-GTK2 " . $Gtk2::VERSION;
1962 if ($Gtk2::VERSION >= 1.040) {
1963 print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
1964 . _(", running with ") . join(".", &Gtk2::major_version,
1965 &Gtk2::minor_version, &Gtk2::micro_version);
1968 my $clawsver = ($CLAWSV eq "") ?
1969 _("was not found!") :
1970 (_("returned version ") . $CLAWSV);
1971 print "Claws Mail " . $clawsver . "\n";
1974 # the command line help
1976 my $line = '-' x length ($xl::s{about_title}) . "\n";
1978 print $xl::s{about_title} . "\n";
1980 print _("Syntax:\n");
1981 print _(" clawsker [options]\n");
1982 print _("Options:\n");
1983 print _(" -h|--help Prints this help screen.\n");
1984 print _(" -v|--version Prints version infos.\n");
1985 print _(" -b|--verbose More messages on standard output.\n");
1986 print _(" -a|--alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
1987 print _(" -c|--clawsrc <file> Uses <file> as full resource name.\n");
1990 sub parse_command_line {
1992 $CLAWSV = get_claws_version ();
1994 GetOptions('h|help' => sub { print_help (); $cont = FALSE },
1995 'v|version' => sub { print_version (); $cont = FALSE },
1996 'b|verbose' => sub { $VERBOSE = TRUE },
1997 'r|read-only' => sub { $READONLY = TRUE },
1998 'u|use-claws-version=s' => \&opt_use_claws_version,
1999 'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
2000 'c|clawsrc=s' => \&opt_clawsrc)
2001 or die _("try -h or --help for syntax.\n");
2004 my $msg = _("Error in options: {msg}\n", msg => $@);
2005 if (defined $ENV{'DISPLAY'} and $ENV{'DISPLAY'} ne '') {
2006 eval { Gtk2->init };
2007 error_dialog ($msg) unless $@;
2014 sub opt_use_claws_version {
2015 my ($name, $value) = @_;
2016 die _("Error: {opt} requires a dotted numeric value argument\n", opt => $name)
2017 unless ($value =~ /^[\d\.]+$/);
2021 sub opt_alternate_config_dir {
2022 my ($name, $value) = @_;
2023 die _("Error: '{dir}' is not a directory or does not exist\n", dir => $value)
2025 $CONFIGDIR = $value;
2026 $CONFIGDIR .= "/" unless ($CONFIGDIR =~ /.*\/$/);
2027 $ALTCONFIGDIR = TRUE;
2031 my ($name, $value) = @_;
2032 die _("Error: '{value}' is not a file or does not exist\n", value => $value)
2034 set_rc_filename ($value);
2037 # update the hidden preferences status from loaded values
2038 sub init_hidden_preferences {
2039 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
2040 foreach my $key (keys %$hash) {
2041 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
2047 sub init_ac_hidden_preferences {
2048 foreach my $akey (keys %ACPREFS) {
2049 foreach my $key (keys %pr::acc) {
2050 my $pname = $pr::acc{$key}[NAME];
2051 $ACHPVALUE{$akey}{$pname} = $ACPREFS{$akey}{$pname};
2057 # load current status from disc
2058 sub load_preferences {
2059 my $rc = get_rc_filename ();
2060 log_message ("Loading preferences from $rc\n");
2061 return FALSE unless check_rc_file ($rc);
2062 return FALSE unless check_claws_not_running ();
2066 if (/^([8a-z_]+)=(.*)$/) {
2067 $PREFS{$1} = decode('UTF-8', $2);
2074 sub load_ac_preferences {
2075 my $rc = get_ac_rc_filename ();
2076 log_message ("Loading account preferences from $rc\n");
2077 return FALSE unless check_rc_file ($rc);
2078 return FALSE unless check_claws_not_running ();
2083 if (/^\[Account: (\d+)\]$/) {
2087 if (/^([8a-z_]+)=(.*)$/) {
2088 $ACPREFS{$akey}{$1} = decode('UTF-8', $2);
2095 # save current preferences to disc
2096 sub save_preferences {
2097 my $rc = get_rc_filename ();
2098 log_message ("Saving preferences to $rc\n");
2099 return FALSE unless check_rc_file ($rc);
2100 return FALSE unless check_claws_not_running ();
2101 my $rcbak = "$rc.backup";
2102 rename ($rc, $rcbak);
2104 open (RCB, "<$rcbak");
2107 if (/^([8a-z_]+)=(.*)$/) {
2108 if (defined($HPVALUE{$1})) {
2109 print RCF $1 . "=" . $HPVALUE{$1} . "\n";
2112 print RCF $_ . "\n";
2116 print RCF $_ . "\n";
2124 sub save_ac_preferences {
2125 my $rc = get_ac_rc_filename ();
2126 log_message ("Saving account preferences to $rc\n");
2127 return FALSE unless check_rc_file ($rc);
2128 return FALSE unless check_claws_not_running ();
2129 my $rcbak = "$rc.backup";
2130 rename ($rc, $rcbak);
2132 open (RCB, "<$rcbak");
2136 if (/^\[Account: (\d+)\]$/) {
2138 print RCF $_ . "\n";
2141 if (/^([8a-z_]+)=(.*)$/) {
2142 if (defined($ACHPVALUE{$akey}{$1})) {
2143 print RCF $1 . "=" . $ACHPVALUE{$akey}{$1} . "\n";
2146 print RCF $_ . "\n";
2150 print RCF $_ . "\n";
2160 my $nb = Gtk2::Notebook->new;
2162 $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
2163 $nb->append_page (new_colours_page (), $xl::s{tab_colours});
2164 $nb->append_page (new_gui_page (), $xl::s{tab_gui});
2165 $nb->append_page (new_other_page (), $xl::s{tab_other});
2166 $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
2167 $nb->append_page (new_accounts_page (), $xl::s{tab_accounts});
2172 # create an about dialog
2173 sub new_about_dialog {
2175 my $title = $xl::s{about_title};
2176 my $lic = $xl::s{about_license};
2177 my $vers = $xl::s{about_version} . " $VERSION";
2179 "This program is free software: you can redistribute it and/or modify
2180 it under the terms of the GNU General Public License as published by
2181 the Free Software Foundation, either version 3 of the License, or
2182 (at your option) any later version.
2184 This program is distributed in the hope that it will be useful,
2185 but WITHOUT ANY WARRANTY; without even the implied warranty of
2186 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2187 GNU General Public License for more details.
2189 You should have received a copy of the GNU General Public License
2190 along with this program. If not, see <http://www.gnu.org/licenses/>.";
2191 my $year = "2007-2016";
2192 my $holder = "Ricardo Mones <ricardo\@mones.org>";
2193 my $url = "http://www.claws-mail.org/clawsker.php";
2195 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
2196 [qw/modal destroy-with-parent/],
2198 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
2199 . "<span size=\"large\">$vers</span>\n\n"
2200 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2201 . "<span>Copyright $year by $holder</span>\n\n"
2202 . "<span size=\"large\">$lic</span>\n\n"
2203 . "<span size=\"small\">$license</span>");
2204 $dialog->set_title ($xl::s{about});
2209 # create buttons box
2210 sub new_button_box {
2211 my ($parent, $adlg) = @_;
2212 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2213 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2214 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2215 # disable button until is really implemented
2216 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2217 my $hbox = Gtk2::HBox->new (FALSE, 5);
2219 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2220 $b_apply->set_sensitive (not $READONLY);
2221 $b_apply->signal_connect (clicked => sub {
2222 save_preferences ($parent);
2223 save_ac_preferences ($parent);
2225 # $b_undo->signal_connect (clicked => sub { undo_current_changes });
2226 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2228 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2229 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2230 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2231 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2237 my $dir = $DATADIR . '/icons/hicolor';
2239 join ('/', ($dir, , $_ . 'x' . $_, 'apps', $NAME . '.png'))
2244 $icon = Gtk2::Gdk::Pixbuf->new_from_file($_) if (-f $_);
2245 push @icons, $icon if ($icon);
2251 exit unless parse_command_line ();
2253 $main_window = Gtk2::Window->new ('toplevel');
2254 exit unless load_preferences ();
2255 exit unless load_ac_preferences ();
2256 exit unless init_hidden_preferences ();
2257 exit unless init_ac_hidden_preferences ();
2259 my $box = Gtk2::VBox->new (FALSE, 5);
2260 $box->set_border_width(3);
2261 my $about = new_about_dialog ();
2262 $box->pack_start (new_notebook (), FALSE, FALSE, 0);
2263 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
2264 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2265 $main_window->set_title ($xl::s{win_title});
2266 $main_window->set_icon_list (get_app_icons ());
2267 $main_window->add ($box);
2268 $main_window->show_all;