3 # Clawsker :: A Claws Mail Tweaker
4 # Copyright 2007-2017 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)";
21 use Glib qw(TRUE FALSE);
23 use POSIX qw(setlocale);
26 use Digest::MD5 qw(md5_hex);
29 my $NAME = 'clawsker';
30 my $PREFIX = '@PREFIX@';
31 my $LIBDIR = '@LIBDIR@';
32 my $DATADIR = '@DATADIR@';
33 my $VERSION = '@VERSION@';
37 my $main_window = undef;
39 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
40 $locale = "C" unless defined($locale);
41 setlocale (LC_ALL, $locale);
42 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
45 my $SHOWHINTS = FALSE;
46 $SHOWHINTS = TRUE if ($Gtk2::VERSION >= 1.040 and Gtk2->CHECK_VERSION (2, 12, 0));
51 my $xla = gettext ($str);
52 if (scalar(keys(%par)) > 0) {
53 foreach my $key (keys %par) {
54 $xla =~ s/\{$key\}/$par{$key}/g;
57 return decode_utf8($xla);
62 win_title => _('Claws Mail Hidden Preferences'),
63 about => _('About...'),
64 about_title => _('Clawsker :: A Claws Mail Tweaker'),
65 about_license => _('License:'),
66 about_version => _('Version:'),
68 tab_colours => _('Colours'),
69 tab_behaviour => _('Behaviour'),
71 tab_other => _('Other'),
72 tab_winpos => _('Windows'),
73 tab_accounts => _('Accounts'),
74 tab_plugins => _('Plugins'),
75 tab_hotkeys => _('Hotkeys'),
76 tab_info => _('Info'),
78 ab_frame => _('Addressbook'),
79 mem_frame => _('Memory'),
80 msgview_frame => _('Message View'),
81 log_frame => _('Log window'),
82 dnd_frame => _('Drag \'n\' drop'),
83 ssl_frame => _('Secure Sockets Layer'),
84 msgs_frame => _('Messages'),
85 swc_frame => _('Completion'),
86 stripes_frame => _('Coloured stripes'),
87 sbar_frame => _('Scroll bars'),
88 mlist_frame => _('Message List'),
89 mview_frame => _('Message View'),
90 compo_frame => _('Compose window'),
91 netm_frame => _('NetworkManager'),
92 diff_frame => _('Viewing patches'),
93 mpass_frame => _('Master passphrase'),
94 compose_frame => _('Compose window'),
95 qs_frame => _('Quick search'),
97 l_oth_use_dlg => _('Use detached address book edit dialogue'),
98 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.'),
99 l_oth_max_use => _('Maximum memory for message cache'),
100 l_oth_max_use_units => _('kilobytes'),
101 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
102 l_oth_min_time => _('Minimun time for cache elements'),
103 l_oth_min_time_units => _('minutes'),
104 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.'),
105 l_oth_use_netm => _('Use NetworkManager'),
106 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
107 l_oth_mp_rounds => _('Rounds for PBKDF2 function'),
108 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.'),
110 l_gui_b_unread => _('Show unread messages with bold font'),
111 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
112 l_gui_no_markup => _('Don\'t use markup'),
113 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
114 l_gui_dot_lines => _('Use dotted lines in tree view components'),
115 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.'),
116 l_gui_h_scroll => _('Enable horizontal scrollbar'),
117 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
118 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
119 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.'),
120 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
121 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
122 l_gui_v_scroll_show => _('Show always'),
123 l_gui_v_scroll_auto => _('Automatic'),
124 l_gui_v_scroll_hide => _('Hide always'),
125 l_gui_from_show => _('From column displays'),
126 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both.'),
127 l_gui_from_show_name => _('Name only'),
128 l_gui_from_show_addr => _('Address only'),
129 l_gui_from_show_both => _('Both name and address'),
130 l_gui_strip_off => _('Coloured lines contrast'),
131 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.'),
132 l_gui_cursor_v => _('Show cursor'),
133 h_gui_cursor_v => _('Display the cursor in the Message View.'),
134 l_gui_toolbar_d => _('Detachable toolbars'),
135 h_gui_toolbar_d => _('Show handles in the toolbars.'),
136 l_gui_strip_all => _('Use stripes in all tree view components'),
137 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
138 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
139 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
140 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
141 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
142 l_gui_margin_co => _('Show margin'),
143 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
144 l_gui_mview_date => _('Don\'t display localized date'),
145 h_gui_mview_date => _('Toggles localization of date format in Message View.'),
146 l_gui_zero_char => _('Zero replacement character'),
147 h_gui_zero_char => _('Replaces \'0\' with the given character in Folder List.'),
148 l_gui_type_any => _('Editable headers'),
149 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.'),
150 l_gui_warn_send_multi => _('Warn when sending to more than'),
151 l_gui_warn_send_multi_units => _('recipients'),
152 h_gui_warn_send_multi => _('Show a warning dialogue when sending to more recipients than specified. Use 0 to disable this check.'),
153 l_gui_next_del => _('Select next message on delete'),
154 h_gui_next_del => _('When deleting a message, toggles between selecting the next one (newer message) or the previous one (older message).'),
156 l_beh_hover_t => _('Drag \'n\' drop hover timeout'),
157 l_beh_hover_t_units => _('milliseconds'),
158 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.'),
159 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
160 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
161 l_beh_flowed => _('Respect format=flowed in messages'),
162 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.'),
163 l_beh_parts_rw => _('Allow writable temporary files'),
164 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
165 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
166 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
167 l_beh_up_step => _('Progress bar update step every'),
168 l_beh_up_step_units => _('items'),
169 h_beh_up_step => _('Update stepping in progress bars.'),
170 l_beh_thread_a => _('Maximum age when threading by subject'),
171 l_beh_thread_a_units => _('days'),
172 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
173 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
174 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
175 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
176 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
177 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
178 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
179 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
180 h_beh_out_ascii => _('If allowed by content, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is always enforced.'),
181 l_beh_pp_unsel => _('Primary paste unselects selection'),
182 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
183 l_beh_inline_at => _('Show inline attachments'),
184 h_beh_inline_at => _('Allows to hide inline attachments already shown in mail structure view.'),
185 l_beh_addr_swc => _('Address search in compose window matches any'),
186 h_beh_addr_swc => _('On Tab-key completion, address text will match any part of the string or only from the start.'),
187 l_beh_fold_swc => _('Folder search in folder selector matches any'),
188 h_beh_fold_swc => _('On folder name completion text will match any part of the string or only from the start.'),
189 l_beh_rewrite_ff => _('Rewrite first \'From\' using QP encoding'),
190 h_beh_rewrite_ff => _('Workaround some servers which convert first \'From\' to \'>From\' by using Quoted-Printable transfer encoding instead of 7bit/8bit encoding.'),
192 l_col_emphasis => _('X-Mailer header'),
193 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
194 l_col_log_err => _('Error messages'),
195 h_col_log_err => _('Colour for error messages in log window.'),
196 l_col_log_in => _('Server messages'),
197 h_col_log_in => _('Colour for messages received from servers in log window.'),
198 l_col_log_msg => _('Standard messages'),
199 h_col_log_msg => _('Colour for messages in log window.'),
200 l_col_log_out => _('Client messages'),
201 h_col_log_out => _('Colour for messages sent to servers in log window.'),
202 l_col_log_warn => _('Warning messages'),
203 h_col_log_warn => _('Colour for warning messages in log window.'),
205 l_col_tags_bg => _('Tags background'),
206 h_col_tags_bg => _('Background colour for tags in message view.'),
207 l_col_tags_text => _('Tags text'),
208 h_col_tags_text => _('Text colour for tags in message view.'),
210 l_col_default_header_bg => _('Default headers background'),
211 h_col_default_header_bg => _('Background colour for default headers in compose window.'),
212 l_col_default_header_text => _('Default headers text'),
213 h_col_default_header_text => _('Text colour for default headers in compose window.'),
215 l_col_qs_active_bg => _('Active quick search background'),
216 h_col_qs_active_bg => _('Background colour for active quick search.'),
217 l_col_qs_active_text => _('Active quick search text'),
218 h_col_qs_active_text => _('Text colour for active quick search.'),
219 l_col_qs_error_bg => _('Quick search error background'),
220 h_col_qs_error_bg => _('Background colour for quick search error.'),
221 l_col_qs_error_text => _('Quick search error text'),
222 h_col_qs_error_text => _('Text colour for quick search error.'),
224 l_col_diff_add => _('Added lines'),
225 h_col_diff_add => _('Colour for added lines in patches.'),
226 l_col_diff_del => _('Deleted lines'),
227 h_col_diff_del => _('Colour for deleted lines in patches.'),
228 l_col_diff_hunk => _('Hunk lines'),
229 h_col_diff_hunk => _('Colour for hunk headers in patches.'),
231 l_win_x => _('X position'),
232 h_win_x => _('X coordinate for window\'s top-left corner.'),
233 l_win_y => _('Y position'),
234 h_win_y => _('Y coordinate for window\'s top-left corner.'),
235 l_win_w => _('Width'),
236 h_win_w => _('Window\'s width in pixels.'),
237 l_win_h => _('Height'),
238 h_win_h => _('Window\'s height in pixels.'),
240 l_win_main_mx => _('Maximized'),
241 h_win_main_mx => _('Changes window maximized status.'),
242 l_win_main_fs => _('Full-screen'),
243 h_win_main_fs => _('Changes full screen status.'),
245 l_acc_gtls_set => _('Use custom GnuTLS priority'),
246 h_acc_gtls_set => _('Enables using user provided GnuTLS priority string.'),
247 l_acc_gtls_pri => _('GnuTLS priority'),
248 h_acc_gtls_pri => _('Value to use as GnuTLS priority string if custom priority check is enabled. Otherwise this value is ignored.'),
250 l_plu_gpg_alimit => _('Autocompletion limit'),
251 h_plu_gpg_alimit => _('Limits the number of addresses obtained from keyring through autocompletion. Use 0 to get all matches.'),
252 l_plu_lav_burl => _('Base URL'),
253 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.'),
254 l_plu_prl_flvb => _('Log level'),
255 h_plu_prl_flvb => _('Verbosity level of log, accumulative.'),
256 l_plu_prl_none => _('None'),
257 l_plu_prl_manual => _('Manual'),
258 l_plu_prl_action => _('Actions'),
259 l_plu_prl_match => _('Matches'),
262 # data and metadata of resource files
267 # all preferences read by load_preferences
271 # values of all preferences handled by clawsker
275 # default config dir and file name
276 my $ALTCONFIGDIR = FALSE;
277 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
278 my $CONFIGRC = 'clawsrc';
279 my $ACCOUNTRC = 'accountrc';
280 # supported and available plugins lists
281 my @PLUGINS = qw(AttRemover GPG ManageSieve Libravatar PerlPlugin);
283 # loaded hotkeys from load_menurc
285 # current tree selection
290 # index constants for preference arrays
291 use constant NAME => 0; # the name on the rc file
292 use constant LABEL => 1; # the label on the GUI
293 use constant DESC => 2; # the description for the hint/help
294 use constant TYPE => 3; # data type: bool, int, float, string, color
295 use constant CMVER => 4; # lowest[,highest] Claws Mail version(s) the feature exists
296 use constant CMDEF => 5; # default value for the preference in Claws Mail
297 use constant PLUGIN => 6; # plugin section (only in plugin preferences)
299 # constants for GUI spacing
300 use constant HBOX_PAD => 5;
301 use constant FRAME_SPC => 2;
302 use constant PAGE_SPC => 5;
306 sub version_greater_or_equal {
307 my ($version, $refvers) = @_;
308 return TRUE if (length($version) == 0 and length($refvers) >= 0);
309 return FALSE if (length($version) >= 0 and length($refvers) == 0);
310 return TRUE if (version->parse($version) >= version->parse($refvers));
314 sub get_claws_version {
315 $_ = qx/which claws-mail/;
317 return "" unless ($_); # not installed
321 my @fver = split (/ /);
322 die "Invalid version string" unless ($fver[2] eq "version");
323 my @ver = split (/\./, $fver[3]);
326 if ($ver[2] =~ /(\d+)git(\d+)/) {
335 # data handlers and auxiliar functions
337 sub handle_bool_value {
338 my ($widget, $event, $dataref) = @_;
339 $$dataref = ($widget->get_active ())? '1': '0';
342 sub handle_int_value {
343 my ($widget, $event, $dataref) = @_;
344 $_ = $widget->get_text ();
349 $widget->set_text ($_);
352 $widget->set_text ($$dataref);
356 sub handle_string_value {
357 my ($widget, $event, $dataref) = @_;
358 $$dataref = $widget->get_text ();
361 sub handle_nchar_value {
362 my ($widget, $event, $dataref, $minlen, $maxlen) = @_;
363 $_ = substr ($widget->get_text (), 0, $maxlen);
364 $widget->set_text ($_);
368 sub gdk_color_from_str {
370 my ($rr, $gg, $bb) = (0, 0 ,0);
372 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
377 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
381 sub str_from_gdk_color {
383 my $rr = $color->red / 256;
384 my $gg = $color->green / 256;
385 my $bb = $color->blue / 256;
386 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
390 sub handle_color_value {
391 my ($widget, $event, $dataref) = @_;
392 my $newcol = $widget->get_color;
393 $$dataref = str_from_gdk_color ($newcol);
396 sub handle_selection_value {
397 my ($widget, $event, $dataref) = @_;
398 $$dataref = $widget->get_active;
401 sub get_rc_filename {
402 return $CONFIGDIR . $CONFIGRC;
405 sub get_ac_rc_filename {
406 return $CONFIGDIR . $ACCOUNTRC;
409 sub get_menurc_filename {
410 return $CONFIGDIR . "menurc";
413 sub set_rc_filename {
415 my @parts = split ('/', $fullname);
416 $CONFIGRC = $parts[$#parts];
417 $parts[$#parts] = '';
418 $CONFIGDIR = join ('/', @parts);
422 my ($mesg, $fatal) = @_;
423 if (defined($fatal) && $fatal eq 'die') {
424 die "$NAME: $mesg\n";
427 print "$NAME: $mesg\n";
433 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
434 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
435 $errordlg->set_title (_('Clawsker error'));
440 sub claws_is_running {
441 my $emsg = _('Error: seems Claws Mail is currently running, close it first.');
443 error_dialog ($emsg);
447 sub check_claws_not_running {
448 return TRUE if $READONLY;
449 my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
450 $tmpdir = '/tmp' if ($tmpdir eq '');
451 my $lockdir = "$tmpdir/claws-mail-$<";
455 my $socket = "$lockdir/" . md5_hex ($_);
456 -S $socket and return claws_is_running ();
463 (defined($rcfile) && -f $rcfile) or do {
464 my $emsg = _('Error: resource file for Claws Mail was not found.');
466 error_dialog ($emsg);
472 sub set_widget_hint {
474 my ($wdgt, $hint) = @_;
475 $wdgt->set_tooltip_text ($hint);
476 $wdgt->set_has_tooltip (TRUE);
480 sub set_widget_sens {
481 my ($wdgt, $versions) = @_;
482 my @ver = split(/,/, $versions);
484 $wdgt->set_sensitive (
485 version_greater_or_equal ($CLAWSV, $ver[0])
486 and version_greater_or_equal ($ver[1], $CLAWSV)
489 $wdgt->set_sensitive (version_greater_or_equal ($CLAWSV, $ver[0]));
493 # graphic element creation
495 sub new_hbox_spaced_pack {
496 my $hbox = Gtk2::HBox->new (FALSE);
498 $hbox->pack_start ($_, FALSE, FALSE, HBOX_PAD);
503 sub new_check_button_for($$$) {
504 my ($hash, $key, $vhash) = @_;
505 my $name = $$hash{$key}[NAME];
506 my $label = $$hash{$key}[LABEL];
508 my $cb = Gtk2::CheckButton->new ($label);
509 my $value = $$vhash{$name};
510 $value //= $$hash{$key}[CMDEF];
511 $cb->set_active ($value eq '1');
512 $cb->signal_connect (clicked => sub {
514 handle_bool_value ($w, $e, \$$vhash{$name});
516 set_widget_hint ($cb, $$hash{$key}[DESC]);
517 set_widget_sens ($cb, $$hash{$key}[CMVER]);
519 return new_hbox_spaced_pack ($cb);
522 sub new_text_box_for_int($$$) {
523 my ($hash, $key, $vhash) = @_;
524 my $name = $$hash{$key}[NAME];
525 my $label = $$hash{$key}[LABEL];
526 my @type = split (/,/, $$hash{$key}[TYPE]);
527 push (@type, 0), push (@type, 10000) unless ($#type > 0);
530 if (ref $label eq 'ARRAY') {
531 $gunits = Gtk2::Label->new ($label->[1]);
532 $label = $label->[0];
534 my $glabel = Gtk2::Label->new ($label);
535 my $pagei = int (($type[2] - $type[1]) / 10);
536 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
537 my $value = $$vhash{$name};
538 $value //= $$hash{$key}[CMDEF];
539 $gentry->set_numeric (TRUE);
540 $gentry->set_value ($value);
541 $gentry->signal_connect('value-changed' => sub {
543 handle_int_value ($w, $e, \$$vhash{$name});
545 set_widget_hint ($gentry, $$hash{$key}[DESC]);
546 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
547 $glabel->set_sensitive ($gentry->sensitive);
548 $gunits->set_sensitive ($gentry->sensitive) if ($gunits);
550 return new_hbox_spaced_pack ($glabel, $gentry, $gunits) if ($gunits);
551 return new_hbox_spaced_pack ($glabel, $gentry);
554 sub new_text_box_for_nchar($$$) {
555 my ($hash, $key, $vhash) = @_;
556 my $name = $$hash{$key}[NAME];
557 my $label = $$hash{$key}[LABEL];
558 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen,width
559 my $glabel = Gtk2::Label->new ($label);
560 my $gentry = Gtk2::Entry->new ();
561 $gentry->set_max_length($type[2]) if defined ($type[2]);
562 my $width = $type[3];
564 $gentry->set_width_chars(int ($width) + 2) if defined ($width);
565 my $value = $$vhash{$name};
566 $value //= $$hash{$key}[CMDEF];
567 $gentry->set_text ($value);
568 $gentry->signal_connect('key-release-event' => sub {
570 handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1], $type[2]);
572 set_widget_hint ($gentry, $$hash{$key}[DESC]);
573 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
574 $glabel->set_sensitive ($gentry->sensitive);
576 return new_hbox_spaced_pack ($glabel, $gentry);
579 sub new_color_button_for($$$) {
580 my ($hash, $key, $vhash) = @_;
581 my $name = $$hash{$key}[NAME];
582 my $label = $$hash{$key}[LABEL];
584 my $value = $$vhash{$name};
585 $value //= $$hash{$key}[CMDEF];
586 my $col = gdk_color_from_str ($value);
587 my $glabel = Gtk2::Label->new ($label);
588 my $button = Gtk2::ColorButton->new_with_color ($col);
589 $button->set_title ($label);
590 $button->set_relief ('none');
591 $button->signal_connect ('color-set' => sub {
593 handle_color_value ($w, $e, \$$vhash{$name});
595 set_widget_hint ($button, $$hash{$key}[DESC]);
596 set_widget_sens ($button, $$hash{$key}[CMVER]);
597 $glabel->set_sensitive ($button->sensitive);
599 return new_hbox_spaced_pack ($button, $glabel);
602 sub new_selection_box_for($$$) {
603 my ($hash, $key, $vhash) = @_;
604 my $name = $$hash{$key}[NAME];
605 my $label = $$hash{$key}[LABEL];
607 my $glabel = Gtk2::Label->new ($label);
608 my $combo = Gtk2::ComboBox->new_text;
609 my @options = split (';', $$hash{$key}[TYPE]);
610 foreach my $opt (@options) {
611 my ($index, $textkey) = split ('=', $opt);
612 $combo->insert_text ($index, $xl::s{$textkey});
614 $combo->signal_connect ('changed' => sub {
616 handle_selection_value ($w, $e, \$$vhash{$name});
618 my $value = $$vhash{$name};
619 $value //= $$hash{$key}[CMDEF];
620 $combo->set_active ($value);
621 set_widget_hint ($combo, $$hash{$key}[DESC]);
622 set_widget_sens ($combo, $$hash{$key}[CMVER]);
623 $glabel->set_sensitive ($combo->sensitive);
625 return new_hbox_spaced_pack ($glabel, $combo);
628 # more graphic helpers
631 my $hbox = Gtk2::HBox->new (FALSE);
632 $hbox->set_border_width (PAGE_SPC);
634 $hbox->pack_start ($_, FALSE, FALSE, 0);
639 sub new_hbox_pack_compact {
640 my $hbox = Gtk2::HBox->new (FALSE);
641 $hbox->set_border_width (0);
643 $hbox->pack_start ($_, FALSE, FALSE, 0);
649 my $vbox = Gtk2::VBox->new (FALSE, 5);
650 $vbox->set_border_width (PAGE_SPC);
652 $vbox->pack_start ($_, FALSE, FALSE, 0);
657 sub new_vbox_pack_compact {
658 my $vbox = Gtk2::VBox->new (FALSE, 0);
659 $vbox->set_border_width (0);
661 $vbox->pack_start ($_, FALSE, FALSE, 0);
666 sub new_subpage_frame {
667 my ($box, $title, $notpacked) = @_;
668 my $frame = Gtk2::Frame->new ($title);
670 return new_vbox_pack ($frame) unless defined ($notpacked);
674 # preference maps and corresponding page creation subs
676 %pr::oth = ( # other preferences
678 'addressbook_use_editaddress_dialog',
679 $xl::s{l_oth_use_dlg},
680 $xl::s{h_oth_use_dlg},
686 'cache_max_mem_usage',
687 [ $xl::s{l_oth_max_use}, $xl::s{l_oth_max_use_units} ],
688 $xl::s{h_oth_max_use},
689 'int,0,262144', # 0 Kb - 256 Mb
694 'cache_min_keep_time',
695 [ $xl::s{l_oth_min_time}, $xl::s{l_oth_min_time_units} ],
696 $xl::s{h_oth_min_time},
697 'int,0,120', # 0 minutes - 2 hours
702 'use_networkmanager',
703 $xl::s{l_oth_use_netm},
704 $xl::s{h_oth_use_netm},
710 'master_passphrase_pbkdf2_rounds',
711 $xl::s{l_oth_mp_rounds},
712 $xl::s{h_oth_mp_rounds},
719 sub new_other_page() {
720 return new_vbox_pack (
723 new_check_button_for(\%pr::oth, 'use_dlg', \%HPVALUE)),
724 $xl::s{ab_frame}, 'not-packed'),
727 new_text_box_for_int(\%pr::oth, 'max_use', \%HPVALUE),
728 new_text_box_for_int(\%pr::oth, 'min_time', \%HPVALUE)),
729 $xl::s{mem_frame}, 'not-packed'),
732 new_check_button_for(\%pr::oth, 'use_netm', \%HPVALUE)),
733 $xl::s{netm_frame}, 'not-packed'),
736 new_text_box_for_int(\%pr::oth, 'mp_rounds', \%HPVALUE)),
737 $xl::s{mpass_frame}, 'not-packed')
741 %pr::gui = ( # gui bells and whistles
744 $xl::s{l_gui_b_unread},
745 $xl::s{h_gui_b_unread},
752 $xl::s{l_gui_no_markup},
753 $xl::s{h_gui_no_markup},
759 'enable_dotted_lines',
760 $xl::s{l_gui_dot_lines},
761 $xl::s{h_gui_dot_lines},
763 '2.4.0.115,3.7.10.44',
768 $xl::s{l_gui_h_scroll},
769 $xl::s{h_gui_h_scroll},
776 $xl::s{l_gui_swp_from},
777 $xl::s{h_gui_swp_from},
783 'folderview_vscrollbar_policy',
784 $xl::s{l_gui_v_scroll},
785 $xl::s{h_gui_v_scroll},
786 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
792 $xl::s{l_gui_from_show},
793 $xl::s{h_gui_from_show},
794 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
799 'stripes_color_offset',
800 $xl::s{l_gui_strip_off},
801 $xl::s{h_gui_strip_off},
802 'int,0,40000', # no idea what this number means
807 'textview_cursor_visible',
808 $xl::s{l_gui_cursor_v},
809 $xl::s{h_gui_cursor_v},
815 'toolbar_detachable',
816 $xl::s{l_gui_toolbar_d},
817 $xl::s{h_gui_toolbar_d},
823 'use_stripes_everywhere',
824 $xl::s{l_gui_strip_all},
825 $xl::s{h_gui_strip_all},
831 'use_stripes_in_summaries',
832 $xl::s{l_gui_strip_sum},
833 $xl::s{h_gui_strip_sum},
840 $xl::s{l_gui_two_line_v},
841 $xl::s{h_gui_two_line_v},
847 'show_compose_margin',
848 $xl::s{l_gui_margin_co},
849 $xl::s{h_gui_margin_co},
855 'msgview_date_format',
856 $xl::s{l_gui_mview_date},
857 $xl::s{h_gui_mview_date},
863 'zero_replacement_char',
864 $xl::s{l_gui_zero_char},
865 $xl::s{h_gui_zero_char},
872 $xl::s{l_gui_type_any},
873 $xl::s{h_gui_type_any},
879 'warn_sending_many_recipients_num',
880 [ $xl::s{l_gui_warn_send_multi}, $xl::s{l_gui_warn_send_multi_units} ],
881 $xl::s{h_gui_warn_send_multi},
888 $xl::s{l_gui_next_del},
889 $xl::s{h_gui_next_del},
897 my $gf = Gtk2::VBox->new (FALSE, 5);
898 $gf->set_border_width (PAGE_SPC);
900 my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines', \%HPVALUE);
901 my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d', \%HPVALUE);
902 my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char', \%HPVALUE);
904 $gf->pack_start (new_subpage_frame (
906 new_check_button_for (\%pr::gui, 'strip_all', \%HPVALUE),
907 new_check_button_for (\%pr::gui, 'strip_sum', \%HPVALUE),
908 new_text_box_for_int (\%pr::gui, 'strip_off', \%HPVALUE)),
909 $xl::s{stripes_frame}, 'not-packed'),
910 FALSE, FALSE, FRAME_SPC);
911 $gf->pack_start (new_subpage_frame (
913 new_check_button_for (\%pr::gui, 'b_unread', \%HPVALUE),
914 new_check_button_for (\%pr::gui, 'swp_from', \%HPVALUE),
915 new_check_button_for (\%pr::gui, 'two_linev', \%HPVALUE),
916 new_check_button_for (\%pr::gui, 'next_del', \%HPVALUE),
917 new_selection_box_for (\%pr::gui, 'from_show', \%HPVALUE)),
918 $xl::s{mlist_frame}, 'not-packed'),
919 FALSE, FALSE, FRAME_SPC);
920 $gf->pack_start (new_subpage_frame (
922 new_check_button_for (\%pr::gui, 'cursor_v', \%HPVALUE),
923 new_check_button_for (\%pr::gui, 'mview_date', \%HPVALUE)),
924 $xl::s{mview_frame}, 'not-packed'),
925 FALSE, FALSE, FRAME_SPC);
926 $gf->pack_start (new_subpage_frame (
928 new_hbox_pack_compact (
929 new_check_button_for (\%pr::gui, 'no_markup', \%HPVALUE),
930 new_check_button_for (\%pr::gui, 'margin_co', \%HPVALUE),
931 new_check_button_for (\%pr::gui, 'type_any', \%HPVALUE)),
932 new_text_box_for_int (\%pr::gui, 'warn_send_multi', \%HPVALUE)),
933 $xl::s{compo_frame}, 'not-packed'),
934 FALSE, FALSE, FRAME_SPC);
935 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
936 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
937 $gf->pack_start (new_subpage_frame (
939 new_check_button_for (\%pr::gui, 'h_scroll', \%HPVALUE),
940 new_selection_box_for (\%pr::gui, 'v_scroll', \%HPVALUE)),
941 $xl::s{sbar_frame}, 'not-packed'),
942 FALSE, FALSE, FRAME_SPC);
943 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
948 %pr::beh = ( # tweak some behaviour
951 [ $xl::s{l_beh_hover_t}, $xl::s{l_beh_hover_t_units} ],
952 $xl::s{h_beh_hover_t},
953 'int,100,3000', # 0.1 seconds - 3 seconds
959 $xl::s{l_beh_dangerous},
960 $xl::s{h_beh_dangerous},
966 'respect_flowed_format',
967 $xl::s{l_beh_flowed},
968 $xl::s{h_beh_flowed},
974 'save_parts_readwrite',
975 $xl::s{l_beh_parts_rw},
976 $xl::s{h_beh_parts_rw},
982 'skip_ssl_cert_check',
983 $xl::s{l_beh_skip_ssl},
984 $xl::s{h_beh_skip_ssl},
990 'statusbar_update_step',
991 [ $xl::s{l_beh_up_step}, $xl::s{l_beh_up_step_units} ],
992 $xl::s{h_beh_up_step},
993 'int,1,200', # 1 item - 200 items
998 'thread_by_subject_max_age',
999 [ $xl::s{l_beh_thread_a}, $xl::s{l_beh_thread_a_units} ],
1000 $xl::s{h_beh_thread_a},
1001 'int,1,30', # 1 day - 30 days
1007 $xl::s{l_beh_unsafe_ssl},
1008 $xl::s{h_beh_unsafe_ssl},
1014 'utf8_instead_of_locale_for_broken_mail',
1015 $xl::s{l_beh_use_utf8},
1016 $xl::s{h_beh_use_utf8},
1023 $xl::s{l_beh_warn_dnd},
1024 $xl::s{h_beh_warn_dnd},
1030 'outgoing_fallback_to_ascii',
1031 $xl::s{l_beh_out_ascii},
1032 $xl::s{h_beh_out_ascii},
1038 'primary_paste_unselects',
1039 $xl::s{l_beh_pp_unsel},
1040 $xl::s{h_beh_pp_unsel},
1046 'show_inline_attachments',
1047 $xl::s{l_beh_inline_at},
1048 $xl::s{h_beh_inline_at},
1054 'address_search_wildcard',
1055 $xl::s{l_beh_addr_swc},
1056 $xl::s{h_beh_addr_swc},
1062 'folder_search_wildcard',
1063 $xl::s{l_beh_fold_swc},
1064 $xl::s{h_beh_fold_swc},
1070 'rewrite_first_from',
1071 $xl::s{l_beh_rewrite_ff},
1072 $xl::s{h_beh_rewrite_ff},
1079 sub new_behaviour_page() {
1080 my $bf = Gtk2::VBox->new (FALSE, 5);
1081 $bf->set_border_width (PAGE_SPC);
1083 my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step', \%HPVALUE);
1084 my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a', \%HPVALUE);
1086 $bf->pack_start (new_subpage_frame (
1088 new_text_box_for_int (\%pr::beh, 'hover_t', \%HPVALUE),
1089 new_check_button_for (\%pr::beh, 'warn_dnd', \%HPVALUE)),
1090 $xl::s{dnd_frame}, 'not-packed'),
1091 FALSE, FALSE, FRAME_SPC);
1092 $bf->pack_start (new_subpage_frame (
1094 new_check_button_for (\%pr::beh, 'skip_ssl', \%HPVALUE),
1095 new_check_button_for (\%pr::beh, 'unsafe_ssl', \%HPVALUE)),
1096 $xl::s{ssl_frame}, 'not-packed'),
1097 FALSE, FALSE, FRAME_SPC);
1098 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
1099 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
1100 $bf->pack_start (new_subpage_frame (
1102 new_check_button_for (\%pr::beh, 'flowed', \%HPVALUE),
1103 new_check_button_for (\%pr::beh, 'parts_rw', \%HPVALUE),
1104 new_check_button_for (\%pr::beh, 'use_utf8', \%HPVALUE),
1105 new_check_button_for (\%pr::beh, 'dangerous', \%HPVALUE),
1106 new_check_button_for (\%pr::beh, 'out_ascii', \%HPVALUE),
1107 new_check_button_for (\%pr::beh, 'pp_unsel', \%HPVALUE),
1108 new_check_button_for (\%pr::beh, 'inline_at', \%HPVALUE),
1109 new_check_button_for (\%pr::beh, 'rewrite_ff', \%HPVALUE)),
1110 $xl::s{msgs_frame}, 'not-packed'),
1111 FALSE, FALSE, FRAME_SPC);
1112 $bf->pack_start (new_subpage_frame (
1114 new_check_button_for (\%pr::beh, 'addr_swc', \%HPVALUE),
1115 new_check_button_for (\%pr::beh, 'fold_swc', \%HPVALUE)),
1116 $xl::s{swc_frame}, 'not-packed'),
1117 FALSE, FALSE, FRAME_SPC);
1121 %pr::col = ( # a variety of colours
1124 $xl::s{l_col_emphasis},
1125 $xl::s{h_col_emphasis},
1132 $xl::s{l_col_log_err},
1133 $xl::s{h_col_log_err},
1140 $xl::s{l_col_log_in},
1141 $xl::s{h_col_log_in},
1148 $xl::s{l_col_log_msg},
1149 $xl::s{h_col_log_msg},
1156 $xl::s{l_col_log_out},
1157 $xl::s{h_col_log_out},
1164 $xl::s{l_col_log_warn},
1165 $xl::s{h_col_log_warn},
1172 $xl::s{l_col_diff_add},
1173 $xl::s{h_col_diff_add},
1179 'diff_deleted_color',
1180 $xl::s{l_col_diff_del},
1181 $xl::s{h_col_diff_del},
1188 $xl::s{l_col_diff_hunk},
1189 $xl::s{h_col_diff_hunk},
1196 $xl::s{l_col_tags_bg},
1197 $xl::s{h_col_tags_bg},
1204 $xl::s{l_col_tags_text},
1205 $xl::s{h_col_tags_text},
1210 default_header_bg => [
1211 'default_header_bgcolor',
1212 $xl::s{l_col_default_header_bg},
1213 $xl::s{h_col_default_header_bg},
1218 default_header_text => [
1219 'default_header_color',
1220 $xl::s{l_col_default_header_text},
1221 $xl::s{h_col_default_header_text},
1227 'qs_active_bgcolor',
1228 $xl::s{l_col_qs_active_bg},
1229 $xl::s{h_col_qs_active_bg},
1236 $xl::s{l_col_qs_active_text},
1237 $xl::s{h_col_qs_active_text},
1244 $xl::s{l_col_qs_error_bg},
1245 $xl::s{h_col_qs_error_bg},
1252 $xl::s{l_col_qs_error_text},
1253 $xl::s{h_col_qs_error_text},
1260 sub new_colours_page() {
1261 return new_vbox_pack (
1264 new_color_button_for (\%pr::col, 'emphasis', \%HPVALUE),
1265 new_hbox_pack_compact (
1266 new_color_button_for (\%pr::col, 'tags_text', \%HPVALUE),
1267 new_color_button_for (\%pr::col, 'tags_bg', \%HPVALUE))),
1268 $xl::s{msgview_frame}, 'not-packed'),
1271 new_vbox_pack_compact (
1272 new_color_button_for (\%pr::col, 'log_err', \%HPVALUE),
1273 new_color_button_for (\%pr::col, 'log_warn', \%HPVALUE),
1274 new_color_button_for (\%pr::col, 'log_msg', \%HPVALUE)),
1275 new_vbox_pack_compact (
1276 new_color_button_for (\%pr::col, 'log_in', \%HPVALUE),
1277 new_color_button_for (\%pr::col, 'log_out', \%HPVALUE))),
1278 $xl::s{log_frame}, 'not-packed'),
1281 new_color_button_for (\%pr::col, 'diff_add', \%HPVALUE),
1282 new_color_button_for (\%pr::col, 'diff_del', \%HPVALUE),
1283 new_color_button_for (\%pr::col, 'diff_hunk', \%HPVALUE)),
1284 $xl::s{diff_frame}, 'not-packed'),
1287 new_color_button_for (\%pr::col, 'default_header_text', \%HPVALUE),
1288 new_color_button_for (\%pr::col, 'default_header_bg', \%HPVALUE)),
1289 $xl::s{compose_frame}, 'not-packed'),
1292 new_vbox_pack_compact (
1293 new_color_button_for (\%pr::col, 'qs_active_text', \%HPVALUE),
1294 new_color_button_for (\%pr::col, 'qs_error_text', \%HPVALUE)),
1295 new_vbox_pack_compact (
1296 new_color_button_for (\%pr::col, 'qs_active_bg', \%HPVALUE),
1297 new_color_button_for (\%pr::col, 'qs_error_bg', \%HPVALUE))),
1298 $xl::s{qs_frame}, 'not-packed')
1302 %pr::win = ( # tweak window positions and/or sizes
1307 'int,0,3000', # 0 pixels - 3000 pixels
1315 'int,0,3000', # 0 pixels - 3000 pixels
1323 'int,0,3000', # 0 pixels - 3000 pixels
1331 'int,0,3000', # 0 pixels - 3000 pixels
1336 'mainwin_maximised',
1337 $xl::s{l_win_main_mx},
1338 $xl::s{h_win_main_mx},
1344 'mainwin_fullscreen',
1345 $xl::s{l_win_main_fs},
1346 $xl::s{h_win_main_fs},
1352 'main_messagewin_x',
1355 'int,0,3000', # 0 pixels - 3000 pixels
1360 'main_messagewin_y',
1363 'int,0,3000', # 0 pixels - 3000 pixels
1371 'int,0,3000', # 0 pixels - 3000 pixels
1376 'messagewin_height',
1379 'int,0,3000', # 0 pixels - 3000 pixels
1387 'int,0,3000', # 0 pixels - 3000 pixels
1395 'int,0,3000', # 0 pixels - 3000 pixels
1403 'int,0,3000', # 0 pixels - 3000 pixels
1408 'receivewin_height',
1411 'int,0,3000', # 0 pixels - 3000 pixels
1419 'int,0,3000', # 0 pixels - 3000 pixels
1427 'int,0,3000', # 0 pixels - 3000 pixels
1432 'folderitemwin_width',
1435 'int,0,3000', # 0 pixels - 3000 pixels
1440 'folderitemwin_height',
1443 'int,0,3000', # 0 pixels - 3000 pixels
1448 'folderselwin_width',
1451 'int,0,3000', # 0 pixels - 3000 pixels
1456 'folderselwin_height',
1459 'int,0,3000', # 0 pixels - 3000 pixels
1467 'int,0,3000', # 0 pixels - 3000 pixels
1475 'int,0,3000', # 0 pixels - 3000 pixels
1480 'addressbookwin_width',
1483 'int,0,3000', # 0 pixels - 3000 pixels
1488 'addressbookwin_height',
1491 'int,0,3000', # 0 pixels - 3000 pixels
1496 'addressbookeditpersonwin_width',
1499 'int,0,3000', # 0 pixels - 3000 pixels
1504 'addressbookeditpersonwin_height',
1507 'int,0,3000', # 0 pixels - 3000 pixels
1512 'addressbookeditgroupwin_width',
1515 'int,0,3000', # 0 pixels - 3000 pixels
1520 'addressbookeditgroupwin_height',
1523 'int,0,3000', # 0 pixels - 3000 pixels
1528 'addressaddwin_width',
1531 'int,0,3000', # 0 pixels - 3000 pixels
1536 'addressaddwin_height',
1539 'int,0,3000', # 0 pixels - 3000 pixels
1544 'addressbook_folderselwin_width',
1547 'int,0,3000', # 0 pixels - 3000 pixels
1552 'addressbook_folderselwin_height',
1555 'int,0,3000', # 0 pixels - 3000 pixels
1560 'editaccountwin_width',
1563 'int,0,3000', # 0 pixels - 3000 pixels
1568 'editaccountwin_height',
1571 'int,0,3000', # 0 pixels - 3000 pixels
1576 'accountswin_width',
1579 'int,0,3000', # 0 pixels - 3000 pixels
1584 'accountswin_height',
1587 'int,0,3000', # 0 pixels - 3000 pixels
1592 'filteringwin_width',
1595 'int,0,3000', # 0 pixels - 3000 pixels
1600 'filteringwin_height',
1603 'int,0,3000', # 0 pixels - 3000 pixels
1608 'filteringactionwin_width',
1611 'int,0,3000', # 0 pixels - 3000 pixels
1616 'filteringactionwin_height',
1619 'int,0,3000', # 0 pixels - 3000 pixels
1624 'filtering_debugwin_width',
1627 'int,0,3000', # 0 pixels - 3000 pixels
1632 'filtering_debugwin_height',
1635 'int,0,3000', # 0 pixels - 3000 pixels
1643 'int,0,3000', # 0 pixels - 3000 pixels
1648 'matcherwin_height',
1651 'int,0,3000', # 0 pixels - 3000 pixels
1659 'int,0,3000', # 0 pixels - 3000 pixels
1667 'int,0,3000', # 0 pixels - 3000 pixels
1672 'templateswin_width',
1675 'int,0,3000', # 0 pixels - 3000 pixels
1680 'templateswin_height',
1683 'int,0,3000', # 0 pixels - 3000 pixels
1691 'int,0,3000', # 0 pixels - 3000 pixels
1696 'actionswin_height',
1699 'int,0,3000', # 0 pixels - 3000 pixels
1707 'int,0,3000', # 0 pixels - 3000 pixels
1715 'int,0,3000', # 0 pixels - 3000 pixels
1723 'int,0,3000', # 0 pixels - 3000 pixels
1728 'pluginswin_height',
1731 'int,0,3000', # 0 pixels - 3000 pixels
1739 'int,0,3000', # 0 pixels - 3000 pixels
1747 'int,0,3000', # 0 pixels - 3000 pixels
1752 'print_previewwin_width',
1755 'int,0,3000', # 0 pixels - 3000 pixels
1760 'print_previewwin_height',
1763 'int,0,3000', # 0 pixels - 3000 pixels
1769 sub new_winpos_subpage_main() {
1770 return new_subpage_frame (
1771 new_vbox_pack_compact (
1773 new_text_box_for_int (\%pr::win, 'main_x', \%HPVALUE),
1774 new_text_box_for_int (\%pr::win, 'main_y', \%HPVALUE)),
1776 new_text_box_for_int (\%pr::win, 'main_w', \%HPVALUE),
1777 new_text_box_for_int (\%pr::win, 'main_h', \%HPVALUE)),
1779 new_check_button_for (\%pr::win, 'main_fs', \%HPVALUE),
1780 new_check_button_for (\%pr::win, 'main_mx', \%HPVALUE))),
1785 sub new_winpos_subpage_msgs() {
1786 return new_subpage_frame (
1787 new_vbox_pack_compact (
1789 new_text_box_for_int (\%pr::win, 'msgs_x', \%HPVALUE),
1790 new_text_box_for_int (\%pr::win, 'msgs_y', \%HPVALUE)),
1792 new_text_box_for_int (\%pr::win, 'msgs_w', \%HPVALUE),
1793 new_text_box_for_int (\%pr::win, 'msgs_h', \%HPVALUE))),
1798 sub new_winpos_subpage_sendrecv() {
1799 return new_vbox_pack (
1802 new_text_box_for_int (\%pr::win, 'send_w', \%HPVALUE),
1803 new_text_box_for_int (\%pr::win, 'send_h', \%HPVALUE)),
1804 _('Send window'), 'not-packed'),
1807 new_text_box_for_int (\%pr::win, 'recv_w', \%HPVALUE),
1808 new_text_box_for_int (\%pr::win, 'recv_h', \%HPVALUE)),
1809 _('Receive window'), 'not-packed')
1813 sub new_winpos_subpage_fold() {
1814 return new_vbox_pack (
1816 new_vbox_pack_compact (
1818 new_text_box_for_int (\%pr::win, 'fold_x', \%HPVALUE),
1819 new_text_box_for_int (\%pr::win, 'fold_y', \%HPVALUE)),
1821 new_text_box_for_int (\%pr::win, 'fold_w', \%HPVALUE),
1822 new_text_box_for_int (\%pr::win, 'fold_h', \%HPVALUE))),
1823 _('Folder window'), 'not-packed'),
1826 new_text_box_for_int (\%pr::win, 'fsel_w', \%HPVALUE),
1827 new_text_box_for_int (\%pr::win, 'fsel_h', \%HPVALUE)),
1828 _('Folder selection window'), 'not-packed')
1832 sub new_winpos_subpage_addrbook() {
1833 return new_vbox_pack (
1836 new_text_box_for_int (\%pr::win, 'addr_w', \%HPVALUE),
1837 new_text_box_for_int (\%pr::win, 'addr_h', \%HPVALUE)),
1838 _('Addressbook main window'), 'not-packed'),
1841 new_text_box_for_int (\%pr::win, 'adep_w', \%HPVALUE),
1842 new_text_box_for_int (\%pr::win, 'adep_h', \%HPVALUE)),
1843 _('Edit person window'), 'not-packed'),
1846 new_text_box_for_int (\%pr::win, 'adeg_w', \%HPVALUE),
1847 new_text_box_for_int (\%pr::win, 'adeg_h', \%HPVALUE)),
1848 _('Edit group window'), 'not-packed'),
1851 new_text_box_for_int (\%pr::win, 'adda_w', \%HPVALUE),
1852 new_text_box_for_int (\%pr::win, 'adda_h', \%HPVALUE)),
1853 _('Add address window'), 'not-packed'),
1856 new_text_box_for_int (\%pr::win, 'addf_w', \%HPVALUE),
1857 new_text_box_for_int (\%pr::win, 'addf_h', \%HPVALUE)),
1858 _('Folder select window'), 'not-packed')
1862 sub new_winpos_subpage_accounts() {
1863 return new_vbox_pack (
1866 new_text_box_for_int (\%pr::win, 'acco_w', \%HPVALUE),
1867 new_text_box_for_int (\%pr::win, 'acco_h', \%HPVALUE)),
1868 _('Accounts window'), 'not-packed'),
1871 new_text_box_for_int (\%pr::win, 'acce_w', \%HPVALUE),
1872 new_text_box_for_int (\%pr::win, 'acce_h', \%HPVALUE)),
1873 _('Edit account window'), 'not-packed')
1877 sub new_winpos_subpage_filtering() {
1878 return new_vbox_pack (
1881 new_text_box_for_int (\%pr::win, 'filt_w', \%HPVALUE),
1882 new_text_box_for_int (\%pr::win, 'filt_h', \%HPVALUE)),
1883 _('Filtering window'), 'not-packed'),
1886 new_text_box_for_int (\%pr::win, 'fila_w', \%HPVALUE),
1887 new_text_box_for_int (\%pr::win, 'fila_h', \%HPVALUE)),
1888 _('Filtering actions window'), 'not-packed'),
1891 new_text_box_for_int (\%pr::win, 'fild_w', \%HPVALUE),
1892 new_text_box_for_int (\%pr::win, 'fild_h', \%HPVALUE)),
1893 _('Filtering debug window'), 'not-packed'),
1896 new_text_box_for_int (\%pr::win, 'matc_w', \%HPVALUE),
1897 new_text_box_for_int (\%pr::win, 'matc_h', \%HPVALUE)),
1898 _('Matcher window'), 'not-packed')
1902 sub new_winpos_subpage_prefs() {
1903 return new_vbox_pack (
1906 new_text_box_for_int (\%pr::win, 'pref_w', \%HPVALUE),
1907 new_text_box_for_int (\%pr::win, 'pref_h', \%HPVALUE)),
1908 _('Preferences window'), 'not-packed'),
1911 new_text_box_for_int (\%pr::win, 'temp_w', \%HPVALUE),
1912 new_text_box_for_int (\%pr::win, 'temp_h', \%HPVALUE)),
1913 _('Templates window'), 'not-packed'),
1916 new_text_box_for_int (\%pr::win, 'acti_w', \%HPVALUE),
1917 new_text_box_for_int (\%pr::win, 'acti_h', \%HPVALUE)),
1918 _('Actions window'), 'not-packed'),
1921 new_text_box_for_int (\%pr::win, 'tags_w', \%HPVALUE),
1922 new_text_box_for_int (\%pr::win, 'tags_h', \%HPVALUE)),
1923 _('Tags window'), 'not-packed'),
1926 new_text_box_for_int (\%pr::win, 'plug_w', \%HPVALUE),
1927 new_text_box_for_int (\%pr::win, 'plug_h', \%HPVALUE)),
1928 _('Plugins window'), 'not-packed')
1932 sub new_winpos_subpage_misc() {
1933 return new_vbox_pack (
1936 new_text_box_for_int (\%pr::win, 'logw_w', \%HPVALUE),
1937 new_text_box_for_int (\%pr::win, 'logw_h', \%HPVALUE)),
1938 _('Log window'), 'not-packed'),
1941 new_text_box_for_int (\%pr::win, 'prin_w', \%HPVALUE),
1942 new_text_box_for_int (\%pr::win, 'prin_h', \%HPVALUE)),
1943 _('Print preview window'), 'not-packed'),
1946 new_text_box_for_int (\%pr::win, 'sour_w', \%HPVALUE),
1947 new_text_box_for_int (\%pr::win, 'sour_h', \%HPVALUE)),
1948 _('View source window'), 'not-packed')
1952 sub new_winpos_page() {
1953 my $winbook = Gtk2::Notebook->new;
1954 $winbook->set_tab_pos ('right');
1955 $winbook->append_page (new_winpos_subpage_main, _('Main'));
1956 $winbook->append_page (new_winpos_subpage_msgs, _('Message'));
1957 $winbook->append_page (new_winpos_subpage_sendrecv, _('Send/Receive'));
1958 $winbook->append_page (new_winpos_subpage_fold, _('Folder'));
1959 $winbook->append_page (new_winpos_subpage_addrbook, _('Addressbook'));
1960 $winbook->append_page (new_winpos_subpage_accounts, _('Accounts'));
1961 $winbook->append_page (new_winpos_subpage_filtering, _('Filtering'));
1962 $winbook->append_page (new_winpos_subpage_prefs, _('Preferences'));
1963 $winbook->append_page (new_winpos_subpage_misc, _('Other'));
1967 %pr::acc = ( # per account hidden preferences
1969 'gnutls_set_priority',
1970 $xl::s{l_acc_gtls_set},
1971 $xl::s{h_acc_gtls_set},
1978 $xl::s{l_acc_gtls_pri},
1979 $xl::s{h_acc_gtls_pri},
1986 sub new_account_subpage($) {
1988 return new_vbox_pack (
1991 new_check_button_for (\%pr::acc, 'tls_set', $ACHPVALUE{$akey}),
1992 new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey})),
1993 _('GnuTLS priority'), 'not-packed')
1997 sub new_accounts_page() {
1998 my $accbook = Gtk2::Notebook->new;
1999 $accbook->set_tab_pos ('right');
2001 $ACPREFS{$a}{'account_name'} cmp $ACPREFS{$b}{'account_name'}
2004 my $name = $ACPREFS{$_}{'account_name'};
2005 my $isdef = ($ACPREFS{$_}{'is_default'} eq '1');
2006 my $page = new_account_subpage ($_);
2007 $accbook->append_page ($page, $isdef? '<b>' . $name . '</b>': $name);
2009 my $label = $accbook->get_tab_label ($page);
2010 $label->set_use_markup (TRUE);
2013 $accbook->set_scrollable (TRUE);
2017 %pr::plu = ( # plugins hidden preferences
2023 'int,0,3000', # 0 pixels - 3000 pixels
2032 'int,0,3000', # 0 pixels - 3000 pixels
2039 'autocompletion_limit',
2040 $xl::s{l_plu_gpg_alimit},
2041 $xl::s{h_plu_gpg_alimit},
2049 'manager_win_width',
2052 'int,0,3000', # 0 pixels - 3000 pixels
2058 'manager_win_height',
2061 'int,0,3000', # 0 pixels - 3000 pixels
2069 $xl::s{l_plu_lav_burl},
2070 $xl::s{h_plu_lav_burl},
2073 'http://cdn.libravatar.org/avatar',
2078 'filter_log_verbosity',
2079 $xl::s{l_plu_prl_flvb},
2080 $xl::s{h_plu_prl_flvb},
2081 '0=l_plu_prl_none;1=l_plu_prl_manual;2=l_plu_prl_action;3=l_plu_prl_match',
2088 sub new_plugins_page() {
2090 $frame{'AttRemover'} =
2093 new_text_box_for_int (\%pr::plu, 'arm_winw', $PLHPVALUE{'AttRemover'}),
2094 new_text_box_for_int (\%pr::plu, 'arm_winh', $PLHPVALUE{'AttRemover'})),
2095 _('Attachment remover'), 'not-packed');
2099 new_text_box_for_int (\%pr::plu, 'gpg_alimit', $PLHPVALUE{'GPG'})),
2100 _('GPG'), 'not-packed');
2101 $frame{'ManageSieve'} =
2104 new_text_box_for_int (\%pr::plu, 'msv_winw', $PLHPVALUE{'ManageSieve'}),
2105 new_text_box_for_int (\%pr::plu, 'msv_winh', $PLHPVALUE{'ManageSieve'})),
2106 _('Sieve manager'), 'not-packed');
2107 $frame{'Libravatar'} =
2110 new_text_box_for_nchar (\%pr::plu, 'lav_burl', $PLHPVALUE{'Libravatar'})),
2111 _('Libravatar'), 'not-packed');
2112 $frame{'PerlPlugin'} =
2115 new_selection_box_for (\%pr::plu, 'prl_flvb', $PLHPVALUE{'PerlPlugin'})),
2116 _('Perl'), 'not-packed');
2117 foreach (@PLUGINS) {
2118 $frame{$_}->set_sensitive (defined $PLHPVALUE{$_});
2120 return new_vbox_pack (
2121 $frame{'AttRemover'},
2123 $frame{'ManageSieve'},
2124 $frame{'Libravatar'},
2125 $frame{'PerlPlugin'});
2135 BG_LIGHTER => '#ffffff',
2136 BG_DARKER => '#eeeeee'
2139 sub new_hotkeys_list_label {
2140 my $renderer = Gtk2::CellRendererText->new ();
2141 $renderer->set_property('alignment' => 'left');
2142 $renderer->set_property('editable' => FALSE);
2143 $renderer->set_property('size-points' => 8);
2144 $renderer->set_property('size-set' => TRUE);
2148 sub new_hotkeys_list_hotkey {
2149 my $renderer = Gtk2::CellRendererAccel->new ();
2150 $renderer->set_property ('accel-mode' => 'gtk');
2151 $renderer->set_property ('editable' => TRUE);
2152 $renderer->signal_connect ('accel-edited' => sub {
2153 my ($w, $path, $key, $mods, $keycode) = @_;
2154 my $accel = Gtk2::Accelerator->name ($key, $mods);
2155 my ($model, $iter) = $SELHOTKEY->get_selected ();
2156 $model->set($iter, C_HOTKEY, "\"$accel\"");
2157 my $gkey = $model->get_value ($iter, C_GROUP);
2158 my $akey = $model->get_value ($iter, C_ACCEL);
2159 my $data = $HOTKEYS->{$gkey}->{$akey};
2160 $data->{'key'} = "\"$accel\"";
2161 $data->{'enabled'} = TRUE;
2163 $renderer->signal_connect ('accel-cleared' => sub {
2164 my ($w, $path) = @_;
2165 my ($model, $iter) = $SELHOTKEY->get_selected ();
2166 $model->set($iter, C_HOTKEY, "\"\"");
2167 my $gkey = $model->get_value ($iter, C_GROUP);
2168 my $akey = $model->get_value ($iter, C_ACCEL);
2169 my $data = $HOTKEYS->{$gkey}->{$akey};
2170 $data->{'key'} = "\"\"";
2171 $data->{'enabled'} = FALSE;
2176 sub new_hotkeys_list {
2177 my ($gkey, $group) = @_;
2178 my $store = Gtk2::ListStore->new(
2179 qw/Glib::String Glib::String Glib::String Glib::String Glib::String/);
2181 foreach my $akey (sort keys %$group) {
2182 my $iter = $store->append ();
2183 my $hotkey = $group->{$akey}->{'key'};
2185 $label =~ s/[<>]//g; # <rrsyl> and <IMAPFolder> !?
2186 my $bgcol = $even ? BG_DARKER: BG_LIGHTER;
2187 $store->set ($iter, C_LABEL, $label, C_HOTKEY, $hotkey,
2188 C_GROUP, $gkey, C_ACCEL, $akey, C_BCOLOR, $bgcol);
2191 my $treeview = Gtk2::TreeView->new_with_model ($store);
2193 $treeview->insert_column_with_data_func (
2194 0, _("Menu path"), new_hotkeys_list_label (),
2196 my ($col, $renderer, $model, $iter, $data) = @_;
2197 $renderer->set_property (
2198 'text' => $model->get_value ($iter, C_LABEL));
2199 $renderer->set_property (
2200 'background' => $model->get_value ($iter, C_BCOLOR));
2204 $treeview->insert_column_with_data_func (
2205 1, _('Hotkey'), new_hotkeys_list_hotkey (),
2207 my ($col, $renderer, $model, $iter, $data) = @_;
2208 my $hkey = $model->get_value ($iter, C_HOTKEY);
2210 my ($acckey, $accmod) = Gtk2::Accelerator->parse ($hkey);
2211 $renderer->set_property ('accel-key' => $acckey);
2212 $renderer->set_property ('accel-mods' => $accmod);
2213 $renderer->set_property (
2214 'background' => $model->get_value ($iter, C_BCOLOR));
2217 # callback for saving current selection
2218 my $selection = $treeview->get_selection ();
2219 $selection->signal_connect ('changed' => sub { $SELHOTKEY = shift });
2223 sub new_hotkeys_page() {
2224 my $swin = Gtk2::ScrolledWindow->new ();
2225 my $vbox = Gtk2::VBox->new (FALSE, 5);
2226 foreach my $gkey (sort keys %$HOTKEYS) {
2227 my $group = $HOTKEYS->{$gkey};
2229 my $glabel = Gtk2::Label->new ('<b>' . $gkey . '</b>');
2230 $glabel->set_use_markup (TRUE);
2231 $glabel->set_alignment (0, 0.5);
2232 $glabel->set_padding (5, 1);
2233 $vbox->pack_start ($glabel, FALSE, FALSE, 0);
2235 my $keylist = new_hotkeys_list ($gkey, $group);
2236 $vbox->pack_start ($keylist, FALSE, FALSE, 0);
2238 $swin->set_border_width (5);
2239 $swin->set_shadow_type ('none');
2240 $swin->set_policy ('automatic', 'always');
2241 $swin->add_with_viewport ($vbox);
2245 sub new_info_page() {
2246 my $t0 = Gtk2::Table->new (7, 2, FALSE);
2247 my $v = get_toolkit_versions ();
2249 'glib' => 'Perl-GLib',
2250 'glib-r' => _('GLib runtime'),
2251 'glib-b' => _('GLib built'),
2252 'gtk2' => 'Perl-GTK2',
2253 'gtk2-r' => _('GTK2 runtime'),
2254 'gtk2-b' => _('GTK2 built'),
2257 foreach (sort keys %$v) {
2258 if (defined $v->{$_}) {
2259 my $label = Gtk2::Label->new ($labels{$_});
2260 my $value = Gtk2::Label->new ('<b>' . $v->{$_} . '</b>');
2261 $label->set_alignment (0, 0.5);
2262 $value->set_alignment (0, 0.5);
2263 $value->set_use_markup (TRUE);
2264 $t0->attach ($label, 0, 1, $row, $row + 1, 'fill', 'shrink', 8, 6);
2265 $t0->attach ($value, 1, 2, $row, $row + 1, 'fill', 'shrink', 8, 6);
2269 my $t1 = Gtk2::Table->new (2, 2, FALSE);
2270 my @lbl = map { $_->set_alignment (0, 0.5); $_ } (
2271 Gtk2::Label->new (_('Binary')),
2272 Gtk2::Label->new (_('Configuration'))
2274 my $cfgv = $CONFIGDATA->{'Common'}{'config_version'};
2276 my @val = map { $_->set_alignment (0, 0.5); $_->set_use_markup (TRUE); $_ } (
2277 Gtk2::Label->new ('<b>' . $CLAWSV . '</b>'),
2278 Gtk2::Label->new ('<b>' . $cfgv . '</b>')
2280 for (my $i = 0; $i <= $#lbl; ++$i) {
2281 $t1->attach ($lbl[$i], 0, 1, $i, $i + 1, 'fill', 'shrink', 8, 6);
2282 $t1->attach ($val[$i], 1, 2, $i, $i + 1, 'fill', 'shrink', 8, 6);
2284 return new_vbox_pack (
2285 new_subpage_frame ($t0, _('Library versions'), 'not-packed'),
2286 new_subpage_frame ($t1, _('Claws Mail versions'), 'not-packed'));
2290 sub get_toolkit_versions {
2292 $versions{'glib'} = $Glib::VERSION;
2293 # version info stuff appeared in 1.040
2294 if ($Glib::VERSION >= 1.040) {
2295 $versions{'glib-b'} = join('.', Glib->GET_VERSION_INFO);
2296 $versions{'glib-r'} = join('.',
2297 &Glib::major_version, &Glib::minor_version, &Glib::micro_version);
2299 $versions{'gtk2'} = $Gtk2::VERSION;
2300 if ($Gtk2::VERSION >= 1.040) {
2301 $versions{'gtk2-b'} = join('.', Gtk2->GET_VERSION_INFO);
2302 $versions{'gtk2-r'} = join('.',
2303 &Gtk2::major_version, &Gtk2::minor_version, &Gtk2::micro_version);
2308 sub print_version() {
2309 print $xl::s{about_title} . "\n";
2310 print $xl::s{about_version} . " $VERSION\n";
2311 my $v = get_toolkit_versions ();
2312 if ($v->{'glib-b'}) {
2313 print _("Perl-GLib version {glibv}, built for {glibb}, running with {glibr}.",
2314 glibv => $v->{'glib'},
2315 glibb => $v->{'glib-b'},
2316 glibr => $v->{'glib-r'});
2318 print _("Perl-GLib version {glibv}.", glibv => $v->{'glib'});
2321 if ($v->{'gtk2-b'}) {
2322 print _("Perl-GTK2 version {gtkv}, built for {gtkb}, running with {gtkr}.",
2323 gtkv => $v->{'gtk2'},
2324 gtkb => $v->{'gtk2-b'},
2325 gtkr => $v->{'gtk2-r'});
2327 print _("Perl-GTK2 version {gtkv}.", gtkv => $v->{'gtk2'});
2330 my $clawsver = ($CLAWSV eq "") ?
2331 _("Claws Mail was not found!") :
2332 _("Claws Mail returned version {cmv}.", cmv => $CLAWSV);
2333 print $clawsver . "\n";
2336 # the command line help
2338 my $line = '-' x length ($xl::s{about_title});
2340 say $xl::s{about_title};
2344 _(" clawsker [options]"),
2346 _(" -a|--alternate-config-dir <dir> Uses <dir> as Claws Mail configuration."),
2347 _(" -b|--verbose More messages on standard output."),
2348 _(" -c|--clawsrc <file> Uses <file> as full resource name."),
2349 _(" -h|--help Prints this help screen and exits."),
2350 _(" -r|--read-only Disables writing changes to disk."),
2351 _(" -v|--version Prints version information and exits.")
2353 foreach (@help) { say $_ }
2356 sub parse_command_line {
2358 $CLAWSV = get_claws_version ();
2360 GetOptions('h|help' => sub { print_help (); $cont = FALSE },
2361 'v|version' => sub { print_version (); $cont = FALSE },
2362 'b|verbose' => sub { $VERBOSE = TRUE },
2363 'r|read-only' => sub { $READONLY = TRUE },
2364 'u|use-claws-version=s' => \&opt_use_claws_version,
2365 'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
2366 'c|clawsrc=s' => \&opt_clawsrc)
2367 or die _("try -h or --help for syntax.\n");
2370 my $msg = _("Error in options: {msg}\n", msg => $@);
2371 if (defined $ENV{'DISPLAY'} and $ENV{'DISPLAY'} ne '') {
2372 eval { Gtk2->init };
2373 error_dialog ($msg) unless $@;
2380 sub opt_use_claws_version {
2381 my ($name, $value) = @_;
2382 die _("Error: {opt} requires a dotted numeric value argument\n", opt => $name)
2383 unless ($value =~ /^[\d\.]+$/);
2387 sub opt_alternate_config_dir {
2388 my ($name, $value) = @_;
2389 die _("Error: '{dir}' is not a directory or does not exist\n", dir => $value)
2391 $CONFIGDIR = $value;
2392 $CONFIGDIR .= "/" unless ($CONFIGDIR =~ /.*\/$/);
2393 $ALTCONFIGDIR = TRUE;
2397 my ($name, $value) = @_;
2398 die _("Error: '{value}' is not a file or does not exist\n", value => $value)
2400 set_rc_filename ($value);
2403 # update the hidden preferences status from loaded values
2404 sub init_hidden_preferences {
2405 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
2406 foreach my $key (keys %$hash) {
2407 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
2410 foreach my $akey (keys %ACPREFS) {
2411 foreach my $key (keys %pr::acc) {
2412 my $pname = $pr::acc{$key}[NAME];
2413 $ACHPVALUE{$akey}{$pname} = $ACPREFS{$akey}{$pname};
2416 foreach my $key (keys %pr::plu) {
2417 my $plugin = $pr::plu{$key}[PLUGIN];
2418 my $pname = $pr::plu{$key}[NAME];
2419 if (defined $PLPREFS{$plugin}) {
2420 $PLHPVALUE{$plugin}{$pname} = $PLPREFS{$plugin}{$pname};
2426 # generic load/save resource files
2432 open (RCF, '<:encoding(utf8)', $rc)
2433 or die _("Error: opening '{file}' for reading", file => $rc) . ": $!\n";
2434 my $section = '_'; # default unnamed section
2439 if (/^\[([^\]]+)\]$/) { # new section
2441 die _("Error: duplicate section '{sect}' in resource file '{file}'\n",
2442 sect => $section, file => $rc) if ($data{$section});
2443 $data{$section} = {};
2444 $meta{$section}{'#'} = $line;
2446 elsif (/^([0-9a-z_]+)=(.*)$/) { # key=value
2447 $data{$section}{$1} = $2;
2448 $meta{$section}{$1} = $line;
2450 elsif (/^(.*)$/) { # lone value
2451 push (@{$data{$section}{'_'}}, $1);
2455 return (\%data, \%meta);
2459 my ($rc, $data, $meta) = @_;
2460 open (RCF, '>:utf8', $rc)
2461 or die _("Error: opening '{file}' for writing", file => $rc) . ": $!\n";
2462 my @sections = keys %$data;
2463 if (defined $meta) {
2465 $meta->{$a}{'#'} <=> $meta->{$b}{'#'}
2468 foreach my $section (@sections) {
2469 say RCF "[$section]";
2470 if (ref ($data->{$section}{'_'}) eq 'ARRAY') {
2471 foreach my $val (@{$data->{$section}{'_'}}) {
2475 my @keys = keys %{$data->{$section}};
2476 if (defined $meta) {
2478 $meta->{$section}{$a} <=> $meta->{$section}{$b}
2481 foreach my $key (@keys) {
2482 my $val = $data->{$section}{$key};
2483 say RCF "$key=$val";
2494 open (RCF, '<:encoding(utf8)', $rc)
2495 or die _("Error: opening '{file}' for reading", file => $rc) . ": $!\n";
2500 if (/^; \(gtk_accel_path "<([A-Za-z]+)>([^"]+)" ([^\)]+)\)$/) {
2501 my %data = ('key' => $3, 'enabled' => FALSE, 'line' => $line);
2502 $groups{$1}{$2} = \%data;
2503 # say "group -> $1 | path -> $2 | key -> $3";
2504 } elsif (/^\(gtk_accel_path "<([A-Za-z]+)>([^"]+)" ([^\)]+)\)$/) {
2505 my %data = ('key' => $3, 'enabled' => TRUE, 'line' => $line);
2506 $groups{$1}{$2} = \%data;
2507 # say "group -> $1 | path -> $2 | key -> $3";
2516 my ($rc, $groups) = @_;
2518 foreach my $gkey (keys %$groups) {
2519 my $group = $groups->{$gkey};
2520 foreach my $akey (keys %$group) {
2521 my $data = $group->{$akey};
2522 my $key = $data->{'key'};
2523 my $line = $data->{'line'};
2524 $lines[$line] = ($data->{'enabled'})? '': '; ';
2525 $lines[$line] .= '(gtk_accel_path "<'
2526 . $gkey . '>' . $akey . '" ' . $key . ')';
2529 open (RCF, '>:utf8', $rc)
2530 or die _("Error: opening '{file}' for writing", file => $rc) . ": $!\n";
2531 say RCF '; claws-mail GtkAccelMap rc-file -*- scheme -*-';
2532 say RCF '; this file is an automated accelerator map dump';
2534 foreach (@lines) { say RCF $_ if $_ }
2538 # load current status from disc
2539 sub load_rc_preferences {
2540 my $rc = get_rc_filename ();
2541 log_message ("Loading preferences from $rc\n");
2542 return FALSE unless check_rc_file ($rc);
2543 ($CONFIGDATA, $CONFIGMETA) = load_resource ($rc);
2544 foreach (keys %{$CONFIGDATA->{'Common'}}) {
2545 $PREFS{$_} = $CONFIGDATA->{'Common'}{$_};
2547 foreach my $plugin (@PLUGINS) {
2548 if (defined $CONFIGDATA->{$plugin}) {
2549 push (@AVPLUGINS, $plugin);
2550 foreach (keys %{$CONFIGDATA->{$plugin}}) {
2551 $PLPREFS{$plugin}{$_} = $CONFIGDATA->{$plugin}{$_};
2558 sub load_ac_preferences {
2559 my $rc = get_ac_rc_filename ();
2560 log_message ("Loading account preferences from $rc\n");
2561 return FALSE unless check_rc_file ($rc);
2562 ($ACCOUNTDATA, $ACCOUNTMETA) = load_resource ($rc);
2563 foreach my $asect (keys %$ACCOUNTDATA) {
2564 if ($asect =~ /^Account: (\d+)$/) {
2565 foreach (keys %{$ACCOUNTDATA->{$asect}}) {
2566 $ACPREFS{$1}{$_} = $ACCOUNTDATA->{$asect}{$_};
2573 sub load_hk_preferences {
2574 my $rc = get_menurc_filename ();
2575 return FALSE unless check_rc_file ($rc);
2576 $HOTKEYS = load_menurc ($rc);
2580 sub load_preferences {
2581 return FALSE unless check_claws_not_running ();
2582 return (load_rc_preferences ()
2583 and load_ac_preferences ()
2584 and load_hk_preferences ()
2588 # save current preferences to disc
2589 sub save_preferences {
2590 my $rc = get_rc_filename ();
2591 log_message ("Saving preferences to $rc\n");
2592 return FALSE unless check_rc_file ($rc);
2593 return FALSE unless check_claws_not_running ();
2594 my $rcbak = "$rc.backup";
2595 rename ($rc, $rcbak);
2596 foreach (keys %PREFS) {
2597 if (defined $HPVALUE{$_}) {
2598 $CONFIGDATA->{'Common'}{$_} = $HPVALUE{$_};
2601 foreach my $plugin (@AVPLUGINS) {
2602 foreach (keys %{$CONFIGDATA->{$plugin}}) {
2603 if (defined $PLHPVALUE{$plugin}{$_}) {
2604 $CONFIGDATA->{$plugin}{$_} = $PLHPVALUE{$plugin}{$_};
2608 save_resource ($rc, $CONFIGDATA, $CONFIGMETA);
2612 sub save_ac_preferences {
2613 my $rc = get_ac_rc_filename ();
2614 log_message ("Saving account preferences to $rc\n");
2615 return FALSE unless check_rc_file ($rc);
2616 return FALSE unless check_claws_not_running ();
2617 my $rcbak = "$rc.backup";
2618 rename ($rc, $rcbak);
2619 foreach my $asect (keys %$ACCOUNTDATA) {
2620 if ($asect =~ /^Account: (\d+)$/) {
2621 foreach (keys %{$ACCOUNTDATA->{$asect}}) {
2622 if (defined $ACHPVALUE{$1}{$_}) {
2623 $ACCOUNTDATA->{$asect}{$_} = $ACHPVALUE{$1}{$_};
2628 save_resource ($rc, $ACCOUNTDATA, $ACCOUNTMETA);
2632 sub save_hk_preferences {
2633 my $rc = get_menurc_filename ();
2634 log_message ("Saving hotkey preferences to $rc\n");
2635 return FALSE unless check_rc_file ($rc);
2636 return FALSE unless check_claws_not_running ();
2637 save_menurc ($rc, $HOTKEYS);
2643 my $nb = Gtk2::Notebook->new;
2645 $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
2646 $nb->append_page (new_colours_page (), $xl::s{tab_colours});
2647 $nb->append_page (new_gui_page (), $xl::s{tab_gui});
2648 $nb->append_page (new_other_page (), $xl::s{tab_other});
2649 $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
2650 $nb->append_page (new_accounts_page (), $xl::s{tab_accounts});
2651 $nb->append_page (new_plugins_page (), $xl::s{tab_plugins});
2652 $nb->append_page (new_hotkeys_page (), $xl::s{tab_hotkeys});
2653 $nb->append_page (new_info_page (), $xl::s{tab_info});
2658 # create an about dialog
2659 sub new_about_dialog {
2661 my $title = $xl::s{about_title};
2662 my $lic = $xl::s{about_license};
2663 my $vers = $xl::s{about_version} . " $VERSION";
2665 "This program is free software: you can redistribute it and/or modify
2666 it under the terms of the GNU General Public License as published by
2667 the Free Software Foundation, either version 3 of the License, or
2668 (at your option) any later version.
2670 This program is distributed in the hope that it will be useful,
2671 but WITHOUT ANY WARRANTY; without even the implied warranty of
2672 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2673 GNU General Public License for more details.
2675 You should have received a copy of the GNU General Public License
2676 along with this program. If not, see <http://www.gnu.org/licenses/>.";
2677 my $year = "2007-2017";
2678 my $holder = "Ricardo Mones <ricardo\@mones.org>";
2679 my $url = "http://www.claws-mail.org/clawsker.php";
2681 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
2682 [qw/modal destroy-with-parent/],
2684 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
2685 . "<span size=\"large\">$vers</span>\n\n"
2686 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2687 . "<span>Copyright $year by $holder</span>\n\n"
2688 . "<span size=\"large\">$lic</span>\n\n"
2689 . "<span size=\"small\">$license</span>");
2690 $dialog->set_title ($xl::s{about});
2691 if (Gtk2->CHECK_VERSION (2, 10, 0)) {
2692 my @icons = get_app_icons ();
2693 my $image = Gtk2::Image->new_from_pixbuf ($icons[-1]);
2695 $image->set_alignment (0, 0);
2696 $dialog->set_image ($image);
2702 # create buttons box
2703 sub new_button_box {
2704 my ($parent, $adlg) = @_;
2705 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2706 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2707 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2708 # disable button until is really implemented
2709 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2710 my $hbox = Gtk2::HBox->new (FALSE, 5);
2712 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2713 $b_apply->set_sensitive (not $READONLY);
2714 $b_apply->signal_connect (clicked => sub {
2715 save_preferences ($parent);
2716 save_ac_preferences ($parent);
2717 save_hk_preferences ($parent);
2719 # $b_undo->signal_connect (clicked => sub { undo_current_changes });
2720 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2722 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2723 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2724 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2725 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2731 return @APPICONS if (@APPICONS);
2733 if (-d $DATADIR) { # installed
2734 my $dir = $DATADIR . '/icons/hicolor';
2736 join ('/', ($dir, $_ . 'x' . $_, 'apps', $NAME . '.png'))
2738 } else { # unpacked tarball or git clone
2740 join ('/', ('./icons', $NAME . '-' . $_ . '.png'));
2745 $icon = Gtk2::Gdk::Pixbuf->new_from_file($_) if (-f $_);
2746 push @APPICONS, $icon if ($icon);
2752 exit unless parse_command_line ();
2754 $main_window = Gtk2::Window->new ('toplevel');
2755 exit unless load_preferences ();
2756 exit unless init_hidden_preferences ();
2758 my $box = Gtk2::VBox->new (FALSE, 5);
2759 $box->set_border_width(3);
2760 my $about = new_about_dialog ();
2761 $box->pack_start (new_notebook (), TRUE, TRUE, 0);
2762 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
2763 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2764 $main_window->set_title ($xl::s{win_title});
2765 $main_window->set_icon_list (get_app_icons ());
2766 $main_window->add ($box);
2767 $main_window->show_all;