2018-09-29 09:06:41 -07:00
|
|
|
#include "private.h"
|
|
|
|
|
2014-07-12 07:15:39 -07:00
|
|
|
#ifdef HAVE_PO
|
|
|
|
#include <locale.h>
|
|
|
|
#endif
|
2012-06-17 09:03:46 -07:00
|
|
|
|
|
|
|
#include <Ecore_Getopt.h>
|
2012-06-12 03:10:01 -07:00
|
|
|
#include <Elementary.h>
|
2012-06-13 08:10:18 -07:00
|
|
|
#include "main.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
#include "win.h"
|
|
|
|
#include "termio.h"
|
2013-01-28 16:43:13 -08:00
|
|
|
#include "termpty.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
#include "config.h"
|
2012-06-23 23:39:54 -07:00
|
|
|
#include "controls.h"
|
2012-06-16 21:10:17 -07:00
|
|
|
#include "media.h"
|
2012-06-19 08:59:49 -07:00
|
|
|
#include "utils.h"
|
2012-12-27 03:20:32 -08:00
|
|
|
#include "ipc.h"
|
2013-03-19 03:49:47 -07:00
|
|
|
#include "sel.h"
|
2014-10-26 13:00:14 -07:00
|
|
|
#include "miniview.h"
|
|
|
|
#include "gravatar.h"
|
|
|
|
#include "keyin.h"
|
2013-09-06 11:42:17 -07:00
|
|
|
|
2015-09-26 03:01:42 -07:00
|
|
|
int terminology_starting_up;
|
2014-10-26 13:00:14 -07:00
|
|
|
int _log_domain = -1;
|
2018-08-15 10:40:06 -07:00
|
|
|
Eina_Bool multisense_available = EINA_TRUE;
|
2013-09-06 11:42:17 -07:00
|
|
|
|
2014-10-26 13:00:14 -07:00
|
|
|
static Config *_main_config = NULL;
|
2013-09-06 11:42:17 -07:00
|
|
|
|
2019-10-19 01:57:57 -07:00
|
|
|
static void
|
|
|
|
_set_instance_theme(Ipc_Instance *inst)
|
|
|
|
{
|
|
|
|
char path[PATH_MAX];
|
|
|
|
char theme_name[PATH_MAX];
|
|
|
|
const char *theme_path = (const char *)&path;
|
|
|
|
|
|
|
|
if (!inst->theme)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (eina_str_has_suffix(inst->theme, ".edj"))
|
|
|
|
eina_strlcpy(theme_name, inst->theme, sizeof(theme_name));
|
|
|
|
else
|
|
|
|
snprintf(theme_name, sizeof(theme_name), "%s.edj", inst->theme);
|
|
|
|
|
|
|
|
if (strchr(theme_name, '/'))
|
|
|
|
eina_strlcpy(path, theme_name, sizeof(path));
|
|
|
|
else
|
|
|
|
theme_path = theme_path_get(theme_name);
|
|
|
|
|
|
|
|
eina_stringshare_replace(&(inst->config->theme), theme_path);
|
|
|
|
inst->config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2019-10-20 09:16:10 -07:00
|
|
|
static void
|
|
|
|
_configure_instance(Ipc_Instance *inst)
|
|
|
|
{
|
|
|
|
Config *config = inst->config;
|
|
|
|
|
|
|
|
_set_instance_theme(inst);
|
|
|
|
|
|
|
|
if (inst->background)
|
|
|
|
{
|
|
|
|
eina_stringshare_replace(&(config->background), inst->background);
|
|
|
|
config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inst->font)
|
|
|
|
{
|
|
|
|
char *p = strchr(inst->font, '/');
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
int sz;
|
|
|
|
char *fname = alloca(p - inst->font + 1);
|
|
|
|
|
|
|
|
strncpy(fname, inst->font, p - inst->font);
|
|
|
|
fname[p - inst->font] = '\0';
|
|
|
|
sz = atoi(p+1);
|
|
|
|
if (sz > 0)
|
|
|
|
inst->config->font.size = sz;
|
|
|
|
eina_stringshare_replace(&(inst->config->font.name), fname);
|
|
|
|
inst->config->font.bitmap = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char buf[4096], *file;
|
|
|
|
Eina_List *files;
|
|
|
|
int n = strlen(inst->font);
|
|
|
|
Eina_Bool found = EINA_FALSE;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get());
|
|
|
|
files = ecore_file_ls(buf);
|
|
|
|
EINA_LIST_FREE(files, file)
|
|
|
|
{
|
|
|
|
if (n > 0)
|
|
|
|
{
|
|
|
|
if (!strncasecmp(file, inst->font, n))
|
|
|
|
{
|
|
|
|
n = -1;
|
|
|
|
eina_stringshare_replace(&(inst->config->font.name), file);
|
|
|
|
inst->config->font.bitmap = EINA_TRUE;
|
|
|
|
found = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(file);
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
ERR("font '%s' not found in %s", inst->font, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
config->font_set = EINA_TRUE;
|
|
|
|
config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-14 03:57:59 -08:00
|
|
|
if (inst->login_shell != 0xff)
|
2019-10-20 09:16:10 -07:00
|
|
|
{
|
|
|
|
inst->config->login_shell = inst->login_shell;
|
|
|
|
inst->config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
inst->login_shell = inst->config->login_shell;
|
|
|
|
|
|
|
|
if (inst->xterm_256color)
|
|
|
|
{
|
|
|
|
inst->config->xterm_256color = EINA_TRUE;
|
|
|
|
inst->config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (inst->video_mute != 0xff)
|
|
|
|
{
|
|
|
|
config->mute = inst->video_mute;
|
|
|
|
config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (inst->cursor_blink != 0xff)
|
|
|
|
{
|
|
|
|
config->disable_cursor_blink = !inst->cursor_blink;
|
|
|
|
config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (inst->visual_bell != 0xff)
|
|
|
|
{
|
|
|
|
config->disable_visual_bell = !inst->visual_bell;
|
|
|
|
config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (inst->active_links != 0xff)
|
|
|
|
{
|
|
|
|
config->active_links = !!inst->active_links;
|
|
|
|
config->active_links_email = inst->config->active_links;
|
|
|
|
config->active_links_file = inst->config->active_links;
|
|
|
|
config->active_links_url = inst->config->active_links;
|
|
|
|
config->active_links_escape = inst->config->active_links;
|
|
|
|
config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-15 10:40:06 -07:00
|
|
|
static void
|
|
|
|
_check_multisense(void)
|
|
|
|
{
|
|
|
|
int enabled;
|
|
|
|
Eina_Bool setting = edje_audio_channel_mute_get(EDJE_CHANNEL_EFFECT);
|
|
|
|
|
|
|
|
/* older versions of efl have no capability for determining whether multisense support
|
|
|
|
* is available
|
|
|
|
* to check, attempt to set mute on a channel and check the value: if the value has not been
|
|
|
|
* set then the multisense codepath is disabled
|
|
|
|
*
|
|
|
|
* this is a no-op in either case, as the function only sets an internal variable and returns
|
|
|
|
*/
|
|
|
|
for (enabled = 0; enabled < 2; enabled++)
|
|
|
|
{
|
|
|
|
edje_audio_channel_mute_set(EDJE_CHANNEL_EFFECT, enabled);
|
|
|
|
if (enabled != edje_audio_channel_mute_get(EDJE_CHANNEL_EFFECT))
|
|
|
|
multisense_available = EINA_FALSE;
|
|
|
|
}
|
|
|
|
edje_audio_channel_mute_set(EDJE_CHANNEL_EFFECT, setting);
|
|
|
|
}
|
|
|
|
|
2014-10-26 13:00:14 -07:00
|
|
|
Config *
|
|
|
|
main_config_get(void)
|
2014-05-01 15:08:58 -07:00
|
|
|
{
|
2014-10-26 13:00:14 -07:00
|
|
|
return _main_config;
|
2014-05-01 15:08:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-27 03:20:32 -08:00
|
|
|
static void
|
|
|
|
main_ipc_new(Ipc_Instance *inst)
|
|
|
|
{
|
|
|
|
Win *wn;
|
|
|
|
Term *term;
|
2014-10-26 13:00:14 -07:00
|
|
|
Config *config;
|
2013-01-02 23:50:54 -08:00
|
|
|
int pargc = 0, nargc, i;
|
|
|
|
char **pargv = NULL, **nargv = NULL, geom[256];
|
2014-10-26 13:00:14 -07:00
|
|
|
Evas_Object *win;
|
2012-12-27 03:20:32 -08:00
|
|
|
|
|
|
|
if (inst->startup_id)
|
|
|
|
{
|
|
|
|
char buf[4096];
|
2014-06-09 09:59:17 -07:00
|
|
|
|
2012-12-27 03:20:32 -08:00
|
|
|
snprintf(buf, sizeof(buf), "DESKTOP_STARTUP_ID=%s", inst->startup_id);
|
2019-10-14 14:08:19 -07:00
|
|
|
putenv(strdup(buf));
|
2012-12-27 03:20:32 -08:00
|
|
|
}
|
2013-01-02 23:50:54 -08:00
|
|
|
ecore_app_args_get(&pargc, &pargv);
|
|
|
|
nargc = 1;
|
|
|
|
|
|
|
|
if (inst->cd) nargc += 2;
|
|
|
|
if (inst->background) nargc += 2;
|
|
|
|
if (inst->name) nargc += 2;
|
|
|
|
if (inst->role) nargc += 2;
|
|
|
|
if (inst->title) nargc += 2;
|
|
|
|
if (inst->font) nargc += 2;
|
2014-08-09 02:46:47 -07:00
|
|
|
if (inst->startup_split) nargc += 2;
|
2013-01-02 23:50:54 -08:00
|
|
|
if ((inst->pos) || (inst->w > 0) || (inst->h > 0)) nargc += 2;
|
|
|
|
if (inst->login_shell) nargc += 1;
|
|
|
|
if (inst->fullscreen) nargc += 1;
|
|
|
|
if (inst->iconic) nargc += 1;
|
|
|
|
if (inst->borderless) nargc += 1;
|
|
|
|
if (inst->override) nargc += 1;
|
|
|
|
if (inst->maximized) nargc += 1;
|
|
|
|
if (inst->hold) nargc += 1;
|
|
|
|
if (inst->nowm) nargc += 1;
|
2013-06-16 14:07:58 -07:00
|
|
|
if (inst->xterm_256color) nargc += 1;
|
2014-04-11 12:29:26 -07:00
|
|
|
if (inst->active_links) nargc += 1;
|
2019-10-20 09:16:10 -07:00
|
|
|
if (inst->video_mute) nargc += 1;
|
|
|
|
if (inst->cursor_blink) nargc += 1;
|
|
|
|
if (inst->visual_bell) nargc += 1;
|
2013-01-02 23:50:54 -08:00
|
|
|
if (inst->cmd) nargc += 2;
|
2019-10-19 01:57:57 -07:00
|
|
|
if (inst->theme) nargc += 2;
|
2019-09-08 10:28:52 -07:00
|
|
|
|
2013-01-02 23:50:54 -08:00
|
|
|
nargv = calloc(nargc + 1, sizeof(char *));
|
|
|
|
if (!nargv) return;
|
2019-09-08 10:28:52 -07:00
|
|
|
|
2013-01-02 23:50:54 -08:00
|
|
|
i = 0;
|
|
|
|
nargv[i++] = pargv[0];
|
|
|
|
if (inst->cd)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-d";
|
|
|
|
nargv[i++] = (char *)inst->cd;
|
|
|
|
}
|
|
|
|
if (inst->background)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-b";
|
|
|
|
nargv[i++] = (char *)inst->background;
|
|
|
|
}
|
|
|
|
if (inst->name)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-n";
|
|
|
|
nargv[i++] = (char *)inst->name;
|
|
|
|
}
|
2019-10-19 01:57:57 -07:00
|
|
|
if (inst->theme)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-t";
|
|
|
|
nargv[i++] = (char *)inst->theme;
|
|
|
|
}
|
2013-01-02 23:50:54 -08:00
|
|
|
if (inst->role)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-r";
|
|
|
|
nargv[i++] = (char *)inst->role;
|
|
|
|
}
|
|
|
|
if (inst->title)
|
|
|
|
{
|
2017-08-26 10:27:39 -07:00
|
|
|
nargv[i++] = "-T";
|
2013-01-02 23:50:54 -08:00
|
|
|
nargv[i++] = (char *)inst->title;
|
|
|
|
}
|
|
|
|
if (inst->font)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-f";
|
|
|
|
nargv[i++] = (char *)inst->font;
|
|
|
|
}
|
2014-08-09 02:46:47 -07:00
|
|
|
if (inst->startup_split)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-S";
|
|
|
|
nargv[i++] = (char *)inst->startup_split;
|
|
|
|
}
|
2013-01-02 23:50:54 -08:00
|
|
|
if ((inst->pos) || (inst->w > 0) || (inst->h > 0))
|
|
|
|
{
|
|
|
|
if (!inst->pos)
|
|
|
|
snprintf(geom, sizeof(geom), "%ix%i", inst->w, inst->h);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((inst->w > 0) && (inst->h > 0))
|
|
|
|
{
|
|
|
|
if (inst->x >= 0)
|
|
|
|
{
|
|
|
|
if (inst->y >= 0)
|
|
|
|
snprintf(geom, sizeof(geom), "%ix%i+%i+%i",
|
|
|
|
inst->w, inst->h, inst->x, inst->y);
|
|
|
|
else
|
|
|
|
snprintf(geom, sizeof(geom), "%ix%i+%i%i",
|
|
|
|
inst->w, inst->h, inst->x, inst->y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (inst->y >= 0)
|
|
|
|
snprintf(geom, sizeof(geom), "%ix%i%i+%i",
|
|
|
|
inst->w, inst->h, inst->x, inst->y);
|
|
|
|
else
|
|
|
|
snprintf(geom, sizeof(geom), "%ix%i%i%i",
|
|
|
|
inst->w, inst->h, inst->x, inst->y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (inst->x >= 0)
|
|
|
|
{
|
|
|
|
if (inst->y >= 0)
|
|
|
|
snprintf(geom, sizeof(geom), "+%i+%i",
|
|
|
|
inst->x, inst->y);
|
|
|
|
else
|
|
|
|
snprintf(geom, sizeof(geom), "+%i%i",
|
|
|
|
inst->x, inst->y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (inst->y >= 0)
|
|
|
|
snprintf(geom, sizeof(geom), "%i+%i",
|
|
|
|
inst->x, inst->y);
|
|
|
|
else
|
|
|
|
snprintf(geom, sizeof(geom), "%i%i",
|
|
|
|
inst->x, inst->y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nargv[i++] = "-g";
|
|
|
|
nargv[i++] = geom;
|
|
|
|
}
|
|
|
|
if (inst->login_shell)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-l";
|
|
|
|
}
|
|
|
|
if (inst->fullscreen)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-F";
|
|
|
|
}
|
|
|
|
if (inst->iconic)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-I";
|
|
|
|
}
|
|
|
|
if (inst->borderless)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-B";
|
|
|
|
}
|
|
|
|
if (inst->override)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-O";
|
|
|
|
}
|
|
|
|
if (inst->maximized)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-M";
|
|
|
|
}
|
|
|
|
if (inst->hold)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-H";
|
|
|
|
}
|
|
|
|
if (inst->nowm)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-W";
|
|
|
|
}
|
2013-06-16 14:07:58 -07:00
|
|
|
if (inst->xterm_256color)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-2";
|
|
|
|
}
|
2014-04-11 12:29:26 -07:00
|
|
|
if (inst->active_links)
|
|
|
|
{
|
|
|
|
nargv[i++] = "--active-links";
|
|
|
|
}
|
2013-01-02 23:50:54 -08:00
|
|
|
if (inst->cmd)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-e";
|
|
|
|
nargv[i++] = (char *)inst->cmd;
|
|
|
|
}
|
2019-10-20 09:16:10 -07:00
|
|
|
if (inst->video_mute)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-m";
|
|
|
|
}
|
|
|
|
if (inst->cursor_blink)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-c";
|
|
|
|
}
|
|
|
|
if (inst->visual_bell)
|
|
|
|
{
|
|
|
|
nargv[i++] = "-G";
|
|
|
|
}
|
|
|
|
|
2014-06-22 08:38:26 -07:00
|
|
|
|
2013-01-02 23:50:54 -08:00
|
|
|
ecore_app_args_set(nargc, (const char **)nargv);
|
2014-10-26 13:00:14 -07:00
|
|
|
wn = win_new(inst->name, inst->role, inst->title, inst->icon_name,
|
|
|
|
_main_config, inst->fullscreen, inst->iconic,
|
|
|
|
inst->borderless, inst->override, inst->maximized);
|
2014-02-02 03:28:29 -08:00
|
|
|
if (!wn)
|
|
|
|
{
|
2015-02-23 13:51:33 -08:00
|
|
|
CRITICAL(_("Could not create window."));
|
2014-02-02 03:28:29 -08:00
|
|
|
ecore_app_args_set(pargc, (const char **)pargv);
|
|
|
|
free(nargv);
|
|
|
|
return;
|
|
|
|
}
|
2014-06-22 08:38:26 -07:00
|
|
|
|
2014-10-26 13:00:14 -07:00
|
|
|
win = win_evas_object_get(wn);
|
|
|
|
config = win_config_get(wn);
|
2019-10-19 01:57:57 -07:00
|
|
|
inst->config = config;
|
|
|
|
|
2019-10-20 09:16:10 -07:00
|
|
|
_configure_instance(inst);
|
2013-01-02 23:50:54 -08:00
|
|
|
|
|
|
|
if (inst->w <= 0) inst->w = 80;
|
|
|
|
if (inst->h <= 0) inst->h = 24;
|
2014-10-26 13:00:14 -07:00
|
|
|
term = term_new(wn, config, inst->cmd, inst->login_shell,
|
2017-08-28 12:36:48 -07:00
|
|
|
inst->cd, inst->w, inst->h, inst->hold,
|
|
|
|
inst->title);
|
2012-12-27 03:20:32 -08:00
|
|
|
if (!term)
|
|
|
|
{
|
2015-02-23 13:51:33 -08:00
|
|
|
CRITICAL(_("Could not create terminal widget."));
|
2014-10-26 13:00:14 -07:00
|
|
|
win_free(wn);
|
2013-01-02 23:50:54 -08:00
|
|
|
ecore_app_args_set(pargc, (const char **)pargv);
|
|
|
|
free(nargv);
|
2012-12-27 03:20:32 -08:00
|
|
|
return;
|
|
|
|
}
|
2014-10-26 13:00:14 -07:00
|
|
|
|
2015-03-22 10:17:16 -07:00
|
|
|
if (win_term_set(wn, term) < 0)
|
|
|
|
return;
|
2014-10-26 13:00:14 -07:00
|
|
|
|
2020-04-05 13:59:46 -07:00
|
|
|
main_trans_update();
|
2014-10-26 13:00:14 -07:00
|
|
|
main_media_update(config);
|
2012-12-27 03:20:32 -08:00
|
|
|
if (inst->pos)
|
|
|
|
{
|
|
|
|
int screen_w, screen_h;
|
2014-10-26 13:00:14 -07:00
|
|
|
|
|
|
|
elm_win_screen_size_get(win, NULL, NULL, &screen_w, &screen_h);
|
2012-12-27 03:20:32 -08:00
|
|
|
if (inst->x < 0) inst->x = screen_w + inst->x;
|
|
|
|
if (inst->y < 0) inst->y = screen_h + inst->y;
|
2014-10-26 13:00:14 -07:00
|
|
|
evas_object_move(win, inst->x, inst->y);
|
2012-12-27 03:20:32 -08:00
|
|
|
}
|
2014-10-26 13:00:14 -07:00
|
|
|
win_sizing_handle(wn);
|
|
|
|
evas_object_show(win_evas_object_get(wn));
|
2012-12-27 03:20:32 -08:00
|
|
|
if (inst->nowm)
|
|
|
|
ecore_evas_focus_set
|
2014-10-26 13:00:14 -07:00
|
|
|
(ecore_evas_ecore_evas_get(evas_object_evas_get(win)), 1);
|
2013-01-02 23:50:54 -08:00
|
|
|
ecore_app_args_set(pargc, (const char **)pargv);
|
|
|
|
free(nargv);
|
2019-10-14 14:10:08 -07:00
|
|
|
unsetenv("DESKTOP_STARTUP_ID");
|
2012-06-17 02:26:01 -07:00
|
|
|
}
|
|
|
|
|
2014-07-20 13:35:28 -07:00
|
|
|
static Ecore_Getopt options = {
|
2012-06-17 09:03:46 -07:00
|
|
|
PACKAGE_NAME,
|
|
|
|
"%prog [options]",
|
|
|
|
PACKAGE_VERSION,
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("(C) 2012-%d Carsten Haitzler and others"),
|
2012-06-18 07:22:15 -07:00
|
|
|
"BSD 2-Clause",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Terminal emulator written with Enlightenment Foundation Libraries."),
|
2012-06-17 09:03:46 -07:00
|
|
|
EINA_TRUE,
|
|
|
|
{
|
2012-12-10 13:52:39 -08:00
|
|
|
ECORE_GETOPT_BREAK_STR ('e', "exec",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Command to execute. Defaults to $SHELL (or passwd shell or /bin/sh)")),
|
2012-08-05 17:06:13 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('d', "current-directory",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Change to directory for execution of terminal command.")),
|
2012-07-05 03:04:39 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('t', "theme",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Use the named edje theme or path to theme file.")),
|
2012-07-05 03:04:39 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('b', "background",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Use the named file as a background wallpaper.")),
|
2012-07-05 03:04:39 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('g', "geometry",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Terminal geometry to use (eg 80x24 or 80x24+50+20 etc.).")),
|
2012-07-05 03:04:39 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('n', "name",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Set window name.")),
|
2012-07-05 03:04:39 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('r', "role",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Set window role.")),
|
2012-07-05 03:04:39 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('T', "title",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Set window title.")),
|
2012-07-05 03:04:39 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('i', "icon-name",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Set icon name.")),
|
2012-08-05 02:38:58 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('f', "font",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Set font (NAME/SIZE for scalable, NAME for bitmap.")),
|
2014-08-09 02:46:47 -07:00
|
|
|
ECORE_GETOPT_STORE_STR ('S', "split",
|
|
|
|
gettext_noop("Split the terminal window."
|
|
|
|
" 'v' for vertical and 'h' for horizontal."
|
|
|
|
" Can be used multiple times. eg -S vhvv or --split hv"
|
|
|
|
" More description available on the man page.")),
|
2012-09-27 02:33:33 -07:00
|
|
|
ECORE_GETOPT_STORE_BOOL('l', "login",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Run the shell as a login shell.")),
|
2012-07-02 05:06:44 -07:00
|
|
|
ECORE_GETOPT_STORE_BOOL('m', "video-mute",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Set mute mode for video playback.")),
|
2012-08-05 02:38:58 -07:00
|
|
|
ECORE_GETOPT_STORE_BOOL('c', "cursor-blink",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Set cursor blink mode.")),
|
2012-08-05 17:06:13 -07:00
|
|
|
ECORE_GETOPT_STORE_BOOL('G', "visual-bell",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Set visual bell mode.")),
|
2012-07-05 08:11:30 -07:00
|
|
|
ECORE_GETOPT_STORE_TRUE('F', "fullscreen",
|
2014-07-22 14:38:03 -07:00
|
|
|
gettext_noop("Go into the fullscreen mode from the start.")),
|
2012-07-05 08:11:30 -07:00
|
|
|
ECORE_GETOPT_STORE_TRUE('I', "iconic",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Go into an iconic state from the start.")),
|
2012-07-05 08:11:30 -07:00
|
|
|
ECORE_GETOPT_STORE_TRUE('B', "borderless",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Become a borderless managed window.")),
|
2012-07-05 08:11:30 -07:00
|
|
|
ECORE_GETOPT_STORE_TRUE('O', "override",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Become an override-redirect window.")),
|
2012-07-05 08:11:30 -07:00
|
|
|
ECORE_GETOPT_STORE_TRUE('M', "maximized",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Become maximized from the start.")),
|
2012-07-05 12:19:21 -07:00
|
|
|
ECORE_GETOPT_STORE_TRUE('W', "nowm",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Terminology is run without a window manager.")),
|
2012-08-05 02:38:58 -07:00
|
|
|
ECORE_GETOPT_STORE_TRUE('H', "hold",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Do not exit when the command process exits.")),
|
2012-12-27 03:20:32 -08:00
|
|
|
ECORE_GETOPT_STORE_TRUE('s', "single",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Force single executable if multi-instance is enabled.")),
|
2013-06-16 14:07:58 -07:00
|
|
|
ECORE_GETOPT_STORE_TRUE('2', "256color",
|
2014-07-20 13:35:28 -07:00
|
|
|
gettext_noop("Set TERM to 'xterm-256color' instead of 'xterm'.")),
|
2020-02-15 08:31:10 -08:00
|
|
|
ECORE_GETOPT_STORE_DOUBLE('\0', "scale",
|
|
|
|
gettext_noop("Set scaling factor.")),
|
2014-04-11 12:29:26 -07:00
|
|
|
ECORE_GETOPT_STORE_BOOL('\0', "active-links",
|
2014-07-22 14:38:03 -07:00
|
|
|
gettext_noop("Highlight links.")),
|
2019-12-08 08:02:02 -08:00
|
|
|
ECORE_GETOPT_STORE_BOOL('\0', "no-wizard",
|
|
|
|
gettext_noop("Do not display wizard on start up.")),
|
2013-06-16 14:07:58 -07:00
|
|
|
|
2014-07-22 14:38:03 -07:00
|
|
|
ECORE_GETOPT_VERSION ('V', "version"),
|
|
|
|
ECORE_GETOPT_COPYRIGHT ('C', "copyright"),
|
|
|
|
ECORE_GETOPT_LICENSE ('L', "license"),
|
|
|
|
ECORE_GETOPT_HELP ('h', "help"),
|
2012-06-17 09:03:46 -07:00
|
|
|
ECORE_GETOPT_SENTINEL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-07 15:06:51 -07:00
|
|
|
#if ENABLE_NLS
|
2014-07-20 13:35:28 -07:00
|
|
|
static void
|
|
|
|
_translate_options(void)
|
|
|
|
{
|
|
|
|
options.copyright = eina_stringshare_printf(gettext(options.copyright),
|
2019-01-23 12:26:54 -08:00
|
|
|
2019);
|
2014-07-20 13:35:28 -07:00
|
|
|
|
|
|
|
Ecore_Getopt_Desc *desc = (Ecore_Getopt_Desc *) options.descs;
|
2018-02-12 22:12:18 -08:00
|
|
|
while ((desc->shortname != '\0') || (desc->longname) ||
|
|
|
|
(desc->action == ECORE_GETOPT_ACTION_CATEGORY))
|
2014-07-20 13:35:28 -07:00
|
|
|
{
|
2014-07-22 14:38:03 -07:00
|
|
|
if (desc->help)
|
|
|
|
{
|
|
|
|
switch (desc->action)
|
|
|
|
{
|
|
|
|
case ECORE_GETOPT_ACTION_VERSION:
|
|
|
|
desc->help = _("show program version.");
|
|
|
|
break;
|
|
|
|
case ECORE_GETOPT_ACTION_COPYRIGHT:
|
|
|
|
desc->help = _("show copyright.");
|
|
|
|
break;
|
|
|
|
case ECORE_GETOPT_ACTION_LICENSE:
|
|
|
|
desc->help = _("show license.");
|
|
|
|
break;
|
|
|
|
case ECORE_GETOPT_ACTION_HELP:
|
|
|
|
desc->help = _("show this message.");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
desc->help = gettext(desc->help);
|
|
|
|
}
|
|
|
|
}
|
2014-07-20 13:35:28 -07:00
|
|
|
desc++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-11-20 14:03:21 -08:00
|
|
|
#if defined(ENABLE_FUZZING) || defined(ENABLE_TESTS)
|
2017-09-08 15:13:31 -07:00
|
|
|
static void
|
|
|
|
_log_void(const Eina_Log_Domain *_d EINA_UNUSED,
|
|
|
|
Eina_Log_Level level EINA_UNUSED,
|
|
|
|
const char *_file EINA_UNUSED,
|
|
|
|
const char *_fnc EINA_UNUSED,
|
|
|
|
int _line EINA_UNUSED,
|
|
|
|
const char *fmt EINA_UNUSED,
|
|
|
|
void *_data EINA_UNUSED,
|
|
|
|
va_list args EINA_UNUSED)
|
|
|
|
{
|
|
|
|
}
|
2015-10-25 15:07:42 -07:00
|
|
|
#endif
|
|
|
|
|
2019-10-13 12:11:01 -07:00
|
|
|
static void
|
2019-12-08 07:46:49 -08:00
|
|
|
_start(Ipc_Instance *instance, Eina_Bool need_scale_wizard)
|
2019-10-13 12:11:01 -07:00
|
|
|
{
|
|
|
|
Win *wn;
|
|
|
|
Evas_Object *win;
|
|
|
|
Term *term;
|
|
|
|
Config *config;
|
|
|
|
|
|
|
|
wn = win_new(instance->name, instance->role, instance->title,
|
|
|
|
instance->icon_name, instance->config,
|
|
|
|
instance->fullscreen, instance->iconic, instance->borderless,
|
|
|
|
instance->override, instance->maximized);
|
|
|
|
// set an env so terminal apps can detect they are in terminology :)
|
|
|
|
putenv("TERMINOLOGY=1");
|
|
|
|
|
|
|
|
config_del(instance->config);
|
|
|
|
config = NULL;
|
|
|
|
if (!wn)
|
|
|
|
{
|
|
|
|
CRITICAL(_("Could not create window."));
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
config = win_config_get(wn);
|
|
|
|
|
|
|
|
term = term_new(wn, config, instance->cmd, instance->login_shell,
|
|
|
|
instance->cd,
|
|
|
|
instance->w, instance->h, instance->hold, instance->title);
|
|
|
|
if (!term)
|
|
|
|
{
|
|
|
|
CRITICAL(_("Could not create terminal widget."));
|
|
|
|
config = NULL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (win_term_set(wn, term) < 0)
|
|
|
|
{
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2020-04-05 13:59:46 -07:00
|
|
|
main_trans_update();
|
2019-10-13 12:11:01 -07:00
|
|
|
main_media_update(config);
|
|
|
|
win_sizing_handle(wn);
|
|
|
|
win = win_evas_object_get(wn);
|
|
|
|
evas_object_show(win);
|
|
|
|
if (instance->startup_split)
|
|
|
|
{
|
|
|
|
unsigned int i = 0;
|
|
|
|
Term *next = term;
|
|
|
|
|
|
|
|
for (i = 0; i < strlen(instance->startup_split); i++)
|
|
|
|
{
|
|
|
|
char *cmd = NULL;
|
|
|
|
|
|
|
|
if (instance->startup_split[i] == 'v')
|
|
|
|
{
|
2020-02-09 14:10:39 -08:00
|
|
|
cmd = eina_list_data_get(instance->cmds);
|
2020-04-06 14:11:10 -07:00
|
|
|
split_vertically(term_termio_get(next), cmd);
|
2020-02-09 14:10:39 -08:00
|
|
|
instance->cmds = eina_list_remove_list(instance->cmds,
|
|
|
|
instance->cmds);
|
2019-10-13 12:11:01 -07:00
|
|
|
}
|
|
|
|
else if (instance->startup_split[i] == 'h')
|
|
|
|
{
|
2020-02-09 14:10:39 -08:00
|
|
|
cmd = eina_list_data_get(instance->cmds);
|
2020-04-06 14:11:10 -07:00
|
|
|
split_horizontally(term_termio_get(next), cmd);
|
2020-02-09 14:10:39 -08:00
|
|
|
instance->cmds = eina_list_remove_list(instance->cmds,
|
|
|
|
instance->cmds);
|
2019-10-13 12:11:01 -07:00
|
|
|
}
|
|
|
|
else if (instance->startup_split[i] == '-')
|
|
|
|
next = term_next_get(next);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CRITICAL(_("invalid argument found for option -S/--split."
|
|
|
|
" See --help."));
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (instance->pos)
|
|
|
|
{
|
|
|
|
int screen_w, screen_h;
|
|
|
|
|
|
|
|
elm_win_screen_size_get(win, NULL, NULL, &screen_w, &screen_h);
|
|
|
|
if (instance->x < 0) instance->x = screen_w + instance->x;
|
|
|
|
if (instance->y < 0) instance->y = screen_h + instance->y;
|
|
|
|
evas_object_move(win, instance->x, instance->y);
|
|
|
|
}
|
|
|
|
if (instance->nowm)
|
|
|
|
ecore_evas_focus_set(ecore_evas_ecore_evas_get(
|
|
|
|
evas_object_evas_get(win)), 1);
|
|
|
|
|
|
|
|
controls_init();
|
|
|
|
|
2019-12-08 07:46:49 -08:00
|
|
|
if (need_scale_wizard)
|
|
|
|
win_scale_wizard(win, term);
|
2019-10-13 12:11:01 -07:00
|
|
|
|
|
|
|
terminology_starting_up = EINA_FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
end:
|
|
|
|
return;
|
|
|
|
exit:
|
|
|
|
ecore_main_loop_quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Instance_Add {
|
|
|
|
Ipc_Instance *instance;
|
|
|
|
char **argv;
|
|
|
|
Eina_Bool result;
|
|
|
|
Eina_Bool timedout;
|
|
|
|
Eina_Bool done;
|
|
|
|
pthread_mutex_t lock;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
_instance_add_free(struct Instance_Add *add)
|
|
|
|
{
|
|
|
|
if (!add)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pthread_mutex_destroy(&add->lock);
|
|
|
|
free(add);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
|
|
|
_instance_sleep(void *data)
|
|
|
|
{
|
|
|
|
struct Instance_Add *add = data;
|
|
|
|
Eina_Bool timedout = EINA_FALSE;
|
|
|
|
|
|
|
|
sleep(2);
|
|
|
|
pthread_mutex_lock(&add->lock);
|
|
|
|
if (!add->done)
|
|
|
|
timedout = add->timedout = EINA_TRUE;
|
|
|
|
pthread_mutex_unlock(&add->lock);
|
|
|
|
if (timedout)
|
|
|
|
{
|
|
|
|
/* ok, we waited 2 seconds without any answer,
|
|
|
|
* remove the unix socket and restart terminology from scratch in a
|
|
|
|
* better state */
|
|
|
|
ipc_instance_conn_free();
|
2019-10-14 13:14:32 -07:00
|
|
|
errno = 0;
|
|
|
|
execv(add->argv[0], add->argv);
|
|
|
|
ERR("execv failed on '%s': %s", add->argv[0], strerror(errno));
|
2019-10-13 12:11:01 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_instance_add_free(add);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_instance_add_waiter(Ipc_Instance *instance,
|
|
|
|
char **argv)
|
|
|
|
{
|
|
|
|
struct Instance_Add *add;
|
|
|
|
Eina_Bool timedout = EINA_FALSE;
|
|
|
|
Eina_Bool result = EINA_TRUE;
|
|
|
|
pthread_t thr;
|
|
|
|
|
|
|
|
add = calloc(1, sizeof(*add));
|
|
|
|
if (!add)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
add->instance = instance;
|
|
|
|
add->argv = argv;
|
|
|
|
pthread_mutex_init(&add->lock, NULL);
|
|
|
|
|
|
|
|
pthread_create(&thr, NULL, &_instance_sleep, add);
|
|
|
|
|
|
|
|
/* If the unix socket is stalled, this might block */
|
|
|
|
result = ipc_instance_add(add->instance);
|
|
|
|
pthread_mutex_lock(&add->lock);
|
|
|
|
/* Hoora, it did not block! */
|
|
|
|
add->done = EINA_TRUE;
|
|
|
|
if (add->timedout)
|
|
|
|
{
|
|
|
|
timedout = add->timedout = EINA_TRUE;
|
|
|
|
result = EINA_FALSE;
|
|
|
|
}
|
|
|
|
pthread_mutex_unlock(&add->lock);
|
|
|
|
if (timedout)
|
|
|
|
_instance_add_free(add);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_start_multi(Ipc_Instance *instance,
|
2019-12-08 07:46:49 -08:00
|
|
|
char **argv,
|
|
|
|
Eina_Bool need_scale_wizard)
|
2019-10-13 12:11:01 -07:00
|
|
|
{
|
|
|
|
int remote_try = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (_instance_add_waiter(instance, argv))
|
|
|
|
{
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
/* Could not start a new window remotely,
|
|
|
|
* let's start our own server */
|
|
|
|
ipc_instance_new_func_set(main_ipc_new);
|
|
|
|
if (ipc_serve())
|
|
|
|
{
|
|
|
|
goto normal_start;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG("IPC server: failure");
|
|
|
|
}
|
|
|
|
remote_try++;
|
|
|
|
}
|
|
|
|
while (remote_try <= 1);
|
|
|
|
|
|
|
|
normal_start:
|
2019-12-08 07:46:49 -08:00
|
|
|
_start(instance, need_scale_wizard);
|
2019-10-13 12:11:01 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
EAPI_MAIN int
|
|
|
|
elm_main(int argc, char **argv)
|
|
|
|
{
|
2012-07-02 05:06:44 -07:00
|
|
|
char *geometry = NULL;
|
2012-06-17 09:03:46 -07:00
|
|
|
Eina_Bool quit_option = EINA_FALSE;
|
2012-12-27 03:20:32 -08:00
|
|
|
Eina_Bool single = EINA_FALSE;
|
2019-12-08 08:02:02 -08:00
|
|
|
Eina_Bool no_wizard = EINA_FALSE;
|
2012-12-10 13:52:39 -08:00
|
|
|
Eina_Bool cmd_options = EINA_FALSE;
|
2020-02-16 05:11:46 -08:00
|
|
|
double scale = -1.0; /* unset */
|
2019-10-13 12:11:01 -07:00
|
|
|
Ipc_Instance instance = {
|
|
|
|
.login_shell = 0xff, /* unset */
|
|
|
|
.active_links = 0xff, /* unset */
|
2019-10-20 09:16:10 -07:00
|
|
|
.video_mute = 0xff, /* unset */
|
|
|
|
.cursor_blink = 0xff, /* unset */
|
|
|
|
.visual_bell = 0xff, /* unset */
|
2019-10-13 12:11:01 -07:00
|
|
|
.startup_id = getenv("DESKTOP_STARTUP_ID"),
|
|
|
|
.w = 1,
|
|
|
|
.h = 1,
|
|
|
|
};
|
2012-06-17 09:03:46 -07:00
|
|
|
Ecore_Getopt_Value values[] = {
|
2012-12-10 13:52:39 -08:00
|
|
|
ECORE_GETOPT_VALUE_BOOL(cmd_options),
|
2019-10-13 12:11:01 -07:00
|
|
|
ECORE_GETOPT_VALUE_STR(instance.cd),
|
2019-10-19 01:57:57 -07:00
|
|
|
ECORE_GETOPT_VALUE_STR(instance.theme),
|
2019-10-13 12:11:01 -07:00
|
|
|
ECORE_GETOPT_VALUE_STR(instance.background),
|
2012-07-02 05:06:44 -07:00
|
|
|
ECORE_GETOPT_VALUE_STR(geometry),
|
2019-10-13 12:11:01 -07:00
|
|
|
ECORE_GETOPT_VALUE_STR(instance.name),
|
|
|
|
ECORE_GETOPT_VALUE_STR(instance.role),
|
|
|
|
ECORE_GETOPT_VALUE_STR(instance.title),
|
|
|
|
ECORE_GETOPT_VALUE_STR(instance.icon_name),
|
|
|
|
ECORE_GETOPT_VALUE_STR(instance.font),
|
|
|
|
ECORE_GETOPT_VALUE_STR(instance.startup_split),
|
2014-04-11 12:29:26 -07:00
|
|
|
|
2019-10-13 12:11:01 -07:00
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.login_shell),
|
2019-10-20 09:16:10 -07:00
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.video_mute),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.cursor_blink),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.visual_bell),
|
2019-10-13 12:11:01 -07:00
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.fullscreen),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.iconic),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.borderless),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.override),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.maximized),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.nowm),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.hold),
|
2012-12-27 03:20:32 -08:00
|
|
|
ECORE_GETOPT_VALUE_BOOL(single),
|
2019-10-20 09:16:10 -07:00
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.xterm_256color),
|
2020-02-15 08:31:10 -08:00
|
|
|
ECORE_GETOPT_VALUE_DOUBLE(scale),
|
2019-10-13 12:11:01 -07:00
|
|
|
ECORE_GETOPT_VALUE_BOOL(instance.active_links),
|
2019-12-08 08:02:02 -08:00
|
|
|
ECORE_GETOPT_VALUE_BOOL(no_wizard),
|
2013-06-16 14:07:58 -07:00
|
|
|
|
2012-06-17 09:03:46 -07:00
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
2014-04-11 12:29:26 -07:00
|
|
|
|
2012-06-17 09:03:46 -07:00
|
|
|
ECORE_GETOPT_VALUE_NONE
|
|
|
|
};
|
2012-12-28 19:05:01 -08:00
|
|
|
int args, retval = EXIT_SUCCESS;
|
2019-10-13 12:11:01 -07:00
|
|
|
Eina_Bool size_set = EINA_FALSE;
|
2019-12-08 07:46:49 -08:00
|
|
|
Eina_Bool need_scale_wizard = utils_need_scale_wizard();
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2015-09-26 03:01:42 -07:00
|
|
|
terminology_starting_up = EINA_TRUE;
|
|
|
|
|
2018-11-20 14:03:21 -08:00
|
|
|
#if defined(ENABLE_FUZZING) || defined(ENABLE_TESTS)
|
2017-09-08 15:13:31 -07:00
|
|
|
eina_log_print_cb_set(_log_void, NULL);
|
2015-10-25 15:07:42 -07:00
|
|
|
#endif
|
|
|
|
|
2018-04-30 07:01:46 -07:00
|
|
|
elm_config_item_select_on_focus_disabled_set(EINA_TRUE);
|
|
|
|
|
2014-07-12 07:15:39 -07:00
|
|
|
elm_language_set("");
|
2014-09-18 05:52:21 -07:00
|
|
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
|
|
|
elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
|
|
|
|
elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR);
|
|
|
|
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
|
2019-07-07 15:06:51 -07:00
|
|
|
#if ENABLE_NLS
|
2014-09-18 05:52:21 -07:00
|
|
|
elm_app_compile_locale_set(LOCALEDIR);
|
2014-09-19 06:31:55 -07:00
|
|
|
#endif
|
2014-09-18 05:52:21 -07:00
|
|
|
elm_app_info_set(elm_main, "terminology", "themes/default.edj");
|
|
|
|
|
2019-07-07 15:06:51 -07:00
|
|
|
#if ENABLE_NLS
|
2014-09-18 05:52:21 -07:00
|
|
|
bindtextdomain(PACKAGE, elm_app_locale_dir_get());
|
2014-07-12 07:15:39 -07:00
|
|
|
textdomain(PACKAGE);
|
2014-07-20 13:35:28 -07:00
|
|
|
_translate_options();
|
|
|
|
#else
|
2019-01-23 12:26:54 -08:00
|
|
|
options.copyright = "(C) 2012-2019 Carsten Haitzler and others";
|
2014-07-12 07:15:39 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-17 09:32:23 -07:00
|
|
|
_log_domain = eina_log_domain_register("terminology", NULL);
|
|
|
|
if (_log_domain < 0)
|
|
|
|
{
|
2014-07-20 13:35:28 -07:00
|
|
|
EINA_LOG_CRIT(_("Could not create logging domain '%s'."), "terminology");
|
2012-06-17 09:32:23 -07:00
|
|
|
elm_shutdown();
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2013-03-24 03:56:01 -07:00
|
|
|
config_init();
|
2014-08-24 08:53:18 -07:00
|
|
|
|
2019-09-08 10:41:16 -07:00
|
|
|
_main_config = config_load();
|
2014-10-26 13:00:14 -07:00
|
|
|
if (key_bindings_load(_main_config) < 0)
|
2014-08-23 08:01:20 -07:00
|
|
|
{
|
2015-02-23 13:51:33 -08:00
|
|
|
CRITICAL(_("Could not initialize key bindings."));
|
2014-08-23 08:01:20 -07:00
|
|
|
retval = EXIT_FAILURE;
|
|
|
|
goto end;
|
|
|
|
}
|
2013-03-24 03:56:01 -07:00
|
|
|
|
2019-10-13 12:11:01 -07:00
|
|
|
ecore_con_init();
|
|
|
|
ecore_con_url_init();
|
|
|
|
|
2013-04-18 21:56:21 -07:00
|
|
|
ipc_init();
|
|
|
|
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.config = config_fork(_main_config);
|
2013-03-24 03:56:01 -07:00
|
|
|
|
2012-06-17 09:03:46 -07:00
|
|
|
args = ecore_getopt_parse(&options, values, argc, argv);
|
|
|
|
if (args < 0)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2015-02-23 13:51:33 -08:00
|
|
|
CRITICAL(_("Could not parse command line options."));
|
2012-06-17 09:03:46 -07:00
|
|
|
retval = EXIT_FAILURE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2020-02-16 05:11:46 -08:00
|
|
|
if (scale > 0.0)
|
2020-02-15 08:31:10 -08:00
|
|
|
{
|
|
|
|
elm_config_scale_set(scale);
|
|
|
|
elm_config_all_flush();
|
|
|
|
instance.config->temporary = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2019-12-08 08:02:02 -08:00
|
|
|
if (no_wizard)
|
|
|
|
need_scale_wizard = EINA_FALSE;
|
|
|
|
|
|
|
|
if (quit_option)
|
|
|
|
goto end;
|
2012-06-17 09:03:46 -07:00
|
|
|
|
2012-12-10 13:52:39 -08:00
|
|
|
if (cmd_options)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (args == argc)
|
|
|
|
{
|
2015-02-23 13:51:33 -08:00
|
|
|
CRITICAL(_("option %s requires an argument!"), argv[args-1]);
|
|
|
|
CRITICAL(_("invalid options found. See --help."));
|
2012-12-10 13:52:39 -08:00
|
|
|
goto end;
|
|
|
|
}
|
2014-07-20 13:35:28 -07:00
|
|
|
|
2019-10-13 12:11:01 -07:00
|
|
|
if (instance.startup_split)
|
2012-12-10 13:52:39 -08:00
|
|
|
{
|
2015-11-19 11:20:03 -08:00
|
|
|
for(i = args+1; i < argc; i++)
|
2020-02-09 14:10:39 -08:00
|
|
|
instance.cmds = eina_list_append(instance.cmds, argv[i]);
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.cmd = argv[args];
|
2015-11-19 11:20:03 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Eina_Strbuf *strb;
|
|
|
|
strb = eina_strbuf_new();
|
2017-08-26 10:26:29 -07:00
|
|
|
eina_strbuf_append(strb, argv[args]);
|
2017-10-10 12:14:07 -07:00
|
|
|
for(i = args+1; i < argc; i++)
|
2015-11-19 11:20:03 -08:00
|
|
|
{
|
|
|
|
eina_strbuf_append_char(strb, ' ');
|
2017-08-26 10:26:29 -07:00
|
|
|
eina_strbuf_append(strb, argv[i]);
|
2015-11-19 11:20:03 -08:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.cmd = eina_strbuf_string_steal(strb);
|
2015-11-19 11:20:03 -08:00
|
|
|
eina_strbuf_free(strb);
|
2012-12-10 13:52:39 -08:00
|
|
|
}
|
|
|
|
}
|
2018-02-12 22:12:18 -08:00
|
|
|
|
2018-08-15 10:40:06 -07:00
|
|
|
_check_multisense();
|
|
|
|
|
2019-10-20 09:16:10 -07:00
|
|
|
_configure_instance(&instance);
|
2015-08-02 09:37:25 -07:00
|
|
|
|
2012-08-05 02:38:58 -07:00
|
|
|
|
2012-07-02 05:06:44 -07:00
|
|
|
if (geometry)
|
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
if (sscanf(geometry,"%ix%i+%i+%i", &instance.w, &instance.h,
|
|
|
|
&instance.x, &instance.y) == 4)
|
2012-07-02 05:06:44 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.pos = EINA_TRUE;
|
|
|
|
size_set = EINA_TRUE;
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
else if (sscanf(geometry,"%ix%i-%i+%i", &instance.w, &instance.h,
|
|
|
|
&instance.x, &instance.y) == 4)
|
2012-07-02 05:06:44 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.x = -instance.x;
|
|
|
|
instance.pos = EINA_TRUE;
|
|
|
|
size_set = EINA_TRUE;
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
else if (sscanf(geometry,"%ix%i-%i-%i", &instance.w, &instance.h,
|
|
|
|
&instance.x, &instance.y) == 4)
|
2012-07-02 05:06:44 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.x = -instance.x;
|
|
|
|
instance.y = -instance.y;
|
|
|
|
instance.pos = EINA_TRUE;
|
|
|
|
size_set = EINA_TRUE;
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
else if (sscanf(geometry,"%ix%i+%i-%i", &instance.w, &instance.h,
|
|
|
|
&instance.x, &instance.y) == 4)
|
2012-07-02 05:06:44 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.y = -instance.y;
|
|
|
|
instance.pos = EINA_TRUE;
|
|
|
|
size_set = EINA_TRUE;
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
else if (sscanf(geometry,"%ix%i", &instance.w, &instance.h) == 2)
|
2012-07-02 05:06:44 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
size_set = EINA_TRUE;
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
else if (sscanf(geometry,"+%i+%i", &instance.x, &instance.y) == 2)
|
2012-07-02 05:06:44 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.pos = EINA_TRUE;
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
else if (sscanf(geometry,"-%i+%i", &instance.x, &instance.y) == 2)
|
2012-07-02 05:06:44 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.x = -instance.x;
|
|
|
|
instance.pos = EINA_TRUE;
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
else if (sscanf(geometry,"+%i-%i", &instance.x, &instance.y) == 2)
|
2012-07-02 05:06:44 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.y = -instance.y;
|
|
|
|
instance.pos = EINA_TRUE;
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
else if (sscanf(geometry,"-%i-%i", &instance.x, &instance.y) == 2)
|
2012-07-02 05:06:44 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.x = -instance.x;
|
|
|
|
instance.y = -instance.y;
|
|
|
|
instance.pos = EINA_TRUE;
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
|
|
|
}
|
2019-09-08 10:28:52 -07:00
|
|
|
|
2012-07-02 05:06:44 -07:00
|
|
|
if (!size_set)
|
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
if (instance.config->custom_geometry)
|
2013-04-17 12:59:20 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.w = instance.config->cg_width;
|
|
|
|
instance.h = instance.config->cg_height;
|
2013-04-17 12:59:20 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.w = 80;
|
|
|
|
instance.h = 24;
|
2013-04-17 12:59:20 -07:00
|
|
|
}
|
2012-07-02 05:06:44 -07:00
|
|
|
}
|
2014-01-12 10:08:38 -08:00
|
|
|
|
2019-10-13 12:11:01 -07:00
|
|
|
elm_theme_overlay_add(NULL,
|
|
|
|
config_theme_path_default_get(instance.config));
|
|
|
|
elm_theme_overlay_add(NULL, config_theme_path_get(instance.config));
|
2014-06-30 13:38:13 -07:00
|
|
|
|
2019-10-13 12:11:01 -07:00
|
|
|
if ((!single) && (instance.config->multi_instance))
|
2012-12-27 03:20:32 -08:00
|
|
|
{
|
|
|
|
char cwdbuf[4096];
|
2019-09-08 10:28:52 -07:00
|
|
|
|
2019-10-13 12:11:01 -07:00
|
|
|
if (!instance.cd)
|
|
|
|
instance.cd = getcwd(cwdbuf, sizeof(cwdbuf));
|
2019-12-08 07:46:49 -08:00
|
|
|
if (_start_multi(&instance, argv, need_scale_wizard))
|
2013-01-15 13:58:18 -08:00
|
|
|
goto end;
|
2012-12-27 03:20:32 -08:00
|
|
|
}
|
2019-10-13 12:11:01 -07:00
|
|
|
else
|
2012-12-27 03:20:32 -08:00
|
|
|
{
|
2019-12-08 07:46:49 -08:00
|
|
|
_start(&instance, need_scale_wizard);
|
2012-12-27 03:20:32 -08:00
|
|
|
}
|
2012-06-12 03:10:01 -07:00
|
|
|
elm_run();
|
2013-07-30 02:52:40 -07:00
|
|
|
|
2015-02-15 09:03:40 -08:00
|
|
|
ecore_con_url_shutdown();
|
|
|
|
ecore_con_shutdown();
|
|
|
|
|
2019-10-13 12:11:01 -07:00
|
|
|
instance.config = NULL;
|
2012-06-17 09:03:46 -07:00
|
|
|
end:
|
2019-10-13 12:11:01 -07:00
|
|
|
if (instance.config)
|
2014-07-10 01:04:23 -07:00
|
|
|
{
|
2019-10-13 12:11:01 -07:00
|
|
|
config_del(instance.config);
|
|
|
|
instance.config = NULL;
|
2014-07-10 01:04:23 -07:00
|
|
|
}
|
2012-06-17 09:32:23 -07:00
|
|
|
|
2012-12-27 03:20:32 -08:00
|
|
|
ipc_shutdown();
|
2012-07-04 21:36:47 -07:00
|
|
|
|
2013-01-26 14:22:39 -08:00
|
|
|
termpty_shutdown();
|
2014-03-30 11:38:49 -07:00
|
|
|
miniview_shutdown();
|
2014-10-05 12:00:14 -07:00
|
|
|
gravatar_shutdown();
|
2014-03-30 11:38:49 -07:00
|
|
|
|
2014-10-26 13:00:14 -07:00
|
|
|
windows_free();
|
2013-01-26 14:22:39 -08:00
|
|
|
|
2014-10-26 13:00:14 -07:00
|
|
|
config_del(_main_config);
|
2014-08-23 08:01:20 -07:00
|
|
|
key_bindings_shutdown();
|
2012-12-27 03:20:32 -08:00
|
|
|
config_shutdown();
|
2018-01-01 15:09:14 -08:00
|
|
|
controls_shutdown();
|
2012-06-17 09:32:23 -07:00
|
|
|
eina_log_domain_unregister(_log_domain);
|
|
|
|
_log_domain = -1;
|
|
|
|
|
2018-01-01 15:09:14 -08:00
|
|
|
|
2019-07-07 15:06:51 -07:00
|
|
|
#if ENABLE_NLS
|
2014-07-20 13:35:28 -07:00
|
|
|
eina_stringshare_del(options.copyright);
|
|
|
|
#endif
|
2014-07-27 10:59:37 -07:00
|
|
|
|
|
|
|
elm_shutdown();
|
|
|
|
|
2012-06-17 09:03:46 -07:00
|
|
|
return retval;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
ELM_MAIN()
|