summaryrefslogtreecommitdiffstats
path: root/logdrake
diff options
context:
space:
mode:
authorYves Duret <yduret@mandriva.com>2001-08-03 05:49:10 +0000
committerYves Duret <yduret@mandriva.com>2001-08-03 05:49:10 +0000
commitc336c728a80293c752169062aeba4a13268c7e0f (patch)
treed9cd712f3eac1f11ceee06531fbceaa954fe0bfb /logdrake
parent94aacb8dc40e49dd8a2f0f0381637c231f71c9aa (diff)
downloadcontrol-center-c336c728a80293c752169062aeba4a13268c7e0f.tar
control-center-c336c728a80293c752169062aeba4a13268c7e0f.tar.gz
control-center-c336c728a80293c752169062aeba4a13268c7e0f.tar.bz2
control-center-c336c728a80293c752169062aeba4a13268c7e0f.tar.xz
control-center-c336c728a80293c752169062aeba4a13268c7e0f.zip
really fixed bug when embeded in mcc
use plain english instead of bad french
Diffstat (limited to 'logdrake')
-rwxr-xr-xlogdrake240
1 files changed, 67 insertions, 173 deletions
diff --git a/logdrake b/logdrake
index 60ec9f73..a9652844 100755
--- a/logdrake
+++ b/logdrake
@@ -68,30 +68,19 @@ $window->border_width (5);
### menus definition
# the menus are not shown
# but they provides shiny shortcut like C-q
-my @menu_items = ( { path => _("/_File"),
- type => '<Branch>' },
- { path => _("/File/_New"),
- accelerator => _("<control>N"),
- callback => \&print_hello },
- { path => _("/File/_Open"),
- accelerator => _("<control>O"),
- callback => \&print_hello },
- { path => _("/File/_Save"),
- accelerator => _("<control>S"),
- callback => \&print_hello },
- { path => _("/File/Save _As") },
- { path => _("/File/-"),
- type => '<Separator>' },
- { path => _("/File/_Quit"),
- accelerator => _("<control>Q"),
- callback => sub { $::isEmbedded ? kill(USR1, $::CCPID) : Gtk->exit(0) } },
- { path => _("/_Options"),
- type => '<Branch>' },
- { path => _("/Options/Test") },
-
- { path => _("/_Help"),
- type => '<LastBranch>' },
- { path => _("/Help/_About...") } );
+my @menu_items = (
+ { path => _("/_File"), type => '<Branch>' },
+ { path => _("/File/_New"), accelerator => _("<control>N"), callback => \&print_hello },
+ { path => _("/File/_Open"), accelerator => _("<control>O"),callback => \&print_hello },
+ { path => _("/File/_Save"), accelerator => _("<control>S"),callback => \&print_hello },
+ { path => _("/File/Save _As") },
+ { path => _("/File/-"),type => '<Separator>' },
+ { path => _("/File/_Quit"), accelerator => _("<control>Q"), callback => sub { $::isEmbedded ? kill(USR1, $::CCPID) : Gtk->exit(0) } },
+ { path => _("/_Options"), type => '<Branch>' },
+ { path => _("/Options/Test") },
+ { path => _("/_Help"),type => '<LastBranch>' },
+ { path => _("/Help/_About...") }
+ );
my $menubar = get_main_menu( $window );
######### menus end
@@ -134,65 +123,45 @@ my $col=$cyan;
######### font and colors end
-
my %files = (
- "auth" => { file => "/var/log/auth.log", desc => _("authentification") },
- "user" => { file => "/var/log/user.log", desc => _("user") },
- "auth" => { file => "/var/log/auth.log", desc => _("authentification") },
- "syslog" => { file => "/var/log/syslog", desc => _("syslog") }
+ "auth" => { file => "/var/log/auth.log", desc => _("authentification") },
+ "user" => { file => "/var/log/user.log", desc => _("user") },
+ "messages" => { file => "/var/log/messages", desc => _("messages") },
+ "syslog" => { file => "/var/log/syslog", desc => _("syslog") }
);
-# Create root tree
-my $tree = new Gtk::Tree();
-my $leaf;
-my $root_dir;
-$tree->set_selection_mode('single');
-$tree->set_view_mode('item');
-fill_tree ("");
-# 1, gtkadd(new Gtk::Frame(_("Choose a file")),
-# gtkpack_(new Gtk::VBox(0,5),
-# 1, createScrolledWindow($tree),
-# 0, gtkpack(new Gtk::HBox(0,5),
-# gtksignal_connect(new Gtk::Button("syslog"), clicked => \&select_item, "/var/log/syslog"),
-# gtksignal_connect(new Gtk::Button("dmesg"), clicked => \&select_item, "/var/log/dmesg"),
-# gtksignal_connect(new Gtk::Button("user.log"), clicked => \&select_item, "/var/log/user.log")
-# )
-# )
-# ),
-
-
-
#### far from window
-
gtkadd($window,
gtkpack_(new Gtk::VBox(0,5),
- 0, _("see your log"),
- 1, gtkadd(new Gtk::Frame(_("toi aussi choisi")),
- gtkpack__(new Gtk::VBox(0,5),
- gtkpack__(new Gtk::HBox(0,5),
- _("matching"),
- $e_yes = new Gtk::Entry(),
- _("not matching"),
- $e_no = new Gtk::Entry()
- ),
- _("tips: you can use OR"),
- gtkpack (new Gtk::VBox(0,5),
- map {
- ${"b_". $_} = new Gtk::CheckButton($files{$_}{desc})
- } keys %files,
- ),
- gtksignal_connect(new Gtk::Button(_("search")), clicked => \&search)
- )
+ 0, _("A tool to see your log"),
+ 0, gtkadd(new Gtk::Frame(_("Settings")),
+ gtkpack__(new Gtk::VBox(0,5),
+ gtkpack__(new Gtk::VBox(0,5),
+ _("Show lines"),
+ gtkpack__(new Gtk::HBox(0,5),
+ _("matching"),
+ $e_yes = new Gtk::Entry(),
+ _("but not matching"),
+ $e_no = new Gtk::Entry()
+ )
+ ),
+ _("tips: you can use OR"),
+ gtkpack (new Gtk::VBox(0,5),
+ map {
+ ${"b_". $_} = new Gtk::CheckButton($files{$_}{desc})
+ } keys %files,
+ ),
+ gtksignal_connect(new Gtk::Button(_("search")), clicked => \&search)
+ )
),
- 1, gtkadd(new Gtk::Frame(_("Content of the file")),
- createScrolledWindow(my $log = new Gtk::Text(undef, undef))
- )
-
- )
+ 1, gtkadd(new Gtk::Frame(_("Content of the file")),
+ createScrolledWindow(my $log_text = new Gtk::Text(undef, undef))
+ )
+
+ )
);
$window->realize;
-
$window->show_all();
Gtk->main_iteration while Gtk->events_pending;
$::isEmbedded and kill USR2, $::CCPID;
@@ -202,134 +171,52 @@ Gtk->main;
# search functions
#-------------------------------------------------------------
sub search {
- $log->backward_delete($log->get_length());
- $log->freeze();
+ $log_text->backward_delete($log_text->get_length());
+ $log_text->freeze();
foreach (keys %files) {
parse_file($files{$_}{file}) if ${$::{"b_". $_}}->active
};
- $log->thaw();
+ $log_text->thaw();
+ Gtk->main_iteration while Gtk->events_pending;
}
sub parse_file {
my $file = $_[0];
$file =~ s/\.gz$//;
my @all=catMaybeCompressed ($file);
- my $taille= @all +1;
- my $i=1;
- gtkadd(my $win_pb = new Gtk::Window(),
+ my $taille= @all;
+ my $i=0;
+ gtkadd(my $win_pb = (gtkset_modal new Gtk::Window(), 1),
gtkpack(new Gtk::VBox(5,0),
_("please wait, parsing file: "). $files{$_}{desc},
my $pbar = new Gtk::ProgressBar()
)
);
+ $win_pb->set_position('center');
$win_pb->realize();
$win_pb->show_all();
- my $ey= $e_yes->get_chars( 0, -1 );
- my $en= $e_no->get_chars( 0, -1 );
+ my $ey= $e_yes->get_chars(0, -1);
+ my $en= $e_no->get_chars(0, -1);
$ey =~ s/ OR /\|/;
foreach (@all) {
+ $i++;
if ($i % 10) {
$pbar->update($i/$taille);
Gtk->main_iteration while Gtk->events_pending;
}
-
- if (($en eq "") and ($ey eq "")) {
- logcolorize($_)
- } else {
- if (/$ey/i and ($en eq "")) {
- logcolorize($_);
- } else {
- logcolorize($_) if (/$ey/i and (not /$en/i));
- }
- }
- $i++;
+
+ if (($en eq "") and /$ey/i) {logcolorize($_); next}
+ if ((! /$en/i) and /$ey/i) {logcolorize($_); next}
+ if ((! /$en/i) and ($ey eq "")) {logcolorize($_); next}
}
$win_pb->destroy();
-}
-#-------------------------------------------------------------
-# tree functions
-#-------------------------------------------------------------
-### Subroutines
-
-sub fill_tree {
- my $root_dir = "/var/log/" . $_[0];
- # Create root tree item widget
- $leaf = new_with_label Gtk::TreeItem( $root_dir );
- $tree->append( $leaf );
- $leaf->signal_connect( 'select', \&select_item, $root_dir );
- $leaf->set_user_data( $root_dir );
-
- # Create the subtree
- if (-d $root_dir) {
- my $subtree = new Gtk::Tree();
- $leaf->set_subtree( $subtree );
- $leaf->signal_connect( 'expand', \&expand_tree, $subtree );
- $leaf->signal_connect( 'collapse', \&collapse_tree );
- $leaf->expand();
- }
-}
-
-sub change_tree {
- $leaf->destroy();
- fill_tree (@_);
- $leaf->show();
-}
-
-# Callback for expanding a tree - find subdirectories, files and add them to tree
-sub expand_tree {
- my ($item, $subtree) = @_;
- my ($dir_entry, $path, $item_new, $new_subtree);
- my $dir = $item->get_user_data();
-
- chdir($dir);
- foreach $dir_entry ( <*> ) {
- $path = $dir . "/" . $dir_entry;
- $path =~ s|//|/|g;
- $item_new = new_with_label Gtk::TreeItem( $dir_entry );
- $item_new->set_user_data($path);
- $item_new->signal_connect('select', \&select_item, $path );
- $subtree->append($item_new);
- $item_new->show();
-
- if (-d $path) {
- $new_subtree = new Gtk::Tree();
- $item_new->set_subtree( $new_subtree );
- $item_new->signal_connect('expand', \&expand_tree, $new_subtree);
- $item_new->signal_connect('collapse', \&collapse_tree);
- }
- }
- chdir( ".." );
}
-# Callback for collapsing a tree -- removes the subtree
-sub collapse_tree {
- my ($item) = @_;
- my $subtree = new Gtk::Tree();
-
- $item->remove_subtree();
- $item->set_subtree( $subtree );
- $item->signal_connect( 'expand', \&expand_tree, $subtree );
-}
-
-# Called whenever an item is clicked on the tree widget.
-sub select_item {
- my ($widget, $file) = @_;
- return if (-d $file);
-
- $log->backward_delete($log->get_length());
- $log->freeze();
- parse_file($file);
- $log->thaw();
-}
-
-sub log_output {
- $log->insert($_[2],$_[0], undef,$_[1]);
-}
-
##########################################################################################
+
sub logcolorize {
# we get date & time if it is date & time (dmesg)
@@ -379,6 +266,11 @@ sub logcolorize {
}
+sub log_output {
+ $log_text->insert($_[2],$_[0], undef,$_[1]);
+}
+
+
#-------------------------------------------------------------
# menu callback functions
#-------------------------------------------------------------
@@ -432,10 +324,12 @@ sub destroy_window {
}
-
-
# log
# $Log$
+# Revision 1.13 2001/08/03 05:49:10 yduret
+# really fixed bug when embeded in mcc
+# use plain english instead of bad french
+#
# Revision 1.12 2001/08/02 08:28:18 pablo
# update pot file, s/ :/:/ for English text
#