10 Clawsker - A Claws Mail Tweaker
18 Clawsker is an applet to edit the so called Claws Mail hidden preferences.
20 Claws Mail is a fast, lightweight and feature-rich MUA with a high number
21 of configurable options. To keep the binary small and fast some of these
22 preferences which are not widely used are not provided with a graphical
23 interface for inspection and/or modification.
25 Users wanting to edit such preferences had to face raw editing of their
26 configuration files, now you can do it with a convenient GTK2 interface
32 Shows a brief help screen.
34 --alternate-config-dir <dir>
35 Uses <dir> as Claws Mail configuration dir.
38 Uses <file> as Claws Mail resource configuration file. This sets
39 the full file name overriding any previous setting.
41 Multiple options are allowed, although only the last one has effect. Weird
42 option specifications may produce weird results (but otherwise correct).
46 A running Claws Mail cannot be detected if using the --clawsrc option because
47 the directory is not assumed to be a Claws Mail configuration dir. If that is
48 the case the --alternate-config-dir option instead.
52 Ricardo Mones E<lt>ricardo@mones.orgE<gt>
56 Copyright (c) 2007 by Ricardo Mones
58 This program is free software: you can redistribute it and/or modify
59 it under the terms of the GNU General Public License as published by
60 the Free Software Foundation, either version 3 of the License, or
61 (at your option) any later version.
63 This program is distributed in the hope that it will be useful,
64 but WITHOUT ANY WARRANTY; without even the implied warranty of
65 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66 GNU General Public License for more details.
68 You should have received a copy of the GNU General Public License
69 along with this program. If not, see E<lt>http://www.gnu.org/licenses/E<gt>.
74 use POSIX qw(setlocale);
76 use Glib qw(TRUE FALSE);
79 my $NAME = 'clawsker';
80 my $PREFIX = '@PREFIX@';
81 my $LIBDIR = '@LIBDIR@';
82 my $VERSION = '@VERSION@';
84 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
85 setlocale (LC_ALL, $locale);
86 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
92 my $xla = gettext ($str);
93 if (scalar(keys(%par)) > 0) {
94 foreach my $key (keys %par) {
95 $xla =~ s/\{$key\}/$par{$key}/g;
103 win_title => _('Claws Mail Hidden Preferences'),
104 about => _('About...'),
105 about_title => _('Clawsker :: A Claws Mail Tweaker'),
106 about_license => _('License:'),
107 about_version => _('Version:'),
109 tab_colours => _('Colours'),
110 tab_behaviour => _('Behaviour'),
112 tab_other => _('Other'),
114 ab_frame => _('Addressbook'),
115 mem_frame => _('Memory'),
116 msgview_frame => _('Message view'),
117 log_frame => _('Log window'),
118 dnd_frame => _('Drag \'n\' drop'),
119 ssl_frame => _('Secure Sockets Layer'),
120 msgs_frame => _('Messages'),
121 stripes_frame => _('Coloured stripes'),
122 sbar_frame => _('Scroll bars'),
123 mlist_frame => _('Message list'),
125 l_oth_use_dlg => _('Use detached address book edit dialogue'),
126 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.'),
127 l_oth_max_use => _('Maximum memory for message cache (Kb)'),
128 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kB.'),
129 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
130 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.'),
132 l_gui_b_unread => _('Show unread messages with bold font'),
133 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
134 l_gui_no_markup => _('Don\'t use markup in compose window'),
135 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
136 l_gui_dot_lines => _('Use dotted lines in tree views'),
137 h_gui_dot_lines => _('Use the old dotted line look in the main window tree views (folder and message lists) instead of the modern lineless look.'),
138 l_gui_h_scroll => _('Enable horizontal scrollbar'),
139 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
140 l_gui_swp_from => _('Dislay To header in From field in Sent folder'),
141 h_gui_swp_from => _('Display the sender\'s email address in the To column of the Sent folder instead of the recipient\'s.'),
142 l_gui_v_scroll => _('Folder list scrollbar behaviour'),
143 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
144 l_gui_v_scroll_show => _('Show always'),
145 l_gui_v_scroll_auto => _('Automatic'),
146 l_gui_v_scroll_hide => _('Hide always'),
147 l_gui_strip_off => _('Striped lines contrast'),
148 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.'),
149 l_gui_cursor_v => _('Show Cursor in message view'),
150 h_gui_cursor_v => _('Display the cursor in the message view.'),
151 l_gui_toolbar_d => _('Detachable toolbars'),
152 h_gui_toolbar_d => _('Show handles in the toolbars.'),
153 l_gui_strip_all => _('Use stripes in all tree view components'),
154 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
155 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
156 h_gui_strip_sum => _('Enable alternately coloured lines in message list and folder list'),
158 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
159 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.'),
160 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
161 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
162 l_beh_flowed => _('Respect format=flowed in messages'),
163 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.'),
164 l_beh_parts_rw => _('Allow writable temporary files'),
165 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
166 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
167 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
168 l_beh_up_step => _('Progress bar update step (items)'),
169 h_beh_up_step => _('Update stepping in progress bars.'),
170 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
171 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
172 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
173 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
174 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
175 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
176 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
177 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
179 l_col_emphasis => _('X-Mailer header'),
180 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
181 l_col_log_err => _('Error messages'),
182 h_col_log_err => _('Colour for error messages in log window.'),
183 l_col_log_in => _('Server messages'),
184 h_col_log_in => _('Colour for input messages in log window.'),
185 l_col_log_msg => _('Standard messages'),
186 h_col_log_msg => _('Colour for messages in log window.'),
187 l_col_log_out => _('Client messages'),
188 h_col_log_out => _('Colour for output messages in log window.'),
189 l_col_log_warn => _('Warnings'),
190 h_col_log_warn => _('Colour for warning messages in log window.'),
192 e_error => _('Error: '),
193 e_noclawsrc => _('resource file for Claws Mail was not found.'),
194 e_running => _('seems Claws Mail is currently running, close it first.'),
195 e_requireddir => _('option requires a directory name.'),
196 e_requiredfile => _('option requires a file name.'),
197 e_notadir => _('specified name is not a directory or does not exist.'),
198 e_notafile => _('specified name is not a file or does not exist.'),
201 # all preferences read by load_preferences
203 # values of all preferences handled by clawsker
205 # default config dir and file name
206 my $ALTCONFIGDIR = FALSE;
207 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
208 my $CONFIGRC = 'clawsrc';
210 # index constants for preference arrays
211 use constant NAME => 0; # the name on the rc file
212 use constant LABEL => 1; # the label on the GUI
213 use constant DESC => 2; # the description for the hint/help
214 use constant TYPE => 3; # data type: bool, int, float, string, color
215 use constant GUI => 4; # GUI element
217 # constants for GUI spacing
218 use constant HBOX_SPC => 5;
219 use constant FRAME_SPC => 2;
220 use constant PAGE_SPC => 5;
222 # data handlers and auxiliar functions
224 sub handle_bool_value {
225 my ($widget, $event, $dataref) = @_;
226 $$dataref = ($widget->get_active ())? '1': '0';
229 sub handle_int_value {
230 my ($widget, $event, $dataref) = @_;
231 $_ = $widget->get_text ();
236 $widget->set_text ($_);
239 $widget->set_text ($$dataref);
243 sub handle_string_value {
244 my ($widget, $event, $dataref) = @_;
245 $$dataref = $widget->get_text ();
248 sub gdk_color_from_str {
250 my ($rr, $gg, $bb) = (0, 0 ,0);
252 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
257 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
261 sub str_from_gdk_color {
263 my $rr = $color->red / 256;
264 my $gg = $color->green / 256;
265 my $bb = $color->blue / 256;
266 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
270 sub handle_color_value {
271 my ($widget, $event, $dataref) = @_;
272 my $newcol = $widget->get_color;
273 $$dataref = &str_from_gdk_color ($newcol);
276 sub handle_selection_value {
277 my ($widget, $event, $dataref) = @_;
278 $$dataref = $widget->get_active;
281 sub get_rc_filename {
282 return $CONFIGDIR . $CONFIGRC;
285 sub set_rc_filename {
287 my @parts = split ('/', $fullname);
288 $CONFIGRC = $parts[$#parts];
289 $parts[$#parts] = '';
290 $CONFIGDIR = join ('/', @parts);
293 sub check_claws_not_running() {
294 my $socket = ($ALTCONFIGDIR)? "/tmp/": $CONFIGDIR;
295 $socket .= "claws-mail-$<";
296 -S $socket and die "$xl::s{e_error}$xl::s{e_running}\n";
299 # graphic element creation
301 sub new_check_button_for {
302 my ($hash, $key) = @_;
303 my $name = $$hash{$key}[NAME];
304 my $label = $$hash{$key}[LABEL];
306 my $hbox = Gtk2::HBox->new (FALSE, 5);
307 my $cb = Gtk2::CheckButton->new ($label);
308 $$hash{$key}[GUI] = $cb;
309 $cb->set_active ($HPVALUE{$name} eq '1');
310 $cb->signal_connect (clicked => sub {
312 &handle_bool_value($w, $e, \$HPVALUE{$name});
314 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
319 sub new_text_box_for {
320 my ($hash, $key) = @_;
321 my $name = $$hash{$key}[NAME];
322 my $label = $$hash{$key}[LABEL];
324 my $hbox = Gtk2::HBox->new (FALSE, 5);
325 my $glabel = Gtk2::Label->new ($label);
326 my $gentry = Gtk2::Entry->new;
327 $gentry->set_width_chars (8);
328 $$hash{$key}[GUI] = $gentry;
329 $gentry->set_text($HPVALUE{$name});
330 $gentry->signal_connect(changed => sub {
332 &handle_int_value($w, $e, \$HPVALUE{$name}); # FIXME int only
334 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
335 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
340 sub new_color_button_for {
341 my ($hash, $key) = @_;
342 my $name = $$hash{$key}[NAME];
343 my $label = $$hash{$key}[LABEL];
345 my $col = &gdk_color_from_str ($HPVALUE{$name});
346 my $hbox = Gtk2::HBox->new (FALSE, 5);
347 my $glabel = Gtk2::Label->new ($label);
348 my $button = Gtk2::ColorButton->new_with_color ($col);
349 $$hash{$key}[GUI] = $button;
350 $button->set_title ($label);
351 $button->set_relief ('none');
352 $button->signal_connect ('color-set' => sub {
354 &handle_color_value($w, $e, \$HPVALUE{$name});
356 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
357 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
362 sub new_selection_box_for {
363 my ($hash, $key) = @_;
364 my $name = $$hash{$key}[NAME];
365 my $label = $$hash{$key}[LABEL];
367 my $hbox = Gtk2::HBox->new (FALSE, 5);
368 my $glabel = Gtk2::Label->new ($label);
369 my $combo = Gtk2::ComboBox->new_text;
370 $$hash{$key}[GUI] = $combo;
371 my @options = split (';', $$hash{$key}[TYPE]);
372 foreach my $opt (@options) {
373 my ($index, $textkey) = split ('=', $opt);
374 $combo->insert_text ($index, $xl::s{$textkey});
376 $combo->signal_connect ('changed' => sub {
378 &handle_selection_value($w, $e, \$HPVALUE{$name});
380 $combo->set_active ($HPVALUE{$name});
381 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
382 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
387 # preference maps and corresponding page creation subs
389 %pr::oth = ( # other preferences
391 'addressbook_use_editaddress_dialog',
392 $xl::s{l_oth_use_dlg},
393 $xl::s{h_oth_use_dlg},
398 'cache_max_mem_usage',
399 $xl::s{l_oth_max_use},
400 $xl::s{h_oth_max_use},
405 'cache_min_keep_time',
406 $xl::s{l_oth_min_time},
407 $xl::s{h_oth_min_time},
413 sub new_other_page() {
414 my $of = Gtk2::VBox->new (FALSE, 5);
415 $of->set_border_width (PAGE_SPC);
417 my $ab_frame = Gtk2::Frame->new ($xl::s{ab_frame});
418 my $cb_use_dlg = &new_check_button_for(\%pr::oth, 'use_dlg');
419 my $vb1 = Gtk2::VBox->new (FALSE, 5);
420 $vb1->set_border_width (PAGE_SPC);
421 $vb1->pack_start ($cb_use_dlg, FALSE, FALSE, 0);
422 $ab_frame->add ($vb1);
424 my $mem_frame = Gtk2::Frame->new ($xl::s{mem_frame});
425 my $tb_max_use = &new_text_box_for(\%pr::oth, 'max_use');
426 my $tb_min_time = &new_text_box_for(\%pr::oth, 'min_time');
427 my $vb2 = Gtk2::VBox->new (FALSE, 5);
428 $vb2->set_border_width (PAGE_SPC);
429 $vb2->pack_start ($tb_max_use, FALSE, FALSE, 0);
430 $vb2->pack_start ($tb_min_time, FALSE, FALSE, 0);
431 $mem_frame->add ($vb2);
433 $of->pack_start ($ab_frame, FALSE, FALSE, FRAME_SPC);
434 $of->pack_start ($mem_frame, FALSE, FALSE, FRAME_SPC);
439 %pr::gui = ( # gui bells and whistles
442 $xl::s{l_gui_b_unread},
443 $xl::s{h_gui_b_unread},
449 $xl::s{l_gui_no_markup},
450 $xl::s{h_gui_no_markup},
455 'enable_dotted_lines',
456 $xl::s{l_gui_dot_lines},
457 $xl::s{h_gui_dot_lines},
463 $xl::s{l_gui_h_scroll},
464 $xl::s{h_gui_h_scroll},
470 $xl::s{l_gui_swp_from},
471 $xl::s{h_gui_swp_from},
476 'folderview_vscrollbar_policy',
477 $xl::s{l_gui_v_scroll},
478 $xl::s{h_gui_v_scroll},
479 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
483 'stripes_color_offset',
484 $xl::s{l_gui_strip_off},
485 $xl::s{h_gui_strip_off},
490 'textview_cursor_visible',
491 $xl::s{l_gui_cursor_v},
492 $xl::s{h_gui_cursor_v},
497 'toolbar_detachable',
498 $xl::s{l_gui_toolbar_d},
499 $xl::s{h_gui_toolbar_d},
504 'use_stripes_everywhere',
505 $xl::s{l_gui_strip_all},
506 $xl::s{h_gui_strip_all},
511 'use_stripes_in_summaries',
512 $xl::s{l_gui_strip_sum},
513 $xl::s{h_gui_strip_sum},
520 my $gf = Gtk2::VBox->new (FALSE, 5);
521 $gf->set_border_width (PAGE_SPC);
523 my $stripes_frame = Gtk2::Frame->new ($xl::s{stripes_frame});
524 my $cb_strip_all = &new_check_button_for (\%pr::gui, 'strip_all');
525 my $cb_strip_sum = &new_check_button_for (\%pr::gui, 'strip_sum');
526 my $tb_strip_off = &new_text_box_for (\%pr::gui, 'strip_off');
527 my $vb1 = Gtk2::VBox->new (FALSE, 5);
528 $vb1->set_border_width (PAGE_SPC);
529 $vb1->pack_start ($cb_strip_all, FALSE, FALSE, 0);
530 $vb1->pack_start ($cb_strip_sum, FALSE, FALSE, 0);
531 $vb1->pack_start ($tb_strip_off, FALSE, FALSE, 0);
532 $stripes_frame->add ($vb1);
534 my $mlist_frame = Gtk2::Frame->new ($xl::s{mlist_frame});
535 my $cb_b_unread = &new_check_button_for (\%pr::gui, 'b_unread');
536 my $cb_swp_from = &new_check_button_for (\%pr::gui, 'swp_from');
537 my $vb3 = Gtk2::VBox->new (FALSE, 5);
538 $vb3->set_border_width (PAGE_SPC);
539 $vb3->pack_start ($cb_b_unread, FALSE, FALSE, 0);
540 $vb3->pack_start ($cb_swp_from, FALSE, FALSE, 0);
541 $mlist_frame->add ($vb3);
543 my $sbar_frame = Gtk2::Frame->new ($xl::s{sbar_frame});
544 my $cb_h_scroll = &new_check_button_for (\%pr::gui, 'h_scroll');
545 my $sb_v_scroll = &new_selection_box_for (\%pr::gui, 'v_scroll');
546 my $vb2 = Gtk2::VBox->new (FALSE, 5);
547 $vb2->set_border_width (PAGE_SPC);
548 $vb2->pack_start ($cb_h_scroll, FALSE, FALSE, 0);
549 $vb2->pack_start ($sb_v_scroll, FALSE, FALSE, 0);
550 $sbar_frame->add ($vb2);
552 my $cb_no_markup = &new_check_button_for (\%pr::gui, 'no_markup');
553 my $cb_dot_lines = &new_check_button_for (\%pr::gui, 'dot_lines');
554 my $cb_cursor_v = &new_check_button_for (\%pr::gui, 'cursor_v');
555 my $cb_toolbar_d = &new_check_button_for (\%pr::gui, 'toolbar_d');
557 $gf->pack_start ($stripes_frame, FALSE, FALSE, FRAME_SPC);
558 $gf->pack_start ($mlist_frame, FALSE, FALSE, FRAME_SPC);
559 $gf->pack_start ($cb_no_markup, FALSE, FALSE, 0);
560 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
561 $gf->pack_start ($cb_cursor_v, FALSE, FALSE, 0);
562 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
563 $gf->pack_start ($sbar_frame, FALSE, FALSE, FRAME_SPC);
568 %pr::beh = ( # tweak some behaviour
571 $xl::s{l_beh_hover_t},
572 $xl::s{h_beh_hover_t},
578 $xl::s{l_beh_dangerous},
579 $xl::s{h_beh_dangerous},
584 'respect_flowed_format',
585 $xl::s{l_beh_flowed},
586 $xl::s{h_beh_flowed},
591 'save_parts_readwrite',
592 $xl::s{l_beh_parts_rw},
593 $xl::s{h_beh_parts_rw},
598 'skip_ssl_cert_check',
599 $xl::s{l_beh_skip_ssl},
600 $xl::s{h_beh_skip_ssl},
605 'statusbar_update_step',
606 $xl::s{l_beh_up_step},
607 $xl::s{h_beh_up_step},
612 'thread_by_subject_max_age',
613 $xl::s{l_beh_thread_a},
614 $xl::s{h_beh_thread_a},
620 $xl::s{l_beh_unsafe_ssl},
621 $xl::s{h_beh_unsafe_ssl},
626 'utf8_instead_of_locale_for_broken_mail',
627 $xl::s{l_beh_use_utf8},
628 $xl::s{h_beh_use_utf8},
634 $xl::s{l_beh_warn_dnd},
635 $xl::s{h_beh_warn_dnd},
641 sub new_behaviour_page() {
642 my $bf = Gtk2::VBox->new (FALSE, 5);
643 $bf->set_border_width (PAGE_SPC);
645 my $dnd_frame = Gtk2::Frame->new ($xl::s{dnd_frame});
646 my $tb_hoover_t = &new_text_box_for (\%pr::beh, 'hover_t');
647 my $cb_warn_dnd = &new_check_button_for (\%pr::beh, 'warn_dnd');
648 my $vb1 = Gtk2::VBox->new (FALSE, 5);
649 $vb1->set_border_width (PAGE_SPC);
650 $vb1->pack_start ($cb_warn_dnd, FALSE, FALSE, 0);
651 $vb1->pack_start ($tb_hoover_t, FALSE, FALSE, 0);
652 $dnd_frame->add ($vb1);
654 my $ssl_frame = Gtk2::Frame->new ($xl::s{ssl_frame});
655 my $cb_skip_ssl = &new_check_button_for (\%pr::beh, 'skip_ssl');
656 my $cb_unsafe_ssl = &new_check_button_for (\%pr::beh, 'unsafe_ssl');
657 my $hb1 = Gtk2::HBox->new (FALSE, 5);
658 $hb1->set_border_width (PAGE_SPC);
659 $hb1->pack_start ($cb_skip_ssl, FALSE, FALSE, 0);
660 $hb1->pack_start ($cb_unsafe_ssl, FALSE, FALSE, 0);
661 $ssl_frame->add ($hb1);
663 my $tb_up_step = &new_text_box_for (\%pr::beh, 'up_step');
664 my $tb_thread_a = &new_text_box_for (\%pr::beh, 'thread_a');
666 my $msgs_frame = Gtk2::Frame->new ($xl::s{msgs_frame});
667 my $cb_flowed = &new_check_button_for (\%pr::beh, 'flowed');
668 my $cb_parts_rw = &new_check_button_for (\%pr::beh, 'parts_rw');
669 my $cb_use_utf8 = &new_check_button_for (\%pr::beh, 'use_utf8');
670 my $cb_dangerous = &new_check_button_for (\%pr::beh, 'dangerous');
671 my $vb2 = Gtk2::VBox->new (FALSE, 5);
672 $vb2->set_border_width (PAGE_SPC);
673 $vb2->pack_start ($cb_flowed, FALSE, FALSE, 0);
674 $vb2->pack_start ($cb_parts_rw, FALSE, FALSE, 0);
675 $vb2->pack_start ($cb_use_utf8, FALSE, FALSE, 0);
676 $vb2->pack_start ($cb_dangerous, FALSE, FALSE, 0);
677 $msgs_frame->add ($vb2);
679 $bf->pack_start ($dnd_frame, FALSE, FALSE, FRAME_SPC);
680 $bf->pack_start ($ssl_frame, FALSE, FALSE, FRAME_SPC);
681 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
682 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
683 $bf->pack_start ($msgs_frame, FALSE, FALSE, FRAME_SPC);
688 %pr::col = ( # a variety of colours
691 $xl::s{l_col_emphasis},
692 $xl::s{h_col_emphasis},
698 $xl::s{l_col_log_err},
699 $xl::s{h_col_log_err},
705 $xl::s{l_col_log_in},
706 $xl::s{h_col_log_in},
712 $xl::s{l_col_log_msg},
713 $xl::s{h_col_log_msg},
719 $xl::s{l_col_log_out},
720 $xl::s{h_col_log_out},
726 $xl::s{l_col_log_warn},
727 $xl::s{h_col_log_warn},
733 sub new_colours_page() {
734 my $cf = Gtk2::VBox->new (FALSE, 5);
735 $cf->set_border_width (PAGE_SPC);
737 my $msgview_frame = Gtk2::Frame->new ($xl::s{msgview_frame});
738 my $cb_emphasis = &new_color_button_for (\%pr::col, 'emphasis');
739 my $vb1 = Gtk2::VBox->new (FALSE, 5);
740 $vb1->set_border_width (PAGE_SPC);
741 $vb1->pack_start ($cb_emphasis, FALSE, FALSE, 0);
742 $msgview_frame->add ($vb1);
744 my $log_frame = Gtk2::Frame->new ($xl::s{log_frame});
745 my $cb_log_err = &new_color_button_for (\%pr::col, 'log_err');
746 my $cb_log_in = &new_color_button_for (\%pr::col, 'log_in');
747 my $cb_log_msg = &new_color_button_for (\%pr::col, 'log_msg');
748 my $cb_log_out = &new_color_button_for (\%pr::col, 'log_out');
749 my $cb_log_warn = &new_color_button_for (\%pr::col, 'log_warn');
750 my $vb2 = Gtk2::VBox->new (FALSE, 5);
751 $vb2->set_border_width (PAGE_SPC);
752 $vb2->pack_start ($cb_log_err, FALSE, FALSE, 0);
753 $vb2->pack_start ($cb_log_in, FALSE, FALSE, 0);
754 $vb2->pack_start ($cb_log_msg, FALSE, FALSE, 0);
755 $vb2->pack_start ($cb_log_out, FALSE, FALSE, 0);
756 $vb2->pack_start ($cb_log_warn, FALSE, FALSE, 0);
757 $log_frame->add ($vb2);
759 $cf->pack_start ($msgview_frame, FALSE, FALSE, 0);
760 $cf->pack_start ($log_frame, FALSE, FALSE, 0);
765 # the command line help
767 my $line = '-' x length ($xl::s{about_title}) . "\n";
769 print $xl::s{about_title} . "\n";
770 print $xl::s{about_version} . " $VERSION\n";
772 print _("Syntax:\n");
773 print _(" clawsker [options]\n");
774 print _("Options:\n");
775 print _(" --help Prints this help screen.\n");
776 print _(" --alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
777 print _(" --clawsrc <file> Uses <file> as full resource name.\n");
780 # parse the command line
781 sub parse_command_line() {
783 while (defined($ARGV[$arg])) {
789 /--alternate-config-dir/ && do {
791 die "$xl::s{e_error}$xl::s{e_requireddir}\n"
792 unless defined($ARGV[$arg]);
793 die "$xl::s{e_error}$xl::s{e_notadir}\n"
794 unless -d $ARGV[$arg];
795 $CONFIGDIR = $ARGV[$arg];
796 $ALTCONFIGDIR = TRUE;
801 die "$xl::s{e_error}$xl::s{e_requiredfile}\n"
802 unless defined($ARGV[$arg]);
803 die "$xl::s{e_error}$xl::s{e_notafile}\n"
804 unless -f $ARGV[$arg];
805 &set_rc_filename ($ARGV[$arg]);
808 /.*/ && die $xl::s{e_error}
809 . _("unknown option '{opt}'.\n", opt => $ARGV[$arg]);
815 # update the hidden preferences status from loaded values
816 sub init_hidden_preferences() {
817 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth) {
818 foreach my $key (keys %$hash) {
819 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
824 # load current status from disc
825 sub load_preferences() {
826 my $rc = &get_rc_filename;
827 -f $rc or die "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
828 &check_claws_not_running;
832 if (/^([8a-z_]+)=(.*)$/) {
839 # save current preferences to disc
840 sub save_preferences() {
841 my $rc = &get_rc_filename;
842 -f $rc or die "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
843 &check_claws_not_running;
844 my $rcbak = "$rc.backup";
845 rename ($rc, $rcbak);
847 open (RCB, "<$rcbak");
850 if (/^([8a-z_]+)=(.*)$/) {
851 if (defined($HPVALUE{$1})) {
852 print RCF $1 . "=" . $HPVALUE{$1} . "\n";
868 my $nb = Gtk2::Notebook->new;
870 $nb->append_page (&new_behaviour_page, $xl::s{tab_behaviour});
871 $nb->append_page (&new_colours_page, $xl::s{tab_colours});
872 $nb->append_page (&new_gui_page, $xl::s{tab_gui});
873 $nb->append_page (&new_other_page, $xl::s{tab_other});
878 # create an about dialog
879 sub new_about_dialog() {
881 my $title = $xl::s{about_title};
882 my $lic = $xl::s{about_license};
883 my $vers = $xl::s{about_version} . " $VERSION";
885 "This program is free software: you can redistribute it and/or modify
886 it under the terms of the GNU General Public License as published by
887 the Free Software Foundation, either version 3 of the License, or
888 (at your option) any later version.
890 This program is distributed in the hope that it will be useful,
891 but WITHOUT ANY WARRANTY; without even the implied warranty of
892 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
893 GNU General Public License for more details.
895 You should have received a copy of the GNU General Public License
896 along with this program. If not, see <http://www.gnu.org/licenses/>.";
898 my $holder = "Ricardo Mones <ricardo\@mones.org>";
900 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
901 [qw/modal destroy-with-parent/],
903 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
904 . "<span size=\"large\">$vers</span>\n"
905 . "<span>Copyright $year by $holder</span>\n\n"
906 . "<span size=\"large\">$lic</span>\n\n"
907 . "<span size=\"small\">$license</span>");
908 $dialog->set_title ($xl::s{about});
914 sub new_button_box() {
916 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
917 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
918 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
919 # disable button until is really implemented
920 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
921 my $hbox = Gtk2::HBox->new (FALSE, 5);
923 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
924 $b_apply->signal_connect (clicked => sub { &save_preferences });
925 # $b_undo->signal_connect (clicked => sub { &undo_current_changes });
926 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
928 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
929 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
930 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
931 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
939 &init_hidden_preferences;
941 my $window = Gtk2::Window->new ('toplevel');
942 my $box = Gtk2::VBox->new (FALSE, 5);
943 $box->set_border_width(3);
944 my $about = &new_about_dialog;
945 $box->pack_start (&new_notebook, FALSE, FALSE, 0);
946 $box->pack_end (&new_button_box ($about), FALSE, FALSE, 0);
947 $window->signal_connect (delete_event => sub { Gtk2->main_quit });
948 $window->set_title ($xl::s{win_title});