2006-05-17 12:49:47 +00:00
|
|
|
--- mc-4.6.1a/src/setup.c.showfree 2006-02-23 16:32:18.000000000 +0100
|
2006-07-10 12:25:08 +00:00
|
|
|
+++ mc-4.6.1a/src/setup.c 2006-07-10 12:44:43.000000000 +0200
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -134,6 +134,7 @@
|
2006-02-28 11:14:11 +00:00
|
|
|
{ "show_mini_info", &show_mini_info },
|
|
|
|
{ "permission_mode", &permission_mode },
|
|
|
|
{ "filetype_mode", &filetype_mode },
|
|
|
|
+ { "free_space", &free_space },
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
2006-07-10 12:25:08 +00:00
|
|
|
--- mc-4.6.1a/src/main.c.showfree 2006-07-10 12:44:43.000000000 +0200
|
|
|
|
+++ mc-4.6.1a/src/main.c 2006-07-10 14:09:24.000000000 +0200
|
2006-05-29 11:43:26 +00:00
|
|
|
@@ -61,6 +61,7 @@
|
|
|
|
#include "listmode.h"
|
|
|
|
#include "execute.h"
|
|
|
|
#include "ext.h" /* For flush_extension_file() */
|
2005-12-28 14:21:04 +00:00
|
|
|
+#include "mountlist.h" /* my_statfs */
|
|
|
|
|
2006-05-29 11:43:26 +00:00
|
|
|
/* Listbox for the command history feature */
|
|
|
|
#include "widget.h"
|
|
|
|
@@ -231,6 +232,12 @@
|
|
|
|
/* We need to paint it after CONSOLE_RESTORE, see: load_prompt */
|
|
|
|
int update_prompt = 0;
|
2005-12-29 19:32:05 +00:00
|
|
|
|
|
|
|
+/* 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;
|
|
|
|
+
|
2006-05-29 11:43:26 +00:00
|
|
|
/* The home directory */
|
|
|
|
const char *home_dir = NULL;
|
2005-12-28 14:21:04 +00:00
|
|
|
|
2006-05-29 11:43:26 +00:00
|
|
|
@@ -402,6 +409,8 @@
|
|
|
|
int reload_other = !(force_update & UP_ONLY_CURRENT);
|
|
|
|
WPanel *panel;
|
|
|
|
|
|
|
|
+ show_free_space(current_panel);
|
2005-12-29 19:32:05 +00:00
|
|
|
+
|
2006-05-29 11:43:26 +00:00
|
|
|
update_one_panel (get_current_index (), force_update, current_file);
|
|
|
|
if (reload_other)
|
|
|
|
update_one_panel (get_other_index (), force_update, UP_KEEPSEL);
|
2006-07-10 12:25:08 +00:00
|
|
|
@@ -467,6 +476,48 @@
|
2006-05-29 11:43:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+void
|
2005-12-29 19:32:05 +00:00
|
|
|
+show_free_space(WPanel *panel)
|
|
|
|
+{
|
|
|
|
+ /* Don't try to stat non-local fs */
|
2006-05-29 11:43:26 +00:00
|
|
|
+ if (!vfs_file_is_local(panel->cwd) || !free_space)
|
2005-12-29 19:32:05 +00:00
|
|
|
+ return;
|
2006-05-29 11:43:26 +00:00
|
|
|
+
|
|
|
|
+ if (old_cwd == NULL || strcmp(old_cwd, panel->cwd) != 0) {
|
2006-07-10 12:25:08 +00:00
|
|
|
+ struct stat st;
|
|
|
|
+
|
2005-12-29 19:32:05 +00:00
|
|
|
+ init_my_statfs();
|
2006-01-02 13:22:35 +00:00
|
|
|
+ g_free(old_cwd);
|
2005-12-29 19:32:05 +00:00
|
|
|
+ old_cwd = g_strdup(panel->cwd);
|
2006-07-10 12:25:08 +00:00
|
|
|
+
|
|
|
|
+ if ( mc_lstat (panel->cwd, &st) )
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if ( !S_ISLNK (st.st_mode) ) {
|
|
|
|
+ my_statfs (&myfs_stats, panel->cwd);
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ char buf[MC_MAXPATHLEN];
|
|
|
|
+ memset (buf, 0, sizeof(buf));
|
|
|
|
+ if ( mc_readlink (panel->cwd, buf, sizeof(buf)-1) <= 0 )
|
|
|
|
+ return;
|
|
|
|
+ my_statfs (&myfs_stats, buf);
|
|
|
|
+ }
|
2005-12-29 19:32:05 +00:00
|
|
|
+ }
|
2006-05-29 11:43:26 +00:00
|
|
|
+
|
2005-12-29 19:32:05 +00:00
|
|
|
+ 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);
|
2006-01-02 13:22:35 +00:00
|
|
|
+ tmp = g_strdup_printf (_("%s (%d%%) of %s"), buffer1, myfs_stats.total > 0 ?
|
2005-12-29 19:32:05 +00:00
|
|
|
+ (int)(100 * (double)myfs_stats.avail / myfs_stats.total) : 0,
|
|
|
|
+ buffer2);
|
2006-06-07 13:01:24 +00:00
|
|
|
+ widget_move (&panel->widget, panel->widget.lines-1, panel->widget.cols-2-strlen(tmp));
|
2005-12-29 19:32:05 +00:00
|
|
|
+ addstr (tmp);
|
|
|
|
+ g_free (tmp);
|
|
|
|
+ }
|
|
|
|
+}
|
2006-05-29 11:43:26 +00:00
|
|
|
+
|
|
|
|
static int
|
|
|
|
quit_cmd_internal (int quiet)
|
2005-12-28 14:21:04 +00:00
|
|
|
{
|
2006-07-10 12:25:08 +00:00
|
|
|
--- mc-4.6.1a/src/main.h.showfree 2006-07-10 12:44:43.000000000 +0200
|
|
|
|
+++ mc-4.6.1a/src/main.h 2006-07-10 12:44:43.000000000 +0200
|
2006-05-29 11:43:26 +00:00
|
|
|
@@ -55,6 +55,7 @@
|
|
|
|
extern int show_all_if_ambiguous;
|
|
|
|
extern int slow_terminal;
|
|
|
|
extern int update_prompt; /* To comunicate with subshell */
|
|
|
|
+extern char *old_cwd;
|
|
|
|
extern int safe_delete;
|
|
|
|
extern int confirm_delete;
|
|
|
|
extern int confirm_directory_hotlist_delete;
|
|
|
|
@@ -102,6 +103,7 @@
|
|
|
|
int load_prompt (int, void *);
|
|
|
|
void save_cwds_stat (void);
|
|
|
|
void quiet_quit_cmd (void); /* For cmd.c and command.c */
|
|
|
|
+void show_free_space(WPanel *panel);
|
|
|
|
|
|
|
|
void touch_bar (void);
|
|
|
|
void update_xterm_title_path (void);
|
2006-07-10 12:25:08 +00:00
|
|
|
--- mc-4.6.1a/src/screen.c.showfree 2006-07-10 12:44:43.000000000 +0200
|
|
|
|
+++ mc-4.6.1a/src/screen.c 2006-07-10 12:44:43.000000000 +0200
|
2006-05-29 11:43:26 +00:00
|
|
|
@@ -47,7 +47,7 @@
|
|
|
|
#include "widget.h"
|
|
|
|
#include "menu.h" /* menubar_visible */
|
|
|
|
#define WANT_WIDGETS
|
|
|
|
-#include "main.h" /* the_menubar */
|
|
|
|
+#include "main.h" /* the_menubar, show_free_space() */
|
|
|
|
#include "unixcompat.h"
|
|
|
|
|
|
|
|
#define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
|
|
|
|
@@ -866,6 +866,7 @@
|
2005-12-28 14:21:04 +00:00
|
|
|
hline ((slow_terminal ? '-' : ACS_HLINE) | NORMAL_COLOR,
|
|
|
|
panel->widget.cols - 2);
|
|
|
|
#endif /* !HAVE_SLANG */
|
2006-05-29 11:43:26 +00:00
|
|
|
+ show_free_space (panel);
|
2005-12-28 14:21:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-05-29 11:43:26 +00:00
|
|
|
@@ -929,6 +930,8 @@
|
2005-12-28 14:21:04 +00:00
|
|
|
widget_move (&panel->widget, 0, panel->widget.cols - 3);
|
|
|
|
addstr ("v");
|
|
|
|
|
|
|
|
+ mini_info_separator (panel);
|
|
|
|
+
|
|
|
|
if (panel->active)
|
|
|
|
standend ();
|
|
|
|
}
|
2006-07-10 12:25:08 +00:00
|
|
|
--- mc-4.6.1a/src/layout.c.showfree 2006-07-10 12:44:43.000000000 +0200
|
|
|
|
+++ mc-4.6.1a/src/layout.c 2006-07-10 12:44:43.000000000 +0200
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -99,6 +99,9 @@
|
2006-02-01 15:10:24 +00:00
|
|
|
/* Set to show current working dir in xterm window title */
|
|
|
|
int xterm_title = 1;
|
|
|
|
|
|
|
|
+/* Set to show free space on device assigned to current directory */
|
|
|
|
+int free_space = 1;
|
|
|
|
+
|
|
|
|
/* The starting line for the output of the subprogram */
|
|
|
|
int output_start_y = 0;
|
|
|
|
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -128,6 +131,7 @@
|
2006-02-01 15:10:24 +00:00
|
|
|
static int _keybar_visible;
|
|
|
|
static int _message_visible;
|
|
|
|
static int _xterm_title;
|
|
|
|
+static int _free_space;
|
|
|
|
static int _permission_mode;
|
|
|
|
static int _filetype_mode;
|
|
|
|
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -158,6 +162,7 @@
|
2006-02-01 15:10:24 +00:00
|
|
|
int *variable;
|
|
|
|
WCheck *widget;
|
|
|
|
} check_options [] = {
|
2006-02-28 11:14:11 +00:00
|
|
|
+ { N_("show free sp&Ace"), &free_space, 0 },
|
2006-02-01 15:10:24 +00:00
|
|
|
{ N_("&Xterm window title"), &xterm_title, 0 },
|
|
|
|
{ N_("h&Intbar visible"), &message_visible, 0 },
|
|
|
|
{ N_("&Keybar visible"), &keybar_visible, 0 },
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -229,8 +234,8 @@
|
2006-02-01 15:10:24 +00:00
|
|
|
if (_equal_split){
|
|
|
|
/* Turn equal split off */
|
|
|
|
_equal_split = 0;
|
|
|
|
- check_options [6].widget->state = check_options [6].widget->state & ~C_BOOL;
|
|
|
|
- dlg_select_widget (check_options [6].widget);
|
|
|
|
+ check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL;
|
|
|
|
+ dlg_select_widget (check_options [7].widget);
|
|
|
|
dlg_select_widget (bleft_widget);
|
|
|
|
}
|
|
|
|
_first_panel_size++;
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -244,8 +249,8 @@
|
2006-02-01 15:10:24 +00:00
|
|
|
if (_equal_split){
|
|
|
|
/* Turn equal split off */
|
|
|
|
_equal_split = 0;
|
|
|
|
- check_options [6].widget->state = check_options [6].widget->state & ~C_BOOL;
|
|
|
|
- dlg_select_widget (check_options [6].widget);
|
|
|
|
+ check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL;
|
|
|
|
+ dlg_select_widget (check_options [7].widget);
|
|
|
|
dlg_select_widget (bright_widget);
|
|
|
|
}
|
|
|
|
_first_panel_size--;
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -291,23 +296,24 @@
|
|
|
|
if (old_output_lines != _output_lines){
|
|
|
|
old_output_lines = _output_lines;
|
|
|
|
attrset (COLOR_NORMAL);
|
|
|
|
- dlg_move (h, 9, 16 + first_width);
|
|
|
|
+ dlg_move (h, 10, 16 + first_width);
|
|
|
|
addstr (output_lines_label);
|
|
|
|
- dlg_move (h, 9, 10 + first_width);
|
|
|
|
+ dlg_move (h, 10, 10 + first_width);
|
|
|
|
tty_printf ("%02d", _output_lines);
|
|
|
|
}
|
|
|
|
}
|
2006-02-01 15:10:24 +00:00
|
|
|
return MSG_HANDLED;
|
|
|
|
|
|
|
|
case DLG_POST_KEY:
|
|
|
|
- _filetype_mode = check_options [8].widget->state & C_BOOL;
|
|
|
|
- _permission_mode = check_options [7].widget->state & C_BOOL;
|
|
|
|
- _equal_split = check_options [6].widget->state & C_BOOL;
|
|
|
|
- _menubar_visible = check_options [5].widget->state & C_BOOL;
|
|
|
|
- _command_prompt = check_options [4].widget->state & C_BOOL;
|
|
|
|
- _keybar_visible = check_options [2].widget->state & C_BOOL;
|
|
|
|
- _message_visible = check_options [1].widget->state & C_BOOL;
|
|
|
|
- _xterm_title = check_options [0].widget->state & C_BOOL;
|
|
|
|
+ _filetype_mode = check_options [9].widget->state & C_BOOL;
|
|
|
|
+ _permission_mode = check_options [8].widget->state & C_BOOL;
|
|
|
|
+ _equal_split = check_options [7].widget->state & C_BOOL;
|
|
|
|
+ _menubar_visible = check_options [6].widget->state & C_BOOL;
|
|
|
|
+ _command_prompt = check_options [5].widget->state & C_BOOL;
|
|
|
|
+ _keybar_visible = check_options [3].widget->state & C_BOOL;
|
|
|
|
+ _message_visible = check_options [2].widget->state & C_BOOL;
|
|
|
|
+ _xterm_title = check_options [1].widget->state & C_BOOL;
|
|
|
|
+ _free_space = check_options [0].widget->state & C_BOOL;
|
|
|
|
if (console_flag){
|
|
|
|
int minimum;
|
|
|
|
if (_output_lines < 0)
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -335,7 +341,7 @@
|
|
|
|
if (old_output_lines != _output_lines){
|
|
|
|
old_output_lines = _output_lines;
|
|
|
|
attrset (COLOR_NORMAL);
|
|
|
|
- dlg_move (h, 9, 10 + first_width);
|
|
|
|
+ dlg_move (h, 10, 10 + first_width);
|
|
|
|
tty_printf ("%02d", _output_lines);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -374,7 +380,7 @@
|
2006-02-01 15:10:24 +00:00
|
|
|
first_width = l1;
|
|
|
|
}
|
|
|
|
|
|
|
|
- for (i = 0; i <= 8; i++) {
|
|
|
|
+ for (i = 0; i <= 9; i++) {
|
|
|
|
check_options[i].text = _(check_options[i].text);
|
|
|
|
l1 = mbstrlen (check_options[i].text) + 7;
|
|
|
|
if (l1 > first_width)
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -391,7 +397,7 @@
|
2006-02-01 15:10:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
second_width = mbstrlen (title3) + 1;
|
|
|
|
- for (i = 0; i < 6; i++) {
|
|
|
|
+ for (i = 0; i < 7; i++) {
|
|
|
|
check_options[i].text = _(check_options[i].text);
|
|
|
|
l1 = mbstrlen (check_options[i].text) + 7;
|
|
|
|
if (l1 > second_width)
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -446,23 +452,23 @@
|
|
|
|
0));
|
|
|
|
if (console_flag) {
|
|
|
|
add_widget (layout_dlg,
|
|
|
|
- button_new (9, 12 + first_width, B_MINUS,
|
|
|
|
+ button_new (10, 12 + first_width, B_MINUS,
|
|
|
|
NARROW_BUTTON, "&-", bminus_cback));
|
|
|
|
add_widget (layout_dlg,
|
|
|
|
- button_new (9, 7 + first_width, B_PLUS, NARROW_BUTTON,
|
|
|
|
+ button_new (10, 7 + first_width, B_PLUS, NARROW_BUTTON,
|
|
|
|
"&+", bplus_cback));
|
2006-02-01 15:10:24 +00:00
|
|
|
}
|
|
|
|
#define XTRACT(i) *check_options[i].variable, check_options[i].text
|
|
|
|
|
|
|
|
- for (i = 0; i < 6; i++) {
|
|
|
|
+ for (i = 0; i < 7; i++) {
|
|
|
|
check_options[i].widget =
|
|
|
|
- check_new (8 - i, 7 + first_width, XTRACT (i));
|
|
|
|
+ check_new (9 - i, 7 + first_width, XTRACT (i));
|
|
|
|
add_widget (layout_dlg, check_options[i].widget);
|
|
|
|
}
|
|
|
|
- check_options[8].widget = check_new (10, 6, XTRACT (8));
|
|
|
|
+ check_options[9].widget = check_new (10, 6, XTRACT (9));
|
|
|
|
+ add_widget (layout_dlg, check_options[9].widget);
|
|
|
|
+ check_options[8].widget = check_new (9, 6, XTRACT (8));
|
|
|
|
add_widget (layout_dlg, check_options[8].widget);
|
|
|
|
- check_options[7].widget = check_new (9, 6, XTRACT (7));
|
|
|
|
- add_widget (layout_dlg, check_options[7].widget);
|
|
|
|
|
|
|
|
_filetype_mode = filetype_mode;
|
|
|
|
_permission_mode = permission_mode;
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -472,20 +478,21 @@
|
2006-02-01 15:10:24 +00:00
|
|
|
_keybar_visible = keybar_visible;
|
|
|
|
_message_visible = message_visible;
|
|
|
|
_xterm_title = xterm_title;
|
|
|
|
+ _free_space = free_space;
|
|
|
|
bright_widget =
|
|
|
|
button_new (6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback);
|
|
|
|
add_widget (layout_dlg, bright_widget);
|
|
|
|
bleft_widget =
|
|
|
|
button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback);
|
|
|
|
add_widget (layout_dlg, bleft_widget);
|
|
|
|
- check_options[6].widget = check_new (5, 6, XTRACT (6));
|
|
|
|
+ check_options[7].widget = check_new (5, 6, XTRACT (7));
|
|
|
|
old_first_panel_size = -1;
|
|
|
|
old_horizontal_split = -1;
|
|
|
|
old_output_lines = -1;
|
|
|
|
|
|
|
|
_first_panel_size = first_panel_size;
|
|
|
|
_output_lines = output_lines;
|
|
|
|
- add_widget (layout_dlg, check_options[6].widget);
|
|
|
|
+ add_widget (layout_dlg, check_options[7].widget);
|
2006-05-17 12:49:47 +00:00
|
|
|
radio_widget = radio_new (3, 6, 2, s_split_direction);
|
2006-02-01 15:10:24 +00:00
|
|
|
add_widget (layout_dlg, radio_widget);
|
|
|
|
radio_widget->sel = horizontal_split;
|
|
|
|
--- mc-4.6.1a/src/layout.h.showfree 2004-12-03 20:17:47.000000000 +0100
|
2006-07-10 12:25:08 +00:00
|
|
|
+++ mc-4.6.1a/src/layout.h 2006-07-10 12:44:43.000000000 +0200
|
2006-05-17 12:49:47 +00:00
|
|
|
@@ -39,6 +39,7 @@
|
2006-02-01 15:10:24 +00:00
|
|
|
extern int output_start_y;
|
|
|
|
extern int message_visible;
|
|
|
|
extern int xterm_title;
|
|
|
|
+extern int free_space;
|
|
|
|
|
|
|
|
extern int horizontal_split;
|
|
|
|
extern int nice_rotating_dash;
|