3 # Clawsker :: A Claws Mail Tweaker
7 use Glib qw(TRUE FALSE);
9 use POSIX qw(setlocale);
12 use Digest::MD5 qw(md5_hex);
14 my $NAME = 'clawsker';
15 my $PREFIX = '@PREFIX@';
16 my $LIBDIR = '@LIBDIR@';
17 my $VERSION = '@VERSION@';
20 my $main_window = undef;
22 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
23 $locale = "C" unless defined($locale);
24 setlocale (LC_ALL, $locale);
25 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
28 my $SHOWHINTS = FALSE;
29 $SHOWHINTS = TRUE if ($Gtk2::VERSION >= 1.040 and Gtk2->CHECK_VERSION (2, 12, 0));
34 my $xla = gettext ($str);
35 if (scalar(keys(%par)) > 0) {
36 foreach my $key (keys %par) {
37 $xla =~ s/\{$key\}/$par{$key}/g;
40 return decode_utf8($xla);
45 win_title => _('Claws Mail Hidden Preferences'),
46 about => _('About...'),
47 about_title => _('Clawsker :: A Claws Mail Tweaker'),
48 about_license => _('License:'),
49 about_version => _('Version:'),
51 tab_colours => _('Colours'),
52 tab_behaviour => _('Behaviour'),
54 tab_other => _('Other'),
55 tab_winpos => _('Windows'),
57 ab_frame => _('Addressbook'),
58 mem_frame => _('Memory'),
59 msgview_frame => _('Message View'),
60 log_frame => _('Log window'),
61 dnd_frame => _('Drag \'n\' drop'),
62 ssl_frame => _('Secure Sockets Layer'),
63 msgs_frame => _('Messages'),
64 stripes_frame => _('Coloured stripes'),
65 sbar_frame => _('Scroll bars'),
66 mlist_frame => _('Message List'),
67 mview_frame => _('Message View'),
68 compo_frame => _('Compose window'),
69 netm_frame => _('NetworkManager'),
70 diff_frame => _('Viewing patches'),
72 l_oth_use_dlg => _('Use detached address book edit dialogue'),
73 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.'),
74 l_oth_max_use => _('Maximum memory for message cache (kB)'),
75 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
76 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
77 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.'),
78 l_oth_use_netm => _('Use NetworkManager'),
79 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
81 l_gui_b_unread => _('Show unread messages with bold font'),
82 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
83 l_gui_no_markup => _('Don\'t use markup in compose window'),
84 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
85 l_gui_dot_lines => _('Use dotted lines in tree view components'),
86 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.'),
87 l_gui_h_scroll => _('Enable horizontal scrollbar'),
88 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
89 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
90 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.'),
91 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
92 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
93 l_gui_v_scroll_show => _('Show always'),
94 l_gui_v_scroll_auto => _('Automatic'),
95 l_gui_v_scroll_hide => _('Hide always'),
96 l_gui_from_show => _('From column displays'),
97 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both'),
98 l_gui_from_show_name => _('Name only'),
99 l_gui_from_show_addr => _('Address only'),
100 l_gui_from_show_both => _('Both name and address'),
101 l_gui_strip_off => _('Coloured lines contrast'),
102 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.'),
103 l_gui_cursor_v => _('Show cursor'),
104 h_gui_cursor_v => _('Display the cursor in the Message View.'),
105 l_gui_toolbar_d => _('Detachable toolbars'),
106 h_gui_toolbar_d => _('Show handles in the toolbars.'),
107 l_gui_strip_all => _('Use stripes in all tree view components'),
108 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
109 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
110 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
111 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
112 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
113 l_gui_margin_co => _('Show compose margin'),
114 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
115 l_gui_mview_date => _('Don\'t display localized date'),
116 h_gui_mview_date => _('Toggles localization of date format in Message View'),
117 l_gui_zero_char => _('Zero replacement character'),
118 h_gui_zero_char => _('Replaces \'0\' with the given character in Folder List'),
120 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
121 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.'),
122 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
123 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
124 l_beh_flowed => _('Respect format=flowed in messages'),
125 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.'),
126 l_beh_parts_rw => _('Allow writable temporary files'),
127 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
128 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
129 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
130 l_beh_up_step => _('Progress bar update step (items)'),
131 h_beh_up_step => _('Update stepping in progress bars.'),
132 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
133 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
134 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
135 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
136 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
137 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
138 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
139 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
140 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
141 h_beh_out_ascii => _('If content allows, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is enforced always.'),
142 l_beh_pp_unsel => _('Primary paste unselects selection'),
143 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
144 l_beh_inline_at => _('Show inline attachments'),
145 h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view'),
147 l_col_emphasis => _('X-Mailer header'),
148 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
149 l_col_log_err => _('Error messages'),
150 h_col_log_err => _('Colour for error messages in log window.'),
151 l_col_log_in => _('Server messages'),
152 h_col_log_in => _('Colour for messages received from servers in log window.'),
153 l_col_log_msg => _('Standard messages'),
154 h_col_log_msg => _('Colour for messages in log window.'),
155 l_col_log_out => _('Client messages'),
156 h_col_log_out => _('Colour for messages sent to servers in log window.'),
157 l_col_log_warn => _('Warnings'),
158 h_col_log_warn => _('Colour for warning messages in log window.'),
160 l_col_diff_add => _('Added lines'),
161 h_col_diff_add => _('Colour for added lines in patches.'),
162 l_col_diff_del => _('Deleted lines'),
163 h_col_diff_del => _('Colour for deleted lines in patches.'),
164 l_col_diff_hunk => _('Hunk lines'),
165 h_col_diff_hunk => _('Color for hunk headers in patches.'),
167 l_win_x => _('X position'),
168 h_win_x => _('X coordinate for window\'s top-left corner.'),
169 l_win_y => _('Y position'),
170 h_win_y => _('Y coordinate for window\'s top-left corner.'),
171 l_win_w => _('Width'),
172 h_win_w => _('Window\'s width in pixels.'),
173 l_win_h => _('Height'),
174 h_win_h => _('Window\'s height in pixels.'),
176 l_win_main_mx => _('Maximized'),
177 h_win_main_mx => _('Changes window maximized status.'),
178 l_win_main_fs => _('Full-screen'),
179 h_win_main_fs => _('Changes full screen status.'),
181 e_error => _('Error: '),
182 e_noclawsrc => _('resource file for Claws Mail was not found.'),
183 e_running => _('seems Claws Mail is currently running, close it first.'),
184 e_requireddir => _('option requires a directory name.'),
185 e_requiredfile => _('option requires a file name.'),
186 e_notadir => _('specified name is not a directory or does not exist.'),
187 e_notafile => _('specified name is not a file or does not exist.'),
190 # all preferences read by load_preferences
192 # values of all preferences handled by clawsker
194 # default config dir and file name
195 my $ALTCONFIGDIR = FALSE;
196 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
197 my $CONFIGRC = 'clawsrc';
199 # index constants for preference arrays
200 use constant NAME => 0; # the name on the rc file
201 use constant LABEL => 1; # the label on the GUI
202 use constant DESC => 2; # the description for the hint/help
203 use constant TYPE => 3; # data type: bool, int, float, string, color
204 use constant CMVER => 4; # lowest Claws Mail version the feature exists
205 use constant CMDEF => 5; # default value for the preference in Claws Mail
206 use constant GUI => 6; # GUI element
208 # constants for GUI spacing
209 use constant HBOX_SPC => 5;
210 use constant FRAME_SPC => 2;
211 use constant PAGE_SPC => 5;
215 sub version_greater_or_equal() {
216 my ($version, $refvers) = @_;
217 my @version = split (/\./, $version);
218 my @refvers = split (/\./, $refvers);
219 while ($#version < $#refvers) {
220 push (@version, '0');
223 while (($idx <= $#refvers)
224 and (int ($version[$idx]) == int ($refvers[$idx]))) {
227 return TRUE if (($idx > $#refvers)
228 or (int ($version[$idx]) >= int ($refvers[$idx])));
232 sub get_claws_version() {
237 foreach my $bin (@cmbin) {
242 return "" unless ($_); # not installed
245 my @fver = split (/ /);
246 die "Invalid version string" unless ($fver[2] eq "version");
247 my @ver = split (/\./, $fver[3]);
250 if ($ver[2] =~ /(\d+)cvs(\d+)/) {
259 # data handlers and auxiliar functions
261 sub handle_bool_value {
262 my ($widget, $event, $dataref) = @_;
263 $$dataref = ($widget->get_active ())? '1': '0';
266 sub handle_int_value {
267 my ($widget, $event, $dataref) = @_;
268 $_ = $widget->get_text ();
273 $widget->set_text ($_);
276 $widget->set_text ($$dataref);
280 sub handle_string_value {
281 my ($widget, $event, $dataref) = @_;
282 $$dataref = $widget->get_text ();
285 sub handle_nchar_value {
286 my ($widget, $event, $dataref, $minlen) = @_;
287 $_ = substr ($widget->get_text (), 0, $minlen);
288 $widget->set_text ($_);
292 sub gdk_color_from_str {
294 my ($rr, $gg, $bb) = (0, 0 ,0);
296 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
301 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
305 sub str_from_gdk_color {
307 my $rr = $color->red / 256;
308 my $gg = $color->green / 256;
309 my $bb = $color->blue / 256;
310 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
314 sub handle_color_value {
315 my ($widget, $event, $dataref) = @_;
316 my $newcol = $widget->get_color;
317 $$dataref = &str_from_gdk_color ($newcol);
320 sub handle_selection_value {
321 my ($widget, $event, $dataref) = @_;
322 $$dataref = $widget->get_active;
325 sub get_rc_filename {
326 return $CONFIGDIR . $CONFIGRC;
329 sub set_rc_filename {
331 my @parts = split ('/', $fullname);
332 $CONFIGRC = $parts[$#parts];
333 $parts[$#parts] = '';
334 $CONFIGDIR = join ('/', @parts);
338 my ($mesg, $fatal) = @_;
339 if (defined($fatal) && $fatal eq 'die') {
340 die "$NAME: $mesg\n";
343 print "$NAME: $mesg\n";
349 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
350 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
351 $errordlg->set_title (_('Error message'));
356 sub claws_is_running() {
357 my $emsg = "$xl::s{e_error}$xl::s{e_running}";
359 error_dialog ($emsg);
363 sub check_claws_not_running() {
364 my $socket = (not $ALTCONFIGDIR)? "/tmp/": $CONFIGDIR;
365 $socket .= "claws-mail-$<";
366 -S $socket and return &claws_is_running;
368 my $lockdir = "/tmp/claws-mail-$<";
372 $socket = "$lockdir/" . md5_hex($_);
373 -S $socket and return &claws_is_running;
378 sub check_rc_file() {
380 (defined($rcfile) && -f $rcfile) or do {
381 my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
383 error_dialog ($emsg);
389 sub set_widget_hint() {
391 my ($wdgt, $hint) = @_;
392 $wdgt->set_tooltip_text ($hint);
393 $wdgt->set_has_tooltip (TRUE);
397 sub set_widget_sens() {
398 my ($wdgt, $versions) = @_;
399 my @ver = split(/,/, $versions);
401 $wdgt->set_sensitive (
402 &version_greater_or_equal ($CLAWSV, $ver[0])
403 and &version_greater_or_equal ($ver[1], $CLAWSV)
406 $wdgt->set_sensitive (&version_greater_or_equal ($CLAWSV, $ver[0]));
410 # graphic element creation
412 sub new_check_button_for {
413 my ($hash, $key) = @_;
414 my $name = $$hash{$key}[NAME];
415 my $label = $$hash{$key}[LABEL];
417 my $hbox = Gtk2::HBox->new (FALSE, 5);
418 my $cb = Gtk2::CheckButton->new ($label);
419 $$hash{$key}[GUI] = $cb;
420 if (defined ($HPVALUE{$name})) {
421 $cb->set_active ($HPVALUE{$name} eq '1');
423 $cb->signal_connect (clicked => sub {
425 &handle_bool_value($w, $e, \$HPVALUE{$name});
427 &set_widget_hint ($cb, $$hash{$key}[DESC]);
428 &set_widget_sens ($cb, $$hash{$key}[CMVER]);
429 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
434 sub new_text_box_for_int {
435 my ($hash, $key) = @_;
436 my $name = $$hash{$key}[NAME];
437 my $label = $$hash{$key}[LABEL];
438 my @type = split (/,/, $$hash{$key}[TYPE]);
439 push (@type, 0), push (@type, 10000) unless ($#type > 0);
441 my $hbox = Gtk2::HBox->new (FALSE, 5);
442 my $glabel = Gtk2::Label->new ($label);
443 my $pagei = int (($type[2] - $type[1]) / 10);
444 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
445 $gentry->set_numeric (TRUE);
446 $gentry->set_value ($HPVALUE{$name});
447 $$hash{$key}[GUI] = $gentry;
448 $gentry->signal_connect('value-changed' => sub {
450 &handle_int_value($w, $e, \$HPVALUE{$name});
452 &set_widget_hint ($gentry, $$hash{$key}[DESC]);
453 &set_widget_sens ($gentry, $$hash{$key}[CMVER]);
454 $glabel->set_sensitive ($gentry->sensitive);
455 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
456 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
461 sub new_text_box_for_nchar {
462 my ($hash, $key) = @_;
463 my $name = $$hash{$key}[NAME];
464 my $label = $$hash{$key}[LABEL];
465 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen
466 my $hbox = Gtk2::HBox->new (FALSE, 5);
467 my $glabel = Gtk2::Label->new ($label);
468 my $gentry = Gtk2::Entry->new ();
469 $gentry->set_max_length($type[2]) if defined ($type[2]);
470 $gentry->set_width_chars(int ($type[2]) + 2) if defined ($type[2]);
471 $gentry->set_text ($HPVALUE{$name});
472 $$hash{$key}[GUI] = $gentry;
473 $gentry->signal_connect('key-release-event' => sub {
475 &handle_nchar_value($w, $e, \$HPVALUE{$name}, $type[1]);
477 &set_widget_hint ($gentry, $$hash{$key}[DESC]);
478 &set_widget_sens ($gentry, $$hash{$key}[CMVER]);
479 $glabel->set_sensitive ($gentry->sensitive);
480 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
481 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
486 sub new_color_button_for {
487 my ($hash, $key) = @_;
488 my $name = $$hash{$key}[NAME];
489 my $label = $$hash{$key}[LABEL];
491 my $col = &gdk_color_from_str ($HPVALUE{$name});
492 my $hbox = Gtk2::HBox->new (FALSE, 5);
493 my $glabel = Gtk2::Label->new ($label);
494 my $button = Gtk2::ColorButton->new_with_color ($col);
495 $$hash{$key}[GUI] = $button;
496 $button->set_title ($label);
497 $button->set_relief ('none');
498 $button->signal_connect ('color-set' => sub {
500 &handle_color_value($w, $e, \$HPVALUE{$name});
502 &set_widget_hint ($button, $$hash{$key}[DESC]);
503 &set_widget_sens ($button, $$hash{$key}[CMVER]);
504 $glabel->set_sensitive ($button->sensitive);
505 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
506 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
511 sub new_selection_box_for {
512 my ($hash, $key) = @_;
513 my $name = $$hash{$key}[NAME];
514 my $label = $$hash{$key}[LABEL];
516 my $hbox = Gtk2::HBox->new (FALSE, 5);
517 my $glabel = Gtk2::Label->new ($label);
518 my $combo = Gtk2::ComboBox->new_text;
519 $$hash{$key}[GUI] = $combo;
520 my @options = split (';', $$hash{$key}[TYPE]);
521 foreach my $opt (@options) {
522 my ($index, $textkey) = split ('=', $opt);
523 $combo->insert_text ($index, $xl::s{$textkey});
525 $combo->signal_connect ('changed' => sub {
527 &handle_selection_value($w, $e, \$HPVALUE{$name});
529 $combo->set_active ($HPVALUE{$name});
530 &set_widget_hint ($combo, $$hash{$key}[DESC]);
531 &set_widget_sens ($combo, $$hash{$key}[CMVER]);
532 $glabel->set_sensitive ($combo->sensitive);
533 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
534 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
539 # more graphic helpers
541 sub new_hbox_pack() {
542 my $hbox = Gtk2::HBox->new (FALSE, 5);
543 $hbox->set_border_width (PAGE_SPC);
544 foreach my $item (@_) {
545 $hbox->pack_start ($item, FALSE, FALSE, 0);
550 sub new_vbox_pack() {
551 my $vbox = Gtk2::VBox->new (FALSE, 5);
552 $vbox->set_border_width (PAGE_SPC);
553 foreach my $item (@_) {
554 $vbox->pack_start ($item, FALSE, FALSE, 0);
559 sub new_vbox_pack_compact() {
560 my $vbox = Gtk2::VBox->new (FALSE, 0);
561 $vbox->set_border_width (0);
562 foreach my $item (@_) {
563 $vbox->pack_start ($item, FALSE, FALSE, 0);
568 sub new_subpage_frame () {
569 my ($box, $title, $notpacked) = @_;
570 my $frame = Gtk2::Frame->new ($title);
572 return &new_vbox_pack ($frame) unless defined ($notpacked);
576 # preference maps and corresponding page creation subs
578 %pr::oth = ( # other preferences
580 'addressbook_use_editaddress_dialog',
581 $xl::s{l_oth_use_dlg},
582 $xl::s{h_oth_use_dlg},
589 'cache_max_mem_usage',
590 $xl::s{l_oth_max_use},
591 $xl::s{h_oth_max_use},
592 'int,0,262144', # 0 Kb - 256 Mb
598 'cache_min_keep_time',
599 $xl::s{l_oth_min_time},
600 $xl::s{h_oth_min_time},
601 'int,0,120', # 0 minutes - 2 hours
607 'use_networkmanager',
608 $xl::s{l_oth_use_netm},
609 $xl::s{h_oth_use_netm},
617 sub new_other_page() {
618 return &new_vbox_pack (
621 &new_check_button_for(\%pr::oth, 'use_dlg')),
622 $xl::s{ab_frame}, 'not-packed'),
625 &new_text_box_for_int(\%pr::oth, 'max_use'),
626 &new_text_box_for_int(\%pr::oth, 'min_time')),
627 $xl::s{mem_frame}, 'not-packed'),
630 &new_check_button_for(\%pr::oth, 'use_netm')),
631 $xl::s{netm_frame}, 'not-packed')
635 %pr::gui = ( # gui bells and whistles
638 $xl::s{l_gui_b_unread},
639 $xl::s{h_gui_b_unread},
647 $xl::s{l_gui_no_markup},
648 $xl::s{h_gui_no_markup},
655 'enable_dotted_lines',
656 $xl::s{l_gui_dot_lines},
657 $xl::s{h_gui_dot_lines},
665 $xl::s{l_gui_h_scroll},
666 $xl::s{h_gui_h_scroll},
674 $xl::s{l_gui_swp_from},
675 $xl::s{h_gui_swp_from},
682 'folderview_vscrollbar_policy',
683 $xl::s{l_gui_v_scroll},
684 $xl::s{h_gui_v_scroll},
685 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
692 $xl::s{l_gui_from_show},
693 $xl::s{h_gui_from_show},
694 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
700 'stripes_color_offset',
701 $xl::s{l_gui_strip_off},
702 $xl::s{h_gui_strip_off},
703 'int,0,40000', # no idea what this number means
709 'textview_cursor_visible',
710 $xl::s{l_gui_cursor_v},
711 $xl::s{h_gui_cursor_v},
718 'toolbar_detachable',
719 $xl::s{l_gui_toolbar_d},
720 $xl::s{h_gui_toolbar_d},
727 'use_stripes_everywhere',
728 $xl::s{l_gui_strip_all},
729 $xl::s{h_gui_strip_all},
736 'use_stripes_in_summaries',
737 $xl::s{l_gui_strip_sum},
738 $xl::s{h_gui_strip_sum},
746 $xl::s{l_gui_two_line_v},
747 $xl::s{h_gui_two_line_v},
754 'show_compose_margin',
755 $xl::s{l_gui_margin_co},
756 $xl::s{h_gui_margin_co},
763 'msgview_date_format',
764 $xl::s{l_gui_mview_date},
765 $xl::s{h_gui_mview_date},
772 'zero_replacement_char',
773 $xl::s{l_gui_zero_char},
774 $xl::s{h_gui_zero_char},
783 my $gf = Gtk2::VBox->new (FALSE, 5);
784 $gf->set_border_width (PAGE_SPC);
786 my $cb_dot_lines = &new_check_button_for (\%pr::gui, 'dot_lines');
787 my $cb_toolbar_d = &new_check_button_for (\%pr::gui, 'toolbar_d');
788 my $tb_zero_char = &new_text_box_for_nchar (\%pr::gui, 'zero_char');
790 $gf->pack_start (&new_subpage_frame (
792 &new_check_button_for (\%pr::gui, 'strip_all'),
793 &new_check_button_for (\%pr::gui, 'strip_sum'),
794 &new_text_box_for_int (\%pr::gui, 'strip_off')),
795 $xl::s{stripes_frame}, 'not-packed'),
796 FALSE, FALSE, FRAME_SPC);
797 $gf->pack_start (&new_subpage_frame (
799 &new_check_button_for (\%pr::gui, 'b_unread'),
800 &new_check_button_for (\%pr::gui, 'swp_from'),
801 &new_check_button_for (\%pr::gui, 'two_linev'),
802 &new_selection_box_for (\%pr::gui, 'from_show')),
803 $xl::s{mlist_frame}, 'not-packed'),
804 FALSE, FALSE, FRAME_SPC);
805 $gf->pack_start (&new_subpage_frame (
807 &new_check_button_for (\%pr::gui, 'cursor_v'),
808 &new_check_button_for (\%pr::gui, 'mview_date')),
809 $xl::s{mview_frame}, 'not-packed'),
810 FALSE, FALSE, FRAME_SPC);
811 $gf->pack_start (&new_subpage_frame (
813 &new_check_button_for (\%pr::gui, 'no_markup'),
814 &new_check_button_for (\%pr::gui, 'margin_co')),
815 $xl::s{compo_frame}, 'not-packed'),
816 FALSE, FALSE, FRAME_SPC);
817 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
818 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
819 $gf->pack_start (&new_subpage_frame (
821 &new_check_button_for (\%pr::gui, 'h_scroll'),
822 &new_selection_box_for (\%pr::gui, 'v_scroll')),
823 $xl::s{sbar_frame}, 'not-packed'),
824 FALSE, FALSE, FRAME_SPC);
825 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
830 %pr::beh = ( # tweak some behaviour
833 $xl::s{l_beh_hover_t},
834 $xl::s{h_beh_hover_t},
835 'int,100,3000', # 0.1 seconds - 3 seconds
842 $xl::s{l_beh_dangerous},
843 $xl::s{h_beh_dangerous},
850 'respect_flowed_format',
851 $xl::s{l_beh_flowed},
852 $xl::s{h_beh_flowed},
859 'save_parts_readwrite',
860 $xl::s{l_beh_parts_rw},
861 $xl::s{h_beh_parts_rw},
868 'skip_ssl_cert_check',
869 $xl::s{l_beh_skip_ssl},
870 $xl::s{h_beh_skip_ssl},
877 'statusbar_update_step',
878 $xl::s{l_beh_up_step},
879 $xl::s{h_beh_up_step},
880 'int,1,200', # 1 item - 200 items
886 'thread_by_subject_max_age',
887 $xl::s{l_beh_thread_a},
888 $xl::s{h_beh_thread_a},
889 'int,1,30', # 1 day - 30 days
896 $xl::s{l_beh_unsafe_ssl},
897 $xl::s{h_beh_unsafe_ssl},
904 'utf8_instead_of_locale_for_broken_mail',
905 $xl::s{l_beh_use_utf8},
906 $xl::s{h_beh_use_utf8},
914 $xl::s{l_beh_warn_dnd},
915 $xl::s{h_beh_warn_dnd},
922 'outgoing_fallback_to_ascii',
923 $xl::s{l_beh_out_ascii},
924 $xl::s{h_beh_out_ascii},
931 'primary_paste_unselects',
932 $xl::s{l_beh_pp_unsel},
933 $xl::s{h_beh_pp_unsel},
940 'show_inline_attachments',
941 $xl::s{l_beh_inline_at},
942 $xl::s{h_beh_inline_at},
950 sub new_behaviour_page() {
951 my $bf = Gtk2::VBox->new (FALSE, 5);
952 $bf->set_border_width (PAGE_SPC);
954 my $tb_up_step = &new_text_box_for_int (\%pr::beh, 'up_step');
955 my $tb_thread_a = &new_text_box_for_int (\%pr::beh, 'thread_a');
957 $bf->pack_start (&new_subpage_frame (
959 &new_text_box_for_int (\%pr::beh, 'hover_t'),
960 &new_check_button_for (\%pr::beh, 'warn_dnd')),
961 $xl::s{dnd_frame}, 'not-packed'),
962 FALSE, FALSE, FRAME_SPC);
963 $bf->pack_start (&new_subpage_frame (
965 &new_check_button_for (\%pr::beh, 'skip_ssl'),
966 &new_check_button_for (\%pr::beh, 'unsafe_ssl')),
967 $xl::s{ssl_frame}, 'not-packed'),
968 FALSE, FALSE, FRAME_SPC);
969 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
970 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
971 $bf->pack_start (&new_subpage_frame (
973 &new_check_button_for (\%pr::beh, 'flowed'),
974 &new_check_button_for (\%pr::beh, 'parts_rw'),
975 &new_check_button_for (\%pr::beh, 'use_utf8'),
976 &new_check_button_for (\%pr::beh, 'dangerous'),
977 &new_check_button_for (\%pr::beh, 'out_ascii'),
978 &new_check_button_for (\%pr::beh, 'pp_unsel'),
979 &new_check_button_for (\%pr::beh, 'inline_at')),
980 $xl::s{msgs_frame}, 'not-packed'),
981 FALSE, FALSE, FRAME_SPC);
986 %pr::col = ( # a variety of colours
989 $xl::s{l_col_emphasis},
990 $xl::s{h_col_emphasis},
998 $xl::s{l_col_log_err},
999 $xl::s{h_col_log_err},
1007 $xl::s{l_col_log_in},
1008 $xl::s{h_col_log_in},
1016 $xl::s{l_col_log_msg},
1017 $xl::s{h_col_log_msg},
1025 $xl::s{l_col_log_out},
1026 $xl::s{h_col_log_out},
1034 $xl::s{l_col_log_warn},
1035 $xl::s{h_col_log_warn},
1043 $xl::s{l_col_diff_add},
1044 $xl::s{h_col_diff_add},
1051 'diff_deleted_color',
1052 $xl::s{l_col_diff_del},
1053 $xl::s{h_col_diff_del},
1061 $xl::s{l_col_diff_hunk},
1062 $xl::s{h_col_diff_hunk},
1070 sub new_colours_page() {
1071 return &new_vbox_pack (
1072 &new_subpage_frame (
1074 &new_color_button_for (\%pr::col, 'emphasis')),
1075 $xl::s{msgview_frame}, 'not-packed'),
1076 &new_subpage_frame (
1078 &new_color_button_for (\%pr::col, 'log_err'),
1079 &new_color_button_for (\%pr::col, 'log_in'),
1080 &new_color_button_for (\%pr::col, 'log_msg'),
1081 &new_color_button_for (\%pr::col, 'log_out'),
1082 &new_color_button_for (\%pr::col, 'log_warn')),
1083 $xl::s{log_frame}, 'not-packed'),
1084 &new_subpage_frame (
1086 &new_color_button_for (\%pr::col, 'diff_add'),
1087 &new_color_button_for (\%pr::col, 'diff_del'),
1088 &new_color_button_for (\%pr::col, 'diff_hunk')),
1089 $xl::s{diff_frame}, 'not-packed')
1093 %pr::win = ( # tweak window positions and/or sizes
1098 'int,0,3000', # 0 pixels - 3000 pixels
1107 'int,0,3000', # 0 pixels - 3000 pixels
1116 'int,0,3000', # 0 pixels - 3000 pixels
1125 'int,0,3000', # 0 pixels - 3000 pixels
1131 'mainwin_maximised',
1132 $xl::s{l_win_main_mx},
1133 $xl::s{h_win_main_mx},
1140 'mainwin_fullscreen',
1141 $xl::s{l_win_main_fs},
1142 $xl::s{h_win_main_fs},
1149 'main_messagewin_x',
1152 'int,0,3000', # 0 pixels - 3000 pixels
1158 'main_messagewin_y',
1161 'int,0,3000', # 0 pixels - 3000 pixels
1170 'int,0,3000', # 0 pixels - 3000 pixels
1176 'messagewin_height',
1179 'int,0,3000', # 0 pixels - 3000 pixels
1188 'int,0,3000', # 0 pixels - 3000 pixels
1197 'int,0,3000', # 0 pixels - 3000 pixels
1206 'int,0,3000', # 0 pixels - 3000 pixels
1212 'receivewin_height',
1215 'int,0,3000', # 0 pixels - 3000 pixels
1224 'int,0,3000', # 0 pixels - 3000 pixels
1233 'int,0,3000', # 0 pixels - 3000 pixels
1239 'folderitemwin_width',
1242 'int,0,3000', # 0 pixels - 3000 pixels
1248 'folderitemwin_height',
1251 'int,0,3000', # 0 pixels - 3000 pixels
1257 'folderselwin_width',
1260 'int,0,3000', # 0 pixels - 3000 pixels
1266 'folderselwin_height',
1269 'int,0,3000', # 0 pixels - 3000 pixels
1278 'int,0,3000', # 0 pixels - 3000 pixels
1287 'int,0,3000', # 0 pixels - 3000 pixels
1293 'addressbookwin_width',
1296 'int,0,3000', # 0 pixels - 3000 pixels
1302 'addressbookwin_height',
1305 'int,0,3000', # 0 pixels - 3000 pixels
1311 'addressbookeditpersonwin_width',
1314 'int,0,3000', # 0 pixels - 3000 pixels
1320 'addressbookeditpersonwin_height',
1323 'int,0,3000', # 0 pixels - 3000 pixels
1329 'addressbookeditgroupwin_width',
1332 'int,0,3000', # 0 pixels - 3000 pixels
1338 'addressbookeditgroupwin_height',
1341 'int,0,3000', # 0 pixels - 3000 pixels
1347 'addressaddwin_width',
1350 'int,0,3000', # 0 pixels - 3000 pixels
1356 'addressaddwin_height',
1359 'int,0,3000', # 0 pixels - 3000 pixels
1365 'addressbook_folderselwin_width',
1368 'int,0,3000', # 0 pixels - 3000 pixels
1374 'addressbook_folderselwin_height',
1377 'int,0,3000', # 0 pixels - 3000 pixels
1383 'editaccountwin_width',
1386 'int,0,3000', # 0 pixels - 3000 pixels
1392 'editaccountwin_height',
1395 'int,0,3000', # 0 pixels - 3000 pixels
1401 'accountswin_width',
1404 'int,0,3000', # 0 pixels - 3000 pixels
1410 'accountswin_height',
1413 'int,0,3000', # 0 pixels - 3000 pixels
1419 'filteringwin_width',
1422 'int,0,3000', # 0 pixels - 3000 pixels
1428 'filteringwin_height',
1431 'int,0,3000', # 0 pixels - 3000 pixels
1437 'filteringactionwin_width',
1440 'int,0,3000', # 0 pixels - 3000 pixels
1446 'filteringactionwin_height',
1449 'int,0,3000', # 0 pixels - 3000 pixels
1455 'filtering_debugwin_width',
1458 'int,0,3000', # 0 pixels - 3000 pixels
1464 'filtering_debugwin_height',
1467 'int,0,3000', # 0 pixels - 3000 pixels
1476 'int,0,3000', # 0 pixels - 3000 pixels
1482 'matcherwin_height',
1485 'int,0,3000', # 0 pixels - 3000 pixels
1494 'int,0,3000', # 0 pixels - 3000 pixels
1503 'int,0,3000', # 0 pixels - 3000 pixels
1509 'templateswin_width',
1512 'int,0,3000', # 0 pixels - 3000 pixels
1518 'templateswin_height',
1521 'int,0,3000', # 0 pixels - 3000 pixels
1530 'int,0,3000', # 0 pixels - 3000 pixels
1536 'actionswin_height',
1539 'int,0,3000', # 0 pixels - 3000 pixels
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 'pluginswin_height',
1575 'int,0,3000', # 0 pixels - 3000 pixels
1584 'int,0,3000', # 0 pixels - 3000 pixels
1593 'int,0,3000', # 0 pixels - 3000 pixels
1599 'print_previewwin_width',
1602 'int,0,3000', # 0 pixels - 3000 pixels
1608 'print_previewwin_height',
1611 'int,0,3000', # 0 pixels - 3000 pixels
1618 sub new_winpos_subpage_main() {
1619 return &new_subpage_frame (
1620 &new_vbox_pack_compact (
1622 &new_text_box_for_int (\%pr::win, 'main_x'),
1623 &new_text_box_for_int (\%pr::win, 'main_y')),
1625 &new_text_box_for_int (\%pr::win, 'main_w'),
1626 &new_text_box_for_int (\%pr::win, 'main_h')),
1628 &new_check_button_for (\%pr::win, 'main_fs'),
1629 &new_check_button_for (\%pr::win, 'main_mx'))),
1634 sub new_winpos_subpage_msgs() {
1635 return &new_subpage_frame (
1636 &new_vbox_pack_compact (
1638 &new_text_box_for_int (\%pr::win, 'msgs_x'),
1639 &new_text_box_for_int (\%pr::win, 'msgs_y')),
1641 &new_text_box_for_int (\%pr::win, 'msgs_w'),
1642 &new_text_box_for_int (\%pr::win, 'msgs_h'))),
1647 sub new_winpos_subpage_sendrecv() {
1648 return &new_vbox_pack (
1649 &new_subpage_frame (
1651 &new_text_box_for_int (\%pr::win, 'send_w'),
1652 &new_text_box_for_int (\%pr::win, 'send_h')),
1653 _('Send window'), 'not-packed'),
1654 &new_subpage_frame (
1656 &new_text_box_for_int (\%pr::win, 'recv_w'),
1657 &new_text_box_for_int (\%pr::win, 'recv_h')),
1658 _('Receive window'), 'not-packed')
1662 sub new_winpos_subpage_fold() {
1663 return &new_vbox_pack (
1664 &new_subpage_frame (
1665 &new_vbox_pack_compact (
1667 &new_text_box_for_int (\%pr::win, 'fold_x'),
1668 &new_text_box_for_int (\%pr::win, 'fold_y')),
1670 &new_text_box_for_int (\%pr::win, 'fold_w'),
1671 &new_text_box_for_int (\%pr::win, 'fold_h'))),
1672 _('Folder window'), 'not-packed'),
1673 &new_subpage_frame (
1675 &new_text_box_for_int (\%pr::win, 'fsel_w'),
1676 &new_text_box_for_int (\%pr::win, 'fsel_h')),
1677 _('Folder selection window'), 'not-packed')
1681 sub new_winpos_subpage_addrbook() {
1682 return &new_vbox_pack (
1683 &new_subpage_frame (
1685 &new_text_box_for_int (\%pr::win, 'addr_w'),
1686 &new_text_box_for_int (\%pr::win, 'addr_h')),
1687 _('Addressbook main window'), 'not-packed'),
1688 &new_subpage_frame (
1690 &new_text_box_for_int (\%pr::win, 'adep_w'),
1691 &new_text_box_for_int (\%pr::win, 'adep_h')),
1692 _('Edit person window'), 'not-packed'),
1693 &new_subpage_frame (
1695 &new_text_box_for_int (\%pr::win, 'adeg_w'),
1696 &new_text_box_for_int (\%pr::win, 'adeg_h')),
1697 _('Edit group window'), 'not-packed'),
1698 &new_subpage_frame (
1700 &new_text_box_for_int (\%pr::win, 'adda_w'),
1701 &new_text_box_for_int (\%pr::win, 'adda_h')),
1702 _('Add address window'), 'not-packed'),
1703 &new_subpage_frame (
1705 &new_text_box_for_int (\%pr::win, 'addf_w'),
1706 &new_text_box_for_int (\%pr::win, 'addf_h')),
1707 _('Folder select window'), 'not-packed')
1711 sub new_winpos_subpage_accounts() {
1712 return &new_vbox_pack (
1713 &new_subpage_frame (
1715 &new_text_box_for_int (\%pr::win, 'acco_w'),
1716 &new_text_box_for_int (\%pr::win, 'acco_h')),
1717 _('Accounts window'), 'not-packed'),
1718 &new_subpage_frame (
1720 &new_text_box_for_int (\%pr::win, 'acce_w'),
1721 &new_text_box_for_int (\%pr::win, 'acce_h')),
1722 _('Edit account window'), 'not-packed')
1726 sub new_winpos_subpage_filtering() {
1727 return &new_vbox_pack (
1728 &new_subpage_frame (
1730 &new_text_box_for_int (\%pr::win, 'filt_w'),
1731 &new_text_box_for_int (\%pr::win, 'filt_h')),
1732 _('Filtering window'), 'not-packed'),
1733 &new_subpage_frame (
1735 &new_text_box_for_int (\%pr::win, 'fila_w'),
1736 &new_text_box_for_int (\%pr::win, 'fila_h')),
1737 _('Filtering actions window'), 'not-packed'),
1738 &new_subpage_frame (
1740 &new_text_box_for_int (\%pr::win, 'fild_w'),
1741 &new_text_box_for_int (\%pr::win, 'fild_h')),
1742 _('Filtering debug window'), 'not-packed'),
1743 &new_subpage_frame (
1745 &new_text_box_for_int (\%pr::win, 'matc_w'),
1746 &new_text_box_for_int (\%pr::win, 'matc_h')),
1747 _('Matcher window'), 'not-packed')
1751 sub new_winpos_subpage_prefs() {
1752 return &new_vbox_pack (
1753 &new_subpage_frame (
1755 &new_text_box_for_int (\%pr::win, 'pref_w'),
1756 &new_text_box_for_int (\%pr::win, 'pref_h')),
1757 _('Preferences window'), 'not-packed'),
1758 &new_subpage_frame (
1760 &new_text_box_for_int (\%pr::win, 'temp_w'),
1761 &new_text_box_for_int (\%pr::win, 'temp_h')),
1762 _('Templates window'), 'not-packed'),
1763 &new_subpage_frame (
1765 &new_text_box_for_int (\%pr::win, 'acti_w'),
1766 &new_text_box_for_int (\%pr::win, 'acti_h')),
1767 _('Actions window'), 'not-packed'),
1768 &new_subpage_frame (
1770 &new_text_box_for_int (\%pr::win, 'tags_w'),
1771 &new_text_box_for_int (\%pr::win, 'tags_h')),
1772 _('Tags window'), 'not-packed'),
1773 &new_subpage_frame (
1775 &new_text_box_for_int (\%pr::win, 'plug_w'),
1776 &new_text_box_for_int (\%pr::win, 'plug_h')),
1777 _('Plugins window'), 'not-packed')
1781 sub new_winpos_subpage_misc() {
1782 return &new_vbox_pack (
1783 &new_subpage_frame (
1785 &new_text_box_for_int (\%pr::win, 'logw_w'),
1786 &new_text_box_for_int (\%pr::win, 'logw_h')),
1787 _('Log window'), 'not-packed'),
1788 &new_subpage_frame (
1790 &new_text_box_for_int (\%pr::win, 'prin_w'),
1791 &new_text_box_for_int (\%pr::win, 'prin_h')),
1792 _('Print preview window'), 'not-packed'),
1793 &new_subpage_frame (
1795 &new_text_box_for_int (\%pr::win, 'sour_w'),
1796 &new_text_box_for_int (\%pr::win, 'sour_h')),
1797 _('View source window'), 'not-packed')
1801 sub new_winpos_page() {
1802 my $winbook = Gtk2::Notebook->new;
1803 $winbook->set_tab_pos ('right');
1804 $winbook->append_page (&new_winpos_subpage_main, _('Main'));
1805 $winbook->append_page (&new_winpos_subpage_msgs, _('Message'));
1806 $winbook->append_page (&new_winpos_subpage_sendrecv, _('Send/Receive'));
1807 $winbook->append_page (&new_winpos_subpage_fold, _('Folder'));
1808 $winbook->append_page (&new_winpos_subpage_addrbook, _('Addressbook'));
1809 $winbook->append_page (&new_winpos_subpage_accounts, _('Accounts'));
1810 $winbook->append_page (&new_winpos_subpage_filtering, _('Filtering'));
1811 $winbook->append_page (&new_winpos_subpage_prefs, _('Preferences'));
1812 $winbook->append_page (&new_winpos_subpage_misc, _('Other'));
1817 sub print_version() {
1818 print $xl::s{about_title} . "\n";
1819 print $xl::s{about_version} . " $VERSION\n";
1820 print "Perl-GLib " . $Glib::VERSION;
1821 # version info stuff appeared in 1.040
1822 if ($Glib::VERSION >= 1.040) {
1823 print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
1824 . _(", running with ") . join(".", &Glib::major_version,
1825 &Glib::minor_version, &Glib::micro_version);
1828 print "Perl-GTK2 " . $Gtk2::VERSION;
1829 if ($Gtk2::VERSION >= 1.040) {
1830 print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
1831 . _(", running with ") . join(".", &Gtk2::major_version,
1832 &Gtk2::minor_version, &Gtk2::micro_version);
1835 my $clawsver = ($CLAWSV eq "") ?
1836 _("was not found!") :
1837 (_("returned version ") . $CLAWSV);
1838 print "Claws Mail " . $clawsver . "\n";
1841 # the command line help
1843 my $line = '-' x length ($xl::s{about_title}) . "\n";
1845 print $xl::s{about_title} . "\n";
1847 print _("Syntax:\n");
1848 print _(" clawsker [options]\n");
1849 print _("Options:\n");
1850 print _(" --help Prints this help screen.\n");
1851 print _(" --version Prints version infos.\n");
1852 print _(" --verbose More messages on standard output.\n");
1853 print _(" --alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
1854 print _(" --clawsrc <file> Uses <file> as full resource name.\n");
1857 # handle errors which don't allow to run
1858 sub command_line_fatal() {
1860 my $emsg = $xl::s{e_error} . $reason;
1861 error_dialog ($emsg);
1862 log_message ("$emsg", 'die');
1865 # parse the command line
1866 sub parse_command_line() {
1867 $CLAWSV = &get_claws_version;
1869 while (defined($ARGV[$arg])) {
1883 /--use-claws-version/ && do {
1885 &command_line_fatal ("required version")
1886 unless defined($ARGV[$arg]);
1887 &command_line_fatal ("required a dotted numeric value")
1888 unless ($ARGV[$arg] =~ /[\d\.]+/);
1889 $CLAWSV = $ARGV[$arg];
1892 /--alternate-config-dir/ && do {
1894 &command_line_fatal ($xl::s{e_requireddir})
1895 unless defined($ARGV[$arg]);
1896 &command_line_fatal ($xl::s{e_notadir})
1897 unless -d $ARGV[$arg];
1898 $CONFIGDIR = $ARGV[$arg];
1900 unless ($CONFIGDIR =~ /.*\/$/);
1901 $ALTCONFIGDIR = TRUE;
1906 &command_line_fatal($xl::s{e_requiredfile})
1907 unless defined($ARGV[$arg]);
1908 &command_line_fatal($xl::s{e_notafile})
1909 unless -f $ARGV[$arg];
1910 &set_rc_filename ($ARGV[$arg]);
1913 /.*/ && &command_line_fatal (
1914 _("unknown option '{opt}'.\n", opt => $ARGV[$arg]));
1918 # eveything continues...
1922 # update the hidden preferences status from loaded values
1923 sub init_hidden_preferences() {
1924 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
1925 foreach my $key (keys %$hash) {
1926 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
1932 # load current status from disc
1933 sub load_preferences() {
1934 my $rc = &get_rc_filename;
1935 &log_message ("Loading preferences from $rc\n");
1936 return FALSE unless &check_rc_file ($rc);
1937 return FALSE unless &check_claws_not_running;
1941 if (/^([8a-z_]+)=(.*)$/) {
1949 # save current preferences to disc
1950 sub save_preferences() {
1951 my $rc = &get_rc_filename;
1952 &log_message ("Saving preferences to $rc\n");
1953 return FALSE unless &check_rc_file ($rc);
1954 return FALSE unless &check_claws_not_running;
1955 my $rcbak = "$rc.backup";
1956 rename ($rc, $rcbak);
1958 open (RCB, "<$rcbak");
1961 if (/^([8a-z_]+)=(.*)$/) {
1962 if (defined($HPVALUE{$1})) {
1963 print RCF $1 . "=" . $HPVALUE{$1} . "\n";
1966 print RCF $_ . "\n";
1970 print RCF $_ . "\n";
1979 sub new_notebook() {
1980 my $nb = Gtk2::Notebook->new;
1982 $nb->append_page (&new_behaviour_page, $xl::s{tab_behaviour});
1983 $nb->append_page (&new_colours_page, $xl::s{tab_colours});
1984 $nb->append_page (&new_gui_page, $xl::s{tab_gui});
1985 $nb->append_page (&new_other_page, $xl::s{tab_other});
1986 $nb->append_page (&new_winpos_page, $xl::s{tab_winpos});
1991 # create an about dialog
1992 sub new_about_dialog() {
1994 my $title = $xl::s{about_title};
1995 my $lic = $xl::s{about_license};
1996 my $vers = $xl::s{about_version} . " $VERSION";
1998 "This program is free software: you can redistribute it and/or modify
1999 it under the terms of the GNU General Public License as published by
2000 the Free Software Foundation, either version 3 of the License, or
2001 (at your option) any later version.
2003 This program is distributed in the hope that it will be useful,
2004 but WITHOUT ANY WARRANTY; without even the implied warranty of
2005 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2006 GNU General Public License for more details.
2008 You should have received a copy of the GNU General Public License
2009 along with this program. If not, see <http://www.gnu.org/licenses/>.";
2010 my $year = "2007-2013";
2011 my $holder = "Ricardo Mones <ricardo\@mones.org>";
2012 my $url = "http://www.claws-mail.org/clawsker.php";
2014 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
2015 [qw/modal destroy-with-parent/],
2017 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
2018 . "<span size=\"large\">$vers</span>\n\n"
2019 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2020 . "<span>Copyright $year by $holder</span>\n\n"
2021 . "<span size=\"large\">$lic</span>\n\n"
2022 . "<span size=\"small\">$license</span>");
2023 $dialog->set_title ($xl::s{about});
2028 # create buttons box
2029 sub new_button_box() {
2030 my ($parent, $adlg) = @_;
2031 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2032 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2033 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2034 # disable button until is really implemented
2035 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2036 my $hbox = Gtk2::HBox->new (FALSE, 5);
2038 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2039 $b_apply->signal_connect (clicked => sub { &save_preferences ($parent) });
2040 # $b_undo->signal_connect (clicked => sub { &undo_current_changes });
2041 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2043 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2044 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2045 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2046 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2052 $main_window = Gtk2::Window->new ('toplevel');
2053 exit unless &parse_command_line;
2054 exit unless &load_preferences;
2055 exit unless &init_hidden_preferences;
2057 my $box = Gtk2::VBox->new (FALSE, 5);
2058 $box->set_border_width(3);
2059 my $about = &new_about_dialog;
2060 $box->pack_start (&new_notebook, FALSE, FALSE, 0);
2061 $box->pack_end (&new_button_box ($main_window, $about), FALSE, FALSE, 0);
2062 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2063 $main_window->set_title ($xl::s{win_title});
2064 $main_window->add ($box);
2065 $main_window->show_all;