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'),
73 tab_plugins => _('Plugins'),
74 tab_info => _('Info'),
76 ab_frame => _('Addressbook'),
77 mem_frame => _('Memory'),
78 msgview_frame => _('Message View'),
79 log_frame => _('Log window'),
80 dnd_frame => _('Drag \'n\' drop'),
81 ssl_frame => _('Secure Sockets Layer'),
82 msgs_frame => _('Messages'),
83 swc_frame => _('Completion'),
84 stripes_frame => _('Coloured stripes'),
85 sbar_frame => _('Scroll bars'),
86 mlist_frame => _('Message List'),
87 mview_frame => _('Message View'),
88 compo_frame => _('Compose window'),
89 netm_frame => _('NetworkManager'),
90 diff_frame => _('Viewing patches'),
91 mpass_frame => _('Master passphrase'),
93 l_oth_use_dlg => _('Use detached address book edit dialogue'),
94 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.'),
95 l_oth_max_use => _('Maximum memory for message cache (kB)'),
96 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
97 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
98 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.'),
99 l_oth_use_netm => _('Use NetworkManager'),
100 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
101 l_oth_mp_rounds => _('Rounds for PBKDF2 function'),
102 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.'),
104 l_gui_b_unread => _('Show unread messages with bold font'),
105 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
106 l_gui_no_markup => _('Don\'t use markup'),
107 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
108 l_gui_dot_lines => _('Use dotted lines in tree view components'),
109 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.'),
110 l_gui_h_scroll => _('Enable horizontal scrollbar'),
111 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
112 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
113 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.'),
114 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
115 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
116 l_gui_v_scroll_show => _('Show always'),
117 l_gui_v_scroll_auto => _('Automatic'),
118 l_gui_v_scroll_hide => _('Hide always'),
119 l_gui_from_show => _('From column displays'),
120 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both.'),
121 l_gui_from_show_name => _('Name only'),
122 l_gui_from_show_addr => _('Address only'),
123 l_gui_from_show_both => _('Both name and address'),
124 l_gui_strip_off => _('Coloured lines contrast'),
125 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.'),
126 l_gui_cursor_v => _('Show cursor'),
127 h_gui_cursor_v => _('Display the cursor in the Message View.'),
128 l_gui_toolbar_d => _('Detachable toolbars'),
129 h_gui_toolbar_d => _('Show handles in the toolbars.'),
130 l_gui_strip_all => _('Use stripes in all tree view components'),
131 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
132 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
133 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
134 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
135 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
136 l_gui_margin_co => _('Show margin'),
137 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
138 l_gui_mview_date => _('Don\'t display localized date'),
139 h_gui_mview_date => _('Toggles localization of date format in Message View.'),
140 l_gui_zero_char => _('Zero replacement character'),
141 h_gui_zero_char => _('Replaces \'0\' with the given character in Folder List.'),
142 l_gui_type_any => _('Editable headers'),
143 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.'),
144 l_gui_next_del => _('Select next message on delete'),
145 h_gui_next_del => _('When deleting a message, toggles between selecting the next one (newer message) or the previous one (older message).'),
147 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
148 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.'),
149 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
150 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
151 l_beh_flowed => _('Respect format=flowed in messages'),
152 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.'),
153 l_beh_parts_rw => _('Allow writable temporary files'),
154 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
155 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
156 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
157 l_beh_up_step => _('Progress bar update step (items)'),
158 h_beh_up_step => _('Update stepping in progress bars.'),
159 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
160 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
161 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
162 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
163 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
164 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
165 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
166 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
167 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
168 h_beh_out_ascii => _('If content allows, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is enforced always.'),
169 l_beh_pp_unsel => _('Primary paste unselects selection'),
170 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
171 l_beh_inline_at => _('Show inline attachments'),
172 h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view.'),
173 l_beh_addr_swc => _('Address search in compose window matches any'),
174 h_beh_addr_swc => _('On Tab-key completion, address text will match any part of the string or only from the start.'),
175 l_beh_fold_swc => _('Folder search in folder selector matches any'),
176 h_beh_fold_swc => _('On folder name completion text will match any part of the string or only from the start.'),
178 l_col_emphasis => _('X-Mailer header'),
179 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
180 l_col_log_err => _('Error messages'),
181 h_col_log_err => _('Colour for error messages in log window.'),
182 l_col_log_in => _('Server messages'),
183 h_col_log_in => _('Colour for messages received from servers in log window.'),
184 l_col_log_msg => _('Standard messages'),
185 h_col_log_msg => _('Colour for messages in log window.'),
186 l_col_log_out => _('Client messages'),
187 h_col_log_out => _('Colour for messages sent to servers in log window.'),
188 l_col_log_warn => _('Warnings'),
189 h_col_log_warn => _('Colour for warning messages in log window.'),
191 l_col_diff_add => _('Added lines'),
192 h_col_diff_add => _('Colour for added lines in patches.'),
193 l_col_diff_del => _('Deleted lines'),
194 h_col_diff_del => _('Colour for deleted lines in patches.'),
195 l_col_diff_hunk => _('Hunk lines'),
196 h_col_diff_hunk => _('Color for hunk headers in patches.'),
198 l_win_x => _('X position'),
199 h_win_x => _('X coordinate for window\'s top-left corner.'),
200 l_win_y => _('Y position'),
201 h_win_y => _('Y coordinate for window\'s top-left corner.'),
202 l_win_w => _('Width'),
203 h_win_w => _('Window\'s width in pixels.'),
204 l_win_h => _('Height'),
205 h_win_h => _('Window\'s height in pixels.'),
207 l_win_main_mx => _('Maximized'),
208 h_win_main_mx => _('Changes window maximized status.'),
209 l_win_main_fs => _('Full-screen'),
210 h_win_main_fs => _('Changes full screen status.'),
212 l_acc_gtls_set => _('Use custom GnuTLS priority'),
213 h_acc_gtls_set => _('Enables using user provided GnuTLS priority string.'),
214 l_acc_gtls_pri => _('GnuTLS priority'),
215 h_acc_gtls_pri => _('Value to use as GnuTLS priority string if custom priority check is enabled. Otherwise this value is ignored.'),
217 l_plu_gpg_alimit => _('Autocompletion limit'),
218 h_plu_gpg_alimit => _('Limits the number of addresses obtained from from keyring through autocompletion. Use 0 to get all matches.'),
219 l_plu_lav_burl => _('Base URL'),
220 h_plu_lav_burl => _('This is the URL where avatar requests are sent. You can use the one of your own libravatar server, if available.'),
221 l_plu_prl_flvb => _('Log level'),
222 h_plu_prl_flvb => _('Verbosity level of log, acumulative.'),
223 l_plu_prl_none => _('None'),
224 l_plu_prl_manual => _('Manual'),
225 l_plu_prl_action => _('Actions'),
226 l_plu_prl_match => _('Matches'),
228 e_error => _('Error: '),
229 e_noclawsrc => _('resource file for Claws Mail was not found.'),
230 e_running => _('seems Claws Mail is currently running, close it first.'),
233 # data and metadata of resource files
238 # all preferences read by load_preferences
242 # values of all preferences handled by clawsker
246 # default config dir and file name
247 my $ALTCONFIGDIR = FALSE;
248 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
249 my $CONFIGRC = 'clawsrc';
250 my $ACCOUNTRC = 'accountrc';
251 # supported and available plugins lists
252 my @PLUGINS = qw(AttRemover GPG ManageSieve Libravatar PerlPlugin);
257 # index constants for preference arrays
258 use constant NAME => 0; # the name on the rc file
259 use constant LABEL => 1; # the label on the GUI
260 use constant DESC => 2; # the description for the hint/help
261 use constant TYPE => 3; # data type: bool, int, float, string, color
262 use constant CMVER => 4; # lowest[,highest] Claws Mail version(s) the feature exists
263 use constant CMDEF => 5; # default value for the preference in Claws Mail
264 use constant PLUGIN => 6; # plugin section (only in plugin preferences)
266 # constants for GUI spacing
267 use constant HBOX_SPC => 5;
268 use constant FRAME_SPC => 2;
269 use constant PAGE_SPC => 5;
273 sub version_greater_or_equal {
274 my ($version, $refvers) = @_;
275 my @version = split (/\./, $version);
276 my @refvers = split (/\./, $refvers);
277 while ($#version < $#refvers) {
278 push (@version, '0');
281 while (($idx <= $#refvers)
282 and (int ($version[$idx]) == int ($refvers[$idx]))) {
285 return TRUE if (($idx > $#refvers)
286 or (int ($version[$idx]) >= int ($refvers[$idx])));
290 sub get_claws_version {
291 $_ = qx/which claws-mail/;
293 return "" unless ($_); # not installed
297 my @fver = split (/ /);
298 die "Invalid version string" unless ($fver[2] eq "version");
299 my @ver = split (/\./, $fver[3]);
302 if ($ver[2] =~ /(\d+)git(\d+)/) {
311 # data handlers and auxiliar functions
313 sub handle_bool_value {
314 my ($widget, $event, $dataref) = @_;
315 $$dataref = ($widget->get_active ())? '1': '0';
318 sub handle_int_value {
319 my ($widget, $event, $dataref) = @_;
320 $_ = $widget->get_text ();
325 $widget->set_text ($_);
328 $widget->set_text ($$dataref);
332 sub handle_string_value {
333 my ($widget, $event, $dataref) = @_;
334 $$dataref = $widget->get_text ();
337 sub handle_nchar_value {
338 my ($widget, $event, $dataref, $minlen, $maxlen) = @_;
339 $_ = substr ($widget->get_text (), 0, $maxlen);
340 $widget->set_text ($_);
344 sub gdk_color_from_str {
346 my ($rr, $gg, $bb) = (0, 0 ,0);
348 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
353 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
357 sub str_from_gdk_color {
359 my $rr = $color->red / 256;
360 my $gg = $color->green / 256;
361 my $bb = $color->blue / 256;
362 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
366 sub handle_color_value {
367 my ($widget, $event, $dataref) = @_;
368 my $newcol = $widget->get_color;
369 $$dataref = str_from_gdk_color ($newcol);
372 sub handle_selection_value {
373 my ($widget, $event, $dataref) = @_;
374 $$dataref = $widget->get_active;
377 sub get_rc_filename {
378 return $CONFIGDIR . $CONFIGRC;
381 sub get_ac_rc_filename {
382 return $CONFIGDIR . $ACCOUNTRC;
385 sub set_rc_filename {
387 my @parts = split ('/', $fullname);
388 $CONFIGRC = $parts[$#parts];
389 $parts[$#parts] = '';
390 $CONFIGDIR = join ('/', @parts);
394 my ($mesg, $fatal) = @_;
395 if (defined($fatal) && $fatal eq 'die') {
396 die "$NAME: $mesg\n";
399 print "$NAME: $mesg\n";
405 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
406 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
407 $errordlg->set_title (_('Clawsker error'));
412 sub claws_is_running {
413 my $emsg = "$xl::s{e_error}$xl::s{e_running}";
415 error_dialog ($emsg);
419 sub check_claws_not_running {
420 return TRUE if $READONLY;
421 my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
422 $tmpdir = '/tmp' if ($tmpdir eq '');
423 my $lockdir = "$tmpdir/claws-mail-$<";
427 my $socket = "$lockdir/" . md5_hex ($_);
428 -S $socket and return claws_is_running ();
435 (defined($rcfile) && -f $rcfile) or do {
436 my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
438 error_dialog ($emsg);
444 sub set_widget_hint {
446 my ($wdgt, $hint) = @_;
447 $wdgt->set_tooltip_text ($hint);
448 $wdgt->set_has_tooltip (TRUE);
452 sub set_widget_sens {
453 my ($wdgt, $versions) = @_;
454 my @ver = split(/,/, $versions);
456 $wdgt->set_sensitive (
457 version_greater_or_equal ($CLAWSV, $ver[0])
458 and version_greater_or_equal ($ver[1], $CLAWSV)
461 $wdgt->set_sensitive (version_greater_or_equal ($CLAWSV, $ver[0]));
465 # graphic element creation
467 sub new_check_button_for($$$) {
468 my ($hash, $key, $vhash) = @_;
469 my $name = $$hash{$key}[NAME];
470 my $label = $$hash{$key}[LABEL];
472 my $hbox = Gtk2::HBox->new (FALSE, 5);
473 my $cb = Gtk2::CheckButton->new ($label);
474 my $value = $$vhash{$name};
475 $value //= $$hash{$key}[CMDEF];
476 $cb->set_active ($value eq '1');
477 $cb->signal_connect (clicked => sub {
479 handle_bool_value ($w, $e, \$$vhash{$name});
481 set_widget_hint ($cb, $$hash{$key}[DESC]);
482 set_widget_sens ($cb, $$hash{$key}[CMVER]);
483 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
488 sub new_text_box_for_int($$$) {
489 my ($hash, $key, $vhash) = @_;
490 my $name = $$hash{$key}[NAME];
491 my $label = $$hash{$key}[LABEL];
492 my @type = split (/,/, $$hash{$key}[TYPE]);
493 push (@type, 0), push (@type, 10000) unless ($#type > 0);
495 my $hbox = Gtk2::HBox->new (FALSE, 5);
496 my $glabel = Gtk2::Label->new ($label);
497 my $pagei = int (($type[2] - $type[1]) / 10);
498 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
499 my $value = $$vhash{$name};
500 $value //= $$hash{$key}[CMDEF];
501 $gentry->set_numeric (TRUE);
502 $gentry->set_value ($value);
503 $gentry->signal_connect('value-changed' => sub {
505 handle_int_value ($w, $e, \$$vhash{$name});
507 set_widget_hint ($gentry, $$hash{$key}[DESC]);
508 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
509 $glabel->set_sensitive ($gentry->sensitive);
510 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
511 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
516 sub new_text_box_for_nchar($$$) {
517 my ($hash, $key, $vhash) = @_;
518 my $name = $$hash{$key}[NAME];
519 my $label = $$hash{$key}[LABEL];
520 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen,width
521 my $hbox = Gtk2::HBox->new (FALSE, 5);
522 my $glabel = Gtk2::Label->new ($label);
523 my $gentry = Gtk2::Entry->new ();
524 $gentry->set_max_length($type[2]) if defined ($type[2]);
525 my $width = $type[3];
527 $gentry->set_width_chars(int ($width) + 2) if defined ($width);
528 my $value = $$vhash{$name};
529 $value //= $$hash{$key}[CMDEF];
530 $gentry->set_text ($value);
531 $gentry->signal_connect('key-release-event' => sub {
533 handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1], $type[2]);
535 set_widget_hint ($gentry, $$hash{$key}[DESC]);
536 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
537 $glabel->set_sensitive ($gentry->sensitive);
538 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
539 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
544 sub new_color_button_for($$$) {
545 my ($hash, $key, $vhash) = @_;
546 my $name = $$hash{$key}[NAME];
547 my $label = $$hash{$key}[LABEL];
549 my $value = $$vhash{$name};
550 $value //= $$hash{$key}[CMDEF];
551 my $col = gdk_color_from_str ($value);
552 my $hbox = Gtk2::HBox->new (FALSE, 5);
553 my $glabel = Gtk2::Label->new ($label);
554 my $button = Gtk2::ColorButton->new_with_color ($col);
555 $button->set_title ($label);
556 $button->set_relief ('none');
557 $button->signal_connect ('color-set' => sub {
559 handle_color_value ($w, $e, \$$vhash{$name});
561 set_widget_hint ($button, $$hash{$key}[DESC]);
562 set_widget_sens ($button, $$hash{$key}[CMVER]);
563 $glabel->set_sensitive ($button->sensitive);
564 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
565 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
570 sub new_selection_box_for($$$) {
571 my ($hash, $key, $vhash) = @_;
572 my $name = $$hash{$key}[NAME];
573 my $label = $$hash{$key}[LABEL];
575 my $hbox = Gtk2::HBox->new (FALSE, 5);
576 my $glabel = Gtk2::Label->new ($label);
577 my $combo = Gtk2::ComboBox->new_text;
578 my @options = split (';', $$hash{$key}[TYPE]);
579 foreach my $opt (@options) {
580 my ($index, $textkey) = split ('=', $opt);
581 $combo->insert_text ($index, $xl::s{$textkey});
583 $combo->signal_connect ('changed' => sub {
585 handle_selection_value ($w, $e, \$$vhash{$name});
587 my $value = $$vhash{$name};
588 $value //= $$hash{$key}[CMDEF];
589 $combo->set_active ($value);
590 set_widget_hint ($combo, $$hash{$key}[DESC]);
591 set_widget_sens ($combo, $$hash{$key}[CMVER]);
592 $glabel->set_sensitive ($combo->sensitive);
593 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
594 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
599 # more graphic helpers
602 my $hbox = Gtk2::HBox->new (FALSE, 5);
603 $hbox->set_border_width (PAGE_SPC);
604 foreach my $item (@_) {
605 $hbox->pack_start ($item, FALSE, FALSE, 0);
611 my $vbox = Gtk2::VBox->new (FALSE, 5);
612 $vbox->set_border_width (PAGE_SPC);
613 foreach my $item (@_) {
614 $vbox->pack_start ($item, FALSE, FALSE, 0);
619 sub new_vbox_pack_compact {
620 my $vbox = Gtk2::VBox->new (FALSE, 0);
621 $vbox->set_border_width (0);
622 foreach my $item (@_) {
623 $vbox->pack_start ($item, FALSE, FALSE, 0);
628 sub new_subpage_frame {
629 my ($box, $title, $notpacked) = @_;
630 my $frame = Gtk2::Frame->new ($title);
632 return new_vbox_pack ($frame) unless defined ($notpacked);
636 # preference maps and corresponding page creation subs
638 %pr::oth = ( # other preferences
640 'addressbook_use_editaddress_dialog',
641 $xl::s{l_oth_use_dlg},
642 $xl::s{h_oth_use_dlg},
648 'cache_max_mem_usage',
649 $xl::s{l_oth_max_use},
650 $xl::s{h_oth_max_use},
651 'int,0,262144', # 0 Kb - 256 Mb
656 'cache_min_keep_time',
657 $xl::s{l_oth_min_time},
658 $xl::s{h_oth_min_time},
659 'int,0,120', # 0 minutes - 2 hours
664 'use_networkmanager',
665 $xl::s{l_oth_use_netm},
666 $xl::s{h_oth_use_netm},
672 'master_passphrase_pbkdf2_rounds',
673 $xl::s{l_oth_mp_rounds},
674 $xl::s{h_oth_mp_rounds},
681 sub new_other_page() {
682 return new_vbox_pack (
685 new_check_button_for(\%pr::oth, 'use_dlg', \%HPVALUE)),
686 $xl::s{ab_frame}, 'not-packed'),
689 new_text_box_for_int(\%pr::oth, 'max_use', \%HPVALUE),
690 new_text_box_for_int(\%pr::oth, 'min_time', \%HPVALUE)),
691 $xl::s{mem_frame}, 'not-packed'),
694 new_check_button_for(\%pr::oth, 'use_netm', \%HPVALUE)),
695 $xl::s{netm_frame}, 'not-packed'),
698 new_text_box_for_int(\%pr::oth, 'mp_rounds', \%HPVALUE)),
699 $xl::s{mpass_frame}, 'not-packed')
703 %pr::gui = ( # gui bells and whistles
706 $xl::s{l_gui_b_unread},
707 $xl::s{h_gui_b_unread},
714 $xl::s{l_gui_no_markup},
715 $xl::s{h_gui_no_markup},
721 'enable_dotted_lines',
722 $xl::s{l_gui_dot_lines},
723 $xl::s{h_gui_dot_lines},
730 $xl::s{l_gui_h_scroll},
731 $xl::s{h_gui_h_scroll},
738 $xl::s{l_gui_swp_from},
739 $xl::s{h_gui_swp_from},
745 'folderview_vscrollbar_policy',
746 $xl::s{l_gui_v_scroll},
747 $xl::s{h_gui_v_scroll},
748 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
754 $xl::s{l_gui_from_show},
755 $xl::s{h_gui_from_show},
756 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
761 'stripes_color_offset',
762 $xl::s{l_gui_strip_off},
763 $xl::s{h_gui_strip_off},
764 'int,0,40000', # no idea what this number means
769 'textview_cursor_visible',
770 $xl::s{l_gui_cursor_v},
771 $xl::s{h_gui_cursor_v},
777 'toolbar_detachable',
778 $xl::s{l_gui_toolbar_d},
779 $xl::s{h_gui_toolbar_d},
785 'use_stripes_everywhere',
786 $xl::s{l_gui_strip_all},
787 $xl::s{h_gui_strip_all},
793 'use_stripes_in_summaries',
794 $xl::s{l_gui_strip_sum},
795 $xl::s{h_gui_strip_sum},
802 $xl::s{l_gui_two_line_v},
803 $xl::s{h_gui_two_line_v},
809 'show_compose_margin',
810 $xl::s{l_gui_margin_co},
811 $xl::s{h_gui_margin_co},
817 'msgview_date_format',
818 $xl::s{l_gui_mview_date},
819 $xl::s{h_gui_mview_date},
825 'zero_replacement_char',
826 $xl::s{l_gui_zero_char},
827 $xl::s{h_gui_zero_char},
834 $xl::s{l_gui_type_any},
835 $xl::s{h_gui_type_any},
842 $xl::s{l_gui_next_del},
843 $xl::s{h_gui_next_del},
851 my $gf = Gtk2::VBox->new (FALSE, 5);
852 $gf->set_border_width (PAGE_SPC);
854 my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines', \%HPVALUE);
855 my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d', \%HPVALUE);
856 my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char', \%HPVALUE);
858 $gf->pack_start (new_subpage_frame (
860 new_check_button_for (\%pr::gui, 'strip_all', \%HPVALUE),
861 new_check_button_for (\%pr::gui, 'strip_sum', \%HPVALUE),
862 new_text_box_for_int (\%pr::gui, 'strip_off', \%HPVALUE)),
863 $xl::s{stripes_frame}, 'not-packed'),
864 FALSE, FALSE, FRAME_SPC);
865 $gf->pack_start (new_subpage_frame (
867 new_check_button_for (\%pr::gui, 'b_unread', \%HPVALUE),
868 new_check_button_for (\%pr::gui, 'swp_from', \%HPVALUE),
869 new_check_button_for (\%pr::gui, 'two_linev', \%HPVALUE),
870 new_check_button_for (\%pr::gui, 'next_del', \%HPVALUE),
871 new_selection_box_for (\%pr::gui, 'from_show', \%HPVALUE)),
872 $xl::s{mlist_frame}, 'not-packed'),
873 FALSE, FALSE, FRAME_SPC);
874 $gf->pack_start (new_subpage_frame (
876 new_check_button_for (\%pr::gui, 'cursor_v', \%HPVALUE),
877 new_check_button_for (\%pr::gui, 'mview_date', \%HPVALUE)),
878 $xl::s{mview_frame}, 'not-packed'),
879 FALSE, FALSE, FRAME_SPC);
880 $gf->pack_start (new_subpage_frame (
882 new_check_button_for (\%pr::gui, 'no_markup', \%HPVALUE),
883 new_check_button_for (\%pr::gui, 'margin_co', \%HPVALUE),
884 new_check_button_for (\%pr::gui, 'type_any', \%HPVALUE)),
885 $xl::s{compo_frame}, 'not-packed'),
886 FALSE, FALSE, FRAME_SPC);
887 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
888 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
889 $gf->pack_start (new_subpage_frame (
891 new_check_button_for (\%pr::gui, 'h_scroll', \%HPVALUE),
892 new_selection_box_for (\%pr::gui, 'v_scroll', \%HPVALUE)),
893 $xl::s{sbar_frame}, 'not-packed'),
894 FALSE, FALSE, FRAME_SPC);
895 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
900 %pr::beh = ( # tweak some behaviour
903 $xl::s{l_beh_hover_t},
904 $xl::s{h_beh_hover_t},
905 'int,100,3000', # 0.1 seconds - 3 seconds
911 $xl::s{l_beh_dangerous},
912 $xl::s{h_beh_dangerous},
918 'respect_flowed_format',
919 $xl::s{l_beh_flowed},
920 $xl::s{h_beh_flowed},
926 'save_parts_readwrite',
927 $xl::s{l_beh_parts_rw},
928 $xl::s{h_beh_parts_rw},
934 'skip_ssl_cert_check',
935 $xl::s{l_beh_skip_ssl},
936 $xl::s{h_beh_skip_ssl},
942 'statusbar_update_step',
943 $xl::s{l_beh_up_step},
944 $xl::s{h_beh_up_step},
945 'int,1,200', # 1 item - 200 items
950 'thread_by_subject_max_age',
951 $xl::s{l_beh_thread_a},
952 $xl::s{h_beh_thread_a},
953 'int,1,30', # 1 day - 30 days
959 $xl::s{l_beh_unsafe_ssl},
960 $xl::s{h_beh_unsafe_ssl},
966 'utf8_instead_of_locale_for_broken_mail',
967 $xl::s{l_beh_use_utf8},
968 $xl::s{h_beh_use_utf8},
975 $xl::s{l_beh_warn_dnd},
976 $xl::s{h_beh_warn_dnd},
982 'outgoing_fallback_to_ascii',
983 $xl::s{l_beh_out_ascii},
984 $xl::s{h_beh_out_ascii},
990 'primary_paste_unselects',
991 $xl::s{l_beh_pp_unsel},
992 $xl::s{h_beh_pp_unsel},
998 'show_inline_attachments',
999 $xl::s{l_beh_inline_at},
1000 $xl::s{h_beh_inline_at},
1006 'address_search_wildcard',
1007 $xl::s{l_beh_addr_swc},
1008 $xl::s{h_beh_addr_swc},
1014 'folder_search_wildcard',
1015 $xl::s{l_beh_fold_swc},
1016 $xl::s{h_beh_fold_swc},
1023 sub new_behaviour_page() {
1024 my $bf = Gtk2::VBox->new (FALSE, 5);
1025 $bf->set_border_width (PAGE_SPC);
1027 my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step', \%HPVALUE);
1028 my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a', \%HPVALUE);
1030 $bf->pack_start (new_subpage_frame (
1032 new_text_box_for_int (\%pr::beh, 'hover_t', \%HPVALUE),
1033 new_check_button_for (\%pr::beh, 'warn_dnd', \%HPVALUE)),
1034 $xl::s{dnd_frame}, 'not-packed'),
1035 FALSE, FALSE, FRAME_SPC);
1036 $bf->pack_start (new_subpage_frame (
1038 new_check_button_for (\%pr::beh, 'skip_ssl', \%HPVALUE),
1039 new_check_button_for (\%pr::beh, 'unsafe_ssl', \%HPVALUE)),
1040 $xl::s{ssl_frame}, 'not-packed'),
1041 FALSE, FALSE, FRAME_SPC);
1042 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
1043 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
1044 $bf->pack_start (new_subpage_frame (
1046 new_check_button_for (\%pr::beh, 'flowed', \%HPVALUE),
1047 new_check_button_for (\%pr::beh, 'parts_rw', \%HPVALUE),
1048 new_check_button_for (\%pr::beh, 'use_utf8', \%HPVALUE),
1049 new_check_button_for (\%pr::beh, 'dangerous', \%HPVALUE),
1050 new_check_button_for (\%pr::beh, 'out_ascii', \%HPVALUE),
1051 new_check_button_for (\%pr::beh, 'pp_unsel', \%HPVALUE),
1052 new_check_button_for (\%pr::beh, 'inline_at', \%HPVALUE)),
1053 $xl::s{msgs_frame}, 'not-packed'),
1054 FALSE, FALSE, FRAME_SPC);
1055 $bf->pack_start (new_subpage_frame (
1057 new_check_button_for (\%pr::beh, 'addr_swc', \%HPVALUE),
1058 new_check_button_for (\%pr::beh, 'fold_swc', \%HPVALUE)),
1059 $xl::s{swc_frame}, 'not-packed'),
1060 FALSE, FALSE, FRAME_SPC);
1064 %pr::col = ( # a variety of colours
1067 $xl::s{l_col_emphasis},
1068 $xl::s{h_col_emphasis},
1075 $xl::s{l_col_log_err},
1076 $xl::s{h_col_log_err},
1083 $xl::s{l_col_log_in},
1084 $xl::s{h_col_log_in},
1091 $xl::s{l_col_log_msg},
1092 $xl::s{h_col_log_msg},
1099 $xl::s{l_col_log_out},
1100 $xl::s{h_col_log_out},
1107 $xl::s{l_col_log_warn},
1108 $xl::s{h_col_log_warn},
1115 $xl::s{l_col_diff_add},
1116 $xl::s{h_col_diff_add},
1122 'diff_deleted_color',
1123 $xl::s{l_col_diff_del},
1124 $xl::s{h_col_diff_del},
1131 $xl::s{l_col_diff_hunk},
1132 $xl::s{h_col_diff_hunk},
1139 sub new_colours_page() {
1140 return new_vbox_pack (
1143 new_color_button_for (\%pr::col, 'emphasis', \%HPVALUE)),
1144 $xl::s{msgview_frame}, 'not-packed'),
1147 new_color_button_for (\%pr::col, 'log_err', \%HPVALUE),
1148 new_color_button_for (\%pr::col, 'log_in', \%HPVALUE),
1149 new_color_button_for (\%pr::col, 'log_msg', \%HPVALUE),
1150 new_color_button_for (\%pr::col, 'log_out', \%HPVALUE),
1151 new_color_button_for (\%pr::col, 'log_warn', \%HPVALUE)),
1152 $xl::s{log_frame}, 'not-packed'),
1155 new_color_button_for (\%pr::col, 'diff_add', \%HPVALUE),
1156 new_color_button_for (\%pr::col, 'diff_del', \%HPVALUE),
1157 new_color_button_for (\%pr::col, 'diff_hunk', \%HPVALUE)),
1158 $xl::s{diff_frame}, 'not-packed')
1162 %pr::win = ( # tweak window positions and/or sizes
1167 'int,0,3000', # 0 pixels - 3000 pixels
1175 'int,0,3000', # 0 pixels - 3000 pixels
1183 'int,0,3000', # 0 pixels - 3000 pixels
1191 'int,0,3000', # 0 pixels - 3000 pixels
1196 'mainwin_maximised',
1197 $xl::s{l_win_main_mx},
1198 $xl::s{h_win_main_mx},
1204 'mainwin_fullscreen',
1205 $xl::s{l_win_main_fs},
1206 $xl::s{h_win_main_fs},
1212 'main_messagewin_x',
1215 'int,0,3000', # 0 pixels - 3000 pixels
1220 'main_messagewin_y',
1223 'int,0,3000', # 0 pixels - 3000 pixels
1231 'int,0,3000', # 0 pixels - 3000 pixels
1236 'messagewin_height',
1239 'int,0,3000', # 0 pixels - 3000 pixels
1247 'int,0,3000', # 0 pixels - 3000 pixels
1255 'int,0,3000', # 0 pixels - 3000 pixels
1263 'int,0,3000', # 0 pixels - 3000 pixels
1268 'receivewin_height',
1271 'int,0,3000', # 0 pixels - 3000 pixels
1279 'int,0,3000', # 0 pixels - 3000 pixels
1287 'int,0,3000', # 0 pixels - 3000 pixels
1292 'folderitemwin_width',
1295 'int,0,3000', # 0 pixels - 3000 pixels
1300 'folderitemwin_height',
1303 'int,0,3000', # 0 pixels - 3000 pixels
1308 'folderselwin_width',
1311 'int,0,3000', # 0 pixels - 3000 pixels
1316 'folderselwin_height',
1319 'int,0,3000', # 0 pixels - 3000 pixels
1327 'int,0,3000', # 0 pixels - 3000 pixels
1335 'int,0,3000', # 0 pixels - 3000 pixels
1340 'addressbookwin_width',
1343 'int,0,3000', # 0 pixels - 3000 pixels
1348 'addressbookwin_height',
1351 'int,0,3000', # 0 pixels - 3000 pixels
1356 'addressbookeditpersonwin_width',
1359 'int,0,3000', # 0 pixels - 3000 pixels
1364 'addressbookeditpersonwin_height',
1367 'int,0,3000', # 0 pixels - 3000 pixels
1372 'addressbookeditgroupwin_width',
1375 'int,0,3000', # 0 pixels - 3000 pixels
1380 'addressbookeditgroupwin_height',
1383 'int,0,3000', # 0 pixels - 3000 pixels
1388 'addressaddwin_width',
1391 'int,0,3000', # 0 pixels - 3000 pixels
1396 'addressaddwin_height',
1399 'int,0,3000', # 0 pixels - 3000 pixels
1404 'addressbook_folderselwin_width',
1407 'int,0,3000', # 0 pixels - 3000 pixels
1412 'addressbook_folderselwin_height',
1415 'int,0,3000', # 0 pixels - 3000 pixels
1420 'editaccountwin_width',
1423 'int,0,3000', # 0 pixels - 3000 pixels
1428 'editaccountwin_height',
1431 'int,0,3000', # 0 pixels - 3000 pixels
1436 'accountswin_width',
1439 'int,0,3000', # 0 pixels - 3000 pixels
1444 'accountswin_height',
1447 'int,0,3000', # 0 pixels - 3000 pixels
1452 'filteringwin_width',
1455 'int,0,3000', # 0 pixels - 3000 pixels
1460 'filteringwin_height',
1463 'int,0,3000', # 0 pixels - 3000 pixels
1468 'filteringactionwin_width',
1471 'int,0,3000', # 0 pixels - 3000 pixels
1476 'filteringactionwin_height',
1479 'int,0,3000', # 0 pixels - 3000 pixels
1484 'filtering_debugwin_width',
1487 'int,0,3000', # 0 pixels - 3000 pixels
1492 'filtering_debugwin_height',
1495 'int,0,3000', # 0 pixels - 3000 pixels
1503 'int,0,3000', # 0 pixels - 3000 pixels
1508 'matcherwin_height',
1511 'int,0,3000', # 0 pixels - 3000 pixels
1519 'int,0,3000', # 0 pixels - 3000 pixels
1527 'int,0,3000', # 0 pixels - 3000 pixels
1532 'templateswin_width',
1535 'int,0,3000', # 0 pixels - 3000 pixels
1540 'templateswin_height',
1543 'int,0,3000', # 0 pixels - 3000 pixels
1551 'int,0,3000', # 0 pixels - 3000 pixels
1556 'actionswin_height',
1559 'int,0,3000', # 0 pixels - 3000 pixels
1567 'int,0,3000', # 0 pixels - 3000 pixels
1575 'int,0,3000', # 0 pixels - 3000 pixels
1583 'int,0,3000', # 0 pixels - 3000 pixels
1588 'pluginswin_height',
1591 'int,0,3000', # 0 pixels - 3000 pixels
1599 'int,0,3000', # 0 pixels - 3000 pixels
1607 'int,0,3000', # 0 pixels - 3000 pixels
1612 'print_previewwin_width',
1615 'int,0,3000', # 0 pixels - 3000 pixels
1620 'print_previewwin_height',
1623 'int,0,3000', # 0 pixels - 3000 pixels
1629 sub new_winpos_subpage_main() {
1630 return new_subpage_frame (
1631 new_vbox_pack_compact (
1633 new_text_box_for_int (\%pr::win, 'main_x', \%HPVALUE),
1634 new_text_box_for_int (\%pr::win, 'main_y', \%HPVALUE)),
1636 new_text_box_for_int (\%pr::win, 'main_w', \%HPVALUE),
1637 new_text_box_for_int (\%pr::win, 'main_h', \%HPVALUE)),
1639 new_check_button_for (\%pr::win, 'main_fs', \%HPVALUE),
1640 new_check_button_for (\%pr::win, 'main_mx', \%HPVALUE))),
1645 sub new_winpos_subpage_msgs() {
1646 return new_subpage_frame (
1647 new_vbox_pack_compact (
1649 new_text_box_for_int (\%pr::win, 'msgs_x', \%HPVALUE),
1650 new_text_box_for_int (\%pr::win, 'msgs_y', \%HPVALUE)),
1652 new_text_box_for_int (\%pr::win, 'msgs_w', \%HPVALUE),
1653 new_text_box_for_int (\%pr::win, 'msgs_h', \%HPVALUE))),
1658 sub new_winpos_subpage_sendrecv() {
1659 return new_vbox_pack (
1662 new_text_box_for_int (\%pr::win, 'send_w', \%HPVALUE),
1663 new_text_box_for_int (\%pr::win, 'send_h', \%HPVALUE)),
1664 _('Send window'), 'not-packed'),
1667 new_text_box_for_int (\%pr::win, 'recv_w', \%HPVALUE),
1668 new_text_box_for_int (\%pr::win, 'recv_h', \%HPVALUE)),
1669 _('Receive window'), 'not-packed')
1673 sub new_winpos_subpage_fold() {
1674 return new_vbox_pack (
1676 new_vbox_pack_compact (
1678 new_text_box_for_int (\%pr::win, 'fold_x', \%HPVALUE),
1679 new_text_box_for_int (\%pr::win, 'fold_y', \%HPVALUE)),
1681 new_text_box_for_int (\%pr::win, 'fold_w', \%HPVALUE),
1682 new_text_box_for_int (\%pr::win, 'fold_h', \%HPVALUE))),
1683 _('Folder window'), 'not-packed'),
1686 new_text_box_for_int (\%pr::win, 'fsel_w', \%HPVALUE),
1687 new_text_box_for_int (\%pr::win, 'fsel_h', \%HPVALUE)),
1688 _('Folder selection window'), 'not-packed')
1692 sub new_winpos_subpage_addrbook() {
1693 return new_vbox_pack (
1696 new_text_box_for_int (\%pr::win, 'addr_w', \%HPVALUE),
1697 new_text_box_for_int (\%pr::win, 'addr_h', \%HPVALUE)),
1698 _('Addressbook main window'), 'not-packed'),
1701 new_text_box_for_int (\%pr::win, 'adep_w', \%HPVALUE),
1702 new_text_box_for_int (\%pr::win, 'adep_h', \%HPVALUE)),
1703 _('Edit person window'), 'not-packed'),
1706 new_text_box_for_int (\%pr::win, 'adeg_w', \%HPVALUE),
1707 new_text_box_for_int (\%pr::win, 'adeg_h', \%HPVALUE)),
1708 _('Edit group window'), 'not-packed'),
1711 new_text_box_for_int (\%pr::win, 'adda_w', \%HPVALUE),
1712 new_text_box_for_int (\%pr::win, 'adda_h', \%HPVALUE)),
1713 _('Add address window'), 'not-packed'),
1716 new_text_box_for_int (\%pr::win, 'addf_w', \%HPVALUE),
1717 new_text_box_for_int (\%pr::win, 'addf_h', \%HPVALUE)),
1718 _('Folder select window'), 'not-packed')
1722 sub new_winpos_subpage_accounts() {
1723 return new_vbox_pack (
1726 new_text_box_for_int (\%pr::win, 'acco_w', \%HPVALUE),
1727 new_text_box_for_int (\%pr::win, 'acco_h', \%HPVALUE)),
1728 _('Accounts window'), 'not-packed'),
1731 new_text_box_for_int (\%pr::win, 'acce_w', \%HPVALUE),
1732 new_text_box_for_int (\%pr::win, 'acce_h', \%HPVALUE)),
1733 _('Edit account window'), 'not-packed')
1737 sub new_winpos_subpage_filtering() {
1738 return new_vbox_pack (
1741 new_text_box_for_int (\%pr::win, 'filt_w', \%HPVALUE),
1742 new_text_box_for_int (\%pr::win, 'filt_h', \%HPVALUE)),
1743 _('Filtering window'), 'not-packed'),
1746 new_text_box_for_int (\%pr::win, 'fila_w', \%HPVALUE),
1747 new_text_box_for_int (\%pr::win, 'fila_h', \%HPVALUE)),
1748 _('Filtering actions window'), 'not-packed'),
1751 new_text_box_for_int (\%pr::win, 'fild_w', \%HPVALUE),
1752 new_text_box_for_int (\%pr::win, 'fild_h', \%HPVALUE)),
1753 _('Filtering debug window'), 'not-packed'),
1756 new_text_box_for_int (\%pr::win, 'matc_w', \%HPVALUE),
1757 new_text_box_for_int (\%pr::win, 'matc_h', \%HPVALUE)),
1758 _('Matcher window'), 'not-packed')
1762 sub new_winpos_subpage_prefs() {
1763 return new_vbox_pack (
1766 new_text_box_for_int (\%pr::win, 'pref_w', \%HPVALUE),
1767 new_text_box_for_int (\%pr::win, 'pref_h', \%HPVALUE)),
1768 _('Preferences window'), 'not-packed'),
1771 new_text_box_for_int (\%pr::win, 'temp_w', \%HPVALUE),
1772 new_text_box_for_int (\%pr::win, 'temp_h', \%HPVALUE)),
1773 _('Templates window'), 'not-packed'),
1776 new_text_box_for_int (\%pr::win, 'acti_w', \%HPVALUE),
1777 new_text_box_for_int (\%pr::win, 'acti_h', \%HPVALUE)),
1778 _('Actions window'), 'not-packed'),
1781 new_text_box_for_int (\%pr::win, 'tags_w', \%HPVALUE),
1782 new_text_box_for_int (\%pr::win, 'tags_h', \%HPVALUE)),
1783 _('Tags window'), 'not-packed'),
1786 new_text_box_for_int (\%pr::win, 'plug_w', \%HPVALUE),
1787 new_text_box_for_int (\%pr::win, 'plug_h', \%HPVALUE)),
1788 _('Plugins window'), 'not-packed')
1792 sub new_winpos_subpage_misc() {
1793 return new_vbox_pack (
1796 new_text_box_for_int (\%pr::win, 'logw_w', \%HPVALUE),
1797 new_text_box_for_int (\%pr::win, 'logw_h', \%HPVALUE)),
1798 _('Log window'), 'not-packed'),
1801 new_text_box_for_int (\%pr::win, 'prin_w', \%HPVALUE),
1802 new_text_box_for_int (\%pr::win, 'prin_h', \%HPVALUE)),
1803 _('Print preview window'), 'not-packed'),
1806 new_text_box_for_int (\%pr::win, 'sour_w', \%HPVALUE),
1807 new_text_box_for_int (\%pr::win, 'sour_h', \%HPVALUE)),
1808 _('View source window'), 'not-packed')
1812 sub new_winpos_page() {
1813 my $winbook = Gtk2::Notebook->new;
1814 $winbook->set_tab_pos ('right');
1815 $winbook->append_page (new_winpos_subpage_main, _('Main'));
1816 $winbook->append_page (new_winpos_subpage_msgs, _('Message'));
1817 $winbook->append_page (new_winpos_subpage_sendrecv, _('Send/Receive'));
1818 $winbook->append_page (new_winpos_subpage_fold, _('Folder'));
1819 $winbook->append_page (new_winpos_subpage_addrbook, _('Addressbook'));
1820 $winbook->append_page (new_winpos_subpage_accounts, _('Accounts'));
1821 $winbook->append_page (new_winpos_subpage_filtering, _('Filtering'));
1822 $winbook->append_page (new_winpos_subpage_prefs, _('Preferences'));
1823 $winbook->append_page (new_winpos_subpage_misc, _('Other'));
1827 %pr::acc = ( # per account hidden preferences
1829 'gnutls_set_priority',
1830 $xl::s{l_acc_gtls_set},
1831 $xl::s{h_acc_gtls_set},
1838 $xl::s{l_acc_gtls_pri},
1839 $xl::s{h_acc_gtls_pri},
1846 sub new_account_subpage($) {
1848 return new_vbox_pack (
1851 new_check_button_for (\%pr::acc, 'tls_set', $ACHPVALUE{$akey}),
1852 new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey})),
1853 _('GnuTLS priority'), 'not-packed')
1857 sub new_accounts_page() {
1858 my $accbook = Gtk2::Notebook->new;
1859 $accbook->set_tab_pos ('right');
1861 $ACPREFS{$a}{'account_name'} cmp $ACPREFS{$b}{'account_name'}
1864 my $name = $ACPREFS{$_}{'account_name'};
1865 my $isdef = ($ACPREFS{$_}{'is_default'} eq '1');
1866 my $page = new_account_subpage ($_);
1867 $accbook->append_page ($page, $isdef? '<b>' . $name . '</b>': $name);
1869 my $label = $accbook->get_tab_label ($page);
1870 $label->set_use_markup (TRUE);
1876 %pr::plu = ( # plugins hidden preferences
1882 'int,0,3000', # 0 pixels - 3000 pixels
1891 'int,0,3000', # 0 pixels - 3000 pixels
1898 'autocompletion_limit',
1899 $xl::s{l_plu_gpg_alimit},
1900 $xl::s{h_plu_gpg_alimit},
1908 'manager_win_width',
1911 'int,0,3000', # 0 pixels - 3000 pixels
1917 'manager_win_height',
1920 'int,0,3000', # 0 pixels - 3000 pixels
1928 $xl::s{l_plu_lav_burl},
1929 $xl::s{h_plu_lav_burl},
1932 'http://cdn.libravatar.org/avatar',
1937 'filter_log_verbosity',
1938 $xl::s{l_plu_prl_flvb},
1939 $xl::s{h_plu_prl_flvb},
1940 '0=l_plu_prl_none;1=l_plu_prl_manual;2=l_plu_prl_action;3=l_plu_prl_match',
1947 sub new_plugins_page() {
1949 $frame{'AttRemover'} =
1952 new_text_box_for_int (\%pr::plu, 'arm_winw', $PLHPVALUE{'AttRemover'}),
1953 new_text_box_for_int (\%pr::plu, 'arm_winh', $PLHPVALUE{'AttRemover'})),
1954 _('Attachment remover'), 'not-packed');
1958 new_text_box_for_int (\%pr::plu, 'gpg_alimit', $PLHPVALUE{'GPG'})),
1959 _('GPG'), 'not-packed');
1960 $frame{'ManageSieve'} =
1963 new_text_box_for_int (\%pr::plu, 'msv_winw', $PLHPVALUE{'ManageSieve'}),
1964 new_text_box_for_int (\%pr::plu, 'msv_winh', $PLHPVALUE{'ManageSieve'})),
1965 _('Sieve manager'), 'not-packed');
1966 $frame{'Libravatar'} =
1969 new_text_box_for_nchar (\%pr::plu, 'lav_burl', $PLHPVALUE{'Libravatar'})),
1970 _('Libravatar'), 'not-packed');
1971 $frame{'PerlPlugin'} =
1974 new_selection_box_for (\%pr::plu, 'prl_flvb', $PLHPVALUE{'PerlPlugin'})),
1975 _('Perl'), 'not-packed');
1976 foreach (@PLUGINS) {
1977 $frame{$_}->set_sensitive (defined $PLHPVALUE{$_});
1979 return new_vbox_pack (
1980 $frame{'AttRemover'},
1982 $frame{'ManageSieve'},
1983 $frame{'Libravatar'},
1984 $frame{'PerlPlugin'});
1987 sub new_info_page() {
1988 my $t0 = Gtk2::Table->new (7, 2, FALSE);
1989 my $v = get_toolkit_versions ();
1991 'glib' => 'Perl-GLib',
1992 'glib-r' => _('GLib runtime'),
1993 'glib-b' => _('GLib built'),
1994 'gtk2' => 'Perl-GTK2',
1995 'gtk2-r' => _('GTK2 runtime'),
1996 'gtk2-b' => _('GTK2 built'),
1999 foreach (sort keys %$v) {
2000 if (defined $v->{$_}) {
2001 my $label = Gtk2::Label->new ($labels{$_});
2002 my $value = Gtk2::Label->new ('<b>' . $v->{$_} . '</b>');
2003 $label->set_alignment (0, 0.5);
2004 $value->set_alignment (0, 0.5);
2005 $value->set_use_markup (TRUE);
2006 $t0->attach ($label, 0, 1, $row, $row + 1, 'fill', 'shrink', 8, 6);
2007 $t0->attach ($value, 1, 2, $row, $row + 1, 'fill', 'shrink', 8, 6);
2011 my $t1 = Gtk2::Table->new (2, 2, FALSE);
2012 my @lbl = map { $_->set_alignment (0, 0.5); $_ } (
2013 Gtk2::Label->new (_('Binary')),
2014 Gtk2::Label->new (_('Configuration'))
2016 my $cfgv = $CONFIGDATA->{'Common'}{'config_version'};
2018 my @val = map { $_->set_alignment (0, 0.5); $_->set_use_markup (TRUE); $_ } (
2019 Gtk2::Label->new ('<b>' . $CLAWSV . '</b>'),
2020 Gtk2::Label->new ('<b>' . $cfgv . '</b>')
2022 for (my $i = 0; $i <= $#lbl; ++$i) {
2023 $t1->attach ($lbl[$i], 0, 1, $i, $i + 1, 'fill', 'shrink', 8, 6);
2024 $t1->attach ($val[$i], 1, 2, $i, $i + 1, 'fill', 'shrink', 8, 6);
2026 return new_vbox_pack (
2027 new_subpage_frame ($t0, _('Library versions'), 'not-packed'),
2028 new_subpage_frame ($t1, _('Claws Mail versions'), 'not-packed'));
2032 sub get_toolkit_versions {
2034 $versions{'glib'} = $Glib::VERSION;
2035 # version info stuff appeared in 1.040
2036 if ($Glib::VERSION >= 1.040) {
2037 $versions{'glib-b'} = join('.', Glib->GET_VERSION_INFO);
2038 $versions{'glib-r'} = join('.',
2039 &Glib::major_version, &Glib::minor_version, &Glib::micro_version);
2041 $versions{'gtk2'} = $Gtk2::VERSION;
2042 if ($Gtk2::VERSION >= 1.040) {
2043 $versions{'gtk2-b'} = join('.', Gtk2->GET_VERSION_INFO);
2044 $versions{'gtk2-r'} = join('.',
2045 &Gtk2::major_version, &Gtk2::minor_version, &Gtk2::micro_version);
2050 sub print_version() {
2051 print $xl::s{about_title} . "\n";
2052 print $xl::s{about_version} . " $VERSION\n";
2053 my $v = get_toolkit_versions ();
2054 print "Perl-GLib " . $v->{'glib'};
2055 print _(", built for ") . $v->{'glib-b'}
2056 . _(", running with ") . $v->{'glib-r'} if $v->{'glib-b'};
2058 print "Perl-GTK2 " . $v->{'gtk2'};
2059 print _(", built for ") . $v->{'gtk2-b'}
2060 . _(", running with ") . $v->{'gtk2-r'} if $v->{'gtk2-b'};
2062 my $clawsver = ($CLAWSV eq "") ?
2063 _("was not found!") :
2064 (_("returned version ") . $CLAWSV);
2065 print "Claws Mail " . $clawsver . "\n";
2068 # the command line help
2070 my $line = '-' x length ($xl::s{about_title}) . "\n";
2072 print $xl::s{about_title} . "\n";
2074 print _("Syntax:\n");
2075 print _(" clawsker [options]\n");
2076 print _("Options:\n");
2077 print _(" -a|--alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
2078 print _(" -b|--verbose More messages on standard output.\n");
2079 print _(" -c|--clawsrc <file> Uses <file> as full resource name.\n");
2080 print _(" -h|--help Prints this help screen.\n");
2081 print _(" -r|--read-only Disables writing changes to disk.\n");
2082 print _(" -v|--version Prints version infos.\n");
2085 sub parse_command_line {
2087 $CLAWSV = get_claws_version ();
2089 GetOptions('h|help' => sub { print_help (); $cont = FALSE },
2090 'v|version' => sub { print_version (); $cont = FALSE },
2091 'b|verbose' => sub { $VERBOSE = TRUE },
2092 'r|read-only' => sub { $READONLY = TRUE },
2093 'u|use-claws-version=s' => \&opt_use_claws_version,
2094 'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
2095 'c|clawsrc=s' => \&opt_clawsrc)
2096 or die _("try -h or --help for syntax.\n");
2099 my $msg = _("Error in options: {msg}\n", msg => $@);
2100 if (defined $ENV{'DISPLAY'} and $ENV{'DISPLAY'} ne '') {
2101 eval { Gtk2->init };
2102 error_dialog ($msg) unless $@;
2109 sub opt_use_claws_version {
2110 my ($name, $value) = @_;
2111 die _("Error: {opt} requires a dotted numeric value argument\n", opt => $name)
2112 unless ($value =~ /^[\d\.]+$/);
2116 sub opt_alternate_config_dir {
2117 my ($name, $value) = @_;
2118 die _("Error: '{dir}' is not a directory or does not exist\n", dir => $value)
2120 $CONFIGDIR = $value;
2121 $CONFIGDIR .= "/" unless ($CONFIGDIR =~ /.*\/$/);
2122 $ALTCONFIGDIR = TRUE;
2126 my ($name, $value) = @_;
2127 die _("Error: '{value}' is not a file or does not exist\n", value => $value)
2129 set_rc_filename ($value);
2132 # update the hidden preferences status from loaded values
2133 sub init_hidden_preferences {
2134 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
2135 foreach my $key (keys %$hash) {
2136 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
2142 sub init_ac_hidden_preferences {
2143 foreach my $akey (keys %ACPREFS) {
2144 foreach my $key (keys %pr::acc) {
2145 my $pname = $pr::acc{$key}[NAME];
2146 $ACHPVALUE{$akey}{$pname} = $ACPREFS{$akey}{$pname};
2152 sub init_plu_hidden_preferences {
2153 foreach my $key (keys %pr::plu) {
2154 my $plugin = $pr::plu{$key}[PLUGIN];
2155 my $pname = $pr::plu{$key}[NAME];
2156 if (defined $PLPREFS{$plugin}) {
2157 $PLHPVALUE{$plugin}{$pname} = $PLPREFS{$plugin}{$pname};
2163 # generic load/save resource files
2169 open (RCF, '<:encoding(utf8)', $rc)
2170 or die _("Error: opening '{file}' for reading", file => $rc) . ": $!";
2171 my $section = '_'; # default unnamed section
2176 if (/^\[([^\]]+)\]$/) { # new section
2178 die _("Error: duplicate section '{sect}' in resource file '{file}'\n",
2179 sect => $section, file => $rc) if ($data{$section});
2180 $data{$section} = {};
2181 $meta{$section}{'#'} = $line;
2183 elsif (/^([0-9a-z_]+)=(.*)$/) { # key=value
2184 $data{$section}{$1} = $2;
2185 $meta{$section}{$1} = $line;
2187 elsif (/^(.*)$/) { # lone value
2188 push (@{$data{$section}{'_'}}, $1);
2192 return (\%data, \%meta);
2196 my ($rc, $data, $meta) = @_;
2197 open (RCF, '>:utf8', $rc)
2198 or die _("Error: opening '{file}' for writing", file => $rc) . ": $!";
2199 my @sections = keys %$data;
2200 if (defined $meta) {
2202 $meta->{$a}{'#'} <=> $meta->{$b}{'#'}
2205 foreach my $section (@sections) {
2206 say RCF "[$section]";
2207 if (ref ($data->{$section}{'_'}) eq 'ARRAY') {
2208 foreach my $val (@{$data->{$section}{'_'}}) {
2212 my @keys = keys %{$data->{$section}};
2213 if (defined $meta) {
2215 $meta->{$section}{$a} <=> $meta->{$section}{$b}
2218 foreach my $key (@keys) {
2219 my $val = $data->{$section}{$key};
2220 say RCF "$key=$val";
2228 # load current status from disc
2229 sub load_preferences {
2230 my $rc = get_rc_filename ();
2231 log_message ("Loading preferences from $rc\n");
2232 return FALSE unless check_rc_file ($rc);
2233 return FALSE unless check_claws_not_running ();
2234 ($CONFIGDATA, $CONFIGMETA) = load_resource ($rc);
2235 foreach (keys %{$CONFIGDATA->{'Common'}}) {
2236 $PREFS{$_} = $CONFIGDATA->{'Common'}{$_};
2238 foreach my $plugin (@PLUGINS) {
2239 if (defined $CONFIGDATA->{$plugin}) {
2240 push (@AVPLUGINS, $plugin);
2241 foreach (keys %{$CONFIGDATA->{$plugin}}) {
2242 $PLPREFS{$plugin}{$_} = $CONFIGDATA->{$plugin}{$_};
2249 sub load_ac_preferences {
2250 my $rc = get_ac_rc_filename ();
2251 log_message ("Loading account preferences from $rc\n");
2252 return FALSE unless check_rc_file ($rc);
2253 return FALSE unless check_claws_not_running ();
2254 ($ACCOUNTDATA, $ACCOUNTMETA) = load_resource ($rc);
2255 foreach my $asect (keys %$ACCOUNTDATA) {
2256 if ($asect =~ /^Account: (\d+)$/) {
2257 foreach (keys %{$ACCOUNTDATA->{$asect}}) {
2258 $ACPREFS{$1}{$_} = $ACCOUNTDATA->{$asect}{$_};
2265 # save current preferences to disc
2266 sub save_preferences {
2267 my $rc = get_rc_filename ();
2268 log_message ("Saving preferences to $rc\n");
2269 return FALSE unless check_rc_file ($rc);
2270 return FALSE unless check_claws_not_running ();
2271 my $rcbak = "$rc.backup";
2272 rename ($rc, $rcbak);
2273 foreach (keys %PREFS) {
2274 if (defined $HPVALUE{$_}) {
2275 $CONFIGDATA->{'Common'}{$_} = $HPVALUE{$_};
2278 foreach my $plugin (@AVPLUGINS) {
2279 foreach (keys %{$CONFIGDATA->{$plugin}}) {
2280 if (defined $PLHPVALUE{$plugin}{$_}) {
2281 $CONFIGDATA->{$plugin}{$_} = $PLHPVALUE{$plugin}{$_};
2285 save_resource ($rc, $CONFIGDATA, $CONFIGMETA);
2289 sub save_ac_preferences {
2290 my $rc = get_ac_rc_filename ();
2291 log_message ("Saving account preferences to $rc\n");
2292 return FALSE unless check_rc_file ($rc);
2293 return FALSE unless check_claws_not_running ();
2294 my $rcbak = "$rc.backup";
2295 rename ($rc, $rcbak);
2296 foreach my $asect (keys %$ACCOUNTDATA) {
2297 if ($asect =~ /^Account: (\d+)$/) {
2298 foreach (keys %{$ACCOUNTDATA->{$asect}}) {
2299 if (defined $ACHPVALUE{$1}{$_}) {
2300 $ACCOUNTDATA->{$asect}{$_} = $ACHPVALUE{$1}{$_};
2305 save_resource ($rc, $ACCOUNTDATA, $ACCOUNTMETA);
2311 my $nb = Gtk2::Notebook->new;
2313 $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
2314 $nb->append_page (new_colours_page (), $xl::s{tab_colours});
2315 $nb->append_page (new_gui_page (), $xl::s{tab_gui});
2316 $nb->append_page (new_other_page (), $xl::s{tab_other});
2317 $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
2318 $nb->append_page (new_accounts_page (), $xl::s{tab_accounts});
2319 $nb->append_page (new_plugins_page (), $xl::s{tab_plugins});
2320 $nb->append_page (new_info_page (), $xl::s{tab_info});
2325 # create an about dialog
2326 sub new_about_dialog {
2328 my $title = $xl::s{about_title};
2329 my $lic = $xl::s{about_license};
2330 my $vers = $xl::s{about_version} . " $VERSION";
2332 "This program is free software: you can redistribute it and/or modify
2333 it under the terms of the GNU General Public License as published by
2334 the Free Software Foundation, either version 3 of the License, or
2335 (at your option) any later version.
2337 This program is distributed in the hope that it will be useful,
2338 but WITHOUT ANY WARRANTY; without even the implied warranty of
2339 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2340 GNU General Public License for more details.
2342 You should have received a copy of the GNU General Public License
2343 along with this program. If not, see <http://www.gnu.org/licenses/>.";
2344 my $year = "2007-2016";
2345 my $holder = "Ricardo Mones <ricardo\@mones.org>";
2346 my $url = "http://www.claws-mail.org/clawsker.php";
2348 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
2349 [qw/modal destroy-with-parent/],
2351 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
2352 . "<span size=\"large\">$vers</span>\n\n"
2353 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2354 . "<span>Copyright $year by $holder</span>\n\n"
2355 . "<span size=\"large\">$lic</span>\n\n"
2356 . "<span size=\"small\">$license</span>");
2357 $dialog->set_title ($xl::s{about});
2362 # create buttons box
2363 sub new_button_box {
2364 my ($parent, $adlg) = @_;
2365 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2366 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2367 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2368 # disable button until is really implemented
2369 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2370 my $hbox = Gtk2::HBox->new (FALSE, 5);
2372 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2373 $b_apply->set_sensitive (not $READONLY);
2374 $b_apply->signal_connect (clicked => sub {
2375 save_preferences ($parent);
2376 save_ac_preferences ($parent);
2378 # $b_undo->signal_connect (clicked => sub { undo_current_changes });
2379 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2381 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2382 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2383 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2384 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2390 return @APPICONS if (@APPICONS);
2392 if (-d $DATADIR) { # installed
2393 my $dir = $DATADIR . '/icons/hicolor';
2395 join ('/', ($dir, $_ . 'x' . $_, 'apps', $NAME . '.png'))
2397 } else { # unpacked tarball or git clone
2399 join ('/', ('./icons', $NAME . '-' . $_ . '.png'));
2404 $icon = Gtk2::Gdk::Pixbuf->new_from_file($_) if (-f $_);
2405 push @APPICONS, $icon if ($icon);
2411 exit unless parse_command_line ();
2413 $main_window = Gtk2::Window->new ('toplevel');
2414 exit unless load_preferences ();
2415 exit unless load_ac_preferences ();
2416 exit unless init_hidden_preferences ();
2417 exit unless init_ac_hidden_preferences ();
2418 exit unless init_plu_hidden_preferences ();
2420 my $box = Gtk2::VBox->new (FALSE, 5);
2421 $box->set_border_width(3);
2422 my $about = new_about_dialog ();
2423 $box->pack_start (new_notebook (), FALSE, FALSE, 0);
2424 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
2425 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2426 $main_window->set_title ($xl::s{win_title});
2427 $main_window->set_icon_list (get_app_icons ());
2428 $main_window->add ($box);
2429 $main_window->show_all;