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)";
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_info => _('Info'),
77 ab_frame => _('Addressbook'),
78 mem_frame => _('Memory'),
79 msgview_frame => _('Message View'),
80 log_frame => _('Log window'),
81 dnd_frame => _('Drag \'n\' drop'),
82 ssl_frame => _('Secure Sockets Layer'),
83 msgs_frame => _('Messages'),
84 swc_frame => _('Completion'),
85 stripes_frame => _('Coloured stripes'),
86 sbar_frame => _('Scroll bars'),
87 mlist_frame => _('Message List'),
88 mview_frame => _('Message View'),
89 compo_frame => _('Compose window'),
90 netm_frame => _('NetworkManager'),
91 diff_frame => _('Viewing patches'),
92 mpass_frame => _('Master passphrase'),
93 compose_frame => _('Compose window'),
94 qs_frame => _('Quick search'),
96 l_oth_use_dlg => _('Use detached address book edit dialogue'),
97 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.'),
98 l_oth_max_use => _('Maximum memory for message cache (kB)'),
99 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
100 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
101 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.'),
102 l_oth_use_netm => _('Use NetworkManager'),
103 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
104 l_oth_mp_rounds => _('Rounds for PBKDF2 function'),
105 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.'),
107 l_gui_b_unread => _('Show unread messages with bold font'),
108 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
109 l_gui_no_markup => _('Don\'t use markup'),
110 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
111 l_gui_dot_lines => _('Use dotted lines in tree view components'),
112 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.'),
113 l_gui_h_scroll => _('Enable horizontal scrollbar'),
114 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
115 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
116 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.'),
117 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
118 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
119 l_gui_v_scroll_show => _('Show always'),
120 l_gui_v_scroll_auto => _('Automatic'),
121 l_gui_v_scroll_hide => _('Hide always'),
122 l_gui_from_show => _('From column displays'),
123 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both.'),
124 l_gui_from_show_name => _('Name only'),
125 l_gui_from_show_addr => _('Address only'),
126 l_gui_from_show_both => _('Both name and address'),
127 l_gui_strip_off => _('Coloured lines contrast'),
128 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.'),
129 l_gui_cursor_v => _('Show cursor'),
130 h_gui_cursor_v => _('Display the cursor in the Message View.'),
131 l_gui_toolbar_d => _('Detachable toolbars'),
132 h_gui_toolbar_d => _('Show handles in the toolbars.'),
133 l_gui_strip_all => _('Use stripes in all tree view components'),
134 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
135 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
136 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
137 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
138 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
139 l_gui_margin_co => _('Show margin'),
140 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
141 l_gui_mview_date => _('Don\'t display localized date'),
142 h_gui_mview_date => _('Toggles localization of date format in Message View.'),
143 l_gui_zero_char => _('Zero replacement character'),
144 h_gui_zero_char => _('Replaces \'0\' with the given character in Folder List.'),
145 l_gui_type_any => _('Editable headers'),
146 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.'),
147 l_gui_warn_send_multi => _('Warn when sending to more than'),
148 h_gui_warn_send_multi => _('Warn when sending to multiple recipients.'),
149 l_gui_warn_send_multi_threshold => _('recipients'),
150 h_gui_warn_send_multi_threshold => _('Warn when sending to multiple recipients.'),
151 l_gui_next_del => _('Select next message on delete'),
152 h_gui_next_del => _('When deleting a message, toggles between selecting the next one (newer message) or the previous one (older message).'),
154 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
155 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.'),
156 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
157 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
158 l_beh_flowed => _('Respect format=flowed in messages'),
159 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.'),
160 l_beh_parts_rw => _('Allow writable temporary files'),
161 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
162 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
163 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
164 l_beh_up_step => _('Progress bar update step (items)'),
165 h_beh_up_step => _('Update stepping in progress bars.'),
166 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
167 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
168 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
169 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
170 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
171 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
172 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
173 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
174 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
175 h_beh_out_ascii => _('If allowed by content, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is always enforced.'),
176 l_beh_pp_unsel => _('Primary paste unselects selection'),
177 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
178 l_beh_inline_at => _('Show inline attachments'),
179 h_beh_inline_at => _('Allows to hide inline attachments already shown in mail structure view.'),
180 l_beh_addr_swc => _('Address search in compose window matches any'),
181 h_beh_addr_swc => _('On Tab-key completion, address text will match any part of the string or only from the start.'),
182 l_beh_fold_swc => _('Folder search in folder selector matches any'),
183 h_beh_fold_swc => _('On folder name completion text will match any part of the string or only from the start.'),
184 l_beh_rewrite_ff => _('Rewrite first \'From\' using QP encoding'),
185 h_beh_rewrite_ff => _('Workaround some servers which convert first \'From\' to \'>From\' by using Quoted-Printable transfer encoding instead of 7bit/8bit encoding.'),
187 l_col_emphasis => _('X-Mailer header'),
188 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
189 l_col_log_err => _('Error messages'),
190 h_col_log_err => _('Colour for error messages in log window.'),
191 l_col_log_in => _('Server messages'),
192 h_col_log_in => _('Colour for messages received from servers in log window.'),
193 l_col_log_msg => _('Standard messages'),
194 h_col_log_msg => _('Colour for messages in log window.'),
195 l_col_log_out => _('Client messages'),
196 h_col_log_out => _('Colour for messages sent to servers in log window.'),
197 l_col_log_warn => _('Warning messages'),
198 h_col_log_warn => _('Colour for warning messages in log window.'),
200 l_col_tags_bg => _('Tags background'),
201 h_col_tags_bg => _('Background colour for tags in message view.'),
202 l_col_tags_text => _('Tags text'),
203 h_col_tags_text => _('Text colour for tags in message view.'),
205 l_col_default_header_bg => _('Default headers background'),
206 h_col_default_header_bg => _('Background colour for default headers in compose window.'),
207 l_col_default_header_text => _('Default headers text'),
208 h_col_default_header_text => _('Text colour for default headers in compose window.'),
210 l_col_qs_active_bg => _('Active quick search background'),
211 h_col_qs_active_bg => _('Background colour for active quick search.'),
212 l_col_qs_active_text => _('Active quick search text'),
213 h_col_qs_active_text => _('Text colour for active quick search.'),
214 l_col_qs_error_bg => _('Quick search error background'),
215 h_col_qs_error_bg => _('Background colour for quick search error.'),
216 l_col_qs_error_text => _('Quick search error text'),
217 h_col_qs_error_text => _('Text colour for quick search error.'),
219 l_col_diff_add => _('Added lines'),
220 h_col_diff_add => _('Colour for added lines in patches.'),
221 l_col_diff_del => _('Deleted lines'),
222 h_col_diff_del => _('Colour for deleted lines in patches.'),
223 l_col_diff_hunk => _('Hunk lines'),
224 h_col_diff_hunk => _('Colour for hunk headers in patches.'),
226 l_win_x => _('X position'),
227 h_win_x => _('X coordinate for window\'s top-left corner.'),
228 l_win_y => _('Y position'),
229 h_win_y => _('Y coordinate for window\'s top-left corner.'),
230 l_win_w => _('Width'),
231 h_win_w => _('Window\'s width in pixels.'),
232 l_win_h => _('Height'),
233 h_win_h => _('Window\'s height in pixels.'),
235 l_win_main_mx => _('Maximized'),
236 h_win_main_mx => _('Changes window maximized status.'),
237 l_win_main_fs => _('Full-screen'),
238 h_win_main_fs => _('Changes full screen status.'),
240 l_acc_gtls_set => _('Use custom GnuTLS priority'),
241 h_acc_gtls_set => _('Enables using user provided GnuTLS priority string.'),
242 l_acc_gtls_pri => _('GnuTLS priority'),
243 h_acc_gtls_pri => _('Value to use as GnuTLS priority string if custom priority check is enabled. Otherwise this value is ignored.'),
245 l_plu_gpg_alimit => _('Autocompletion limit'),
246 h_plu_gpg_alimit => _('Limits the number of addresses obtained from keyring through autocompletion. Use 0 to get all matches.'),
247 l_plu_lav_burl => _('Base URL'),
248 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.'),
249 l_plu_prl_flvb => _('Log level'),
250 h_plu_prl_flvb => _('Verbosity level of log, accumulative.'),
251 l_plu_prl_none => _('None'),
252 l_plu_prl_manual => _('Manual'),
253 l_plu_prl_action => _('Actions'),
254 l_plu_prl_match => _('Matches'),
257 # data and metadata of resource files
262 # all preferences read by load_preferences
266 # values of all preferences handled by clawsker
270 # default config dir and file name
271 my $ALTCONFIGDIR = FALSE;
272 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
273 my $CONFIGRC = 'clawsrc';
274 my $ACCOUNTRC = 'accountrc';
275 # supported and available plugins lists
276 my @PLUGINS = qw(AttRemover GPG ManageSieve Libravatar PerlPlugin);
281 # index constants for preference arrays
282 use constant NAME => 0; # the name on the rc file
283 use constant LABEL => 1; # the label on the GUI
284 use constant DESC => 2; # the description for the hint/help
285 use constant TYPE => 3; # data type: bool, int, float, string, color
286 use constant CMVER => 4; # lowest[,highest] Claws Mail version(s) the feature exists
287 use constant CMDEF => 5; # default value for the preference in Claws Mail
288 use constant PLUGIN => 6; # plugin section (only in plugin preferences)
290 # constants for GUI spacing
291 use constant HBOX_PAD => 5;
292 use constant FRAME_SPC => 2;
293 use constant PAGE_SPC => 5;
297 sub version_greater_or_equal {
298 my ($version, $refvers) = @_;
299 return TRUE if (length($version) == 0 and length($refvers) >= 0);
300 return FALSE if (length($version) >= 0 and length($refvers) == 0);
301 return TRUE if (version->parse($version) >= version->parse($refvers));
305 sub get_claws_version {
306 $_ = qx/which claws-mail/;
308 return "" unless ($_); # not installed
312 my @fver = split (/ /);
313 die "Invalid version string" unless ($fver[2] eq "version");
314 my @ver = split (/\./, $fver[3]);
317 if ($ver[2] =~ /(\d+)git(\d+)/) {
326 # data handlers and auxiliar functions
328 sub handle_bool_value {
329 my ($widget, $event, $dataref) = @_;
330 $$dataref = ($widget->get_active ())? '1': '0';
333 sub handle_int_value {
334 my ($widget, $event, $dataref) = @_;
335 $_ = $widget->get_text ();
340 $widget->set_text ($_);
343 $widget->set_text ($$dataref);
347 sub handle_string_value {
348 my ($widget, $event, $dataref) = @_;
349 $$dataref = $widget->get_text ();
352 sub handle_nchar_value {
353 my ($widget, $event, $dataref, $minlen, $maxlen) = @_;
354 $_ = substr ($widget->get_text (), 0, $maxlen);
355 $widget->set_text ($_);
359 sub gdk_color_from_str {
361 my ($rr, $gg, $bb) = (0, 0 ,0);
363 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
368 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
372 sub str_from_gdk_color {
374 my $rr = $color->red / 256;
375 my $gg = $color->green / 256;
376 my $bb = $color->blue / 256;
377 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
381 sub handle_color_value {
382 my ($widget, $event, $dataref) = @_;
383 my $newcol = $widget->get_color;
384 $$dataref = str_from_gdk_color ($newcol);
387 sub handle_selection_value {
388 my ($widget, $event, $dataref) = @_;
389 $$dataref = $widget->get_active;
392 sub get_rc_filename {
393 return $CONFIGDIR . $CONFIGRC;
396 sub get_ac_rc_filename {
397 return $CONFIGDIR . $ACCOUNTRC;
400 sub set_rc_filename {
402 my @parts = split ('/', $fullname);
403 $CONFIGRC = $parts[$#parts];
404 $parts[$#parts] = '';
405 $CONFIGDIR = join ('/', @parts);
409 my ($mesg, $fatal) = @_;
410 if (defined($fatal) && $fatal eq 'die') {
411 die "$NAME: $mesg\n";
414 print "$NAME: $mesg\n";
420 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
421 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
422 $errordlg->set_title (_('Clawsker error'));
427 sub claws_is_running {
428 my $emsg = _('Error: seems Claws Mail is currently running, close it first.');
430 error_dialog ($emsg);
434 sub check_claws_not_running {
435 return TRUE if $READONLY;
436 my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
437 $tmpdir = '/tmp' if ($tmpdir eq '');
438 my $lockdir = "$tmpdir/claws-mail-$<";
442 my $socket = "$lockdir/" . md5_hex ($_);
443 -S $socket and return claws_is_running ();
450 (defined($rcfile) && -f $rcfile) or do {
451 my $emsg = _('Error: resource file for Claws Mail was not found.');
453 error_dialog ($emsg);
459 sub set_widget_hint {
461 my ($wdgt, $hint) = @_;
462 $wdgt->set_tooltip_text ($hint);
463 $wdgt->set_has_tooltip (TRUE);
467 sub set_widget_sens {
468 my ($wdgt, $versions) = @_;
469 my @ver = split(/,/, $versions);
471 $wdgt->set_sensitive (
472 version_greater_or_equal ($CLAWSV, $ver[0])
473 and version_greater_or_equal ($ver[1], $CLAWSV)
476 $wdgt->set_sensitive (version_greater_or_equal ($CLAWSV, $ver[0]));
480 # graphic element creation
482 sub new_hbox_spaced_pack {
483 my $hbox = Gtk2::HBox->new (FALSE);
485 $hbox->pack_start ($_, FALSE, FALSE, HBOX_PAD);
490 sub new_check_button_for($$$) {
491 my ($hash, $key, $vhash) = @_;
492 my $name = $$hash{$key}[NAME];
493 my $label = $$hash{$key}[LABEL];
495 my $cb = Gtk2::CheckButton->new ($label);
496 my $value = $$vhash{$name};
497 $value //= $$hash{$key}[CMDEF];
498 $cb->set_active ($value eq '1');
499 $cb->signal_connect (clicked => sub {
501 handle_bool_value ($w, $e, \$$vhash{$name});
503 set_widget_hint ($cb, $$hash{$key}[DESC]);
504 set_widget_sens ($cb, $$hash{$key}[CMVER]);
506 return new_hbox_spaced_pack ($cb);
509 sub new_text_box_for_int($$$) {
510 my ($hash, $key, $vhash) = @_;
511 my $name = $$hash{$key}[NAME];
512 my $label = $$hash{$key}[LABEL];
513 my @type = split (/,/, $$hash{$key}[TYPE]);
514 push (@type, 0), push (@type, 10000) unless ($#type > 0);
516 my $glabel = Gtk2::Label->new ($label);
517 my $pagei = int (($type[2] - $type[1]) / 10);
518 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
519 my $value = $$vhash{$name};
520 $value //= $$hash{$key}[CMDEF];
521 $gentry->set_numeric (TRUE);
522 $gentry->set_value ($value);
523 $gentry->signal_connect('value-changed' => sub {
525 handle_int_value ($w, $e, \$$vhash{$name});
527 set_widget_hint ($gentry, $$hash{$key}[DESC]);
528 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
529 $glabel->set_sensitive ($gentry->sensitive);
531 return new_hbox_spaced_pack ($glabel, $gentry);
534 sub check_button_and_text_box_update_sens($$$) {
535 my ($cb, $gentry, $glabel) = @_;
536 $gentry->set_sensitive ($cb->get_active);
537 $glabel->set_sensitive ($cb->get_active);
540 sub new_check_button_and_text_box_for_int($$$$) {
541 my ($hash, $key, $key2, $vhash) = @_;
542 my $name = $$hash{$key}[NAME];
543 my $label = $$hash{$key}[LABEL];
545 my $cb = Gtk2::CheckButton->new ($label);
546 my $value = $$vhash{$name};
547 $value //= $$hash{$key}[CMDEF];
548 $cb->set_active ($value eq '1');
549 set_widget_hint ($cb, $$hash{$key}[DESC]);
550 set_widget_sens ($cb, $$hash{$key}[CMVER]);
552 my $name2 = $$hash{$key2}[NAME];
553 my $label2 = $$hash{$key2}[LABEL];
554 my @type = split (/,/, $$hash{$key2}[TYPE]);
555 push (@type, 0), push (@type, 10000) unless ($#type > 0);
557 my $pagei = int (($type[2] - $type[1]) / 10);
558 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
559 my $value2 = $$vhash{$name2};
560 my $glabel = Gtk2::Label->new ($label2);
561 $value2 //= $$hash{$key2}[CMDEF];
562 $gentry->set_numeric (TRUE);
563 $gentry->set_value ($value2);
564 $gentry->signal_connect('value-changed' => sub {
566 handle_int_value ($w, $e, \$$vhash{$name});
568 set_widget_hint ($gentry, $$hash{$key2}[DESC]);
569 set_widget_sens ($gentry, $$hash{$key2}[CMVER]);
570 check_button_and_text_box_update_sens($cb, $gentry, $glabel);
572 $cb->signal_connect ('clicked' => sub {
574 handle_bool_value ($w, $e, \$$vhash{$name});
575 check_button_and_text_box_update_sens($w, $gentry, $glabel);
578 return new_hbox_spaced_pack ($cb, $gentry, $glabel);
581 sub new_text_box_for_nchar($$$) {
582 my ($hash, $key, $vhash) = @_;
583 my $name = $$hash{$key}[NAME];
584 my $label = $$hash{$key}[LABEL];
585 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen,width
586 my $glabel = Gtk2::Label->new ($label);
587 my $gentry = Gtk2::Entry->new ();
588 $gentry->set_max_length($type[2]) if defined ($type[2]);
589 my $width = $type[3];
591 $gentry->set_width_chars(int ($width) + 2) if defined ($width);
592 my $value = $$vhash{$name};
593 $value //= $$hash{$key}[CMDEF];
594 $gentry->set_text ($value);
595 $gentry->signal_connect('key-release-event' => sub {
597 handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1], $type[2]);
599 set_widget_hint ($gentry, $$hash{$key}[DESC]);
600 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
601 $glabel->set_sensitive ($gentry->sensitive);
603 return new_hbox_spaced_pack ($glabel, $gentry);
606 sub new_color_button_for($$$) {
607 my ($hash, $key, $vhash) = @_;
608 my $name = $$hash{$key}[NAME];
609 my $label = $$hash{$key}[LABEL];
611 my $value = $$vhash{$name};
612 $value //= $$hash{$key}[CMDEF];
613 my $col = gdk_color_from_str ($value);
614 my $glabel = Gtk2::Label->new ($label);
615 my $button = Gtk2::ColorButton->new_with_color ($col);
616 $button->set_title ($label);
617 $button->set_relief ('none');
618 $button->signal_connect ('color-set' => sub {
620 handle_color_value ($w, $e, \$$vhash{$name});
622 set_widget_hint ($button, $$hash{$key}[DESC]);
623 set_widget_sens ($button, $$hash{$key}[CMVER]);
624 $glabel->set_sensitive ($button->sensitive);
626 return new_hbox_spaced_pack ($button, $glabel);
629 sub new_selection_box_for($$$) {
630 my ($hash, $key, $vhash) = @_;
631 my $name = $$hash{$key}[NAME];
632 my $label = $$hash{$key}[LABEL];
634 my $glabel = Gtk2::Label->new ($label);
635 my $combo = Gtk2::ComboBox->new_text;
636 my @options = split (';', $$hash{$key}[TYPE]);
637 foreach my $opt (@options) {
638 my ($index, $textkey) = split ('=', $opt);
639 $combo->insert_text ($index, $xl::s{$textkey});
641 $combo->signal_connect ('changed' => sub {
643 handle_selection_value ($w, $e, \$$vhash{$name});
645 my $value = $$vhash{$name};
646 $value //= $$hash{$key}[CMDEF];
647 $combo->set_active ($value);
648 set_widget_hint ($combo, $$hash{$key}[DESC]);
649 set_widget_sens ($combo, $$hash{$key}[CMVER]);
650 $glabel->set_sensitive ($combo->sensitive);
652 return new_hbox_spaced_pack ($glabel, $combo);
655 # more graphic helpers
658 my $hbox = Gtk2::HBox->new (FALSE);
659 $hbox->set_border_width (PAGE_SPC);
661 $hbox->pack_start ($_, FALSE, FALSE, 0);
666 sub new_hbox_pack_compact {
667 my $hbox = Gtk2::HBox->new (FALSE);
668 $hbox->set_border_width (0);
670 $hbox->pack_start ($_, FALSE, FALSE, 0);
676 my $vbox = Gtk2::VBox->new (FALSE, 5);
677 $vbox->set_border_width (PAGE_SPC);
679 $vbox->pack_start ($_, FALSE, FALSE, 0);
684 sub new_vbox_pack_compact {
685 my $vbox = Gtk2::VBox->new (FALSE, 0);
686 $vbox->set_border_width (0);
688 $vbox->pack_start ($_, FALSE, FALSE, 0);
693 sub new_subpage_frame {
694 my ($box, $title, $notpacked) = @_;
695 my $frame = Gtk2::Frame->new ($title);
697 return new_vbox_pack ($frame) unless defined ($notpacked);
701 # preference maps and corresponding page creation subs
703 %pr::oth = ( # other preferences
705 'addressbook_use_editaddress_dialog',
706 $xl::s{l_oth_use_dlg},
707 $xl::s{h_oth_use_dlg},
713 'cache_max_mem_usage',
714 $xl::s{l_oth_max_use},
715 $xl::s{h_oth_max_use},
716 'int,0,262144', # 0 Kb - 256 Mb
721 'cache_min_keep_time',
722 $xl::s{l_oth_min_time},
723 $xl::s{h_oth_min_time},
724 'int,0,120', # 0 minutes - 2 hours
729 'use_networkmanager',
730 $xl::s{l_oth_use_netm},
731 $xl::s{h_oth_use_netm},
737 'master_passphrase_pbkdf2_rounds',
738 $xl::s{l_oth_mp_rounds},
739 $xl::s{h_oth_mp_rounds},
746 sub new_other_page() {
747 return new_vbox_pack (
750 new_check_button_for(\%pr::oth, 'use_dlg', \%HPVALUE)),
751 $xl::s{ab_frame}, 'not-packed'),
754 new_text_box_for_int(\%pr::oth, 'max_use', \%HPVALUE),
755 new_text_box_for_int(\%pr::oth, 'min_time', \%HPVALUE)),
756 $xl::s{mem_frame}, 'not-packed'),
759 new_check_button_for(\%pr::oth, 'use_netm', \%HPVALUE)),
760 $xl::s{netm_frame}, 'not-packed'),
763 new_text_box_for_int(\%pr::oth, 'mp_rounds', \%HPVALUE)),
764 $xl::s{mpass_frame}, 'not-packed')
768 %pr::gui = ( # gui bells and whistles
771 $xl::s{l_gui_b_unread},
772 $xl::s{h_gui_b_unread},
779 $xl::s{l_gui_no_markup},
780 $xl::s{h_gui_no_markup},
786 'enable_dotted_lines',
787 $xl::s{l_gui_dot_lines},
788 $xl::s{h_gui_dot_lines},
790 '2.4.0.115,3.7.10.44',
795 $xl::s{l_gui_h_scroll},
796 $xl::s{h_gui_h_scroll},
803 $xl::s{l_gui_swp_from},
804 $xl::s{h_gui_swp_from},
810 'folderview_vscrollbar_policy',
811 $xl::s{l_gui_v_scroll},
812 $xl::s{h_gui_v_scroll},
813 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
819 $xl::s{l_gui_from_show},
820 $xl::s{h_gui_from_show},
821 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
826 'stripes_color_offset',
827 $xl::s{l_gui_strip_off},
828 $xl::s{h_gui_strip_off},
829 'int,0,40000', # no idea what this number means
834 'textview_cursor_visible',
835 $xl::s{l_gui_cursor_v},
836 $xl::s{h_gui_cursor_v},
842 'toolbar_detachable',
843 $xl::s{l_gui_toolbar_d},
844 $xl::s{h_gui_toolbar_d},
850 'use_stripes_everywhere',
851 $xl::s{l_gui_strip_all},
852 $xl::s{h_gui_strip_all},
858 'use_stripes_in_summaries',
859 $xl::s{l_gui_strip_sum},
860 $xl::s{h_gui_strip_sum},
867 $xl::s{l_gui_two_line_v},
868 $xl::s{h_gui_two_line_v},
874 'show_compose_margin',
875 $xl::s{l_gui_margin_co},
876 $xl::s{h_gui_margin_co},
882 'msgview_date_format',
883 $xl::s{l_gui_mview_date},
884 $xl::s{h_gui_mview_date},
890 'zero_replacement_char',
891 $xl::s{l_gui_zero_char},
892 $xl::s{h_gui_zero_char},
899 $xl::s{l_gui_type_any},
900 $xl::s{h_gui_type_any},
906 'warn_sending_many_recipients',
907 $xl::s{l_gui_warn_send_multi},
908 $xl::s{l_gui_warn_send_multi},
913 warn_send_multi_threshold => [
914 'warn_sending_many_recipients_num',
915 $xl::s{l_gui_warn_send_multi_threshold},
916 $xl::s{l_gui_warn_send_multi_threshold},
923 $xl::s{l_gui_next_del},
924 $xl::s{h_gui_next_del},
932 my $gf = Gtk2::VBox->new (FALSE, 5);
933 $gf->set_border_width (PAGE_SPC);
935 my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines', \%HPVALUE);
936 my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d', \%HPVALUE);
937 my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char', \%HPVALUE);
939 $gf->pack_start (new_subpage_frame (
941 new_check_button_for (\%pr::gui, 'strip_all', \%HPVALUE),
942 new_check_button_for (\%pr::gui, 'strip_sum', \%HPVALUE),
943 new_text_box_for_int (\%pr::gui, 'strip_off', \%HPVALUE)),
944 $xl::s{stripes_frame}, 'not-packed'),
945 FALSE, FALSE, FRAME_SPC);
946 $gf->pack_start (new_subpage_frame (
948 new_check_button_for (\%pr::gui, 'b_unread', \%HPVALUE),
949 new_check_button_for (\%pr::gui, 'swp_from', \%HPVALUE),
950 new_check_button_for (\%pr::gui, 'two_linev', \%HPVALUE),
951 new_check_button_for (\%pr::gui, 'next_del', \%HPVALUE),
952 new_selection_box_for (\%pr::gui, 'from_show', \%HPVALUE)),
953 $xl::s{mlist_frame}, 'not-packed'),
954 FALSE, FALSE, FRAME_SPC);
955 $gf->pack_start (new_subpage_frame (
957 new_check_button_for (\%pr::gui, 'cursor_v', \%HPVALUE),
958 new_check_button_for (\%pr::gui, 'mview_date', \%HPVALUE)),
959 $xl::s{mview_frame}, 'not-packed'),
960 FALSE, FALSE, FRAME_SPC);
961 $gf->pack_start (new_subpage_frame (
963 new_check_button_for (\%pr::gui, 'no_markup', \%HPVALUE),
964 new_check_button_for (\%pr::gui, 'margin_co', \%HPVALUE),
965 new_check_button_for (\%pr::gui, 'type_any', \%HPVALUE),
966 new_check_button_and_text_box_for_int (\%pr::gui, 'warn_send_multi', 'warn_send_multi_threshold', \%HPVALUE)),
967 $xl::s{compo_frame}, 'not-packed'),
968 FALSE, FALSE, FRAME_SPC);
969 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
970 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
971 $gf->pack_start (new_subpage_frame (
973 new_check_button_for (\%pr::gui, 'h_scroll', \%HPVALUE),
974 new_selection_box_for (\%pr::gui, 'v_scroll', \%HPVALUE)),
975 $xl::s{sbar_frame}, 'not-packed'),
976 FALSE, FALSE, FRAME_SPC);
977 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
982 %pr::beh = ( # tweak some behaviour
985 $xl::s{l_beh_hover_t},
986 $xl::s{h_beh_hover_t},
987 'int,100,3000', # 0.1 seconds - 3 seconds
993 $xl::s{l_beh_dangerous},
994 $xl::s{h_beh_dangerous},
1000 'respect_flowed_format',
1001 $xl::s{l_beh_flowed},
1002 $xl::s{h_beh_flowed},
1008 'save_parts_readwrite',
1009 $xl::s{l_beh_parts_rw},
1010 $xl::s{h_beh_parts_rw},
1016 'skip_ssl_cert_check',
1017 $xl::s{l_beh_skip_ssl},
1018 $xl::s{h_beh_skip_ssl},
1024 'statusbar_update_step',
1025 $xl::s{l_beh_up_step},
1026 $xl::s{h_beh_up_step},
1027 'int,1,200', # 1 item - 200 items
1032 'thread_by_subject_max_age',
1033 $xl::s{l_beh_thread_a},
1034 $xl::s{h_beh_thread_a},
1035 'int,1,30', # 1 day - 30 days
1041 $xl::s{l_beh_unsafe_ssl},
1042 $xl::s{h_beh_unsafe_ssl},
1048 'utf8_instead_of_locale_for_broken_mail',
1049 $xl::s{l_beh_use_utf8},
1050 $xl::s{h_beh_use_utf8},
1057 $xl::s{l_beh_warn_dnd},
1058 $xl::s{h_beh_warn_dnd},
1064 'outgoing_fallback_to_ascii',
1065 $xl::s{l_beh_out_ascii},
1066 $xl::s{h_beh_out_ascii},
1072 'primary_paste_unselects',
1073 $xl::s{l_beh_pp_unsel},
1074 $xl::s{h_beh_pp_unsel},
1080 'show_inline_attachments',
1081 $xl::s{l_beh_inline_at},
1082 $xl::s{h_beh_inline_at},
1088 'address_search_wildcard',
1089 $xl::s{l_beh_addr_swc},
1090 $xl::s{h_beh_addr_swc},
1096 'folder_search_wildcard',
1097 $xl::s{l_beh_fold_swc},
1098 $xl::s{h_beh_fold_swc},
1104 'rewrite_first_from',
1105 $xl::s{l_beh_rewrite_ff},
1106 $xl::s{h_beh_rewrite_ff},
1113 sub new_behaviour_page() {
1114 my $bf = Gtk2::VBox->new (FALSE, 5);
1115 $bf->set_border_width (PAGE_SPC);
1117 my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step', \%HPVALUE);
1118 my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a', \%HPVALUE);
1120 $bf->pack_start (new_subpage_frame (
1122 new_text_box_for_int (\%pr::beh, 'hover_t', \%HPVALUE),
1123 new_check_button_for (\%pr::beh, 'warn_dnd', \%HPVALUE)),
1124 $xl::s{dnd_frame}, 'not-packed'),
1125 FALSE, FALSE, FRAME_SPC);
1126 $bf->pack_start (new_subpage_frame (
1128 new_check_button_for (\%pr::beh, 'skip_ssl', \%HPVALUE),
1129 new_check_button_for (\%pr::beh, 'unsafe_ssl', \%HPVALUE)),
1130 $xl::s{ssl_frame}, 'not-packed'),
1131 FALSE, FALSE, FRAME_SPC);
1132 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
1133 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
1134 $bf->pack_start (new_subpage_frame (
1136 new_check_button_for (\%pr::beh, 'flowed', \%HPVALUE),
1137 new_check_button_for (\%pr::beh, 'parts_rw', \%HPVALUE),
1138 new_check_button_for (\%pr::beh, 'use_utf8', \%HPVALUE),
1139 new_check_button_for (\%pr::beh, 'dangerous', \%HPVALUE),
1140 new_check_button_for (\%pr::beh, 'out_ascii', \%HPVALUE),
1141 new_check_button_for (\%pr::beh, 'pp_unsel', \%HPVALUE),
1142 new_check_button_for (\%pr::beh, 'inline_at', \%HPVALUE),
1143 new_check_button_for (\%pr::beh, 'rewrite_ff', \%HPVALUE)),
1144 $xl::s{msgs_frame}, 'not-packed'),
1145 FALSE, FALSE, FRAME_SPC);
1146 $bf->pack_start (new_subpage_frame (
1148 new_check_button_for (\%pr::beh, 'addr_swc', \%HPVALUE),
1149 new_check_button_for (\%pr::beh, 'fold_swc', \%HPVALUE)),
1150 $xl::s{swc_frame}, 'not-packed'),
1151 FALSE, FALSE, FRAME_SPC);
1155 %pr::col = ( # a variety of colours
1158 $xl::s{l_col_emphasis},
1159 $xl::s{h_col_emphasis},
1166 $xl::s{l_col_log_err},
1167 $xl::s{h_col_log_err},
1174 $xl::s{l_col_log_in},
1175 $xl::s{h_col_log_in},
1182 $xl::s{l_col_log_msg},
1183 $xl::s{h_col_log_msg},
1190 $xl::s{l_col_log_out},
1191 $xl::s{h_col_log_out},
1198 $xl::s{l_col_log_warn},
1199 $xl::s{h_col_log_warn},
1206 $xl::s{l_col_diff_add},
1207 $xl::s{h_col_diff_add},
1213 'diff_deleted_color',
1214 $xl::s{l_col_diff_del},
1215 $xl::s{h_col_diff_del},
1222 $xl::s{l_col_diff_hunk},
1223 $xl::s{h_col_diff_hunk},
1230 $xl::s{l_col_tags_bg},
1231 $xl::s{h_col_tags_bg},
1238 $xl::s{l_col_tags_text},
1239 $xl::s{h_col_tags_text},
1244 default_header_bg => [
1245 'default_header_bgcolor',
1246 $xl::s{l_col_default_header_bg},
1247 $xl::s{h_col_default_header_bg},
1252 default_header_text => [
1253 'default_header_color',
1254 $xl::s{l_col_default_header_text},
1255 $xl::s{h_col_default_header_text},
1261 'qs_active_bgcolor',
1262 $xl::s{l_col_qs_active_bg},
1263 $xl::s{h_col_qs_active_bg},
1270 $xl::s{l_col_qs_active_text},
1271 $xl::s{h_col_qs_active_text},
1278 $xl::s{l_col_qs_error_bg},
1279 $xl::s{h_col_qs_error_bg},
1286 $xl::s{l_col_qs_error_text},
1287 $xl::s{h_col_qs_error_text},
1294 sub new_colours_page() {
1295 return new_vbox_pack (
1298 new_color_button_for (\%pr::col, 'emphasis', \%HPVALUE),
1299 new_hbox_pack_compact (
1300 new_color_button_for (\%pr::col, 'tags_text', \%HPVALUE),
1301 new_color_button_for (\%pr::col, 'tags_bg', \%HPVALUE))),
1302 $xl::s{msgview_frame}, 'not-packed'),
1305 new_vbox_pack_compact (
1306 new_color_button_for (\%pr::col, 'log_err', \%HPVALUE),
1307 new_color_button_for (\%pr::col, 'log_warn', \%HPVALUE),
1308 new_color_button_for (\%pr::col, 'log_msg', \%HPVALUE)),
1309 new_vbox_pack_compact (
1310 new_color_button_for (\%pr::col, 'log_in', \%HPVALUE),
1311 new_color_button_for (\%pr::col, 'log_out', \%HPVALUE))),
1312 $xl::s{log_frame}, 'not-packed'),
1315 new_color_button_for (\%pr::col, 'diff_add', \%HPVALUE),
1316 new_color_button_for (\%pr::col, 'diff_del', \%HPVALUE),
1317 new_color_button_for (\%pr::col, 'diff_hunk', \%HPVALUE)),
1318 $xl::s{diff_frame}, 'not-packed'),
1321 new_color_button_for (\%pr::col, 'default_header_text', \%HPVALUE),
1322 new_color_button_for (\%pr::col, 'default_header_bg', \%HPVALUE)),
1323 $xl::s{compose_frame}, 'not-packed'),
1326 new_vbox_pack_compact (
1327 new_color_button_for (\%pr::col, 'qs_active_text', \%HPVALUE),
1328 new_color_button_for (\%pr::col, 'qs_error_text', \%HPVALUE)),
1329 new_vbox_pack_compact (
1330 new_color_button_for (\%pr::col, 'qs_active_bg', \%HPVALUE),
1331 new_color_button_for (\%pr::col, 'qs_error_bg', \%HPVALUE))),
1332 $xl::s{qs_frame}, 'not-packed')
1336 %pr::win = ( # tweak window positions and/or sizes
1341 'int,0,3000', # 0 pixels - 3000 pixels
1349 'int,0,3000', # 0 pixels - 3000 pixels
1357 'int,0,3000', # 0 pixels - 3000 pixels
1365 'int,0,3000', # 0 pixels - 3000 pixels
1370 'mainwin_maximised',
1371 $xl::s{l_win_main_mx},
1372 $xl::s{h_win_main_mx},
1378 'mainwin_fullscreen',
1379 $xl::s{l_win_main_fs},
1380 $xl::s{h_win_main_fs},
1386 'main_messagewin_x',
1389 'int,0,3000', # 0 pixels - 3000 pixels
1394 'main_messagewin_y',
1397 'int,0,3000', # 0 pixels - 3000 pixels
1405 'int,0,3000', # 0 pixels - 3000 pixels
1410 'messagewin_height',
1413 'int,0,3000', # 0 pixels - 3000 pixels
1421 'int,0,3000', # 0 pixels - 3000 pixels
1429 'int,0,3000', # 0 pixels - 3000 pixels
1437 'int,0,3000', # 0 pixels - 3000 pixels
1442 'receivewin_height',
1445 'int,0,3000', # 0 pixels - 3000 pixels
1453 'int,0,3000', # 0 pixels - 3000 pixels
1461 'int,0,3000', # 0 pixels - 3000 pixels
1466 'folderitemwin_width',
1469 'int,0,3000', # 0 pixels - 3000 pixels
1474 'folderitemwin_height',
1477 'int,0,3000', # 0 pixels - 3000 pixels
1482 'folderselwin_width',
1485 'int,0,3000', # 0 pixels - 3000 pixels
1490 'folderselwin_height',
1493 'int,0,3000', # 0 pixels - 3000 pixels
1501 'int,0,3000', # 0 pixels - 3000 pixels
1509 'int,0,3000', # 0 pixels - 3000 pixels
1514 'addressbookwin_width',
1517 'int,0,3000', # 0 pixels - 3000 pixels
1522 'addressbookwin_height',
1525 'int,0,3000', # 0 pixels - 3000 pixels
1530 'addressbookeditpersonwin_width',
1533 'int,0,3000', # 0 pixels - 3000 pixels
1538 'addressbookeditpersonwin_height',
1541 'int,0,3000', # 0 pixels - 3000 pixels
1546 'addressbookeditgroupwin_width',
1549 'int,0,3000', # 0 pixels - 3000 pixels
1554 'addressbookeditgroupwin_height',
1557 'int,0,3000', # 0 pixels - 3000 pixels
1562 'addressaddwin_width',
1565 'int,0,3000', # 0 pixels - 3000 pixels
1570 'addressaddwin_height',
1573 'int,0,3000', # 0 pixels - 3000 pixels
1578 'addressbook_folderselwin_width',
1581 'int,0,3000', # 0 pixels - 3000 pixels
1586 'addressbook_folderselwin_height',
1589 'int,0,3000', # 0 pixels - 3000 pixels
1594 'editaccountwin_width',
1597 'int,0,3000', # 0 pixels - 3000 pixels
1602 'editaccountwin_height',
1605 'int,0,3000', # 0 pixels - 3000 pixels
1610 'accountswin_width',
1613 'int,0,3000', # 0 pixels - 3000 pixels
1618 'accountswin_height',
1621 'int,0,3000', # 0 pixels - 3000 pixels
1626 'filteringwin_width',
1629 'int,0,3000', # 0 pixels - 3000 pixels
1634 'filteringwin_height',
1637 'int,0,3000', # 0 pixels - 3000 pixels
1642 'filteringactionwin_width',
1645 'int,0,3000', # 0 pixels - 3000 pixels
1650 'filteringactionwin_height',
1653 'int,0,3000', # 0 pixels - 3000 pixels
1658 'filtering_debugwin_width',
1661 'int,0,3000', # 0 pixels - 3000 pixels
1666 'filtering_debugwin_height',
1669 'int,0,3000', # 0 pixels - 3000 pixels
1677 'int,0,3000', # 0 pixels - 3000 pixels
1682 'matcherwin_height',
1685 'int,0,3000', # 0 pixels - 3000 pixels
1693 'int,0,3000', # 0 pixels - 3000 pixels
1701 'int,0,3000', # 0 pixels - 3000 pixels
1706 'templateswin_width',
1709 'int,0,3000', # 0 pixels - 3000 pixels
1714 'templateswin_height',
1717 'int,0,3000', # 0 pixels - 3000 pixels
1725 'int,0,3000', # 0 pixels - 3000 pixels
1730 'actionswin_height',
1733 'int,0,3000', # 0 pixels - 3000 pixels
1741 'int,0,3000', # 0 pixels - 3000 pixels
1749 'int,0,3000', # 0 pixels - 3000 pixels
1757 'int,0,3000', # 0 pixels - 3000 pixels
1762 'pluginswin_height',
1765 'int,0,3000', # 0 pixels - 3000 pixels
1773 'int,0,3000', # 0 pixels - 3000 pixels
1781 'int,0,3000', # 0 pixels - 3000 pixels
1786 'print_previewwin_width',
1789 'int,0,3000', # 0 pixels - 3000 pixels
1794 'print_previewwin_height',
1797 'int,0,3000', # 0 pixels - 3000 pixels
1803 sub new_winpos_subpage_main() {
1804 return new_subpage_frame (
1805 new_vbox_pack_compact (
1807 new_text_box_for_int (\%pr::win, 'main_x', \%HPVALUE),
1808 new_text_box_for_int (\%pr::win, 'main_y', \%HPVALUE)),
1810 new_text_box_for_int (\%pr::win, 'main_w', \%HPVALUE),
1811 new_text_box_for_int (\%pr::win, 'main_h', \%HPVALUE)),
1813 new_check_button_for (\%pr::win, 'main_fs', \%HPVALUE),
1814 new_check_button_for (\%pr::win, 'main_mx', \%HPVALUE))),
1819 sub new_winpos_subpage_msgs() {
1820 return new_subpage_frame (
1821 new_vbox_pack_compact (
1823 new_text_box_for_int (\%pr::win, 'msgs_x', \%HPVALUE),
1824 new_text_box_for_int (\%pr::win, 'msgs_y', \%HPVALUE)),
1826 new_text_box_for_int (\%pr::win, 'msgs_w', \%HPVALUE),
1827 new_text_box_for_int (\%pr::win, 'msgs_h', \%HPVALUE))),
1832 sub new_winpos_subpage_sendrecv() {
1833 return new_vbox_pack (
1836 new_text_box_for_int (\%pr::win, 'send_w', \%HPVALUE),
1837 new_text_box_for_int (\%pr::win, 'send_h', \%HPVALUE)),
1838 _('Send window'), 'not-packed'),
1841 new_text_box_for_int (\%pr::win, 'recv_w', \%HPVALUE),
1842 new_text_box_for_int (\%pr::win, 'recv_h', \%HPVALUE)),
1843 _('Receive window'), 'not-packed')
1847 sub new_winpos_subpage_fold() {
1848 return new_vbox_pack (
1850 new_vbox_pack_compact (
1852 new_text_box_for_int (\%pr::win, 'fold_x', \%HPVALUE),
1853 new_text_box_for_int (\%pr::win, 'fold_y', \%HPVALUE)),
1855 new_text_box_for_int (\%pr::win, 'fold_w', \%HPVALUE),
1856 new_text_box_for_int (\%pr::win, 'fold_h', \%HPVALUE))),
1857 _('Folder window'), 'not-packed'),
1860 new_text_box_for_int (\%pr::win, 'fsel_w', \%HPVALUE),
1861 new_text_box_for_int (\%pr::win, 'fsel_h', \%HPVALUE)),
1862 _('Folder selection window'), 'not-packed')
1866 sub new_winpos_subpage_addrbook() {
1867 return new_vbox_pack (
1870 new_text_box_for_int (\%pr::win, 'addr_w', \%HPVALUE),
1871 new_text_box_for_int (\%pr::win, 'addr_h', \%HPVALUE)),
1872 _('Addressbook main window'), 'not-packed'),
1875 new_text_box_for_int (\%pr::win, 'adep_w', \%HPVALUE),
1876 new_text_box_for_int (\%pr::win, 'adep_h', \%HPVALUE)),
1877 _('Edit person window'), 'not-packed'),
1880 new_text_box_for_int (\%pr::win, 'adeg_w', \%HPVALUE),
1881 new_text_box_for_int (\%pr::win, 'adeg_h', \%HPVALUE)),
1882 _('Edit group window'), 'not-packed'),
1885 new_text_box_for_int (\%pr::win, 'adda_w', \%HPVALUE),
1886 new_text_box_for_int (\%pr::win, 'adda_h', \%HPVALUE)),
1887 _('Add address window'), 'not-packed'),
1890 new_text_box_for_int (\%pr::win, 'addf_w', \%HPVALUE),
1891 new_text_box_for_int (\%pr::win, 'addf_h', \%HPVALUE)),
1892 _('Folder select window'), 'not-packed')
1896 sub new_winpos_subpage_accounts() {
1897 return new_vbox_pack (
1900 new_text_box_for_int (\%pr::win, 'acco_w', \%HPVALUE),
1901 new_text_box_for_int (\%pr::win, 'acco_h', \%HPVALUE)),
1902 _('Accounts window'), 'not-packed'),
1905 new_text_box_for_int (\%pr::win, 'acce_w', \%HPVALUE),
1906 new_text_box_for_int (\%pr::win, 'acce_h', \%HPVALUE)),
1907 _('Edit account window'), 'not-packed')
1911 sub new_winpos_subpage_filtering() {
1912 return new_vbox_pack (
1915 new_text_box_for_int (\%pr::win, 'filt_w', \%HPVALUE),
1916 new_text_box_for_int (\%pr::win, 'filt_h', \%HPVALUE)),
1917 _('Filtering window'), 'not-packed'),
1920 new_text_box_for_int (\%pr::win, 'fila_w', \%HPVALUE),
1921 new_text_box_for_int (\%pr::win, 'fila_h', \%HPVALUE)),
1922 _('Filtering actions window'), 'not-packed'),
1925 new_text_box_for_int (\%pr::win, 'fild_w', \%HPVALUE),
1926 new_text_box_for_int (\%pr::win, 'fild_h', \%HPVALUE)),
1927 _('Filtering debug window'), 'not-packed'),
1930 new_text_box_for_int (\%pr::win, 'matc_w', \%HPVALUE),
1931 new_text_box_for_int (\%pr::win, 'matc_h', \%HPVALUE)),
1932 _('Matcher window'), 'not-packed')
1936 sub new_winpos_subpage_prefs() {
1937 return new_vbox_pack (
1940 new_text_box_for_int (\%pr::win, 'pref_w', \%HPVALUE),
1941 new_text_box_for_int (\%pr::win, 'pref_h', \%HPVALUE)),
1942 _('Preferences window'), 'not-packed'),
1945 new_text_box_for_int (\%pr::win, 'temp_w', \%HPVALUE),
1946 new_text_box_for_int (\%pr::win, 'temp_h', \%HPVALUE)),
1947 _('Templates window'), 'not-packed'),
1950 new_text_box_for_int (\%pr::win, 'acti_w', \%HPVALUE),
1951 new_text_box_for_int (\%pr::win, 'acti_h', \%HPVALUE)),
1952 _('Actions window'), 'not-packed'),
1955 new_text_box_for_int (\%pr::win, 'tags_w', \%HPVALUE),
1956 new_text_box_for_int (\%pr::win, 'tags_h', \%HPVALUE)),
1957 _('Tags window'), 'not-packed'),
1960 new_text_box_for_int (\%pr::win, 'plug_w', \%HPVALUE),
1961 new_text_box_for_int (\%pr::win, 'plug_h', \%HPVALUE)),
1962 _('Plugins window'), 'not-packed')
1966 sub new_winpos_subpage_misc() {
1967 return new_vbox_pack (
1970 new_text_box_for_int (\%pr::win, 'logw_w', \%HPVALUE),
1971 new_text_box_for_int (\%pr::win, 'logw_h', \%HPVALUE)),
1972 _('Log window'), 'not-packed'),
1975 new_text_box_for_int (\%pr::win, 'prin_w', \%HPVALUE),
1976 new_text_box_for_int (\%pr::win, 'prin_h', \%HPVALUE)),
1977 _('Print preview window'), 'not-packed'),
1980 new_text_box_for_int (\%pr::win, 'sour_w', \%HPVALUE),
1981 new_text_box_for_int (\%pr::win, 'sour_h', \%HPVALUE)),
1982 _('View source window'), 'not-packed')
1986 sub new_winpos_page() {
1987 my $winbook = Gtk2::Notebook->new;
1988 $winbook->set_tab_pos ('right');
1989 $winbook->append_page (new_winpos_subpage_main, _('Main'));
1990 $winbook->append_page (new_winpos_subpage_msgs, _('Message'));
1991 $winbook->append_page (new_winpos_subpage_sendrecv, _('Send/Receive'));
1992 $winbook->append_page (new_winpos_subpage_fold, _('Folder'));
1993 $winbook->append_page (new_winpos_subpage_addrbook, _('Addressbook'));
1994 $winbook->append_page (new_winpos_subpage_accounts, _('Accounts'));
1995 $winbook->append_page (new_winpos_subpage_filtering, _('Filtering'));
1996 $winbook->append_page (new_winpos_subpage_prefs, _('Preferences'));
1997 $winbook->append_page (new_winpos_subpage_misc, _('Other'));
2001 %pr::acc = ( # per account hidden preferences
2003 'gnutls_set_priority',
2004 $xl::s{l_acc_gtls_set},
2005 $xl::s{h_acc_gtls_set},
2012 $xl::s{l_acc_gtls_pri},
2013 $xl::s{h_acc_gtls_pri},
2020 sub new_account_subpage($) {
2022 return new_vbox_pack (
2025 new_check_button_for (\%pr::acc, 'tls_set', $ACHPVALUE{$akey}),
2026 new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey})),
2027 _('GnuTLS priority'), 'not-packed')
2031 sub new_accounts_page() {
2032 my $accbook = Gtk2::Notebook->new;
2033 $accbook->set_tab_pos ('right');
2035 $ACPREFS{$a}{'account_name'} cmp $ACPREFS{$b}{'account_name'}
2038 my $name = $ACPREFS{$_}{'account_name'};
2039 my $isdef = ($ACPREFS{$_}{'is_default'} eq '1');
2040 my $page = new_account_subpage ($_);
2041 $accbook->append_page ($page, $isdef? '<b>' . $name . '</b>': $name);
2043 my $label = $accbook->get_tab_label ($page);
2044 $label->set_use_markup (TRUE);
2047 $accbook->set_scrollable (TRUE);
2051 %pr::plu = ( # plugins hidden preferences
2057 'int,0,3000', # 0 pixels - 3000 pixels
2066 'int,0,3000', # 0 pixels - 3000 pixels
2073 'autocompletion_limit',
2074 $xl::s{l_plu_gpg_alimit},
2075 $xl::s{h_plu_gpg_alimit},
2083 'manager_win_width',
2086 'int,0,3000', # 0 pixels - 3000 pixels
2092 'manager_win_height',
2095 'int,0,3000', # 0 pixels - 3000 pixels
2103 $xl::s{l_plu_lav_burl},
2104 $xl::s{h_plu_lav_burl},
2107 'http://cdn.libravatar.org/avatar',
2112 'filter_log_verbosity',
2113 $xl::s{l_plu_prl_flvb},
2114 $xl::s{h_plu_prl_flvb},
2115 '0=l_plu_prl_none;1=l_plu_prl_manual;2=l_plu_prl_action;3=l_plu_prl_match',
2122 sub new_plugins_page() {
2124 $frame{'AttRemover'} =
2127 new_text_box_for_int (\%pr::plu, 'arm_winw', $PLHPVALUE{'AttRemover'}),
2128 new_text_box_for_int (\%pr::plu, 'arm_winh', $PLHPVALUE{'AttRemover'})),
2129 _('Attachment remover'), 'not-packed');
2133 new_text_box_for_int (\%pr::plu, 'gpg_alimit', $PLHPVALUE{'GPG'})),
2134 _('GPG'), 'not-packed');
2135 $frame{'ManageSieve'} =
2138 new_text_box_for_int (\%pr::plu, 'msv_winw', $PLHPVALUE{'ManageSieve'}),
2139 new_text_box_for_int (\%pr::plu, 'msv_winh', $PLHPVALUE{'ManageSieve'})),
2140 _('Sieve manager'), 'not-packed');
2141 $frame{'Libravatar'} =
2144 new_text_box_for_nchar (\%pr::plu, 'lav_burl', $PLHPVALUE{'Libravatar'})),
2145 _('Libravatar'), 'not-packed');
2146 $frame{'PerlPlugin'} =
2149 new_selection_box_for (\%pr::plu, 'prl_flvb', $PLHPVALUE{'PerlPlugin'})),
2150 _('Perl'), 'not-packed');
2151 foreach (@PLUGINS) {
2152 $frame{$_}->set_sensitive (defined $PLHPVALUE{$_});
2154 return new_vbox_pack (
2155 $frame{'AttRemover'},
2157 $frame{'ManageSieve'},
2158 $frame{'Libravatar'},
2159 $frame{'PerlPlugin'});
2162 sub new_info_page() {
2163 my $t0 = Gtk2::Table->new (7, 2, FALSE);
2164 my $v = get_toolkit_versions ();
2166 'glib' => 'Perl-GLib',
2167 'glib-r' => _('GLib runtime'),
2168 'glib-b' => _('GLib built'),
2169 'gtk2' => 'Perl-GTK2',
2170 'gtk2-r' => _('GTK2 runtime'),
2171 'gtk2-b' => _('GTK2 built'),
2174 foreach (sort keys %$v) {
2175 if (defined $v->{$_}) {
2176 my $label = Gtk2::Label->new ($labels{$_});
2177 my $value = Gtk2::Label->new ('<b>' . $v->{$_} . '</b>');
2178 $label->set_alignment (0, 0.5);
2179 $value->set_alignment (0, 0.5);
2180 $value->set_use_markup (TRUE);
2181 $t0->attach ($label, 0, 1, $row, $row + 1, 'fill', 'shrink', 8, 6);
2182 $t0->attach ($value, 1, 2, $row, $row + 1, 'fill', 'shrink', 8, 6);
2186 my $t1 = Gtk2::Table->new (2, 2, FALSE);
2187 my @lbl = map { $_->set_alignment (0, 0.5); $_ } (
2188 Gtk2::Label->new (_('Binary')),
2189 Gtk2::Label->new (_('Configuration'))
2191 my $cfgv = $CONFIGDATA->{'Common'}{'config_version'};
2193 my @val = map { $_->set_alignment (0, 0.5); $_->set_use_markup (TRUE); $_ } (
2194 Gtk2::Label->new ('<b>' . $CLAWSV . '</b>'),
2195 Gtk2::Label->new ('<b>' . $cfgv . '</b>')
2197 for (my $i = 0; $i <= $#lbl; ++$i) {
2198 $t1->attach ($lbl[$i], 0, 1, $i, $i + 1, 'fill', 'shrink', 8, 6);
2199 $t1->attach ($val[$i], 1, 2, $i, $i + 1, 'fill', 'shrink', 8, 6);
2201 return new_vbox_pack (
2202 new_subpage_frame ($t0, _('Library versions'), 'not-packed'),
2203 new_subpage_frame ($t1, _('Claws Mail versions'), 'not-packed'));
2207 sub get_toolkit_versions {
2209 $versions{'glib'} = $Glib::VERSION;
2210 # version info stuff appeared in 1.040
2211 if ($Glib::VERSION >= 1.040) {
2212 $versions{'glib-b'} = join('.', Glib->GET_VERSION_INFO);
2213 $versions{'glib-r'} = join('.',
2214 &Glib::major_version, &Glib::minor_version, &Glib::micro_version);
2216 $versions{'gtk2'} = $Gtk2::VERSION;
2217 if ($Gtk2::VERSION >= 1.040) {
2218 $versions{'gtk2-b'} = join('.', Gtk2->GET_VERSION_INFO);
2219 $versions{'gtk2-r'} = join('.',
2220 &Gtk2::major_version, &Gtk2::minor_version, &Gtk2::micro_version);
2225 sub print_version() {
2226 print $xl::s{about_title} . "\n";
2227 print $xl::s{about_version} . " $VERSION\n";
2228 my $v = get_toolkit_versions ();
2229 if ($v->{'glib-b'}) {
2230 print _("Perl-GLib version {glibv}, built for {glibb}, running with {glibr}.",
2231 glibv => $v->{'glib'},
2232 glibb => $v->{'glib-b'},
2233 glibr => $v->{'glib-r'});
2235 print _("Perl-GLib version {glibv}.", glibv => $v->{'glib'});
2238 if ($v->{'gtk2-b'}) {
2239 print _("Perl-GTK2 version {gtkv}, built for {gtkb}, running with {gtkr}.",
2240 gtkv => $v->{'gtk2'},
2241 gtkb => $v->{'gtk2-b'},
2242 gtkr => $v->{'gtk2-r'});
2244 print _("Perl-GTK2 version {gtkv}.", gtkv => $v->{'gtk2'});
2247 my $clawsver = ($CLAWSV eq "") ?
2248 _("Claws Mail was not found!") :
2249 _("Claws Mail returned version {cmv}.", cmv => $CLAWSV);
2250 print $clawsver . "\n";
2253 # the command line help
2255 my $line = '-' x length ($xl::s{about_title});
2257 say $xl::s{about_title};
2261 _(" clawsker [options]"),
2263 _(" -a|--alternate-config-dir <dir> Uses <dir> as Claws Mail configuration."),
2264 _(" -b|--verbose More messages on standard output."),
2265 _(" -c|--clawsrc <file> Uses <file> as full resource name."),
2266 _(" -h|--help Prints this help screen and exits."),
2267 _(" -r|--read-only Disables writing changes to disk."),
2268 _(" -v|--version Prints version information and exits.")
2270 foreach (@help) { say $_ }
2273 sub parse_command_line {
2275 $CLAWSV = get_claws_version ();
2277 GetOptions('h|help' => sub { print_help (); $cont = FALSE },
2278 'v|version' => sub { print_version (); $cont = FALSE },
2279 'b|verbose' => sub { $VERBOSE = TRUE },
2280 'r|read-only' => sub { $READONLY = TRUE },
2281 'u|use-claws-version=s' => \&opt_use_claws_version,
2282 'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
2283 'c|clawsrc=s' => \&opt_clawsrc)
2284 or die _("try -h or --help for syntax.\n");
2287 my $msg = _("Error in options: {msg}\n", msg => $@);
2288 if (defined $ENV{'DISPLAY'} and $ENV{'DISPLAY'} ne '') {
2289 eval { Gtk2->init };
2290 error_dialog ($msg) unless $@;
2297 sub opt_use_claws_version {
2298 my ($name, $value) = @_;
2299 die _("Error: {opt} requires a dotted numeric value argument\n", opt => $name)
2300 unless ($value =~ /^[\d\.]+$/);
2304 sub opt_alternate_config_dir {
2305 my ($name, $value) = @_;
2306 die _("Error: '{dir}' is not a directory or does not exist\n", dir => $value)
2308 $CONFIGDIR = $value;
2309 $CONFIGDIR .= "/" unless ($CONFIGDIR =~ /.*\/$/);
2310 $ALTCONFIGDIR = TRUE;
2314 my ($name, $value) = @_;
2315 die _("Error: '{value}' is not a file or does not exist\n", value => $value)
2317 set_rc_filename ($value);
2320 # update the hidden preferences status from loaded values
2321 sub init_hidden_preferences {
2322 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
2323 foreach my $key (keys %$hash) {
2324 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
2327 foreach my $akey (keys %ACPREFS) {
2328 foreach my $key (keys %pr::acc) {
2329 my $pname = $pr::acc{$key}[NAME];
2330 $ACHPVALUE{$akey}{$pname} = $ACPREFS{$akey}{$pname};
2333 foreach my $key (keys %pr::plu) {
2334 my $plugin = $pr::plu{$key}[PLUGIN];
2335 my $pname = $pr::plu{$key}[NAME];
2336 if (defined $PLPREFS{$plugin}) {
2337 $PLHPVALUE{$plugin}{$pname} = $PLPREFS{$plugin}{$pname};
2343 # generic load/save resource files
2349 open (RCF, '<:encoding(utf8)', $rc)
2350 or die _("Error: opening '{file}' for reading", file => $rc) . ": $!\n";
2351 my $section = '_'; # default unnamed section
2356 if (/^\[([^\]]+)\]$/) { # new section
2358 die _("Error: duplicate section '{sect}' in resource file '{file}'\n",
2359 sect => $section, file => $rc) if ($data{$section});
2360 $data{$section} = {};
2361 $meta{$section}{'#'} = $line;
2363 elsif (/^([0-9a-z_]+)=(.*)$/) { # key=value
2364 $data{$section}{$1} = $2;
2365 $meta{$section}{$1} = $line;
2367 elsif (/^(.*)$/) { # lone value
2368 push (@{$data{$section}{'_'}}, $1);
2372 return (\%data, \%meta);
2376 my ($rc, $data, $meta) = @_;
2377 open (RCF, '>:utf8', $rc)
2378 or die _("Error: opening '{file}' for writing", file => $rc) . ": $!\n";
2379 my @sections = keys %$data;
2380 if (defined $meta) {
2382 $meta->{$a}{'#'} <=> $meta->{$b}{'#'}
2385 foreach my $section (@sections) {
2386 say RCF "[$section]";
2387 if (ref ($data->{$section}{'_'}) eq 'ARRAY') {
2388 foreach my $val (@{$data->{$section}{'_'}}) {
2392 my @keys = keys %{$data->{$section}};
2393 if (defined $meta) {
2395 $meta->{$section}{$a} <=> $meta->{$section}{$b}
2398 foreach my $key (@keys) {
2399 my $val = $data->{$section}{$key};
2400 say RCF "$key=$val";
2408 # load current status from disc
2409 sub load_rc_preferences {
2410 my $rc = get_rc_filename ();
2411 log_message ("Loading preferences from $rc\n");
2412 return FALSE unless check_rc_file ($rc);
2413 ($CONFIGDATA, $CONFIGMETA) = load_resource ($rc);
2414 foreach (keys %{$CONFIGDATA->{'Common'}}) {
2415 $PREFS{$_} = $CONFIGDATA->{'Common'}{$_};
2417 foreach my $plugin (@PLUGINS) {
2418 if (defined $CONFIGDATA->{$plugin}) {
2419 push (@AVPLUGINS, $plugin);
2420 foreach (keys %{$CONFIGDATA->{$plugin}}) {
2421 $PLPREFS{$plugin}{$_} = $CONFIGDATA->{$plugin}{$_};
2428 sub load_ac_preferences {
2429 my $rc = get_ac_rc_filename ();
2430 log_message ("Loading account preferences from $rc\n");
2431 return FALSE unless check_rc_file ($rc);
2432 ($ACCOUNTDATA, $ACCOUNTMETA) = load_resource ($rc);
2433 foreach my $asect (keys %$ACCOUNTDATA) {
2434 if ($asect =~ /^Account: (\d+)$/) {
2435 foreach (keys %{$ACCOUNTDATA->{$asect}}) {
2436 $ACPREFS{$1}{$_} = $ACCOUNTDATA->{$asect}{$_};
2443 sub load_preferences {
2444 return FALSE unless check_claws_not_running ();
2445 return (load_rc_preferences () and load_ac_preferences ());
2448 # save current preferences to disc
2449 sub save_preferences {
2450 my $rc = get_rc_filename ();
2451 log_message ("Saving preferences to $rc\n");
2452 return FALSE unless check_rc_file ($rc);
2453 return FALSE unless check_claws_not_running ();
2454 my $rcbak = "$rc.backup";
2455 rename ($rc, $rcbak);
2456 foreach (keys %PREFS) {
2457 if (defined $HPVALUE{$_}) {
2458 $CONFIGDATA->{'Common'}{$_} = $HPVALUE{$_};
2461 foreach my $plugin (@AVPLUGINS) {
2462 foreach (keys %{$CONFIGDATA->{$plugin}}) {
2463 if (defined $PLHPVALUE{$plugin}{$_}) {
2464 $CONFIGDATA->{$plugin}{$_} = $PLHPVALUE{$plugin}{$_};
2468 save_resource ($rc, $CONFIGDATA, $CONFIGMETA);
2472 sub save_ac_preferences {
2473 my $rc = get_ac_rc_filename ();
2474 log_message ("Saving account preferences to $rc\n");
2475 return FALSE unless check_rc_file ($rc);
2476 return FALSE unless check_claws_not_running ();
2477 my $rcbak = "$rc.backup";
2478 rename ($rc, $rcbak);
2479 foreach my $asect (keys %$ACCOUNTDATA) {
2480 if ($asect =~ /^Account: (\d+)$/) {
2481 foreach (keys %{$ACCOUNTDATA->{$asect}}) {
2482 if (defined $ACHPVALUE{$1}{$_}) {
2483 $ACCOUNTDATA->{$asect}{$_} = $ACHPVALUE{$1}{$_};
2488 save_resource ($rc, $ACCOUNTDATA, $ACCOUNTMETA);
2494 my $nb = Gtk2::Notebook->new;
2496 $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
2497 $nb->append_page (new_colours_page (), $xl::s{tab_colours});
2498 $nb->append_page (new_gui_page (), $xl::s{tab_gui});
2499 $nb->append_page (new_other_page (), $xl::s{tab_other});
2500 $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
2501 $nb->append_page (new_accounts_page (), $xl::s{tab_accounts});
2502 $nb->append_page (new_plugins_page (), $xl::s{tab_plugins});
2503 $nb->append_page (new_info_page (), $xl::s{tab_info});
2508 # create an about dialog
2509 sub new_about_dialog {
2511 my $title = $xl::s{about_title};
2512 my $lic = $xl::s{about_license};
2513 my $vers = $xl::s{about_version} . " $VERSION";
2515 "This program is free software: you can redistribute it and/or modify
2516 it under the terms of the GNU General Public License as published by
2517 the Free Software Foundation, either version 3 of the License, or
2518 (at your option) any later version.
2520 This program is distributed in the hope that it will be useful,
2521 but WITHOUT ANY WARRANTY; without even the implied warranty of
2522 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2523 GNU General Public License for more details.
2525 You should have received a copy of the GNU General Public License
2526 along with this program. If not, see <http://www.gnu.org/licenses/>.";
2527 my $year = "2007-2016";
2528 my $holder = "Ricardo Mones <ricardo\@mones.org>";
2529 my $url = "http://www.claws-mail.org/clawsker.php";
2531 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
2532 [qw/modal destroy-with-parent/],
2534 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
2535 . "<span size=\"large\">$vers</span>\n\n"
2536 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2537 . "<span>Copyright $year by $holder</span>\n\n"
2538 . "<span size=\"large\">$lic</span>\n\n"
2539 . "<span size=\"small\">$license</span>");
2540 $dialog->set_title ($xl::s{about});
2541 if (Gtk2->CHECK_VERSION (2, 10, 0)) {
2542 my @icons = get_app_icons ();
2543 my $image = Gtk2::Image->new_from_pixbuf ($icons[-1]);
2545 $image->set_alignment (0, 0);
2546 $dialog->set_image ($image);
2552 # create buttons box
2553 sub new_button_box {
2554 my ($parent, $adlg) = @_;
2555 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2556 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2557 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2558 # disable button until is really implemented
2559 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2560 my $hbox = Gtk2::HBox->new (FALSE, 5);
2562 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2563 $b_apply->set_sensitive (not $READONLY);
2564 $b_apply->signal_connect (clicked => sub {
2565 save_preferences ($parent);
2566 save_ac_preferences ($parent);
2568 # $b_undo->signal_connect (clicked => sub { undo_current_changes });
2569 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2571 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2572 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2573 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2574 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2580 return @APPICONS if (@APPICONS);
2582 if (-d $DATADIR) { # installed
2583 my $dir = $DATADIR . '/icons/hicolor';
2585 join ('/', ($dir, $_ . 'x' . $_, 'apps', $NAME . '.png'))
2587 } else { # unpacked tarball or git clone
2589 join ('/', ('./icons', $NAME . '-' . $_ . '.png'));
2594 $icon = Gtk2::Gdk::Pixbuf->new_from_file($_) if (-f $_);
2595 push @APPICONS, $icon if ($icon);
2601 exit unless parse_command_line ();
2603 $main_window = Gtk2::Window->new ('toplevel');
2604 exit unless load_preferences ();
2605 exit unless init_hidden_preferences ();
2607 my $box = Gtk2::VBox->new (FALSE, 5);
2608 $box->set_border_width(3);
2609 my $about = new_about_dialog ();
2610 $box->pack_start (new_notebook (), FALSE, FALSE, 0);
2611 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
2612 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2613 $main_window->set_title ($xl::s{win_title});
2614 $main_window->set_icon_list (get_app_icons ());
2615 $main_window->add ($box);
2616 $main_window->show_all;