forked from enlightenment/enlightenment
make enlightenment_open use the same terminals config as e and sync
the code. SVN revision: 75301
This commit is contained in:
parent
6efc2eb976
commit
1edee7df77
115
src/bin/e_open.c
115
src/bin/e_open.c
|
@ -262,55 +262,94 @@ single_command_open(const char *command, const char * const *argv, int argc)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Efreet_Desktop *
|
||||||
|
_terminal_get(const char *defaults_list)
|
||||||
|
{
|
||||||
|
Efreet_Desktop *tdesktop = NULL;
|
||||||
|
Efreet_Ini *ini;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
ini = efreet_ini_new(defaults_list);
|
||||||
|
if ((ini) && (ini->data) &&
|
||||||
|
(efreet_ini_section_set(ini, "Default Applications")) &&
|
||||||
|
(ini->section))
|
||||||
|
{
|
||||||
|
s = efreet_ini_string_get(ini, "x-scheme-handler/terminal");
|
||||||
|
if (s) tdesktop = efreet_util_desktop_file_id_find(s);
|
||||||
|
}
|
||||||
|
if (ini) efreet_ini_free(ini);
|
||||||
|
return tdesktop;
|
||||||
|
}
|
||||||
|
|
||||||
static char **
|
static char **
|
||||||
terminal_open(void)
|
terminal_open(void)
|
||||||
{
|
{
|
||||||
const char *generic_names[] = {
|
const char *terms[] =
|
||||||
"[Tt]erminal",
|
{
|
||||||
"[Tt]erminal [Ee]mulator",
|
"terminology.desktop",
|
||||||
"[Tt]erminal *",
|
"xterm.desktop",
|
||||||
|
"rxvt.desktop",
|
||||||
|
"gnome-terimnal.desktop",
|
||||||
|
"konsole.desktop",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
const char **itr;
|
const char *s;
|
||||||
Eina_List *cmds = NULL;
|
char buf[PATH_MAX], **ret;
|
||||||
char **ret;
|
Efreet_Desktop *tdesktop = NULL, *td;
|
||||||
Efreet_Desktop *desktop = NULL;
|
Eina_List *l;
|
||||||
|
int i;
|
||||||
|
|
||||||
for (itr = generic_names; (desktop == NULL) && (*itr != NULL); itr++)
|
s = efreet_data_home_get();
|
||||||
desktop = desktop_first_free_others
|
if (s)
|
||||||
(efreet_util_desktop_generic_name_glob_list(*itr));
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "%s/applications/defaults.list", s);
|
||||||
|
tdesktop = _terminal_get(buf);
|
||||||
|
}
|
||||||
|
if (tdesktop) goto have_desktop;
|
||||||
|
EINA_LIST_FOREACH(efreet_data_dirs_get(), l, s)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "%s/applications/defaults.list", s);
|
||||||
|
tdesktop = _terminal_get(buf);
|
||||||
|
if (tdesktop) goto have_desktop;
|
||||||
|
}
|
||||||
|
|
||||||
if (!desktop)
|
for (i = 0; terms[i]; i++)
|
||||||
desktop = desktop_first_free_others(efreet_util_desktop_category_list
|
{
|
||||||
("TerminalEmulator"));
|
tdesktop = efreet_util_desktop_file_id_find(terms[i]);
|
||||||
|
if (tdesktop) goto have_desktop;
|
||||||
if (!desktop)
|
}
|
||||||
|
if (!tdesktop)
|
||||||
|
{
|
||||||
|
l = efreet_util_desktop_category_list("TerminalEmulator");
|
||||||
|
if (l)
|
||||||
|
{
|
||||||
|
// just take first one since above list doesn't work.
|
||||||
|
tdesktop = l->data;
|
||||||
|
EINA_LIST_FREE(l, td)
|
||||||
|
{
|
||||||
|
// free/unref the desktosp we are not going to use
|
||||||
|
if (td != tdesktop) efreet_desktop_free(td);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!tdesktop) return NULL;
|
||||||
|
have_desktop:
|
||||||
|
if (!tdesktop->exec)
|
||||||
|
{
|
||||||
|
efreet_desktop_free(tdesktop);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
efreet_desktop_command_get(desktop, NULL, get_command, &cmds);
|
|
||||||
if (!cmds) ret = NULL;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *c;
|
|
||||||
|
|
||||||
ret = calloc(eina_list_count(cmds) + 1, sizeof(char *));
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
unsigned int i = 0;
|
|
||||||
EINA_LIST_FREE(cmds, c)
|
|
||||||
{
|
|
||||||
ret[i] = c; /* was strdup by efreet_desktop_command_get() */
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
ret[i] = NULL;
|
ret = malloc(sizeof(char *) * 2);
|
||||||
}
|
if (!ret) return NULL;
|
||||||
else
|
ret[0] = strdup(tdesktop->exec);
|
||||||
|
ret[1] = NULL;
|
||||||
|
if (!ret[0])
|
||||||
{
|
{
|
||||||
EINA_LIST_FREE(cmds, c)
|
free(ret);
|
||||||
free(c);
|
efreet_desktop_free(tdesktop);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
efreet_desktop_free(tdesktop);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1489,9 +1489,12 @@ e_util_terminal_desktop_get(void)
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s/applications/defaults.list",
|
s = efreet_data_home_get();
|
||||||
efreet_data_home_get());
|
if (s)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "%s/applications/defaults.list", s);
|
||||||
tdesktop = _e_util_default_terminal_get(buf);
|
tdesktop = _e_util_default_terminal_get(buf);
|
||||||
|
}
|
||||||
if (tdesktop) return tdesktop;
|
if (tdesktop) return tdesktop;
|
||||||
EINA_LIST_FOREACH(efreet_data_dirs_get(), l, s)
|
EINA_LIST_FOREACH(efreet_data_dirs_get(), l, s)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue