3 # Clawsker :: A Claws Mail Tweaker
4 # Copyright 2007-2016 Ricardo Mones <ricardo@mones.org>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # See COPYING file for license details.
12 # See AUTHORS file for a complete list of contributors.
15 binmode STDOUT, ":encoding(utf8)";
20 use Glib qw(TRUE FALSE);
22 use POSIX qw(setlocale);
25 use Digest::MD5 qw(md5_hex);
28 my $NAME = 'clawsker';
29 my $PREFIX = '@PREFIX@';
30 my $LIBDIR = '@LIBDIR@';
31 my $DATADIR = '@DATADIR@';
32 my $VERSION = '@VERSION@';
35 my $main_window = undef;
37 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
38 $locale = "C" unless defined($locale);
39 setlocale (LC_ALL, $locale);
40 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
43 my $SHOWHINTS = FALSE;
44 $SHOWHINTS = TRUE if ($Gtk2::VERSION >= 1.040 and Gtk2->CHECK_VERSION (2, 12, 0));
49 my $xla = gettext ($str);
50 if (scalar(keys(%par)) > 0) {
51 foreach my $key (keys %par) {
52 $xla =~ s/\{$key\}/$par{$key}/g;
55 return decode_utf8($xla);
60 win_title => _('Claws Mail Hidden Preferences'),
61 about => _('About...'),
62 about_title => _('Clawsker :: A Claws Mail Tweaker'),
63 about_license => _('License:'),
64 about_version => _('Version:'),
66 tab_colours => _('Colours'),
67 tab_behaviour => _('Behaviour'),
69 tab_other => _('Other'),
70 tab_winpos => _('Windows'),
72 ab_frame => _('Addressbook'),
73 mem_frame => _('Memory'),
74 msgview_frame => _('Message View'),
75 log_frame => _('Log window'),
76 dnd_frame => _('Drag \'n\' drop'),
77 ssl_frame => _('Secure Sockets Layer'),
78 msgs_frame => _('Messages'),
79 swc_frame => _('Completion'),
80 stripes_frame => _('Coloured stripes'),
81 sbar_frame => _('Scroll bars'),
82 mlist_frame => _('Message List'),
83 mview_frame => _('Message View'),
84 compo_frame => _('Compose window'),
85 netm_frame => _('NetworkManager'),
86 diff_frame => _('Viewing patches'),
87 mpass_frame => _('Master passphrase'),
89 l_oth_use_dlg => _('Use detached address book edit dialogue'),
90 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.'),
91 l_oth_max_use => _('Maximum memory for message cache (kB)'),
92 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
93 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
94 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.'),
95 l_oth_use_netm => _('Use NetworkManager'),
96 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
97 l_oth_mp_rounds => _('Rounds for PBKDF2 function'),
98 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.'),
100 l_gui_b_unread => _('Show unread messages with bold font'),
101 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
102 l_gui_no_markup => _('Don\'t use markup'),
103 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
104 l_gui_dot_lines => _('Use dotted lines in tree view components'),
105 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.'),
106 l_gui_h_scroll => _('Enable horizontal scrollbar'),
107 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
108 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
109 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.'),
110 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
111 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
112 l_gui_v_scroll_show => _('Show always'),
113 l_gui_v_scroll_auto => _('Automatic'),
114 l_gui_v_scroll_hide => _('Hide always'),
115 l_gui_from_show => _('From column displays'),
116 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both.'),
117 l_gui_from_show_name => _('Name only'),
118 l_gui_from_show_addr => _('Address only'),
119 l_gui_from_show_both => _('Both name and address'),
120 l_gui_strip_off => _('Coloured lines contrast'),
121 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.'),
122 l_gui_cursor_v => _('Show cursor'),
123 h_gui_cursor_v => _('Display the cursor in the Message View.'),
124 l_gui_toolbar_d => _('Detachable toolbars'),
125 h_gui_toolbar_d => _('Show handles in the toolbars.'),
126 l_gui_strip_all => _('Use stripes in all tree view components'),
127 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
128 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
129 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
130 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
131 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
132 l_gui_margin_co => _('Show margin'),
133 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
134 l_gui_mview_date => _('Don\'t display localized date'),
135 h_gui_mview_date => _('Toggles localization of date format in Message View.'),
136 l_gui_zero_char => _('Zero replacement character'),
137 h_gui_zero_char => _('Replaces \'0\' with the given character in Folder List.'),
138 l_gui_type_any => _('Editable headers'),
139 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.'),
140 l_gui_next_del => _('Select next message on delete'),
141 h_gui_next_del => _('When deleting a message, toggles between selecting the next one (newer message) or the previous one (older message).'),
143 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
144 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.'),
145 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
146 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
147 l_beh_flowed => _('Respect format=flowed in messages'),
148 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.'),
149 l_beh_parts_rw => _('Allow writable temporary files'),
150 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
151 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
152 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
153 l_beh_up_step => _('Progress bar update step (items)'),
154 h_beh_up_step => _('Update stepping in progress bars.'),
155 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
156 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
157 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
158 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
159 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
160 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
161 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
162 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
163 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
164 h_beh_out_ascii => _('If content allows, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is enforced always.'),
165 l_beh_pp_unsel => _('Primary paste unselects selection'),
166 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
167 l_beh_inline_at => _('Show inline attachments'),
168 h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view.'),
169 l_beh_addr_swc => _('Address search in compose window matches any'),
170 h_beh_addr_swc => _('On Tab-key completion, address text will match any part of the string or only from the start.'),
171 l_beh_fold_swc => _('Folder search in folder selector matches any'),
172 h_beh_fold_swc => _('On folder name completion text will match any part of the string or only from the start.'),
174 l_col_emphasis => _('X-Mailer header'),
175 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
176 l_col_log_err => _('Error messages'),
177 h_col_log_err => _('Colour for error messages in log window.'),
178 l_col_log_in => _('Server messages'),
179 h_col_log_in => _('Colour for messages received from servers in log window.'),
180 l_col_log_msg => _('Standard messages'),
181 h_col_log_msg => _('Colour for messages in log window.'),
182 l_col_log_out => _('Client messages'),
183 h_col_log_out => _('Colour for messages sent to servers in log window.'),
184 l_col_log_warn => _('Warnings'),
185 h_col_log_warn => _('Colour for warning messages in log window.'),
187 l_col_diff_add => _('Added lines'),
188 h_col_diff_add => _('Colour for added lines in patches.'),
189 l_col_diff_del => _('Deleted lines'),
190 h_col_diff_del => _('Colour for deleted lines in patches.'),
191 l_col_diff_hunk => _('Hunk lines'),
192 h_col_diff_hunk => _('Color for hunk headers in patches.'),
194 l_win_x => _('X position'),
195 h_win_x => _('X coordinate for window\'s top-left corner.'),
196 l_win_y => _('Y position'),
197 h_win_y => _('Y coordinate for window\'s top-left corner.'),
198 l_win_w => _('Width'),
199 h_win_w => _('Window\'s width in pixels.'),
200 l_win_h => _('Height'),
201 h_win_h => _('Window\'s height in pixels.'),
203 l_win_main_mx => _('Maximized'),
204 h_win_main_mx => _('Changes window maximized status.'),
205 l_win_main_fs => _('Full-screen'),
206 h_win_main_fs => _('Changes full screen status.'),
208 e_error => _('Error: '),
209 e_noclawsrc => _('resource file for Claws Mail was not found.'),
210 e_running => _('seems Claws Mail is currently running, close it first.'),
213 # all preferences read by load_preferences
215 # values of all preferences handled by clawsker
217 # default config dir and file name
218 my $ALTCONFIGDIR = FALSE;
219 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
220 my $CONFIGRC = 'clawsrc';
222 # index constants for preference arrays
223 use constant NAME => 0; # the name on the rc file
224 use constant LABEL => 1; # the label on the GUI
225 use constant DESC => 2; # the description for the hint/help
226 use constant TYPE => 3; # data type: bool, int, float, string, color
227 use constant CMVER => 4; # lowest[,highest] Claws Mail version(s) the feature exists
228 use constant CMDEF => 5; # default value for the preference in Claws Mail
229 use constant GUI => 6; # GUI element
231 # constants for GUI spacing
232 use constant HBOX_SPC => 5;
233 use constant FRAME_SPC => 2;
234 use constant PAGE_SPC => 5;
238 sub version_greater_or_equal {
239 my ($version, $refvers) = @_;
240 my @version = split (/\./, $version);
241 my @refvers = split (/\./, $refvers);
242 while ($#version < $#refvers) {
243 push (@version, '0');
246 while (($idx <= $#refvers)
247 and (int ($version[$idx]) == int ($refvers[$idx]))) {
250 return TRUE if (($idx > $#refvers)
251 or (int ($version[$idx]) >= int ($refvers[$idx])));
255 sub get_claws_version {
260 foreach my $bin (@cmbin) {
265 return "" unless ($_); # not installed
268 my @fver = split (/ /);
269 die "Invalid version string" unless ($fver[2] eq "version");
270 my @ver = split (/\./, $fver[3]);
273 if ($ver[2] =~ /(\d+)git(\d+)/) {
282 # data handlers and auxiliar functions
284 sub handle_bool_value {
285 my ($widget, $event, $dataref) = @_;
286 $$dataref = ($widget->get_active ())? '1': '0';
289 sub handle_int_value {
290 my ($widget, $event, $dataref) = @_;
291 $_ = $widget->get_text ();
296 $widget->set_text ($_);
299 $widget->set_text ($$dataref);
303 sub handle_string_value {
304 my ($widget, $event, $dataref) = @_;
305 $$dataref = $widget->get_text ();
308 sub handle_nchar_value {
309 my ($widget, $event, $dataref, $minlen) = @_;
310 $_ = substr ($widget->get_text (), 0, $minlen);
311 $widget->set_text ($_);
315 sub gdk_color_from_str {
317 my ($rr, $gg, $bb) = (0, 0 ,0);
319 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
324 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
328 sub str_from_gdk_color {
330 my $rr = $color->red / 256;
331 my $gg = $color->green / 256;
332 my $bb = $color->blue / 256;
333 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
337 sub handle_color_value {
338 my ($widget, $event, $dataref) = @_;
339 my $newcol = $widget->get_color;
340 $$dataref = str_from_gdk_color ($newcol);
343 sub handle_selection_value {
344 my ($widget, $event, $dataref) = @_;
345 $$dataref = $widget->get_active;
348 sub get_rc_filename {
349 return $CONFIGDIR . $CONFIGRC;
352 sub set_rc_filename {
354 my @parts = split ('/', $fullname);
355 $CONFIGRC = $parts[$#parts];
356 $parts[$#parts] = '';
357 $CONFIGDIR = join ('/', @parts);
361 my ($mesg, $fatal) = @_;
362 if (defined($fatal) && $fatal eq 'die') {
363 die "$NAME: $mesg\n";
366 print "$NAME: $mesg\n";
372 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
373 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
374 $errordlg->set_title (_('Clawsker error'));
379 sub claws_is_running {
380 my $emsg = "$xl::s{e_error}$xl::s{e_running}";
382 error_dialog ($emsg);
386 sub check_claws_not_running {
387 my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
388 $tmpdir = '/tmp' if ($tmpdir eq '');
389 my $lockdir = "$tmpdir/claws-mail-$<";
393 my $socket = "$lockdir/" . md5_hex ($_);
394 -S $socket and return claws_is_running ();
401 (defined($rcfile) && -f $rcfile) or do {
402 my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
404 error_dialog ($emsg);
410 sub set_widget_hint {
412 my ($wdgt, $hint) = @_;
413 $wdgt->set_tooltip_text ($hint);
414 $wdgt->set_has_tooltip (TRUE);
418 sub set_widget_sens {
419 my ($wdgt, $versions) = @_;
420 my @ver = split(/,/, $versions);
422 $wdgt->set_sensitive (
423 version_greater_or_equal ($CLAWSV, $ver[0])
424 and version_greater_or_equal ($ver[1], $CLAWSV)
427 $wdgt->set_sensitive (version_greater_or_equal ($CLAWSV, $ver[0]));
431 # graphic element creation
433 sub new_check_button_for {
434 my ($hash, $key) = @_;
435 my $name = $$hash{$key}[NAME];
436 my $label = $$hash{$key}[LABEL];
438 my $hbox = Gtk2::HBox->new (FALSE, 5);
439 my $cb = Gtk2::CheckButton->new ($label);
440 $$hash{$key}[GUI] = $cb;
441 my $value = $HPVALUE{$name};
442 $value //= $$hash{$key}[CMDEF];
443 $cb->set_active ($value eq '1');
444 $cb->signal_connect (clicked => sub {
446 handle_bool_value ($w, $e, \$HPVALUE{$name});
448 set_widget_hint ($cb, $$hash{$key}[DESC]);
449 set_widget_sens ($cb, $$hash{$key}[CMVER]);
450 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
455 sub new_text_box_for_int {
456 my ($hash, $key) = @_;
457 my $name = $$hash{$key}[NAME];
458 my $label = $$hash{$key}[LABEL];
459 my @type = split (/,/, $$hash{$key}[TYPE]);
460 push (@type, 0), push (@type, 10000) unless ($#type > 0);
462 my $hbox = Gtk2::HBox->new (FALSE, 5);
463 my $glabel = Gtk2::Label->new ($label);
464 my $pagei = int (($type[2] - $type[1]) / 10);
465 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
466 my $value = $HPVALUE{$name};
467 $value //= $$hash{$key}[CMDEF];
468 $gentry->set_numeric (TRUE);
469 $gentry->set_value ($value);
470 $$hash{$key}[GUI] = $gentry;
471 $gentry->signal_connect('value-changed' => sub {
473 handle_int_value ($w, $e, \$HPVALUE{$name});
475 set_widget_hint ($gentry, $$hash{$key}[DESC]);
476 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
477 $glabel->set_sensitive ($gentry->sensitive);
478 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
479 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
484 sub new_text_box_for_nchar($$$) {
485 my ($hash, $key, $vhash) = @_;
486 my $name = $$hash{$key}[NAME];
487 my $label = $$hash{$key}[LABEL];
488 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen
489 my $hbox = Gtk2::HBox->new (FALSE, 5);
490 my $glabel = Gtk2::Label->new ($label);
491 my $gentry = Gtk2::Entry->new ();
492 $gentry->set_max_length($type[2]) if defined ($type[2]);
493 $gentry->set_width_chars(int ($type[2]) + 2) if defined ($type[2]);
494 my $value = $$vhash{$name};
495 $value //= $$hash{$key}[CMDEF];
496 $gentry->set_text ($value);
497 $$hash{$key}[GUI] = $gentry;
498 $gentry->signal_connect('key-release-event' => sub {
500 handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1]);
502 set_widget_hint ($gentry, $$hash{$key}[DESC]);
503 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
504 $glabel->set_sensitive ($gentry->sensitive);
505 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
506 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
511 sub new_color_button_for {
512 my ($hash, $key) = @_;
513 my $name = $$hash{$key}[NAME];
514 my $label = $$hash{$key}[LABEL];
516 my $value = $HPVALUE{$name};
517 $value //= $$hash{$key}[CMDEF];
518 my $col = gdk_color_from_str ($value);
519 my $hbox = Gtk2::HBox->new (FALSE, 5);
520 my $glabel = Gtk2::Label->new ($label);
521 my $button = Gtk2::ColorButton->new_with_color ($col);
522 $$hash{$key}[GUI] = $button;
523 $button->set_title ($label);
524 $button->set_relief ('none');
525 $button->signal_connect ('color-set' => sub {
527 handle_color_value ($w, $e, \$HPVALUE{$name});
529 set_widget_hint ($button, $$hash{$key}[DESC]);
530 set_widget_sens ($button, $$hash{$key}[CMVER]);
531 $glabel->set_sensitive ($button->sensitive);
532 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
533 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
538 sub new_selection_box_for {
539 my ($hash, $key) = @_;
540 my $name = $$hash{$key}[NAME];
541 my $label = $$hash{$key}[LABEL];
543 my $hbox = Gtk2::HBox->new (FALSE, 5);
544 my $glabel = Gtk2::Label->new ($label);
545 my $combo = Gtk2::ComboBox->new_text;
546 $$hash{$key}[GUI] = $combo;
547 my @options = split (';', $$hash{$key}[TYPE]);
548 foreach my $opt (@options) {
549 my ($index, $textkey) = split ('=', $opt);
550 $combo->insert_text ($index, $xl::s{$textkey});
552 $combo->signal_connect ('changed' => sub {
554 handle_selection_value ($w, $e, \$HPVALUE{$name});
556 my $value = $HPVALUE{$name};
557 $value //= $$hash{$key}[CMDEF];
558 $combo->set_active ($value);
559 set_widget_hint ($combo, $$hash{$key}[DESC]);
560 set_widget_sens ($combo, $$hash{$key}[CMVER]);
561 $glabel->set_sensitive ($combo->sensitive);
562 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
563 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
568 # more graphic helpers
571 my $hbox = Gtk2::HBox->new (FALSE, 5);
572 $hbox->set_border_width (PAGE_SPC);
573 foreach my $item (@_) {
574 $hbox->pack_start ($item, FALSE, FALSE, 0);
580 my $vbox = Gtk2::VBox->new (FALSE, 5);
581 $vbox->set_border_width (PAGE_SPC);
582 foreach my $item (@_) {
583 $vbox->pack_start ($item, FALSE, FALSE, 0);
588 sub new_vbox_pack_compact {
589 my $vbox = Gtk2::VBox->new (FALSE, 0);
590 $vbox->set_border_width (0);
591 foreach my $item (@_) {
592 $vbox->pack_start ($item, FALSE, FALSE, 0);
597 sub new_subpage_frame {
598 my ($box, $title, $notpacked) = @_;
599 my $frame = Gtk2::Frame->new ($title);
601 return new_vbox_pack ($frame) unless defined ($notpacked);
605 # preference maps and corresponding page creation subs
607 %pr::oth = ( # other preferences
609 'addressbook_use_editaddress_dialog',
610 $xl::s{l_oth_use_dlg},
611 $xl::s{h_oth_use_dlg},
618 'cache_max_mem_usage',
619 $xl::s{l_oth_max_use},
620 $xl::s{h_oth_max_use},
621 'int,0,262144', # 0 Kb - 256 Mb
627 'cache_min_keep_time',
628 $xl::s{l_oth_min_time},
629 $xl::s{h_oth_min_time},
630 'int,0,120', # 0 minutes - 2 hours
636 'use_networkmanager',
637 $xl::s{l_oth_use_netm},
638 $xl::s{h_oth_use_netm},
645 'master_passphrase_pbkdf2_rounds',
646 $xl::s{l_oth_mp_rounds},
647 $xl::s{h_oth_mp_rounds},
655 sub new_other_page() {
656 return new_vbox_pack (
659 new_check_button_for(\%pr::oth, 'use_dlg')),
660 $xl::s{ab_frame}, 'not-packed'),
663 new_text_box_for_int(\%pr::oth, 'max_use'),
664 new_text_box_for_int(\%pr::oth, 'min_time')),
665 $xl::s{mem_frame}, 'not-packed'),
668 new_check_button_for(\%pr::oth, 'use_netm')),
669 $xl::s{netm_frame}, 'not-packed'),
672 new_text_box_for_int(\%pr::oth, 'mp_rounds')),
673 $xl::s{mpass_frame}, 'not-packed')
677 %pr::gui = ( # gui bells and whistles
680 $xl::s{l_gui_b_unread},
681 $xl::s{h_gui_b_unread},
689 $xl::s{l_gui_no_markup},
690 $xl::s{h_gui_no_markup},
697 'enable_dotted_lines',
698 $xl::s{l_gui_dot_lines},
699 $xl::s{h_gui_dot_lines},
707 $xl::s{l_gui_h_scroll},
708 $xl::s{h_gui_h_scroll},
716 $xl::s{l_gui_swp_from},
717 $xl::s{h_gui_swp_from},
724 'folderview_vscrollbar_policy',
725 $xl::s{l_gui_v_scroll},
726 $xl::s{h_gui_v_scroll},
727 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
734 $xl::s{l_gui_from_show},
735 $xl::s{h_gui_from_show},
736 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
742 'stripes_color_offset',
743 $xl::s{l_gui_strip_off},
744 $xl::s{h_gui_strip_off},
745 'int,0,40000', # no idea what this number means
751 'textview_cursor_visible',
752 $xl::s{l_gui_cursor_v},
753 $xl::s{h_gui_cursor_v},
760 'toolbar_detachable',
761 $xl::s{l_gui_toolbar_d},
762 $xl::s{h_gui_toolbar_d},
769 'use_stripes_everywhere',
770 $xl::s{l_gui_strip_all},
771 $xl::s{h_gui_strip_all},
778 'use_stripes_in_summaries',
779 $xl::s{l_gui_strip_sum},
780 $xl::s{h_gui_strip_sum},
788 $xl::s{l_gui_two_line_v},
789 $xl::s{h_gui_two_line_v},
796 'show_compose_margin',
797 $xl::s{l_gui_margin_co},
798 $xl::s{h_gui_margin_co},
805 'msgview_date_format',
806 $xl::s{l_gui_mview_date},
807 $xl::s{h_gui_mview_date},
814 'zero_replacement_char',
815 $xl::s{l_gui_zero_char},
816 $xl::s{h_gui_zero_char},
824 $xl::s{l_gui_type_any},
825 $xl::s{h_gui_type_any},
833 $xl::s{l_gui_next_del},
834 $xl::s{h_gui_next_del},
843 my $gf = Gtk2::VBox->new (FALSE, 5);
844 $gf->set_border_width (PAGE_SPC);
846 my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines');
847 my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d');
848 my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char', \%HPVALUE);
850 $gf->pack_start (new_subpage_frame (
852 new_check_button_for (\%pr::gui, 'strip_all'),
853 new_check_button_for (\%pr::gui, 'strip_sum'),
854 new_text_box_for_int (\%pr::gui, 'strip_off')),
855 $xl::s{stripes_frame}, 'not-packed'),
856 FALSE, FALSE, FRAME_SPC);
857 $gf->pack_start (new_subpage_frame (
859 new_check_button_for (\%pr::gui, 'b_unread'),
860 new_check_button_for (\%pr::gui, 'swp_from'),
861 new_check_button_for (\%pr::gui, 'two_linev'),
862 new_check_button_for (\%pr::gui, 'next_del'),
863 new_selection_box_for (\%pr::gui, 'from_show')),
864 $xl::s{mlist_frame}, 'not-packed'),
865 FALSE, FALSE, FRAME_SPC);
866 $gf->pack_start (new_subpage_frame (
868 new_check_button_for (\%pr::gui, 'cursor_v'),
869 new_check_button_for (\%pr::gui, 'mview_date')),
870 $xl::s{mview_frame}, 'not-packed'),
871 FALSE, FALSE, FRAME_SPC);
872 $gf->pack_start (new_subpage_frame (
874 new_check_button_for (\%pr::gui, 'no_markup'),
875 new_check_button_for (\%pr::gui, 'margin_co'),
876 new_check_button_for (\%pr::gui, 'type_any')),
877 $xl::s{compo_frame}, 'not-packed'),
878 FALSE, FALSE, FRAME_SPC);
879 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
880 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
881 $gf->pack_start (new_subpage_frame (
883 new_check_button_for (\%pr::gui, 'h_scroll'),
884 new_selection_box_for (\%pr::gui, 'v_scroll')),
885 $xl::s{sbar_frame}, 'not-packed'),
886 FALSE, FALSE, FRAME_SPC);
887 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
892 %pr::beh = ( # tweak some behaviour
895 $xl::s{l_beh_hover_t},
896 $xl::s{h_beh_hover_t},
897 'int,100,3000', # 0.1 seconds - 3 seconds
904 $xl::s{l_beh_dangerous},
905 $xl::s{h_beh_dangerous},
912 'respect_flowed_format',
913 $xl::s{l_beh_flowed},
914 $xl::s{h_beh_flowed},
921 'save_parts_readwrite',
922 $xl::s{l_beh_parts_rw},
923 $xl::s{h_beh_parts_rw},
930 'skip_ssl_cert_check',
931 $xl::s{l_beh_skip_ssl},
932 $xl::s{h_beh_skip_ssl},
939 'statusbar_update_step',
940 $xl::s{l_beh_up_step},
941 $xl::s{h_beh_up_step},
942 'int,1,200', # 1 item - 200 items
948 'thread_by_subject_max_age',
949 $xl::s{l_beh_thread_a},
950 $xl::s{h_beh_thread_a},
951 'int,1,30', # 1 day - 30 days
958 $xl::s{l_beh_unsafe_ssl},
959 $xl::s{h_beh_unsafe_ssl},
966 'utf8_instead_of_locale_for_broken_mail',
967 $xl::s{l_beh_use_utf8},
968 $xl::s{h_beh_use_utf8},
976 $xl::s{l_beh_warn_dnd},
977 $xl::s{h_beh_warn_dnd},
984 'outgoing_fallback_to_ascii',
985 $xl::s{l_beh_out_ascii},
986 $xl::s{h_beh_out_ascii},
993 'primary_paste_unselects',
994 $xl::s{l_beh_pp_unsel},
995 $xl::s{h_beh_pp_unsel},
1002 'show_inline_attachments',
1003 $xl::s{l_beh_inline_at},
1004 $xl::s{h_beh_inline_at},
1011 'address_search_wildcard',
1012 $xl::s{l_beh_addr_swc},
1013 $xl::s{h_beh_addr_swc},
1020 'folder_search_wildcard',
1021 $xl::s{l_beh_fold_swc},
1022 $xl::s{h_beh_fold_swc},
1030 sub new_behaviour_page() {
1031 my $bf = Gtk2::VBox->new (FALSE, 5);
1032 $bf->set_border_width (PAGE_SPC);
1034 my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step');
1035 my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a');
1037 $bf->pack_start (new_subpage_frame (
1039 new_text_box_for_int (\%pr::beh, 'hover_t'),
1040 new_check_button_for (\%pr::beh, 'warn_dnd')),
1041 $xl::s{dnd_frame}, 'not-packed'),
1042 FALSE, FALSE, FRAME_SPC);
1043 $bf->pack_start (new_subpage_frame (
1045 new_check_button_for (\%pr::beh, 'skip_ssl'),
1046 new_check_button_for (\%pr::beh, 'unsafe_ssl')),
1047 $xl::s{ssl_frame}, 'not-packed'),
1048 FALSE, FALSE, FRAME_SPC);
1049 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
1050 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
1051 $bf->pack_start (new_subpage_frame (
1053 new_check_button_for (\%pr::beh, 'flowed'),
1054 new_check_button_for (\%pr::beh, 'parts_rw'),
1055 new_check_button_for (\%pr::beh, 'use_utf8'),
1056 new_check_button_for (\%pr::beh, 'dangerous'),
1057 new_check_button_for (\%pr::beh, 'out_ascii'),
1058 new_check_button_for (\%pr::beh, 'pp_unsel'),
1059 new_check_button_for (\%pr::beh, 'inline_at')),
1060 $xl::s{msgs_frame}, 'not-packed'),
1061 FALSE, FALSE, FRAME_SPC);
1062 $bf->pack_start (new_subpage_frame (
1064 new_check_button_for (\%pr::beh, 'addr_swc'),
1065 new_check_button_for (\%pr::beh, 'fold_swc')),
1066 $xl::s{swc_frame}, 'not-packed'),
1067 FALSE, FALSE, FRAME_SPC);
1071 %pr::col = ( # a variety of colours
1074 $xl::s{l_col_emphasis},
1075 $xl::s{h_col_emphasis},
1083 $xl::s{l_col_log_err},
1084 $xl::s{h_col_log_err},
1092 $xl::s{l_col_log_in},
1093 $xl::s{h_col_log_in},
1101 $xl::s{l_col_log_msg},
1102 $xl::s{h_col_log_msg},
1110 $xl::s{l_col_log_out},
1111 $xl::s{h_col_log_out},
1119 $xl::s{l_col_log_warn},
1120 $xl::s{h_col_log_warn},
1128 $xl::s{l_col_diff_add},
1129 $xl::s{h_col_diff_add},
1136 'diff_deleted_color',
1137 $xl::s{l_col_diff_del},
1138 $xl::s{h_col_diff_del},
1146 $xl::s{l_col_diff_hunk},
1147 $xl::s{h_col_diff_hunk},
1155 sub new_colours_page() {
1156 return new_vbox_pack (
1159 new_color_button_for (\%pr::col, 'emphasis')),
1160 $xl::s{msgview_frame}, 'not-packed'),
1163 new_color_button_for (\%pr::col, 'log_err'),
1164 new_color_button_for (\%pr::col, 'log_in'),
1165 new_color_button_for (\%pr::col, 'log_msg'),
1166 new_color_button_for (\%pr::col, 'log_out'),
1167 new_color_button_for (\%pr::col, 'log_warn')),
1168 $xl::s{log_frame}, 'not-packed'),
1171 new_color_button_for (\%pr::col, 'diff_add'),
1172 new_color_button_for (\%pr::col, 'diff_del'),
1173 new_color_button_for (\%pr::col, 'diff_hunk')),
1174 $xl::s{diff_frame}, 'not-packed')
1178 %pr::win = ( # tweak window positions and/or sizes
1183 'int,0,3000', # 0 pixels - 3000 pixels
1192 'int,0,3000', # 0 pixels - 3000 pixels
1201 'int,0,3000', # 0 pixels - 3000 pixels
1210 'int,0,3000', # 0 pixels - 3000 pixels
1216 'mainwin_maximised',
1217 $xl::s{l_win_main_mx},
1218 $xl::s{h_win_main_mx},
1225 'mainwin_fullscreen',
1226 $xl::s{l_win_main_fs},
1227 $xl::s{h_win_main_fs},
1234 'main_messagewin_x',
1237 'int,0,3000', # 0 pixels - 3000 pixels
1243 'main_messagewin_y',
1246 'int,0,3000', # 0 pixels - 3000 pixels
1255 'int,0,3000', # 0 pixels - 3000 pixels
1261 'messagewin_height',
1264 'int,0,3000', # 0 pixels - 3000 pixels
1273 'int,0,3000', # 0 pixels - 3000 pixels
1282 'int,0,3000', # 0 pixels - 3000 pixels
1291 'int,0,3000', # 0 pixels - 3000 pixels
1297 'receivewin_height',
1300 'int,0,3000', # 0 pixels - 3000 pixels
1309 'int,0,3000', # 0 pixels - 3000 pixels
1318 'int,0,3000', # 0 pixels - 3000 pixels
1324 'folderitemwin_width',
1327 'int,0,3000', # 0 pixels - 3000 pixels
1333 'folderitemwin_height',
1336 'int,0,3000', # 0 pixels - 3000 pixels
1342 'folderselwin_width',
1345 'int,0,3000', # 0 pixels - 3000 pixels
1351 'folderselwin_height',
1354 'int,0,3000', # 0 pixels - 3000 pixels
1363 'int,0,3000', # 0 pixels - 3000 pixels
1372 'int,0,3000', # 0 pixels - 3000 pixels
1378 'addressbookwin_width',
1381 'int,0,3000', # 0 pixels - 3000 pixels
1387 'addressbookwin_height',
1390 'int,0,3000', # 0 pixels - 3000 pixels
1396 'addressbookeditpersonwin_width',
1399 'int,0,3000', # 0 pixels - 3000 pixels
1405 'addressbookeditpersonwin_height',
1408 'int,0,3000', # 0 pixels - 3000 pixels
1414 'addressbookeditgroupwin_width',
1417 'int,0,3000', # 0 pixels - 3000 pixels
1423 'addressbookeditgroupwin_height',
1426 'int,0,3000', # 0 pixels - 3000 pixels
1432 'addressaddwin_width',
1435 'int,0,3000', # 0 pixels - 3000 pixels
1441 'addressaddwin_height',
1444 'int,0,3000', # 0 pixels - 3000 pixels
1450 'addressbook_folderselwin_width',
1453 'int,0,3000', # 0 pixels - 3000 pixels
1459 'addressbook_folderselwin_height',
1462 'int,0,3000', # 0 pixels - 3000 pixels
1468 'editaccountwin_width',
1471 'int,0,3000', # 0 pixels - 3000 pixels
1477 'editaccountwin_height',
1480 'int,0,3000', # 0 pixels - 3000 pixels
1486 'accountswin_width',
1489 'int,0,3000', # 0 pixels - 3000 pixels
1495 'accountswin_height',
1498 'int,0,3000', # 0 pixels - 3000 pixels
1504 'filteringwin_width',
1507 'int,0,3000', # 0 pixels - 3000 pixels
1513 'filteringwin_height',
1516 'int,0,3000', # 0 pixels - 3000 pixels
1522 'filteringactionwin_width',
1525 'int,0,3000', # 0 pixels - 3000 pixels
1531 'filteringactionwin_height',
1534 'int,0,3000', # 0 pixels - 3000 pixels
1540 'filtering_debugwin_width',
1543 'int,0,3000', # 0 pixels - 3000 pixels
1549 'filtering_debugwin_height',
1552 'int,0,3000', # 0 pixels - 3000 pixels
1561 'int,0,3000', # 0 pixels - 3000 pixels
1567 'matcherwin_height',
1570 'int,0,3000', # 0 pixels - 3000 pixels
1579 'int,0,3000', # 0 pixels - 3000 pixels
1588 'int,0,3000', # 0 pixels - 3000 pixels
1594 'templateswin_width',
1597 'int,0,3000', # 0 pixels - 3000 pixels
1603 'templateswin_height',
1606 'int,0,3000', # 0 pixels - 3000 pixels
1615 'int,0,3000', # 0 pixels - 3000 pixels
1621 'actionswin_height',
1624 'int,0,3000', # 0 pixels - 3000 pixels
1633 'int,0,3000', # 0 pixels - 3000 pixels
1642 'int,0,3000', # 0 pixels - 3000 pixels
1651 'int,0,3000', # 0 pixels - 3000 pixels
1657 'pluginswin_height',
1660 'int,0,3000', # 0 pixels - 3000 pixels
1669 'int,0,3000', # 0 pixels - 3000 pixels
1678 'int,0,3000', # 0 pixels - 3000 pixels
1684 'print_previewwin_width',
1687 'int,0,3000', # 0 pixels - 3000 pixels
1693 'print_previewwin_height',
1696 'int,0,3000', # 0 pixels - 3000 pixels
1703 sub new_winpos_subpage_main() {
1704 return new_subpage_frame (
1705 new_vbox_pack_compact (
1707 new_text_box_for_int (\%pr::win, 'main_x'),
1708 new_text_box_for_int (\%pr::win, 'main_y')),
1710 new_text_box_for_int (\%pr::win, 'main_w'),
1711 new_text_box_for_int (\%pr::win, 'main_h')),
1713 new_check_button_for (\%pr::win, 'main_fs'),
1714 new_check_button_for (\%pr::win, 'main_mx'))),
1719 sub new_winpos_subpage_msgs() {
1720 return new_subpage_frame (
1721 new_vbox_pack_compact (
1723 new_text_box_for_int (\%pr::win, 'msgs_x'),
1724 new_text_box_for_int (\%pr::win, 'msgs_y')),
1726 new_text_box_for_int (\%pr::win, 'msgs_w'),
1727 new_text_box_for_int (\%pr::win, 'msgs_h'))),
1732 sub new_winpos_subpage_sendrecv() {
1733 return new_vbox_pack (
1736 new_text_box_for_int (\%pr::win, 'send_w'),
1737 new_text_box_for_int (\%pr::win, 'send_h')),
1738 _('Send window'), 'not-packed'),
1741 new_text_box_for_int (\%pr::win, 'recv_w'),
1742 new_text_box_for_int (\%pr::win, 'recv_h')),
1743 _('Receive window'), 'not-packed')
1747 sub new_winpos_subpage_fold() {
1748 return new_vbox_pack (
1750 new_vbox_pack_compact (
1752 new_text_box_for_int (\%pr::win, 'fold_x'),
1753 new_text_box_for_int (\%pr::win, 'fold_y')),
1755 new_text_box_for_int (\%pr::win, 'fold_w'),
1756 new_text_box_for_int (\%pr::win, 'fold_h'))),
1757 _('Folder window'), 'not-packed'),
1760 new_text_box_for_int (\%pr::win, 'fsel_w'),
1761 new_text_box_for_int (\%pr::win, 'fsel_h')),
1762 _('Folder selection window'), 'not-packed')
1766 sub new_winpos_subpage_addrbook() {
1767 return new_vbox_pack (
1770 new_text_box_for_int (\%pr::win, 'addr_w'),
1771 new_text_box_for_int (\%pr::win, 'addr_h')),
1772 _('Addressbook main window'), 'not-packed'),
1775 new_text_box_for_int (\%pr::win, 'adep_w'),
1776 new_text_box_for_int (\%pr::win, 'adep_h')),
1777 _('Edit person window'), 'not-packed'),
1780 new_text_box_for_int (\%pr::win, 'adeg_w'),
1781 new_text_box_for_int (\%pr::win, 'adeg_h')),
1782 _('Edit group window'), 'not-packed'),
1785 new_text_box_for_int (\%pr::win, 'adda_w'),
1786 new_text_box_for_int (\%pr::win, 'adda_h')),
1787 _('Add address window'), 'not-packed'),
1790 new_text_box_for_int (\%pr::win, 'addf_w'),
1791 new_text_box_for_int (\%pr::win, 'addf_h')),
1792 _('Folder select window'), 'not-packed')
1796 sub new_winpos_subpage_accounts() {
1797 return new_vbox_pack (
1800 new_text_box_for_int (\%pr::win, 'acco_w'),
1801 new_text_box_for_int (\%pr::win, 'acco_h')),
1802 _('Accounts window'), 'not-packed'),
1805 new_text_box_for_int (\%pr::win, 'acce_w'),
1806 new_text_box_for_int (\%pr::win, 'acce_h')),
1807 _('Edit account window'), 'not-packed')
1811 sub new_winpos_subpage_filtering() {
1812 return new_vbox_pack (
1815 new_text_box_for_int (\%pr::win, 'filt_w'),
1816 new_text_box_for_int (\%pr::win, 'filt_h')),
1817 _('Filtering window'), 'not-packed'),
1820 new_text_box_for_int (\%pr::win, 'fila_w'),
1821 new_text_box_for_int (\%pr::win, 'fila_h')),
1822 _('Filtering actions window'), 'not-packed'),
1825 new_text_box_for_int (\%pr::win, 'fild_w'),
1826 new_text_box_for_int (\%pr::win, 'fild_h')),
1827 _('Filtering debug window'), 'not-packed'),
1830 new_text_box_for_int (\%pr::win, 'matc_w'),
1831 new_text_box_for_int (\%pr::win, 'matc_h')),
1832 _('Matcher window'), 'not-packed')
1836 sub new_winpos_subpage_prefs() {
1837 return new_vbox_pack (
1840 new_text_box_for_int (\%pr::win, 'pref_w'),
1841 new_text_box_for_int (\%pr::win, 'pref_h')),
1842 _('Preferences window'), 'not-packed'),
1845 new_text_box_for_int (\%pr::win, 'temp_w'),
1846 new_text_box_for_int (\%pr::win, 'temp_h')),
1847 _('Templates window'), 'not-packed'),
1850 new_text_box_for_int (\%pr::win, 'acti_w'),
1851 new_text_box_for_int (\%pr::win, 'acti_h')),
1852 _('Actions window'), 'not-packed'),
1855 new_text_box_for_int (\%pr::win, 'tags_w'),
1856 new_text_box_for_int (\%pr::win, 'tags_h')),
1857 _('Tags window'), 'not-packed'),
1860 new_text_box_for_int (\%pr::win, 'plug_w'),
1861 new_text_box_for_int (\%pr::win, 'plug_h')),
1862 _('Plugins window'), 'not-packed')
1866 sub new_winpos_subpage_misc() {
1867 return new_vbox_pack (
1870 new_text_box_for_int (\%pr::win, 'logw_w'),
1871 new_text_box_for_int (\%pr::win, 'logw_h')),
1872 _('Log window'), 'not-packed'),
1875 new_text_box_for_int (\%pr::win, 'prin_w'),
1876 new_text_box_for_int (\%pr::win, 'prin_h')),
1877 _('Print preview window'), 'not-packed'),
1880 new_text_box_for_int (\%pr::win, 'sour_w'),
1881 new_text_box_for_int (\%pr::win, 'sour_h')),
1882 _('View source window'), 'not-packed')
1886 sub new_winpos_page() {
1887 my $winbook = Gtk2::Notebook->new;
1888 $winbook->set_tab_pos ('right');
1889 $winbook->append_page (new_winpos_subpage_main, _('Main'));
1890 $winbook->append_page (new_winpos_subpage_msgs, _('Message'));
1891 $winbook->append_page (new_winpos_subpage_sendrecv, _('Send/Receive'));
1892 $winbook->append_page (new_winpos_subpage_fold, _('Folder'));
1893 $winbook->append_page (new_winpos_subpage_addrbook, _('Addressbook'));
1894 $winbook->append_page (new_winpos_subpage_accounts, _('Accounts'));
1895 $winbook->append_page (new_winpos_subpage_filtering, _('Filtering'));
1896 $winbook->append_page (new_winpos_subpage_prefs, _('Preferences'));
1897 $winbook->append_page (new_winpos_subpage_misc, _('Other'));
1902 sub print_version() {
1903 print $xl::s{about_title} . "\n";
1904 print $xl::s{about_version} . " $VERSION\n";
1905 print "Perl-GLib " . $Glib::VERSION;
1906 # version info stuff appeared in 1.040
1907 if ($Glib::VERSION >= 1.040) {
1908 print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
1909 . _(", running with ") . join(".", &Glib::major_version,
1910 &Glib::minor_version, &Glib::micro_version);
1913 print "Perl-GTK2 " . $Gtk2::VERSION;
1914 if ($Gtk2::VERSION >= 1.040) {
1915 print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
1916 . _(", running with ") . join(".", &Gtk2::major_version,
1917 &Gtk2::minor_version, &Gtk2::micro_version);
1920 my $clawsver = ($CLAWSV eq "") ?
1921 _("was not found!") :
1922 (_("returned version ") . $CLAWSV);
1923 print "Claws Mail " . $clawsver . "\n";
1926 # the command line help
1928 my $line = '-' x length ($xl::s{about_title}) . "\n";
1930 print $xl::s{about_title} . "\n";
1932 print _("Syntax:\n");
1933 print _(" clawsker [options]\n");
1934 print _("Options:\n");
1935 print _(" -h|--help Prints this help screen.\n");
1936 print _(" -v|--version Prints version infos.\n");
1937 print _(" -b|--verbose More messages on standard output.\n");
1938 print _(" -a|--alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
1939 print _(" -c|--clawsrc <file> Uses <file> as full resource name.\n");
1942 sub parse_command_line {
1944 $CLAWSV = get_claws_version ();
1946 GetOptions('h|help' => sub { print_help (); $cont = FALSE },
1947 'v|version' => sub { print_version (); $cont = FALSE },
1948 'b|verbose' => sub { $VERBOSE = TRUE },
1949 'u|use-claws-version=s' => \&opt_use_claws_version,
1950 'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
1951 'r|clawsrc=s' => \&opt_clawsrc)
1952 or die _("try -h or --help for syntax.\n");
1955 my $msg = _("Error in options: {msg}\n", msg => $@);
1956 if (defined $ENV{'DISPLAY'} and $ENV{'DISPLAY'} ne '') {
1957 eval { Gtk2->init };
1958 error_dialog ($msg) unless $@;
1965 sub opt_use_claws_version {
1966 my ($name, $value) = @_;
1967 die _("Error: {opt} requires a dotted numeric value argument\n", opt => $name)
1968 unless ($value =~ /^[\d\.]+$/);
1972 sub opt_alternate_config_dir {
1973 my ($name, $value) = @_;
1974 die _("Error: '{dir}' is not a directory or does not exist\n", dir => $value)
1976 $CONFIGDIR = $value;
1977 $CONFIGDIR .= "/" unless ($CONFIGDIR =~ /.*\/$/);
1978 $ALTCONFIGDIR = TRUE;
1982 my ($name, $value) = @_;
1983 die _("Error: '{value}' is not a file or does not exist\n", value => $value)
1985 set_rc_filename ($value);
1988 # update the hidden preferences status from loaded values
1989 sub init_hidden_preferences {
1990 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
1991 foreach my $key (keys %$hash) {
1992 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
1998 # load current status from disc
1999 sub load_preferences {
2000 my $rc = get_rc_filename ();
2001 log_message ("Loading preferences from $rc\n");
2002 return FALSE unless check_rc_file ($rc);
2003 return FALSE unless check_claws_not_running ();
2007 if (/^([8a-z_]+)=(.*)$/) {
2008 $PREFS{$1} = decode('UTF-8', $2);
2015 # save current preferences to disc
2016 sub save_preferences {
2017 my $rc = get_rc_filename ();
2018 log_message ("Saving preferences to $rc\n");
2019 return FALSE unless check_rc_file ($rc);
2020 return FALSE unless check_claws_not_running ();
2021 my $rcbak = "$rc.backup";
2022 rename ($rc, $rcbak);
2024 open (RCB, "<$rcbak");
2027 if (/^([8a-z_]+)=(.*)$/) {
2028 if (defined($HPVALUE{$1})) {
2029 print RCF $1 . "=" . $HPVALUE{$1} . "\n";
2032 print RCF $_ . "\n";
2036 print RCF $_ . "\n";
2046 my $nb = Gtk2::Notebook->new;
2048 $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
2049 $nb->append_page (new_colours_page (), $xl::s{tab_colours});
2050 $nb->append_page (new_gui_page (), $xl::s{tab_gui});
2051 $nb->append_page (new_other_page (), $xl::s{tab_other});
2052 $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
2057 # create an about dialog
2058 sub new_about_dialog {
2060 my $title = $xl::s{about_title};
2061 my $lic = $xl::s{about_license};
2062 my $vers = $xl::s{about_version} . " $VERSION";
2064 "This program is free software: you can redistribute it and/or modify
2065 it under the terms of the GNU General Public License as published by
2066 the Free Software Foundation, either version 3 of the License, or
2067 (at your option) any later version.
2069 This program is distributed in the hope that it will be useful,
2070 but WITHOUT ANY WARRANTY; without even the implied warranty of
2071 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2072 GNU General Public License for more details.
2074 You should have received a copy of the GNU General Public License
2075 along with this program. If not, see <http://www.gnu.org/licenses/>.";
2076 my $year = "2007-2016";
2077 my $holder = "Ricardo Mones <ricardo\@mones.org>";
2078 my $url = "http://www.claws-mail.org/clawsker.php";
2080 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
2081 [qw/modal destroy-with-parent/],
2083 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
2084 . "<span size=\"large\">$vers</span>\n\n"
2085 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2086 . "<span>Copyright $year by $holder</span>\n\n"
2087 . "<span size=\"large\">$lic</span>\n\n"
2088 . "<span size=\"small\">$license</span>");
2089 $dialog->set_title ($xl::s{about});
2094 # create buttons box
2095 sub new_button_box {
2096 my ($parent, $adlg) = @_;
2097 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2098 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2099 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2100 # disable button until is really implemented
2101 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2102 my $hbox = Gtk2::HBox->new (FALSE, 5);
2104 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2105 $b_apply->signal_connect (clicked => sub { save_preferences ($parent) });
2106 # $b_undo->signal_connect (clicked => sub { undo_current_changes });
2107 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2109 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2110 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2111 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2112 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2118 my $dir = $DATADIR . '/icons/hicolor';
2120 join ('/', ($dir, , $_ . 'x' . $_, 'apps', $NAME . '.png'))
2125 $icon = Gtk2::Gdk::Pixbuf->new_from_file($_) if (-f $_);
2126 push @icons, $icon if ($icon);
2132 exit unless parse_command_line ();
2134 $main_window = Gtk2::Window->new ('toplevel');
2135 exit unless load_preferences ();
2136 exit unless init_hidden_preferences ();
2138 my $box = Gtk2::VBox->new (FALSE, 5);
2139 $box->set_border_width(3);
2140 my $about = new_about_dialog ();
2141 $box->pack_start (new_notebook (), FALSE, FALSE, 0);
2142 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
2143 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2144 $main_window->set_title ($xl::s{win_title});
2145 $main_window->set_icon_list (get_app_icons ());
2146 $main_window->add ($box);
2147 $main_window->show_all;