3 # Clawsker :: A Claws Mail Tweaker
7 use Glib qw(TRUE FALSE);
9 use POSIX qw(setlocale);
13 my $NAME = 'clawsker';
14 my $PREFIX = '@PREFIX@';
15 my $LIBDIR = '@LIBDIR@';
16 my $VERSION = '@VERSION@';
19 my $main_window = undef;
21 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
22 $locale = "C" unless defined($locale);
23 setlocale (LC_ALL, $locale);
24 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
27 my $SHOWHINTS = FALSE;
28 $SHOWHINTS = TRUE if ($Gtk2::VERSION >= 1.040 and Gtk2->CHECK_VERSION (2, 12, 0));
33 my $xla = gettext ($str);
34 if (scalar(keys(%par)) > 0) {
35 foreach my $key (keys %par) {
36 $xla =~ s/\{$key\}/$par{$key}/g;
39 return decode_utf8($xla);
44 win_title => _('Claws Mail Hidden Preferences'),
45 about => _('About...'),
46 about_title => _('Clawsker :: A Claws Mail Tweaker'),
47 about_license => _('License:'),
48 about_version => _('Version:'),
50 tab_colours => _('Colours'),
51 tab_behaviour => _('Behaviour'),
53 tab_other => _('Other'),
54 tab_winpos => _('Windows'),
56 ab_frame => _('Addressbook'),
57 mem_frame => _('Memory'),
58 msgview_frame => _('Message View'),
59 log_frame => _('Log window'),
60 dnd_frame => _('Drag \'n\' drop'),
61 ssl_frame => _('Secure Sockets Layer'),
62 msgs_frame => _('Messages'),
63 stripes_frame => _('Coloured stripes'),
64 sbar_frame => _('Scroll bars'),
65 mlist_frame => _('Message List'),
66 mview_frame => _('Message View'),
67 compo_frame => _('Compose window'),
68 netm_frame => _('NetworkManager'),
69 diff_frame => _('Viewing patches'),
71 l_oth_use_dlg => _('Use detached address book edit dialogue'),
72 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.'),
73 l_oth_max_use => _('Maximum memory for message cache (kB)'),
74 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
75 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
76 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.'),
77 l_oth_use_netm => _('Use NetworkManager'),
78 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
80 l_gui_b_unread => _('Show unread messages with bold font'),
81 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
82 l_gui_no_markup => _('Don\'t use markup in compose window'),
83 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
84 l_gui_dot_lines => _('Use dotted lines in tree view components'),
85 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.'),
86 l_gui_h_scroll => _('Enable horizontal scrollbar'),
87 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
88 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
89 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.'),
90 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
91 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
92 l_gui_v_scroll_show => _('Show always'),
93 l_gui_v_scroll_auto => _('Automatic'),
94 l_gui_v_scroll_hide => _('Hide always'),
95 l_gui_from_show => _('From column displays'),
96 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both'),
97 l_gui_from_show_name => _('Name only'),
98 l_gui_from_show_addr => _('Address only'),
99 l_gui_from_show_both => _('Both name and address'),
100 l_gui_strip_off => _('Coloured lines contrast'),
101 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.'),
102 l_gui_cursor_v => _('Show cursor'),
103 h_gui_cursor_v => _('Display the cursor in the Message View.'),
104 l_gui_toolbar_d => _('Detachable toolbars'),
105 h_gui_toolbar_d => _('Show handles in the toolbars.'),
106 l_gui_strip_all => _('Use stripes in all tree view components'),
107 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
108 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
109 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
110 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
111 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
112 l_gui_margin_co => _('Show compose margin'),
113 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
114 l_gui_mview_date => _('Don\'t display localized date'),
115 h_gui_mview_date => _('Toggles localization of date format in Message View'),
116 l_gui_zero_char => _('Zero replacement character'),
117 h_gui_zero_char => _('Replaces \'0\' with the given character in Folder List'),
119 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
120 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.'),
121 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
122 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
123 l_beh_flowed => _('Respect format=flowed in messages'),
124 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.'),
125 l_beh_parts_rw => _('Allow writable temporary files'),
126 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
127 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
128 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
129 l_beh_up_step => _('Progress bar update step (items)'),
130 h_beh_up_step => _('Update stepping in progress bars.'),
131 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
132 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
133 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
134 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
135 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
136 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
137 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
138 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
139 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
140 h_beh_out_ascii => _('If content allows, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is enforced always.'),
141 l_beh_pp_unsel => _('Primary paste unselects selection'),
142 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
143 l_beh_inline_at => _('Show inline attachments'),
144 h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view'),
146 l_col_emphasis => _('X-Mailer header'),
147 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
148 l_col_log_err => _('Error messages'),
149 h_col_log_err => _('Colour for error messages in log window.'),
150 l_col_log_in => _('Server messages'),
151 h_col_log_in => _('Colour for messages received from servers in log window.'),
152 l_col_log_msg => _('Standard messages'),
153 h_col_log_msg => _('Colour for messages in log window.'),
154 l_col_log_out => _('Client messages'),
155 h_col_log_out => _('Colour for messages sent to servers in log window.'),
156 l_col_log_warn => _('Warnings'),
157 h_col_log_warn => _('Colour for warning messages in log window.'),
159 l_col_diff_add => _('Added lines'),
160 h_col_diff_add => _('Colour for added lines in patches.'),
161 l_col_diff_del => _('Deleted lines'),
162 h_col_diff_del => _('Colour for deleted lines in patches.'),
163 l_col_diff_hunk => _('Hunk lines'),
164 h_col_diff_hunk => _('Color for hunk headers in patches.'),
166 l_win_x => _('X position'),
167 h_win_x => _('X coordinate for window\'s top-left corner.'),
168 l_win_y => _('Y position'),
169 h_win_y => _('Y coordinate for window\'s top-left corner.'),
170 l_win_w => _('Width'),
171 h_win_w => _('Window\'s width in pixels.'),
172 l_win_h => _('Height'),
173 h_win_h => _('Window\'s height in pixels.'),
175 l_win_main_mx => _('Maximized'),
176 h_win_main_mx => _('Changes window maximized status.'),
177 l_win_main_fs => _('Full-screen'),
178 h_win_main_fs => _('Changes full screen status.'),
180 e_error => _('Error: '),
181 e_noclawsrc => _('resource file for Claws Mail was not found.'),
182 e_running => _('seems Claws Mail is currently running, close it first.'),
183 e_requireddir => _('option requires a directory name.'),
184 e_requiredfile => _('option requires a file name.'),
185 e_notadir => _('specified name is not a directory or does not exist.'),
186 e_notafile => _('specified name is not a file or does not exist.'),
189 # all preferences read by load_preferences
191 # values of all preferences handled by clawsker
193 # default config dir and file name
194 my $ALTCONFIGDIR = FALSE;
195 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
196 my $CONFIGRC = 'clawsrc';
198 # index constants for preference arrays
199 use constant NAME => 0; # the name on the rc file
200 use constant LABEL => 1; # the label on the GUI
201 use constant DESC => 2; # the description for the hint/help
202 use constant TYPE => 3; # data type: bool, int, float, string, color
203 use constant CMVER => 4; # lowest Claws Mail version the feature exists
204 use constant CMDEF => 5; # default value for the preference in Claws Mail
205 use constant GUI => 6; # GUI element
207 # constants for GUI spacing
208 use constant HBOX_SPC => 5;
209 use constant FRAME_SPC => 2;
210 use constant PAGE_SPC => 5;
214 sub version_greater_or_equal() {
215 my ($version, $refvers) = @_;
216 my @version = split (/\./, $version);
217 my @refvers = split (/\./, $refvers);
218 while ($#version < $#refvers) {
219 push (@version, '0');
222 while (($idx <= $#refvers)
223 and (int ($version[$idx]) == int ($refvers[$idx]))) {
226 return TRUE if (($idx > $#refvers)
227 or (int ($version[$idx]) >= int ($refvers[$idx])));
231 sub get_claws_version() {
236 foreach my $bin (@cmbin) {
241 return "" unless ($_); # not installed
244 my @fver = split (/ /);
245 die "Invalid version string" unless ($fver[2] eq "version");
246 my @ver = split (/\./, $fver[3]);
249 if ($ver[2] =~ /(\d+)cvs(\d+)/) {
258 # data handlers and auxiliar functions
260 sub handle_bool_value {
261 my ($widget, $event, $dataref) = @_;
262 $$dataref = ($widget->get_active ())? '1': '0';
265 sub handle_int_value {
266 my ($widget, $event, $dataref) = @_;
267 $_ = $widget->get_text ();
272 $widget->set_text ($_);
275 $widget->set_text ($$dataref);
279 sub handle_string_value {
280 my ($widget, $event, $dataref) = @_;
281 $$dataref = $widget->get_text ();
284 sub handle_nchar_value {
285 my ($widget, $event, $dataref, $minlen) = @_;
286 $_ = substr ($widget->get_text (), 0, $minlen);
287 $widget->set_text ($_);
291 sub gdk_color_from_str {
293 my ($rr, $gg, $bb) = (0, 0 ,0);
295 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
300 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
304 sub str_from_gdk_color {
306 my $rr = $color->red / 256;
307 my $gg = $color->green / 256;
308 my $bb = $color->blue / 256;
309 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
313 sub handle_color_value {
314 my ($widget, $event, $dataref) = @_;
315 my $newcol = $widget->get_color;
316 $$dataref = &str_from_gdk_color ($newcol);
319 sub handle_selection_value {
320 my ($widget, $event, $dataref) = @_;
321 $$dataref = $widget->get_active;
324 sub get_rc_filename {
325 return $CONFIGDIR . $CONFIGRC;
328 sub set_rc_filename {
330 my @parts = split ('/', $fullname);
331 $CONFIGRC = $parts[$#parts];
332 $parts[$#parts] = '';
333 $CONFIGDIR = join ('/', @parts);
337 my ($mesg, $fatal) = @_;
338 if (defined($fatal) && $fatal eq 'die') {
339 die "$NAME: $mesg\n";
342 print "$NAME: $mesg\n";
348 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
349 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
350 $errordlg->set_title (_('Error message'));
355 sub check_claws_not_running() {
356 my $socket = (not $ALTCONFIGDIR)? "/tmp/": $CONFIGDIR;
357 $socket .= "claws-mail-$<";
359 my $emsg = "$xl::s{e_error}$xl::s{e_running}";
361 error_dialog ($emsg);
367 sub check_rc_file() {
369 (defined($rcfile) && -f $rcfile) or do {
370 my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
372 error_dialog ($emsg);
378 sub set_widget_hint() {
380 my ($wdgt, $hint) = @_;
381 $wdgt->set_tooltip_text ($hint);
382 $wdgt->set_has_tooltip (TRUE);
386 sub set_widget_sens() {
387 my ($wdgt, $minver) = @_;
388 $wdgt->set_sensitive (&version_greater_or_equal ($CLAWSV, $minver));
391 # graphic element creation
393 sub new_check_button_for {
394 my ($hash, $key) = @_;
395 my $name = $$hash{$key}[NAME];
396 my $label = $$hash{$key}[LABEL];
398 my $hbox = Gtk2::HBox->new (FALSE, 5);
399 my $cb = Gtk2::CheckButton->new ($label);
400 $$hash{$key}[GUI] = $cb;
401 if (defined ($HPVALUE{$name})) {
402 $cb->set_active ($HPVALUE{$name} eq '1');
404 $cb->signal_connect (clicked => sub {
406 &handle_bool_value($w, $e, \$HPVALUE{$name});
408 &set_widget_hint ($cb, $$hash{$key}[DESC]);
409 &set_widget_sens ($cb, $$hash{$key}[CMVER]);
410 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
415 sub new_text_box_for_int {
416 my ($hash, $key) = @_;
417 my $name = $$hash{$key}[NAME];
418 my $label = $$hash{$key}[LABEL];
419 my @type = split (/,/, $$hash{$key}[TYPE]);
420 push (@type, 0), push (@type, 10000) unless ($#type > 0);
422 my $hbox = Gtk2::HBox->new (FALSE, 5);
423 my $glabel = Gtk2::Label->new ($label);
424 my $pagei = int (($type[2] - $type[1]) / 10);
425 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
426 $gentry->set_numeric (TRUE);
427 $gentry->set_value ($HPVALUE{$name});
428 $$hash{$key}[GUI] = $gentry;
429 $gentry->signal_connect('value-changed' => sub {
431 &handle_int_value($w, $e, \$HPVALUE{$name});
433 &set_widget_hint ($gentry, $$hash{$key}[DESC]);
434 &set_widget_sens ($gentry, $$hash{$key}[CMVER]);
435 $glabel->set_sensitive ($gentry->sensitive);
436 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
437 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
442 sub new_text_box_for_nchar {
443 my ($hash, $key) = @_;
444 my $name = $$hash{$key}[NAME];
445 my $label = $$hash{$key}[LABEL];
446 my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen
447 my $hbox = Gtk2::HBox->new (FALSE, 5);
448 my $glabel = Gtk2::Label->new ($label);
449 my $gentry = Gtk2::Entry->new ();
450 $gentry->set_max_length($type[2]) if defined ($type[2]);
451 $gentry->set_width_chars(int ($type[2]) + 2) if defined ($type[2]);
452 $gentry->set_text ($HPVALUE{$name});
453 $$hash{$key}[GUI] = $gentry;
454 $gentry->signal_connect('key-release-event' => sub {
456 &handle_nchar_value($w, $e, \$HPVALUE{$name}, $type[1]);
458 &set_widget_hint ($gentry, $$hash{$key}[DESC]);
459 &set_widget_sens ($gentry, $$hash{$key}[CMVER]);
460 $glabel->set_sensitive ($gentry->sensitive);
461 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
462 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
467 sub new_color_button_for {
468 my ($hash, $key) = @_;
469 my $name = $$hash{$key}[NAME];
470 my $label = $$hash{$key}[LABEL];
472 my $col = &gdk_color_from_str ($HPVALUE{$name});
473 my $hbox = Gtk2::HBox->new (FALSE, 5);
474 my $glabel = Gtk2::Label->new ($label);
475 my $button = Gtk2::ColorButton->new_with_color ($col);
476 $$hash{$key}[GUI] = $button;
477 $button->set_title ($label);
478 $button->set_relief ('none');
479 $button->signal_connect ('color-set' => sub {
481 &handle_color_value($w, $e, \$HPVALUE{$name});
483 &set_widget_hint ($button, $$hash{$key}[DESC]);
484 &set_widget_sens ($button, $$hash{$key}[CMVER]);
485 $glabel->set_sensitive ($button->sensitive);
486 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
487 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
492 sub new_selection_box_for {
493 my ($hash, $key) = @_;
494 my $name = $$hash{$key}[NAME];
495 my $label = $$hash{$key}[LABEL];
497 my $hbox = Gtk2::HBox->new (FALSE, 5);
498 my $glabel = Gtk2::Label->new ($label);
499 my $combo = Gtk2::ComboBox->new_text;
500 $$hash{$key}[GUI] = $combo;
501 my @options = split (';', $$hash{$key}[TYPE]);
502 foreach my $opt (@options) {
503 my ($index, $textkey) = split ('=', $opt);
504 $combo->insert_text ($index, $xl::s{$textkey});
506 $combo->signal_connect ('changed' => sub {
508 &handle_selection_value($w, $e, \$HPVALUE{$name});
510 $combo->set_active ($HPVALUE{$name});
511 &set_widget_hint ($combo, $$hash{$key}[DESC]);
512 &set_widget_sens ($combo, $$hash{$key}[CMVER]);
513 $glabel->set_sensitive ($combo->sensitive);
514 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
515 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
520 # more graphic helpers
522 sub new_hbox_pack() {
523 my $hbox = Gtk2::HBox->new (FALSE, 5);
524 $hbox->set_border_width (PAGE_SPC);
525 foreach my $item (@_) {
526 $hbox->pack_start ($item, FALSE, FALSE, 0);
531 sub new_vbox_pack() {
532 my $vbox = Gtk2::VBox->new (FALSE, 5);
533 $vbox->set_border_width (PAGE_SPC);
534 foreach my $item (@_) {
535 $vbox->pack_start ($item, FALSE, FALSE, 0);
540 sub new_vbox_pack_compact() {
541 my $vbox = Gtk2::VBox->new (FALSE, 0);
542 $vbox->set_border_width (0);
543 foreach my $item (@_) {
544 $vbox->pack_start ($item, FALSE, FALSE, 0);
549 sub new_subpage_frame () {
550 my ($box, $title, $notpacked) = @_;
551 my $frame = Gtk2::Frame->new ($title);
553 return &new_vbox_pack ($frame) unless defined ($notpacked);
557 # preference maps and corresponding page creation subs
559 %pr::oth = ( # other preferences
561 'addressbook_use_editaddress_dialog',
562 $xl::s{l_oth_use_dlg},
563 $xl::s{h_oth_use_dlg},
570 'cache_max_mem_usage',
571 $xl::s{l_oth_max_use},
572 $xl::s{h_oth_max_use},
573 'int,0,262144', # 0 Kb - 256 Mb
579 'cache_min_keep_time',
580 $xl::s{l_oth_min_time},
581 $xl::s{h_oth_min_time},
582 'int,0,120', # 0 minutes - 2 hours
588 'use_networkmanager',
589 $xl::s{l_oth_use_netm},
590 $xl::s{h_oth_use_netm},
598 sub new_other_page() {
599 return &new_vbox_pack (
602 &new_check_button_for(\%pr::oth, 'use_dlg')),
603 $xl::s{ab_frame}, 'not-packed'),
606 &new_text_box_for_int(\%pr::oth, 'max_use'),
607 &new_text_box_for_int(\%pr::oth, 'min_time')),
608 $xl::s{mem_frame}, 'not-packed'),
611 &new_check_button_for(\%pr::oth, 'use_netm')),
612 $xl::s{netm_frame}, 'not-packed')
616 %pr::gui = ( # gui bells and whistles
619 $xl::s{l_gui_b_unread},
620 $xl::s{h_gui_b_unread},
628 $xl::s{l_gui_no_markup},
629 $xl::s{h_gui_no_markup},
636 'enable_dotted_lines',
637 $xl::s{l_gui_dot_lines},
638 $xl::s{h_gui_dot_lines},
646 $xl::s{l_gui_h_scroll},
647 $xl::s{h_gui_h_scroll},
655 $xl::s{l_gui_swp_from},
656 $xl::s{h_gui_swp_from},
663 'folderview_vscrollbar_policy',
664 $xl::s{l_gui_v_scroll},
665 $xl::s{h_gui_v_scroll},
666 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
673 $xl::s{l_gui_from_show},
674 $xl::s{h_gui_from_show},
675 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
681 'stripes_color_offset',
682 $xl::s{l_gui_strip_off},
683 $xl::s{h_gui_strip_off},
684 'int,0,40000', # no idea what this number means
690 'textview_cursor_visible',
691 $xl::s{l_gui_cursor_v},
692 $xl::s{h_gui_cursor_v},
699 'toolbar_detachable',
700 $xl::s{l_gui_toolbar_d},
701 $xl::s{h_gui_toolbar_d},
708 'use_stripes_everywhere',
709 $xl::s{l_gui_strip_all},
710 $xl::s{h_gui_strip_all},
717 'use_stripes_in_summaries',
718 $xl::s{l_gui_strip_sum},
719 $xl::s{h_gui_strip_sum},
727 $xl::s{l_gui_two_line_v},
728 $xl::s{h_gui_two_line_v},
735 'show_compose_margin',
736 $xl::s{l_gui_margin_co},
737 $xl::s{h_gui_margin_co},
744 'msgview_date_format',
745 $xl::s{l_gui_mview_date},
746 $xl::s{h_gui_mview_date},
753 'zero_replacement_char',
754 $xl::s{l_gui_zero_char},
755 $xl::s{h_gui_zero_char},
764 my $gf = Gtk2::VBox->new (FALSE, 5);
765 $gf->set_border_width (PAGE_SPC);
767 my $cb_dot_lines = &new_check_button_for (\%pr::gui, 'dot_lines');
768 my $cb_toolbar_d = &new_check_button_for (\%pr::gui, 'toolbar_d');
769 my $tb_zero_char = &new_text_box_for_nchar (\%pr::gui, 'zero_char');
771 $gf->pack_start (&new_subpage_frame (
773 &new_check_button_for (\%pr::gui, 'strip_all'),
774 &new_check_button_for (\%pr::gui, 'strip_sum'),
775 &new_text_box_for_int (\%pr::gui, 'strip_off')),
776 $xl::s{stripes_frame}, 'not-packed'),
777 FALSE, FALSE, FRAME_SPC);
778 $gf->pack_start (&new_subpage_frame (
780 &new_check_button_for (\%pr::gui, 'b_unread'),
781 &new_check_button_for (\%pr::gui, 'swp_from'),
782 &new_check_button_for (\%pr::gui, 'two_linev'),
783 &new_selection_box_for (\%pr::gui, 'from_show')),
784 $xl::s{mlist_frame}, 'not-packed'),
785 FALSE, FALSE, FRAME_SPC);
786 $gf->pack_start (&new_subpage_frame (
788 &new_check_button_for (\%pr::gui, 'cursor_v'),
789 &new_check_button_for (\%pr::gui, 'mview_date')),
790 $xl::s{mview_frame}, 'not-packed'),
791 FALSE, FALSE, FRAME_SPC);
792 $gf->pack_start (&new_subpage_frame (
794 &new_check_button_for (\%pr::gui, 'no_markup'),
795 &new_check_button_for (\%pr::gui, 'margin_co')),
796 $xl::s{compo_frame}, 'not-packed'),
797 FALSE, FALSE, FRAME_SPC);
798 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
799 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
800 $gf->pack_start (&new_subpage_frame (
802 &new_check_button_for (\%pr::gui, 'h_scroll'),
803 &new_selection_box_for (\%pr::gui, 'v_scroll')),
804 $xl::s{sbar_frame}, 'not-packed'),
805 FALSE, FALSE, FRAME_SPC);
806 $gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
811 %pr::beh = ( # tweak some behaviour
814 $xl::s{l_beh_hover_t},
815 $xl::s{h_beh_hover_t},
816 'int,100,3000', # 0.1 seconds - 3 seconds
823 $xl::s{l_beh_dangerous},
824 $xl::s{h_beh_dangerous},
831 'respect_flowed_format',
832 $xl::s{l_beh_flowed},
833 $xl::s{h_beh_flowed},
840 'save_parts_readwrite',
841 $xl::s{l_beh_parts_rw},
842 $xl::s{h_beh_parts_rw},
849 'skip_ssl_cert_check',
850 $xl::s{l_beh_skip_ssl},
851 $xl::s{h_beh_skip_ssl},
858 'statusbar_update_step',
859 $xl::s{l_beh_up_step},
860 $xl::s{h_beh_up_step},
861 'int,1,200', # 1 item - 200 items
867 'thread_by_subject_max_age',
868 $xl::s{l_beh_thread_a},
869 $xl::s{h_beh_thread_a},
870 'int,1,30', # 1 day - 30 days
877 $xl::s{l_beh_unsafe_ssl},
878 $xl::s{h_beh_unsafe_ssl},
885 'utf8_instead_of_locale_for_broken_mail',
886 $xl::s{l_beh_use_utf8},
887 $xl::s{h_beh_use_utf8},
895 $xl::s{l_beh_warn_dnd},
896 $xl::s{h_beh_warn_dnd},
903 'outgoing_fallback_to_ascii',
904 $xl::s{l_beh_out_ascii},
905 $xl::s{h_beh_out_ascii},
912 'primary_paste_unselects',
913 $xl::s{l_beh_pp_unsel},
914 $xl::s{h_beh_pp_unsel},
921 'show_inline_attachments',
922 $xl::s{l_beh_inline_at},
923 $xl::s{h_beh_inline_at},
931 sub new_behaviour_page() {
932 my $bf = Gtk2::VBox->new (FALSE, 5);
933 $bf->set_border_width (PAGE_SPC);
935 my $tb_up_step = &new_text_box_for_int (\%pr::beh, 'up_step');
936 my $tb_thread_a = &new_text_box_for_int (\%pr::beh, 'thread_a');
938 $bf->pack_start (&new_subpage_frame (
940 &new_text_box_for_int (\%pr::beh, 'hover_t'),
941 &new_check_button_for (\%pr::beh, 'warn_dnd')),
942 $xl::s{dnd_frame}, 'not-packed'),
943 FALSE, FALSE, FRAME_SPC);
944 $bf->pack_start (&new_subpage_frame (
946 &new_check_button_for (\%pr::beh, 'skip_ssl'),
947 &new_check_button_for (\%pr::beh, 'unsafe_ssl')),
948 $xl::s{ssl_frame}, 'not-packed'),
949 FALSE, FALSE, FRAME_SPC);
950 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
951 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
952 $bf->pack_start (&new_subpage_frame (
954 &new_check_button_for (\%pr::beh, 'flowed'),
955 &new_check_button_for (\%pr::beh, 'parts_rw'),
956 &new_check_button_for (\%pr::beh, 'use_utf8'),
957 &new_check_button_for (\%pr::beh, 'dangerous'),
958 &new_check_button_for (\%pr::beh, 'out_ascii'),
959 &new_check_button_for (\%pr::beh, 'pp_unsel'),
960 &new_check_button_for (\%pr::beh, 'inline_at')),
961 $xl::s{msgs_frame}, 'not-packed'),
962 FALSE, FALSE, FRAME_SPC);
967 %pr::col = ( # a variety of colours
970 $xl::s{l_col_emphasis},
971 $xl::s{h_col_emphasis},
979 $xl::s{l_col_log_err},
980 $xl::s{h_col_log_err},
988 $xl::s{l_col_log_in},
989 $xl::s{h_col_log_in},
997 $xl::s{l_col_log_msg},
998 $xl::s{h_col_log_msg},
1006 $xl::s{l_col_log_out},
1007 $xl::s{h_col_log_out},
1015 $xl::s{l_col_log_warn},
1016 $xl::s{h_col_log_warn},
1024 $xl::s{l_col_diff_add},
1025 $xl::s{h_col_diff_add},
1032 'diff_deleted_color',
1033 $xl::s{l_col_diff_del},
1034 $xl::s{h_col_diff_del},
1042 $xl::s{l_col_diff_hunk},
1043 $xl::s{h_col_diff_hunk},
1051 sub new_colours_page() {
1052 return &new_vbox_pack (
1053 &new_subpage_frame (
1055 &new_color_button_for (\%pr::col, 'emphasis')),
1056 $xl::s{msgview_frame}, 'not-packed'),
1057 &new_subpage_frame (
1059 &new_color_button_for (\%pr::col, 'log_err'),
1060 &new_color_button_for (\%pr::col, 'log_in'),
1061 &new_color_button_for (\%pr::col, 'log_msg'),
1062 &new_color_button_for (\%pr::col, 'log_out'),
1063 &new_color_button_for (\%pr::col, 'log_warn')),
1064 $xl::s{log_frame}, 'not-packed'),
1065 &new_subpage_frame (
1067 &new_color_button_for (\%pr::col, 'diff_add'),
1068 &new_color_button_for (\%pr::col, 'diff_del'),
1069 &new_color_button_for (\%pr::col, 'diff_hunk')),
1070 $xl::s{diff_frame}, 'not-packed')
1074 %pr::win = ( # tweak window positions and/or sizes
1079 'int,0,3000', # 0 pixels - 3000 pixels
1088 'int,0,3000', # 0 pixels - 3000 pixels
1097 'int,0,3000', # 0 pixels - 3000 pixels
1106 'int,0,3000', # 0 pixels - 3000 pixels
1112 'mainwin_maximised',
1113 $xl::s{l_win_main_mx},
1114 $xl::s{h_win_main_mx},
1121 'mainwin_fullscreen',
1122 $xl::s{l_win_main_fs},
1123 $xl::s{h_win_main_fs},
1130 'main_messagewin_x',
1133 'int,0,3000', # 0 pixels - 3000 pixels
1139 'main_messagewin_y',
1142 'int,0,3000', # 0 pixels - 3000 pixels
1151 'int,0,3000', # 0 pixels - 3000 pixels
1157 'messagewin_height',
1160 'int,0,3000', # 0 pixels - 3000 pixels
1169 'int,0,3000', # 0 pixels - 3000 pixels
1178 'int,0,3000', # 0 pixels - 3000 pixels
1187 'int,0,3000', # 0 pixels - 3000 pixels
1193 'receivewin_height',
1196 'int,0,3000', # 0 pixels - 3000 pixels
1205 'int,0,3000', # 0 pixels - 3000 pixels
1214 'int,0,3000', # 0 pixels - 3000 pixels
1220 'folderitemwin_width',
1223 'int,0,3000', # 0 pixels - 3000 pixels
1229 'folderitemwin_height',
1232 'int,0,3000', # 0 pixels - 3000 pixels
1238 'folderselwin_width',
1241 'int,0,3000', # 0 pixels - 3000 pixels
1247 'folderselwin_height',
1250 'int,0,3000', # 0 pixels - 3000 pixels
1259 'int,0,3000', # 0 pixels - 3000 pixels
1268 'int,0,3000', # 0 pixels - 3000 pixels
1274 'addressbookwin_width',
1277 'int,0,3000', # 0 pixels - 3000 pixels
1283 'addressbookwin_height',
1286 'int,0,3000', # 0 pixels - 3000 pixels
1292 'addressbookeditpersonwin_width',
1295 'int,0,3000', # 0 pixels - 3000 pixels
1301 'addressbookeditpersonwin_height',
1304 'int,0,3000', # 0 pixels - 3000 pixels
1310 'addressbookeditgroupwin_width',
1313 'int,0,3000', # 0 pixels - 3000 pixels
1319 'addressbookeditgroupwin_height',
1322 'int,0,3000', # 0 pixels - 3000 pixels
1328 'addressaddwin_width',
1331 'int,0,3000', # 0 pixels - 3000 pixels
1337 'addressaddwin_height',
1340 'int,0,3000', # 0 pixels - 3000 pixels
1346 'addressbook_folderselwin_width',
1349 'int,0,3000', # 0 pixels - 3000 pixels
1355 'addressbook_folderselwin_height',
1358 'int,0,3000', # 0 pixels - 3000 pixels
1364 'editaccountwin_width',
1367 'int,0,3000', # 0 pixels - 3000 pixels
1373 'editaccountwin_height',
1376 'int,0,3000', # 0 pixels - 3000 pixels
1382 'accountswin_width',
1385 'int,0,3000', # 0 pixels - 3000 pixels
1391 'accountswin_height',
1394 'int,0,3000', # 0 pixels - 3000 pixels
1400 'filteringwin_width',
1403 'int,0,3000', # 0 pixels - 3000 pixels
1409 'filteringwin_height',
1412 'int,0,3000', # 0 pixels - 3000 pixels
1418 'filteringactionwin_width',
1421 'int,0,3000', # 0 pixels - 3000 pixels
1427 'filteringactionwin_height',
1430 'int,0,3000', # 0 pixels - 3000 pixels
1436 'filtering_debugwin_width',
1439 'int,0,3000', # 0 pixels - 3000 pixels
1445 'filtering_debugwin_height',
1448 'int,0,3000', # 0 pixels - 3000 pixels
1457 'int,0,3000', # 0 pixels - 3000 pixels
1463 'matcherwin_height',
1466 'int,0,3000', # 0 pixels - 3000 pixels
1475 'int,0,3000', # 0 pixels - 3000 pixels
1484 'int,0,3000', # 0 pixels - 3000 pixels
1490 'templateswin_width',
1493 'int,0,3000', # 0 pixels - 3000 pixels
1499 'templateswin_height',
1502 'int,0,3000', # 0 pixels - 3000 pixels
1511 'int,0,3000', # 0 pixels - 3000 pixels
1517 'actionswin_height',
1520 'int,0,3000', # 0 pixels - 3000 pixels
1529 'int,0,3000', # 0 pixels - 3000 pixels
1538 'int,0,3000', # 0 pixels - 3000 pixels
1547 'int,0,3000', # 0 pixels - 3000 pixels
1553 'pluginswin_height',
1556 'int,0,3000', # 0 pixels - 3000 pixels
1565 'int,0,3000', # 0 pixels - 3000 pixels
1574 'int,0,3000', # 0 pixels - 3000 pixels
1580 'print_previewwin_width',
1583 'int,0,3000', # 0 pixels - 3000 pixels
1589 'print_previewwin_height',
1592 'int,0,3000', # 0 pixels - 3000 pixels
1599 sub new_winpos_subpage_main() {
1600 return &new_subpage_frame (
1601 &new_vbox_pack_compact (
1603 &new_text_box_for_int (\%pr::win, 'main_x'),
1604 &new_text_box_for_int (\%pr::win, 'main_y')),
1606 &new_text_box_for_int (\%pr::win, 'main_w'),
1607 &new_text_box_for_int (\%pr::win, 'main_h')),
1609 &new_check_button_for (\%pr::win, 'main_fs'),
1610 &new_check_button_for (\%pr::win, 'main_mx'))),
1615 sub new_winpos_subpage_msgs() {
1616 return &new_subpage_frame (
1617 &new_vbox_pack_compact (
1619 &new_text_box_for_int (\%pr::win, 'msgs_x'),
1620 &new_text_box_for_int (\%pr::win, 'msgs_y')),
1622 &new_text_box_for_int (\%pr::win, 'msgs_w'),
1623 &new_text_box_for_int (\%pr::win, 'msgs_h'))),
1628 sub new_winpos_subpage_sendrecv() {
1629 return &new_vbox_pack (
1630 &new_subpage_frame (
1632 &new_text_box_for_int (\%pr::win, 'send_w'),
1633 &new_text_box_for_int (\%pr::win, 'send_h')),
1634 _('Send window'), 'not-packed'),
1635 &new_subpage_frame (
1637 &new_text_box_for_int (\%pr::win, 'recv_w'),
1638 &new_text_box_for_int (\%pr::win, 'recv_h')),
1639 _('Receive window'), 'not-packed')
1643 sub new_winpos_subpage_fold() {
1644 return &new_vbox_pack (
1645 &new_subpage_frame (
1646 &new_vbox_pack_compact (
1648 &new_text_box_for_int (\%pr::win, 'fold_x'),
1649 &new_text_box_for_int (\%pr::win, 'fold_y')),
1651 &new_text_box_for_int (\%pr::win, 'fold_w'),
1652 &new_text_box_for_int (\%pr::win, 'fold_h'))),
1653 _('Folder window'), 'not-packed'),
1654 &new_subpage_frame (
1656 &new_text_box_for_int (\%pr::win, 'fsel_w'),
1657 &new_text_box_for_int (\%pr::win, 'fsel_h')),
1658 _('Folder selection window'), 'not-packed')
1662 sub new_winpos_subpage_addrbook() {
1663 return &new_vbox_pack (
1664 &new_subpage_frame (
1666 &new_text_box_for_int (\%pr::win, 'addr_w'),
1667 &new_text_box_for_int (\%pr::win, 'addr_h')),
1668 _('Addressbook main window'), 'not-packed'),
1669 &new_subpage_frame (
1671 &new_text_box_for_int (\%pr::win, 'adep_w'),
1672 &new_text_box_for_int (\%pr::win, 'adep_h')),
1673 _('Edit person window'), 'not-packed'),
1674 &new_subpage_frame (
1676 &new_text_box_for_int (\%pr::win, 'adeg_w'),
1677 &new_text_box_for_int (\%pr::win, 'adeg_h')),
1678 _('Edit group window'), 'not-packed'),
1679 &new_subpage_frame (
1681 &new_text_box_for_int (\%pr::win, 'adda_w'),
1682 &new_text_box_for_int (\%pr::win, 'adda_h')),
1683 _('Add address window'), 'not-packed'),
1684 &new_subpage_frame (
1686 &new_text_box_for_int (\%pr::win, 'addf_w'),
1687 &new_text_box_for_int (\%pr::win, 'addf_h')),
1688 _('Folder select window'), 'not-packed')
1692 sub new_winpos_subpage_accounts() {
1693 return &new_vbox_pack (
1694 &new_subpage_frame (
1696 &new_text_box_for_int (\%pr::win, 'acco_w'),
1697 &new_text_box_for_int (\%pr::win, 'acco_h')),
1698 _('Accounts window'), 'not-packed'),
1699 &new_subpage_frame (
1701 &new_text_box_for_int (\%pr::win, 'acce_w'),
1702 &new_text_box_for_int (\%pr::win, 'acce_h')),
1703 _('Edit account window'), 'not-packed')
1707 sub new_winpos_subpage_filtering() {
1708 return &new_vbox_pack (
1709 &new_subpage_frame (
1711 &new_text_box_for_int (\%pr::win, 'filt_w'),
1712 &new_text_box_for_int (\%pr::win, 'filt_h')),
1713 _('Filtering window'), 'not-packed'),
1714 &new_subpage_frame (
1716 &new_text_box_for_int (\%pr::win, 'fila_w'),
1717 &new_text_box_for_int (\%pr::win, 'fila_h')),
1718 _('Filtering actions window'), 'not-packed'),
1719 &new_subpage_frame (
1721 &new_text_box_for_int (\%pr::win, 'fild_w'),
1722 &new_text_box_for_int (\%pr::win, 'fild_h')),
1723 _('Filtering debug window'), 'not-packed'),
1724 &new_subpage_frame (
1726 &new_text_box_for_int (\%pr::win, 'matc_w'),
1727 &new_text_box_for_int (\%pr::win, 'matc_h')),
1728 _('Matcher window'), 'not-packed')
1732 sub new_winpos_subpage_prefs() {
1733 return &new_vbox_pack (
1734 &new_subpage_frame (
1736 &new_text_box_for_int (\%pr::win, 'pref_w'),
1737 &new_text_box_for_int (\%pr::win, 'pref_h')),
1738 _('Preferences window'), 'not-packed'),
1739 &new_subpage_frame (
1741 &new_text_box_for_int (\%pr::win, 'temp_w'),
1742 &new_text_box_for_int (\%pr::win, 'temp_h')),
1743 _('Templates window'), 'not-packed'),
1744 &new_subpage_frame (
1746 &new_text_box_for_int (\%pr::win, 'acti_w'),
1747 &new_text_box_for_int (\%pr::win, 'acti_h')),
1748 _('Actions window'), 'not-packed'),
1749 &new_subpage_frame (
1751 &new_text_box_for_int (\%pr::win, 'tags_w'),
1752 &new_text_box_for_int (\%pr::win, 'tags_h')),
1753 _('Tags window'), 'not-packed'),
1754 &new_subpage_frame (
1756 &new_text_box_for_int (\%pr::win, 'plug_w'),
1757 &new_text_box_for_int (\%pr::win, 'plug_h')),
1758 _('Plugins window'), 'not-packed')
1762 sub new_winpos_subpage_misc() {
1763 return &new_vbox_pack (
1764 &new_subpage_frame (
1766 &new_text_box_for_int (\%pr::win, 'logw_w'),
1767 &new_text_box_for_int (\%pr::win, 'logw_h')),
1768 _('Log window'), 'not-packed'),
1769 &new_subpage_frame (
1771 &new_text_box_for_int (\%pr::win, 'prin_w'),
1772 &new_text_box_for_int (\%pr::win, 'prin_h')),
1773 _('Print preview window'), 'not-packed'),
1774 &new_subpage_frame (
1776 &new_text_box_for_int (\%pr::win, 'sour_w'),
1777 &new_text_box_for_int (\%pr::win, 'sour_h')),
1778 _('View source window'), 'not-packed')
1782 sub new_winpos_page() {
1783 my $winbook = Gtk2::Notebook->new;
1784 $winbook->set_tab_pos ('right');
1785 $winbook->append_page (&new_winpos_subpage_main, _('Main'));
1786 $winbook->append_page (&new_winpos_subpage_msgs, _('Message'));
1787 $winbook->append_page (&new_winpos_subpage_sendrecv, _('Send/Receive'));
1788 $winbook->append_page (&new_winpos_subpage_fold, _('Folder'));
1789 $winbook->append_page (&new_winpos_subpage_addrbook, _('Addressbook'));
1790 $winbook->append_page (&new_winpos_subpage_accounts, _('Accounts'));
1791 $winbook->append_page (&new_winpos_subpage_filtering, _('Filtering'));
1792 $winbook->append_page (&new_winpos_subpage_prefs, _('Preferences'));
1793 $winbook->append_page (&new_winpos_subpage_misc, _('Other'));
1798 sub print_version() {
1799 print $xl::s{about_title} . "\n";
1800 print $xl::s{about_version} . " $VERSION\n";
1801 print "Perl-GLib " . $Glib::VERSION;
1802 # version info stuff appeared in 1.040
1803 if ($Glib::VERSION >= 1.040) {
1804 print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
1805 . _(", running with ") . join(".", &Glib::major_version,
1806 &Glib::minor_version, &Glib::micro_version);
1809 print "Perl-GTK2 " . $Gtk2::VERSION;
1810 if ($Gtk2::VERSION >= 1.040) {
1811 print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
1812 . _(", running with ") . join(".", &Gtk2::major_version,
1813 &Gtk2::minor_version, &Gtk2::micro_version);
1816 my $clawsver = ($CLAWSV eq "") ?
1817 _("was not found!") :
1818 (_("returned version ") . $CLAWSV);
1819 print "Claws Mail " . $clawsver . "\n";
1822 # the command line help
1824 my $line = '-' x length ($xl::s{about_title}) . "\n";
1826 print $xl::s{about_title} . "\n";
1828 print _("Syntax:\n");
1829 print _(" clawsker [options]\n");
1830 print _("Options:\n");
1831 print _(" --help Prints this help screen.\n");
1832 print _(" --version Prints version infos.\n");
1833 print _(" --verbose More messages on standard output.\n");
1834 print _(" --alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
1835 print _(" --clawsrc <file> Uses <file> as full resource name.\n");
1838 # handle errors which don't allow to run
1839 sub command_line_fatal() {
1841 my $emsg = $xl::s{e_error} . $reason;
1842 error_dialog ($emsg);
1843 log_message ("$emsg", 'die');
1846 # parse the command line
1847 sub parse_command_line() {
1848 $CLAWSV = &get_claws_version;
1850 while (defined($ARGV[$arg])) {
1864 /--use-claws-version/ && do {
1866 &command_line_fatal ("required version")
1867 unless defined($ARGV[$arg]);
1868 &command_line_fatal ("required a dotted numeric value")
1869 unless ($ARGV[$arg] =~ /[\d\.]+/);
1870 $CLAWSV = $ARGV[$arg];
1873 /--alternate-config-dir/ && do {
1875 &command_line_fatal ($xl::s{e_requireddir})
1876 unless defined($ARGV[$arg]);
1877 &command_line_fatal ($xl::s{e_notadir})
1878 unless -d $ARGV[$arg];
1879 $CONFIGDIR = $ARGV[$arg];
1881 unless ($CONFIGDIR =~ /.*\/$/);
1882 $ALTCONFIGDIR = TRUE;
1887 &command_line_fatal($xl::s{e_requiredfile})
1888 unless defined($ARGV[$arg]);
1889 &command_line_fatal($xl::s{e_notafile})
1890 unless -f $ARGV[$arg];
1891 &set_rc_filename ($ARGV[$arg]);
1894 /.*/ && &command_line_fatal (
1895 _("unknown option '{opt}'.\n", opt => $ARGV[$arg]));
1899 # eveything continues...
1903 # update the hidden preferences status from loaded values
1904 sub init_hidden_preferences() {
1905 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
1906 foreach my $key (keys %$hash) {
1907 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
1913 # load current status from disc
1914 sub load_preferences() {
1915 my $rc = &get_rc_filename;
1916 &log_message ("Loading preferences from $rc\n");
1917 return FALSE unless &check_rc_file ($rc);
1918 return FALSE unless &check_claws_not_running;
1922 if (/^([8a-z_]+)=(.*)$/) {
1930 # save current preferences to disc
1931 sub save_preferences() {
1932 my $rc = &get_rc_filename;
1933 &log_message ("Saving preferences to $rc\n");
1934 return FALSE unless &check_rc_file ($rc);
1935 return FALSE unless &check_claws_not_running;
1936 my $rcbak = "$rc.backup";
1937 rename ($rc, $rcbak);
1939 open (RCB, "<$rcbak");
1942 if (/^([8a-z_]+)=(.*)$/) {
1943 if (defined($HPVALUE{$1})) {
1944 print RCF $1 . "=" . $HPVALUE{$1} . "\n";
1947 print RCF $_ . "\n";
1951 print RCF $_ . "\n";
1960 sub new_notebook() {
1961 my $nb = Gtk2::Notebook->new;
1963 $nb->append_page (&new_behaviour_page, $xl::s{tab_behaviour});
1964 $nb->append_page (&new_colours_page, $xl::s{tab_colours});
1965 $nb->append_page (&new_gui_page, $xl::s{tab_gui});
1966 $nb->append_page (&new_other_page, $xl::s{tab_other});
1967 $nb->append_page (&new_winpos_page, $xl::s{tab_winpos});
1972 # create an about dialog
1973 sub new_about_dialog() {
1975 my $title = $xl::s{about_title};
1976 my $lic = $xl::s{about_license};
1977 my $vers = $xl::s{about_version} . " $VERSION";
1979 "This program is free software: you can redistribute it and/or modify
1980 it under the terms of the GNU General Public License as published by
1981 the Free Software Foundation, either version 3 of the License, or
1982 (at your option) any later version.
1984 This program is distributed in the hope that it will be useful,
1985 but WITHOUT ANY WARRANTY; without even the implied warranty of
1986 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1987 GNU General Public License for more details.
1989 You should have received a copy of the GNU General Public License
1990 along with this program. If not, see <http://www.gnu.org/licenses/>.";
1991 my $year = "2007-2012";
1992 my $holder = "Ricardo Mones <ricardo\@mones.org>";
1993 my $url = "http://www.claws-mail.org/clawsker.php";
1995 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
1996 [qw/modal destroy-with-parent/],
1998 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
1999 . "<span size=\"large\">$vers</span>\n\n"
2000 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
2001 . "<span>Copyright $year by $holder</span>\n\n"
2002 . "<span size=\"large\">$lic</span>\n\n"
2003 . "<span size=\"small\">$license</span>");
2004 $dialog->set_title ($xl::s{about});
2009 # create buttons box
2010 sub new_button_box() {
2011 my ($parent, $adlg) = @_;
2012 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
2013 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
2014 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
2015 # disable button until is really implemented
2016 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
2017 my $hbox = Gtk2::HBox->new (FALSE, 5);
2019 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
2020 $b_apply->signal_connect (clicked => sub { &save_preferences ($parent) });
2021 # $b_undo->signal_connect (clicked => sub { &undo_current_changes });
2022 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
2024 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
2025 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
2026 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
2027 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
2033 $main_window = Gtk2::Window->new ('toplevel');
2034 exit unless &parse_command_line;
2035 exit unless &load_preferences;
2036 exit unless &init_hidden_preferences;
2038 my $box = Gtk2::VBox->new (FALSE, 5);
2039 $box->set_border_width(3);
2040 my $about = &new_about_dialog;
2041 $box->pack_start (&new_notebook, FALSE, FALSE, 0);
2042 $box->pack_end (&new_button_box ($main_window, $about), FALSE, FALSE, 0);
2043 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
2044 $main_window->set_title ($xl::s{win_title});
2045 $main_window->add ($box);
2046 $main_window->show_all;