3 # Clawsker :: A Claws Mail Tweaker
7 use Glib qw(TRUE FALSE);
9 use POSIX qw(setlocale);
12 my $NAME = 'clawsker';
13 my $PREFIX = '@PREFIX@';
14 my $LIBDIR = '@LIBDIR@';
15 my $VERSION = '@VERSION@';
18 my $main_window = undef;
20 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
21 $locale = "C" unless defined($locale);
22 setlocale (LC_ALL, $locale);
23 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
26 my $SHOWHINTS = FALSE;
27 $SHOWHINTS = TRUE if ($Gtk2::VERSION >= 1.040 and Gtk2->CHECK_VERSION (2, 12, 0));
32 my $xla = gettext ($str);
33 if (scalar(keys(%par)) > 0) {
34 foreach my $key (keys %par) {
35 $xla =~ s/\{$key\}/$par{$key}/g;
43 win_title => _('Claws Mail Hidden Preferences'),
44 about => _('About...'),
45 about_title => _('Clawsker :: A Claws Mail Tweaker'),
46 about_license => _('License:'),
47 about_version => _('Version:'),
49 tab_colours => _('Colours'),
50 tab_behaviour => _('Behaviour'),
52 tab_other => _('Other'),
53 tab_winpos => _('Windows'),
55 ab_frame => _('Addressbook'),
56 mem_frame => _('Memory'),
57 msgview_frame => _('Message View'),
58 log_frame => _('Log window'),
59 dnd_frame => _('Drag \'n\' drop'),
60 ssl_frame => _('Secure Sockets Layer'),
61 msgs_frame => _('Messages'),
62 stripes_frame => _('Coloured stripes'),
63 sbar_frame => _('Scroll bars'),
64 mlist_frame => _('Message List'),
65 mview_frame => _('Message View'),
66 compo_frame => _('Compose window'),
67 netm_frame => _('NetworkManager'),
69 l_oth_use_dlg => _('Use detached address book edit dialogue'),
70 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.'),
71 l_oth_max_use => _('Maximum memory for message cache (kB)'),
72 h_oth_max_use => _('The maximum amount of memory to use to cache messages, in kilobytes.'),
73 l_oth_min_time => _('Minimun time for cache elements (minutes)'),
74 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.'),
75 l_oth_use_netm => _('Use NetworkManager'),
76 h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
78 l_gui_b_unread => _('Show unread messages with bold font'),
79 h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
80 l_gui_no_markup => _('Don\'t use markup in compose window'),
81 h_gui_no_markup => _('Don\'t use bold and italic text in Compose dialogue\'s account selector.'),
82 l_gui_dot_lines => _('Use dotted lines in tree view components'),
83 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.'),
84 l_gui_h_scroll => _('Enable horizontal scrollbar'),
85 h_gui_h_scroll => _('Enable the horizontal scrollbar in the Message List.'),
86 l_gui_swp_from => _('Display To column instead From column in Sent folder'),
87 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.'),
88 l_gui_v_scroll => _('Folder List scrollbar behaviour'),
89 h_gui_v_scroll => _('Specify the policy of vertical scrollbar of Folder List: show always, automatic or hide always.'),
90 l_gui_v_scroll_show => _('Show always'),
91 l_gui_v_scroll_auto => _('Automatic'),
92 l_gui_v_scroll_hide => _('Hide always'),
93 l_gui_from_show => _('From column displays'),
94 h_gui_from_show => _('Selects the data displayed in the From column of the Message List: name, address or both'),
95 l_gui_from_show_name => _('Name only'),
96 l_gui_from_show_addr => _('Address only'),
97 l_gui_from_show_both => _('Both name and address'),
98 l_gui_strip_off => _('Coloured lines contrast'),
99 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.'),
100 l_gui_cursor_v => _('Show cursor'),
101 h_gui_cursor_v => _('Display the cursor in the Message View.'),
102 l_gui_toolbar_d => _('Detachable toolbars'),
103 h_gui_toolbar_d => _('Show handles in the toolbars.'),
104 l_gui_strip_all => _('Use stripes in all tree view components'),
105 h_gui_strip_all => _('Enable alternately coloured lines in all tree view components.'),
106 l_gui_strip_sum => _('Use stripes in Folder List and Message List'),
107 h_gui_strip_sum => _('Enable alternately coloured lines in Message List and Folder List.'),
108 l_gui_two_line_v => _('2 lines per Message List item in 3-column layout'),
109 h_gui_two_line_v => _('Spread Message List information over two lines when using the three column mode.'),
110 l_gui_margin_co => _('Show compose margin'),
111 h_gui_margin_co => _('Shows a small margin in the Compose View.'),
112 l_gui_mview_date => _('Don\'t display localized date'),
113 h_gui_mview_date => _('Toggles localization of date format in Message View'),
115 l_beh_hover_t => _('Drag \'n\' drop hover timeout (ms)'),
116 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.'),
117 l_beh_dangerous => _('Don\'t confirm deletions (dangerous!)'),
118 h_beh_dangerous => _('Don\'t ask for confirmation before definitive deletion of emails.'),
119 l_beh_flowed => _('Respect format=flowed in messages'),
120 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.'),
121 l_beh_parts_rw => _('Allow writable temporary files'),
122 h_beh_parts_rw => _('Saves temporary files when opening attachment with write bit set.'),
123 l_beh_skip_ssl => _('Don\'t check SSL certificates'),
124 h_beh_skip_ssl => _('Disables the verification of SSL certificates.'),
125 l_beh_up_step => _('Progress bar update step (items)'),
126 h_beh_up_step => _('Update stepping in progress bars.'),
127 l_beh_thread_a => _('Maximum age when threading by subject (days)'),
128 h_beh_thread_a => _('Number of days to include a message in a thread when using "Thread using subject in addition to standard headers".'),
129 l_beh_unsafe_ssl => _('Allow unsafe SSL certificates'),
130 h_beh_unsafe_ssl => _('Allows Claws Mail to remember multiple SSL certificates for a given server/port.'),
131 l_beh_use_utf8 => _('Force UTF-8 for broken mails'),
132 h_beh_use_utf8 => _('Use UTF-8 encoding for broken mails instead of current locale.'),
133 l_beh_warn_dnd => _('Warn on drag \'n\' drop'),
134 h_beh_warn_dnd => _('Display a confirmation dialogue on drag \'n\' drop of folders.'),
135 l_beh_out_ascii => _('Outgoing messages fallback to ASCII'),
136 h_beh_out_ascii => _('If content allows, ASCII will be used to encode outgoing messages, otherwise the user-defined encoding is enforced always.'),
137 l_beh_pp_unsel => _('Primary paste unselects selection'),
138 h_beh_pp_unsel => _('Controls how pasting using middle-click changes the selected text and insertion point.'),
139 l_beh_inline_at => _('Show inline attachments'),
140 h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view'),
142 l_col_emphasis => _('X-Mailer header'),
143 h_col_emphasis => _('The colour used for the X-Mailer line when its value is Claws Mail.'),
144 l_col_log_err => _('Error messages'),
145 h_col_log_err => _('Colour for error messages in log window.'),
146 l_col_log_in => _('Server messages'),
147 h_col_log_in => _('Colour for messages received from servers in log window.'),
148 l_col_log_msg => _('Standard messages'),
149 h_col_log_msg => _('Colour for messages in log window.'),
150 l_col_log_out => _('Client messages'),
151 h_col_log_out => _('Colour for messages sent to servers in log window.'),
152 l_col_log_warn => _('Warnings'),
153 h_col_log_warn => _('Colour for warning messages in log window.'),
155 l_win_x => _('X position'),
156 h_win_x => _('X coordinate for window\'s top-left corner.'),
157 l_win_y => _('Y position'),
158 h_win_y => _('Y coordinate for window\'s top-left corner.'),
159 l_win_w => _('Width'),
160 h_win_w => _('Window\'s width in pixels.'),
161 l_win_h => _('Height'),
162 h_win_h => _('Window\'s height in pixels.'),
164 l_win_main_mx => _('Maximized'),
165 h_win_main_mx => _('Changes window maximized status.'),
166 l_win_main_fs => _('Full-screen'),
167 h_win_main_fs => _('Changes full screen status.'),
169 e_error => _('Error: '),
170 e_noclawsrc => _('resource file for Claws Mail was not found.'),
171 e_running => _('seems Claws Mail is currently running, close it first.'),
172 e_requireddir => _('option requires a directory name.'),
173 e_requiredfile => _('option requires a file name.'),
174 e_notadir => _('specified name is not a directory or does not exist.'),
175 e_notafile => _('specified name is not a file or does not exist.'),
178 # all preferences read by load_preferences
180 # values of all preferences handled by clawsker
182 # default config dir and file name
183 my $ALTCONFIGDIR = FALSE;
184 my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
185 my $CONFIGRC = 'clawsrc';
187 # index constants for preference arrays
188 use constant NAME => 0; # the name on the rc file
189 use constant LABEL => 1; # the label on the GUI
190 use constant DESC => 2; # the description for the hint/help
191 use constant TYPE => 3; # data type: bool, int, float, string, color
192 use constant CMVER => 4; # lowest Claws Mail version the feature exists
193 use constant CMDEF => 5; # default value for the preference in Claws Mail
194 use constant GUI => 6; # GUI element
196 # constants for GUI spacing
197 use constant HBOX_SPC => 5;
198 use constant FRAME_SPC => 2;
199 use constant PAGE_SPC => 5;
203 sub version_greater_or_equal() {
204 my ($version, $refvers) = @_;
205 my @version = split (/\./, $version);
206 my @refvers = split (/\./, $refvers);
207 while ($#version < $#refvers) {
208 push (@version, '0');
211 while (($idx <= $#refvers)
212 and (int ($version[$idx]) == int ($refvers[$idx]))) {
215 return TRUE if (($idx > $#refvers)
216 or (int ($version[$idx]) >= int ($refvers[$idx])));
220 sub get_claws_version() {
225 foreach my $bin (@cmbin) {
230 return "" unless ($_); # not installed
233 my @fver = split (/ /);
234 die "Invalid version string" unless ($fver[2] eq "version");
235 my @ver = split (/\./, $fver[3]);
238 if ($ver[2] =~ /(\d+)cvs(\d+)/) {
247 # data handlers and auxiliar functions
249 sub handle_bool_value {
250 my ($widget, $event, $dataref) = @_;
251 $$dataref = ($widget->get_active ())? '1': '0';
254 sub handle_int_value {
255 my ($widget, $event, $dataref) = @_;
256 $_ = $widget->get_text ();
261 $widget->set_text ($_);
264 $widget->set_text ($$dataref);
268 sub handle_string_value {
269 my ($widget, $event, $dataref) = @_;
270 $$dataref = $widget->get_text ();
273 sub gdk_color_from_str {
275 my ($rr, $gg, $bb) = (0, 0 ,0);
277 if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
282 my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
286 sub str_from_gdk_color {
288 my $rr = $color->red / 256;
289 my $gg = $color->green / 256;
290 my $bb = $color->blue / 256;
291 my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
295 sub handle_color_value {
296 my ($widget, $event, $dataref) = @_;
297 my $newcol = $widget->get_color;
298 $$dataref = &str_from_gdk_color ($newcol);
301 sub handle_selection_value {
302 my ($widget, $event, $dataref) = @_;
303 $$dataref = $widget->get_active;
306 sub get_rc_filename {
307 return $CONFIGDIR . $CONFIGRC;
310 sub set_rc_filename {
312 my @parts = split ('/', $fullname);
313 $CONFIGRC = $parts[$#parts];
314 $parts[$#parts] = '';
315 $CONFIGDIR = join ('/', @parts);
319 my ($mesg, $fatal) = @_;
320 if (defined($fatal) && $fatal eq 'die') {
321 die "$NAME: $mesg\n";
324 print "$NAME: $mesg\n";
330 my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
331 my $errordlg = Gtk2::MessageDialog->new_with_markup ($main_window, 'modal', 'error', 'cancel', $markup);
332 $errordlg->set_title (_('Error message'));
337 sub check_claws_not_running() {
338 my $socket = (not $ALTCONFIGDIR)? "/tmp/": $CONFIGDIR;
339 $socket .= "claws-mail-$<";
341 my $emsg = "$xl::s{e_error}$xl::s{e_running}";
343 error_dialog ($emsg);
349 sub check_rc_file() {
351 (defined($rcfile) && -f $rcfile) or do {
352 my $emsg = "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
354 error_dialog ($emsg);
360 sub set_widget_hint() {
362 my ($wdgt, $hint) = @_;
363 $wdgt->set_tooltip_text ($hint);
364 $wdgt->set_has_tooltip (TRUE);
368 sub set_widget_sens() {
369 my ($wdgt, $minver) = @_;
370 $wdgt->set_sensitive (&version_greater_or_equal ($CLAWSV, $minver));
373 # graphic element creation
375 sub new_check_button_for {
376 my ($hash, $key) = @_;
377 my $name = $$hash{$key}[NAME];
378 my $label = $$hash{$key}[LABEL];
380 my $hbox = Gtk2::HBox->new (FALSE, 5);
381 my $cb = Gtk2::CheckButton->new ($label);
382 $$hash{$key}[GUI] = $cb;
383 if (defined ($HPVALUE{$name})) {
384 $cb->set_active ($HPVALUE{$name} eq '1');
386 $cb->signal_connect (clicked => sub {
388 &handle_bool_value($w, $e, \$HPVALUE{$name});
390 &set_widget_hint ($cb, $$hash{$key}[DESC]);
391 &set_widget_sens ($cb, $$hash{$key}[CMVER]);
392 $hbox->pack_start ($cb, FALSE, FALSE, HBOX_SPC);
397 sub new_text_box_for_int {
398 my ($hash, $key) = @_;
399 my $name = $$hash{$key}[NAME];
400 my $label = $$hash{$key}[LABEL];
401 my @type = split (/,/, $$hash{$key}[TYPE]);
402 push (@type, 0), push (@type, 10000) unless ($#type > 0);
404 my $hbox = Gtk2::HBox->new (FALSE, 5);
405 my $glabel = Gtk2::Label->new ($label);
406 my $pagei = int (($type[2] - $type[1]) / 10);
407 my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
408 $gentry->set_numeric (TRUE);
409 $gentry->set_value ($HPVALUE{$name});
410 $$hash{$key}[GUI] = $gentry;
411 $gentry->signal_connect('value-changed' => sub {
413 &handle_int_value($w, $e, \$HPVALUE{$name});
415 &set_widget_hint ($gentry, $$hash{$key}[DESC]);
416 &set_widget_sens ($gentry, $$hash{$key}[CMVER]);
417 $glabel->set_sensitive ($gentry->sensitive);
418 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
419 $hbox->pack_start ($gentry, FALSE, FALSE, HBOX_SPC);
424 sub new_color_button_for {
425 my ($hash, $key) = @_;
426 my $name = $$hash{$key}[NAME];
427 my $label = $$hash{$key}[LABEL];
429 my $col = &gdk_color_from_str ($HPVALUE{$name});
430 my $hbox = Gtk2::HBox->new (FALSE, 5);
431 my $glabel = Gtk2::Label->new ($label);
432 my $button = Gtk2::ColorButton->new_with_color ($col);
433 $$hash{$key}[GUI] = $button;
434 $button->set_title ($label);
435 $button->set_relief ('none');
436 $button->signal_connect ('color-set' => sub {
438 &handle_color_value($w, $e, \$HPVALUE{$name});
440 &set_widget_hint ($button, $$hash{$key}[DESC]);
441 &set_widget_sens ($button, $$hash{$key}[CMVER]);
442 $glabel->set_sensitive ($button->sensitive);
443 $hbox->pack_start ($button, FALSE, FALSE, HBOX_SPC);
444 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
449 sub new_selection_box_for {
450 my ($hash, $key) = @_;
451 my $name = $$hash{$key}[NAME];
452 my $label = $$hash{$key}[LABEL];
454 my $hbox = Gtk2::HBox->new (FALSE, 5);
455 my $glabel = Gtk2::Label->new ($label);
456 my $combo = Gtk2::ComboBox->new_text;
457 $$hash{$key}[GUI] = $combo;
458 my @options = split (';', $$hash{$key}[TYPE]);
459 foreach my $opt (@options) {
460 my ($index, $textkey) = split ('=', $opt);
461 $combo->insert_text ($index, $xl::s{$textkey});
463 $combo->signal_connect ('changed' => sub {
465 &handle_selection_value($w, $e, \$HPVALUE{$name});
467 $combo->set_active ($HPVALUE{$name});
468 &set_widget_hint ($combo, $$hash{$key}[DESC]);
469 &set_widget_sens ($combo, $$hash{$key}[CMVER]);
470 $glabel->set_sensitive ($combo->sensitive);
471 $hbox->pack_start ($glabel, FALSE, FALSE, HBOX_SPC);
472 $hbox->pack_start ($combo, FALSE, FALSE, HBOX_SPC);
477 # more graphic helpers
479 sub new_hbox_pack() {
480 my $hbox = Gtk2::HBox->new (FALSE, 5);
481 $hbox->set_border_width (PAGE_SPC);
482 foreach my $item (@_) {
483 $hbox->pack_start ($item, FALSE, FALSE, 0);
488 sub new_vbox_pack() {
489 my $vbox = Gtk2::VBox->new (FALSE, 5);
490 $vbox->set_border_width (PAGE_SPC);
491 foreach my $item (@_) {
492 $vbox->pack_start ($item, FALSE, FALSE, 0);
497 sub new_vbox_pack_compact() {
498 my $vbox = Gtk2::VBox->new (FALSE, 0);
499 $vbox->set_border_width (0);
500 foreach my $item (@_) {
501 $vbox->pack_start ($item, FALSE, FALSE, 0);
506 sub new_subpage_frame () {
507 my ($box, $title, $notpacked) = @_;
508 my $frame = Gtk2::Frame->new ($title);
510 return &new_vbox_pack ($frame) unless defined ($notpacked);
514 # preference maps and corresponding page creation subs
516 %pr::oth = ( # other preferences
518 'addressbook_use_editaddress_dialog',
519 $xl::s{l_oth_use_dlg},
520 $xl::s{h_oth_use_dlg},
527 'cache_max_mem_usage',
528 $xl::s{l_oth_max_use},
529 $xl::s{h_oth_max_use},
530 'int,0,262144', # 0 Kb - 256 Mb
536 'cache_min_keep_time',
537 $xl::s{l_oth_min_time},
538 $xl::s{h_oth_min_time},
539 'int,0,120', # 0 minutes - 2 hours
545 'use_networkmanager',
546 $xl::s{l_oth_use_netm},
547 $xl::s{h_oth_use_netm},
555 sub new_other_page() {
556 return &new_vbox_pack (
559 &new_check_button_for(\%pr::oth, 'use_dlg')),
560 $xl::s{ab_frame}, 'not-packed'),
563 &new_text_box_for_int(\%pr::oth, 'max_use'),
564 &new_text_box_for_int(\%pr::oth, 'min_time')),
565 $xl::s{mem_frame}, 'not-packed'),
568 &new_check_button_for(\%pr::oth, 'use_netm')),
569 $xl::s{netm_frame}, 'not-packed')
573 %pr::gui = ( # gui bells and whistles
576 $xl::s{l_gui_b_unread},
577 $xl::s{h_gui_b_unread},
585 $xl::s{l_gui_no_markup},
586 $xl::s{h_gui_no_markup},
593 'enable_dotted_lines',
594 $xl::s{l_gui_dot_lines},
595 $xl::s{h_gui_dot_lines},
603 $xl::s{l_gui_h_scroll},
604 $xl::s{h_gui_h_scroll},
612 $xl::s{l_gui_swp_from},
613 $xl::s{h_gui_swp_from},
620 'folderview_vscrollbar_policy',
621 $xl::s{l_gui_v_scroll},
622 $xl::s{h_gui_v_scroll},
623 '0=l_gui_v_scroll_show;1=l_gui_v_scroll_auto;2=l_gui_v_scroll_hide',
630 $xl::s{l_gui_from_show},
631 $xl::s{h_gui_from_show},
632 '0=l_gui_from_show_name;1=l_gui_from_show_addr;2=l_gui_from_show_both',
638 'stripes_color_offset',
639 $xl::s{l_gui_strip_off},
640 $xl::s{h_gui_strip_off},
641 'int,0,40000', # no idea what this number means
647 'textview_cursor_visible',
648 $xl::s{l_gui_cursor_v},
649 $xl::s{h_gui_cursor_v},
656 'toolbar_detachable',
657 $xl::s{l_gui_toolbar_d},
658 $xl::s{h_gui_toolbar_d},
665 'use_stripes_everywhere',
666 $xl::s{l_gui_strip_all},
667 $xl::s{h_gui_strip_all},
674 'use_stripes_in_summaries',
675 $xl::s{l_gui_strip_sum},
676 $xl::s{h_gui_strip_sum},
684 $xl::s{l_gui_two_line_v},
685 $xl::s{h_gui_two_line_v},
692 'show_compose_margin',
693 $xl::s{l_gui_margin_co},
694 $xl::s{h_gui_margin_co},
701 'msgview_date_format',
702 $xl::s{l_gui_mview_date},
703 $xl::s{h_gui_mview_date},
712 my $gf = Gtk2::VBox->new (FALSE, 5);
713 $gf->set_border_width (PAGE_SPC);
715 my $cb_dot_lines = &new_check_button_for (\%pr::gui, 'dot_lines');
716 my $cb_toolbar_d = &new_check_button_for (\%pr::gui, 'toolbar_d');
718 $gf->pack_start (&new_subpage_frame (
720 &new_check_button_for (\%pr::gui, 'strip_all'),
721 &new_check_button_for (\%pr::gui, 'strip_sum'),
722 &new_text_box_for_int (\%pr::gui, 'strip_off')),
723 $xl::s{stripes_frame}, 'not-packed'),
724 FALSE, FALSE, FRAME_SPC);
725 $gf->pack_start (&new_subpage_frame (
727 &new_check_button_for (\%pr::gui, 'b_unread'),
728 &new_check_button_for (\%pr::gui, 'swp_from'),
729 &new_check_button_for (\%pr::gui, 'two_linev'),
730 &new_selection_box_for (\%pr::gui, 'from_show')),
731 $xl::s{mlist_frame}, 'not-packed'),
732 FALSE, FALSE, FRAME_SPC);
733 $gf->pack_start (&new_subpage_frame (
735 &new_check_button_for (\%pr::gui, 'cursor_v'),
736 &new_check_button_for (\%pr::gui, 'mview_date')),
737 $xl::s{mview_frame}, 'not-packed'),
738 FALSE, FALSE, FRAME_SPC);
739 $gf->pack_start (&new_subpage_frame (
741 &new_check_button_for (\%pr::gui, 'no_markup'),
742 &new_check_button_for (\%pr::gui, 'margin_co')),
743 $xl::s{compo_frame}, 'not-packed'),
744 FALSE, FALSE, FRAME_SPC);
745 $gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
746 $gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
747 $gf->pack_start (&new_subpage_frame (
749 &new_check_button_for (\%pr::gui, 'h_scroll'),
750 &new_selection_box_for (\%pr::gui, 'v_scroll')),
751 $xl::s{sbar_frame}, 'not-packed'),
752 FALSE, FALSE, FRAME_SPC);
757 %pr::beh = ( # tweak some behaviour
760 $xl::s{l_beh_hover_t},
761 $xl::s{h_beh_hover_t},
762 'int,100,3000', # 0.1 seconds - 3 seconds
769 $xl::s{l_beh_dangerous},
770 $xl::s{h_beh_dangerous},
777 'respect_flowed_format',
778 $xl::s{l_beh_flowed},
779 $xl::s{h_beh_flowed},
786 'save_parts_readwrite',
787 $xl::s{l_beh_parts_rw},
788 $xl::s{h_beh_parts_rw},
795 'skip_ssl_cert_check',
796 $xl::s{l_beh_skip_ssl},
797 $xl::s{h_beh_skip_ssl},
804 'statusbar_update_step',
805 $xl::s{l_beh_up_step},
806 $xl::s{h_beh_up_step},
807 'int,1,200', # 1 item - 200 items
813 'thread_by_subject_max_age',
814 $xl::s{l_beh_thread_a},
815 $xl::s{h_beh_thread_a},
816 'int,1,30', # 1 day - 30 days
823 $xl::s{l_beh_unsafe_ssl},
824 $xl::s{h_beh_unsafe_ssl},
831 'utf8_instead_of_locale_for_broken_mail',
832 $xl::s{l_beh_use_utf8},
833 $xl::s{h_beh_use_utf8},
841 $xl::s{l_beh_warn_dnd},
842 $xl::s{h_beh_warn_dnd},
849 'outgoing_fallback_to_ascii',
850 $xl::s{l_beh_out_ascii},
851 $xl::s{h_beh_out_ascii},
858 'primary_paste_unselects',
859 $xl::s{l_beh_pp_unsel},
860 $xl::s{h_beh_pp_unsel},
867 'show_inline_attachments',
868 $xl::s{l_beh_inline_at},
869 $xl::s{h_beh_inline_at},
877 sub new_behaviour_page() {
878 my $bf = Gtk2::VBox->new (FALSE, 5);
879 $bf->set_border_width (PAGE_SPC);
881 my $tb_up_step = &new_text_box_for_int (\%pr::beh, 'up_step');
882 my $tb_thread_a = &new_text_box_for_int (\%pr::beh, 'thread_a');
884 $bf->pack_start (&new_subpage_frame (
886 &new_text_box_for_int (\%pr::beh, 'hover_t'),
887 &new_check_button_for (\%pr::beh, 'warn_dnd')),
888 $xl::s{dnd_frame}, 'not-packed'),
889 FALSE, FALSE, FRAME_SPC);
890 $bf->pack_start (&new_subpage_frame (
892 &new_check_button_for (\%pr::beh, 'skip_ssl'),
893 &new_check_button_for (\%pr::beh, 'unsafe_ssl')),
894 $xl::s{ssl_frame}, 'not-packed'),
895 FALSE, FALSE, FRAME_SPC);
896 $bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
897 $bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
898 $bf->pack_start (&new_subpage_frame (
900 &new_check_button_for (\%pr::beh, 'flowed'),
901 &new_check_button_for (\%pr::beh, 'parts_rw'),
902 &new_check_button_for (\%pr::beh, 'use_utf8'),
903 &new_check_button_for (\%pr::beh, 'dangerous'),
904 &new_check_button_for (\%pr::beh, 'out_ascii'),
905 &new_check_button_for (\%pr::beh, 'pp_unsel'),
906 &new_check_button_for (\%pr::beh, 'inline_at')),
907 $xl::s{msgs_frame}, 'not-packed'),
908 FALSE, FALSE, FRAME_SPC);
913 %pr::col = ( # a variety of colours
916 $xl::s{l_col_emphasis},
917 $xl::s{h_col_emphasis},
925 $xl::s{l_col_log_err},
926 $xl::s{h_col_log_err},
934 $xl::s{l_col_log_in},
935 $xl::s{h_col_log_in},
943 $xl::s{l_col_log_msg},
944 $xl::s{h_col_log_msg},
952 $xl::s{l_col_log_out},
953 $xl::s{h_col_log_out},
961 $xl::s{l_col_log_warn},
962 $xl::s{h_col_log_warn},
970 sub new_colours_page() {
971 return &new_vbox_pack (
974 &new_color_button_for (\%pr::col, 'emphasis')),
975 $xl::s{msgview_frame}, 'not-packed'),
978 &new_color_button_for (\%pr::col, 'log_err'),
979 &new_color_button_for (\%pr::col, 'log_in'),
980 &new_color_button_for (\%pr::col, 'log_msg'),
981 &new_color_button_for (\%pr::col, 'log_out'),
982 &new_color_button_for (\%pr::col, 'log_warn')),
983 $xl::s{log_frame}, 'not-packed')
987 %pr::win = ( # tweak window positions and/or sizes
992 'int,0,3000', # 0 pixels - 3000 pixels
1001 'int,0,3000', # 0 pixels - 3000 pixels
1010 'int,0,3000', # 0 pixels - 3000 pixels
1019 'int,0,3000', # 0 pixels - 3000 pixels
1025 'mainwin_maximised',
1026 $xl::s{l_win_main_mx},
1027 $xl::s{h_win_main_mx},
1034 'mainwin_fullscreen',
1035 $xl::s{l_win_main_fs},
1036 $xl::s{h_win_main_fs},
1043 'main_messagewin_x',
1046 'int,0,3000', # 0 pixels - 3000 pixels
1052 'main_messagewin_y',
1055 'int,0,3000', # 0 pixels - 3000 pixels
1064 'int,0,3000', # 0 pixels - 3000 pixels
1070 'messagewin_height',
1073 'int,0,3000', # 0 pixels - 3000 pixels
1082 'int,0,3000', # 0 pixels - 3000 pixels
1091 'int,0,3000', # 0 pixels - 3000 pixels
1100 'int,0,3000', # 0 pixels - 3000 pixels
1106 'receivewin_height',
1109 'int,0,3000', # 0 pixels - 3000 pixels
1118 'int,0,3000', # 0 pixels - 3000 pixels
1127 'int,0,3000', # 0 pixels - 3000 pixels
1133 'folderitemwin_width',
1136 'int,0,3000', # 0 pixels - 3000 pixels
1142 'folderitemwin_height',
1145 'int,0,3000', # 0 pixels - 3000 pixels
1151 'folderselwin_width',
1154 'int,0,3000', # 0 pixels - 3000 pixels
1160 'folderselwin_height',
1163 'int,0,3000', # 0 pixels - 3000 pixels
1172 'int,0,3000', # 0 pixels - 3000 pixels
1181 'int,0,3000', # 0 pixels - 3000 pixels
1187 'addressbookwin_width',
1190 'int,0,3000', # 0 pixels - 3000 pixels
1196 'addressbookwin_height',
1199 'int,0,3000', # 0 pixels - 3000 pixels
1205 'addressbookeditpersonwin_width',
1208 'int,0,3000', # 0 pixels - 3000 pixels
1214 'addressbookeditpersonwin_height',
1217 'int,0,3000', # 0 pixels - 3000 pixels
1223 'addressbookeditgroupwin_width',
1226 'int,0,3000', # 0 pixels - 3000 pixels
1232 'addressbookeditgroupwin_height',
1235 'int,0,3000', # 0 pixels - 3000 pixels
1241 'addressaddwin_width',
1244 'int,0,3000', # 0 pixels - 3000 pixels
1250 'addressaddwin_height',
1253 'int,0,3000', # 0 pixels - 3000 pixels
1259 'addressbook_folderselwin_width',
1262 'int,0,3000', # 0 pixels - 3000 pixels
1268 'addressbook_folderselwin_height',
1271 'int,0,3000', # 0 pixels - 3000 pixels
1277 'editaccountwin_width',
1280 'int,0,3000', # 0 pixels - 3000 pixels
1286 'editaccountwin_height',
1289 'int,0,3000', # 0 pixels - 3000 pixels
1295 'accountswin_width',
1298 'int,0,3000', # 0 pixels - 3000 pixels
1304 'accountswin_height',
1307 'int,0,3000', # 0 pixels - 3000 pixels
1313 'filteringwin_width',
1316 'int,0,3000', # 0 pixels - 3000 pixels
1322 'filteringwin_height',
1325 'int,0,3000', # 0 pixels - 3000 pixels
1331 'filteringactionwin_width',
1334 'int,0,3000', # 0 pixels - 3000 pixels
1340 'filteringactionwin_height',
1343 'int,0,3000', # 0 pixels - 3000 pixels
1349 'filtering_debugwin_width',
1352 'int,0,3000', # 0 pixels - 3000 pixels
1358 'filtering_debugwin_height',
1361 'int,0,3000', # 0 pixels - 3000 pixels
1370 'int,0,3000', # 0 pixels - 3000 pixels
1376 'matcherwin_height',
1379 'int,0,3000', # 0 pixels - 3000 pixels
1388 'int,0,3000', # 0 pixels - 3000 pixels
1397 'int,0,3000', # 0 pixels - 3000 pixels
1403 'templateswin_width',
1406 'int,0,3000', # 0 pixels - 3000 pixels
1412 'templateswin_height',
1415 'int,0,3000', # 0 pixels - 3000 pixels
1424 'int,0,3000', # 0 pixels - 3000 pixels
1430 'actionswin_height',
1433 'int,0,3000', # 0 pixels - 3000 pixels
1442 'int,0,3000', # 0 pixels - 3000 pixels
1451 'int,0,3000', # 0 pixels - 3000 pixels
1460 'int,0,3000', # 0 pixels - 3000 pixels
1466 'pluginswin_height',
1469 'int,0,3000', # 0 pixels - 3000 pixels
1478 'int,0,3000', # 0 pixels - 3000 pixels
1487 'int,0,3000', # 0 pixels - 3000 pixels
1493 'print_previewwin_width',
1496 'int,0,3000', # 0 pixels - 3000 pixels
1502 'print_previewwin_height',
1505 'int,0,3000', # 0 pixels - 3000 pixels
1512 sub new_winpos_subpage_main() {
1513 return &new_subpage_frame (
1514 &new_vbox_pack_compact (
1516 &new_text_box_for_int (\%pr::win, 'main_x'),
1517 &new_text_box_for_int (\%pr::win, 'main_y')),
1519 &new_text_box_for_int (\%pr::win, 'main_w'),
1520 &new_text_box_for_int (\%pr::win, 'main_h')),
1522 &new_check_button_for (\%pr::win, 'main_fs'),
1523 &new_check_button_for (\%pr::win, 'main_mx'))),
1528 sub new_winpos_subpage_msgs() {
1529 return &new_subpage_frame (
1530 &new_vbox_pack_compact (
1532 &new_text_box_for_int (\%pr::win, 'msgs_x'),
1533 &new_text_box_for_int (\%pr::win, 'msgs_y')),
1535 &new_text_box_for_int (\%pr::win, 'msgs_w'),
1536 &new_text_box_for_int (\%pr::win, 'msgs_h'))),
1541 sub new_winpos_subpage_sendrecv() {
1542 return &new_vbox_pack (
1543 &new_subpage_frame (
1545 &new_text_box_for_int (\%pr::win, 'send_w'),
1546 &new_text_box_for_int (\%pr::win, 'send_h')),
1547 _('Send window'), 'not-packed'),
1548 &new_subpage_frame (
1550 &new_text_box_for_int (\%pr::win, 'recv_w'),
1551 &new_text_box_for_int (\%pr::win, 'recv_h')),
1552 _('Receive window'), 'not-packed')
1556 sub new_winpos_subpage_fold() {
1557 return &new_vbox_pack (
1558 &new_subpage_frame (
1559 &new_vbox_pack_compact (
1561 &new_text_box_for_int (\%pr::win, 'fold_x'),
1562 &new_text_box_for_int (\%pr::win, 'fold_y')),
1564 &new_text_box_for_int (\%pr::win, 'fold_w'),
1565 &new_text_box_for_int (\%pr::win, 'fold_h'))),
1566 _('Folder window'), 'not-packed'),
1567 &new_subpage_frame (
1569 &new_text_box_for_int (\%pr::win, 'fsel_w'),
1570 &new_text_box_for_int (\%pr::win, 'fsel_h')),
1571 _('Folder selection window'), 'not-packed')
1575 sub new_winpos_subpage_addrbook() {
1576 return &new_vbox_pack (
1577 &new_subpage_frame (
1579 &new_text_box_for_int (\%pr::win, 'addr_w'),
1580 &new_text_box_for_int (\%pr::win, 'addr_h')),
1581 _('Addressbook main window'), 'not-packed'),
1582 &new_subpage_frame (
1584 &new_text_box_for_int (\%pr::win, 'adep_w'),
1585 &new_text_box_for_int (\%pr::win, 'adep_h')),
1586 _('Edit person window'), 'not-packed'),
1587 &new_subpage_frame (
1589 &new_text_box_for_int (\%pr::win, 'adeg_w'),
1590 &new_text_box_for_int (\%pr::win, 'adeg_h')),
1591 _('Edit group window'), 'not-packed'),
1592 &new_subpage_frame (
1594 &new_text_box_for_int (\%pr::win, 'adda_w'),
1595 &new_text_box_for_int (\%pr::win, 'adda_h')),
1596 _('Add address window'), 'not-packed'),
1597 &new_subpage_frame (
1599 &new_text_box_for_int (\%pr::win, 'addf_w'),
1600 &new_text_box_for_int (\%pr::win, 'addf_h')),
1601 _('Folder select window'), 'not-packed')
1605 sub new_winpos_subpage_accounts() {
1606 return &new_vbox_pack (
1607 &new_subpage_frame (
1609 &new_text_box_for_int (\%pr::win, 'acco_w'),
1610 &new_text_box_for_int (\%pr::win, 'acco_h')),
1611 _('Accounts window'), 'not-packed'),
1612 &new_subpage_frame (
1614 &new_text_box_for_int (\%pr::win, 'acce_w'),
1615 &new_text_box_for_int (\%pr::win, 'acce_h')),
1616 _('Edit account window'), 'not-packed')
1620 sub new_winpos_subpage_filtering() {
1621 return &new_vbox_pack (
1622 &new_subpage_frame (
1624 &new_text_box_for_int (\%pr::win, 'filt_w'),
1625 &new_text_box_for_int (\%pr::win, 'filt_h')),
1626 _('Filtering window'), 'not-packed'),
1627 &new_subpage_frame (
1629 &new_text_box_for_int (\%pr::win, 'fila_w'),
1630 &new_text_box_for_int (\%pr::win, 'fila_h')),
1631 _('Filtering actions window'), 'not-packed'),
1632 &new_subpage_frame (
1634 &new_text_box_for_int (\%pr::win, 'fild_w'),
1635 &new_text_box_for_int (\%pr::win, 'fild_h')),
1636 _('Filtering debug window'), 'not-packed'),
1637 &new_subpage_frame (
1639 &new_text_box_for_int (\%pr::win, 'matc_w'),
1640 &new_text_box_for_int (\%pr::win, 'matc_h')),
1641 _('Matcher window'), 'not-packed')
1645 sub new_winpos_subpage_prefs() {
1646 return &new_vbox_pack (
1647 &new_subpage_frame (
1649 &new_text_box_for_int (\%pr::win, 'pref_w'),
1650 &new_text_box_for_int (\%pr::win, 'pref_h')),
1651 _('Preferences window'), 'not-packed'),
1652 &new_subpage_frame (
1654 &new_text_box_for_int (\%pr::win, 'temp_w'),
1655 &new_text_box_for_int (\%pr::win, 'temp_h')),
1656 _('Templates window'), 'not-packed'),
1657 &new_subpage_frame (
1659 &new_text_box_for_int (\%pr::win, 'acti_w'),
1660 &new_text_box_for_int (\%pr::win, 'acti_h')),
1661 _('Actions window'), 'not-packed'),
1662 &new_subpage_frame (
1664 &new_text_box_for_int (\%pr::win, 'tags_w'),
1665 &new_text_box_for_int (\%pr::win, 'tags_h')),
1666 _('Tags window'), 'not-packed'),
1667 &new_subpage_frame (
1669 &new_text_box_for_int (\%pr::win, 'plug_w'),
1670 &new_text_box_for_int (\%pr::win, 'plug_h')),
1671 _('Plugins window'), 'not-packed')
1675 sub new_winpos_subpage_misc() {
1676 return &new_vbox_pack (
1677 &new_subpage_frame (
1679 &new_text_box_for_int (\%pr::win, 'logw_w'),
1680 &new_text_box_for_int (\%pr::win, 'logw_h')),
1681 _('Log window'), 'not-packed'),
1682 &new_subpage_frame (
1684 &new_text_box_for_int (\%pr::win, 'prin_w'),
1685 &new_text_box_for_int (\%pr::win, 'prin_h')),
1686 _('Print preview window'), 'not-packed'),
1687 &new_subpage_frame (
1689 &new_text_box_for_int (\%pr::win, 'sour_w'),
1690 &new_text_box_for_int (\%pr::win, 'sour_h')),
1691 _('View source window'), 'not-packed')
1695 sub new_winpos_page() {
1696 my $winbook = Gtk2::Notebook->new;
1697 $winbook->set_tab_pos ('right');
1698 $winbook->append_page (&new_winpos_subpage_main, _('Main'));
1699 $winbook->append_page (&new_winpos_subpage_msgs, _('Message'));
1700 $winbook->append_page (&new_winpos_subpage_sendrecv, _('Send/Receive'));
1701 $winbook->append_page (&new_winpos_subpage_fold, _('Folder'));
1702 $winbook->append_page (&new_winpos_subpage_addrbook, _('Addressbook'));
1703 $winbook->append_page (&new_winpos_subpage_accounts, _('Accounts'));
1704 $winbook->append_page (&new_winpos_subpage_filtering, _('Filtering'));
1705 $winbook->append_page (&new_winpos_subpage_prefs, _('Preferences'));
1706 $winbook->append_page (&new_winpos_subpage_misc, _('Other'));
1711 sub print_version() {
1712 print $xl::s{about_title} . "\n";
1713 print $xl::s{about_version} . " $VERSION\n";
1714 print "Perl-GLib " . $Glib::VERSION;
1715 # version info stuff appeared in 1.040
1716 if ($Glib::VERSION >= 1.040) {
1717 print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
1718 . _(", running with ") . join(".", &Glib::major_version,
1719 &Glib::minor_version, &Glib::micro_version);
1722 print "Perl-GTK2 " . $Gtk2::VERSION;
1723 if ($Gtk2::VERSION >= 1.040) {
1724 print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
1725 . _(", running with ") . join(".", &Gtk2::major_version,
1726 &Gtk2::minor_version, &Gtk2::micro_version);
1729 my $clawsver = ($CLAWSV eq "") ?
1730 _("was not found!") :
1731 (_("returned version ") . $CLAWSV);
1732 print "Claws Mail " . $clawsver . "\n";
1735 # the command line help
1737 my $line = '-' x length ($xl::s{about_title}) . "\n";
1739 print $xl::s{about_title} . "\n";
1741 print _("Syntax:\n");
1742 print _(" clawsker [options]\n");
1743 print _("Options:\n");
1744 print _(" --help Prints this help screen.\n");
1745 print _(" --version Prints version infos.\n");
1746 print _(" --verbose More messages on standard output.\n");
1747 print _(" --alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
1748 print _(" --clawsrc <file> Uses <file> as full resource name.\n");
1751 # handle errors which don't allow to run
1752 sub command_line_fatal() {
1754 my $emsg = $xl::s{e_error} . $reason;
1755 error_dialog ($emsg);
1756 log_message ("$emsg", 'die');
1759 # parse the command line
1760 sub parse_command_line() {
1761 $CLAWSV = &get_claws_version;
1763 while (defined($ARGV[$arg])) {
1777 /--use-claws-version/ && do {
1779 &command_line_fatal ("required version")
1780 unless defined($ARGV[$arg]);
1781 &command_line_fatal ("required a dotted numeric value")
1782 unless ($ARGV[$arg] =~ /[\d\.]+/);
1783 $CLAWSV = $ARGV[$arg];
1786 /--alternate-config-dir/ && do {
1788 &command_line_fatal ($xl::s{e_requireddir})
1789 unless defined($ARGV[$arg]);
1790 &command_line_fatal ($xl::s{e_notadir})
1791 unless -d $ARGV[$arg];
1792 $CONFIGDIR = $ARGV[$arg];
1794 unless ($CONFIGDIR =~ /.*\/$/);
1795 $ALTCONFIGDIR = TRUE;
1800 &command_line_fatal($xl::s{e_requiredfile})
1801 unless defined($ARGV[$arg]);
1802 &command_line_fatal($xl::s{e_notafile})
1803 unless -f $ARGV[$arg];
1804 &set_rc_filename ($ARGV[$arg]);
1807 /.*/ && &command_line_fatal (
1808 _("unknown option '{opt}'.\n", opt => $ARGV[$arg]));
1812 # eveything continues...
1816 # update the hidden preferences status from loaded values
1817 sub init_hidden_preferences() {
1818 foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
1819 foreach my $key (keys %$hash) {
1820 $HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
1826 # load current status from disc
1827 sub load_preferences() {
1828 my $rc = &get_rc_filename;
1829 &log_message ("Loading preferences from $rc\n");
1830 return FALSE unless &check_rc_file ($rc);
1831 return FALSE unless &check_claws_not_running;
1835 if (/^([8a-z_]+)=(.*)$/) {
1843 # save current preferences to disc
1844 sub save_preferences() {
1845 my $rc = &get_rc_filename;
1846 &log_message ("Saving preferences to $rc\n");
1847 return FALSE unless &check_rc_file ($rc);
1848 return FALSE unless &check_claws_not_running;
1849 my $rcbak = "$rc.backup";
1850 rename ($rc, $rcbak);
1852 open (RCB, "<$rcbak");
1855 if (/^([8a-z_]+)=(.*)$/) {
1856 if (defined($HPVALUE{$1})) {
1857 print RCF $1 . "=" . $HPVALUE{$1} . "\n";
1860 print RCF $_ . "\n";
1864 print RCF $_ . "\n";
1873 sub new_notebook() {
1874 my $nb = Gtk2::Notebook->new;
1876 $nb->append_page (&new_behaviour_page, $xl::s{tab_behaviour});
1877 $nb->append_page (&new_colours_page, $xl::s{tab_colours});
1878 $nb->append_page (&new_gui_page, $xl::s{tab_gui});
1879 $nb->append_page (&new_other_page, $xl::s{tab_other});
1880 $nb->append_page (&new_winpos_page, $xl::s{tab_winpos});
1885 # create an about dialog
1886 sub new_about_dialog() {
1888 my $title = $xl::s{about_title};
1889 my $lic = $xl::s{about_license};
1890 my $vers = $xl::s{about_version} . " $VERSION";
1892 "This program is free software: you can redistribute it and/or modify
1893 it under the terms of the GNU General Public License as published by
1894 the Free Software Foundation, either version 3 of the License, or
1895 (at your option) any later version.
1897 This program is distributed in the hope that it will be useful,
1898 but WITHOUT ANY WARRANTY; without even the implied warranty of
1899 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1900 GNU General Public License for more details.
1902 You should have received a copy of the GNU General Public License
1903 along with this program. If not, see <http://www.gnu.org/licenses/>.";
1904 my $year = "2007-2011";
1905 my $holder = "Ricardo Mones <ricardo\@mones.org>";
1906 my $url = "http://www.claws-mail.org/clawsker";
1908 my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
1909 [qw/modal destroy-with-parent/],
1911 "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
1912 . "<span size=\"large\">$vers</span>\n\n"
1913 . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
1914 . "<span>Copyright $year by $holder</span>\n\n"
1915 . "<span size=\"large\">$lic</span>\n\n"
1916 . "<span size=\"small\">$license</span>");
1917 $dialog->set_title ($xl::s{about});
1922 # create buttons box
1923 sub new_button_box() {
1924 my ($parent, $adlg) = @_;
1925 my $b_about = Gtk2::Button->new_from_stock ('gtk-about');
1926 my $b_exit = Gtk2::Button->new_from_stock ('gtk-quit');
1927 my $b_apply = Gtk2::Button->new_from_stock ('gtk-apply');
1928 # disable button until is really implemented
1929 # my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
1930 my $hbox = Gtk2::HBox->new (FALSE, 5);
1932 $b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
1933 $b_apply->signal_connect (clicked => sub { &save_preferences ($parent) });
1934 # $b_undo->signal_connect (clicked => sub { &undo_current_changes });
1935 $b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
1937 $hbox->pack_end ($b_apply, FALSE, FALSE, 0);
1938 $hbox->pack_end ($b_exit, FALSE, FALSE, 0);
1939 # $hbox->pack_end ($b_undo, FALSE, FALSE, 0);
1940 $hbox->pack_start ($b_about, FALSE, FALSE, 0);
1946 $main_window = Gtk2::Window->new ('toplevel');
1947 exit unless &parse_command_line;
1948 exit unless &load_preferences;
1949 exit unless &init_hidden_preferences;
1951 my $box = Gtk2::VBox->new (FALSE, 5);
1952 $box->set_border_width(3);
1953 my $about = &new_about_dialog;
1954 $box->pack_start (&new_notebook, FALSE, FALSE, 0);
1955 $box->pack_end (&new_button_box ($main_window, $about), FALSE, FALSE, 0);
1956 $main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
1957 $main_window->set_title ($xl::s{win_title});
1958 $main_window->add ($box);
1959 $main_window->show_all;