* util.c (load_mc_home_file): New function. Load file from

mc_home, but try localized version of that file first.
* util.h: Declare load_mc_home_file().
* help.c (interactive_display): Use load_mc_home_file(). If the
first argument is NULL assume mc.hlp.
* dlg.c (dialog_handle_key): Use interactive_display() without
specifying the help file.
* tree.c (tree_copy): Likewise.
* cmd.c (help_cmd): Likewise.
(get_random_hint): Use load_mc_home_file().
This commit is contained in:
Pavel Roskin 2001-06-09 07:13:46 +00:00
parent 9193c81bd9
commit 58d8979490
8 changed files with 76 additions and 40 deletions

View File

@ -1,3 +1,16 @@
2001-06-09 Pavel Roskin <proski@gnu.org>
* util.c (load_mc_home_file): New function. Load file from
mc_home, but try localized version of that file first.
* util.h: Declare load_mc_home_file().
* help.c (interactive_display): Use load_mc_home_file(). If the
first argument is NULL assume mc.hlp.
* dlg.c (dialog_handle_key): Use interactive_display() without
specifying the help file.
* tree.c (tree_copy): Likewise.
* cmd.c (help_cmd): Likewise.
(get_random_hint): Use load_mc_home_file().
2001-06-07 Andrew V. Samoilov <sav@bcs.zp.ua>
* charsets.h: Define CHARSETS_INDEX without leading LIBDIR.

View File

@ -1201,9 +1201,7 @@ void other_symlink_cmd (void)
void help_cmd (void)
{
char *hlpfile = concat_dir_and_file (mc_home, _("mc.hlp"));
interactive_display (hlpfile, "[main]");
g_free (hlpfile);
interactive_display (NULL, "[main]");
}
void view_panel_cmd (void)
@ -1269,8 +1267,6 @@ char *guess_message_value (unsigned want_info)
char *get_random_hint (void)
{
char *data, *result, *eol;
char *hintfile_base, *hintfile;
char *lang;
int len;
int start;
@ -1294,24 +1290,7 @@ char *get_random_hint (void)
last_sec = tv.tv_sec;
#endif
hintfile_base = concat_dir_and_file (mc_home, MC_HINT);
lang = guess_message_value (0);
hintfile = g_strdup_printf ("%s.%s", hintfile_base, lang);
data = load_file (hintfile);
g_free (hintfile);
if (!data) {
hintfile = g_strdup_printf ("%s.%.2s", hintfile_base, lang);
data = load_file (hintfile);
g_free (hintfile);
if (!data)
data = load_file (hintfile_base);
}
g_free (lang);
g_free (hintfile_base);
data = load_mc_home_file (MC_HINT, NULL);
if (!data)
return 0;

View File

@ -630,8 +630,6 @@ void dlg_stop (Dlg_head *h)
static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
{
char *hlpfile;
switch (d_key){
case KEY_LEFT:
case KEY_UP:
@ -644,9 +642,7 @@ static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
break;
case KEY_F(1):
hlpfile = concat_dir_and_file (mc_home, _("mc.hlp"));
interactive_display (hlpfile, h->help_ctx);
g_free (hlpfile);
interactive_display (NULL, h->help_ctx);
do_refresh ();
break;

View File

@ -757,12 +757,24 @@ interactive_display (char *filename, char *node)
{
WButtonBar *help_bar;
Widget *md;
char *hlpfile = filename;
if ((data = load_file (filename)) == 0){
if (filename)
data = load_file (filename);
else
data = load_mc_home_file ("mc.hlp", &hlpfile);
if (data == NULL){
message (1, MSG_ERROR, _(" Can't open file %s \n %s "),
filename, unix_error_string (errno));
return;
hlpfile, unix_error_string (errno));
}
if (!filename)
g_free (hlpfile);
if (!data)
return;
if (!(main_node = search_string (data, node))){
message (1, MSG_ERROR, _(" Can't find node %s in help file "), node);
interactive_display_finish ();

View File

@ -651,9 +651,7 @@ void tree_copy (WTree *tree, char *default_dest)
static void tree_help_cmd (void)
{
char *hlpfile = concat_dir_and_file (mc_home, _("mc.hlp"));
interactive_display (hlpfile, "[Directory Tree]");
g_free (hlpfile);
interactive_display (NULL, "[Directory Tree]");
}
static int tree_copy_cmd (WTree *tree)

View File

@ -74,6 +74,8 @@
#include "global.h"
#include "profile.h"
#include "user.h" /* expand_format */
#include "main.h" /* mc_home */
#include "cmd.h" /* guess_message_value */
#include "../vfs/vfs.h"
#ifdef HAVE_CHARSET
@ -607,6 +609,43 @@ char *load_file (char *filename)
}
}
char *load_mc_home_file (const char *filename, char ** allocated_filename)
{
char *hintfile_base, *hintfile;
char *lang;
char *data;
hintfile_base = concat_dir_and_file (mc_home, filename);
lang = guess_message_value (0);
hintfile = g_strdup_printf ("%s.%s", hintfile_base, lang);
data = load_file (hintfile);
if (!data) {
g_free (hintfile);
hintfile = g_strdup_printf ("%s.%.2s", hintfile_base, lang);
data = load_file (hintfile);
if (!data) {
g_free (hintfile);
hintfile = hintfile_base;
data = load_file (hintfile_base);
}
}
g_free (lang);
if (hintfile != hintfile_base)
g_free (hintfile_base);
if (allocated_filename)
*allocated_filename = hintfile;
else
g_free (hintfile);
return data;
}
/* Check strftime() results. Some systems (i.e. Solaris) have different
short-month-name sizes for different locales */
size_t i18n_checktimelength (void)

View File

@ -46,6 +46,7 @@ int set_int (char *, char *, int);
int get_int (char *, char *, int);
char *load_file (char *filename);
char *load_mc_home_file (const char *filename, char ** allocated_filename);
#include "fs.h"
#ifndef S_ISLNK

View File

@ -1825,9 +1825,7 @@ static void do_normal_search (void *xview, char *text)
/* Real view only */
static void help_cmd (void)
{
char *hlpfile = concat_dir_and_file (mc_home, _("mc.hlp"));
interactive_display (hlpfile, "[Internal File Viewer]");
g_free (hlpfile);
interactive_display (NULL, "[Internal File Viewer]");
/*
view_refresh (0);
*/