3 # Clawsker :: A Claws Mail Tweaker
4 # Copyright 2007-2015 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)";
19 use Glib qw(TRUE FALSE);
21 use POSIX qw(setlocale);
24 use Digest::MD5 qw(md5_hex);
27 my $NAME = 'clawsker';
28 my $PREFIX = '@PREFIX@';
29 my $LIBDIR = '@LIBDIR@';
30 my $VERSION = '@VERSION@';
33 my $main_window = undef;
35 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
36 $locale = "C" unless defined($locale);
37 setlocale (LC_ALL, $locale);
38 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
41 my $SHOWHINTS = FALSE;
42 $SHOWHINTS = TRUE if ($Gtk2::VERSION >= 1.040 and Gtk2->CHECK_VERSION (2, 12, 0));
47 my $xla = gettext ($str);
48 if (scalar(keys(%par)) > 0) {
49 foreach my $key (keys %par) {
50 $xla =~ s/\{$key\}/$par{$key}/g;
53 return decode_utf8($xla);
58 win_title => _('Claws Mail Hidden Preferences'),
59 about => _('About...'),
60 about_title => _('Clawsker :: A Claws Mail Tweaker'),
61 about_license => _('License:'),
62 about_version => _('Version:'),
64 tab_colours => _('Colours'),
65 tab_behaviour => _('Behaviour'),
67 tab_other => _('Other'),
68 tab_winpos => _('Windows'),
70 ab_frame => _('Addressbook'),
71 mem_frame => _('Memory'),
72 msgview_frame => _('Message View'),
73 log_frame => _('Log window'),
74 dnd_frame => _('Drag \'n\' drop'),
75 ssl_frame => _('Secure Sockets Layer'),
76 msgs_frame => _('Messages'),
77 swc_frame => _('Completion'),
78 stripes_frame => _('Coloured stripes'),
79 sbar_frame => _('Scroll bars'),
80 mlist_frame => _('Message List'),
81 mview_frame => _('Message View'),
82 compo_frame => _('Compose window'),
83 netm_frame => _('NetworkManager'),
84 diff_frame => _('Viewing patches'),
86 l_oth_use_dlg => _('Use detached address book edit dialogue'),
87 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.'),
88 l_oth_max_use => _('Maximum memory for message cache (kB)'),
89 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
90 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
91 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.'),
92 l_oth_use_netm => _('Use NetworkManager'),
93 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
95 l_gui_b_unread => _('Show unread messages with bold font'),
96 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
97 l_gui_no_markup => _('Don\'t use markup'),
98 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
99 l_gui_dot_lines => _('Use dotted lines in tree view components'),
100 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.'),
101 l_gui_h_scroll => _('Enable horizontal scrollbar'),
102 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
103 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
104 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.'),
105 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
106 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
107 l_gui_v_scroll_show => _('Show always'),
108 l_gui_v_scroll_auto => _('Automatic'),
109 l_gui_v_scroll_hide => _('Hide always'),
110 l_gui_from_show => _('From column displays'),
111 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both.'),
112 l_gui_from_show_name => _('Name only'),
113 l_gui_from_show_addr => _('Address only'),
114 l_gui_from_show_both => _('Both name and address'),
115 l_gui_strip_off => _('Coloured lines contrast'),
116 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.'),
117 l_gui_cursor_v => _('Show cursor'),
118 h_gui_cursor_v => _('Display the cursor in the Message View.'),
119 l_gui_toolbar_d => _('Detachable toolbars'),
120 h_gui_toolbar_d => _('Show handles in the toolbars.'),
121 l_gui_strip_all => _('Use stripes in all tree view components'),
122 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
123 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
124 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
125 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
126 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
127 l_gui_margin_co => _('Show margin'),
128 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
129 l_gui_mview_date => _('Don\'t display localized date'),
130 h_gui_mview_date => _('Toggles localization of date format in Message View.'),
131 l_gui_zero_char => _('Zero replacement character'),
132 h_gui_zero_char => _('Replaces \'0\' with the given character in Folder List.'),
133 l_gui_type_any => _('Editable headers'),
134 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.'),
135 l_gui_next_del => _('Select next message on delete'),
136 h_gui_next_del => _('When deleting a message, toggles between selecting the next one (newer message) or the previous one (older message).'),
138 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
139 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.'),
140 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
141 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
142 l_beh_flowed => _('Respect format=flowed in messages'),
143 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.'),
144 l_beh_parts_rw => _('Allow writable temporary files'),
145 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
146 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
147 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
148 l_beh_up_step => _('Progress bar update step (items)'),
149 h_beh_up_step => _('Update stepping in progress bars.'),
150 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
151 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
152 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
153 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
154 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
155 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
156 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
157 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
158 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
159 h_beh_out_ascii => _('If content allows, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is enforced always.'),
160 l_beh_pp_unsel => _('Primary paste unselects selection'),
161 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
162 l_beh_inline_at => _('Show inline attachments'),
163 h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view.'),
164 l_beh_addr_swc => _('Address search in compose window matches any'),
165 h_beh_addr_swc => _('On Tab-key completion, address text will match any part of the string or only the from the start.'),
166 l_beh_fold_swc => _('Folder search in folder selector matches any'),
167 h_beh_fold_swc => _('On folder name completion text will match any part of the string or only from the start.'),
169 l_col_emphasis => _('X-Mailer header'),
170 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
171 l_col_log_err => _('Error messages'),
172 h_col_log_err => _('Colour for error messages in log window.'),
173 l_col_log_in => _('Server messages'),
174 h_col_log_in => _('Colour for messages received from servers in log window.'),
175 l_col_log_msg => _('Standard messages'),
176 h_col_log_msg => _('Colour for messages in log window.'),
177 l_col_log_out => _('Client messages'),
178 h_col_log_out => _('Colour for messages sent to servers in log window.'),
179 l_col_log_warn => _('Warnings'),
180 h_col_log_warn => _('Colour for warning messages in log window.'),
182 l_col_diff_add => _('Added lines'),
183 h_col_diff_add => _('Colour for added lines in patches.'),
184 l_col_diff_del => _('Deleted lines'),
185 h_col_diff_del => _('Colour for deleted lines in patches.'),
186 l_col_diff_hunk => _('Hunk lines'),
187 h_col_diff_hunk => _('Color for hunk headers in patches.'),
189 l_win_x => _('X position'),
190 h_win_x => _('X coordinate for window\'s top-left corner.'),
191 l_win_y => _('Y position'),
192 h_win_y => _('Y coordinate for window\'s top-left corner.'),
193 l_win_w => _('Width'),
194 h_win_w => _('Window\'s width in pixels.'),
195 l_win_h => _('Height'),
196 h_win_h => _('Window\'s height in pixels.'),
198 l_win_main_mx => _('Maximized'),
199 h_win_main_mx => _('Changes window maximized status.'),
200 l_win_main_fs => _('Full-screen'),
201 h_win_main_fs => _('Changes full screen status.'),
203 e_error => _('Error: '),
204 e_noclawsrc => _('resource file for Claws Mail was not found.'),
205 e_running => _('seems Claws Mail is currently running, close it first.'),
208 # all preferences read by load_preferences
210 # values of all preferences handled by clawsker
212 # default config dir and file name
213 my $ALTCONFIGDIR = FALSE;
214 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
215 my $CONFIGRC = 'clawsrc';
217 # index constants for preference arrays
218 use constant NAME => 0; # the name on the rc file
219 use constant LABEL => 1; # the label on the GUI
220 use constant DESC => 2; # the description for the hint/help
221 use constant TYPE => 3; # data type: bool, int, float, string, color
222 use constant CMVER => 4; # lowest[,highest] Claws Mail version(s) the feature exists
223 use constant CMDEF => 5; # default value for the preference in Claws Mail
224 use constant GUI => 6; # GUI element
226 # constants for GUI spacing
227 use constant HBOX_SPC => 5;
228 use constant FRAME_SPC => 2;
229 use constant PAGE_SPC => 5;
233 sub version_greater_or_equal {
234 my ($version, $refvers) = @_;
235 my @version = split (/\./, $version);
236 my @refvers = split (/\./, $refvers);
237 while ($#version < $#refvers) {
238 push (@version, '0');
241 while (($idx <= $#refvers)
242 and (int ($version[$idx]) == int ($refvers[$idx]))) {
245 return TRUE if (($idx > $#refvers)
246 or (int ($version[$idx]) >= int ($refvers[$idx])));
250 sub get_claws_version {
255 foreach my $bin (@cmbin) {
260 return "" unless ($_); # not installed
263 my @fver = split (/ /);
264 die "Invalid version string" unless ($fver[2] eq "version");
265 my @ver = split (/\./, $fver[3]);
268 if ($ver[2] =~ /(\d+)cvs(\d+)/) {
277 # data handlers and auxiliar functions
279 sub handle_bool_value {
280 my ($widget, $event, $dataref) = @_;
281 $$dataref = ($widget->get_active ())? '1': '0';
284 sub handle_int_value {
285 my ($widget, $event, $dataref) = @_;
286 $_ = $widget->get_text ();
291 $widget->set_text ($_);
294 $widget->set_text ($$dataref);
298 sub handle_string_value {
299 my ($widget, $event, $dataref) = @_;
300 $$dataref = $widget->get_text ();
303 sub handle_nchar_value {
304 my ($widget, $event, $dataref, $minlen) = @_;
305 $_ = substr ($widget->get_text (), 0, $minlen);
306 $widget->set_text ($_);
310 sub gdk_color_from_str {
312 my ($rr, $gg, $bb) = (0, 0 ,0);
314 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
319 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
323 sub str_from_gdk_color {
325 my $rr = $color->red / 256;
326 my $gg = $color->green / 256;
327 my $bb = $color->blue / 256;
328 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
332 sub handle_color_value {
333 my ($widget, $event, $dataref) = @_;
334 my $newcol = $widget->get_color;
335 $$dataref = str_from_gdk_color ($newcol);
338 sub handle_selection_value {
339 my ($widget, $event, $dataref) = @_;
340 $$dataref = $widget->get_active;
343 sub get_rc_filename {
344 return $CONFIGDIR . $CONFIGRC;
347 sub set_rc_filename {
349 my @parts = split ('/', $fullname);
350 $CONFIGRC = $parts[$#parts];
351 $parts[$#parts] = '';
352 $CONFIGDIR = join ('/', @parts);
356 my ($mesg, $fatal) = @_;
357 if (defined($fatal) && $fatal eq 'die') {
358 die "$NAME: $mesg\n";
361 print "$NAME: $mesg\n";
367 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
368 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
369 $errordlg->set_title (_('Clawsker error'));
374 sub claws_is_running {
375 my $emsg = "$xl::s{e_error}$xl::s{e_running}";
377 error_dialog ($emsg);
381 sub check_claws_not_running {
382 my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
383 $tmpdir = '/tmp' if ($tmpdir eq '');
384 my $socket = (not $ALTCONFIGDIR)? $tmpdir: $CONFIGDIR;
385 $socket .= "/claws-mail-$<";
386 -S $socket and return claws_is_running ();
388 my $lockdir = "$tmpdir/claws-mail-$<";
392 $socket = "$lockdir/" . md5_hex ($_);
393 -S $socket and return claws_is_running ();
400 (defined($rcfile) && -f $rcfile) or do {
401 my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
403 error_dialog ($emsg);
409 sub set_widget_hint {
411 my ($wdgt, $hint) = @_;
412 $wdgt->set_tooltip_text ($hint);
413 $wdgt->set_has_tooltip (TRUE);
417 sub set_widget_sens {
418 my ($wdgt, $versions) = @_;
419 my @ver = split(/,/, $versions);
421 $wdgt->set_sensitive (
422 version_greater_or_equal ($CLAWSV, $ver[0])
423 and version_greater_or_equal ($ver[1], $CLAWSV)
426 $wdgt->set_sensitive (version_greater_or_equal ($CLAWSV, $ver[0]));
430 # graphic element creation
432 sub new_check_button_for {
433 my ($hash, $key) = @_;
434 my $name = $$hash{$key}[NAME];
435 my $label = $$hash{$key}[LABEL];
437 my $hbox = Gtk2::HBox->new (FALSE, 5);
438 my $cb = Gtk2::CheckButton->new ($label);
439 $$hash{$key}[GUI] = $cb;
440 if (defined ($HPVALUE{$name})) {
441 $cb->set_active ($HPVALUE{$name} eq '1');
443 $cb->signal_connect (clicked => sub {
445 handle_bool_value ($w, $e, \$HPVALUE{$name});
447 set_widget_hint ($cb, $$hash{$key}[DESC]);
448 set_widget_sens ($cb, $$hash{$key}[CMVER]);
449 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
454 sub new_text_box_for_int {
455 my ($hash, $key) = @_;
456 my $name = $$hash{$key}[NAME];
457 my $label = $$hash{$key}[LABEL];
458 my @type = split (/,/, $$hash{$key}[TYPE]);
459 push (@type, 0), push (@type, 10000) unless ($#type > 0);
461 my $hbox = Gtk2::HBox->new (FALSE, 5);
462 my $glabel = Gtk2::Label->new ($label);
463 my $pagei = int (($type[2] - $type[1]) / 10);
464 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
465 $gentry->set_numeric (TRUE);
466 $gentry->set_value ($HPVALUE{$name});
467 $$hash{$key}[GUI] = $gentry;
468 $gentry->signal_connect('value-changed' => sub {
470 handle_int_value ($w, $e, \$HPVALUE{$name});
472 set_widget_hint ($gentry, $$hash{$key}[DESC]);
473 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
474 $glabel->set_sensitive ($gentry->sensitive);
475 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
476 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
481 sub new_text_box_for_nchar {
482 my ($hash, $key) = @_;
483 my $name = $$hash{$key}[NAME];
484 my $label = $$hash{$key}[LABEL];
485 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen
486 my $hbox = Gtk2::HBox->new (FALSE, 5);
487 my $glabel = Gtk2::Label->new ($label);
488 my $gentry = Gtk2::Entry->new ();
489 $gentry->set_max_length($type[2]) if defined ($type[2]);
490 $gentry->set_width_chars(int ($type[2]) + 2) if defined ($type[2]);
491 $gentry->set_text ($HPVALUE{$name});
492 $$hash{$key}[GUI] = $gentry;
493 $gentry->signal_connect('key-release-event' => sub {
495 handle_nchar_value ($w, $e, \$HPVALUE{$name}, $type[1]);
497 set_widget_hint ($gentry, $$hash{$key}[DESC]);
498 set_widget_sens ($gentry, $$hash{$key}[CMVER]);
499 $glabel->set_sensitive ($gentry->sensitive);
500 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
501 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
506 sub new_color_button_for {
507 my ($hash, $key) = @_;
508 my $name = $$hash{$key}[NAME];
509 my $label = $$hash{$key}[LABEL];
511 my $col = gdk_color_from_str ($HPVALUE{$name});
512 my $hbox = Gtk2::HBox->new (FALSE, 5);
513 my $glabel = Gtk2::Label->new ($label);
514 my $button = Gtk2::ColorButton->new_with_color ($col);
515 $$hash{$key}[GUI] = $button;
516 $button->set_title ($label);
517 $button->set_relief ('none');
518 $button->signal_connect ('color-set' => sub {
520 handle_color_value ($w, $e, \$HPVALUE{$name});
522 set_widget_hint ($button, $$hash{$key}[DESC]);
523 set_widget_sens ($button, $$hash{$key}[CMVER]);
524 $glabel->set_sensitive ($button->sensitive);
525 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
526 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
531 sub new_selection_box_for {
532 my ($hash, $key) = @_;
533 my $name = $$hash{$key}[NAME];
534 my $label = $$hash{$key}[LABEL];
536 my $hbox = Gtk2::HBox->new (FALSE, 5);
537 my $glabel = Gtk2::Label->new ($label);
538 my $combo = Gtk2::ComboBox->new_text;
539 $$hash{$key}[GUI] = $combo;
540 my @options = split (';', $$hash{$key}[TYPE]);
541 foreach my $opt (@options) {
542 my ($index, $textkey) = split ('=', $opt);
543 $combo->insert_text ($index, $xl::s{$textkey});
545 $combo->signal_connect ('changed' => sub {
547 handle_selection_value ($w, $e, \$HPVALUE{$name});
549 $combo->set_active ($HPVALUE{$name});
550 set_widget_hint ($combo, $$hash{$key}[DESC]);
551 set_widget_sens ($combo, $$hash{$key}[CMVER]);
552 $glabel->set_sensitive ($combo->sensitive);
553 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
554 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
559 # more graphic helpers
562 my $hbox = Gtk2::HBox->new (FALSE, 5);
563 $hbox->set_border_width (PAGE_SPC);
564 foreach my $item (@_) {
565 $hbox->pack_start ($item, FALSE, FALSE, 0);
571 my $vbox = Gtk2::VBox->new (FALSE, 5);
572 $vbox->set_border_width (PAGE_SPC);
573 foreach my $item (@_) {
574 $vbox->pack_start ($item, FALSE, FALSE, 0);
579 sub new_vbox_pack_compact {
580 my $vbox = Gtk2::VBox->new (FALSE, 0);
581 $vbox->set_border_width (0);
582 foreach my $item (@_) {
583 $vbox->pack_start ($item, FALSE, FALSE, 0);
588 sub new_subpage_frame {
589 my ($box, $title, $notpacked) = @_;
590 my $frame = Gtk2::Frame->new ($title);
592 return new_vbox_pack ($frame) unless defined ($notpacked);
596 # preference maps and corresponding page creation subs
598 %pr::oth = ( # other preferences
600 'addressbook_use_editaddress_dialog',
601 $xl::s{l_oth_use_dlg},
602 $xl::s{h_oth_use_dlg},
609 'cache_max_mem_usage',
610 $xl::s{l_oth_max_use},
611 $xl::s{h_oth_max_use},
612 'int,0,262144', # 0 Kb - 256 Mb
618 'cache_min_keep_time',
619 $xl::s{l_oth_min_time},
620 $xl::s{h_oth_min_time},
621 'int,0,120', # 0 minutes - 2 hours
627 'use_networkmanager',
628 $xl::s{l_oth_use_netm},
629 $xl::s{h_oth_use_netm},
637 sub new_other_page() {
638 return new_vbox_pack (
641 new_check_button_for(\%pr::oth, 'use_dlg')),
642 $xl::s{ab_frame}, 'not-packed'),
645 new_text_box_for_int(\%pr::oth, 'max_use'),
646 new_text_box_for_int(\%pr::oth, 'min_time')),
647 $xl::s{mem_frame}, 'not-packed'),
650 new_check_button_for(\%pr::oth, 'use_netm')),
651 $xl::s{netm_frame}, 'not-packed')
655 %pr::gui = ( # gui bells and whistles
658 $xl::s{l_gui_b_unread},
659 $xl::s{h_gui_b_unread},
667 $xl::s{l_gui_no_markup},
668 $xl::s{h_gui_no_markup},
675 'enable_dotted_lines',
676 $xl::s{l_gui_dot_lines},
677 $xl::s{h_gui_dot_lines},
685 $xl::s{l_gui_h_scroll},
686 $xl::s{h_gui_h_scroll},
694 $xl::s{l_gui_swp_from},
695 $xl::s{h_gui_swp_from},
702 'folderview_vscrollbar_policy',
703 $xl::s{l_gui_v_scroll},
704 $xl::s{h_gui_v_scroll},
705 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
712 $xl::s{l_gui_from_show},
713 $xl::s{h_gui_from_show},
714 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
720 'stripes_color_offset',
721 $xl::s{l_gui_strip_off},
722 $xl::s{h_gui_strip_off},
723 'int,0,40000', # no idea what this number means
729 'textview_cursor_visible',
730 $xl::s{l_gui_cursor_v},
731 $xl::s{h_gui_cursor_v},
738 'toolbar_detachable',
739 $xl::s{l_gui_toolbar_d},
740 $xl::s{h_gui_toolbar_d},
747 'use_stripes_everywhere',
748 $xl::s{l_gui_strip_all},
749 $xl::s{h_gui_strip_all},
756 'use_stripes_in_summaries',
757 $xl::s{l_gui_strip_sum},
758 $xl::s{h_gui_strip_sum},
766 $xl::s{l_gui_two_line_v},
767 $xl::s{h_gui_two_line_v},
774 'show_compose_margin',
775 $xl::s{l_gui_margin_co},
776 $xl::s{h_gui_margin_co},
783 'msgview_date_format',
784 $xl::s{l_gui_mview_date},
785 $xl::s{h_gui_mview_date},
792 'zero_replacement_char',
793 $xl::s{l_gui_zero_char},
794 $xl::s{h_gui_zero_char},
802 $xl::s{l_gui_type_any},
803 $xl::s{h_gui_type_any},
811 $xl::s{l_gui_next_del},
812 $xl::s{h_gui_next_del},
821 my $gf = Gtk2::VBox->new (FALSE, 5);
822 $gf->set_border_width (PAGE_SPC);
824 my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines');
825 my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d');
826 my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char');
828 $gf->pack_start (new_subpage_frame (
830 new_check_button_for (\%pr::gui, 'strip_all'),
831 new_check_button_for (\%pr::gui, 'strip_sum'),
832 new_text_box_for_int (\%pr::gui, 'strip_off')),
833 $xl::s{stripes_frame}, 'not-packed'),
834 FALSE, FALSE, FRAME_SPC);
835 $gf->pack_start (new_subpage_frame (
837 new_check_button_for (\%pr::gui, 'b_unread'),
838 new_check_button_for (\%pr::gui, 'swp_from'),
839 new_check_button_for (\%pr::gui, 'two_linev'),
840 new_check_button_for (\%pr::gui, 'next_del'),
841 new_selection_box_for (\%pr::gui, 'from_show')),
842 $xl::s{mlist_frame}, 'not-packed'),
843 FALSE, FALSE, FRAME_SPC);
844 $gf->pack_start (new_subpage_frame (
846 new_check_button_for (\%pr::gui, 'cursor_v'),
847 new_check_button_for (\%pr::gui, 'mview_date')),
848 $xl::s{mview_frame}, 'not-packed'),
849 FALSE, FALSE, FRAME_SPC);
850 $gf->pack_start (new_subpage_frame (
852 new_check_button_for (\%pr::gui, 'no_markup'),
853 new_check_button_for (\%pr::gui, 'margin_co'),
854 new_check_button_for (\%pr::gui, 'type_any')),
855 $xl::s{compo_frame}, 'not-packed'),
856 FALSE, FALSE, FRAME_SPC);
857 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
858 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
859 $gf->pack_start (new_subpage_frame (
861 new_check_button_for (\%pr::gui, 'h_scroll'),
862 new_selection_box_for (\%pr::gui, 'v_scroll')),
863 $xl::s{sbar_frame}, 'not-packed'),
864 FALSE, FALSE, FRAME_SPC);
865 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
870 %pr::beh = ( # tweak some behaviour
873 $xl::s{l_beh_hover_t},
874 $xl::s{h_beh_hover_t},
875 'int,100,3000', # 0.1 seconds - 3 seconds
882 $xl::s{l_beh_dangerous},
883 $xl::s{h_beh_dangerous},
890 'respect_flowed_format',
891 $xl::s{l_beh_flowed},
892 $xl::s{h_beh_flowed},
899 'save_parts_readwrite',
900 $xl::s{l_beh_parts_rw},
901 $xl::s{h_beh_parts_rw},
908 'skip_ssl_cert_check',
909 $xl::s{l_beh_skip_ssl},
910 $xl::s{h_beh_skip_ssl},
917 'statusbar_update_step',
918 $xl::s{l_beh_up_step},
919 $xl::s{h_beh_up_step},
920 'int,1,200', # 1 item - 200 items
926 'thread_by_subject_max_age',
927 $xl::s{l_beh_thread_a},
928 $xl::s{h_beh_thread_a},
929 'int,1,30', # 1 day - 30 days
936 $xl::s{l_beh_unsafe_ssl},
937 $xl::s{h_beh_unsafe_ssl},
944 'utf8_instead_of_locale_for_broken_mail',
945 $xl::s{l_beh_use_utf8},
946 $xl::s{h_beh_use_utf8},
954 $xl::s{l_beh_warn_dnd},
955 $xl::s{h_beh_warn_dnd},
962 'outgoing_fallback_to_ascii',
963 $xl::s{l_beh_out_ascii},
964 $xl::s{h_beh_out_ascii},
971 'primary_paste_unselects',
972 $xl::s{l_beh_pp_unsel},
973 $xl::s{h_beh_pp_unsel},
980 'show_inline_attachments',
981 $xl::s{l_beh_inline_at},
982 $xl::s{h_beh_inline_at},
989 'address_search_wildcard',
990 $xl::s{l_beh_addr_swc},
991 $xl::s{h_beh_addr_sw1},
998 'folder_search_wildcard',
999 $xl::s{l_beh_fold_swc},
1000 $xl::s{h_beh_fold_sw1},
1008 sub new_behaviour_page() {
1009 my $bf = Gtk2::VBox->new (FALSE, 5);
1010 $bf->set_border_width (PAGE_SPC);
1012 my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step');
1013 my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a');
1015 $bf->pack_start (new_subpage_frame (
1017 new_text_box_for_int (\%pr::beh, 'hover_t'),
1018 new_check_button_for (\%pr::beh, 'warn_dnd')),
1019 $xl::s{dnd_frame}, 'not-packed'),
1020 FALSE, FALSE, FRAME_SPC);
1021 $bf->pack_start (new_subpage_frame (
1023 new_check_button_for (\%pr::beh, 'skip_ssl'),
1024 new_check_button_for (\%pr::beh, 'unsafe_ssl')),
1025 $xl::s{ssl_frame}, 'not-packed'),
1026 FALSE, FALSE, FRAME_SPC);
1027 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
1028 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
1029 $bf->pack_start (new_subpage_frame (
1031 new_check_button_for (\%pr::beh, 'flowed'),
1032 new_check_button_for (\%pr::beh, 'parts_rw'),
1033 new_check_button_for (\%pr::beh, 'use_utf8'),
1034 new_check_button_for (\%pr::beh, 'dangerous'),
1035 new_check_button_for (\%pr::beh, 'out_ascii'),
1036 new_check_button_for (\%pr::beh, 'pp_unsel'),
1037 new_check_button_for (\%pr::beh, 'inline_at')),
1038 $xl::s{msgs_frame}, 'not-packed'),
1039 FALSE, FALSE, FRAME_SPC);
1040 $bf->pack_start (new_subpage_frame (
1042 new_check_button_for (\%pr::beh, 'addr_swc'),
1043 new_check_button_for (\%pr::beh, 'fold_swc')),
1044 $xl::s{swc_frame}, 'not-packed'),
1045 FALSE, FALSE, FRAME_SPC);
1049 %pr::col = ( # a variety of colours
1052 $xl::s{l_col_emphasis},
1053 $xl::s{h_col_emphasis},
1061 $xl::s{l_col_log_err},
1062 $xl::s{h_col_log_err},
1070 $xl::s{l_col_log_in},
1071 $xl::s{h_col_log_in},
1079 $xl::s{l_col_log_msg},
1080 $xl::s{h_col_log_msg},
1088 $xl::s{l_col_log_out},
1089 $xl::s{h_col_log_out},
1097 $xl::s{l_col_log_warn},
1098 $xl::s{h_col_log_warn},
1106 $xl::s{l_col_diff_add},
1107 $xl::s{h_col_diff_add},
1114 'diff_deleted_color',
1115 $xl::s{l_col_diff_del},
1116 $xl::s{h_col_diff_del},
1124 $xl::s{l_col_diff_hunk},
1125 $xl::s{h_col_diff_hunk},
1133 sub new_colours_page() {
1134 return new_vbox_pack (
1137 new_color_button_for (\%pr::col, 'emphasis')),
1138 $xl::s{msgview_frame}, 'not-packed'),
1141 new_color_button_for (\%pr::col, 'log_err'),
1142 new_color_button_for (\%pr::col, 'log_in'),
1143 new_color_button_for (\%pr::col, 'log_msg'),
1144 new_color_button_for (\%pr::col, 'log_out'),
1145 new_color_button_for (\%pr::col, 'log_warn')),
1146 $xl::s{log_frame}, 'not-packed'),
1149 new_color_button_for (\%pr::col, 'diff_add'),
1150 new_color_button_for (\%pr::col, 'diff_del'),
1151 new_color_button_for (\%pr::col, 'diff_hunk')),
1152 $xl::s{diff_frame}, 'not-packed')
1156 %pr::win = ( # tweak window positions and/or sizes
1161 'int,0,3000', # 0 pixels - 3000 pixels
1170 'int,0,3000', # 0 pixels - 3000 pixels
1179 'int,0,3000', # 0 pixels - 3000 pixels
1188 'int,0,3000', # 0 pixels - 3000 pixels
1194 'mainwin_maximised',
1195 $xl::s{l_win_main_mx},
1196 $xl::s{h_win_main_mx},
1203 'mainwin_fullscreen',
1204 $xl::s{l_win_main_fs},
1205 $xl::s{h_win_main_fs},
1212 'main_messagewin_x',
1215 'int,0,3000', # 0 pixels - 3000 pixels
1221 'main_messagewin_y',
1224 'int,0,3000', # 0 pixels - 3000 pixels
1233 'int,0,3000', # 0 pixels - 3000 pixels
1239 'messagewin_height',
1242 'int,0,3000', # 0 pixels - 3000 pixels
1251 'int,0,3000', # 0 pixels - 3000 pixels
1260 'int,0,3000', # 0 pixels - 3000 pixels
1269 'int,0,3000', # 0 pixels - 3000 pixels
1275 'receivewin_height',
1278 'int,0,3000', # 0 pixels - 3000 pixels
1287 'int,0,3000', # 0 pixels - 3000 pixels
1296 'int,0,3000', # 0 pixels - 3000 pixels
1302 'folderitemwin_width',
1305 'int,0,3000', # 0 pixels - 3000 pixels
1311 'folderitemwin_height',
1314 'int,0,3000', # 0 pixels - 3000 pixels
1320 'folderselwin_width',
1323 'int,0,3000', # 0 pixels - 3000 pixels
1329 'folderselwin_height',
1332 'int,0,3000', # 0 pixels - 3000 pixels
1341 'int,0,3000', # 0 pixels - 3000 pixels
1350 'int,0,3000', # 0 pixels - 3000 pixels
1356 'addressbookwin_width',
1359 'int,0,3000', # 0 pixels - 3000 pixels
1365 'addressbookwin_height',
1368 'int,0,3000', # 0 pixels - 3000 pixels
1374 'addressbookeditpersonwin_width',
1377 'int,0,3000', # 0 pixels - 3000 pixels
1383 'addressbookeditpersonwin_height',
1386 'int,0,3000', # 0 pixels - 3000 pixels
1392 'addressbookeditgroupwin_width',
1395 'int,0,3000', # 0 pixels - 3000 pixels
1401 'addressbookeditgroupwin_height',
1404 'int,0,3000', # 0 pixels - 3000 pixels
1410 'addressaddwin_width',
1413 'int,0,3000', # 0 pixels - 3000 pixels
1419 'addressaddwin_height',
1422 'int,0,3000', # 0 pixels - 3000 pixels
1428 'addressbook_folderselwin_width',
1431 'int,0,3000', # 0 pixels - 3000 pixels
1437 'addressbook_folderselwin_height',
1440 'int,0,3000', # 0 pixels - 3000 pixels
1446 'editaccountwin_width',
1449 'int,0,3000', # 0 pixels - 3000 pixels
1455 'editaccountwin_height',
1458 'int,0,3000', # 0 pixels - 3000 pixels
1464 'accountswin_width',
1467 'int,0,3000', # 0 pixels - 3000 pixels
1473 'accountswin_height',
1476 'int,0,3000', # 0 pixels - 3000 pixels
1482 'filteringwin_width',
1485 'int,0,3000', # 0 pixels - 3000 pixels
1491 'filteringwin_height',
1494 'int,0,3000', # 0 pixels - 3000 pixels
1500 'filteringactionwin_width',
1503 'int,0,3000', # 0 pixels - 3000 pixels
1509 'filteringactionwin_height',
1512 'int,0,3000', # 0 pixels - 3000 pixels
1518 'filtering_debugwin_width',
1521 'int,0,3000', # 0 pixels - 3000 pixels
1527 'filtering_debugwin_height',
1530 'int,0,3000', # 0 pixels - 3000 pixels
1539 'int,0,3000', # 0 pixels - 3000 pixels
1545 'matcherwin_height',
1548 'int,0,3000', # 0 pixels - 3000 pixels
1557 'int,0,3000', # 0 pixels - 3000 pixels
1566 'int,0,3000', # 0 pixels - 3000 pixels
1572 'templateswin_width',
1575 'int,0,3000', # 0 pixels - 3000 pixels
1581 'templateswin_height',
1584 'int,0,3000', # 0 pixels - 3000 pixels
1593 'int,0,3000', # 0 pixels - 3000 pixels
1599 'actionswin_height',
1602 'int,0,3000', # 0 pixels - 3000 pixels
1611 'int,0,3000', # 0 pixels - 3000 pixels
1620 'int,0,3000', # 0 pixels - 3000 pixels
1629 'int,0,3000', # 0 pixels - 3000 pixels
1635 'pluginswin_height',
1638 'int,0,3000', # 0 pixels - 3000 pixels
1647 'int,0,3000', # 0 pixels - 3000 pixels
1656 'int,0,3000', # 0 pixels - 3000 pixels
1662 'print_previewwin_width',
1665 'int,0,3000', # 0 pixels - 3000 pixels
1671 'print_previewwin_height',
1674 'int,0,3000', # 0 pixels - 3000 pixels
1681 sub new_winpos_subpage_main() {
1682 return new_subpage_frame (
1683 new_vbox_pack_compact (
1685 new_text_box_for_int (\%pr::win, 'main_x'),
1686 new_text_box_for_int (\%pr::win, 'main_y')),
1688 new_text_box_for_int (\%pr::win, 'main_w'),
1689 new_text_box_for_int (\%pr::win, 'main_h')),
1691 new_check_button_for (\%pr::win, 'main_fs'),
1692 new_check_button_for (\%pr::win, 'main_mx'))),
1697 sub new_winpos_subpage_msgs() {
1698 return new_subpage_frame (
1699 new_vbox_pack_compact (
1701 new_text_box_for_int (\%pr::win, 'msgs_x'),
1702 new_text_box_for_int (\%pr::win, 'msgs_y')),
1704 new_text_box_for_int (\%pr::win, 'msgs_w'),
1705 new_text_box_for_int (\%pr::win, 'msgs_h'))),
1710 sub new_winpos_subpage_sendrecv() {
1711 return new_vbox_pack (
1714 new_text_box_for_int (\%pr::win, 'send_w'),
1715 new_text_box_for_int (\%pr::win, 'send_h')),
1716 _('Send window'), 'not-packed'),
1719 new_text_box_for_int (\%pr::win, 'recv_w'),
1720 new_text_box_for_int (\%pr::win, 'recv_h')),
1721 _('Receive window'), 'not-packed')
1725 sub new_winpos_subpage_fold() {
1726 return new_vbox_pack (
1728 new_vbox_pack_compact (
1730 new_text_box_for_int (\%pr::win, 'fold_x'),
1731 new_text_box_for_int (\%pr::win, 'fold_y')),
1733 new_text_box_for_int (\%pr::win, 'fold_w'),
1734 new_text_box_for_int (\%pr::win, 'fold_h'))),
1735 _('Folder window'), 'not-packed'),
1738 new_text_box_for_int (\%pr::win, 'fsel_w'),
1739 new_text_box_for_int (\%pr::win, 'fsel_h')),
1740 _('Folder selection window'), 'not-packed')
1744 sub new_winpos_subpage_addrbook() {
1745 return new_vbox_pack (
1748 new_text_box_for_int (\%pr::win, 'addr_w'),
1749 new_text_box_for_int (\%pr::win, 'addr_h')),
1750 _('Addressbook main window'), 'not-packed'),
1753 new_text_box_for_int (\%pr::win, 'adep_w'),
1754 new_text_box_for_int (\%pr::win, 'adep_h')),
1755 _('Edit person window'), 'not-packed'),
1758 new_text_box_for_int (\%pr::win, 'adeg_w'),
1759 new_text_box_for_int (\%pr::win, 'adeg_h')),
1760 _('Edit group window'), 'not-packed'),
1763 new_text_box_for_int (\%pr::win, 'adda_w'),
1764 new_text_box_for_int (\%pr::win, 'adda_h')),
1765 _('Add address window'), 'not-packed'),
1768 new_text_box_for_int (\%pr::win, 'addf_w'),
1769 new_text_box_for_int (\%pr::win, 'addf_h')),
1770 _('Folder select window'), 'not-packed')
1774 sub new_winpos_subpage_accounts() {
1775 return new_vbox_pack (
1778 new_text_box_for_int (\%pr::win, 'acco_w'),
1779 new_text_box_for_int (\%pr::win, 'acco_h')),
1780 _('Accounts window'), 'not-packed'),
1783 new_text_box_for_int (\%pr::win, 'acce_w'),
1784 new_text_box_for_int (\%pr::win, 'acce_h')),
1785 _('Edit account window'), 'not-packed')
1789 sub new_winpos_subpage_filtering() {
1790 return new_vbox_pack (
1793 new_text_box_for_int (\%pr::win, 'filt_w'),
1794 new_text_box_for_int (\%pr::win, 'filt_h')),
1795 _('Filtering window'), 'not-packed'),
1798 new_text_box_for_int (\%pr::win, 'fila_w'),
1799 new_text_box_for_int (\%pr::win, 'fila_h')),
1800 _('Filtering actions window'), 'not-packed'),
1803 new_text_box_for_int (\%pr::win, 'fild_w'),
1804 new_text_box_for_int (\%pr::win, 'fild_h')),
1805 _('Filtering debug window'), 'not-packed'),
1808 new_text_box_for_int (\%pr::win, 'matc_w'),
1809 new_text_box_for_int (\%pr::win, 'matc_h')),
1810 _('Matcher window'), 'not-packed')
1814 sub new_winpos_subpage_prefs() {
1815 return new_vbox_pack (
1818 new_text_box_for_int (\%pr::win, 'pref_w'),
1819 new_text_box_for_int (\%pr::win, 'pref_h')),
1820 _('Preferences window'), 'not-packed'),
1823 new_text_box_for_int (\%pr::win, 'temp_w'),
1824 new_text_box_for_int (\%pr::win, 'temp_h')),
1825 _('Templates window'), 'not-packed'),
1828 new_text_box_for_int (\%pr::win, 'acti_w'),
1829 new_text_box_for_int (\%pr::win, 'acti_h')),
1830 _('Actions window'), 'not-packed'),
1833 new_text_box_for_int (\%pr::win, 'tags_w'),
1834 new_text_box_for_int (\%pr::win, 'tags_h')),
1835 _('Tags window'), 'not-packed'),
1838 new_text_box_for_int (\%pr::win, 'plug_w'),
1839 new_text_box_for_int (\%pr::win, 'plug_h')),
1840 _('Plugins window'), 'not-packed')
1844 sub new_winpos_subpage_misc() {
1845 return new_vbox_pack (
1848 new_text_box_for_int (\%pr::win, 'logw_w'),
1849 new_text_box_for_int (\%pr::win, 'logw_h')),
1850 _('Log window'), 'not-packed'),
1853 new_text_box_for_int (\%pr::win, 'prin_w'),
1854 new_text_box_for_int (\%pr::win, 'prin_h')),
1855 _('Print preview window'), 'not-packed'),
1858 new_text_box_for_int (\%pr::win, 'sour_w'),
1859 new_text_box_for_int (\%pr::win, 'sour_h')),
1860 _('View source window'), 'not-packed')
1864 sub new_winpos_page() {
1865 my $winbook = Gtk2::Notebook->new;
1866 $winbook->set_tab_pos ('right');
1867 $winbook->append_page (new_winpos_subpage_main, _('Main'));
1868 $winbook->append_page (new_winpos_subpage_msgs, _('Message'));
1869 $winbook->append_page (new_winpos_subpage_sendrecv, _('Send/Receive'));
1870 $winbook->append_page (new_winpos_subpage_fold, _('Folder'));
1871 $winbook->append_page (new_winpos_subpage_addrbook, _('Addressbook'));
1872 $winbook->append_page (new_winpos_subpage_accounts, _('Accounts'));
1873 $winbook->append_page (new_winpos_subpage_filtering, _('Filtering'));
1874 $winbook->append_page (new_winpos_subpage_prefs, _('Preferences'));
1875 $winbook->append_page (new_winpos_subpage_misc, _('Other'));
1880 sub print_version() {
1881 print $xl::s{about_title} . "\n";
1882 print $xl::s{about_version} . " $VERSION\n";
1883 print "Perl-GLib " . $Glib::VERSION;
1884 # version info stuff appeared in 1.040
1885 if ($Glib::VERSION >= 1.040) {
1886 print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
1887 . _(", running with ") . join(".", &Glib::major_version,
1888 &Glib::minor_version, &Glib::micro_version);
1891 print "Perl-GTK2 " . $Gtk2::VERSION;
1892 if ($Gtk2::VERSION >= 1.040) {
1893 print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
1894 . _(", running with ") . join(".", &Gtk2::major_version,
1895 &Gtk2::minor_version, &Gtk2::micro_version);
1898 my $clawsver = ($CLAWSV eq "") ?
1899 _("was not found!") :
1900 (_("returned version ") . $CLAWSV);
1901 print "Claws Mail " . $clawsver . "\n";
1904 # the command line help
1906 my $line = '-' x length ($xl::s{about_title}) . "\n";
1908 print $xl::s{about_title} . "\n";
1910 print _("Syntax:\n");
1911 print _(" clawsker [options]\n");
1912 print _("Options:\n");
1913 print _(" -h|--help Prints this help screen.\n");
1914 print _(" -v|--version Prints version infos.\n");
1915 print _(" -b|--verbose More messages on standard output.\n");
1916 print _(" -a|--alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
1917 print _(" -c|--clawsrc <file> Uses <file> as full resource name.\n");
1920 sub parse_command_line {
1922 $CLAWSV = get_claws_version ();
1924 GetOptions('h|help' => sub { print_help (); $cont = FALSE },
1925 'v|version' => sub { print_version (); $cont = FALSE },
1926 'b|verbose' => sub { $VERBOSE = TRUE },
1927 'u|use-claws-version=s' => \&opt_use_claws_version,
1928 'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
1929 'r|clawsrc=s' => \&opt_clawsrc)
1930 or die _("try -h or --help for syntax.\n");
1933 my $msg = _("Error in options: {msg}\n", msg => $@);
1934 if (defined $ENV{'DISPLAY'} and $ENV{'DISPLAY'} ne '') {
1935 eval { Gtk2->init };
1936 error_dialog ($msg) unless $@;
1943 sub opt_use_claws_version {
1944 my ($name, $value) = @_;
1945 die _("Error: {opt} requires a dotted numeric value argument\n", opt => $name)
1946 unless ($value =~ /^[\d\.]+$/);
1950 sub opt_alternate_config_dir {
1951 my ($name, $value) = @_;
1952 die _("Error: '{dir}' is not a directory or does not exist\n", dir => $value)
1954 $CONFIGDIR = $value;
1955 $CONFIGDIR .= "/" unless ($CONFIGDIR =~ /.*\/$/);
1956 $ALTCONFIGDIR = TRUE;
1960 my ($name, $value) = @_;
1961 die _("Error: '{value}' is not a file or does not exist\n", value => $value)
1963 set_rc_filename ($value);
1966 # update the hidden preferences status from loaded values
1967 sub init_hidden_preferences {
1968 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
1969 foreach my $key (keys %$hash) {
1970 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
1976 # load current status from disc
1977 sub load_preferences {
1978 my $rc = get_rc_filename ();
1979 log_message ("Loading preferences from $rc\n");
1980 return FALSE unless check_rc_file ($rc);
1981 return FALSE unless check_claws_not_running ();
1985 if (/^([8a-z_]+)=(.*)$/) {
1986 $PREFS{$1} = decode('UTF-8', $2);
1993 # save current preferences to disc
1994 sub save_preferences {
1995 my $rc = get_rc_filename ();
1996 log_message ("Saving preferences to $rc\n");
1997 return FALSE unless check_rc_file ($rc);
1998 return FALSE unless check_claws_not_running ();
1999 my $rcbak = "$rc.backup";
2000 rename ($rc, $rcbak);
2002 open (RCB, "<$rcbak");
2005 if (/^([8a-z_]+)=(.*)$/) {
2006 if (defined($HPVALUE{$1})) {
2007 print RCF $1 . "=" . $HPVALUE{$1} . "\n";
2010 print RCF $_ . "\n";
2014 print RCF $_ . "\n";
2024 my $nb = Gtk2::Notebook->new;
2026 $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
2027 $nb->append_page (new_colours_page (), $xl::s{tab_colours});
2028 $nb->append_page (new_gui_page (), $xl::s{tab_gui});
2029 $nb->append_page (new_other_page (), $xl::s{tab_other});
2030 $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
2035 # create an about dialog
2036 sub new_about_dialog {
2038 my $title = $xl::s{about_title};
2039 my $lic = $xl::s{about_license};
2040 my $vers = $xl::s{about_version} . " $VERSION";
2042 "This program is free software: you can redistribute it and/or modify
2043 it under the terms of the GNU General Public License as published by
2044 the Free Software Foundation, either version 3 of the License, or
2045 (at your option) any later version.
2047 This program is distributed in the hope that it will be useful,
2048 but WITHOUT ANY WARRANTY; without even the implied warranty of
2049 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2050 GNU General Public License for more details.
2052 You should have received a copy of the GNU General Public License
2053 along with this program. If not, see <http://www.gnu.org/licenses/>.";
2054 my $year = "2007-2015";
2055 my $holder = "Ricardo Mones <ricardo\@mones.org>";
2056 my $url = "http://www.claws-mail.org/clawsker.php";
2058 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
2059 [qw/modal destroy-with-parent/],
2061 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
2062 . "<span size=\"large\">$vers</span>\n\n"
2063 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2064 . "<span>Copyright $year by $holder</span>\n\n"
2065 . "<span size=\"large\">$lic</span>\n\n"
2066 . "<span size=\"small\">$license</span>");
2067 $dialog->set_title ($xl::s{about});
2072 # create buttons box
2073 sub new_button_box {
2074 my ($parent, $adlg) = @_;
2075 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2076 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2077 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2078 # disable button until is really implemented
2079 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2080 my $hbox = Gtk2::HBox->new (FALSE, 5);
2082 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2083 $b_apply->signal_connect (clicked => sub { save_preferences ($parent) });
2084 # $b_undo->signal_connect (clicked => sub { undo_current_changes });
2085 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2087 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2088 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2089 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2090 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2096 exit unless parse_command_line ();
2098 $main_window = Gtk2::Window->new ('toplevel');
2099 exit unless load_preferences ();
2100 exit unless init_hidden_preferences ();
2102 my $box = Gtk2::VBox->new (FALSE, 5);
2103 $box->set_border_width(3);
2104 my $about = new_about_dialog ();
2105 $box->pack_start (new_notebook (), FALSE, FALSE, 0);
2106 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
2107 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2108 $main_window->set_title ($xl::s{win_title});
2109 $main_window->add ($box);
2110 $main_window->show_all;