my $DATADIR = '@DATADIR@';
my $VERSION = '@VERSION@';
my $VERBOSE = FALSE;
+my $READONLY = FALSE;
my $CLAWSV = undef;
my $main_window = undef;
tab_gui => _('GUI'),
tab_other => _('Other'),
tab_winpos => _('Windows'),
+ tab_accounts => _('Accounts'),
ab_frame => _('Addressbook'),
mem_frame => _('Memory'),
h_oth_use_netm => _('Use NetworkManager to switch offline automatically.'),
l_oth_mp_rounds => _('Rounds for PBKDF2 function'),
h_oth_mp_rounds => _('Specify the number of iterations the key derivation function will be applied on master passphrase computation. Does not modify currently stored passphrase, only master passphrases computed after changing this value are affected.'),
-
+
l_gui_b_unread => _('Show unread messages with bold font'),
h_gui_b_unread => _('Show unread messages in the Message List using a bold font.'),
l_gui_no_markup => _('Don\'t use markup'),
l_win_main_fs => _('Full-screen'),
h_win_main_fs => _('Changes full screen status.'),
+ l_acc_gtls_set => _('Use custom GnuTLS priority'),
+ h_acc_gtls_set => _('Enables using user provided GnuTLS priority string.'),
+ l_acc_gtls_pri => _('GnuTLS priority'),
+ h_acc_gtls_pri => _('Value to use as GnuTLS priority string if custom priority check is enabled. Otherwise this value is ignored.'),
+
e_error => _('Error: '),
e_noclawsrc => _('resource file for Claws Mail was not found.'),
e_running => _('seems Claws Mail is currently running, close it first.'),
my %ACPREFS = ();
# values of all preferences handled by clawsker
my %HPVALUE = ();
+my %ACHPVALUE = ();
# default config dir and file name
my $ALTCONFIGDIR = FALSE;
my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
push (@version, '0');
}
my $idx = 0;
- while (($idx <= $#refvers)
+ while (($idx <= $#refvers)
and (int ($version[$idx]) == int ($refvers[$idx]))) {
++$idx;
}
}
sub handle_nchar_value {
- my ($widget, $event, $dataref, $minlen) = @_;
- $_ = substr ($widget->get_text (), 0, $minlen);
+ my ($widget, $event, $dataref, $minlen, $maxlen) = @_;
+ $_ = substr ($widget->get_text (), 0, $maxlen);
$widget->set_text ($_);
$$dataref = $_;
}
$_ = uc ($str);
if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
$rr = hex($1) * 256;
- $gg = hex($2) * 256;
+ $gg = hex($2) * 256;
$bb = hex($3) * 256;
}
my $color = Gtk2::Gdk::Color->new ($rr, $gg, $bb);
}
sub check_claws_not_running {
+ return TRUE if $READONLY;
my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
$tmpdir = '/tmp' if ($tmpdir eq '');
my $lockdir = "$tmpdir/claws-mail-$<";
- -d $lockdir and do {
+ -d $lockdir and do {
$_ = $CONFIGDIR;
s/\/$//;
my $socket = "$lockdir/" . md5_hex ($_);
sub set_widget_hint {
if ($SHOWHINTS) {
- my ($wdgt, $hint) = @_;
+ my ($wdgt, $hint) = @_;
$wdgt->set_tooltip_text ($hint);
$wdgt->set_has_tooltip (TRUE);
}
}
}
-# graphic element creation
+# graphic element creation
sub new_check_button_for($$$) {
my ($hash, $key, $vhash) = @_;
my $name = $$hash{$key}[NAME];
my $label = $$hash{$key}[LABEL];
my @type = split (/,/, $$hash{$key}[TYPE]);
- push (@type, 0), push (@type, 10000) unless ($#type > 0);
+ push (@type, 0), push (@type, 10000) unless ($#type > 0);
#
my $hbox = Gtk2::HBox->new (FALSE, 5);
my $glabel = Gtk2::Label->new ($label);
my ($hash, $key, $vhash) = @_;
my $name = $$hash{$key}[NAME];
my $label = $$hash{$key}[LABEL];
- my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen
+ my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen,width
my $hbox = Gtk2::HBox->new (FALSE, 5);
my $glabel = Gtk2::Label->new ($label);
my $gentry = Gtk2::Entry->new ();
$gentry->set_max_length($type[2]) if defined ($type[2]);
- $gentry->set_width_chars(int ($type[2]) + 2) if defined ($type[2]);
+ my $width = $type[3];
+ $width //= $type[2];
+ $gentry->set_width_chars(int ($width) + 2) if defined ($width);
my $value = $$vhash{$name};
$value //= $$hash{$key}[CMDEF];
$gentry->set_text ($value);
$gentry->signal_connect('key-release-event' => sub {
my ($w, $e) = @_;
- handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1]);
+ handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1], $type[2]);
});
set_widget_hint ($gentry, $$hash{$key}[DESC]);
set_widget_sens ($gentry, $$hash{$key}[CMVER]);
$hbox->pack_start ($item, FALSE, FALSE, 0);
}
return $hbox;
-}
+}
sub new_vbox_pack {
my $vbox = Gtk2::VBox->new (FALSE, 5);
$vbox->pack_start ($item, FALSE, FALSE, 0);
}
return $vbox;
-}
+}
sub new_vbox_pack_compact {
my $vbox = Gtk2::VBox->new (FALSE, 0);
$vbox->pack_start ($item, FALSE, FALSE, 0);
}
return $vbox;
-}
+}
sub new_subpage_frame {
my ($box, $title, $notpacked) = @_;
my $frame = Gtk2::Frame->new ($title);
- $frame->add ($box);
+ $frame->add ($box);
return new_vbox_pack ($frame) unless defined ($notpacked);
return $frame;
}
# preference maps and corresponding page creation subs
%pr::oth = ( # other preferences
- use_dlg => [
+ use_dlg => [
'addressbook_use_editaddress_dialog',
$xl::s{l_oth_use_dlg},
$xl::s{h_oth_use_dlg},
}
%pr::gui = ( # gui bells and whistles
- b_unread => [
+ b_unread => [
'bold_unread',
$xl::s{l_gui_b_unread},
$xl::s{h_gui_b_unread},
new_check_button_for (\%pr::gui, 'two_linev', \%HPVALUE),
new_check_button_for (\%pr::gui, 'next_del', \%HPVALUE),
new_selection_box_for (\%pr::gui, 'from_show', \%HPVALUE)),
- $xl::s{mlist_frame}, 'not-packed'),
+ $xl::s{mlist_frame}, 'not-packed'),
FALSE, FALSE, FRAME_SPC);
$gf->pack_start (new_subpage_frame (
new_hbox_pack (
new_check_button_for (\%pr::gui, 'cursor_v', \%HPVALUE),
new_check_button_for (\%pr::gui, 'mview_date', \%HPVALUE)),
- $xl::s{mview_frame}, 'not-packed'),
+ $xl::s{mview_frame}, 'not-packed'),
FALSE, FALSE, FRAME_SPC);
$gf->pack_start (new_subpage_frame (
new_hbox_pack (
new_check_button_for (\%pr::gui, 'no_markup', \%HPVALUE),
new_check_button_for (\%pr::gui, 'margin_co', \%HPVALUE),
new_check_button_for (\%pr::gui, 'type_any', \%HPVALUE)),
- $xl::s{compo_frame}, 'not-packed'),
+ $xl::s{compo_frame}, 'not-packed'),
FALSE, FALSE, FRAME_SPC);
$gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
$gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
new_vbox_pack (
new_text_box_for_int (\%pr::beh, 'hover_t', \%HPVALUE),
new_check_button_for (\%pr::beh, 'warn_dnd', \%HPVALUE)),
- $xl::s{dnd_frame}, 'not-packed'),
+ $xl::s{dnd_frame}, 'not-packed'),
FALSE, FALSE, FRAME_SPC);
$bf->pack_start (new_subpage_frame (
new_hbox_pack (
return $winbook;
}
+%pr::acc = ( # per account hidden preferences
+ tls_set => [
+ 'gnutls_set_priority',
+ $xl::s{l_acc_gtls_set},
+ $xl::s{h_acc_gtls_set},
+ 'bool',
+ '3.9.0.181',
+ '0',
+ undef,
+ ],
+ tls_pri => [
+ 'gnutls_priority',
+ $xl::s{l_acc_gtls_pri},
+ $xl::s{h_acc_gtls_pri},
+ 'char,0,256,32',
+ '3.9.0.181',
+ '0',
+ undef,
+ ],
+);
+
+sub new_account_subpage($) {
+ my ($akey) = @_;
+ return new_vbox_pack (
+ new_subpage_frame (
+ new_vbox_pack (
+ new_check_button_for (\%pr::acc, 'tls_set', $ACHPVALUE{$akey}),
+ new_text_box_for_nchar (\%pr::acc, 'tls_pri', $ACHPVALUE{$akey})),
+ _('GnuTLS priority'), 'not-packed')
+ );
+}
+
+sub new_accounts_page() {
+ my $accbook = Gtk2::Notebook->new;
+ $accbook->set_tab_pos ('right');
+ foreach (keys %ACPREFS) {
+ my $name = $ACPREFS{$_}{'account_name'};
+ $accbook->append_page (new_account_subpage ($_), $name);
+ }
+ return $accbook;
+}
+
# version info
sub print_version() {
print $xl::s{about_title} . "\n";
print "Perl-GLib " . $Glib::VERSION;
# version info stuff appeared in 1.040
if ($Glib::VERSION >= 1.040) {
- print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
- . _(", running with ") . join(".", &Glib::major_version,
+ print _(", built for ") . join(".", Glib->GET_VERSION_INFO)
+ . _(", running with ") . join(".", &Glib::major_version,
&Glib::minor_version, &Glib::micro_version);
}
print "\n";
print "Perl-GTK2 " . $Gtk2::VERSION;
if ($Gtk2::VERSION >= 1.040) {
print _(", built for ") . join(".", Gtk2->GET_VERSION_INFO)
- . _(", running with ") . join(".", &Gtk2::major_version,
+ . _(", running with ") . join(".", &Gtk2::major_version,
&Gtk2::minor_version, &Gtk2::micro_version);
}
print "\n";
- my $clawsver = ($CLAWSV eq "") ?
- _("was not found!") :
+ my $clawsver = ($CLAWSV eq "") ?
+ _("was not found!") :
(_("returned version ") . $CLAWSV);
print "Claws Mail " . $clawsver . "\n";
}
GetOptions('h|help' => sub { print_help (); $cont = FALSE },
'v|version' => sub { print_version (); $cont = FALSE },
'b|verbose' => sub { $VERBOSE = TRUE },
+ 'r|read-only' => sub { $READONLY = TRUE },
'u|use-claws-version=s' => \&opt_use_claws_version,
'a|alternate-config-dir=s' => \&opt_alternate_config_dir,
- 'r|clawsrc=s' => \&opt_clawsrc)
+ 'c|clawsrc=s' => \&opt_clawsrc)
or die _("try -h or --help for syntax.\n");
};
if ($@) {
# update the hidden preferences status from loaded values
sub init_hidden_preferences {
foreach my $hash (\%pr::beh, \%pr::col, \%pr::gui, \%pr::oth, \%pr::win) {
- foreach my $key (keys %$hash) {
+ foreach my $key (keys %$hash) {
$HPVALUE{${$hash}{$key}[NAME]} = $PREFS{${$hash}{$key}[NAME]};
}
}
return TRUE;
}
+sub init_ac_hidden_preferences {
+ foreach my $akey (keys %ACPREFS) {
+ foreach my $key (keys %pr::acc) {
+ my $pname = $pr::acc{$key}[NAME];
+ $ACHPVALUE{$akey}{$pname} = $ACPREFS{$akey}{$pname};
+ }
+ }
+ return TRUE;
+}
+
# load current status from disc
sub load_preferences {
my $rc = get_rc_filename ();
return TRUE;
}
+sub save_ac_preferences {
+ my $rc = get_ac_rc_filename ();
+ log_message ("Saving account preferences to $rc\n");
+ return FALSE unless check_rc_file ($rc);
+ return FALSE unless check_claws_not_running ();
+ my $rcbak = "$rc.backup";
+ rename ($rc, $rcbak);
+ open (RCF, ">$rc");
+ open (RCB, "<$rcbak");
+ my $akey;
+ while (<RCB>) {
+ chomp;
+ if (/^\[Account: (\d+)\]$/) {
+ $akey = $1;
+ print RCF $_ . "\n";
+ next;
+ }
+ if (/^([8a-z_]+)=(.*)$/) {
+ if (defined($ACHPVALUE{$akey}{$1})) {
+ print RCF $1 . "=" . $ACHPVALUE{$akey}{$1} . "\n";
+ }
+ else {
+ print RCF $_ . "\n";
+ }
+ }
+ else {
+ print RCF $_ . "\n";
+ }
+ }
+ close (RCB);
+ close (RCF);
+ return TRUE;
+}
+
# create notebook
sub new_notebook {
my $nb = Gtk2::Notebook->new;
- #
+ #
$nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
$nb->append_page (new_colours_page (), $xl::s{tab_colours});
$nb->append_page (new_gui_page (), $xl::s{tab_gui});
$nb->append_page (new_other_page (), $xl::s{tab_other});
$nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
+ $nb->append_page (new_accounts_page (), $xl::s{tab_accounts});
return $nb;
}
my $title = $xl::s{about_title};
my $lic = $xl::s{about_license};
my $vers = $xl::s{about_version} . " $VERSION";
- my $license =
+ my $license =
"This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
my $holder = "Ricardo Mones <ricardo\@mones.org>";
my $url = "http://www.claws-mail.org/clawsker.php";
- my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
- [qw/modal destroy-with-parent/],
- 'info', 'close',
+ my $dialog = Gtk2::MessageDialog->new_with_markup ($parent,
+ [qw/modal destroy-with-parent/],
+ 'info', 'close',
"<span size=\"x-large\" weight=\"bold\">$title</span>\n"
. "<span size=\"large\">$vers</span>\n\n"
. "<span color=\"blue\" size=\"large\">$url</span>\n\n"
# disable button until is really implemented
# my $b_undo = Gtk2::Button->new_from_stock ('gtk-undo');
my $hbox = Gtk2::HBox->new (FALSE, 5);
- # signal handlers
+ # signal handlers
$b_exit->signal_connect (clicked => sub { Gtk2->main_quit });
- $b_apply->signal_connect (clicked => sub { save_preferences ($parent) });
+ $b_apply->set_sensitive (not $READONLY);
+ $b_apply->signal_connect (clicked => sub {
+ save_preferences ($parent);
+ save_ac_preferences ($parent);
+ });
# $b_undo->signal_connect (clicked => sub { undo_current_changes });
$b_about->signal_connect (clicked => sub { $adlg->run; $adlg->hide });
# package them
Gtk2->init;
$main_window = Gtk2::Window->new ('toplevel');
exit unless load_preferences ();
+exit unless load_ac_preferences ();
exit unless init_hidden_preferences ();
+exit unless init_ac_hidden_preferences ();
# create main GUI
my $box = Gtk2::VBox->new (FALSE, 5);
$box->set_border_width(3);