X-Git-Url: http://git.claws-mail.org/?p=clawsker.git;a=blobdiff_plain;f=clawsker;h=0378514cdc4dc7fb7c0606e74384db610dc3863f;hp=9d578a20bdbb2f2a4c172f4363b9109974972224;hb=1844beb53658b5fbea9f55284e149584ae82d28a;hpb=a851e306b5188ac780aff7071eb34ed141f30966
diff --git a/clawsker b/clawsker
index 9d578a2..0378514 100755
--- a/clawsker
+++ b/clawsker
@@ -28,8 +28,19 @@ using Clawsker.
=head1 OPTIONS
-No options are currently available.
+--help
+ Shows a brief help screen.
+--alternate-config-dir
+ Uses as Claws Mail configuration dir.
+
+--clawsrc
+ Uses 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.
@@ -69,14 +80,14 @@ my $LIBDIR = '@LIBDIR@';
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;
@@ -105,8 +116,9 @@ sub _ {
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.'),
@@ -176,18 +188,21 @@ sub _ {
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
@@ -260,6 +275,23 @@ sub handle_selection_value {
$$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 {
@@ -288,6 +320,7 @@ sub new_text_box_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 {
@@ -311,6 +344,7 @@ sub new_color_button_for {
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});
@@ -374,11 +408,12 @@ sub new_selection_box_for {
sub new_other_page() {
my $of = Gtk2::VBox->new (FALSE, 5);
- $of->set_border_width(PAGE_SPC);
+ $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);
@@ -386,6 +421,7 @@ sub new_other_page() {
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);
@@ -478,38 +514,46 @@ sub new_other_page() {
sub new_gui_page() {
my $gf = Gtk2::VBox->new (FALSE, 5);
- $gf->set_border_width(PAGE_SPC);
+ $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);
@@ -592,12 +636,13 @@ sub new_gui_page() {
sub new_behaviour_page() {
my $bf = Gtk2::VBox->new (FALSE, 5);
- $bf->set_border_width(PAGE_SPC);
+ $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);
@@ -606,6 +651,7 @@ sub new_behaviour_page() {
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);
@@ -619,6 +665,7 @@ sub new_behaviour_page() {
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);
@@ -681,11 +728,12 @@ sub new_behaviour_page() {
sub new_colours_page() {
my $cf = Gtk2::VBox->new (FALSE, 5);
- $cf->set_border_width(PAGE_SPC);
+ $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);
@@ -696,6 +744,7 @@ sub new_colours_page() {
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);
@@ -709,6 +758,55 @@ sub new_colours_page() {
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 Uses as Claws Mail config dir.\n");
+ print _(" --clawsrc Uses 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) {
@@ -720,8 +818,9 @@ sub init_hidden_preferences() {
# 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 () {
chomp;
@@ -734,7 +833,9 @@ sub load_preferences() {
# 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");
@@ -828,6 +929,7 @@ sub new_button_box() {
}
# initialise
+&parse_command_line;
&load_preferences;
&init_hidden_preferences;
# create main GUI