Ticket #188: mc-show-free.patch
File mc-show-free.patch, 9.0 KB (added by andrew_b, 16 years ago) |
---|
-
src/layout.c
diff --git a/src/layout.c b/src/layout.c index 8bd8e7e..9c14474 100644
a b int message_visible = 1; 97 97 /* Set to show current working dir in xterm window title */ 98 98 int xterm_title = 1; 99 99 100 /* Set to show free space on device assigned to current directory */ 101 int free_space = 1; 102 100 103 /* The starting line for the output of the subprogram */ 101 104 int output_start_y = 0; 102 105 … … static int _command_prompt; 126 129 static int _keybar_visible; 127 130 static int _message_visible; 128 131 static int _xterm_title; 132 static int _free_space; 129 133 static int _permission_mode; 130 134 static int _filetype_mode; 131 135 … … static struct { 156 160 int *variable; 157 161 WCheck *widget; 158 162 } check_options [] = { 163 { N_("show free sp&Ace"), &free_space, 0 }, 159 164 { N_("&Xterm window title"), &xterm_title, 0 }, 160 165 { N_("h&Intbar visible"), &message_visible, 0 }, 161 166 { N_("&Keybar visible"), &keybar_visible, 0 }, … … static int b2left_cback (int action) 227 232 if (_equal_split){ 228 233 /* Turn equal split off */ 229 234 _equal_split = 0; 230 check_options [ 6].widget->state = check_options [6].widget->state & ~C_BOOL;231 dlg_select_widget (check_options [ 6].widget);235 check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL; 236 dlg_select_widget (check_options [7].widget); 232 237 dlg_select_widget (bleft_widget); 233 238 } 234 239 _first_panel_size++; … … static int b2right_cback (int action) 242 247 if (_equal_split){ 243 248 /* Turn equal split off */ 244 249 _equal_split = 0; 245 check_options [ 6].widget->state = check_options [6].widget->state & ~C_BOOL;246 dlg_select_widget (check_options [ 6].widget);250 check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL; 251 dlg_select_widget (check_options [7].widget); 247 252 dlg_select_widget (bright_widget); 248 253 } 249 254 _first_panel_size--; … … layout_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) 289 294 if (old_output_lines != _output_lines){ 290 295 old_output_lines = _output_lines; 291 296 attrset (COLOR_NORMAL); 292 dlg_move (h, 9, 16 + first_width);297 dlg_move (h, 10, 16 + first_width); 293 298 addstr (output_lines_label); 294 dlg_move (h, 9, 10 + first_width);299 dlg_move (h, 10, 10 + first_width); 295 300 tty_printf ("%02d", _output_lines); 296 301 } 297 302 } 298 303 return MSG_HANDLED; 299 304 300 305 case DLG_POST_KEY: 301 _filetype_mode = check_options [8].widget->state & C_BOOL; 302 _permission_mode = check_options [7].widget->state & C_BOOL; 303 _equal_split = check_options [6].widget->state & C_BOOL; 304 _menubar_visible = check_options [5].widget->state & C_BOOL; 305 _command_prompt = check_options [4].widget->state & C_BOOL; 306 _keybar_visible = check_options [2].widget->state & C_BOOL; 307 _message_visible = check_options [1].widget->state & C_BOOL; 308 _xterm_title = check_options [0].widget->state & C_BOOL; 306 _filetype_mode = check_options [9].widget->state & C_BOOL; 307 _permission_mode = check_options [8].widget->state & C_BOOL; 308 _equal_split = check_options [7].widget->state & C_BOOL; 309 _menubar_visible = check_options [6].widget->state & C_BOOL; 310 _command_prompt = check_options [5].widget->state & C_BOOL; 311 _keybar_visible = check_options [3].widget->state & C_BOOL; 312 _message_visible = check_options [2].widget->state & C_BOOL; 313 _xterm_title = check_options [1].widget->state & C_BOOL; 314 _free_space = check_options [0].widget->state & C_BOOL; 309 315 if (console_flag){ 310 316 int minimum; 311 317 if (_output_lines < 0) … … layout_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) 333 339 if (old_output_lines != _output_lines){ 334 340 old_output_lines = _output_lines; 335 341 attrset (COLOR_NORMAL); 336 dlg_move (h, 9, 10 + first_width);342 dlg_move (h, 10, 10 + first_width); 337 343 tty_printf ("%02d", _output_lines); 338 344 } 339 345 } … … init_layout (void) 356 362 static const char *title1, *title2, *title3; 357 363 358 364 if (!i18n_layt_flag) { 359 register int l1;365 register size_t l1; 360 366 361 367 first_width = 19; /* length of line with '<' '>' buttons */ 362 368 … … init_layout (void) 372 378 first_width = l1; 373 379 } 374 380 375 for (i = 0; i <= 8; i++) {381 for (i = 0; i <= 9; i++) { 376 382 check_options[i].text = _(check_options[i].text); 377 383 l1 = strlen (check_options[i].text) + 7; 378 384 if (l1 > first_width) … … init_layout (void) 389 395 390 396 391 397 second_width = strlen (title3) + 1; 392 for (i = 0; i < 6; i++) {398 for (i = 0; i < 7; i++) { 393 399 check_options[i].text = _(check_options[i].text); 394 400 l1 = strlen (check_options[i].text) + 7; 395 401 if (l1 > second_width) … … init_layout (void) 444 450 0)); 445 451 if (console_flag) { 446 452 add_widget (layout_dlg, 447 button_new ( 9, 12 + first_width, B_MINUS,453 button_new (10, 12 + first_width, B_MINUS, 448 454 NARROW_BUTTON, "&-", bminus_cback)); 449 455 add_widget (layout_dlg, 450 button_new ( 9, 7 + first_width, B_PLUS, NARROW_BUTTON,456 button_new (10, 7 + first_width, B_PLUS, NARROW_BUTTON, 451 457 "&+", bplus_cback)); 452 458 } 453 459 #define XTRACT(i) *check_options[i].variable, check_options[i].text 454 460 455 for (i = 0; i < 6; i++) {461 for (i = 0; i < 7; i++) { 456 462 check_options[i].widget = 457 check_new ( 8- i, 7 + first_width, XTRACT (i));463 check_new (9 - i, 7 + first_width, XTRACT (i)); 458 464 add_widget (layout_dlg, check_options[i].widget); 459 465 } 460 check_options[8].widget = check_new (10, 6, XTRACT (8)); 466 check_options[9].widget = check_new (10, 6, XTRACT (9)); 467 add_widget (layout_dlg, check_options[9].widget); 468 check_options[8].widget = check_new (9, 6, XTRACT (8)); 461 469 add_widget (layout_dlg, check_options[8].widget); 462 check_options[7].widget = check_new (9, 6, XTRACT (7));463 add_widget (layout_dlg, check_options[7].widget);464 470 465 471 _filetype_mode = filetype_mode; 466 472 _permission_mode = permission_mode; … … init_layout (void) 470 476 _keybar_visible = keybar_visible; 471 477 _message_visible = message_visible; 472 478 _xterm_title = xterm_title; 479 _free_space = free_space; 473 480 bright_widget = 474 481 button_new (6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback); 475 482 add_widget (layout_dlg, bright_widget); 476 483 bleft_widget = 477 484 button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback); 478 485 add_widget (layout_dlg, bleft_widget); 479 check_options[ 6].widget = check_new (5, 6, XTRACT (6));486 check_options[7].widget = check_new (5, 6, XTRACT (7)); 480 487 old_first_panel_size = -1; 481 488 old_horizontal_split = -1; 482 489 old_output_lines = -1; 483 490 484 491 _first_panel_size = first_panel_size; 485 492 _output_lines = output_lines; 486 add_widget (layout_dlg, check_options[ 6].widget);493 add_widget (layout_dlg, check_options[7].widget); 487 494 radio_widget = radio_new (3, 6, 2, s_split_direction); 488 495 add_widget (layout_dlg, radio_widget); 489 496 radio_widget->sel = horizontal_split; -
src/layout.h
diff --git a/src/layout.h b/src/layout.h index 6593a6f..86f4aac 100644
a b extern int keybar_visible; 39 39 extern int output_start_y; 40 40 extern int message_visible; 41 41 extern int xterm_title; 42 extern int free_space; 42 43 43 44 extern int horizontal_split; 44 45 extern int nice_rotating_dash; -
src/screen.c
diff --git a/src/screen.c b/src/screen.c index a1ae531..eb3d055 100644
a b 50 50 #include "main-widgets.h" 51 51 #include "main.h" /* the_menubar */ 52 52 #include "unixcompat.h" 53 #include "mountlist.h" /* my_statfs */ 53 54 54 55 #define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) ) 55 56 … … mini_info_separator (WPanel *panel) 765 766 } 766 767 767 768 static void 769 show_free_space (WPanel *panel) 770 { 771 /* Used to figure out how many free space we have */ 772 static struct my_statfs myfs_stats; 773 /* Old current working directory for displaying free space */ 774 static char *old_cwd = NULL; 775 776 /* Don't try to stat non-local fs */ 777 if (!vfs_file_is_local (panel->cwd) || !free_space) 778 return; 779 780 if (old_cwd == NULL || strcmp (old_cwd, panel->cwd) != 0) { 781 char rpath[PATH_MAX]; 782 783 init_my_statfs (); 784 g_free (old_cwd); 785 old_cwd = g_strdup (panel->cwd); 786 787 if (mc_realpath (panel->cwd, rpath) == NULL) 788 return; 789 790 my_statfs (&myfs_stats, rpath); 791 } 792 793 if (myfs_stats.avail > 0 || myfs_stats.total > 0) { 794 char buffer1 [6], buffer2[6], *tmp; 795 size_trunc_len (buffer1, 5, myfs_stats.avail, 1); 796 size_trunc_len (buffer2, 5, myfs_stats.total, 1); 797 tmp = g_strdup_printf (" %s/%s (%d%%) ", buffer1, buffer2, 798 myfs_stats.total > 0 ? 799 (int)(100 * (double)myfs_stats.avail / myfs_stats.total) : 0); 800 widget_move (&panel->widget, panel->widget.lines - 1, 801 panel->widget.cols - 2 - strlen(tmp)); 802 addstr (tmp); 803 g_free (tmp); 804 } 805 } 806 807 static void 768 808 show_dir (WPanel *panel) 769 809 { 770 810 char *tmp; … … show_dir (WPanel *panel) 806 846 widget_move (&panel->widget, 0, panel->widget.cols - 3); 807 847 addstr ("v"); 808 848 849 attrset (NORMAL_COLOR); 850 851 show_free_space (panel); 852 809 853 if (panel->active) 810 854 standend (); 811 855 } -
src/setup.c
diff --git a/src/setup.c b/src/setup.c index e806f10..25f6973 100644
a b static const struct { 135 135 { "show_mini_info", &show_mini_info }, 136 136 { "permission_mode", &permission_mode }, 137 137 { "filetype_mode", &filetype_mode }, 138 { "free_space", &free_space }, 138 139 { 0, 0 } 139 140 }; 140 141