Charset problem in Terminal
edscott wilson garcia
edscott at xfce.org
Wed Jan 5 15:24:50 CET 2005
El mar, 04-01-2005 a las 17:21 +0000, James Tappin escribió:
>
> I do find it puzzling that the problem only affects terminals launched
> from xffm, but not those launched from the panel, the command line or Rox.
> Unfortunately I've not been able to locate the code in xffm that actually
> does the launch to try and see if there is some subtle difference from
> other ways of launching the terminal.
>
> James
Everything launched by xffm (double click, toolbars, menus) is done by
(libs/run.c):
\begin{code}
G_MODULE_EXPORT
int
runvwd( const gchar *workdir,
char *argv[])
{
int i;
GError *error=NULL;
if (!argv || !argv[0]) {
g_warning("!argv || !argv[0]");
return FALSE;
}
if (!workdir || !g_file_test(workdir,G_FILE_TEST_IS_DIR)) {
workdir=get_selected_chdir();
if (!g_file_test(workdir,G_FILE_TEST_IS_DIR)) workdir=GETWD;
}
if (strcmp(workdir,GETWD)!=0) {
print_diagnostics(NULL,"$chdir ",workdir,"\n$",argv[0],NULL);
xffm_setenv("PWD",(gchar *)workdir,FALSE);
#ifdef DEBUG
printf("DBG: getenv(PWD)=%s\n",getenv("PWD"));
#endif
}
else {
print_diagnostics(NULL,"$",argv[0],NULL);
}
for (i=1;argv[i];i++) print_diagnostics(NULL," ",argv[i],NULL);
print_diagnostics(NULL,"\n",NULL);
print_status("xfce/info",_("Executing")," ",argv[0],NULL);
if (strcmp(argv[0],"sudo")==0) print_status("xfce/sudo",
_("Executing"), " sudo ", argv[1], NULL);
else print_status("xfce/info", _("Executing"), " ", argv[0], NULL);
if (!
g_spawn_async(workdir,argv,NULL,G_SPAWN_SEARCH_PATH,NULL,NULL,NULL,&error)){
gchar *msg = g_strcompress (error->message);
print_diagnostics("xfce/error",msg,":\n",argv[0] ,"\n",NULL);
g_error_free (error);
g_free (msg);
chdir (GETWD);
xffm_setenv("PWD",(gchar *)GETWD,FALSE);
return FALSE;
}
if (strcmp(workdir,GETWD)!=0) print_diagnostics(NULL,"$chdir
",GETWD,"\n",NULL);
xffm_setenv("PWD",(gchar *)GETWD,FALSE);
chdir(GETWD);
return TRUE;
}
\end{code}
For the terminal, the argv argument is constructed by
g_shell_parse_argv (what_term(), &argc,&argv,&error);
from (libs/terminal.c):
\begin{code}
const gchar *what_term(void){
static gchar *term=NULL;
if (term){
g_free(term);
term=NULL;
}
term=NULL;
if (getenv("TERMCMD") && strlen( getenv("TERMCMD"))){
if (MIME_is_valid_command(getenv("TERMCMD"))){
term = g_strdup(getenv("TERMCMD"));
} else {
print_diagnostics("xfce/warning",
getenv("TERMCMD"),": ",strerror(errno),"\n",NULL);
}
}
if (!term) {
term=g_find_program_in_path("xfce4-terminal");
if (!term) term=g_strdup("xterm");
}
if ((strncmp(term,"xterm",strlen("xterm"))==0 ||
strstr(term,"xfce4-terminal"))
&& getenv("XFFM_HOLD_XTERM") &&
strlen( getenv("XFFM_HOLD_XTERM"))){
gchar *p=term;
term=g_strconcat(p," -hold",NULL);
g_free(p);
}
return (const gchar *)term;
}
\end{code}
So basically, what it does is:
1- Check for TERMCMD environment variable. If set, verifies that it is a
valid command. This environment variable comes from the
xfce-mcs-manager.
2- If no valid TERMCMD is set, then a check is made for xfce4-terminal
and if that is not found then xterm is used.
3- Since both xfce4-terminal and xterm support the -hold option, then
the environment variables are checked for this and the command line set
accordingly.
4- The argv parameter is obtained from the constructed command line by
glib function.
5- The environment variable PWD is set to the working directory
(xfce4-terminal needs this).
6- The command is executed by the glib function g_spawn_async().
I suggest you first enable "verbose diagnostics". That way you will get
the complete list of argv printed out to the diagnostics window. If the
problem is not apparent from there, try to comment out the environment
variable stuff replace the what_term() function with:
const gchar* what_term(void){return "Terminal";}
HTH
regards,
Edscott
--
edscott wilson garcia <edscott at xfce.org>
More information about the Xfce4-dev
mailing list