=head1 OPTIONS
-No options are currently available.
+--help
+ Shows a brief help screen.
+--alternate-config-dir <dir>
+ Uses <dir> as Claws Mail configuration dir.
+
+--clawsrc <file>
+ Uses <file> as Claws Mail resource configuration file. This sets
+ the full file name overriding any previous setting.
+
+Multiple options are allowed, although only the last one has effect. Weird
+option specifications may produce weird results (but otherwise correct).
+
=head1 LIMITATIONS
Alternate configuration directories are not (yet) supported.
my $VERSION = '@VERSION@';
my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
-setlocale(LC_ALL, $locale);
-bindtextdomain(lc($NAME), sprintf('%s/share/locale', $PREFIX));
-textdomain(lc($NAME));
+setlocale (LC_ALL, $locale);
+bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
+textdomain ($NAME);
sub _ {
my $str = shift;
my %par = @_;
- my $xla = gettext($str);
+ my $xla = gettext ($str);
if (scalar(keys(%par)) > 0) {
foreach my $key (keys %par) {
$xla =~ s/\{$key\}/$par{$key}/g;
%xl::s = (
win_title => _('Claws Mail Hidden Preferences'),
about => _('About...'),
- about_title => _('Clawsker ~ A Claws Mail Tweaker'),
+ about_title => _('Clawsker :: A Claws Mail Tweaker'),
about_license => _('License:'),
about_version => _('Version:'),
dnd_frame => _('Drag and drop'),
ssl_frame => _('Secure Sockets Layer'),
msgs_frame => _('Messages'),
- stripes_frame => _('Stripes'),
+ stripes_frame => _('Coloured stripes'),
sbar_frame => _('Scroll bars'),
+ mlist_frame => _('Message list'),
l_oth_use_dlg => _('Use address book dialog'),
h_oth_use_dlg => _('If true use a separate dialogue to edit a person\'s details. Otherwise will use a form embedded in the addressbook\'s main window.'),
h_col_log_warn => _('Colour for warning messages in log window.'),
e_error => _('Error: '),
- e_noclawsrc => _('no $HOME/.claws-mail/clawsrc file found.'),
+ e_noclawsrc => _('resource file for Claws Mail was not found.'),
e_running => _('seems Claws Mail is currently running, close it first.'),
+ e_requireddir => _('option requires a directory name.'),
+ e_requiredfile => _('option requires a file name.'),
+ e_notadir => _('specified name is not a directory or does not exist.'),
+ e_notafile => _('specified name is not a file or does not exist.'),
);
-# check if claws is running
-my $socket = "/tmp/claws-mail-$<";
--S $socket and die "$xl::s{e_error}$xl::s{e_running}\n";
-
# all preferences read by load_preferences
my %PREFS = ();
# values of all preferences handled by clawsker
my %HPVALUE = ();
+# default config dir and file name
+my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
+my $CONFIGRC = 'clawsrc';
# index constants for preference arrays
use constant NAME => 0; # the name on the rc file
# constants for GUI spacing
use constant HBOX_SPC => 5;
use constant FRAME_SPC => 2;
+use constant PAGE_SPC => 5;
# data handlers and auxiliar functions
$$dataref = $widget->get_active;
}
+sub get_rc_filename {
+ return $CONFIGDIR . $CONFIGRC;
+}
+
+sub set_rc_filename {
+ my ($fullname) = @_;
+ my @parts = split ('/', $fullname);
+ $CONFIGRC = $parts[$#parts];
+ $parts[$#parts] = '';
+ $CONFIGDIR = join ('/', @parts);
+}
+
+sub check_claws_not_running() {
+ my $socket = "/tmp/claws-mail-$<";
+ -S $socket and die "$xl::s{e_error}$xl::s{e_running}\n";
+}
+
# graphic element creation
sub new_check_button_for {
my $hbox = Gtk2::HBox->new (FALSE, 5);
my $glabel = Gtk2::Label->new ($label);
my $gentry = Gtk2::Entry->new;
+ $gentry->set_width_chars (8);
$$hash{$key}[GUI] = $gentry;
$gentry->set_text($HPVALUE{$name});
$gentry->signal_connect(changed => sub {
my $button = Gtk2::ColorButton->new_with_color ($col);
$$hash{$key}[GUI] = $button;
$button->set_title ($label);
+ $button->set_relief ('none');
$button->signal_connect ('color-set' => sub {
my ($w, $e) = @_;
&handle_color_value($w, $e, \$HPVALUE{$name});
sub new_other_page() {
my $of = Gtk2::VBox->new (FALSE, 5);
+ $of->set_border_width (PAGE_SPC);
my $ab_frame = Gtk2::Frame->new ($xl::s{ab_frame});
my $cb_use_dlg = &new_check_button_for(\%pr::oth, 'use_dlg');
my $vb1 = Gtk2::VBox->new (FALSE, 5);
+ $vb1->set_border_width (PAGE_SPC);
$vb1->pack_start ($cb_use_dlg, FALSE, FALSE, 0);
$ab_frame->add ($vb1);
my $tb_max_use = &new_text_box_for(\%pr::oth, 'max_use');
my $tb_min_time = &new_text_box_for(\%pr::oth, 'min_time');
my $vb2 = Gtk2::VBox->new (FALSE, 5);
+ $vb2->set_border_width (PAGE_SPC);
$vb2->pack_start ($tb_max_use, FALSE, FALSE, 0);
$vb2->pack_start ($tb_min_time, FALSE, FALSE, 0);
$mem_frame->add ($vb2);
sub new_gui_page() {
my $gf = Gtk2::VBox->new (FALSE, 5);
+ $gf->set_border_width (PAGE_SPC);
my $stripes_frame = Gtk2::Frame->new ($xl::s{stripes_frame});
my $cb_strip_all = &new_check_button_for (\%pr::gui, 'strip_all');
my $cb_strip_sum = &new_check_button_for (\%pr::gui, 'strip_sum');
my $tb_strip_off = &new_text_box_for (\%pr::gui, 'strip_off');
my $vb1 = Gtk2::VBox->new (FALSE, 5);
+ $vb1->set_border_width (PAGE_SPC);
$vb1->pack_start ($cb_strip_all, FALSE, FALSE, 0);
$vb1->pack_start ($cb_strip_sum, FALSE, FALSE, 0);
$vb1->pack_start ($tb_strip_off, FALSE, FALSE, 0);
$stripes_frame->add ($vb1);
+ my $mlist_frame = Gtk2::Frame->new ($xl::s{mlist_frame});
+ my $cb_b_unread = &new_check_button_for (\%pr::gui, 'b_unread');
+ my $cb_swp_from = &new_check_button_for (\%pr::gui, 'swp_from');
+ my $vb3 = Gtk2::VBox->new (FALSE, 5);
+ $vb3->set_border_width (PAGE_SPC);
+ $vb3->pack_start ($cb_b_unread, FALSE, FALSE, 0);
+ $vb3->pack_start ($cb_swp_from, FALSE, FALSE, 0);
+ $mlist_frame->add ($vb3);
+
my $sbar_frame = Gtk2::Frame->new ($xl::s{sbar_frame});
my $cb_h_scroll = &new_check_button_for (\%pr::gui, 'h_scroll');
my $sb_v_scroll = &new_selection_box_for (\%pr::gui, 'v_scroll');
my $vb2 = Gtk2::VBox->new (FALSE, 5);
+ $vb2->set_border_width (PAGE_SPC);
$vb2->pack_start ($cb_h_scroll, FALSE, FALSE, 0);
$vb2->pack_start ($sb_v_scroll, FALSE, FALSE, 0);
$sbar_frame->add ($vb2);
- my $cb_b_unread = &new_check_button_for (\%pr::gui, 'b_unread');
my $cb_no_markup = &new_check_button_for (\%pr::gui, 'no_markup');
my $cb_dot_lines = &new_check_button_for (\%pr::gui, 'dot_lines');
- my $cb_swp_from = &new_check_button_for (\%pr::gui, 'swp_from');
my $cb_cursor_v = &new_check_button_for (\%pr::gui, 'cursor_v');
my $cb_toolbar_d = &new_check_button_for (\%pr::gui, 'toolbar_d');
$gf->pack_start ($stripes_frame, FALSE, FALSE, FRAME_SPC);
- $gf->pack_start ($cb_b_unread, FALSE, FALSE, 0);
+ $gf->pack_start ($mlist_frame, FALSE, FALSE, FRAME_SPC);
$gf->pack_start ($cb_no_markup, FALSE, FALSE, 0);
$gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
- $gf->pack_start ($cb_swp_from, FALSE, FALSE, 0);
$gf->pack_start ($cb_cursor_v, FALSE, FALSE, 0);
$gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
$gf->pack_start ($sbar_frame, FALSE, FALSE, FRAME_SPC);
sub new_behaviour_page() {
my $bf = Gtk2::VBox->new (FALSE, 5);
+ $bf->set_border_width (PAGE_SPC);
my $dnd_frame = Gtk2::Frame->new ($xl::s{dnd_frame});
my $tb_hoover_t = &new_text_box_for (\%pr::beh, 'hover_t');
my $cb_warn_dnd = &new_check_button_for (\%pr::beh, 'warn_dnd');
my $vb1 = Gtk2::VBox->new (FALSE, 5);
+ $vb1->set_border_width (PAGE_SPC);
$vb1->pack_start ($cb_warn_dnd, FALSE, FALSE, 0);
$vb1->pack_start ($tb_hoover_t, FALSE, FALSE, 0);
$dnd_frame->add ($vb1);
my $cb_skip_ssl = &new_check_button_for (\%pr::beh, 'skip_ssl');
my $cb_unsafe_ssl = &new_check_button_for (\%pr::beh, 'unsafe_ssl');
my $hb1 = Gtk2::HBox->new (FALSE, 5);
+ $hb1->set_border_width (PAGE_SPC);
$hb1->pack_start ($cb_skip_ssl, FALSE, FALSE, 0);
$hb1->pack_start ($cb_unsafe_ssl, FALSE, FALSE, 0);
$ssl_frame->add ($hb1);
my $cb_use_utf8 = &new_check_button_for (\%pr::beh, 'use_utf8');
my $cb_dangerous = &new_check_button_for (\%pr::beh, 'dangerous');
my $vb2 = Gtk2::VBox->new (FALSE, 5);
+ $vb2->set_border_width (PAGE_SPC);
$vb2->pack_start ($cb_flowed, FALSE, FALSE, 0);
$vb2->pack_start ($cb_parts_rw, FALSE, FALSE, 0);
$vb2->pack_start ($cb_use_utf8, FALSE, FALSE, 0);
sub new_colours_page() {
my $cf = Gtk2::VBox->new (FALSE, 5);
+ $cf->set_border_width (PAGE_SPC);
my $msgview_frame = Gtk2::Frame->new ($xl::s{msgview_frame});
my $cb_emphasis = &new_color_button_for (\%pr::col, 'emphasis');
my $vb1 = Gtk2::VBox->new (FALSE, 5);
+ $vb1->set_border_width (PAGE_SPC);
$vb1->pack_start ($cb_emphasis, FALSE, FALSE, 0);
$msgview_frame->add ($vb1);
my $cb_log_out = &new_color_button_for (\%pr::col, 'log_out');
my $cb_log_warn = &new_color_button_for (\%pr::col, 'log_warn');
my $vb2 = Gtk2::VBox->new (FALSE, 5);
+ $vb2->set_border_width (PAGE_SPC);
$vb2->pack_start ($cb_log_err, FALSE, FALSE, 0);
$vb2->pack_start ($cb_log_in, FALSE, FALSE, 0);
$vb2->pack_start ($cb_log_msg, FALSE, FALSE, 0);
$cf->pack_start ($msgview_frame, FALSE, FALSE, 0);
$cf->pack_start ($log_frame, FALSE, FALSE, 0);
+
return $cf;
}
+# the command line help
+sub print_help() {
+ my $line = '-' x length ($xl::s{about_title}) . "\n";
+ print $line;
+ print $xl::s{about_title} . "\n";
+ print $xl::s{about_version} . " $VERSION\n";
+ print $line;
+ print _("Syntax:\n");
+ print _(" clawsker [options]\n");
+ print _("Options:\n");
+ print _(" --help Prints this help screen.\n");
+ print _(" --alternate-config-dir <dir> Uses <dir> as Claws Mail config dir.\n");
+ print _(" --clawsrc <file> Uses <file> as full resource name.\n");
+}
+
+# parse the command line
+sub parse_command_line() {
+ my $arg = 0;
+ while (defined($ARGV[$arg])) {
+ for ($ARGV[$arg]) {
+ /--help/ && do {
+ &print_help;
+ exit 0;
+ };
+ /--alternate-config-dir/ && do {
+ ++$arg;
+ die "$xl::s{e_error}$xl::s{e_requireddir}\n"
+ unless defined($ARGV[$arg]);
+ die "$xl::s{e_error}$xl::s{e_notadir}\n"
+ unless -d $ARGV[$arg];
+ $CONFIGDIR = $ARGV[$arg];
+ last;
+ };
+ /--clawsrc/ && do {
+ ++$arg;
+ die "$xl::s{e_error}$xl::s{e_requiredfile}\n"
+ unless defined($ARGV[$arg]);
+ die "$xl::s{e_error}$xl::s{e_notafile}\n"
+ unless -f $ARGV[$arg];
+ &set_rc_filename ($ARGV[$arg]);
+ last;
+ };
+ /.*/ && die $xl::s{e_error}
+ . _("unknown option '{opt}'.\n", opt => $ARGV[$arg]);
+ }
+ ++$arg;
+ }
+}
+
# update the hidden preferences status from loaded values
sub init_hidden_preferences() {
foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth) {
# load current status from disc
sub load_preferences() {
- my $rc = $ENV{HOME} . '/.claws-mail/clawsrc';
+ my $rc = &get_rc_filename;
-f $rc or die "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
+ &check_claws_not_running;
open (RCF, "<$rc");
while (<RCF>) {
chomp;
# save current preferences to disc
sub save_preferences() {
- my $rc = $ENV{HOME} . '/.claws-mail/clawsrc';
+ my $rc = &get_rc_filename;
+ -f $rc or die "$xl::s{e_error}$xl::s{e_noclawsrc}\n";
+ &check_claws_not_running;
my $rcbak = "$rc.backup";
rename ($rc, $rcbak);
open (RCF, ">$rc");
return $hbox;
}
-# initialise values
+# initialise
+&parse_command_line;
&load_preferences;
&init_hidden_preferences;
# create main GUI
my $window = Gtk2::Window->new ('toplevel');
my $box = Gtk2::VBox->new (FALSE, 5);
+$box->set_border_width(3);
my $about = &new_about_dialog;
$box->pack_start (&new_notebook, FALSE, FALSE, 0);
$box->pack_end (&new_button_box ($about), FALSE, FALSE, 0);
-
+$window->signal_connect (delete_event => sub { Gtk2->main_quit });
$window->set_title ($xl::s{win_title});
$window->add ($box);
$window->show_all;