Re: Fearure request
- From: Jindrich Novy <jnovy redhat com>
- To: Sergei Trofimovich <slyich gmail com>
- Cc: mc-devel gnome org
- Subject: Re: Fearure request
- Date: Wed, 28 Dec 2005 15:33:50 +0100
Hello Sergei,
On Wed, 2005-11-16 at 01:06 +0200, Sergei Trofimovich wrote:
> It would be great to see in the bottom
> of window free space of current directory. (df /path/to/dir)
the following patch adds support for displaying an amount of free
space figured by stat-ing the current directory. The free space is
displayed like this:
3509M (16%) of 21G
in the status separator line on each panel. I consider this feature
helpful as well.
Cheers,
Jindrich
--
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/
(o_ _o)
//\ The worst evil in the world is refusal to think. //\
V_/_ _\_V
--- mc-4.6.1a/src/screen.c.showfree 2005-12-27 10:45:05.000000000 +0100
+++ mc-4.6.1a/src/screen.c 2005-12-27 12:52:58.000000000 +0100
@@ -49,6 +49,7 @@
#define WANT_WIDGETS
#include "main.h" /* the_menubar */
#include "unixcompat.h"
+#include "mountlist.h" /* my_statfs */
#define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
@@ -851,6 +852,9 @@ paint_dir (WPanel *panel)
standend ();
}
+static int initialized;
+static struct my_statfs myfs_stats;
+
static void
mini_info_separator (WPanel *panel)
{
@@ -866,6 +870,34 @@ mini_info_separator (WPanel *panel)
hline ((slow_terminal ? '-' : ACS_HLINE) | NORMAL_COLOR,
panel->widget.cols - 2);
#endif /* !HAVE_SLANG */
+
+
+ {
+ struct stat st;
+
+ if (!initialized) {
+ initialized = 1;
+ init_my_statfs();
+ }
+
+ my_statfs (&myfs_stats, current_panel->cwd);
+ st = current_panel->dir.list [current_panel->selected].st;
+
+ if (myfs_stats.avail > 0 || myfs_stats.total > 0) {
+ char buffer1 [6], buffer2[6], *tmp;
+ size_trunc_len (buffer1, 5, myfs_stats.avail, 1);
+ size_trunc_len (buffer2, 5, myfs_stats.total, 1);
+ tmp = g_strdup_printf (_("%s (%d%%) of %s"), buffer1, myfs_stats.total ?
+ (int)(100 * (double)myfs_stats.avail / myfs_stats.total) : 0,
+ buffer2);
+ widget_move (&panel->widget, panel->widget.lines-3, panel->widget.cols-2-strlen(tmp));
+ if (panel->active)
+ attrset (REVERSE_COLOR);
+ addstr (tmp);
+ attrset (NORMAL_COLOR);
+ g_free (tmp);
+ }
+ }
}
static void
@@ -929,6 +961,8 @@ show_dir (WPanel *panel)
widget_move (&panel->widget, 0, panel->widget.cols - 3);
addstr ("v");
+ mini_info_separator (panel);
+
if (panel->active)
standend ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]