summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/logdrake
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/logdrake')
-rwxr-xr-xperl-install/standalone/logdrake110
1 files changed, 41 insertions, 69 deletions
diff --git a/perl-install/standalone/logdrake b/perl-install/standalone/logdrake
index fa6475bbc..df4751115 100755
--- a/perl-install/standalone/logdrake
+++ b/perl-install/standalone/logdrake
@@ -29,6 +29,7 @@ use interactive;
use ugtk2 qw(:create :dialogs :helpers :wrappers);
use vars qw(*F);
+$ugtk2::wm_icon = "/usr/share/mcc/themes/default/logdrake-mdk.png";
my $in = 'interactive'->vnew('su');
my ($isExplain, $Explain, $isFile, $File, $isWord, $Word);
@@ -46,7 +47,7 @@ $| = 1 if $isTail;
my $h = chomp_(`hostname -s`);
$ugtk2::wm_icon = "logdrake";
-my $explain_title = N("Mandrake Tools Logs");
+my $explain_title = N("Mandrakelinux Tools Logs");
my $my_win = ugtk2->new($isExplain ? $explain_title : N("Logdrake"));
unless ($::isEmbedded) {
@@ -55,12 +56,12 @@ unless ($::isEmbedded) {
}
$my_win->{window}->signal_connect(delete_event => \&quit);
-my $cal = gtkset_sensitive(new Gtk2::Calendar(), 0);
+my $cal = gtkset_sensitive(Gtk2::Calendar->new, 0);
my $mday = (localtime(time()))[3];
$cal->select_day($mday);
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my $cal_mode = 0;
-my $cal_butt = gtksignal_connect(new Gtk2::CheckButton(N("Show only for the selected day")), clicked => sub { $cal_mode = !$cal_mode; gtkset_sensitive($cal,$cal_mode) });
+my $cal_butt = gtksignal_connect(Gtk2::CheckButton->new(N("Show only for the selected day")), clicked => sub { $cal_mode = !$cal_mode; gtkset_sensitive($cal,$cal_mode) });
### menus definition
# the menus are not shown
@@ -112,7 +113,7 @@ my %files = (
"explanations" => { file => "/var/log/explanations", desc => $explain_title }
);
-my $yy = gtkset_sensitive(gtksignal_connect(new Gtk2::Button(N("search")) , clicked => \&search),0);
+my $yy = gtkset_sensitive(gtksignal_connect(Gtk2::Button->new(N("search")) , clicked => \&search),0);
my $log_text = gtktext_insert(Gtk2::TextView->new, [ [ '' ] ]);
@@ -123,29 +124,29 @@ my $refcount_search;
my %toggle;
gtkadd($my_win->{window},
- gtkpack_(new Gtk2::VBox(0,0),
+ gtkpack_(Gtk2::VBox->new(0,0),
if_(!$isExplain && !$::isEmbedded, 0, N("A tool to monitor your logs")),
- if_(!$isFile, 0, gtkadd(new Gtk2::Frame(N("Settings")),
- gtkpack__(new Gtk2::VBox(0,2),
- gtkpack__(new Gtk2::VBox(0,2),
+ if_(!$isFile, 0, gtkadd(Gtk2::Frame->new(N("Settings")),
+ gtkpack__(Gtk2::VBox->new(0,2),
+ gtkpack__(Gtk2::VBox->new(0,2),
# N("Show lines"),
- gtkpack__(new Gtk2::HBox(0,0),
- " " . N("Matching") . " ", my $e_yes = new Gtk2::Entry(),
- " " . N("but not matching") . " ", my $e_no = new Gtk2::Entry()
+ gtkpack__(Gtk2::HBox->new(0,0),
+ " " . N("Matching") . " ", my $e_yes = Gtk2::Entry->new,
+ " " . N("but not matching") . " ", my $e_no = Gtk2::Entry->new
)
),
- gtkpack_(new Gtk2::HBox(0,0),
- 1, gtkadd(gtkset_border_width(new Gtk2::Frame(N("Choose file")),2),
+ gtkpack_(Gtk2::HBox->new(0,0),
+ 1, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Choose file")),2),
gtkpack(gtkset_border_width(Gtk2::VBox->new(0,0),0),
- map { $toggle{$_} = gtksignal_connect(new Gtk2::CheckButton($files{$_}{desc}),
+ map { $toggle{$_} = gtksignal_connect(Gtk2::CheckButton->new($files{$_}{desc}),
clicked => sub {
$refcount_search++;
gtkset_sensitive($yy, $refcount_search);
}) } sort keys %files,
)
),
- 0, gtkadd(gtkset_border_width(new Gtk2::Frame(N("Calendar")),2),
- gtkpack__(gtkset_border_width(new Gtk2::VBox(0,0),5),
+ 0, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Calendar")),2),
+ gtkpack__(gtkset_border_width(Gtk2::VBox->new(0,0),5),
$cal_butt, $cal
)
)
@@ -154,18 +155,18 @@ gtkadd($my_win->{window},
)
)
),
- !$isExplain ? (1, gtkadd(new Gtk2::Frame(N("Content of the file")),
+ !$isExplain ? (1, gtkadd(Gtk2::Frame->new(N("Content of the file")),
create_scrolled_window($log_text)
)) : (1, create_scrolled_window($log_text)),
if_(!$isExplain, 0, gtkadd(gtkset_border_width(gtkset_layout(Gtk2::HButtonBox->new, 'end'), 5),
- if_(!$isFile, gtksignal_connect(new Gtk2::Button(N("Mail alert")),
+ if_(!$isFile, gtksignal_connect(Gtk2::Button->new(N("Mail alert")),
clicked => sub {
eval { alert_config() };
my $err = $@;
$::WizardWindow->destroy if defined $::WizardWindow;
undef $::WizardWindow;
if ($err && $err !~ /wizcancel/) {
- err_dialog(N("Error"), N("The alert wizard had unexpectly failled:")
+ err_dialog(N("Error"), N("The alert wizard has failed unexpectedly:")
. "\n\n" . $err);
}
})),
@@ -205,19 +206,20 @@ sub search() {
my $timer;
-my (@logs, %tags);
+my @logs;
+
+my $F;
sub parse_file {
my ($file, $descr) = @_;
- undef %tags;
$file =~ s/\.gz$//;
my ($pbar, $win_pb);
unless ($::isEmbedded && $isExplain) {
- gtkadd($win_pb = gtkset_modal(new Gtk2::Window('toplevel'), 1),
- gtkpack(new Gtk2::VBox(2,0),
- new Gtk2::Label(" " . N("please wait, parsing file: %s", $descr) . " "),
- $pbar = new Gtk2::ProgressBar()
+ gtkadd($win_pb = gtkset_modal(Gtk2::Window->new('toplevel'), 1),
+ gtkpack(Gtk2::VBox->new(2,0),
+ Gtk2::Label->new(" " . N("please wait, parsing file: %s", $descr) . " "),
+ $pbar = Gtk2::ProgressBar->new
)
);
$win_pb->set_transient_for($my_win->{rwindow}) unless $::isEmbedded;
@@ -274,49 +276,19 @@ sub parse_file {
$win_pb->destroy if !$::isEmbedded || !$isExplain;
if ($isTail) {
- close F;
- open F, $file or die "E: $!";
+ close $F;
+ open $F, $file or die "E: $!";
local $_;
- while (<F>) {}; #to prevent to output the file twice..
+ while (<$F>) {}; #to prevent to output the file twice..
# $log_text->set_point($log_text->get_length());
$timer ||= Glib::Timeout->add(1000, sub {
- logcolorize($_) while <F>;
- seek F, 0, 1;
+ logcolorize($_) while <$F>;
+ seek $F, 0, 1;
});
}
- log_output__real();
+ insert_text_n_scroll();
}
-sub text_append {
- my ($textview, $t, %opts) = @_;
- my $buffer = $textview->get_buffer;
- $buffer->{tags} ||= {};
- my $gtk_tags = $buffer->{tags};
- if (ref($t) eq 'ARRAY') {
- foreach my $token (@$t) {
- my $iter1 = $buffer->get_end_iter;
- if ($token->[0] =~ /^Gtk2::Gdk::Pixbuf/) {
- $buffer->insert_pixbuf($iter1, $token->[0]);
- next;
- }
- if ($token->[1]) {
- my $tag = $token->[1];
- $gtk_tags->{$tag} ||= $buffer->create_tag($tag, %{$tags{$token->[1]}});
- $buffer->insert_with_tags($iter1, $token->[0], $gtk_tags->{$tag});
- } else {
- $buffer->insert($iter1, $token->[0]);
- }
- }
- } else {
- $buffer->set_text($t);
- }
- #- the following line is needed to move the cursor to the beginning, so that if the
- #- textview has a scrollbar, it won't scroll to the bottom when focusing (#3633)
- $buffer->place_cursor($buffer->get_start_iter);
- $textview->set_wrap_mode($opts{wrap_mode} || 'word');
- $textview->set_editable($opts{editable} || 0);
- $textview->set_cursor_visible($opts{visible} || 0);
-}
##########################################################################################
@@ -340,7 +312,7 @@ sub logcolorize {
}
# Extract PID if present
if ($rec[1] =~ /\[(\d+)\]:/) {
- my ($pid) = $1;
+ my $pid = $1;
$rec[1] =~ s/\[$1\]://;
log_output($rec[1] . "[", undef, 'green');
log_output($pid, 'Bold', 'black');
@@ -367,22 +339,22 @@ sub logcolorize {
log_output("$rec[$therest] ", undef, $col);
}
log_output("\n", undef, 'black');
- log_output__real() if $isExplain;
+ insert_text_n_scroll() if $isExplain;
}
# log_output (Gtk2::TextView, [ [ ... ] ])
sub log_output {
my ($text, $font, $col) = @_;
- my $tag = join($font, $col);
+ my $tag = join('', $font, $col);
push @logs, [ $text, $tag ];
- $tags{$tag} ||= { if_($font, font => $font), foreground => $col };
+ $log_buf->{tags}{$tag} ||= { foreground => $col }; # if_($font, font => $font),
}
-sub log_output__real() {
- text_append($log_text, \@logs);
- undef @logs;
+sub insert_text_n_scroll() {
+ ugtk2::gtktext_insert($log_text, \@logs, append => !($isExplain || $isTail));
$log_text->scroll_to_iter($log_buf->get_end_iter, 0, 1, 0.5, 0.5);
+ undef @logs;
}
@@ -455,7 +427,7 @@ sub alert_config() {
email => {
name => N("Alert configuration") . "\n\n" .
N("Please enter your email address below ") . "\n" .
- N("and enter the name (or the IP) of the SMTP server you whish to use"),
+ N("and enter the name (or the IP) of the SMTP server you wish to use"),
data => [
{ label => "Email address", val => \$options{MAIL} },
{ label => "Email server", val => \$options{SMTP} },