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'),
75 ab_frame => _('Addressbook'),
76 mem_frame => _('Memory'),
77 msgview_frame => _('Message View'),
78 log_frame => _('Log window'),
79 dnd_frame => _('Drag \'n\' drop'),
80 ssl_frame => _('Secure Sockets Layer'),
81 msgs_frame => _('Messages'),
82 swc_frame => _('Completion'),
83 stripes_frame => _('Coloured stripes'),
84 sbar_frame => _('Scroll bars'),
85 mlist_frame => _('Message List'),
86 mview_frame => _('Message View'),
87 compo_frame => _('Compose window'),
88 netm_frame => _('NetworkManager'),
89 diff_frame => _('Viewing patches'),
90 mpass_frame => _('Master passphrase'),
92 l_oth_use_dlg => _('Use detached address book edit dialogue'),
93 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.'),
94 l_oth_max_use => _('Maximum memory for message cache (kB)'),
95 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
96 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
97 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.'),
98 l_oth_use_netm => _('Use NetworkManager'),
99 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
100 l_oth_mp_rounds => _('Rounds for PBKDF2 function'),
101 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.'),
103 l_gui_b_unread => _('Show unread messages with bold font'),
104 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
105 l_gui_no_markup => _('Don\'t use markup'),
106 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
107 l_gui_dot_lines => _('Use dotted lines in tree view components'),
108 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.'),
109 l_gui_h_scroll => _('Enable horizontal scrollbar'),
110 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
111 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
112 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.'),
113 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
114 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
115 l_gui_v_scroll_show => _('Show always'),
116 l_gui_v_scroll_auto => _('Automatic'),
117 l_gui_v_scroll_hide => _('Hide always'),
118 l_gui_from_show => _('From column displays'),
119 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both.'),
120 l_gui_from_show_name => _('Name only'),
121 l_gui_from_show_addr => _('Address only'),
122 l_gui_from_show_both => _('Both name and address'),
123 l_gui_strip_off => _('Coloured lines contrast'),
124 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.'),
125 l_gui_cursor_v => _('Show cursor'),
126 h_gui_cursor_v => _('Display the cursor in the Message View.'),
127 l_gui_toolbar_d => _('Detachable toolbars'),
128 h_gui_toolbar_d => _('Show handles in the toolbars.'),
129 l_gui_strip_all => _('Use stripes in all tree view components'),
130 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
131 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
132 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
133 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
134 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
135 l_gui_margin_co => _('Show margin'),
136 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
137 l_gui_mview_date => _('Don\'t display localized date'),
138 h_gui_mview_date => _('Toggles localization of date format in Message View.'),
139 l_gui_zero_char => _('Zero replacement character'),
140 h_gui_zero_char => _('Replaces \'0\' with the given character in Folder List.'),
141 l_gui_type_any => _('Editable headers'),
142 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.'),
143 l_gui_next_del => _('Select next message on delete'),
144 h_gui_next_del => _('When deleting a message, toggles between selecting the next one (newer message) or the previous one (older message).'),
146 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
147 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.'),
148 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
149 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
150 l_beh_flowed => _('Respect format=flowed in messages'),
151 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.'),
152 l_beh_parts_rw => _('Allow writable temporary files'),
153 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
154 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
155 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
156 l_beh_up_step => _('Progress bar update step (items)'),
157 h_beh_up_step => _('Update stepping in progress bars.'),
158 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
159 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
160 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
161 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
162 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
163 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
164 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
165 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
166 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
167 h_beh_out_ascii => _('If content allows, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is enforced always.'),
168 l_beh_pp_unsel => _('Primary paste unselects selection'),
169 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
170 l_beh_inline_at => _('Show inline attachments'),
171 h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view.'),
172 l_beh_addr_swc => _('Address search in compose window matches any'),
173 h_beh_addr_swc => _('On Tab-key completion, address text will match any part of the string or only from the start.'),
174 l_beh_fold_swc => _('Folder search in folder selector matches any'),
175 h_beh_fold_swc => _('On folder name completion text will match any part of the string or only from the start.'),
177 l_col_emphasis => _('X-Mailer header'),
178 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
179 l_col_log_err => _('Error messages'),
180 h_col_log_err => _('Colour for error messages in log window.'),
181 l_col_log_in => _('Server messages'),
182 h_col_log_in => _('Colour for messages received from servers in log window.'),
183 l_col_log_msg => _('Standard messages'),
184 h_col_log_msg => _('Colour for messages in log window.'),
185 l_col_log_out => _('Client messages'),
186 h_col_log_out => _('Colour for messages sent to servers in log window.'),
187 l_col_log_warn => _('Warnings'),
188 h_col_log_warn => _('Colour for warning messages in log window.'),
190 l_col_diff_add => _('Added lines'),
191 h_col_diff_add => _('Colour for added lines in patches.'),
192 l_col_diff_del => _('Deleted lines'),
193 h_col_diff_del => _('Colour for deleted lines in patches.'),
194 l_col_diff_hunk => _('Hunk lines'),
195 h_col_diff_hunk => _('Color for hunk headers in patches.'),
197 l_win_x => _('X position'),
198 h_win_x => _('X coordinate for window\'s top-left corner.'),
199 l_win_y => _('Y position'),
200 h_win_y => _('Y coordinate for window\'s top-left corner.'),
201 l_win_w => _('Width'),
202 h_win_w => _('Window\'s width in pixels.'),
203 l_win_h => _('Height'),
204 h_win_h => _('Window\'s height in pixels.'),
206 l_win_main_mx => _('Maximized'),
207 h_win_main_mx => _('Changes window maximized status.'),
208 l_win_main_fs => _('Full-screen'),
209 h_win_main_fs => _('Changes full screen status.'),
211 l_acc_gtls_set => _('Use custom GnuTLS priority'),
212 h_acc_gtls_set => _('Enables using user provided GnuTLS priority string.'),
213 l_acc_gtls_pri => _('GnuTLS priority'),
214 h_acc_gtls_pri => _('Value to use as GnuTLS priority string if custom priority check is enabled. Otherwise this value is ignored.'),
216 l_plu_lav_burl => _('Base URL'),
217 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.'),
218 l_plu_prl_flvb => _('Log level'),
219 h_plu_prl_flvb => _('Verbosity level of log, acumulative.'),
220 l_plu_prl_none => _('None'),
221 l_plu_prl_manual => _('Manual'),
222 l_plu_prl_action => _('Actions'),
223 l_plu_prl_match => _('Matches'),
225 e_error => _('Error: '),
226 e_noclawsrc => _('resource file for Claws Mail was not found.'),
227 e_running => _('seems Claws Mail is currently running, close it first.'),
230 # data and metadata of resource files
235 # all preferences read by load_preferences
239 # values of all preferences handled by clawsker
243 # default config dir and file name
244 my $ALTCONFIGDIR = FALSE;
245 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
246 my $CONFIGRC = 'clawsrc';
247 my $ACCOUNTRC = 'accountrc';
249 # index constants for preference arrays
250 use constant NAME => 0; # the name on the rc file
251 use constant LABEL => 1; # the label on the GUI
252 use constant DESC => 2; # the description for the hint/help
253 use constant TYPE => 3; # data type: bool, int, float, string, color
254 use constant CMVER => 4; # lowest[,highest] Claws Mail version(s) the feature exists
255 use constant CMDEF => 5; # default value for the preference in Claws Mail
256 use constant PLUGIN => 6; # plugin section (only in plugin preferences)
258 # constants for GUI spacing
259 use constant HBOX_SPC => 5;
260 use constant FRAME_SPC => 2;
261 use constant PAGE_SPC => 5;
265 sub version_greater_or_equal {
266 my ($version, $refvers) = @_;
267 my @version = split (/\./, $version);
268 my @refvers = split (/\./, $refvers);
269 while ($#version < $#refvers) {
270 push (@version, '0');
273 while (($idx <= $#refvers)
274 and (int ($version[$idx]) == int ($refvers[$idx]))) {
277 return TRUE if (($idx > $#refvers)
278 or (int ($version[$idx]) >= int ($refvers[$idx])));
282 sub get_claws_version {
283 $_ = qx/which claws-mail/;
285 return "" unless ($_); # not installed
289 my @fver = split (/ /);
290 die "Invalid version string" unless ($fver[2] eq "version");
291 my @ver = split (/\./, $fver[3]);
294 if ($ver[2] =~ /(\d+)git(\d+)/) {
303 # data handlers and auxiliar functions
305 sub handle_bool_value {
306 my ($widget, $event, $dataref) = @_;
307 $$dataref = ($widget->get_active ())? '1': '0';
310 sub handle_int_value {
311 my ($widget, $event, $dataref) = @_;
312 $_ = $widget->get_text ();
317 $widget->set_text ($_);
320 $widget->set_text ($$dataref);
324 sub handle_string_value {
325 my ($widget, $event, $dataref) = @_;
326 $$dataref = $widget->get_text ();
329 sub handle_nchar_value {
330 my ($widget, $event, $dataref, $minlen, $maxlen) = @_;
331 $_ = substr ($widget->get_text (), 0, $maxlen);
332 $widget->set_text ($_);
336 sub gdk_color_from_str {
338 my ($rr, $gg, $bb) = (0, 0 ,0);
340 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
345 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
349 sub str_from_gdk_color {
351 my $rr = $color->red / 256;
352 my $gg = $color->green / 256;
353 my $bb = $color->blue / 256;
354 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
358 sub handle_color_value {
359 my ($widget, $event, $dataref) = @_;
360 my $newcol = $widget->get_color;
361 $$dataref = str_from_gdk_color ($newcol);
364 sub handle_selection_value {
365 my ($widget, $event, $dataref) = @_;
366 $$dataref = $widget->get_active;
369 sub get_rc_filename {
370 return $CONFIGDIR . $CONFIGRC;
373 sub get_ac_rc_filename {
374 return $CONFIGDIR . $ACCOUNTRC;
377 sub set_rc_filename {
379 my @parts = split ('/', $fullname);
380 $CONFIGRC = $parts[$#parts];
381 $parts[$#parts] = '';
382 $CONFIGDIR = join ('/', @parts);
386 my ($mesg, $fatal) = @_;
387 if (defined($fatal) && $fatal eq 'die') {
388 die "$NAME: $mesg\n";
391 print "$NAME: $mesg\n";
397 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
398 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
399 $errordlg->set_title (_('Clawsker error'));
404 sub claws_is_running {
405 my $emsg = "$xl::s{e_error}$xl::s{e_running}";
407 error_dialog ($emsg);
411 sub check_claws_not_running {
412 return TRUE if $READONLY;
413 my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
414 $tmpdir = '/tmp' if ($tmpdir eq '');
415 my $lockdir = "$tmpdir/claws-mail-$<";
419 my $socket = "$lockdir/" . md5_hex ($_);
420 -S $socket and return claws_is_running ();
427 (defined($rcfile) && -f $rcfile) or do {
428 my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
430 error_dialog ($emsg);
436 sub set_widget_hint {
438 my ($wdgt, $hint) = @_;
439 $wdgt->set_tooltip_text ($hint);
440 $wdgt->set_has_tooltip (TRUE);
444 sub set_widget_sens {
445 my ($wdgt, $versions) = @_;
446 my @ver = split(/,/, $versions);
448 $wdgt->set_sensitive (
449 version_greater_or_equal ($CLAWSV, $ver[0])
450 and version_greater_or_equal ($ver[1], $CLAWSV)
453 $wdgt->set_sensitive (version_greater_or_equal ($CLAWSV, $ver[0]));
457 # graphic element creation
459 sub new_check_button_for($$$) {
460 my ($hash, $key, $vhash) = @_;
461 my $name = $$hash{$key}[NAME];
462 my $label = $$hash{$key}[LABEL];
464 my $hbox = Gtk2::HBox->new (FALSE, 5);
465 my $cb = Gtk2::CheckButton->new ($label);
466 my $value = $$vhash{$name};
467 $value //= $$hash{$key}[CMDEF];
468 $cb->set_active ($value eq '1');
469 $cb->signal_connect (clicked => sub {
471 handle_bool_value ($w, $e, \$$vhash{$name});
473 set_widget_hint ($cb, $$hash{$key}[DESC]);
474 set_widget_sens ($cb, $$hash{$key}[CMVER]);
475 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
480 sub new_text_box_for_int($$$) {
481 my ($hash, $key, $vhash) = @_;
482 my $name = $$hash{$key}[NAME];
483 my $label = $$hash{$key}[LABEL];
484 my @type = split (/,/, $$hash{$key}[TYPE]);
485 push (@type, 0), push (@type, 10000) unless ($#type > 0);
487 my $hbox = Gtk2::HBox->new (FALSE, 5);
488 my $glabel = Gtk2::Label->new ($label);
489 my $pagei = int (($type[2] - $type[1]) / 10);
490 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
491 my $value = $$vhash{$name};
492 $value //= $$hash{$key}[CMDEF];
493 $gentry->set_numeric (TRUE);
494 $gentry->set_value ($value);
495 $gentry->signal_connect('value-changed' => sub {
497 handle_int_value ($w, $e, \$$vhash{$name});
499 set_widget_hint ($gentry, $$hash{$key}[DESC]);
500 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
501 $glabel->set_sensitive ($gentry->sensitive);
502 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
503 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
508 sub new_text_box_for_nchar($$$) {
509 my ($hash, $key, $vhash) = @_;
510 my $name = $$hash{$key}[NAME];
511 my $label = $$hash{$key}[LABEL];
512 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen,width
513 my $hbox = Gtk2::HBox->new (FALSE, 5);
514 my $glabel = Gtk2::Label->new ($label);
515 my $gentry = Gtk2::Entry->new ();
516 $gentry->set_max_length($type[2]) if defined ($type[2]);
517 my $width = $type[3];
519 $gentry->set_width_chars(int ($width) + 2) if defined ($width);
520 my $value = $$vhash{$name};
521 $value //= $$hash{$key}[CMDEF];
522 $gentry->set_text ($value);
523 $gentry->signal_connect('key-release-event' => sub {
525 handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1], $type[2]);
527 set_widget_hint ($gentry, $$hash{$key}[DESC]);
528 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
529 $glabel->set_sensitive ($gentry->sensitive);
530 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
531 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
536 sub new_color_button_for($$$) {
537 my ($hash, $key, $vhash) = @_;
538 my $name = $$hash{$key}[NAME];
539 my $label = $$hash{$key}[LABEL];
541 my $value = $$vhash{$name};
542 $value //= $$hash{$key}[CMDEF];
543 my $col = gdk_color_from_str ($value);
544 my $hbox = Gtk2::HBox->new (FALSE, 5);
545 my $glabel = Gtk2::Label->new ($label);
546 my $button = Gtk2::ColorButton->new_with_color ($col);
547 $button->set_title ($label);
548 $button->set_relief ('none');
549 $button->signal_connect ('color-set' => sub {
551 handle_color_value ($w, $e, \$$vhash{$name});
553 set_widget_hint ($button, $$hash{$key}[DESC]);
554 set_widget_sens ($button, $$hash{$key}[CMVER]);
555 $glabel->set_sensitive ($button->sensitive);
556 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
557 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
562 sub new_selection_box_for($$$) {
563 my ($hash, $key, $vhash) = @_;
564 my $name = $$hash{$key}[NAME];
565 my $label = $$hash{$key}[LABEL];
567 my $hbox = Gtk2::HBox->new (FALSE, 5);
568 my $glabel = Gtk2::Label->new ($label);
569 my $combo = Gtk2::ComboBox->new_text;
570 my @options = split (';', $$hash{$key}[TYPE]);
571 foreach my $opt (@options) {
572 my ($index, $textkey) = split ('=', $opt);
573 $combo->insert_text ($index, $xl::s{$textkey});
575 $combo->signal_connect ('changed' => sub {
577 handle_selection_value ($w, $e, \$$vhash{$name});
579 my $value = $$vhash{$name};
580 $value //= $$hash{$key}[CMDEF];
581 $combo->set_active ($value);
582 set_widget_hint ($combo, $$hash{$key}[DESC]);
583 set_widget_sens ($combo, $$hash{$key}[CMVER]);
584 $glabel->set_sensitive ($combo->sensitive);
585 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
586 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
591 # more graphic helpers
594 my $hbox = Gtk2::HBox->new (FALSE, 5);
595 $hbox->set_border_width (PAGE_SPC);
596 foreach my $item (@_) {
597 $hbox->pack_start ($item, FALSE, FALSE, 0);
603 my $vbox = Gtk2::VBox->new (FALSE, 5);
604 $vbox->set_border_width (PAGE_SPC);
605 foreach my $item (@_) {
606 $vbox->pack_start ($item, FALSE, FALSE, 0);
611 sub new_vbox_pack_compact {
612 my $vbox = Gtk2::VBox->new (FALSE, 0);
613 $vbox->set_border_width (0);
614 foreach my $item (@_) {
615 $vbox->pack_start ($item, FALSE, FALSE, 0);
620 sub new_subpage_frame {
621 my ($box, $title, $notpacked) = @_;
622 my $frame = Gtk2::Frame->new ($title);
624 return new_vbox_pack ($frame) unless defined ($notpacked);
628 # preference maps and corresponding page creation subs
630 %pr::oth = ( # other preferences
632 'addressbook_use_editaddress_dialog',
633 $xl::s{l_oth_use_dlg},
634 $xl::s{h_oth_use_dlg},
640 'cache_max_mem_usage',
641 $xl::s{l_oth_max_use},
642 $xl::s{h_oth_max_use},
643 'int,0,262144', # 0 Kb - 256 Mb
648 'cache_min_keep_time',
649 $xl::s{l_oth_min_time},
650 $xl::s{h_oth_min_time},
651 'int,0,120', # 0 minutes - 2 hours
656 'use_networkmanager',
657 $xl::s{l_oth_use_netm},
658 $xl::s{h_oth_use_netm},
664 'master_passphrase_pbkdf2_rounds',
665 $xl::s{l_oth_mp_rounds},
666 $xl::s{h_oth_mp_rounds},
673 sub new_other_page() {
674 return new_vbox_pack (
677 new_check_button_for(\%pr::oth, 'use_dlg', \%HPVALUE)),
678 $xl::s{ab_frame}, 'not-packed'),
681 new_text_box_for_int(\%pr::oth, 'max_use', \%HPVALUE),
682 new_text_box_for_int(\%pr::oth, 'min_time', \%HPVALUE)),
683 $xl::s{mem_frame}, 'not-packed'),
686 new_check_button_for(\%pr::oth, 'use_netm', \%HPVALUE)),
687 $xl::s{netm_frame}, 'not-packed'),
690 new_text_box_for_int(\%pr::oth, 'mp_rounds', \%HPVALUE)),
691 $xl::s{mpass_frame}, 'not-packed')
695 %pr::gui = ( # gui bells and whistles
698 $xl::s{l_gui_b_unread},
699 $xl::s{h_gui_b_unread},
706 $xl::s{l_gui_no_markup},
707 $xl::s{h_gui_no_markup},
713 'enable_dotted_lines',
714 $xl::s{l_gui_dot_lines},
715 $xl::s{h_gui_dot_lines},
722 $xl::s{l_gui_h_scroll},
723 $xl::s{h_gui_h_scroll},
730 $xl::s{l_gui_swp_from},
731 $xl::s{h_gui_swp_from},
737 'folderview_vscrollbar_policy',
738 $xl::s{l_gui_v_scroll},
739 $xl::s{h_gui_v_scroll},
740 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
746 $xl::s{l_gui_from_show},
747 $xl::s{h_gui_from_show},
748 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
753 'stripes_color_offset',
754 $xl::s{l_gui_strip_off},
755 $xl::s{h_gui_strip_off},
756 'int,0,40000', # no idea what this number means
761 'textview_cursor_visible',
762 $xl::s{l_gui_cursor_v},
763 $xl::s{h_gui_cursor_v},
769 'toolbar_detachable',
770 $xl::s{l_gui_toolbar_d},
771 $xl::s{h_gui_toolbar_d},
777 'use_stripes_everywhere',
778 $xl::s{l_gui_strip_all},
779 $xl::s{h_gui_strip_all},
785 'use_stripes_in_summaries',
786 $xl::s{l_gui_strip_sum},
787 $xl::s{h_gui_strip_sum},
794 $xl::s{l_gui_two_line_v},
795 $xl::s{h_gui_two_line_v},
801 'show_compose_margin',
802 $xl::s{l_gui_margin_co},
803 $xl::s{h_gui_margin_co},
809 'msgview_date_format',
810 $xl::s{l_gui_mview_date},
811 $xl::s{h_gui_mview_date},
817 'zero_replacement_char',
818 $xl::s{l_gui_zero_char},
819 $xl::s{h_gui_zero_char},
826 $xl::s{l_gui_type_any},
827 $xl::s{h_gui_type_any},
834 $xl::s{l_gui_next_del},
835 $xl::s{h_gui_next_del},
843 my $gf = Gtk2::VBox->new (FALSE, 5);
844 $gf->set_border_width (PAGE_SPC);
846 my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines', \%HPVALUE);
847 my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d', \%HPVALUE);
848 my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char', \%HPVALUE);
850 $gf->pack_start (new_subpage_frame (
852 new_check_button_for (\%pr::gui, 'strip_all', \%HPVALUE),
853 new_check_button_for (\%pr::gui, 'strip_sum', \%HPVALUE),
854 new_text_box_for_int (\%pr::gui, 'strip_off', \%HPVALUE)),
855 $xl::s{stripes_frame}, 'not-packed'),
856 FALSE, FALSE, FRAME_SPC);
857 $gf->pack_start (new_subpage_frame (
859 new_check_button_for (\%pr::gui, 'b_unread', \%HPVALUE),
860 new_check_button_for (\%pr::gui, 'swp_from', \%HPVALUE),
861 new_check_button_for (\%pr::gui, 'two_linev', \%HPVALUE),
862 new_check_button_for (\%pr::gui, 'next_del', \%HPVALUE),
863 new_selection_box_for (\%pr::gui, 'from_show', \%HPVALUE)),
864 $xl::s{mlist_frame}, 'not-packed'),
865 FALSE, FALSE, FRAME_SPC);
866 $gf->pack_start (new_subpage_frame (
868 new_check_button_for (\%pr::gui, 'cursor_v', \%HPVALUE),
869 new_check_button_for (\%pr::gui, 'mview_date', \%HPVALUE)),
870 $xl::s{mview_frame}, 'not-packed'),
871 FALSE, FALSE, FRAME_SPC);
872 $gf->pack_start (new_subpage_frame (
874 new_check_button_for (\%pr::gui, 'no_markup', \%HPVALUE),
875 new_check_button_for (\%pr::gui, 'margin_co', \%HPVALUE),
876 new_check_button_for (\%pr::gui, 'type_any', \%HPVALUE)),
877 $xl::s{compo_frame}, 'not-packed'),
878 FALSE, FALSE, FRAME_SPC);
879 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
880 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
881 $gf->pack_start (new_subpage_frame (
883 new_check_button_for (\%pr::gui, 'h_scroll', \%HPVALUE),
884 new_selection_box_for (\%pr::gui, 'v_scroll', \%HPVALUE)),
885 $xl::s{sbar_frame}, 'not-packed'),
886 FALSE, FALSE, FRAME_SPC);
887 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
892 %pr::beh = ( # tweak some behaviour
895 $xl::s{l_beh_hover_t},
896 $xl::s{h_beh_hover_t},
897 'int,100,3000', # 0.1 seconds - 3 seconds
903 $xl::s{l_beh_dangerous},
904 $xl::s{h_beh_dangerous},
910 'respect_flowed_format',
911 $xl::s{l_beh_flowed},
912 $xl::s{h_beh_flowed},
918 'save_parts_readwrite',
919 $xl::s{l_beh_parts_rw},
920 $xl::s{h_beh_parts_rw},
926 'skip_ssl_cert_check',
927 $xl::s{l_beh_skip_ssl},
928 $xl::s{h_beh_skip_ssl},
934 'statusbar_update_step',
935 $xl::s{l_beh_up_step},
936 $xl::s{h_beh_up_step},
937 'int,1,200', # 1 item - 200 items
942 'thread_by_subject_max_age',
943 $xl::s{l_beh_thread_a},
944 $xl::s{h_beh_thread_a},
945 'int,1,30', # 1 day - 30 days
951 $xl::s{l_beh_unsafe_ssl},
952 $xl::s{h_beh_unsafe_ssl},
958 'utf8_instead_of_locale_for_broken_mail',
959 $xl::s{l_beh_use_utf8},
960 $xl::s{h_beh_use_utf8},
967 $xl::s{l_beh_warn_dnd},
968 $xl::s{h_beh_warn_dnd},
974 'outgoing_fallback_to_ascii',
975 $xl::s{l_beh_out_ascii},
976 $xl::s{h_beh_out_ascii},
982 'primary_paste_unselects',
983 $xl::s{l_beh_pp_unsel},
984 $xl::s{h_beh_pp_unsel},
990 'show_inline_attachments',
991 $xl::s{l_beh_inline_at},
992 $xl::s{h_beh_inline_at},
998 'address_search_wildcard',
999 $xl::s{l_beh_addr_swc},
1000 $xl::s{h_beh_addr_swc},
1006 'folder_search_wildcard',
1007 $xl::s{l_beh_fold_swc},
1008 $xl::s{h_beh_fold_swc},
1015 sub new_behaviour_page() {
1016 my $bf = Gtk2::VBox->new (FALSE, 5);
1017 $bf->set_border_width (PAGE_SPC);
1019 my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step', \%HPVALUE);
1020 my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a', \%HPVALUE);
1022 $bf->pack_start (new_subpage_frame (
1024 new_text_box_for_int (\%pr::beh, 'hover_t', \%HPVALUE),
1025 new_check_button_for (\%pr::beh, 'warn_dnd', \%HPVALUE)),
1026 $xl::s{dnd_frame}, 'not-packed'),
1027 FALSE, FALSE, FRAME_SPC);
1028 $bf->pack_start (new_subpage_frame (
1030 new_check_button_for (\%pr::beh, 'skip_ssl', \%HPVALUE),
1031 new_check_button_for (\%pr::beh, 'unsafe_ssl', \%HPVALUE)),
1032 $xl::s{ssl_frame}, 'not-packed'),
1033 FALSE, FALSE, FRAME_SPC);
1034 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
1035 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
1036 $bf->pack_start (new_subpage_frame (
1038 new_check_button_for (\%pr::beh, 'flowed', \%HPVALUE),
1039 new_check_button_for (\%pr::beh, 'parts_rw', \%HPVALUE),
1040 new_check_button_for (\%pr::beh, 'use_utf8', \%HPVALUE),
1041 new_check_button_for (\%pr::beh, 'dangerous', \%HPVALUE),
1042 new_check_button_for (\%pr::beh, 'out_ascii', \%HPVALUE),
1043 new_check_button_for (\%pr::beh, 'pp_unsel', \%HPVALUE),
1044 new_check_button_for (\%pr::beh, 'inline_at', \%HPVALUE)),
1045 $xl::s{msgs_frame}, 'not-packed'),
1046 FALSE, FALSE, FRAME_SPC);
1047 $bf->pack_start (new_subpage_frame (
1049 new_check_button_for (\%pr::beh, 'addr_swc', \%HPVALUE),
1050 new_check_button_for (\%pr::beh, 'fold_swc', \%HPVALUE)),
1051 $xl::s{swc_frame}, 'not-packed'),
1052 FALSE, FALSE, FRAME_SPC);
1056 %pr::col = ( # a variety of colours
1059 $xl::s{l_col_emphasis},
1060 $xl::s{h_col_emphasis},
1067 $xl::s{l_col_log_err},
1068 $xl::s{h_col_log_err},
1075 $xl::s{l_col_log_in},
1076 $xl::s{h_col_log_in},
1083 $xl::s{l_col_log_msg},
1084 $xl::s{h_col_log_msg},
1091 $xl::s{l_col_log_out},
1092 $xl::s{h_col_log_out},
1099 $xl::s{l_col_log_warn},
1100 $xl::s{h_col_log_warn},
1107 $xl::s{l_col_diff_add},
1108 $xl::s{h_col_diff_add},
1114 'diff_deleted_color',
1115 $xl::s{l_col_diff_del},
1116 $xl::s{h_col_diff_del},
1123 $xl::s{l_col_diff_hunk},
1124 $xl::s{h_col_diff_hunk},
1131 sub new_colours_page() {
1132 return new_vbox_pack (
1135 new_color_button_for (\%pr::col, 'emphasis', \%HPVALUE)),
1136 $xl::s{msgview_frame}, 'not-packed'),
1139 new_color_button_for (\%pr::col, 'log_err', \%HPVALUE),
1140 new_color_button_for (\%pr::col, 'log_in', \%HPVALUE),
1141 new_color_button_for (\%pr::col, 'log_msg', \%HPVALUE),
1142 new_color_button_for (\%pr::col, 'log_out', \%HPVALUE),
1143 new_color_button_for (\%pr::col, 'log_warn', \%HPVALUE)),
1144 $xl::s{log_frame}, 'not-packed'),
1147 new_color_button_for (\%pr::col, 'diff_add', \%HPVALUE),
1148 new_color_button_for (\%pr::col, 'diff_del', \%HPVALUE),
1149 new_color_button_for (\%pr::col, 'diff_hunk', \%HPVALUE)),
1150 $xl::s{diff_frame}, 'not-packed')
1154 %pr::win = ( # tweak window positions and/or sizes
1159 'int,0,3000', # 0 pixels - 3000 pixels
1167 'int,0,3000', # 0 pixels - 3000 pixels
1175 'int,0,3000', # 0 pixels - 3000 pixels
1183 'int,0,3000', # 0 pixels - 3000 pixels
1188 'mainwin_maximised',
1189 $xl::s{l_win_main_mx},
1190 $xl::s{h_win_main_mx},
1196 'mainwin_fullscreen',
1197 $xl::s{l_win_main_fs},
1198 $xl::s{h_win_main_fs},
1204 'main_messagewin_x',
1207 'int,0,3000', # 0 pixels - 3000 pixels
1212 'main_messagewin_y',
1215 'int,0,3000', # 0 pixels - 3000 pixels
1223 'int,0,3000', # 0 pixels - 3000 pixels
1228 'messagewin_height',
1231 'int,0,3000', # 0 pixels - 3000 pixels
1239 'int,0,3000', # 0 pixels - 3000 pixels
1247 'int,0,3000', # 0 pixels - 3000 pixels
1255 'int,0,3000', # 0 pixels - 3000 pixels
1260 'receivewin_height',
1263 'int,0,3000', # 0 pixels - 3000 pixels
1271 'int,0,3000', # 0 pixels - 3000 pixels
1279 'int,0,3000', # 0 pixels - 3000 pixels
1284 'folderitemwin_width',
1287 'int,0,3000', # 0 pixels - 3000 pixels
1292 'folderitemwin_height',
1295 'int,0,3000', # 0 pixels - 3000 pixels
1300 'folderselwin_width',
1303 'int,0,3000', # 0 pixels - 3000 pixels
1308 'folderselwin_height',
1311 'int,0,3000', # 0 pixels - 3000 pixels
1319 'int,0,3000', # 0 pixels - 3000 pixels
1327 'int,0,3000', # 0 pixels - 3000 pixels
1332 'addressbookwin_width',
1335 'int,0,3000', # 0 pixels - 3000 pixels
1340 'addressbookwin_height',
1343 'int,0,3000', # 0 pixels - 3000 pixels
1348 'addressbookeditpersonwin_width',
1351 'int,0,3000', # 0 pixels - 3000 pixels
1356 'addressbookeditpersonwin_height',
1359 'int,0,3000', # 0 pixels - 3000 pixels
1364 'addressbookeditgroupwin_width',
1367 'int,0,3000', # 0 pixels - 3000 pixels
1372 'addressbookeditgroupwin_height',
1375 'int,0,3000', # 0 pixels - 3000 pixels
1380 'addressaddwin_width',
1383 'int,0,3000', # 0 pixels - 3000 pixels
1388 'addressaddwin_height',
1391 'int,0,3000', # 0 pixels - 3000 pixels
1396 'addressbook_folderselwin_width',
1399 'int,0,3000', # 0 pixels - 3000 pixels
1404 'addressbook_folderselwin_height',
1407 'int,0,3000', # 0 pixels - 3000 pixels
1412 'editaccountwin_width',
1415 'int,0,3000', # 0 pixels - 3000 pixels
1420 'editaccountwin_height',
1423 'int,0,3000', # 0 pixels - 3000 pixels
1428 'accountswin_width',
1431 'int,0,3000', # 0 pixels - 3000 pixels
1436 'accountswin_height',
1439 'int,0,3000', # 0 pixels - 3000 pixels
1444 'filteringwin_width',
1447 'int,0,3000', # 0 pixels - 3000 pixels
1452 'filteringwin_height',
1455 'int,0,3000', # 0 pixels - 3000 pixels
1460 'filteringactionwin_width',
1463 'int,0,3000', # 0 pixels - 3000 pixels
1468 'filteringactionwin_height',
1471 'int,0,3000', # 0 pixels - 3000 pixels
1476 'filtering_debugwin_width',
1479 'int,0,3000', # 0 pixels - 3000 pixels
1484 'filtering_debugwin_height',
1487 'int,0,3000', # 0 pixels - 3000 pixels
1495 'int,0,3000', # 0 pixels - 3000 pixels
1500 'matcherwin_height',
1503 'int,0,3000', # 0 pixels - 3000 pixels
1511 'int,0,3000', # 0 pixels - 3000 pixels
1519 'int,0,3000', # 0 pixels - 3000 pixels
1524 'templateswin_width',
1527 'int,0,3000', # 0 pixels - 3000 pixels
1532 'templateswin_height',
1535 'int,0,3000', # 0 pixels - 3000 pixels
1543 'int,0,3000', # 0 pixels - 3000 pixels
1548 'actionswin_height',
1551 'int,0,3000', # 0 pixels - 3000 pixels
1559 'int,0,3000', # 0 pixels - 3000 pixels
1567 'int,0,3000', # 0 pixels - 3000 pixels
1575 'int,0,3000', # 0 pixels - 3000 pixels
1580 'pluginswin_height',
1583 'int,0,3000', # 0 pixels - 3000 pixels
1591 'int,0,3000', # 0 pixels - 3000 pixels
1599 'int,0,3000', # 0 pixels - 3000 pixels
1604 'print_previewwin_width',
1607 'int,0,3000', # 0 pixels - 3000 pixels
1612 'print_previewwin_height',
1615 'int,0,3000', # 0 pixels - 3000 pixels
1621 sub new_winpos_subpage_main() {
1622 return new_subpage_frame (
1623 new_vbox_pack_compact (
1625 new_text_box_for_int (\%pr::win, 'main_x', \%HPVALUE),
1626 new_text_box_for_int (\%pr::win, 'main_y', \%HPVALUE)),
1628 new_text_box_for_int (\%pr::win, 'main_w', \%HPVALUE),
1629 new_text_box_for_int (\%pr::win, 'main_h', \%HPVALUE)),
1631 new_check_button_for (\%pr::win, 'main_fs', \%HPVALUE),
1632 new_check_button_for (\%pr::win, 'main_mx', \%HPVALUE))),
1637 sub new_winpos_subpage_msgs() {
1638 return new_subpage_frame (
1639 new_vbox_pack_compact (
1641 new_text_box_for_int (\%pr::win, 'msgs_x', \%HPVALUE),
1642 new_text_box_for_int (\%pr::win, 'msgs_y', \%HPVALUE)),
1644 new_text_box_for_int (\%pr::win, 'msgs_w', \%HPVALUE),
1645 new_text_box_for_int (\%pr::win, 'msgs_h', \%HPVALUE))),
1650 sub new_winpos_subpage_sendrecv() {
1651 return new_vbox_pack (
1654 new_text_box_for_int (\%pr::win, 'send_w', \%HPVALUE),
1655 new_text_box_for_int (\%pr::win, 'send_h', \%HPVALUE)),
1656 _('Send window'), 'not-packed'),
1659 new_text_box_for_int (\%pr::win, 'recv_w', \%HPVALUE),
1660 new_text_box_for_int (\%pr::win, 'recv_h', \%HPVALUE)),
1661 _('Receive window'), 'not-packed')
1665 sub new_winpos_subpage_fold() {
1666 return new_vbox_pack (
1668 new_vbox_pack_compact (
1670 new_text_box_for_int (\%pr::win, 'fold_x', \%HPVALUE),
1671 new_text_box_for_int (\%pr::win, 'fold_y', \%HPVALUE)),
1673 new_text_box_for_int (\%pr::win, 'fold_w', \%HPVALUE),
1674 new_text_box_for_int (\%pr::win, 'fold_h', \%HPVALUE))),
1675 _('Folder window'), 'not-packed'),
1678 new_text_box_for_int (\%pr::win, 'fsel_w', \%HPVALUE),
1679 new_text_box_for_int (\%pr::win, 'fsel_h', \%HPVALUE)),
1680 _('Folder selection window'), 'not-packed')
1684 sub new_winpos_subpage_addrbook() {
1685 return new_vbox_pack (
1688 new_text_box_for_int (\%pr::win, 'addr_w', \%HPVALUE),
1689 new_text_box_for_int (\%pr::win, 'addr_h', \%HPVALUE)),
1690 _('Addressbook main window'), 'not-packed'),
1693 new_text_box_for_int (\%pr::win, 'adep_w', \%HPVALUE),
1694 new_text_box_for_int (\%pr::win, 'adep_h', \%HPVALUE)),
1695 _('Edit person window'), 'not-packed'),
1698 new_text_box_for_int (\%pr::win, 'adeg_w', \%HPVALUE),
1699 new_text_box_for_int (\%pr::win, 'adeg_h', \%HPVALUE)),
1700 _('Edit group window'), 'not-packed'),
1703 new_text_box_for_int (\%pr::win, 'adda_w', \%HPVALUE),
1704 new_text_box_for_int (\%pr::win, 'adda_h', \%HPVALUE)),
1705 _('Add address window'), 'not-packed'),
1708 new_text_box_for_int (\%pr::win, 'addf_w', \%HPVALUE),
1709 new_text_box_for_int (\%pr::win, 'addf_h', \%HPVALUE)),
1710 _('Folder select window'), 'not-packed')
1714 sub new_winpos_subpage_accounts() {
1715 return new_vbox_pack (
1718 new_text_box_for_int (\%pr::win, 'acco_w', \%HPVALUE),
1719 new_text_box_for_int (\%pr::win, 'acco_h', \%HPVALUE)),
1720 _('Accounts window'), 'not-packed'),
1723 new_text_box_for_int (\%pr::win, 'acce_w', \%HPVALUE),
1724 new_text_box_for_int (\%pr::win, 'acce_h', \%HPVALUE)),
1725 _('Edit account window'), 'not-packed')
1729 sub new_winpos_subpage_filtering() {
1730 return new_vbox_pack (
1733 new_text_box_for_int (\%pr::win, 'filt_w', \%HPVALUE),
1734 new_text_box_for_int (\%pr::win, 'filt_h', \%HPVALUE)),
1735 _('Filtering window'), 'not-packed'),
1738 new_text_box_for_int (\%pr::win, 'fila_w', \%HPVALUE),
1739 new_text_box_for_int (\%pr::win, 'fila_h', \%HPVALUE)),
1740 _('Filtering actions window'), 'not-packed'),
1743 new_text_box_for_int (\%pr::win, 'fild_w', \%HPVALUE),
1744 new_text_box_for_int (\%pr::win, 'fild_h', \%HPVALUE)),
1745 _('Filtering debug window'), 'not-packed'),
1748 new_text_box_for_int (\%pr::win, 'matc_w', \%HPVALUE),
1749 new_text_box_for_int (\%pr::win, 'matc_h', \%HPVALUE)),
1750 _('Matcher window'), 'not-packed')
1754 sub new_winpos_subpage_prefs() {
1755 return new_vbox_pack (
1758 new_text_box_for_int (\%pr::win, 'pref_w', \%HPVALUE),
1759 new_text_box_for_int (\%pr::win, 'pref_h', \%HPVALUE)),
1760 _('Preferences window'), 'not-packed'),
1763 new_text_box_for_int (\%pr::win, 'temp_w', \%HPVALUE),
1764 new_text_box_for_int (\%pr::win, 'temp_h', \%HPVALUE)),
1765 _('Templates window'), 'not-packed'),
1768 new_text_box_for_int (\%pr::win, 'acti_w', \%HPVALUE),
1769 new_text_box_for_int (\%pr::win, 'acti_h', \%HPVALUE)),
1770 _('Actions window'), 'not-packed'),
1773 new_text_box_for_int (\%pr::win, 'tags_w', \%HPVALUE),
1774 new_text_box_for_int (\%pr::win, 'tags_h', \%HPVALUE)),
1775 _('Tags window'), 'not-packed'),
1778 new_text_box_for_int (\%pr::win, 'plug_w', \%HPVALUE),
1779 new_text_box_for_int (\%pr::win, 'plug_h', \%HPVALUE)),
1780 _('Plugins window'), 'not-packed')
1784 sub new_winpos_subpage_misc() {
1785 return new_vbox_pack (
1788 new_text_box_for_int (\%pr::win, 'logw_w', \%HPVALUE),
1789 new_text_box_for_int (\%pr::win, 'logw_h', \%HPVALUE)),
1790 _('Log window'), 'not-packed'),
1793 new_text_box_for_int (\%pr::win, 'prin_w', \%HPVALUE),
1794 new_text_box_for_int (\%pr::win, 'prin_h', \%HPVALUE)),
1795 _('Print preview window'), 'not-packed'),
1798 new_text_box_for_int (\%pr::win, 'sour_w', \%HPVALUE),
1799 new_text_box_for_int (\%pr::win, 'sour_h', \%HPVALUE)),
1800 _('View source window'), 'not-packed')
1804 sub new_winpos_page() {
1805 my $winbook = Gtk2::Notebook->new;
1806 $winbook->set_tab_pos ('right');
1807 $winbook->append_page (new_winpos_subpage_main, _('Main'));
1808 $winbook->append_page (new_winpos_subpage_msgs, _('Message'));
1809 $winbook->append_page (new_winpos_subpage_sendrecv, _('Send/Receive'));
1810 $winbook->append_page (new_winpos_subpage_fold, _('Folder'));
1811 $winbook->append_page (new_winpos_subpage_addrbook, _('Addressbook'));
1812 $winbook->append_page (new_winpos_subpage_accounts, _('Accounts'));
1813 $winbook->append_page (new_winpos_subpage_filtering, _('Filtering'));
1814 $winbook->append_page (new_winpos_subpage_prefs, _('Preferences'));
1815 $winbook->append_page (new_winpos_subpage_misc, _('Other'));
1819 %pr::acc = ( # per account hidden preferences
1821 'gnutls_set_priority',
1822 $xl::s{l_acc_gtls_set},
1823 $xl::s{h_acc_gtls_set},
1830 $xl::s{l_acc_gtls_pri},
1831 $xl::s{h_acc_gtls_pri},
1838 sub new_account_subpage($) {
1840 return new_vbox_pack (
1843 new_check_button_for (\%pr::acc, 'tls_set', $ACHPVALUE{$akey}),
1844 new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey})),
1845 _('GnuTLS priority'), 'not-packed')
1849 sub new_accounts_page() {
1850 my $accbook = Gtk2::Notebook->new;
1851 $accbook->set_tab_pos ('right');
1852 foreach (keys %ACPREFS) {
1853 my $name = $ACPREFS{$_}{'account_name'};
1854 $accbook->append_page (new_account_subpage ($_), $name);
1859 %pr::plu = ( # plugins hidden preferences
1865 'int,0,3000', # 0 pixels - 3000 pixels
1874 'int,0,3000', # 0 pixels - 3000 pixels
1881 'manager_win_width',
1884 'int,0,3000', # 0 pixels - 3000 pixels
1890 'manager_win_height',
1893 'int,0,3000', # 0 pixels - 3000 pixels
1901 $xl::s{l_plu_lav_burl},
1902 $xl::s{h_plu_lav_burl},
1905 'http://cdn.libravatar.org/avatar',
1910 'filter_log_verbosity',
1911 $xl::s{l_plu_prl_flvb},
1912 $xl::s{h_plu_prl_flvb},
1913 '0=l_plu_prl_none;1=l_plu_prl_manual;2=l_plu_prl_action;3=l_plu_prl_match',
1920 sub new_plugins_page() {
1921 return new_vbox_pack (
1924 new_text_box_for_int (\%pr::plu, 'arm_winw', $PLHPVALUE{'AttRemover'}),
1925 new_text_box_for_int (\%pr::plu, 'arm_winh', $PLHPVALUE{'AttRemover'})),
1926 _('Attachment remover'), 'not-packed'),
1929 new_text_box_for_int (\%pr::plu, 'msv_winw', $PLHPVALUE{'ManageSieve'}),
1930 new_text_box_for_int (\%pr::plu, 'msv_winh', $PLHPVALUE{'ManageSieve'})),
1931 _('Sieve manager'), 'not-packed'),
1934 new_text_box_for_nchar (\%pr::plu, 'lav_burl', $PLHPVALUE{'Libravatar'})),
1935 _('Libravatar'), 'not-packed'),
1938 new_selection_box_for (\%pr::plu, 'prl_flvb', $PLHPVALUE{'PerlPlugin'})),
1939 _('Perl'), 'not-packed')
1944 sub print_version() {
1945 print $xl::s{about_title} . "\n";
1946 print $xl::s{about_version} . " $VERSION\n";
1947 print "Perl-GLib " . $Glib::VERSION;
1948 # version info stuff appeared in 1.040
1949 if ($Glib::VERSION >= 1.040) {
1950 print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
1951 . _(", running with ") . join(".", &Glib::major_version,
1952 &Glib::minor_version, &Glib::micro_version);
1955 print "Perl-GTK2 " . $Gtk2::VERSION;
1956 if ($Gtk2::VERSION >= 1.040) {
1957 print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
1958 . _(", running with ") . join(".", &Gtk2::major_version,
1959 &Gtk2::minor_version, &Gtk2::micro_version);
1962 my $clawsver = ($CLAWSV eq "") ?
1963 _("was not found!") :
1964 (_("returned version ") . $CLAWSV);
1965 print "Claws Mail " . $clawsver . "\n";
1968 # the command line help
1970 my $line = '-' x length ($xl::s{about_title}) . "\n";
1972 print $xl::s{about_title} . "\n";
1974 print _("Syntax:\n");
1975 print _(" clawsker [options]\n");
1976 print _("Options:\n");
1977 print _(" -h|--help Prints this help screen.\n");
1978 print _(" -v|--version Prints version infos.\n");
1979 print _(" -b|--verbose More messages on standard output.\n");
1980 print _(" -a|--alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
1981 print _(" -c|--clawsrc <file> Uses <file> as full resource name.\n");
1984 sub parse_command_line {
1986 $CLAWSV = get_claws_version ();
1988 GetOptions('h|help' => sub { print_help (); $cont = FALSE },
1989 'v|version' => sub { print_version (); $cont = FALSE },
1990 'b|verbose' => sub { $VERBOSE = TRUE },
1991 'r|read-only' => sub { $READONLY = TRUE },
1992 'u|use-claws-version=s' => \&opt_use_claws_version,
1993 'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
1994 'c|clawsrc=s' => \&opt_clawsrc)
1995 or die _("try -h or --help for syntax.\n");
1998 my $msg = _("Error in options: {msg}\n", msg => $@);
1999 if (defined $ENV{'DISPLAY'} and $ENV{'DISPLAY'} ne '') {
2000 eval { Gtk2->init };
2001 error_dialog ($msg) unless $@;
2008 sub opt_use_claws_version {
2009 my ($name, $value) = @_;
2010 die _("Error: {opt} requires a dotted numeric value argument\n", opt => $name)
2011 unless ($value =~ /^[\d\.]+$/);
2015 sub opt_alternate_config_dir {
2016 my ($name, $value) = @_;
2017 die _("Error: '{dir}' is not a directory or does not exist\n", dir => $value)
2019 $CONFIGDIR = $value;
2020 $CONFIGDIR .= "/" unless ($CONFIGDIR =~ /.*\/$/);
2021 $ALTCONFIGDIR = TRUE;
2025 my ($name, $value) = @_;
2026 die _("Error: '{value}' is not a file or does not exist\n", value => $value)
2028 set_rc_filename ($value);
2031 # update the hidden preferences status from loaded values
2032 sub init_hidden_preferences {
2033 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
2034 foreach my $key (keys %$hash) {
2035 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
2041 sub init_ac_hidden_preferences {
2042 foreach my $akey (keys %ACPREFS) {
2043 foreach my $key (keys %pr::acc) {
2044 my $pname = $pr::acc{$key}[NAME];
2045 $ACHPVALUE{$akey}{$pname} = $ACPREFS{$akey}{$pname};
2051 sub init_plu_hidden_preferences {
2052 foreach my $key (keys %pr::plu) {
2053 my $plugin = $pr::plu{$key}[PLUGIN];
2054 my $pname = $pr::plu{$key}[NAME];
2055 $PLHPVALUE{$plugin}{$pname} = $PLPREFS{$plugin}{$pname};
2060 # generic load/save resource files
2066 open (RCF, '<:encoding(utf8)', $rc)
2067 or die _("Error: opening '{file}' for reading", file => $rc) . ": $!";
2068 my $section = '_'; # default unnamed section
2073 if (/^\[([^\]]+)\]$/) { # new section
2075 die _("Error: duplicate section '{sect}' in resource file '{file}'\n",
2076 sect => $section, file => $rc) if ($data{$section});
2077 $data{$section} = {};
2078 $meta{$section}{'#'} = $line;
2080 elsif (/^([0-9a-z_]+)=(.*)$/) { # key=value
2081 $data{$section}{$1} = $2;
2082 $meta{$section}{$1} = $line;
2084 elsif (/^(.*)$/) { # lone value
2085 push (@{$data{$section}{'_'}}, $1);
2089 return (\%data, \%meta);
2093 my ($rc, $data, $meta) = @_;
2094 open (RCF, '>:utf8', $rc)
2095 or die _("Error: opening '{file}' for writing", file => $rc) . ": $!";
2096 my @sections = keys %$data;
2097 if (defined $meta) {
2099 $meta->{$a}{'#'} <=> $meta->{$b}{'#'}
2102 foreach my $section (@sections) {
2103 say RCF "[$section]";
2104 if (ref ($data->{$section}{'_'}) eq 'ARRAY') {
2105 foreach my $val (@{$data->{$section}{'_'}}) {
2109 my @keys = keys %{$data->{$section}};
2110 if (defined $meta) {
2112 $meta->{$section}{$a} <=> $meta->{$section}{$b}
2115 foreach my $key (@keys) {
2116 my $val = $data->{$section}{$key};
2117 say RCF "$key=$val";
2125 # load current status from disc
2126 sub load_preferences {
2127 my $rc = get_rc_filename ();
2128 log_message ("Loading preferences from $rc\n");
2129 return FALSE unless check_rc_file ($rc);
2130 return FALSE unless check_claws_not_running ();
2131 ($CONFIGDATA, $CONFIGMETA) = load_resource ($rc);
2132 foreach (keys %{$CONFIGDATA->{'Common'}}) {
2133 $PREFS{$_} = $CONFIGDATA->{'Common'}{$_};
2135 foreach my $plugin (qw(AttRemover Libravatar ManageSieve PerlPlugin)) {
2136 foreach (keys %{$CONFIGDATA->{$plugin}}) {
2137 $PLPREFS{$plugin}{$_} = $CONFIGDATA->{$plugin}{$_};
2143 sub load_ac_preferences {
2144 my $rc = get_ac_rc_filename ();
2145 log_message ("Loading account preferences from $rc\n");
2146 return FALSE unless check_rc_file ($rc);
2147 return FALSE unless check_claws_not_running ();
2148 ($ACCOUNTDATA, $ACCOUNTMETA) = load_resource ($rc);
2149 foreach my $asect (keys %$ACCOUNTDATA) {
2150 if ($asect =~ /^Account: (\d+)$/) {
2151 foreach (keys %{$ACCOUNTDATA->{$asect}}) {
2152 $ACPREFS{$1}{$_} = $ACCOUNTDATA->{$asect}{$_};
2159 # save current preferences to disc
2160 sub save_preferences {
2161 my $rc = get_rc_filename ();
2162 log_message ("Saving preferences to $rc\n");
2163 return FALSE unless check_rc_file ($rc);
2164 return FALSE unless check_claws_not_running ();
2165 my $rcbak = "$rc.backup";
2166 rename ($rc, $rcbak);
2167 foreach (keys %PREFS) {
2168 if (defined $HPVALUE{$_}) {
2169 $CONFIGDATA->{'Common'}{$_} = $HPVALUE{$_};
2172 foreach my $plugin (qw(AttRemover Libravatar ManageSieve PerlPlugin)) {
2173 foreach (keys %{$CONFIGDATA->{$plugin}}) {
2174 if (defined $PLHPVALUE{$plugin}{$_}) {
2175 $CONFIGDATA->{$plugin}{$_} = $PLHPVALUE{$plugin}{$_};
2179 save_resource ($rc, $CONFIGDATA, $CONFIGMETA);
2183 sub save_ac_preferences {
2184 my $rc = get_ac_rc_filename ();
2185 log_message ("Saving account preferences to $rc\n");
2186 return FALSE unless check_rc_file ($rc);
2187 return FALSE unless check_claws_not_running ();
2188 my $rcbak = "$rc.backup";
2189 rename ($rc, $rcbak);
2190 foreach my $asect (keys %$ACCOUNTDATA) {
2191 if ($asect =~ /^Account: (\d+)$/) {
2192 foreach (keys %{$ACCOUNTDATA->{$asect}}) {
2193 if (defined $ACHPVALUE{$1}{$_}) {
2194 $ACCOUNTDATA->{$asect}{$_} = $ACHPVALUE{$1}{$_};
2199 save_resource ($rc, $ACCOUNTDATA, $ACCOUNTMETA);
2205 my $nb = Gtk2::Notebook->new;
2207 $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
2208 $nb->append_page (new_colours_page (), $xl::s{tab_colours});
2209 $nb->append_page (new_gui_page (), $xl::s{tab_gui});
2210 $nb->append_page (new_other_page (), $xl::s{tab_other});
2211 $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
2212 $nb->append_page (new_accounts_page (), $xl::s{tab_accounts});
2213 $nb->append_page (new_plugins_page (), $xl::s{tab_plugins});
2218 # create an about dialog
2219 sub new_about_dialog {
2221 my $title = $xl::s{about_title};
2222 my $lic = $xl::s{about_license};
2223 my $vers = $xl::s{about_version} . " $VERSION";
2225 "This program is free software: you can redistribute it and/or modify
2226 it under the terms of the GNU General Public License as published by
2227 the Free Software Foundation, either version 3 of the License, or
2228 (at your option) any later version.
2230 This program is distributed in the hope that it will be useful,
2231 but WITHOUT ANY WARRANTY; without even the implied warranty of
2232 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2233 GNU General Public License for more details.
2235 You should have received a copy of the GNU General Public License
2236 along with this program. If not, see <http://www.gnu.org/licenses/>.";
2237 my $year = "2007-2016";
2238 my $holder = "Ricardo Mones <ricardo\@mones.org>";
2239 my $url = "http://www.claws-mail.org/clawsker.php";
2241 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
2242 [qw/modal destroy-with-parent/],
2244 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
2245 . "<span size=\"large\">$vers</span>\n\n"
2246 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2247 . "<span>Copyright $year by $holder</span>\n\n"
2248 . "<span size=\"large\">$lic</span>\n\n"
2249 . "<span size=\"small\">$license</span>");
2250 $dialog->set_title ($xl::s{about});
2255 # create buttons box
2256 sub new_button_box {
2257 my ($parent, $adlg) = @_;
2258 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2259 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2260 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2261 # disable button until is really implemented
2262 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2263 my $hbox = Gtk2::HBox->new (FALSE, 5);
2265 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2266 $b_apply->set_sensitive (not $READONLY);
2267 $b_apply->signal_connect (clicked => sub {
2268 save_preferences ($parent);
2269 save_ac_preferences ($parent);
2271 # $b_undo->signal_connect (clicked => sub { undo_current_changes });
2272 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2274 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2275 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2276 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2277 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2283 my $dir = $DATADIR . '/icons/hicolor';
2285 join ('/', ($dir, , $_ . 'x' . $_, 'apps', $NAME . '.png'))
2290 $icon = Gtk2::Gdk::Pixbuf->new_from_file($_) if (-f $_);
2291 push @icons, $icon if ($icon);
2297 exit unless parse_command_line ();
2299 $main_window = Gtk2::Window->new ('toplevel');
2300 exit unless load_preferences ();
2301 exit unless load_ac_preferences ();
2302 exit unless init_hidden_preferences ();
2303 exit unless init_ac_hidden_preferences ();
2304 exit unless init_plu_hidden_preferences ();
2306 my $box = Gtk2::VBox->new (FALSE, 5);
2307 $box->set_border_width(3);
2308 my $about = new_about_dialog ();
2309 $box->pack_start (new_notebook (), FALSE, FALSE, 0);
2310 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
2311 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2312 $main_window->set_title ($xl::s{win_title});
2313 $main_window->set_icon_list (get_app_icons ());
2314 $main_window->add ($box);
2315 $main_window->show_all;