#!/usr/bin/perl -w
#
# Clawsker :: A Claws Mail Tweaker
-# Copyright 2007-2015 Ricardo Mones <ricardo@mones.org>
+# Copyright 2007-2016 Ricardo Mones <ricardo@mones.org>
#
# 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
binmode STDOUT, ":encoding(utf8)";
+use 5.010_000;
use strict;
use utf8;
use Glib qw(TRUE FALSE);
my $NAME = 'clawsker';
my $PREFIX = '@PREFIX@';
my $LIBDIR = '@LIBDIR@';
+my $DATADIR = '@DATADIR@';
my $VERSION = '@VERSION@';
my $VERBOSE = FALSE;
my $CLAWSV = undef;
l_beh_inline_at => _('Show inline attachments'),
h_beh_inline_at => _('Allows hiding inline attachments already shown in mail structure view.'),
l_beh_addr_swc => _('Address search in compose window matches any'),
- h_beh_addr_swc => _('On Tab-key completion, address text will match any part of the string or only the from the start.'),
+ h_beh_addr_swc => _('On Tab-key completion, address text will match any part of the string or only from the start.'),
l_beh_fold_swc => _('Folder search in folder selector matches any'),
h_beh_fold_swc => _('On folder name completion text will match any part of the string or only from the start.'),
# all preferences read by load_preferences
my %PREFS = ();
+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/';
my $CONFIGRC = 'clawsrc';
+my $ACCOUNTRC = 'accountrc';
# index constants for preference arrays
use constant NAME => 0; # the name on the rc file
}
sub get_claws_version {
- my @cmbin = (
- 'claws-mail',
- );
- my $res = "";
- foreach my $bin (@cmbin) {
- $_ = qx/which $bin/;
- chomp;
- last if ($_ ne "");
- }
+ $_ = qx/which claws-mail/;
+ chomp;
return "" unless ($_); # not installed
+ my $res = "";
$_ = qx/$_ -v/;
chomp;
my @fver = split (/ /);
my @ver = split (/\./, $fver[3]);
$res .= "$ver[0].";
$res .= "$ver[1].";
- if ($ver[2] =~ /(\d+)cvs(\d+)/) {
+ if ($ver[2] =~ /(\d+)git(\d+)/) {
$res .= "$1.$2";
}
else {
return $CONFIGDIR . $CONFIGRC;
}
+sub get_ac_rc_filename {
+ return $CONFIGDIR . $ACCOUNTRC;
+}
+
sub set_rc_filename {
my ($fullname) = @_;
my @parts = split ('/', $fullname);
sub check_claws_not_running {
my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
$tmpdir = '/tmp' if ($tmpdir eq '');
- my $socket = (not $ALTCONFIGDIR)? $tmpdir: $CONFIGDIR;
- $socket .= "/claws-mail-$<";
- -S $socket and return claws_is_running ();
- # since 3.9.0cvs36
my $lockdir = "$tmpdir/claws-mail-$<";
-d $lockdir and do {
- $_ = $CONFIGDIR;
- s/\/$//;
- $socket = "$lockdir/" . md5_hex ($_);
- -S $socket and return claws_is_running ();
+ $_ = $CONFIGDIR;
+ s/\/$//;
+ my $socket = "$lockdir/" . md5_hex ($_);
+ -S $socket and return claws_is_running ();
};
return TRUE;
}
# graphic element creation
-sub new_check_button_for {
- my ($hash, $key) = @_;
+sub new_check_button_for($$$) {
+ my ($hash, $key, $vhash) = @_;
my $name = $$hash{$key}[NAME];
my $label = $$hash{$key}[LABEL];
#
my $hbox = Gtk2::HBox->new (FALSE, 5);
my $cb = Gtk2::CheckButton->new ($label);
- $$hash{$key}[GUI] = $cb;
- if (defined ($HPVALUE{$name})) {
- $cb->set_active ($HPVALUE{$name} eq '1');
- }
+ my $value = $$vhash{$name};
+ $value //= $$hash{$key}[CMDEF];
+ $cb->set_active ($value eq '1');
$cb->signal_connect (clicked => sub {
my ($w, $e) = @_;
- handle_bool_value ($w, $e, \$HPVALUE{$name});
+ handle_bool_value ($w, $e, \$$vhash{$name});
});
set_widget_hint ($cb, $$hash{$key}[DESC]);
set_widget_sens ($cb, $$hash{$key}[CMVER]);
return $hbox;
}
-sub new_text_box_for_int {
- my ($hash, $key) = @_;
+sub new_text_box_for_int($$$) {
+ my ($hash, $key, $vhash) = @_;
my $name = $$hash{$key}[NAME];
my $label = $$hash{$key}[LABEL];
my @type = split (/,/, $$hash{$key}[TYPE]);
my $glabel = Gtk2::Label->new ($label);
my $pagei = int (($type[2] - $type[1]) / 10);
my $gentry = Gtk2::SpinButton->new_with_range ($type[1], $type[2], $pagei);
+ my $value = $$vhash{$name};
+ $value //= $$hash{$key}[CMDEF];
$gentry->set_numeric (TRUE);
- $gentry->set_value ($HPVALUE{$name});
- $$hash{$key}[GUI] = $gentry;
+ $gentry->set_value ($value);
$gentry->signal_connect('value-changed' => sub {
my ($w, $e) = @_;
- handle_int_value ($w, $e, \$HPVALUE{$name});
+ handle_int_value ($w, $e, \$$vhash{$name});
});
set_widget_hint ($gentry, $$hash{$key}[DESC]);
set_widget_sens ($gentry, $$hash{$key}[CMVER]);
return $hbox;
}
-sub new_text_box_for_nchar {
- my ($hash, $key) = @_;
+sub new_text_box_for_nchar($$$) {
+ my ($hash, $key, $vhash) = @_;
my $name = $$hash{$key}[NAME];
my $label = $$hash{$key}[LABEL];
my @type = split (/,/, $$hash{$key}[TYPE]); # char,minlen,maxlen
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]);
- $gentry->set_text ($HPVALUE{$name});
- $$hash{$key}[GUI] = $gentry;
+ 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, \$HPVALUE{$name}, $type[1]);
+ handle_nchar_value ($w, $e, \$$vhash{$name}, $type[1]);
});
set_widget_hint ($gentry, $$hash{$key}[DESC]);
set_widget_sens ($gentry, $$hash{$key}[CMVER]);
return $hbox;
}
-sub new_color_button_for {
- my ($hash, $key) = @_;
+sub new_color_button_for($$$) {
+ my ($hash, $key, $vhash) = @_;
my $name = $$hash{$key}[NAME];
my $label = $$hash{$key}[LABEL];
#
- my $col = gdk_color_from_str ($HPVALUE{$name});
+ my $value = $$vhash{$name};
+ $value //= $$hash{$key}[CMDEF];
+ my $col = gdk_color_from_str ($value);
my $hbox = Gtk2::HBox->new (FALSE, 5);
my $glabel = Gtk2::Label->new ($label);
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});
+ handle_color_value ($w, $e, \$$vhash{$name});
});
set_widget_hint ($button, $$hash{$key}[DESC]);
set_widget_sens ($button, $$hash{$key}[CMVER]);
return $hbox;
}
-sub new_selection_box_for {
- my ($hash, $key) = @_;
+sub new_selection_box_for($$$) {
+ my ($hash, $key, $vhash) = @_;
my $name = $$hash{$key}[NAME];
my $label = $$hash{$key}[LABEL];
#
my $hbox = Gtk2::HBox->new (FALSE, 5);
my $glabel = Gtk2::Label->new ($label);
my $combo = Gtk2::ComboBox->new_text;
- $$hash{$key}[GUI] = $combo;
my @options = split (';', $$hash{$key}[TYPE]);
foreach my $opt (@options) {
my ($index, $textkey) = split ('=', $opt);
}
$combo->signal_connect ('changed' => sub {
my ($w, $e) = @_;
- handle_selection_value ($w, $e, \$HPVALUE{$name});
+ handle_selection_value ($w, $e, \$$vhash{$name});
});
- $combo->set_active ($HPVALUE{$name});
+ my $value = $$vhash{$name};
+ $value //= $$hash{$key}[CMDEF];
+ $combo->set_active ($value);
set_widget_hint ($combo, $$hash{$key}[DESC]);
set_widget_sens ($combo, $$hash{$key}[CMVER]);
$glabel->set_sensitive ($combo->sensitive);
return new_vbox_pack (
new_subpage_frame (
new_vbox_pack (
- new_check_button_for(\%pr::oth, 'use_dlg')),
+ new_check_button_for(\%pr::oth, 'use_dlg', \%HPVALUE)),
$xl::s{ab_frame}, 'not-packed'),
new_subpage_frame (
new_vbox_pack (
- new_text_box_for_int(\%pr::oth, 'max_use'),
- new_text_box_for_int(\%pr::oth, 'min_time')),
+ new_text_box_for_int(\%pr::oth, 'max_use', \%HPVALUE),
+ new_text_box_for_int(\%pr::oth, 'min_time', \%HPVALUE)),
$xl::s{mem_frame}, 'not-packed'),
new_subpage_frame (
new_vbox_pack (
- new_check_button_for(\%pr::oth, 'use_netm')),
+ new_check_button_for(\%pr::oth, 'use_netm', \%HPVALUE)),
$xl::s{netm_frame}, 'not-packed'),
new_subpage_frame (
new_vbox_pack (
- new_text_box_for_int(\%pr::oth, 'mp_rounds')),
+ new_text_box_for_int(\%pr::oth, 'mp_rounds', \%HPVALUE)),
$xl::s{mpass_frame}, 'not-packed')
);
}
my $gf = Gtk2::VBox->new (FALSE, 5);
$gf->set_border_width (PAGE_SPC);
- my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines');
- my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d');
- my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char');
+ my $cb_dot_lines = new_check_button_for (\%pr::gui, 'dot_lines', \%HPVALUE);
+ my $cb_toolbar_d = new_check_button_for (\%pr::gui, 'toolbar_d', \%HPVALUE);
+ my $tb_zero_char = new_text_box_for_nchar (\%pr::gui, 'zero_char', \%HPVALUE);
$gf->pack_start (new_subpage_frame (
new_vbox_pack (
- new_check_button_for (\%pr::gui, 'strip_all'),
- new_check_button_for (\%pr::gui, 'strip_sum'),
- new_text_box_for_int (\%pr::gui, 'strip_off')),
+ new_check_button_for (\%pr::gui, 'strip_all', \%HPVALUE),
+ new_check_button_for (\%pr::gui, 'strip_sum', \%HPVALUE),
+ new_text_box_for_int (\%pr::gui, 'strip_off', \%HPVALUE)),
$xl::s{stripes_frame}, 'not-packed'),
FALSE, FALSE, FRAME_SPC);
$gf->pack_start (new_subpage_frame (
new_vbox_pack (
- new_check_button_for (\%pr::gui, 'b_unread'),
- new_check_button_for (\%pr::gui, 'swp_from'),
- new_check_button_for (\%pr::gui, 'two_linev'),
- new_check_button_for (\%pr::gui, 'next_del'),
- new_selection_box_for (\%pr::gui, 'from_show')),
+ new_check_button_for (\%pr::gui, 'b_unread', \%HPVALUE),
+ new_check_button_for (\%pr::gui, 'swp_from', \%HPVALUE),
+ 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'),
FALSE, FALSE, FRAME_SPC);
$gf->pack_start (new_subpage_frame (
new_hbox_pack (
- new_check_button_for (\%pr::gui, 'cursor_v'),
- new_check_button_for (\%pr::gui, 'mview_date')),
+ new_check_button_for (\%pr::gui, 'cursor_v', \%HPVALUE),
+ new_check_button_for (\%pr::gui, 'mview_date', \%HPVALUE)),
$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'),
- new_check_button_for (\%pr::gui, 'margin_co'),
- new_check_button_for (\%pr::gui, 'type_any')),
+ 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'),
FALSE, FALSE, FRAME_SPC);
$gf->pack_start ($cb_dot_lines, FALSE, FALSE, 0);
$gf->pack_start ($cb_toolbar_d, FALSE, FALSE, 0);
$gf->pack_start (new_subpage_frame (
new_vbox_pack (
- new_check_button_for (\%pr::gui, 'h_scroll'),
- new_selection_box_for (\%pr::gui, 'v_scroll')),
+ new_check_button_for (\%pr::gui, 'h_scroll', \%HPVALUE),
+ new_selection_box_for (\%pr::gui, 'v_scroll', \%HPVALUE)),
$xl::s{sbar_frame}, 'not-packed'),
FALSE, FALSE, FRAME_SPC);
$gf->pack_start ($tb_zero_char, FALSE, FALSE, 0);
addr_swc => [
'address_search_wildcard',
$xl::s{l_beh_addr_swc},
- $xl::s{h_beh_addr_sw1},
+ $xl::s{h_beh_addr_swc},
'bool',
'3.9.3.18',
'0',
fold_swc => [
'folder_search_wildcard',
$xl::s{l_beh_fold_swc},
- $xl::s{h_beh_fold_sw1},
+ $xl::s{h_beh_fold_swc},
'bool',
'3.9.3.18',
'0',
my $bf = Gtk2::VBox->new (FALSE, 5);
$bf->set_border_width (PAGE_SPC);
- my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step');
- my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a');
+ my $tb_up_step = new_text_box_for_int (\%pr::beh, 'up_step', \%HPVALUE);
+ my $tb_thread_a = new_text_box_for_int (\%pr::beh, 'thread_a', \%HPVALUE);
$bf->pack_start (new_subpage_frame (
new_vbox_pack (
- new_text_box_for_int (\%pr::beh, 'hover_t'),
- new_check_button_for (\%pr::beh, 'warn_dnd')),
+ 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'),
FALSE, FALSE, FRAME_SPC);
$bf->pack_start (new_subpage_frame (
new_hbox_pack (
- new_check_button_for (\%pr::beh, 'skip_ssl'),
- new_check_button_for (\%pr::beh, 'unsafe_ssl')),
+ new_check_button_for (\%pr::beh, 'skip_ssl', \%HPVALUE),
+ new_check_button_for (\%pr::beh, 'unsafe_ssl', \%HPVALUE)),
$xl::s{ssl_frame}, 'not-packed'),
FALSE, FALSE, FRAME_SPC);
$bf->pack_start ($tb_up_step, FALSE, FALSE, 0);
$bf->pack_start ($tb_thread_a, FALSE, FALSE, 0);
$bf->pack_start (new_subpage_frame (
new_vbox_pack (
- new_check_button_for (\%pr::beh, 'flowed'),
- new_check_button_for (\%pr::beh, 'parts_rw'),
- new_check_button_for (\%pr::beh, 'use_utf8'),
- new_check_button_for (\%pr::beh, 'dangerous'),
- new_check_button_for (\%pr::beh, 'out_ascii'),
- new_check_button_for (\%pr::beh, 'pp_unsel'),
- new_check_button_for (\%pr::beh, 'inline_at')),
+ new_check_button_for (\%pr::beh, 'flowed', \%HPVALUE),
+ new_check_button_for (\%pr::beh, 'parts_rw', \%HPVALUE),
+ new_check_button_for (\%pr::beh, 'use_utf8', \%HPVALUE),
+ new_check_button_for (\%pr::beh, 'dangerous', \%HPVALUE),
+ new_check_button_for (\%pr::beh, 'out_ascii', \%HPVALUE),
+ new_check_button_for (\%pr::beh, 'pp_unsel', \%HPVALUE),
+ new_check_button_for (\%pr::beh, 'inline_at', \%HPVALUE)),
$xl::s{msgs_frame}, 'not-packed'),
FALSE, FALSE, FRAME_SPC);
$bf->pack_start (new_subpage_frame (
new_vbox_pack (
- new_check_button_for (\%pr::beh, 'addr_swc'),
- new_check_button_for (\%pr::beh, 'fold_swc')),
+ new_check_button_for (\%pr::beh, 'addr_swc', \%HPVALUE),
+ new_check_button_for (\%pr::beh, 'fold_swc', \%HPVALUE)),
$xl::s{swc_frame}, 'not-packed'),
FALSE, FALSE, FRAME_SPC);
return $bf;
return new_vbox_pack (
new_subpage_frame (
new_vbox_pack (
- new_color_button_for (\%pr::col, 'emphasis')),
+ new_color_button_for (\%pr::col, 'emphasis', \%HPVALUE)),
$xl::s{msgview_frame}, 'not-packed'),
new_subpage_frame (
new_vbox_pack (
- new_color_button_for (\%pr::col, 'log_err'),
- new_color_button_for (\%pr::col, 'log_in'),
- new_color_button_for (\%pr::col, 'log_msg'),
- new_color_button_for (\%pr::col, 'log_out'),
- new_color_button_for (\%pr::col, 'log_warn')),
+ new_color_button_for (\%pr::col, 'log_err', \%HPVALUE),
+ new_color_button_for (\%pr::col, 'log_in', \%HPVALUE),
+ new_color_button_for (\%pr::col, 'log_msg', \%HPVALUE),
+ new_color_button_for (\%pr::col, 'log_out', \%HPVALUE),
+ new_color_button_for (\%pr::col, 'log_warn', \%HPVALUE)),
$xl::s{log_frame}, 'not-packed'),
new_subpage_frame (
new_vbox_pack (
- new_color_button_for (\%pr::col, 'diff_add'),
- new_color_button_for (\%pr::col, 'diff_del'),
- new_color_button_for (\%pr::col, 'diff_hunk')),
+ new_color_button_for (\%pr::col, 'diff_add', \%HPVALUE),
+ new_color_button_for (\%pr::col, 'diff_del', \%HPVALUE),
+ new_color_button_for (\%pr::col, 'diff_hunk', \%HPVALUE)),
$xl::s{diff_frame}, 'not-packed')
);
}
return new_subpage_frame (
new_vbox_pack_compact (
new_vbox_pack (
- new_text_box_for_int (\%pr::win, 'main_x'),
- new_text_box_for_int (\%pr::win, 'main_y')),
+ new_text_box_for_int (\%pr::win, 'main_x', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'main_y', \%HPVALUE)),
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'main_w'),
- new_text_box_for_int (\%pr::win, 'main_h')),
+ new_text_box_for_int (\%pr::win, 'main_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'main_h', \%HPVALUE)),
new_vbox_pack (
- new_check_button_for (\%pr::win, 'main_fs'),
- new_check_button_for (\%pr::win, 'main_mx'))),
+ new_check_button_for (\%pr::win, 'main_fs', \%HPVALUE),
+ new_check_button_for (\%pr::win, 'main_mx', \%HPVALUE))),
_('Main window')
);
}
return new_subpage_frame (
new_vbox_pack_compact (
new_vbox_pack (
- new_text_box_for_int (\%pr::win, 'msgs_x'),
- new_text_box_for_int (\%pr::win, 'msgs_y')),
+ new_text_box_for_int (\%pr::win, 'msgs_x', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'msgs_y', \%HPVALUE)),
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'msgs_w'),
- new_text_box_for_int (\%pr::win, 'msgs_h'))),
+ new_text_box_for_int (\%pr::win, 'msgs_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'msgs_h', \%HPVALUE))),
_('Message window')
);
}
return new_vbox_pack (
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'send_w'),
- new_text_box_for_int (\%pr::win, 'send_h')),
+ new_text_box_for_int (\%pr::win, 'send_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'send_h', \%HPVALUE)),
_('Send window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'recv_w'),
- new_text_box_for_int (\%pr::win, 'recv_h')),
+ new_text_box_for_int (\%pr::win, 'recv_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'recv_h', \%HPVALUE)),
_('Receive window'), 'not-packed')
);
}
new_subpage_frame (
new_vbox_pack_compact (
new_vbox_pack (
- new_text_box_for_int (\%pr::win, 'fold_x'),
- new_text_box_for_int (\%pr::win, 'fold_y')),
+ new_text_box_for_int (\%pr::win, 'fold_x', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'fold_y', \%HPVALUE)),
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'fold_w'),
- new_text_box_for_int (\%pr::win, 'fold_h'))),
+ new_text_box_for_int (\%pr::win, 'fold_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'fold_h', \%HPVALUE))),
_('Folder window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'fsel_w'),
- new_text_box_for_int (\%pr::win, 'fsel_h')),
+ new_text_box_for_int (\%pr::win, 'fsel_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'fsel_h', \%HPVALUE)),
_('Folder selection window'), 'not-packed')
);
}
return new_vbox_pack (
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'addr_w'),
- new_text_box_for_int (\%pr::win, 'addr_h')),
+ new_text_box_for_int (\%pr::win, 'addr_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'addr_h', \%HPVALUE)),
_('Addressbook main window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'adep_w'),
- new_text_box_for_int (\%pr::win, 'adep_h')),
+ new_text_box_for_int (\%pr::win, 'adep_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'adep_h', \%HPVALUE)),
_('Edit person window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'adeg_w'),
- new_text_box_for_int (\%pr::win, 'adeg_h')),
+ new_text_box_for_int (\%pr::win, 'adeg_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'adeg_h', \%HPVALUE)),
_('Edit group window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'adda_w'),
- new_text_box_for_int (\%pr::win, 'adda_h')),
+ new_text_box_for_int (\%pr::win, 'adda_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'adda_h', \%HPVALUE)),
_('Add address window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'addf_w'),
- new_text_box_for_int (\%pr::win, 'addf_h')),
+ new_text_box_for_int (\%pr::win, 'addf_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'addf_h', \%HPVALUE)),
_('Folder select window'), 'not-packed')
);
}
return new_vbox_pack (
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'acco_w'),
- new_text_box_for_int (\%pr::win, 'acco_h')),
+ new_text_box_for_int (\%pr::win, 'acco_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'acco_h', \%HPVALUE)),
_('Accounts window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'acce_w'),
- new_text_box_for_int (\%pr::win, 'acce_h')),
+ new_text_box_for_int (\%pr::win, 'acce_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'acce_h', \%HPVALUE)),
_('Edit account window'), 'not-packed')
);
}
return new_vbox_pack (
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'filt_w'),
- new_text_box_for_int (\%pr::win, 'filt_h')),
+ new_text_box_for_int (\%pr::win, 'filt_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'filt_h', \%HPVALUE)),
_('Filtering window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'fila_w'),
- new_text_box_for_int (\%pr::win, 'fila_h')),
+ new_text_box_for_int (\%pr::win, 'fila_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'fila_h', \%HPVALUE)),
_('Filtering actions window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'fild_w'),
- new_text_box_for_int (\%pr::win, 'fild_h')),
+ new_text_box_for_int (\%pr::win, 'fild_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'fild_h', \%HPVALUE)),
_('Filtering debug window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'matc_w'),
- new_text_box_for_int (\%pr::win, 'matc_h')),
+ new_text_box_for_int (\%pr::win, 'matc_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'matc_h', \%HPVALUE)),
_('Matcher window'), 'not-packed')
);
}
return new_vbox_pack (
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'pref_w'),
- new_text_box_for_int (\%pr::win, 'pref_h')),
+ new_text_box_for_int (\%pr::win, 'pref_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'pref_h', \%HPVALUE)),
_('Preferences window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'temp_w'),
- new_text_box_for_int (\%pr::win, 'temp_h')),
+ new_text_box_for_int (\%pr::win, 'temp_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'temp_h', \%HPVALUE)),
_('Templates window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'acti_w'),
- new_text_box_for_int (\%pr::win, 'acti_h')),
+ new_text_box_for_int (\%pr::win, 'acti_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'acti_h', \%HPVALUE)),
_('Actions window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'tags_w'),
- new_text_box_for_int (\%pr::win, 'tags_h')),
+ new_text_box_for_int (\%pr::win, 'tags_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'tags_h', \%HPVALUE)),
_('Tags window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'plug_w'),
- new_text_box_for_int (\%pr::win, 'plug_h')),
+ new_text_box_for_int (\%pr::win, 'plug_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'plug_h', \%HPVALUE)),
_('Plugins window'), 'not-packed')
);
}
return new_vbox_pack (
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'logw_w'),
- new_text_box_for_int (\%pr::win, 'logw_h')),
+ new_text_box_for_int (\%pr::win, 'logw_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'logw_h', \%HPVALUE)),
_('Log window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'prin_w'),
- new_text_box_for_int (\%pr::win, 'prin_h')),
+ new_text_box_for_int (\%pr::win, 'prin_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'prin_h', \%HPVALUE)),
_('Print preview window'), 'not-packed'),
new_subpage_frame (
new_hbox_pack (
- new_text_box_for_int (\%pr::win, 'sour_w'),
- new_text_box_for_int (\%pr::win, 'sour_h')),
+ new_text_box_for_int (\%pr::win, 'sour_w', \%HPVALUE),
+ new_text_box_for_int (\%pr::win, 'sour_h', \%HPVALUE)),
_('View source window'), 'not-packed')
);
}
return TRUE;
}
+sub load_ac_preferences {
+ my $rc = get_ac_rc_filename ();
+ log_message ("Loading account preferences from $rc\n");
+ return FALSE unless check_rc_file ($rc);
+ return FALSE unless check_claws_not_running ();
+ open (RCF, "<$rc");
+ my $akey;
+ while (<RCF>) {
+ chomp;
+ if (/^\[Account: (\d+)\]$/) {
+ $akey = $1;
+ next;
+ }
+ if (/^([8a-z_]+)=(.*)$/) {
+ $ACPREFS{$akey}{$1} = decode('UTF-8', $2);
+ }
+ }
+ close (RCF);
+ return TRUE;
+}
+
# save current preferences to disc
sub save_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;
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.";
- my $year = "2007-2015";
+ my $year = "2007-2016";
my $holder = "Ricardo Mones <ricardo\@mones.org>";
my $url = "http://www.claws-mail.org/clawsker.php";
return $hbox;
}
+sub get_app_icons {
+ my $dir = $DATADIR . '/icons/hicolor';
+ my @names = map {
+ join ('/', ($dir, , $_ . 'x' . $_, 'apps', $NAME . '.png'))
+ } (64, 128);
+ my @icons = ();
+ foreach (@names) {
+ my $icon = undef;
+ $icon = Gtk2::Gdk::Pixbuf->new_from_file($_) if (-f $_);
+ push @icons, $icon if ($icon);
+ }
+ return @icons;
+}
+
# initialise
exit unless parse_command_line ();
Gtk2->init;
$box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
$main_window->signal_connect (delete_event => sub { Gtk2->main_quit });
$main_window->set_title ($xl::s{win_title});
+$main_window->set_icon_list (get_app_icons ());
$main_window->add ($box);
$main_window->show_all;
Gtk2->main;