diff --git a/src/info.c b/src/info.c index f7f55cf61..f6e875c26 100644 --- a/src/info.c +++ b/src/info.c @@ -23,14 +23,14 @@ #include <config.h> #include <stdio.h> +#include <sys/stat.h> #include "lib/global.h" - +#include "lib/unixcompat.h" #include "lib/tty/tty.h" #include "lib/tty/key.h" /* is_idle() */ #include "lib/tty/mouse.h" /* Gpm_Event */ #include "lib/skin.h" -#include "lib/unixcompat.h" #include "lib/strutil.h" #include "dialog.h" @@ -53,17 +53,28 @@ struct WInfo int ready; }; -/* Have we called the init_my_statfs routine? */ -static gboolean initialized = FALSE; static struct my_statfs myfs_stats; static void -info_box (Dlg_head * h, struct WInfo *info) +info_box (struct WInfo *info) { + const char *title = _("Information"); + const int len = str_term_width1 (title); + tty_set_normal_attrs (); tty_setcolor (NORMAL_COLOR); widget_erase (&info->widget); - draw_box (h, info->widget.y, info->widget.x, info->widget.lines, info->widget.cols, FALSE); + draw_box (info->widget.parent, info->widget.y, info->widget.x, + info->widget.lines, info->widget.cols, FALSE); + + widget_move (&info->widget, 0, (info->widget.cols - len - 2)/2); + tty_printf (" %s ", title); + + widget_move (&info->widget, 2, 0); + tty_print_alt_char (ACS_LTEE, FALSE); + widget_move (&info->widget, 2, info->widget.cols - 1); + tty_print_alt_char (ACS_RTEE, FALSE); + tty_draw_hline (info->widget.y + 2, info->widget.x + 1, ACS_HLINE, info->widget.cols - 2); } static void @@ -77,18 +88,18 @@ info_show_info (struct WInfo *info) if (!is_idle ()) return; - info_box (info->widget.parent, info); + info_box (info); + tty_setcolor (MARKED_COLOR); widget_move (&info->widget, 1, 3); tty_printf (_("Midnight Commander %s"), VERSION); - tty_setcolor (NORMAL_COLOR); - tty_draw_hline (info->widget.y + 2, info->widget.x + 1, ACS_HLINE, info->widget.cols - 2); - if (get_current_type () != view_listing) - return; if (!info->ready) return; + if (get_current_type () != view_listing) + return; + my_statfs (&myfs_stats, current_panel->cwd); st = current_panel->dir.list[current_panel->selected].st; @@ -101,6 +112,8 @@ info_show_info (struct WInfo *info) i18n_adjust = str_term_width1 (file_label) + 2; } + tty_setcolor (NORMAL_COLOR); + buff = g_string_new (""); switch (info->widget.lines - 2) @@ -112,10 +125,11 @@ info_show_info (struct WInfo *info) case 16: widget_move (&info->widget, 16, 3); if (myfs_stats.nfree > 0 || myfs_stats.nodes > 0) - tty_printf (_("Free nodes: %d (%d%%) of %d"), - myfs_stats.nfree, - myfs_stats.total - ? 100 * myfs_stats.nfree / myfs_stats.nodes : 0, myfs_stats.nodes); + tty_printf (_("Free nodes: %ld (%ld%%) of %ld"), + (size_t) myfs_stats.nfree, + myfs_stats.total != 0 + ? 100 * (size_t) myfs_stats.nfree / (size_t) myfs_stats.nodes : 0, + (size_t) myfs_stats.nodes); else tty_print_string (_("No node information")); @@ -248,13 +262,13 @@ info_callback (Widget * w, widget_msg_t msg, int parm) { case WIDGET_INIT: + init_my_statfs (); add_hook (&select_file_hook, info_hook, info); info->ready = 0; return MSG_HANDLED; case WIDGET_DRAW: info_hook (info); - info_show_info (info); return MSG_HANDLED; case WIDGET_FOCUS: @@ -262,6 +276,7 @@ info_callback (Widget * w, widget_msg_t msg, int parm) case WIDGET_DESTROY: delete_hook (&select_file_hook, info_hook); + free_my_statfs (); return MSG_HANDLED; default: @@ -294,11 +309,5 @@ info_new (int y, int x, int lines, int cols) /* We do not want the cursor */ widget_want_cursor (info->widget, 0); - if (!initialized) - { - initialized = TRUE; - init_my_statfs (); - } - return info; } diff --git a/src/layout.c b/src/layout.c index 459c4d305..b6e19cd23 100644 --- a/src/layout.c +++ b/src/layout.c @@ -1004,6 +1004,8 @@ set_display_type (int num, panel_view_mode_t type) if ((type != view_listing) && (current_panel == (WPanel *) old_widget)) current_panel = num == 0 ? right_panel : left_panel; + + g_free (old_widget); } /* This routine is deeply sticked to the two panels idea.