1998-02-27 07:54:42 +03:00
|
|
|
/* Panel managing.
|
|
|
|
Copyright (C) 1994, 1995 Janne Kukonlehto
|
|
|
|
Copyright (C) 1995 Miguel de Icaza
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2000-08-23 02:50:00 +04:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2001-09-03 09:07:40 +04:00
|
|
|
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
#include "global.h"
|
2001-09-03 09:07:40 +04:00
|
|
|
#include "tty.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "mouse.h" /* Gpm_Event */
|
|
|
|
#include "color.h"
|
2003-10-25 03:20:30 +04:00
|
|
|
#include "dialog.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "info.h"
|
|
|
|
#include "dir.h" /* required by panel */
|
|
|
|
#include "panel.h" /* for the panel structure */
|
2003-10-26 09:45:59 +03:00
|
|
|
#include "main.h" /* other_panel, current_panel definitions */
|
2001-08-30 20:58:40 +04:00
|
|
|
#include "util.h" /* size_trunc_len */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "layout.h"
|
|
|
|
#include "key.h" /* is_idle() */
|
2001-06-19 02:24:04 +04:00
|
|
|
#include "mountlist.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
|
1998-12-02 08:18:20 +03:00
|
|
|
#ifndef VERSION
|
|
|
|
# define VERSION "undefined"
|
|
|
|
#endif
|
|
|
|
|
2003-10-26 08:54:55 +03:00
|
|
|
struct WInfo {
|
|
|
|
Widget widget;
|
|
|
|
int ready;
|
|
|
|
};
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Have we called the init_my_statfs routine? */
|
|
|
|
static int initialized;
|
2001-06-05 20:41:44 +04:00
|
|
|
static struct my_statfs myfs_stats;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-10-26 08:54:55 +03:00
|
|
|
static void info_box (Dlg_head *h, struct WInfo *info)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
standend ();
|
2002-09-08 21:30:52 +04:00
|
|
|
attrset (NORMAL_COLOR);
|
1998-02-27 07:54:42 +03:00
|
|
|
widget_erase (&info->widget);
|
|
|
|
draw_double_box (h, info->widget.y, info->widget.x,
|
|
|
|
info->widget.lines, info->widget.cols);
|
|
|
|
}
|
|
|
|
|
1998-12-03 00:27:27 +03:00
|
|
|
static void
|
2003-10-26 08:54:55 +03:00
|
|
|
info_show_info (struct WInfo *info)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1999-04-06 23:00:16 +04:00
|
|
|
static int i18n_adjust=0;
|
|
|
|
static char *file_label;
|
|
|
|
|
2003-08-18 04:47:43 +04:00
|
|
|
struct stat st;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
if (!is_idle ())
|
|
|
|
return;
|
|
|
|
|
|
|
|
info_box (info->widget.parent, info);
|
|
|
|
attrset (MARKED_COLOR);
|
|
|
|
widget_move (&info->widget, 1, 3);
|
1998-03-25 08:16:00 +03:00
|
|
|
printw (_("Midnight Commander %s"), VERSION);
|
1998-02-27 07:54:42 +03:00
|
|
|
attrset (NORMAL_COLOR);
|
|
|
|
widget_move (&info->widget, 2, 1);
|
|
|
|
hline (ACS_HLINE|NORMAL_COLOR, info->widget.x-2);
|
|
|
|
if (get_current_type () != view_listing)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!info->ready)
|
|
|
|
return;
|
|
|
|
|
2003-10-26 09:45:59 +03:00
|
|
|
my_statfs (&myfs_stats, current_panel->cwd);
|
|
|
|
st = current_panel->dir.list [current_panel->selected].st;
|
2003-08-18 04:47:43 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Print only lines which fit */
|
1999-04-06 23:00:16 +04:00
|
|
|
|
|
|
|
if(!i18n_adjust) {
|
2001-08-30 19:14:39 +04:00
|
|
|
/* This printf pattern string is used as a reference for size */
|
1999-04-06 23:00:16 +04:00
|
|
|
file_label=_("File: %s");
|
|
|
|
i18n_adjust=strlen(file_label)+2;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (info->widget.lines-2){
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Note: all cases are fall-throughs */
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
widget_move (&info->widget, 16, 3);
|
|
|
|
if (myfs_stats.nfree >0 || myfs_stats.nodes > 0)
|
2001-08-30 20:58:40 +04:00
|
|
|
printw (_("Free nodes: %d (%d%%) of %d"),
|
1998-02-27 07:54:42 +03:00
|
|
|
myfs_stats.nfree,
|
|
|
|
myfs_stats.total
|
|
|
|
? 100 * myfs_stats.nfree / myfs_stats.nodes : 0,
|
|
|
|
myfs_stats.nodes);
|
|
|
|
else
|
1998-03-25 08:16:00 +03:00
|
|
|
addstr (_("No node information"));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 15:
|
|
|
|
widget_move (&info->widget, 15, 3);
|
|
|
|
if (myfs_stats.avail > 0 || myfs_stats.total > 0){
|
2001-08-30 20:58:40 +04:00
|
|
|
char buffer1 [6], buffer2[6];
|
|
|
|
size_trunc_len (buffer1, 5, myfs_stats.avail, 1);
|
|
|
|
size_trunc_len (buffer2, 5, myfs_stats.total, 1);
|
|
|
|
printw (_("Free space: %s (%d%%) of %s"), buffer1, myfs_stats.total ?
|
2003-05-27 11:22:04 +04:00
|
|
|
(int)(100 * (double)myfs_stats.avail / myfs_stats.total) : 0,
|
|
|
|
buffer2);
|
1998-02-27 07:54:42 +03:00
|
|
|
} else
|
1998-03-25 08:16:00 +03:00
|
|
|
addstr (_("No space information"));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 14:
|
|
|
|
widget_move (&info->widget, 14, 3);
|
1998-03-25 08:16:00 +03:00
|
|
|
printw (_("Type: %s "), myfs_stats.typename ? myfs_stats.typename : _("non-local vfs"));
|
1998-02-27 07:54:42 +03:00
|
|
|
if (myfs_stats.type != 0xffff && myfs_stats.type != 0xffffffff)
|
|
|
|
printw (" (%Xh)", myfs_stats.type);
|
|
|
|
|
|
|
|
case 13:
|
|
|
|
widget_move (&info->widget, 13, 3);
|
1998-03-25 08:16:00 +03:00
|
|
|
printw (_("Device: %s"),
|
1999-04-06 23:00:16 +04:00
|
|
|
name_trunc (myfs_stats.device, info->widget.cols - i18n_adjust));
|
1998-02-27 07:54:42 +03:00
|
|
|
case 12:
|
|
|
|
widget_move (&info->widget, 12, 3);
|
1998-03-25 08:16:00 +03:00
|
|
|
printw (_("Filesystem: %s"),
|
1999-04-06 23:00:16 +04:00
|
|
|
name_trunc (myfs_stats.mpoint, info->widget.cols - i18n_adjust));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 11:
|
|
|
|
widget_move (&info->widget, 11, 3);
|
2003-08-18 04:47:43 +04:00
|
|
|
printw (_("Accessed: %s"), file_date (st.st_atime));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 10:
|
|
|
|
widget_move (&info->widget, 10, 3);
|
2003-08-18 04:47:43 +04:00
|
|
|
printw (_("Modified: %s"), file_date (st.st_mtime));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 9:
|
|
|
|
widget_move (&info->widget, 9, 3);
|
2003-08-18 04:47:43 +04:00
|
|
|
printw (_("Created: %s"), file_date (st.st_ctime));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 8:
|
|
|
|
widget_move (&info->widget, 8, 3);
|
|
|
|
#if 0
|
2003-10-29 20:36:16 +03:00
|
|
|
#ifdef HAVE_STRUCT_STAT_ST_RDEV
|
2003-08-18 04:47:43 +04:00
|
|
|
if (st.st_rdev)
|
1998-02-27 07:54:42 +03:00
|
|
|
printw ("Inode dev: major: %d, minor: %d",
|
2003-08-18 04:47:43 +04:00
|
|
|
st.st_rdev >> 8, st.st_rdev & 0xff);
|
1998-02-27 07:54:42 +03:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
{
|
2001-08-30 20:58:40 +04:00
|
|
|
char buffer[10];
|
2003-08-18 04:47:43 +04:00
|
|
|
size_trunc_len(buffer, 9, st.st_size, 0);
|
2001-08-30 20:58:40 +04:00
|
|
|
printw (_("Size: %s"), buffer);
|
2003-10-29 20:36:16 +03:00
|
|
|
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
|
2003-08-18 04:47:43 +04:00
|
|
|
printw ((st.st_blocks==1) ?
|
2004-08-16 03:03:08 +04:00
|
|
|
_(" (%d block)") : _(" (%d blocks)"), (int) st.st_blocks);
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
widget_move (&info->widget, 7, 3);
|
2003-08-18 04:47:43 +04:00
|
|
|
printw (_("Owner: %s/%s"), get_owner (st.st_uid),
|
|
|
|
get_group (st.st_gid));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 6:
|
|
|
|
widget_move (&info->widget, 6, 3);
|
2003-08-18 04:47:43 +04:00
|
|
|
printw (_("Links: %d"), (int) st.st_nlink);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 5:
|
|
|
|
widget_move (&info->widget, 5, 3);
|
1998-03-25 08:16:00 +03:00
|
|
|
printw (_("Mode: %s (%04o)"),
|
2003-08-18 04:47:43 +04:00
|
|
|
string_perm (st.st_mode), st.st_mode & 07777);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 4:
|
|
|
|
widget_move (&info->widget, 4, 3);
|
2003-08-18 04:47:43 +04:00
|
|
|
printw (_("Location: %Xh:%Xh"), (int)st.st_dev, (int)st.st_ino);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 3:
|
|
|
|
widget_move (&info->widget, 3, 2);
|
2001-08-30 20:58:40 +04:00
|
|
|
/* .ado: fname is invalid if selected == 0 && info called from current panel */
|
2003-10-26 09:45:59 +03:00
|
|
|
if (current_panel->selected){
|
1999-04-06 23:00:16 +04:00
|
|
|
printw (file_label,
|
2003-10-26 09:45:59 +03:00
|
|
|
name_trunc (current_panel->dir.list [current_panel->selected].fname,
|
1999-04-06 23:00:16 +04:00
|
|
|
info->widget.cols - i18n_adjust));
|
1998-02-27 07:54:42 +03:00
|
|
|
} else
|
1998-03-25 08:16:00 +03:00
|
|
|
printw (_("File: None"));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case 2:
|
|
|
|
case 1:
|
|
|
|
case 0:
|
|
|
|
;
|
|
|
|
} /* switch */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void info_hook (void *data)
|
|
|
|
{
|
2003-10-26 08:54:55 +03:00
|
|
|
struct WInfo *info = (struct WInfo *) data;
|
1998-02-27 07:54:42 +03:00
|
|
|
Widget *other_widget;
|
|
|
|
|
|
|
|
other_widget = get_panel_widget (get_current_index ());
|
|
|
|
if (!other_widget)
|
|
|
|
return;
|
|
|
|
if (dlg_overlap (&info->widget, other_widget))
|
|
|
|
return;
|
|
|
|
|
|
|
|
info->ready = 1;
|
|
|
|
info_show_info (info);
|
|
|
|
}
|
|
|
|
|
2003-09-11 02:48:54 +04:00
|
|
|
static cb_ret_t
|
2003-10-26 08:54:55 +03:00
|
|
|
info_callback (struct WInfo *info, widget_msg_t msg, int parm)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2003-09-10 22:21:40 +04:00
|
|
|
switch (msg) {
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case WIDGET_INIT:
|
|
|
|
add_hook (&select_file_hook, info_hook, info);
|
|
|
|
info->ready = 0;
|
2003-09-11 02:48:54 +04:00
|
|
|
return MSG_HANDLED;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case WIDGET_DRAW:
|
|
|
|
info_hook (info);
|
|
|
|
info_show_info (info);
|
2003-09-11 02:48:54 +04:00
|
|
|
return MSG_HANDLED;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
case WIDGET_FOCUS:
|
2003-09-11 02:48:54 +04:00
|
|
|
return MSG_NOT_HANDLED;
|
2003-09-10 22:21:40 +04:00
|
|
|
|
|
|
|
case WIDGET_DESTROY:
|
|
|
|
delete_hook (&select_file_hook, info_hook);
|
2003-09-11 02:48:54 +04:00
|
|
|
return MSG_HANDLED;
|
2003-09-10 22:21:40 +04:00
|
|
|
|
|
|
|
default:
|
2003-09-11 02:48:54 +04:00
|
|
|
return default_proc (msg, parm);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-26 08:54:55 +03:00
|
|
|
struct WInfo *info_new ()
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2003-10-26 08:54:55 +03:00
|
|
|
struct WInfo *info = g_new (struct WInfo, 1);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
init_widget (&info->widget, 0, 0, 0, 0, (callback_fn)
|
2003-10-26 08:54:55 +03:00
|
|
|
info_callback, NULL);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* We do not want the cursor */
|
|
|
|
widget_want_cursor (info->widget, 0);
|
|
|
|
|
|
|
|
if (!initialized){
|
|
|
|
initialized = 1;
|
|
|
|
init_my_statfs ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|