|
|
b9c426e |
--- mc-2007-01-24-03/src/setup.c.showfree 2006-02-23 16:45:06.000000000 +0100
|
|
|
b9c426e |
+++ mc-2007-01-24-03/src/setup.c 2007-02-15 09:53:48.000000000 +0100
|
|
|
33442ae |
@@ -134,6 +134,7 @@
|
|
|
4567fd4 |
{ "show_mini_info", &show_mini_info },
|
|
|
4567fd4 |
{ "permission_mode", &permission_mode },
|
|
|
4567fd4 |
{ "filetype_mode", &filetype_mode },
|
|
|
4567fd4 |
+ { "free_space", &free_space },
|
|
|
4567fd4 |
{ 0, 0 }
|
|
|
4567fd4 |
};
|
|
|
4567fd4 |
|
|
|
b9c426e |
--- mc-2007-01-24-03/src/main.c.showfree 2007-02-15 09:53:48.000000000 +0100
|
|
|
b9c426e |
+++ mc-2007-01-24-03/src/main.c 2007-02-15 09:53:48.000000000 +0100
|
|
|
b8a906e |
@@ -61,6 +61,7 @@
|
|
|
b8a906e |
#include "listmode.h"
|
|
|
b8a906e |
#include "execute.h"
|
|
|
b8a906e |
#include "ext.h" /* For flush_extension_file() */
|
|
|
ead0eea |
+#include "mountlist.h" /* my_statfs */
|
|
|
ead0eea |
|
|
|
b8a906e |
/* Listbox for the command history feature */
|
|
|
b8a906e |
#include "widget.h"
|
|
|
b8a906e |
@@ -231,6 +232,12 @@
|
|
|
b8a906e |
/* We need to paint it after CONSOLE_RESTORE, see: load_prompt */
|
|
|
b8a906e |
int update_prompt = 0;
|
|
|
b750860 |
|
|
|
b750860 |
+/* Old current working directory for displaying free space */
|
|
|
b750860 |
+char *old_cwd = NULL;
|
|
|
b750860 |
+
|
|
|
b750860 |
+/* Used to figure out how many free space we have */
|
|
|
b750860 |
+struct my_statfs myfs_stats;
|
|
|
b750860 |
+
|
|
|
b8a906e |
/* The home directory */
|
|
|
b8a906e |
const char *home_dir = NULL;
|
|
|
ead0eea |
|
|
|
b8a906e |
@@ -402,6 +409,8 @@
|
|
|
b8a906e |
int reload_other = !(force_update & UP_ONLY_CURRENT);
|
|
|
b8a906e |
WPanel *panel;
|
|
|
b8a906e |
|
|
|
b8a906e |
+ show_free_space(current_panel);
|
|
|
b750860 |
+
|
|
|
b8a906e |
update_one_panel (get_current_index (), force_update, current_file);
|
|
|
b8a906e |
if (reload_other)
|
|
|
b8a906e |
update_one_panel (get_other_index (), force_update, UP_KEEPSEL);
|
|
|
b9c426e |
@@ -467,6 +476,38 @@
|
|
|
b8a906e |
}
|
|
|
b8a906e |
}
|
|
|
b8a906e |
|
|
|
b8a906e |
+void
|
|
|
b750860 |
+show_free_space(WPanel *panel)
|
|
|
b750860 |
+{
|
|
|
b750860 |
+ /* Don't try to stat non-local fs */
|
|
|
b8a906e |
+ if (!vfs_file_is_local(panel->cwd) || !free_space)
|
|
|
b750860 |
+ return;
|
|
|
b8a906e |
+
|
|
|
b8a906e |
+ if (old_cwd == NULL || strcmp(old_cwd, panel->cwd) != 0) {
|
|
|
b9c426e |
+ char rpath[PATH_MAX];
|
|
|
b3faad5 |
+
|
|
|
b750860 |
+ init_my_statfs();
|
|
|
33ba53c |
+ g_free(old_cwd);
|
|
|
b750860 |
+ old_cwd = g_strdup(panel->cwd);
|
|
|
b3faad5 |
+
|
|
|
b9c426e |
+ if (mc_realpath (panel->cwd, rpath) == NULL)
|
|
|
b9c426e |
+ return;
|
|
|
b9c426e |
+ my_statfs (&myfs_stats, rpath);
|
|
|
b750860 |
+ }
|
|
|
b8a906e |
+
|
|
|
b750860 |
+ if (myfs_stats.avail > 0 || myfs_stats.total > 0) {
|
|
|
b750860 |
+ char buffer1 [6], buffer2[6], *tmp;
|
|
|
b750860 |
+ size_trunc_len (buffer1, 5, myfs_stats.avail, 1);
|
|
|
b750860 |
+ size_trunc_len (buffer2, 5, myfs_stats.total, 1);
|
|
|
33ba53c |
+ tmp = g_strdup_printf (_("%s (%d%%) of %s"), buffer1, myfs_stats.total > 0 ?
|
|
|
b750860 |
+ (int)(100 * (double)myfs_stats.avail / myfs_stats.total) : 0,
|
|
|
b750860 |
+ buffer2);
|
|
|
6b7b426 |
+ widget_move (&panel->widget, panel->widget.lines-1, panel->widget.cols-2-strlen(tmp));
|
|
|
b750860 |
+ addstr (tmp);
|
|
|
b750860 |
+ g_free (tmp);
|
|
|
b750860 |
+ }
|
|
|
b750860 |
+}
|
|
|
b8a906e |
+
|
|
|
b8a906e |
static int
|
|
|
b8a906e |
quit_cmd_internal (int quiet)
|
|
|
ead0eea |
{
|
|
|
b9c426e |
--- mc-2007-01-24-03/src/main.h.showfree 2007-02-15 09:53:48.000000000 +0100
|
|
|
b9c426e |
+++ mc-2007-01-24-03/src/main.h 2007-02-15 09:53:48.000000000 +0100
|
|
|
b8a906e |
@@ -55,6 +55,7 @@
|
|
|
b8a906e |
extern int show_all_if_ambiguous;
|
|
|
b8a906e |
extern int slow_terminal;
|
|
|
b8a906e |
extern int update_prompt; /* To comunicate with subshell */
|
|
|
b8a906e |
+extern char *old_cwd;
|
|
|
b8a906e |
extern int safe_delete;
|
|
|
b8a906e |
extern int confirm_delete;
|
|
|
b8a906e |
extern int confirm_directory_hotlist_delete;
|
|
|
b8a906e |
@@ -102,6 +103,7 @@
|
|
|
b8a906e |
int load_prompt (int, void *);
|
|
|
b8a906e |
void save_cwds_stat (void);
|
|
|
b8a906e |
void quiet_quit_cmd (void); /* For cmd.c and command.c */
|
|
|
b8a906e |
+void show_free_space(WPanel *panel);
|
|
|
b8a906e |
|
|
|
b8a906e |
void touch_bar (void);
|
|
|
b8a906e |
void update_xterm_title_path (void);
|
|
|
b9c426e |
--- mc-2007-01-24-03/src/screen.c.showfree 2007-02-15 09:53:48.000000000 +0100
|
|
|
b9c426e |
+++ mc-2007-01-24-03/src/screen.c 2007-02-15 09:53:48.000000000 +0100
|
|
|
b8a906e |
@@ -47,7 +47,7 @@
|
|
|
b8a906e |
#include "widget.h"
|
|
|
b8a906e |
#include "menu.h" /* menubar_visible */
|
|
|
b8a906e |
#define WANT_WIDGETS
|
|
|
b8a906e |
-#include "main.h" /* the_menubar */
|
|
|
b8a906e |
+#include "main.h" /* the_menubar, show_free_space() */
|
|
|
b8a906e |
#include "unixcompat.h"
|
|
|
b8a906e |
|
|
|
b8a906e |
#define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
|
|
|
b8a906e |
@@ -866,6 +866,7 @@
|
|
|
ead0eea |
hline ((slow_terminal ? '-' : ACS_HLINE) | NORMAL_COLOR,
|
|
|
ead0eea |
panel->widget.cols - 2);
|
|
|
ead0eea |
#endif /* !HAVE_SLANG */
|
|
|
b8a906e |
+ show_free_space (panel);
|
|
|
ead0eea |
}
|
|
|
ead0eea |
|
|
|
ead0eea |
static void
|
|
|
b9c426e |
@@ -910,6 +911,8 @@
|
|
|
ead0eea |
widget_move (&panel->widget, 0, panel->widget.cols - 3);
|
|
|
ead0eea |
addstr ("v");
|
|
|
ead0eea |
|
|
|
ead0eea |
+ mini_info_separator (panel);
|
|
|
ead0eea |
+
|
|
|
ead0eea |
if (panel->active)
|
|
|
ead0eea |
standend ();
|
|
|
ead0eea |
}
|
|
|
b9c426e |
--- mc-2007-01-24-03/src/layout.c.showfree 2007-02-15 09:53:47.000000000 +0100
|
|
|
b9c426e |
+++ mc-2007-01-24-03/src/layout.c 2007-02-15 09:53:48.000000000 +0100
|
|
|
b9c426e |
@@ -96,6 +96,9 @@
|
|
|
beabfeb |
/* Set to show current working dir in xterm window title */
|
|
|
beabfeb |
int xterm_title = 1;
|
|
|
beabfeb |
|
|
|
beabfeb |
+/* Set to show free space on device assigned to current directory */
|
|
|
beabfeb |
+int free_space = 1;
|
|
|
beabfeb |
+
|
|
|
beabfeb |
/* The starting line for the output of the subprogram */
|
|
|
beabfeb |
int output_start_y = 0;
|
|
|
beabfeb |
|
|
|
b9c426e |
@@ -125,6 +128,7 @@
|
|
|
beabfeb |
static int _keybar_visible;
|
|
|
beabfeb |
static int _message_visible;
|
|
|
beabfeb |
static int _xterm_title;
|
|
|
beabfeb |
+static int _free_space;
|
|
|
beabfeb |
static int _permission_mode;
|
|
|
beabfeb |
static int _filetype_mode;
|
|
|
beabfeb |
|
|
|
b9c426e |
@@ -155,6 +159,7 @@
|
|
|
beabfeb |
int *variable;
|
|
|
beabfeb |
WCheck *widget;
|
|
|
beabfeb |
} check_options [] = {
|
|
|
4567fd4 |
+ { N_("show free sp&Ace"), &free_space, 0 },
|
|
|
beabfeb |
{ N_("&Xterm window title"), &xterm_title, 0 },
|
|
|
beabfeb |
{ N_("h&Intbar visible"), &message_visible, 0 },
|
|
|
beabfeb |
{ N_("&Keybar visible"), &keybar_visible, 0 },
|
|
|
b9c426e |
@@ -226,8 +231,8 @@
|
|
|
beabfeb |
if (_equal_split){
|
|
|
beabfeb |
/* Turn equal split off */
|
|
|
beabfeb |
_equal_split = 0;
|
|
|
beabfeb |
- check_options [6].widget->state = check_options [6].widget->state & ~C_BOOL;
|
|
|
beabfeb |
- dlg_select_widget (check_options [6].widget);
|
|
|
beabfeb |
+ check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL;
|
|
|
beabfeb |
+ dlg_select_widget (check_options [7].widget);
|
|
|
beabfeb |
dlg_select_widget (bleft_widget);
|
|
|
beabfeb |
}
|
|
|
beabfeb |
_first_panel_size++;
|
|
|
b9c426e |
@@ -241,8 +246,8 @@
|
|
|
beabfeb |
if (_equal_split){
|
|
|
beabfeb |
/* Turn equal split off */
|
|
|
beabfeb |
_equal_split = 0;
|
|
|
beabfeb |
- check_options [6].widget->state = check_options [6].widget->state & ~C_BOOL;
|
|
|
beabfeb |
- dlg_select_widget (check_options [6].widget);
|
|
|
beabfeb |
+ check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL;
|
|
|
beabfeb |
+ dlg_select_widget (check_options [7].widget);
|
|
|
beabfeb |
dlg_select_widget (bright_widget);
|
|
|
beabfeb |
}
|
|
|
beabfeb |
_first_panel_size--;
|
|
|
b9c426e |
@@ -288,23 +293,24 @@
|
|
|
33442ae |
if (old_output_lines != _output_lines){
|
|
|
33442ae |
old_output_lines = _output_lines;
|
|
|
33442ae |
attrset (COLOR_NORMAL);
|
|
|
33442ae |
- dlg_move (h, 9, 16 + first_width);
|
|
|
33442ae |
+ dlg_move (h, 10, 16 + first_width);
|
|
|
33442ae |
addstr (output_lines_label);
|
|
|
33442ae |
- dlg_move (h, 9, 10 + first_width);
|
|
|
33442ae |
+ dlg_move (h, 10, 10 + first_width);
|
|
|
33442ae |
tty_printf ("%02d", _output_lines);
|
|
|
33442ae |
}
|
|
|
33442ae |
}
|
|
|
beabfeb |
return MSG_HANDLED;
|
|
|
beabfeb |
|
|
|
beabfeb |
case DLG_POST_KEY:
|
|
|
beabfeb |
- _filetype_mode = check_options [8].widget->state & C_BOOL;
|
|
|
beabfeb |
- _permission_mode = check_options [7].widget->state & C_BOOL;
|
|
|
beabfeb |
- _equal_split = check_options [6].widget->state & C_BOOL;
|
|
|
beabfeb |
- _menubar_visible = check_options [5].widget->state & C_BOOL;
|
|
|
beabfeb |
- _command_prompt = check_options [4].widget->state & C_BOOL;
|
|
|
beabfeb |
- _keybar_visible = check_options [2].widget->state & C_BOOL;
|
|
|
beabfeb |
- _message_visible = check_options [1].widget->state & C_BOOL;
|
|
|
beabfeb |
- _xterm_title = check_options [0].widget->state & C_BOOL;
|
|
|
beabfeb |
+ _filetype_mode = check_options [9].widget->state & C_BOOL;
|
|
|
beabfeb |
+ _permission_mode = check_options [8].widget->state & C_BOOL;
|
|
|
beabfeb |
+ _equal_split = check_options [7].widget->state & C_BOOL;
|
|
|
beabfeb |
+ _menubar_visible = check_options [6].widget->state & C_BOOL;
|
|
|
beabfeb |
+ _command_prompt = check_options [5].widget->state & C_BOOL;
|
|
|
beabfeb |
+ _keybar_visible = check_options [3].widget->state & C_BOOL;
|
|
|
beabfeb |
+ _message_visible = check_options [2].widget->state & C_BOOL;
|
|
|
beabfeb |
+ _xterm_title = check_options [1].widget->state & C_BOOL;
|
|
|
beabfeb |
+ _free_space = check_options [0].widget->state & C_BOOL;
|
|
|
beabfeb |
if (console_flag){
|
|
|
beabfeb |
int minimum;
|
|
|
beabfeb |
if (_output_lines < 0)
|
|
|
b9c426e |
@@ -332,7 +338,7 @@
|
|
|
33442ae |
if (old_output_lines != _output_lines){
|
|
|
33442ae |
old_output_lines = _output_lines;
|
|
|
33442ae |
attrset (COLOR_NORMAL);
|
|
|
33442ae |
- dlg_move (h, 9, 10 + first_width);
|
|
|
33442ae |
+ dlg_move (h, 10, 10 + first_width);
|
|
|
33442ae |
tty_printf ("%02d", _output_lines);
|
|
|
33442ae |
}
|
|
|
33442ae |
}
|
|
|
b9c426e |
@@ -371,7 +377,7 @@
|
|
|
beabfeb |
first_width = l1;
|
|
|
beabfeb |
}
|
|
|
beabfeb |
|
|
|
beabfeb |
- for (i = 0; i <= 8; i++) {
|
|
|
beabfeb |
+ for (i = 0; i <= 9; i++) {
|
|
|
beabfeb |
check_options[i].text = _(check_options[i].text);
|
|
|
beabfeb |
l1 = mbstrlen (check_options[i].text) + 7;
|
|
|
beabfeb |
if (l1 > first_width)
|
|
|
b9c426e |
@@ -388,7 +394,7 @@
|
|
|
beabfeb |
|
|
|
beabfeb |
|
|
|
beabfeb |
second_width = mbstrlen (title3) + 1;
|
|
|
beabfeb |
- for (i = 0; i < 6; i++) {
|
|
|
beabfeb |
+ for (i = 0; i < 7; i++) {
|
|
|
beabfeb |
check_options[i].text = _(check_options[i].text);
|
|
|
beabfeb |
l1 = mbstrlen (check_options[i].text) + 7;
|
|
|
beabfeb |
if (l1 > second_width)
|
|
|
b9c426e |
@@ -443,23 +449,23 @@
|
|
|
33442ae |
0));
|
|
|
33442ae |
if (console_flag) {
|
|
|
33442ae |
add_widget (layout_dlg,
|
|
|
33442ae |
- button_new (9, 12 + first_width, B_MINUS,
|
|
|
33442ae |
+ button_new (10, 12 + first_width, B_MINUS,
|
|
|
33442ae |
NARROW_BUTTON, "&-", bminus_cback));
|
|
|
33442ae |
add_widget (layout_dlg,
|
|
|
33442ae |
- button_new (9, 7 + first_width, B_PLUS, NARROW_BUTTON,
|
|
|
33442ae |
+ button_new (10, 7 + first_width, B_PLUS, NARROW_BUTTON,
|
|
|
33442ae |
"&+", bplus_cback));
|
|
|
beabfeb |
}
|
|
|
beabfeb |
#define XTRACT(i) *check_options[i].variable, check_options[i].text
|
|
|
beabfeb |
|
|
|
beabfeb |
- for (i = 0; i < 6; i++) {
|
|
|
beabfeb |
+ for (i = 0; i < 7; i++) {
|
|
|
beabfeb |
check_options[i].widget =
|
|
|
beabfeb |
- check_new (8 - i, 7 + first_width, XTRACT (i));
|
|
|
beabfeb |
+ check_new (9 - i, 7 + first_width, XTRACT (i));
|
|
|
beabfeb |
add_widget (layout_dlg, check_options[i].widget);
|
|
|
beabfeb |
}
|
|
|
beabfeb |
- check_options[8].widget = check_new (10, 6, XTRACT (8));
|
|
|
beabfeb |
+ check_options[9].widget = check_new (10, 6, XTRACT (9));
|
|
|
beabfeb |
+ add_widget (layout_dlg, check_options[9].widget);
|
|
|
beabfeb |
+ check_options[8].widget = check_new (9, 6, XTRACT (8));
|
|
|
beabfeb |
add_widget (layout_dlg, check_options[8].widget);
|
|
|
beabfeb |
- check_options[7].widget = check_new (9, 6, XTRACT (7));
|
|
|
beabfeb |
- add_widget (layout_dlg, check_options[7].widget);
|
|
|
beabfeb |
|
|
|
beabfeb |
_filetype_mode = filetype_mode;
|
|
|
beabfeb |
_permission_mode = permission_mode;
|
|
|
b9c426e |
@@ -469,20 +475,21 @@
|
|
|
beabfeb |
_keybar_visible = keybar_visible;
|
|
|
beabfeb |
_message_visible = message_visible;
|
|
|
beabfeb |
_xterm_title = xterm_title;
|
|
|
beabfeb |
+ _free_space = free_space;
|
|
|
beabfeb |
bright_widget =
|
|
|
beabfeb |
button_new (6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback);
|
|
|
beabfeb |
add_widget (layout_dlg, bright_widget);
|
|
|
beabfeb |
bleft_widget =
|
|
|
beabfeb |
button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback);
|
|
|
beabfeb |
add_widget (layout_dlg, bleft_widget);
|
|
|
beabfeb |
- check_options[6].widget = check_new (5, 6, XTRACT (6));
|
|
|
beabfeb |
+ check_options[7].widget = check_new (5, 6, XTRACT (7));
|
|
|
beabfeb |
old_first_panel_size = -1;
|
|
|
beabfeb |
old_horizontal_split = -1;
|
|
|
beabfeb |
old_output_lines = -1;
|
|
|
beabfeb |
|
|
|
beabfeb |
_first_panel_size = first_panel_size;
|
|
|
beabfeb |
_output_lines = output_lines;
|
|
|
beabfeb |
- add_widget (layout_dlg, check_options[6].widget);
|
|
|
beabfeb |
+ add_widget (layout_dlg, check_options[7].widget);
|
|
|
33442ae |
radio_widget = radio_new (3, 6, 2, s_split_direction);
|
|
|
beabfeb |
add_widget (layout_dlg, radio_widget);
|
|
|
beabfeb |
radio_widget->sel = horizontal_split;
|
|
|
b9c426e |
--- mc-2007-01-24-03/src/layout.h.showfree 2004-12-03 20:17:47.000000000 +0100
|
|
|
b9c426e |
+++ mc-2007-01-24-03/src/layout.h 2007-02-15 09:53:48.000000000 +0100
|
|
|
33442ae |
@@ -39,6 +39,7 @@
|
|
|
beabfeb |
extern int output_start_y;
|
|
|
beabfeb |
extern int message_visible;
|
|
|
beabfeb |
extern int xterm_title;
|
|
|
beabfeb |
+extern int free_space;
|
|
|
beabfeb |
|
|
|
beabfeb |
extern int horizontal_split;
|
|
|
beabfeb |
extern int nice_rotating_dash;
|