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 l_plu_lav_burl => _('Base URL'),
216 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.'),
217 l_plu_prl_flvb => _('Log level'),
218 h_plu_prl_flvb => _('Verbosity level of log, acumulative.'),
219 l_plu_prl_none => _('None'),
220 l_plu_prl_manual => _('Manual'),
221 l_plu_prl_action => _('Actions'),
222 l_plu_prl_match => _('Matches'),
224 e_error => _('Error: '),
225 e_noclawsrc => _('resource file for Claws Mail was not found.'),
226 e_running => _('seems Claws Mail is currently running, close it first.'),
229 # all preferences read by load_preferences
232 # values of all preferences handled by clawsker
235 # default config dir and file name
236 my $ALTCONFIGDIR = FALSE;
237 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
238 my $CONFIGRC = 'clawsrc';
239 my $ACCOUNTRC = 'accountrc';
241 # index constants for preference arrays
242 use constant NAME => 0; # the name on the rc file
243 use constant LABEL => 1; # the label on the GUI
244 use constant DESC => 2; # the description for the hint/help
245 use constant TYPE => 3; # data type: bool, int, float, string, color
246 use constant CMVER => 4; # lowest[,highest] Claws Mail version(s) the feature exists
247 use constant CMDEF => 5; # default value for the preference in Claws Mail
249 # constants for GUI spacing
250 use constant HBOX_SPC => 5;
251 use constant FRAME_SPC => 2;
252 use constant PAGE_SPC => 5;
256 sub version_greater_or_equal {
257 my ($version, $refvers) = @_;
258 my @version = split (/\./, $version);
259 my @refvers = split (/\./, $refvers);
260 while ($#version < $#refvers) {
261 push (@version, '0');
264 while (($idx <= $#refvers)
265 and (int ($version[$idx]) == int ($refvers[$idx]))) {
268 return TRUE if (($idx > $#refvers)
269 or (int ($version[$idx]) >= int ($refvers[$idx])));
273 sub get_claws_version {
274 $_ = qx/which claws-mail/;
276 return "" unless ($_); # not installed
280 my @fver = split (/ /);
281 die "Invalid version string" unless ($fver[2] eq "version");
282 my @ver = split (/\./, $fver[3]);
285 if ($ver[2] =~ /(\d+)git(\d+)/) {
294 # data handlers and auxiliar functions
296 sub handle_bool_value {
297 my ($widget, $event, $dataref) = @_;
298 $$dataref = ($widget->get_active ())? '1': '0';
301 sub handle_int_value {
302 my ($widget, $event, $dataref) = @_;
303 $_ = $widget->get_text ();
308 $widget->set_text ($_);
311 $widget->set_text ($$dataref);
315 sub handle_string_value {
316 my ($widget, $event, $dataref) = @_;
317 $$dataref = $widget->get_text ();
320 sub handle_nchar_value {
321 my ($widget, $event, $dataref, $minlen, $maxlen) = @_;
322 $_ = substr ($widget->get_text (), 0, $maxlen);
323 $widget->set_text ($_);
327 sub gdk_color_from_str {
329 my ($rr, $gg, $bb) = (0, 0 ,0);
331 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
336 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
340 sub str_from_gdk_color {
342 my $rr = $color->red / 256;
343 my $gg = $color->green / 256;
344 my $bb = $color->blue / 256;
345 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
349 sub handle_color_value {
350 my ($widget, $event, $dataref) = @_;
351 my $newcol = $widget->get_color;
352 $$dataref = str_from_gdk_color ($newcol);
355 sub handle_selection_value {
356 my ($widget, $event, $dataref) = @_;
357 $$dataref = $widget->get_active;
360 sub get_rc_filename {
361 return $CONFIGDIR . $CONFIGRC;
364 sub get_ac_rc_filename {
365 return $CONFIGDIR . $ACCOUNTRC;
368 sub set_rc_filename {
370 my @parts = split ('/', $fullname);
371 $CONFIGRC = $parts[$#parts];
372 $parts[$#parts] = '';
373 $CONFIGDIR = join ('/', @parts);
377 my ($mesg, $fatal) = @_;
378 if (defined($fatal) && $fatal eq 'die') {
379 die "$NAME: $mesg\n";
382 print "$NAME: $mesg\n";
388 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
389 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
390 $errordlg->set_title (_('Clawsker error'));
395 sub claws_is_running {
396 my $emsg = "$xl::s{e_error}$xl::s{e_running}";
398 error_dialog ($emsg);
402 sub check_claws_not_running {
403 return TRUE if $READONLY;
404 my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
405 $tmpdir = '/tmp' if ($tmpdir eq '');
406 my $lockdir = "$tmpdir/claws-mail-$<";
410 my $socket = "$lockdir/" . md5_hex ($_);
411 -S $socket and return claws_is_running ();
418 (defined($rcfile) && -f $rcfile) or do {
419 my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
421 error_dialog ($emsg);
427 sub set_widget_hint {
429 my ($wdgt, $hint) = @_;
430 $wdgt->set_tooltip_text ($hint);
431 $wdgt->set_has_tooltip (TRUE);
435 sub set_widget_sens {
436 my ($wdgt, $versions) = @_;
437 my @ver = split(/,/, $versions);
439 $wdgt->set_sensitive (
440 version_greater_or_equal ($CLAWSV, $ver[0])
441 and version_greater_or_equal ($ver[1], $CLAWSV)
444 $wdgt->set_sensitive (version_greater_or_equal ($CLAWSV, $ver[0]));
448 # graphic element creation
450 sub new_check_button_for($$$) {
451 my ($hash, $key, $vhash) = @_;
452 my $name = $$hash{$key}[NAME];
453 my $label = $$hash{$key}[LABEL];
455 my $hbox = Gtk2::HBox->new (FALSE, 5);
456 my $cb = Gtk2::CheckButton->new ($label);
457 my $value = $$vhash{$name};
458 $value //= $$hash{$key}[CMDEF];
459 $cb->set_active ($value eq '1');
460 $cb->signal_connect (clicked => sub {
462 handle_bool_value ($w, $e, \$$vhash{$name});
464 set_widget_hint ($cb, $$hash{$key}[DESC]);
465 set_widget_sens ($cb, $$hash{$key}[CMVER]);
466 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
471 sub new_text_box_for_int($$$) {
472 my ($hash, $key, $vhash) = @_;
473 my $name = $$hash{$key}[NAME];
474 my $label = $$hash{$key}[LABEL];
475 my @type = split (/,/, $$hash{$key}[TYPE]);
476 push (@type, 0), push (@type, 10000) unless ($#type > 0);
478 my $hbox = Gtk2::HBox->new (FALSE, 5);
479 my $glabel = Gtk2::Label->new ($label);
480 my $pagei = int (($type[2] - $type[1]) / 10);
481 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
482 my $value = $$vhash{$name};
483 $value //= $$hash{$key}[CMDEF];
484 $gentry->set_numeric (TRUE);
485 $gentry->set_value ($value);
486 $gentry->signal_connect('value-changed' => sub {
488 handle_int_value ($w, $e, \$$vhash{$name});
490 set_widget_hint ($gentry, $$hash{$key}[DESC]);
491 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
492 $glabel->set_sensitive ($gentry->sensitive);
493 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
494 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
499 sub new_text_box_for_nchar($$$) {
500 my ($hash, $key, $vhash) = @_;
501 my $name = $$hash{$key}[NAME];
502 my $label = $$hash{$key}[LABEL];
503 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen,width
504 my $hbox = Gtk2::HBox->new (FALSE, 5);
505 my $glabel = Gtk2::Label->new ($label);
506 my $gentry = Gtk2::Entry->new ();
507 $gentry->set_max_length($type[2]) if defined ($type[2]);
508 my $width = $type[3];
510 $gentry->set_width_chars(int ($width) + 2) if defined ($width);
511 my $value = $$vhash{$name};
512 $value //= $$hash{$key}[CMDEF];
513 $gentry->set_text ($value);
514 $gentry->signal_connect('key-release-event' => sub {
516 handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1], $type[2]);
518 set_widget_hint ($gentry, $$hash{$key}[DESC]);
519 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
520 $glabel->set_sensitive ($gentry->sensitive);
521 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
522 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
527 sub new_color_button_for($$$) {
528 my ($hash, $key, $vhash) = @_;
529 my $name = $$hash{$key}[NAME];
530 my $label = $$hash{$key}[LABEL];
532 my $value = $$vhash{$name};
533 $value //= $$hash{$key}[CMDEF];
534 my $col = gdk_color_from_str ($value);
535 my $hbox = Gtk2::HBox->new (FALSE, 5);
536 my $glabel = Gtk2::Label->new ($label);
537 my $button = Gtk2::ColorButton->new_with_color ($col);
538 $button->set_title ($label);
539 $button->set_relief ('none');
540 $button->signal_connect ('color-set' => sub {
542 handle_color_value ($w, $e, \$$vhash{$name});
544 set_widget_hint ($button, $$hash{$key}[DESC]);
545 set_widget_sens ($button, $$hash{$key}[CMVER]);
546 $glabel->set_sensitive ($button->sensitive);
547 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
548 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
553 sub new_selection_box_for($$$) {
554 my ($hash, $key, $vhash) = @_;
555 my $name = $$hash{$key}[NAME];
556 my $label = $$hash{$key}[LABEL];
558 my $hbox = Gtk2::HBox->new (FALSE, 5);
559 my $glabel = Gtk2::Label->new ($label);
560 my $combo = Gtk2::ComboBox->new_text;
561 my @options = split (';', $$hash{$key}[TYPE]);
562 foreach my $opt (@options) {
563 my ($index, $textkey) = split ('=', $opt);
564 $combo->insert_text ($index, $xl::s{$textkey});
566 $combo->signal_connect ('changed' => sub {
568 handle_selection_value ($w, $e, \$$vhash{$name});
570 my $value = $$vhash{$name};
571 $value //= $$hash{$key}[CMDEF];
572 $combo->set_active ($value);
573 set_widget_hint ($combo, $$hash{$key}[DESC]);
574 set_widget_sens ($combo, $$hash{$key}[CMVER]);
575 $glabel->set_sensitive ($combo->sensitive);
576 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
577 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
582 # more graphic helpers
585 my $hbox = Gtk2::HBox->new (FALSE, 5);
586 $hbox->set_border_width (PAGE_SPC);
587 foreach my $item (@_) {
588 $hbox->pack_start ($item, FALSE, FALSE, 0);
594 my $vbox = Gtk2::VBox->new (FALSE, 5);
595 $vbox->set_border_width (PAGE_SPC);
596 foreach my $item (@_) {
597 $vbox->pack_start ($item, FALSE, FALSE, 0);
602 sub new_vbox_pack_compact {
603 my $vbox = Gtk2::VBox->new (FALSE, 0);
604 $vbox->set_border_width (0);
605 foreach my $item (@_) {
606 $vbox->pack_start ($item, FALSE, FALSE, 0);
611 sub new_subpage_frame {
612 my ($box, $title, $notpacked) = @_;
613 my $frame = Gtk2::Frame->new ($title);
615 return new_vbox_pack ($frame) unless defined ($notpacked);
619 # preference maps and corresponding page creation subs
621 %pr::oth = ( # other preferences
623 'addressbook_use_editaddress_dialog',
624 $xl::s{l_oth_use_dlg},
625 $xl::s{h_oth_use_dlg},
631 'cache_max_mem_usage',
632 $xl::s{l_oth_max_use},
633 $xl::s{h_oth_max_use},
634 'int,0,262144', # 0 Kb - 256 Mb
639 'cache_min_keep_time',
640 $xl::s{l_oth_min_time},
641 $xl::s{h_oth_min_time},
642 'int,0,120', # 0 minutes - 2 hours
647 'use_networkmanager',
648 $xl::s{l_oth_use_netm},
649 $xl::s{h_oth_use_netm},
655 'master_passphrase_pbkdf2_rounds',
656 $xl::s{l_oth_mp_rounds},
657 $xl::s{h_oth_mp_rounds},
664 sub new_other_page() {
665 return new_vbox_pack (
668 new_check_button_for(\%pr::oth, 'use_dlg', \%HPVALUE)),
669 $xl::s{ab_frame}, 'not-packed'),
672 new_text_box_for_int(\%pr::oth, 'max_use', \%HPVALUE),
673 new_text_box_for_int(\%pr::oth, 'min_time', \%HPVALUE)),
674 $xl::s{mem_frame}, 'not-packed'),
677 new_check_button_for(\%pr::oth, 'use_netm', \%HPVALUE)),
678 $xl::s{netm_frame}, 'not-packed'),
681 new_text_box_for_int(\%pr::oth, 'mp_rounds', \%HPVALUE)),
682 $xl::s{mpass_frame}, 'not-packed')
686 %pr::gui = ( # gui bells and whistles
689 $xl::s{l_gui_b_unread},
690 $xl::s{h_gui_b_unread},
697 $xl::s{l_gui_no_markup},
698 $xl::s{h_gui_no_markup},
704 'enable_dotted_lines',
705 $xl::s{l_gui_dot_lines},
706 $xl::s{h_gui_dot_lines},
713 $xl::s{l_gui_h_scroll},
714 $xl::s{h_gui_h_scroll},
721 $xl::s{l_gui_swp_from},
722 $xl::s{h_gui_swp_from},
728 'folderview_vscrollbar_policy',
729 $xl::s{l_gui_v_scroll},
730 $xl::s{h_gui_v_scroll},
731 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
737 $xl::s{l_gui_from_show},
738 $xl::s{h_gui_from_show},
739 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
744 'stripes_color_offset',
745 $xl::s{l_gui_strip_off},
746 $xl::s{h_gui_strip_off},
747 'int,0,40000', # no idea what this number means
752 'textview_cursor_visible',
753 $xl::s{l_gui_cursor_v},
754 $xl::s{h_gui_cursor_v},
760 'toolbar_detachable',
761 $xl::s{l_gui_toolbar_d},
762 $xl::s{h_gui_toolbar_d},
768 'use_stripes_everywhere',
769 $xl::s{l_gui_strip_all},
770 $xl::s{h_gui_strip_all},
776 'use_stripes_in_summaries',
777 $xl::s{l_gui_strip_sum},
778 $xl::s{h_gui_strip_sum},
785 $xl::s{l_gui_two_line_v},
786 $xl::s{h_gui_two_line_v},
792 'show_compose_margin',
793 $xl::s{l_gui_margin_co},
794 $xl::s{h_gui_margin_co},
800 'msgview_date_format',
801 $xl::s{l_gui_mview_date},
802 $xl::s{h_gui_mview_date},
808 'zero_replacement_char',
809 $xl::s{l_gui_zero_char},
810 $xl::s{h_gui_zero_char},
817 $xl::s{l_gui_type_any},
818 $xl::s{h_gui_type_any},
825 $xl::s{l_gui_next_del},
826 $xl::s{h_gui_next_del},
834 my $gf = Gtk2::VBox->new (FALSE, 5);
835 $gf->set_border_width (PAGE_SPC);
837 my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines', \%HPVALUE);
838 my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d', \%HPVALUE);
839 my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char', \%HPVALUE);
841 $gf->pack_start (new_subpage_frame (
843 new_check_button_for (\%pr::gui, 'strip_all', \%HPVALUE),
844 new_check_button_for (\%pr::gui, 'strip_sum', \%HPVALUE),
845 new_text_box_for_int (\%pr::gui, 'strip_off', \%HPVALUE)),
846 $xl::s{stripes_frame}, 'not-packed'),
847 FALSE, FALSE, FRAME_SPC);
848 $gf->pack_start (new_subpage_frame (
850 new_check_button_for (\%pr::gui, 'b_unread', \%HPVALUE),
851 new_check_button_for (\%pr::gui, 'swp_from', \%HPVALUE),
852 new_check_button_for (\%pr::gui, 'two_linev', \%HPVALUE),
853 new_check_button_for (\%pr::gui, 'next_del', \%HPVALUE),
854 new_selection_box_for (\%pr::gui, 'from_show', \%HPVALUE)),
855 $xl::s{mlist_frame}, 'not-packed'),
856 FALSE, FALSE, FRAME_SPC);
857 $gf->pack_start (new_subpage_frame (
859 new_check_button_for (\%pr::gui, 'cursor_v', \%HPVALUE),
860 new_check_button_for (\%pr::gui, 'mview_date', \%HPVALUE)),
861 $xl::s{mview_frame}, 'not-packed'),
862 FALSE, FALSE, FRAME_SPC);
863 $gf->pack_start (new_subpage_frame (
865 new_check_button_for (\%pr::gui, 'no_markup', \%HPVALUE),
866 new_check_button_for (\%pr::gui, 'margin_co', \%HPVALUE),
867 new_check_button_for (\%pr::gui, 'type_any', \%HPVALUE)),
868 $xl::s{compo_frame}, 'not-packed'),
869 FALSE, FALSE, FRAME_SPC);
870 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
871 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
872 $gf->pack_start (new_subpage_frame (
874 new_check_button_for (\%pr::gui, 'h_scroll', \%HPVALUE),
875 new_selection_box_for (\%pr::gui, 'v_scroll', \%HPVALUE)),
876 $xl::s{sbar_frame}, 'not-packed'),
877 FALSE, FALSE, FRAME_SPC);
878 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
883 %pr::beh = ( # tweak some behaviour
886 $xl::s{l_beh_hover_t},
887 $xl::s{h_beh_hover_t},
888 'int,100,3000', # 0.1 seconds - 3 seconds
894 $xl::s{l_beh_dangerous},
895 $xl::s{h_beh_dangerous},
901 'respect_flowed_format',
902 $xl::s{l_beh_flowed},
903 $xl::s{h_beh_flowed},
909 'save_parts_readwrite',
910 $xl::s{l_beh_parts_rw},
911 $xl::s{h_beh_parts_rw},
917 'skip_ssl_cert_check',
918 $xl::s{l_beh_skip_ssl},
919 $xl::s{h_beh_skip_ssl},
925 'statusbar_update_step',
926 $xl::s{l_beh_up_step},
927 $xl::s{h_beh_up_step},
928 'int,1,200', # 1 item - 200 items
933 'thread_by_subject_max_age',
934 $xl::s{l_beh_thread_a},
935 $xl::s{h_beh_thread_a},
936 'int,1,30', # 1 day - 30 days
942 $xl::s{l_beh_unsafe_ssl},
943 $xl::s{h_beh_unsafe_ssl},
949 'utf8_instead_of_locale_for_broken_mail',
950 $xl::s{l_beh_use_utf8},
951 $xl::s{h_beh_use_utf8},
958 $xl::s{l_beh_warn_dnd},
959 $xl::s{h_beh_warn_dnd},
965 'outgoing_fallback_to_ascii',
966 $xl::s{l_beh_out_ascii},
967 $xl::s{h_beh_out_ascii},
973 'primary_paste_unselects',
974 $xl::s{l_beh_pp_unsel},
975 $xl::s{h_beh_pp_unsel},
981 'show_inline_attachments',
982 $xl::s{l_beh_inline_at},
983 $xl::s{h_beh_inline_at},
989 'address_search_wildcard',
990 $xl::s{l_beh_addr_swc},
991 $xl::s{h_beh_addr_swc},
997 'folder_search_wildcard',
998 $xl::s{l_beh_fold_swc},
999 $xl::s{h_beh_fold_swc},
1006 sub new_behaviour_page() {
1007 my $bf = Gtk2::VBox->new (FALSE, 5);
1008 $bf->set_border_width (PAGE_SPC);
1010 my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step', \%HPVALUE);
1011 my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a', \%HPVALUE);
1013 $bf->pack_start (new_subpage_frame (
1015 new_text_box_for_int (\%pr::beh, 'hover_t', \%HPVALUE),
1016 new_check_button_for (\%pr::beh, 'warn_dnd', \%HPVALUE)),
1017 $xl::s{dnd_frame}, 'not-packed'),
1018 FALSE, FALSE, FRAME_SPC);
1019 $bf->pack_start (new_subpage_frame (
1021 new_check_button_for (\%pr::beh, 'skip_ssl', \%HPVALUE),
1022 new_check_button_for (\%pr::beh, 'unsafe_ssl', \%HPVALUE)),
1023 $xl::s{ssl_frame}, 'not-packed'),
1024 FALSE, FALSE, FRAME_SPC);
1025 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
1026 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
1027 $bf->pack_start (new_subpage_frame (
1029 new_check_button_for (\%pr::beh, 'flowed', \%HPVALUE),
1030 new_check_button_for (\%pr::beh, 'parts_rw', \%HPVALUE),
1031 new_check_button_for (\%pr::beh, 'use_utf8', \%HPVALUE),
1032 new_check_button_for (\%pr::beh, 'dangerous', \%HPVALUE),
1033 new_check_button_for (\%pr::beh, 'out_ascii', \%HPVALUE),
1034 new_check_button_for (\%pr::beh, 'pp_unsel', \%HPVALUE),
1035 new_check_button_for (\%pr::beh, 'inline_at', \%HPVALUE)),
1036 $xl::s{msgs_frame}, 'not-packed'),
1037 FALSE, FALSE, FRAME_SPC);
1038 $bf->pack_start (new_subpage_frame (
1040 new_check_button_for (\%pr::beh, 'addr_swc', \%HPVALUE),
1041 new_check_button_for (\%pr::beh, 'fold_swc', \%HPVALUE)),
1042 $xl::s{swc_frame}, 'not-packed'),
1043 FALSE, FALSE, FRAME_SPC);
1047 %pr::col = ( # a variety of colours
1050 $xl::s{l_col_emphasis},
1051 $xl::s{h_col_emphasis},
1058 $xl::s{l_col_log_err},
1059 $xl::s{h_col_log_err},
1066 $xl::s{l_col_log_in},
1067 $xl::s{h_col_log_in},
1074 $xl::s{l_col_log_msg},
1075 $xl::s{h_col_log_msg},
1082 $xl::s{l_col_log_out},
1083 $xl::s{h_col_log_out},
1090 $xl::s{l_col_log_warn},
1091 $xl::s{h_col_log_warn},
1098 $xl::s{l_col_diff_add},
1099 $xl::s{h_col_diff_add},
1105 'diff_deleted_color',
1106 $xl::s{l_col_diff_del},
1107 $xl::s{h_col_diff_del},
1114 $xl::s{l_col_diff_hunk},
1115 $xl::s{h_col_diff_hunk},
1122 sub new_colours_page() {
1123 return new_vbox_pack (
1126 new_color_button_for (\%pr::col, 'emphasis', \%HPVALUE)),
1127 $xl::s{msgview_frame}, 'not-packed'),
1130 new_color_button_for (\%pr::col, 'log_err', \%HPVALUE),
1131 new_color_button_for (\%pr::col, 'log_in', \%HPVALUE),
1132 new_color_button_for (\%pr::col, 'log_msg', \%HPVALUE),
1133 new_color_button_for (\%pr::col, 'log_out', \%HPVALUE),
1134 new_color_button_for (\%pr::col, 'log_warn', \%HPVALUE)),
1135 $xl::s{log_frame}, 'not-packed'),
1138 new_color_button_for (\%pr::col, 'diff_add', \%HPVALUE),
1139 new_color_button_for (\%pr::col, 'diff_del', \%HPVALUE),
1140 new_color_button_for (\%pr::col, 'diff_hunk', \%HPVALUE)),
1141 $xl::s{diff_frame}, 'not-packed')
1145 %pr::win = ( # tweak window positions and/or sizes
1150 'int,0,3000', # 0 pixels - 3000 pixels
1158 'int,0,3000', # 0 pixels - 3000 pixels
1166 'int,0,3000', # 0 pixels - 3000 pixels
1174 'int,0,3000', # 0 pixels - 3000 pixels
1179 'mainwin_maximised',
1180 $xl::s{l_win_main_mx},
1181 $xl::s{h_win_main_mx},
1187 'mainwin_fullscreen',
1188 $xl::s{l_win_main_fs},
1189 $xl::s{h_win_main_fs},
1195 'main_messagewin_x',
1198 'int,0,3000', # 0 pixels - 3000 pixels
1203 'main_messagewin_y',
1206 'int,0,3000', # 0 pixels - 3000 pixels
1214 'int,0,3000', # 0 pixels - 3000 pixels
1219 'messagewin_height',
1222 'int,0,3000', # 0 pixels - 3000 pixels
1230 'int,0,3000', # 0 pixels - 3000 pixels
1238 'int,0,3000', # 0 pixels - 3000 pixels
1246 'int,0,3000', # 0 pixels - 3000 pixels
1251 'receivewin_height',
1254 'int,0,3000', # 0 pixels - 3000 pixels
1262 'int,0,3000', # 0 pixels - 3000 pixels
1270 'int,0,3000', # 0 pixels - 3000 pixels
1275 'folderitemwin_width',
1278 'int,0,3000', # 0 pixels - 3000 pixels
1283 'folderitemwin_height',
1286 'int,0,3000', # 0 pixels - 3000 pixels
1291 'folderselwin_width',
1294 'int,0,3000', # 0 pixels - 3000 pixels
1299 'folderselwin_height',
1302 'int,0,3000', # 0 pixels - 3000 pixels
1310 'int,0,3000', # 0 pixels - 3000 pixels
1318 'int,0,3000', # 0 pixels - 3000 pixels
1323 'addressbookwin_width',
1326 'int,0,3000', # 0 pixels - 3000 pixels
1331 'addressbookwin_height',
1334 'int,0,3000', # 0 pixels - 3000 pixels
1339 'addressbookeditpersonwin_width',
1342 'int,0,3000', # 0 pixels - 3000 pixels
1347 'addressbookeditpersonwin_height',
1350 'int,0,3000', # 0 pixels - 3000 pixels
1355 'addressbookeditgroupwin_width',
1358 'int,0,3000', # 0 pixels - 3000 pixels
1363 'addressbookeditgroupwin_height',
1366 'int,0,3000', # 0 pixels - 3000 pixels
1371 'addressaddwin_width',
1374 'int,0,3000', # 0 pixels - 3000 pixels
1379 'addressaddwin_height',
1382 'int,0,3000', # 0 pixels - 3000 pixels
1387 'addressbook_folderselwin_width',
1390 'int,0,3000', # 0 pixels - 3000 pixels
1395 'addressbook_folderselwin_height',
1398 'int,0,3000', # 0 pixels - 3000 pixels
1403 'editaccountwin_width',
1406 'int,0,3000', # 0 pixels - 3000 pixels
1411 'editaccountwin_height',
1414 'int,0,3000', # 0 pixels - 3000 pixels
1419 'accountswin_width',
1422 'int,0,3000', # 0 pixels - 3000 pixels
1427 'accountswin_height',
1430 'int,0,3000', # 0 pixels - 3000 pixels
1435 'filteringwin_width',
1438 'int,0,3000', # 0 pixels - 3000 pixels
1443 'filteringwin_height',
1446 'int,0,3000', # 0 pixels - 3000 pixels
1451 'filteringactionwin_width',
1454 'int,0,3000', # 0 pixels - 3000 pixels
1459 'filteringactionwin_height',
1462 'int,0,3000', # 0 pixels - 3000 pixels
1467 'filtering_debugwin_width',
1470 'int,0,3000', # 0 pixels - 3000 pixels
1475 'filtering_debugwin_height',
1478 'int,0,3000', # 0 pixels - 3000 pixels
1486 'int,0,3000', # 0 pixels - 3000 pixels
1491 'matcherwin_height',
1494 'int,0,3000', # 0 pixels - 3000 pixels
1502 'int,0,3000', # 0 pixels - 3000 pixels
1510 'int,0,3000', # 0 pixels - 3000 pixels
1515 'templateswin_width',
1518 'int,0,3000', # 0 pixels - 3000 pixels
1523 'templateswin_height',
1526 'int,0,3000', # 0 pixels - 3000 pixels
1534 'int,0,3000', # 0 pixels - 3000 pixels
1539 'actionswin_height',
1542 'int,0,3000', # 0 pixels - 3000 pixels
1550 'int,0,3000', # 0 pixels - 3000 pixels
1558 'int,0,3000', # 0 pixels - 3000 pixels
1566 'int,0,3000', # 0 pixels - 3000 pixels
1571 'pluginswin_height',
1574 'int,0,3000', # 0 pixels - 3000 pixels
1582 'int,0,3000', # 0 pixels - 3000 pixels
1590 'int,0,3000', # 0 pixels - 3000 pixels
1595 'print_previewwin_width',
1598 'int,0,3000', # 0 pixels - 3000 pixels
1603 'print_previewwin_height',
1606 'int,0,3000', # 0 pixels - 3000 pixels
1612 sub new_winpos_subpage_main() {
1613 return new_subpage_frame (
1614 new_vbox_pack_compact (
1616 new_text_box_for_int (\%pr::win, 'main_x', \%HPVALUE),
1617 new_text_box_for_int (\%pr::win, 'main_y', \%HPVALUE)),
1619 new_text_box_for_int (\%pr::win, 'main_w', \%HPVALUE),
1620 new_text_box_for_int (\%pr::win, 'main_h', \%HPVALUE)),
1622 new_check_button_for (\%pr::win, 'main_fs', \%HPVALUE),
1623 new_check_button_for (\%pr::win, 'main_mx', \%HPVALUE))),
1628 sub new_winpos_subpage_msgs() {
1629 return new_subpage_frame (
1630 new_vbox_pack_compact (
1632 new_text_box_for_int (\%pr::win, 'msgs_x', \%HPVALUE),
1633 new_text_box_for_int (\%pr::win, 'msgs_y', \%HPVALUE)),
1635 new_text_box_for_int (\%pr::win, 'msgs_w', \%HPVALUE),
1636 new_text_box_for_int (\%pr::win, 'msgs_h', \%HPVALUE))),
1641 sub new_winpos_subpage_sendrecv() {
1642 return new_vbox_pack (
1645 new_text_box_for_int (\%pr::win, 'send_w', \%HPVALUE),
1646 new_text_box_for_int (\%pr::win, 'send_h', \%HPVALUE)),
1647 _('Send window'), 'not-packed'),
1650 new_text_box_for_int (\%pr::win, 'recv_w', \%HPVALUE),
1651 new_text_box_for_int (\%pr::win, 'recv_h', \%HPVALUE)),
1652 _('Receive window'), 'not-packed')
1656 sub new_winpos_subpage_fold() {
1657 return new_vbox_pack (
1659 new_vbox_pack_compact (
1661 new_text_box_for_int (\%pr::win, 'fold_x', \%HPVALUE),
1662 new_text_box_for_int (\%pr::win, 'fold_y', \%HPVALUE)),
1664 new_text_box_for_int (\%pr::win, 'fold_w', \%HPVALUE),
1665 new_text_box_for_int (\%pr::win, 'fold_h', \%HPVALUE))),
1666 _('Folder window'), 'not-packed'),
1669 new_text_box_for_int (\%pr::win, 'fsel_w', \%HPVALUE),
1670 new_text_box_for_int (\%pr::win, 'fsel_h', \%HPVALUE)),
1671 _('Folder selection window'), 'not-packed')
1675 sub new_winpos_subpage_addrbook() {
1676 return new_vbox_pack (
1679 new_text_box_for_int (\%pr::win, 'addr_w', \%HPVALUE),
1680 new_text_box_for_int (\%pr::win, 'addr_h', \%HPVALUE)),
1681 _('Addressbook main window'), 'not-packed'),
1684 new_text_box_for_int (\%pr::win, 'adep_w', \%HPVALUE),
1685 new_text_box_for_int (\%pr::win, 'adep_h', \%HPVALUE)),
1686 _('Edit person window'), 'not-packed'),
1689 new_text_box_for_int (\%pr::win, 'adeg_w', \%HPVALUE),
1690 new_text_box_for_int (\%pr::win, 'adeg_h', \%HPVALUE)),
1691 _('Edit group window'), 'not-packed'),
1694 new_text_box_for_int (\%pr::win, 'adda_w', \%HPVALUE),
1695 new_text_box_for_int (\%pr::win, 'adda_h', \%HPVALUE)),
1696 _('Add address window'), 'not-packed'),
1699 new_text_box_for_int (\%pr::win, 'addf_w', \%HPVALUE),
1700 new_text_box_for_int (\%pr::win, 'addf_h', \%HPVALUE)),
1701 _('Folder select window'), 'not-packed')
1705 sub new_winpos_subpage_accounts() {
1706 return new_vbox_pack (
1709 new_text_box_for_int (\%pr::win, 'acco_w', \%HPVALUE),
1710 new_text_box_for_int (\%pr::win, 'acco_h', \%HPVALUE)),
1711 _('Accounts window'), 'not-packed'),
1714 new_text_box_for_int (\%pr::win, 'acce_w', \%HPVALUE),
1715 new_text_box_for_int (\%pr::win, 'acce_h', \%HPVALUE)),
1716 _('Edit account window'), 'not-packed')
1720 sub new_winpos_subpage_filtering() {
1721 return new_vbox_pack (
1724 new_text_box_for_int (\%pr::win, 'filt_w', \%HPVALUE),
1725 new_text_box_for_int (\%pr::win, 'filt_h', \%HPVALUE)),
1726 _('Filtering window'), 'not-packed'),
1729 new_text_box_for_int (\%pr::win, 'fila_w', \%HPVALUE),
1730 new_text_box_for_int (\%pr::win, 'fila_h', \%HPVALUE)),
1731 _('Filtering actions window'), 'not-packed'),
1734 new_text_box_for_int (\%pr::win, 'fild_w', \%HPVALUE),
1735 new_text_box_for_int (\%pr::win, 'fild_h', \%HPVALUE)),
1736 _('Filtering debug window'), 'not-packed'),
1739 new_text_box_for_int (\%pr::win, 'matc_w', \%HPVALUE),
1740 new_text_box_for_int (\%pr::win, 'matc_h', \%HPVALUE)),
1741 _('Matcher window'), 'not-packed')
1745 sub new_winpos_subpage_prefs() {
1746 return new_vbox_pack (
1749 new_text_box_for_int (\%pr::win, 'pref_w', \%HPVALUE),
1750 new_text_box_for_int (\%pr::win, 'pref_h', \%HPVALUE)),
1751 _('Preferences window'), 'not-packed'),
1754 new_text_box_for_int (\%pr::win, 'temp_w', \%HPVALUE),
1755 new_text_box_for_int (\%pr::win, 'temp_h', \%HPVALUE)),
1756 _('Templates window'), 'not-packed'),
1759 new_text_box_for_int (\%pr::win, 'acti_w', \%HPVALUE),
1760 new_text_box_for_int (\%pr::win, 'acti_h', \%HPVALUE)),
1761 _('Actions window'), 'not-packed'),
1764 new_text_box_for_int (\%pr::win, 'tags_w', \%HPVALUE),
1765 new_text_box_for_int (\%pr::win, 'tags_h', \%HPVALUE)),
1766 _('Tags window'), 'not-packed'),
1769 new_text_box_for_int (\%pr::win, 'plug_w', \%HPVALUE),
1770 new_text_box_for_int (\%pr::win, 'plug_h', \%HPVALUE)),
1771 _('Plugins window'), 'not-packed')
1775 sub new_winpos_subpage_misc() {
1776 return new_vbox_pack (
1779 new_text_box_for_int (\%pr::win, 'logw_w', \%HPVALUE),
1780 new_text_box_for_int (\%pr::win, 'logw_h', \%HPVALUE)),
1781 _('Log window'), 'not-packed'),
1784 new_text_box_for_int (\%pr::win, 'prin_w', \%HPVALUE),
1785 new_text_box_for_int (\%pr::win, 'prin_h', \%HPVALUE)),
1786 _('Print preview window'), 'not-packed'),
1789 new_text_box_for_int (\%pr::win, 'sour_w', \%HPVALUE),
1790 new_text_box_for_int (\%pr::win, 'sour_h', \%HPVALUE)),
1791 _('View source window'), 'not-packed')
1795 sub new_winpos_page() {
1796 my $winbook = Gtk2::Notebook->new;
1797 $winbook->set_tab_pos ('right');
1798 $winbook->append_page (new_winpos_subpage_main, _('Main'));
1799 $winbook->append_page (new_winpos_subpage_msgs, _('Message'));
1800 $winbook->append_page (new_winpos_subpage_sendrecv, _('Send/Receive'));
1801 $winbook->append_page (new_winpos_subpage_fold, _('Folder'));
1802 $winbook->append_page (new_winpos_subpage_addrbook, _('Addressbook'));
1803 $winbook->append_page (new_winpos_subpage_accounts, _('Accounts'));
1804 $winbook->append_page (new_winpos_subpage_filtering, _('Filtering'));
1805 $winbook->append_page (new_winpos_subpage_prefs, _('Preferences'));
1806 $winbook->append_page (new_winpos_subpage_misc, _('Other'));
1810 %pr::acc = ( # per account hidden preferences
1812 'gnutls_set_priority',
1813 $xl::s{l_acc_gtls_set},
1814 $xl::s{h_acc_gtls_set},
1821 $xl::s{l_acc_gtls_pri},
1822 $xl::s{h_acc_gtls_pri},
1829 sub new_account_subpage($) {
1831 return new_vbox_pack (
1834 new_check_button_for (\%pr::acc, 'tls_set', $ACHPVALUE{$akey}),
1835 new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey})),
1836 _('GnuTLS priority'), 'not-packed')
1840 sub new_accounts_page() {
1841 my $accbook = Gtk2::Notebook->new;
1842 $accbook->set_tab_pos ('right');
1843 foreach (keys %ACPREFS) {
1844 my $name = $ACPREFS{$_}{'account_name'};
1845 $accbook->append_page (new_account_subpage ($_), $name);
1850 %pr::plu = ( # plugins hidden preferences
1856 'int,0,3000', # 0 pixels - 3000 pixels
1865 'int,0,3000', # 0 pixels - 3000 pixels
1873 $xl::s{l_plu_lav_burl},
1874 $xl::s{h_plu_lav_burl},
1877 'http://cdn.libravatar.org/avatar',
1882 'filter_log_verbosity',
1883 $xl::s{l_plu_prl_flvb},
1884 $xl::s{h_plu_prl_flvb},
1885 '0=l_plu_prl_none;1=l_plu_prl_manual;2=l_plu_prl_action;3=l_plu_prl_match',
1893 sub print_version() {
1894 print $xl::s{about_title} . "\n";
1895 print $xl::s{about_version} . " $VERSION\n";
1896 print "Perl-GLib " . $Glib::VERSION;
1897 # version info stuff appeared in 1.040
1898 if ($Glib::VERSION >= 1.040) {
1899 print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
1900 . _(", running with ") . join(".", &Glib::major_version,
1901 &Glib::minor_version, &Glib::micro_version);
1904 print "Perl-GTK2 " . $Gtk2::VERSION;
1905 if ($Gtk2::VERSION >= 1.040) {
1906 print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
1907 . _(", running with ") . join(".", &Gtk2::major_version,
1908 &Gtk2::minor_version, &Gtk2::micro_version);
1911 my $clawsver = ($CLAWSV eq "") ?
1912 _("was not found!") :
1913 (_("returned version ") . $CLAWSV);
1914 print "Claws Mail " . $clawsver . "\n";
1917 # the command line help
1919 my $line = '-' x length ($xl::s{about_title}) . "\n";
1921 print $xl::s{about_title} . "\n";
1923 print _("Syntax:\n");
1924 print _(" clawsker [options]\n");
1925 print _("Options:\n");
1926 print _(" -h|--help Prints this help screen.\n");
1927 print _(" -v|--version Prints version infos.\n");
1928 print _(" -b|--verbose More messages on standard output.\n");
1929 print _(" -a|--alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
1930 print _(" -c|--clawsrc <file> Uses <file> as full resource name.\n");
1933 sub parse_command_line {
1935 $CLAWSV = get_claws_version ();
1937 GetOptions('h|help' => sub { print_help (); $cont = FALSE },
1938 'v|version' => sub { print_version (); $cont = FALSE },
1939 'b|verbose' => sub { $VERBOSE = TRUE },
1940 'r|read-only' => sub { $READONLY = TRUE },
1941 'u|use-claws-version=s' => \&opt_use_claws_version,
1942 'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
1943 'c|clawsrc=s' => \&opt_clawsrc)
1944 or die _("try -h or --help for syntax.\n");
1947 my $msg = _("Error in options: {msg}\n", msg => $@);
1948 if (defined $ENV{'DISPLAY'} and $ENV{'DISPLAY'} ne '') {
1949 eval { Gtk2->init };
1950 error_dialog ($msg) unless $@;
1957 sub opt_use_claws_version {
1958 my ($name, $value) = @_;
1959 die _("Error: {opt} requires a dotted numeric value argument\n", opt => $name)
1960 unless ($value =~ /^[\d\.]+$/);
1964 sub opt_alternate_config_dir {
1965 my ($name, $value) = @_;
1966 die _("Error: '{dir}' is not a directory or does not exist\n", dir => $value)
1968 $CONFIGDIR = $value;
1969 $CONFIGDIR .= "/" unless ($CONFIGDIR =~ /.*\/$/);
1970 $ALTCONFIGDIR = TRUE;
1974 my ($name, $value) = @_;
1975 die _("Error: '{value}' is not a file or does not exist\n", value => $value)
1977 set_rc_filename ($value);
1980 # update the hidden preferences status from loaded values
1981 sub init_hidden_preferences {
1982 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
1983 foreach my $key (keys %$hash) {
1984 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
1990 sub init_ac_hidden_preferences {
1991 foreach my $akey (keys %ACPREFS) {
1992 foreach my $key (keys %pr::acc) {
1993 my $pname = $pr::acc{$key}[NAME];
1994 $ACHPVALUE{$akey}{$pname} = $ACPREFS{$akey}{$pname};
2000 # load current status from disc
2001 sub load_preferences {
2002 my $rc = get_rc_filename ();
2003 log_message ("Loading preferences from $rc\n");
2004 return FALSE unless check_rc_file ($rc);
2005 return FALSE unless check_claws_not_running ();
2009 if (/^([8a-z_]+)=(.*)$/) {
2010 $PREFS{$1} = decode('UTF-8', $2);
2017 sub load_ac_preferences {
2018 my $rc = get_ac_rc_filename ();
2019 log_message ("Loading account preferences from $rc\n");
2020 return FALSE unless check_rc_file ($rc);
2021 return FALSE unless check_claws_not_running ();
2026 if (/^\[Account: (\d+)\]$/) {
2030 if (/^([8a-z_]+)=(.*)$/) {
2031 $ACPREFS{$akey}{$1} = decode('UTF-8', $2);
2038 # save current preferences to disc
2039 sub save_preferences {
2040 my $rc = get_rc_filename ();
2041 log_message ("Saving preferences to $rc\n");
2042 return FALSE unless check_rc_file ($rc);
2043 return FALSE unless check_claws_not_running ();
2044 my $rcbak = "$rc.backup";
2045 rename ($rc, $rcbak);
2047 open (RCB, "<$rcbak");
2050 if (/^([8a-z_]+)=(.*)$/) {
2051 if (defined($HPVALUE{$1})) {
2052 print RCF $1 . "=" . $HPVALUE{$1} . "\n";
2055 print RCF $_ . "\n";
2059 print RCF $_ . "\n";
2067 sub save_ac_preferences {
2068 my $rc = get_ac_rc_filename ();
2069 log_message ("Saving account preferences to $rc\n");
2070 return FALSE unless check_rc_file ($rc);
2071 return FALSE unless check_claws_not_running ();
2072 my $rcbak = "$rc.backup";
2073 rename ($rc, $rcbak);
2075 open (RCB, "<$rcbak");
2079 if (/^\[Account: (\d+)\]$/) {
2081 print RCF $_ . "\n";
2084 if (/^([8a-z_]+)=(.*)$/) {
2085 if (defined($ACHPVALUE{$akey}{$1})) {
2086 print RCF $1 . "=" . $ACHPVALUE{$akey}{$1} . "\n";
2089 print RCF $_ . "\n";
2093 print RCF $_ . "\n";
2103 my $nb = Gtk2::Notebook->new;
2105 $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
2106 $nb->append_page (new_colours_page (), $xl::s{tab_colours});
2107 $nb->append_page (new_gui_page (), $xl::s{tab_gui});
2108 $nb->append_page (new_other_page (), $xl::s{tab_other});
2109 $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
2110 $nb->append_page (new_accounts_page (), $xl::s{tab_accounts});
2115 # create an about dialog
2116 sub new_about_dialog {
2118 my $title = $xl::s{about_title};
2119 my $lic = $xl::s{about_license};
2120 my $vers = $xl::s{about_version} . " $VERSION";
2122 "This program is free software: you can redistribute it and/or modify
2123 it under the terms of the GNU General Public License as published by
2124 the Free Software Foundation, either version 3 of the License, or
2125 (at your option) any later version.
2127 This program is distributed in the hope that it will be useful,
2128 but WITHOUT ANY WARRANTY; without even the implied warranty of
2129 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2130 GNU General Public License for more details.
2132 You should have received a copy of the GNU General Public License
2133 along with this program. If not, see <http://www.gnu.org/licenses/>.";
2134 my $year = "2007-2016";
2135 my $holder = "Ricardo Mones <ricardo\@mones.org>";
2136 my $url = "http://www.claws-mail.org/clawsker.php";
2138 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
2139 [qw/modal destroy-with-parent/],
2141 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
2142 . "<span size=\"large\">$vers</span>\n\n"
2143 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2144 . "<span>Copyright $year by $holder</span>\n\n"
2145 . "<span size=\"large\">$lic</span>\n\n"
2146 . "<span size=\"small\">$license</span>");
2147 $dialog->set_title ($xl::s{about});
2152 # create buttons box
2153 sub new_button_box {
2154 my ($parent, $adlg) = @_;
2155 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2156 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2157 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2158 # disable button until is really implemented
2159 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2160 my $hbox = Gtk2::HBox->new (FALSE, 5);
2162 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2163 $b_apply->set_sensitive (not $READONLY);
2164 $b_apply->signal_connect (clicked => sub {
2165 save_preferences ($parent);
2166 save_ac_preferences ($parent);
2168 # $b_undo->signal_connect (clicked => sub { undo_current_changes });
2169 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2171 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2172 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2173 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2174 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2180 my $dir = $DATADIR . '/icons/hicolor';
2182 join ('/', ($dir, , $_ . 'x' . $_, 'apps', $NAME . '.png'))
2187 $icon = Gtk2::Gdk::Pixbuf->new_from_file($_) if (-f $_);
2188 push @icons, $icon if ($icon);
2194 exit unless parse_command_line ();
2196 $main_window = Gtk2::Window->new ('toplevel');
2197 exit unless load_preferences ();
2198 exit unless load_ac_preferences ();
2199 exit unless init_hidden_preferences ();
2200 exit unless init_ac_hidden_preferences ();
2202 my $box = Gtk2::VBox->new (FALSE, 5);
2203 $box->set_border_width(3);
2204 my $about = new_about_dialog ();
2205 $box->pack_start (new_notebook (), FALSE, FALSE, 0);
2206 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
2207 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2208 $main_window->set_title ($xl::s{win_title});
2209 $main_window->set_icon_list (get_app_icons ());
2210 $main_window->add ($box);
2211 $main_window->show_all;