- display free space on a device assigned to current directory in main

panels
- correctly diplay characters in mcview for non-UTF-8 LANG set (#174004)
    thanks to Dmitry Butskoy
This commit is contained in:
Jindrich Novy 2005-12-29 19:32:05 +00:00
parent ead0eeaff7
commit b750860e96

View File

@ -1,5 +1,5 @@
--- mc-4.6.1a/src/screen.c.showfree 2005-12-27 10:45:05.000000000 +0100 --- mc-4.6.1a/src/screen.c.showfree 2005-12-28 16:49:52.000000000 +0100
+++ mc-4.6.1a/src/screen.c 2005-12-27 12:52:58.000000000 +0100 +++ mc-4.6.1a/src/screen.c 2005-12-28 17:14:45.000000000 +0100
@@ -49,6 +49,7 @@ @@ -49,6 +49,7 @@
#define WANT_WIDGETS #define WANT_WIDGETS
#include "main.h" /* the_menubar */ #include "main.h" /* the_menubar */
@ -8,32 +8,41 @@
#define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) ) #define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
@@ -851,6 +852,9 @@ paint_dir (WPanel *panel) @@ -106,6 +107,12 @@ int filetype_mode = 1;
/* The hook list for the select file function */
Hook *select_file_hook = 0;
+/* Old current working directory for displaying free space */
+char *old_cwd = NULL;
+
+/* Used to figure out how many free space we have */
+struct my_statfs myfs_stats;
+
static cb_ret_t panel_callback (Widget *, widget_msg_t msg, int parm);
static int panel_event (Gpm_Event *event, void *);
static void paint_frame (WPanel *panel);
@@ -851,6 +858,41 @@ paint_dir (WPanel *panel)
standend (); standend ();
} }
+static int initialized;
+static struct my_statfs myfs_stats;
+ +
static void +static void
mini_info_separator (WPanel *panel) +show_free_space(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; + struct stat st;
+ +
+ if (!initialized) { + /* Don't try to stat non-local fs */
+ initialized = 1; + if (strlen(panel->cwd) >= 2 && panel->cwd[0] == '/' && panel->cwd[1] == '#')
+ return;
+
+ if (old_cwd == NULL || strcmp(old_cwd, panel->cwd)) {
+ init_my_statfs(); + init_my_statfs();
+ if (old_cwd != NULL) g_free(old_cwd);
+ old_cwd = g_strdup(panel->cwd);
+ } + }
+ +
+ my_statfs (&myfs_stats, current_panel->cwd); + my_statfs (&myfs_stats, panel->cwd);
+ st = current_panel->dir.list [current_panel->selected].st; + st = panel->dir.list [panel->selected].st;
+ +
+ if (myfs_stats.avail > 0 || myfs_stats.total > 0) { + if (myfs_stats.avail > 0 || myfs_stats.total > 0) {
+ char buffer1 [6], buffer2[6], *tmp; + char buffer1 [6], buffer2[6], *tmp;
@ -49,11 +58,20 @@
+ attrset (NORMAL_COLOR); + attrset (NORMAL_COLOR);
+ g_free (tmp); + g_free (tmp);
+ } + }
+ } +}
+
static void
mini_info_separator (WPanel *panel)
{
@@ -866,6 +908,7 @@ mini_info_separator (WPanel *panel)
hline ((slow_terminal ? '-' : ACS_HLINE) | NORMAL_COLOR,
panel->widget.cols - 2);
#endif /* !HAVE_SLANG */
+ show_free_space (panel);
} }
static void static void
@@ -929,6 +961,8 @@ show_dir (WPanel *panel) @@ -929,6 +972,8 @@ show_dir (WPanel *panel)
widget_move (&panel->widget, 0, panel->widget.cols - 3); widget_move (&panel->widget, 0, panel->widget.cols - 3);
addstr ("v"); addstr ("v");